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())
87 else if (isa<NamedDecl *>(NewHead))
91 assert(NewLast && isa<NamedDecl *>(*NewLast) &&
"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");
180 return llvm::any_of(Decls, [ND](
NamedDecl *
D) {
183 return D->getModuleOwnershipKind() <= ND->getModuleOwnershipKind() &&
184 D->declarationReplaces(ND, false);
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;
231 if (
D->declarationReplaces(OldD, IsKnownNewer)) {
250 if (
D->declarationReplaces(N->D, IsKnownNewer)) {
254 if (
auto *ND = N->Rest.dyn_cast<
NamedDecl *>()) {
255 if (
D->declarationReplaces(ND, IsKnownNewer)) {
283 LLVM_DUMP_METHOD
void dump()
const {
284 Decls
D =
Data.getPointer();
286 llvm::errs() <<
"<null>\n";
292 llvm::errs() <<
'[' <<
Node->D <<
"] -> ";
295 llvm::errs() <<
'[' << cast<NamedDecl *>(
D) <<
"]\n";
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 ...
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.
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.
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...