22 using namespace clang;
32 static const unsigned int POOL_SIZE = 512;
37 struct IdDeclInfoPool {
38 IdDeclInfoPool(IdDeclInfoPool *Next) : Next(Next) {}
41 IdDeclInfo Pool[POOL_SIZE];
44 IdDeclInfoPool *CurPool;
45 unsigned int CurIndex;
51 IdDeclInfoPool *Cur = CurPool;
52 while (IdDeclInfoPool *
P = Cur) {
70 void IdentifierResolver::IdDeclInfo::RemoveDecl(
NamedDecl *D) {
71 for (DeclsTy::iterator I = Decls.end(); I != Decls.begin(); --I) {
78 llvm_unreachable(
"Didn't find this decl on its identifier's chain!");
86 : LangOpt(PP.getLangOpts()), PP(PP),
98 bool AllowInlineNamespace)
const {
108 if (LangOpt.CPlusPlus) {
145 updatingIdentifier(*II);
156 if (isDeclPtr(Ptr)) {
158 IDI = &(*IdDeclInfos)[Name];
162 IDI = toIdDeclInfo(Ptr);
170 updatingIdentifier(*II);
179 if (isDeclPtr(Ptr)) {
198 IdDeclInfo *IDI = toIdDeclInfo(Ptr);
202 IDI->InsertDecl(IDI->decls_begin(), D);
208 assert(D &&
"null param passed");
211 updatingIdentifier(*II);
215 assert(Ptr &&
"Didn't find this decl on its identifier's chain!");
217 if (isDeclPtr(Ptr)) {
218 assert(D == Ptr &&
"Didn't find this decl on its identifier's chain!");
223 return toIdDeclInfo(Ptr)->RemoveDecl(D);
230 readingIdentifier(*II);
233 if (!Ptr)
return end();
236 return iterator(static_cast<NamedDecl*>(Ptr));
238 IdDeclInfo *IDI = toIdDeclInfo(Ptr);
240 IdDeclInfo::DeclsTy::iterator I = IDI->decls_end();
241 if (I != IDI->decls_begin())
265 return DMK_Different;
272 return DMK_Different;
276 if (Existing == MostRecent)
279 if (New == MostRecent)
284 for (
auto RD : New->
redecls()) {
288 if (RD->isCanonicalDecl())
295 return DMK_Different;
300 readingIdentifier(*II);
311 if (isDeclPtr(Ptr)) {
327 IDI = &(*IdDeclInfos)[Name];
341 IDI = toIdDeclInfo(Ptr);
345 for (IdDeclInfo::DeclsTy::iterator I = IDI->decls_begin(),
346 IEnd = IDI->decls_end();
361 if (!(*I)->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
364 IDI->InsertDecl(I, D);
393 IdentifierResolver::IdDeclInfo &
397 if (Ptr)
return *toIdDeclInfo(Ptr);
399 if (CurIndex == POOL_SIZE) {
400 CurPool =
new IdDeclInfoPool(CurPool);
403 IdDeclInfo *IDI = &CurPool->Pool[CurIndex];
405 reinterpret_cast<uintptr_t>(IDI) | 0x1)
414 assert(!isDeclPtr(InfoPtr) &&
"Decl with wrong id ?");
415 IdDeclInfo *Info = toIdDeclInfo(InfoPtr);
418 if (I != Info->decls_begin())
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...
BaseIter getIterator() const
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'...
Decl - This represents one declaration (or definition), e.g.
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
One of these records is kept for each identifier that is lexed.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
iterator end()
end - Returns an iterator that has 'finished'.
The controlling scope in a if/switch/while/for statement.
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
Scope - A scope is a transient data structure that is used while parsing the program.
IdDeclInfoMap - Associates IdDeclInfos with declaration names.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
unsigned getFlags() const
getFlags - Return the flags for this scope.
static DeclMatchKind compareDeclarations(NamedDecl *Existing, NamedDecl *New)
Compare two declarations to see whether they are different or, if they are the same, whether the new declaration should replace the existing declaration.
Defines the clang::LangOptions interface.
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
DeclContext * getEntity() const
Defines the clang::Preprocessor interface.
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...
DeclContext * getDeclContext()
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
bool isFunctionOrMethod() const
T * getFETokenInfo() const
getFETokenInfo/setFETokenInfo - The language front-end is allowed to associate arbitrary metadata wit...
ExternalPreprocessorSource * getExternalSource() const
void setFETokenInfoChangedSinceDeserialization()
Note that the frontend token information for this identifier has changed since it was loaded from an ...
IdDeclInfo & operator[](DeclarationName Name)
Returns the IdDeclInfo associated to the DeclarationName.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
IdentifierResolver(Preprocessor &PP)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
DeclarationName - The name of a declaration.
void InsertDeclAfter(iterator Pos, NamedDecl *D)
Insert the given declaration after the given iterator position.
This is the scope for a function-level C++ try or catch scope.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
virtual void updateOutOfDateIdentifier(IdentifierInfo &II)=0
Update an out-of-date identifier.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
IdDeclInfo::DeclsTy::iterator BaseIter
void setFETokenInfo(void *T)
NamedDecl * getMostRecentDecl()
NamedDecl - This represents a decl with a name.
bool isTranslationUnit() const
iterator - Iterate over the decls of a specified declaration name.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.