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"
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())
97 erase_if([ND](
NamedDecl *D) {
return D == ND; });
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);
133 bool isNull()
const {
return Data.getPointer().isNull(); }
136 assert(!
isNull() &&
"No ASTContext.");
161 assert(!
isNull() &&
"removing from empty list");
180 return llvm::any_of(Decls, [ND](
NamedDecl *D) {
197 for (
size_t I = Decls.size() - 1; I != 0; --I) {
199 Node->Rest = DeclsAsList;
203 if (!Data.getPointer()) {
204 Data.setPointer(DeclsAsList);
210 Node->Rest = DeclsAsList;
222 const bool IsKnownNewer =
true;
240 Data.setPointer(Node);
246 assert(!llvm::is_contained(
getLookupResult(), D) &&
"Already exists!");
254 if (
auto *ND = N->Rest.dyn_cast<
NamedDecl *>()) {
279 Node->Rest = Data.getPointer();
280 Data.setPointer(Node);
283 LLVM_DUMP_METHOD
void dump()
const {
284 Decls D = Data.getPointer();
286 llvm::errs() <<
"<null>\n";
292 llvm::errs() <<
'[' << Node->D <<
"] -> ";
303 :
public llvm::SmallDenseMap<DeclarationName, StoredDeclsList, 4> {
307 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 ...
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
friend class DependentDiagnostic
This represents a decl that may have a name.
bool declarationReplaces(const NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context,...
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.
bool isa(CodeGen::Address addr)
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
U cast(CodeGen::Address addr)