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 void erase_if(Fn ShouldErase) {
47 Decls List =
Data.getPointer();
59 NewTail = &
Node->Rest;
66 C.DeallocateDeclListNode(N);
74 C.DeallocateDeclListNode(
Node);
79 Data.setPointer(NewHead);
81 assert(llvm::none_of(
getLookupResult(), ShouldErase) &&
"Still exists!");
85 erase_if([ND](
NamedDecl *D) {
return D == ND; });
92 RHS.Data.setPointer(
nullptr);
93 RHS.Data.setInt(
false);
101 Decls List =
Data.getPointer();
103 List = ToDealloc->Rest;
104 C.DeallocateDeclListNode(ToDealloc);
116 RHS.Data.setPointer(
nullptr);
117 RHS.Data.setInt(
false);
124 assert(!
isNull() &&
"No ASTContext.");
149 assert(!
isNull() &&
"removing from empty list");
168 if (D->declarationReplaces(ND,
false))
182 for (
size_t I = Decls.size() - 1; I != 0; --I) {
184 Node->Rest = DeclsAsList;
190 Data.setPointer(DeclsAsList);
203 Node->Rest = DeclsAsList;
205 Data.setPointer(Head);
216 const bool IsKnownNewer =
true;
240 assert(!llvm::is_contained(
getLookupResult(), D) &&
"Already exists!");
248 if (
auto *ND = N->Rest.dyn_cast<
NamedDecl *>()) {
277 LLVM_DUMP_METHOD
void dump()
const {
278 Decls D =
Data.getPointer();
280 llvm::errs() <<
"<null>\n";
286 llvm::errs() <<
'[' <<
Node->D <<
"] -> ";
289 llvm::errs() <<
'[' << D.get<
NamedDecl*>() <<
"]\n";
297 :
public llvm::SmallDenseMap<DeclarationName, StoredDeclsList, 4> {
301 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
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.
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context,...
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 an array of all the decls that this list represents.
LLVM_DUMP_METHOD void dump() const
StoredDeclsList & operator=(StoredDeclsList &&RHS)
static void DestroyAll(StoredDeclsMap *Map, bool Dependent)
for(unsigned I=0, E=TL.getNumArgs();I !=E;++I)
@ C
Languages that the frontend can parse and compile.