diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-18 00:34:07 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-18 00:34:07 +0000 |
commit | b57a4fe73b8227c0dba651818b8495dfca61e530 (patch) | |
tree | 56854fb0f97e67a7dc7ef19ba5fedb56155a29a9 /include/clang | |
parent | 0df134715d75c62422502af0f5610885a5a4f472 (diff) |
Move the functionality of ASTContext::getCanonicalDecl(), into a virtual method Decl::getCanonicalDecl().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76273 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/AST/Decl.h | 6 | ||||
-rw-r--r-- | include/clang/AST/DeclBase.h | 10 | ||||
-rw-r--r-- | include/clang/AST/DeclTemplate.h | 4 |
3 files changed, 14 insertions, 6 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index a5c3ea0680..a35638f315 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -437,7 +437,7 @@ public: return First->PreviousDeclaration.getPointer(); } - virtual Decl *getPrimaryDecl() const; + virtual VarDecl *getCanonicalDecl(); /// \brief Iterates through all the redeclarations of the same var decl. class redecl_iterator { @@ -908,7 +908,7 @@ public: void setPreviousDeclaration(FunctionDecl * PrevDecl); - virtual Decl *getPrimaryDecl() const; + virtual FunctionDecl *getCanonicalDecl(); /// \brief Iterates through all the redeclarations of the same function decl. class redecl_iterator { @@ -1316,6 +1316,8 @@ public: void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } virtual SourceRange getSourceRange() const; + + virtual TagDecl* getCanonicalDecl(); /// isDefinition - Return true if this decl has its body specified. bool isDefinition() const { diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 2d056c479b..5350706ae0 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -312,12 +312,14 @@ public: // be defined inside or outside a function etc). bool isDefinedOutsideFunctionOrMethod() const; - /// \brief When there are multiple re-declarations (e.g. for functions), - /// this will return the primary one which all of them point to. - virtual Decl *getPrimaryDecl() const { return const_cast<Decl*>(this); } + /// \brief Retrieves the "canonical" declaration of the given declaration. + virtual Decl *getCanonicalDecl() { return this; } + const Decl *getCanonicalDecl() const { + return const_cast<Decl*>(this)->getCanonicalDecl(); + } /// \brief Whether this particular Decl is a primary one. - bool isPrimaryDecl() const { return getPrimaryDecl() == this; } + bool isCanonicalDecl() const { return getCanonicalDecl() == this; } /// getBody - If this Decl represents a declaration for a body of code, /// such as a function or method definition, this method returns the diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 5d0fe158e0..8601620931 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -604,6 +604,8 @@ public: CommonOrPrev = Prev; } + virtual FunctionTemplateDecl *getCanonicalDecl(); + /// Create a template function node. static FunctionTemplateDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, @@ -1027,6 +1029,8 @@ public: ClassTemplateDecl *getPreviousDeclaration() const { return PreviousDeclaration; } + + virtual ClassTemplateDecl *getCanonicalDecl(); /// Create a class template node. static ClassTemplateDecl *Create(ASTContext &C, DeclContext *DC, |