diff options
author | Craig Topper <craig.topper@gmail.com> | 2015-05-10 18:40:12 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2015-05-10 18:40:12 +0000 |
commit | 382277421dfcedecd2ef736e70158ca861c26178 (patch) | |
tree | a455919f2c92636688455e2df022b41959f97171 | |
parent | f1ff3c146dbb6b90e9373269b2edae462de579da (diff) | |
download | bcm5719-llvm-382277421dfcedecd2ef736e70158ca861c26178.tar.gz bcm5719-llvm-382277421dfcedecd2ef736e70158ca861c26178.zip |
De-virtualize some const versions of getCanonicalDecl by redirecting to the non-const version. Most of the Decl hierarchy already did it this way this just makes the rest consistent.
llvm-svn: 236959
-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 |