23#include "llvm/Support/ErrorHandling.h"
37 static const unsigned int POOL_SIZE = 512;
42 struct IdDeclInfoPool {
44 IdDeclInfo Pool[POOL_SIZE];
49 IdDeclInfoPool *CurPool =
nullptr;
50 unsigned int CurIndex = POOL_SIZE;
56 IdDeclInfoPool *Cur = CurPool;
57 while (IdDeclInfoPool *P = Cur) {
77void IdentifierResolver::IdDeclInfo::RemoveDecl(
NamedDecl *D) {
78 for (DeclsTy::iterator I = Decls.end(); I != Decls.begin(); --I) {
85 llvm_unreachable(
"Didn't find this decl on its identifier's chain!");
93 : LangOpt(PP.getLangOpts()), PP(PP), IdDeclInfos(new
IdDeclInfoMap) {}
105 bool AllowInlineNamespace)
const {
124 if (LangOpt.CPlusPlus) {
163 updatingIdentifier(*II);
174 if (isDeclPtr(Ptr)) {
176 IDI = &(*IdDeclInfos)[Name];
180 IDI = toIdDeclInfo(Ptr);
188 updatingIdentifier(*II);
197 if (isDeclPtr(Ptr)) {
216 IdDeclInfo *IDI = toIdDeclInfo(Ptr);
220 IDI->InsertDecl(IDI->decls_begin(), D);
226 assert(D &&
"null param passed");
229 updatingIdentifier(*II);
233 assert(Ptr &&
"Didn't find this decl on its identifier's chain!");
235 if (isDeclPtr(Ptr)) {
236 assert(D == Ptr &&
"Didn't find this decl on its identifier's chain!");
241 return toIdDeclInfo(Ptr)->RemoveDecl(D);
244llvm::iterator_range<IdentifierResolver::iterator>
251 readingIdentifier(*II);
254 if (!Ptr)
return end();
259 IdDeclInfo *IDI = toIdDeclInfo(Ptr);
261 IdDeclInfo::DeclsTy::iterator I = IDI->decls_end();
262 if (I != IDI->decls_begin())
288 return DMK_Different;
295 return DMK_Different;
299 if (Existing == MostRecent)
302 if (
New == MostRecent)
307 for (
auto *RD :
New->redecls()) {
311 if (RD->isCanonicalDecl())
318 return DMK_Different;
323 readingIdentifier(*II);
334 if (isDeclPtr(Ptr)) {
350 IDI = &(*IdDeclInfos)[Name];
364 IDI = toIdDeclInfo(Ptr);
368 for (IdDeclInfo::DeclsTy::iterator I = IDI->decls_begin(),
369 IEnd = IDI->decls_end();
384 if (!(*I)->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
387 IDI->InsertDecl(I, D);
416IdentifierResolver::IdDeclInfo &
420 if (Ptr)
return *toIdDeclInfo(Ptr);
422 if (CurIndex == POOL_SIZE) {
423 CurPool =
new IdDeclInfoPool(CurPool);
426 IdDeclInfo *IDI = &CurPool->Pool[CurIndex];
437 assert(!isDeclPtr(InfoPtr) &&
"Decl with wrong id ?");
438 IdDeclInfo *Info = toIdDeclInfo(InfoPtr);
441 if (I != Info->decls_begin())
static DeclMatchKind compareDeclarations(NamedDecl *Existing, NamedDecl *New)
Compare two declarations to see whether they are different or, if they are the same,...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines the clang::LangOptions interface.
Defines the clang::Preprocessor interface.
IdDeclInfoMap - Associates IdDeclInfos with declaration names.
IdDeclInfoMap(const IdDeclInfoMap &)=delete
IdDeclInfoMap & operator=(const IdDeclInfoMap &)=delete
IdDeclInfo & operator[](DeclarationName Name)
Returns the IdDeclInfo associated to the DeclarationName.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context,...
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool isFunctionOrMethod() const
DeclContext * getEnclosingNonExpansionStatementContext()
Retrieve the innermost enclosing context that doesn't belong to an expansion statement.
Decl - This represents one declaration (or definition), e.g.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
DeclContext * getDeclContext()
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void * getFETokenInfo() const
Get and set FETokenInfo.
void setFETokenInfo(void *T)
virtual void updateOutOfDateIdentifier(const IdentifierInfo &II)=0
Update an out-of-date identifier.
One of these records is kept for each identifier that is lexed.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
void setFETokenInfoChangedSinceDeserialization()
Note that the frontend token information for this identifier has changed since it was loaded from an ...
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
iterator - Iterate over the decls of a specified declaration name.
IdDeclInfo::DeclsTy::iterator BaseIter
iterator(NamedDecl *D)
A single NamedDecl. (Ptr & 0x1 == 0)
BaseIter getIterator() const
iterator begin(DeclarationName Name)
Returns an iterator over decls with the name 'Name'.
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
IdentifierResolver(Preprocessor &PP)
void InsertDeclAfter(iterator Pos, NamedDecl *D)
Insert the given declaration after the given iterator position.
bool tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name)
Try to add the given declaration to the top level scope, if it (or a redeclaration of it) hasn't alre...
iterator end()
Returns the end iterator.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
llvm::iterator_range< iterator > decls(DeclarationName Name)
Returns a range of decls with the name 'Name'.
bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
This represents a decl that may have a name.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
NamedDecl * getMostRecentDecl()
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
ExternalPreprocessorSource * getExternalSource() const
Scope - A scope is a transient data structure that is used while parsing the program.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
bool isFnTryCatchScope() const
Determine whether this scope is a function-level C++ try or catch scope.
bool isControlScope() const
Determine whether this scope is a controlling scope in a if/switch/while/for statement.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
bool isFunctionScope() const
isFunctionScope() - Return true if this scope is a function scope.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...