diff options
-rw-r--r-- | clang/include/clang/AST/Decl.h | 4 | ||||
-rw-r--r-- | clang/include/clang/AST/DeclCXX.h | 12 | ||||
-rw-r--r-- | clang/lib/AST/Decl.cpp | 4 |
3 files changed, 9 insertions, 11 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index f8e17268e6c..1f7b03ab23c 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -1889,8 +1889,10 @@ public: void setPreviousDeclaration(FunctionDecl * PrevDecl); - virtual const FunctionDecl *getCanonicalDecl() const; FunctionDecl *getCanonicalDecl() override; + const FunctionDecl *getCanonicalDecl() const { + return const_cast<FunctionDecl*>(this)->getCanonicalDecl(); + } unsigned getBuiltinID() const; diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 332238fd542..0dbc9dacf72 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -651,8 +651,8 @@ public: CXXRecordDecl *getCanonicalDecl() override { return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl()); } - virtual const CXXRecordDecl *getCanonicalDecl() const { - return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl()); + const CXXRecordDecl *getCanonicalDecl() const { + return const_cast<CXXRecordDecl*>(this)->getCanonicalDecl(); } CXXRecordDecl *getPreviousDecl() { @@ -1781,7 +1781,7 @@ public: CXXMethodDecl *getCanonicalDecl() override { return cast<CXXMethodDecl>(FunctionDecl::getCanonicalDecl()); } - const CXXMethodDecl *getCanonicalDecl() const override { + const CXXMethodDecl *getCanonicalDecl() const { return const_cast<CXXMethodDecl*>(this)->getCanonicalDecl(); } @@ -2326,12 +2326,12 @@ public: /// \brief Set the constructor that this inheriting constructor is based on. void setInheritedConstructor(const CXXConstructorDecl *BaseCtor); - const CXXConstructorDecl *getCanonicalDecl() const override { - return cast<CXXConstructorDecl>(FunctionDecl::getCanonicalDecl()); - } CXXConstructorDecl *getCanonicalDecl() override { return cast<CXXConstructorDecl>(FunctionDecl::getCanonicalDecl()); } + const CXXConstructorDecl *getCanonicalDecl() const { + return const_cast<CXXConstructorDecl*>(this)->getCanonicalDecl(); + } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 978b1dfc41e..173e22f0696 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2569,10 +2569,6 @@ FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) { IsInline = true; } -const FunctionDecl *FunctionDecl::getCanonicalDecl() const { - return getFirstDecl(); -} - FunctionDecl *FunctionDecl::getCanonicalDecl() { return getFirstDecl(); } /// \brief Returns a value indicating whether this function |