14#ifndef LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
15#define LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
22#include "llvm/ADT/DenseMap.h"
23#include "llvm/ADT/PointerIntPair.h"
24#include "llvm/ADT/PointerUnion.h"
29class DependentDiagnostic;
38 using DeclsAndHasExternalTy = llvm::PointerIntPair<Decls, 1, bool>;
43 DeclsAndHasExternalTy Data;
46 Decls List =
Data.getPointer();
60 NewTail = &
Node->Rest;
67 C.DeallocateDeclListNode(N);
75 C.DeallocateDeclListNode(
Node);
80 Data.setPointer(NewHead);
82 assert(llvm::none_of(
getLookupResult(), ShouldErase) &&
"Still exists!");
84 if (!
Data.getPointer())
91 assert(NewLast && NewLast->is<
NamedDecl *>() &&
"Not the tail?");
104 RHS.Data.setPointer(
nullptr);
105 RHS.Data.setInt(
false);
113 Decls List =
Data.getPointer();
115 List = ToDealloc->Rest;
116 C.DeallocateDeclListNode(ToDealloc);
128 RHS.Data.setPointer(
nullptr);
129 RHS.Data.setInt(
false);
136 assert(!
isNull() &&
"No ASTContext.");
161 assert(!
isNull() &&
"removing from empty list");
184 D->declarationReplaces(ND,
false))
198 for (
size_t I = Decls.size() - 1; I != 0; --I) {
200 Node->Rest = DeclsAsList;
204 if (!
Data.getPointer()) {
205 Data.setPointer(DeclsAsList);
211 Node->Rest = DeclsAsList;
223 const bool IsKnownNewer =
true;
232 if (
D->declarationReplaces(OldD, IsKnownNewer)) {
251 if (
D->declarationReplaces(N->D, IsKnownNewer)) {
255 if (
auto *ND = N->Rest.dyn_cast<
NamedDecl *>()) {
256 if (
D->declarationReplaces(ND, IsKnownNewer)) {
284 LLVM_DUMP_METHOD
void dump()
const {
285 Decls
D =
Data.getPointer();
287 llvm::errs() <<
"<null>\n";
293 llvm::errs() <<
'[' <<
Node->D <<
"] -> ";
296 llvm::errs() <<
'[' <<
D.get<
NamedDecl*>() <<
"]\n";
304 :
public llvm::SmallDenseMap<DeclarationName, StoredDeclsList, 4> {
308 llvm::PointerIntPair<StoredDeclsMap*, 1>
Previous;
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContextLookupResult lookup_result
A list storing NamedDecls in the lookup tables.
llvm::PointerUnion< NamedDecl *, DeclListNode * > Decls
ASTContext & getASTContext() const LLVM_READONLY
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
A dependently-generated diagnostic.
DependentStoredDeclsMap()=default
This represents a decl that may have a name.
An array of decls optimized for the common case of only containing one entry.
void setHasExternalDecls()
DeclsAndHasExternalTy getAsListAndHasExternal() const
DeclListNode * getAsList() const
StoredDeclsList(StoredDeclsList &&RHS)
void addOrReplaceDecl(NamedDecl *D)
If this is a redeclaration of an existing decl, replace the old one with D.
bool hasExternalDecls() const
NamedDecl * getAsDecl() const
void prependDeclNoReplace(NamedDecl *D)
Add a declaration to the list without checking if it replaces anything.
void replaceExternalDecls(ArrayRef< NamedDecl * > Decls)
void remove(NamedDecl *D)
ASTContext & getASTContext()
StoredDeclsList()=default
void removeExternalDecls()
Remove any declarations which were imported from an external AST source.
DeclContext::lookup_result getLookupResult() const
Return the list of all the decls.
LLVM_DUMP_METHOD void dump() const
StoredDeclsList & operator=(StoredDeclsList &&RHS)
static void DestroyAll(StoredDeclsMap *Map, bool Dependent)
The JSON file list parser is used to communicate input to InstallAPI.
for(const auto &A :T->param_types())