From: Aaron Ballman Date: Wed, 6 Nov 2013 22:39:46 +0000 (+0000) Subject: Work around an MSVC 2013 miscompile with the Redeclarable class. Fixes PR16606 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2dc57f42574c8b2cda72cae06c0220fd7fab8c0e;p=clang Work around an MSVC 2013 miscompile with the Redeclarable class. Fixes PR16606 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194176 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index eefc15e399..244a7b8d40 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -274,7 +274,7 @@ public: } NamedDecl *getMostRecentDecl() { - return cast(Decl::getMostRecentDecl()); + return cast(static_cast(this)->getMostRecentDecl()); } const NamedDecl *getMostRecentDecl() const { return const_cast(this)->getMostRecentDecl(); @@ -2827,14 +2827,15 @@ public: } EnumDecl *getPreviousDecl() { - return cast_or_null(TagDecl::getPreviousDecl()); + return cast_or_null( + static_cast(this)->getPreviousDecl()); } const EnumDecl *getPreviousDecl() const { return const_cast(this)->getPreviousDecl(); } EnumDecl *getMostRecentDecl() { - return cast(TagDecl::getMostRecentDecl()); + return cast(static_cast(this)->getMostRecentDecl()); } const EnumDecl *getMostRecentDecl() const { return const_cast(this)->getMostRecentDecl(); @@ -3034,14 +3035,15 @@ public: static RecordDecl *CreateDeserialized(const ASTContext &C, unsigned ID); RecordDecl *getPreviousDecl() { - return cast_or_null(TagDecl::getPreviousDecl()); + return cast_or_null( + static_cast(this)->getPreviousDecl()); } const RecordDecl *getPreviousDecl() const { return const_cast(this)->getPreviousDecl(); } RecordDecl *getMostRecentDecl() { - return cast(TagDecl::getMostRecentDecl()); + return cast(static_cast(this)->getMostRecentDecl()); } const RecordDecl *getMostRecentDecl() const { return const_cast(this)->getMostRecentDecl(); diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 4e27dbd1ff..dbc41320bd 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -639,14 +639,16 @@ public: } CXXRecordDecl *getPreviousDecl() { - return cast_or_null(RecordDecl::getPreviousDecl()); + return cast_or_null( + static_cast(this)->getPreviousDecl()); } const CXXRecordDecl *getPreviousDecl() const { return const_cast(this)->getPreviousDecl(); } CXXRecordDecl *getMostRecentDecl() { - return cast(RecordDecl::getMostRecentDecl()); + return cast( + static_cast(this)->getMostRecentDecl()); } const CXXRecordDecl *getMostRecentDecl() const { @@ -1709,7 +1711,8 @@ public: } CXXMethodDecl *getMostRecentDecl() { - return cast(FunctionDecl::getMostRecentDecl()); + return cast( + static_cast(this)->getMostRecentDecl()); } const CXXMethodDecl *getMostRecentDecl() const { return const_cast(this)->getMostRecentDecl(); diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index d2984fe42a..24bd28a75a 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -826,14 +826,14 @@ public: /// NULL if no such declaration exists. FunctionTemplateDecl *getPreviousDecl() { return cast_or_null( - RedeclarableTemplateDecl::getPreviousDecl()); + static_cast(this)->getPreviousDecl()); } /// \brief Retrieve the previous declaration of this function template, or /// NULL if no such declaration exists. const FunctionTemplateDecl *getPreviousDecl() const { return cast_or_null( - RedeclarableTemplateDecl::getPreviousDecl()); + static_cast(this)->getPreviousDecl()); } FunctionTemplateDecl *getInstantiatedFromMemberTemplate() { @@ -1449,7 +1449,8 @@ public: bool Qualified) const; ClassTemplateSpecializationDecl *getMostRecentDecl() { - CXXRecordDecl *Recent = CXXRecordDecl::getMostRecentDecl(); + CXXRecordDecl *Recent = static_cast( + this)->getMostRecentDecl(); while (!isa(Recent)) { // FIXME: Does injected class name need to be in the redeclarations chain? assert(Recent->isInjectedClassName() && Recent->getPreviousDecl()); @@ -1691,7 +1692,8 @@ public: ClassTemplatePartialSpecializationDecl *getMostRecentDecl() { return cast( - ClassTemplateSpecializationDecl::getMostRecentDecl()); + static_cast( + this)->getMostRecentDecl()); } /// Get the list of template parameters @@ -1890,19 +1892,20 @@ public: /// NULL if no such declaration exists. ClassTemplateDecl *getPreviousDecl() { return cast_or_null( - RedeclarableTemplateDecl::getPreviousDecl()); + static_cast(this)->getPreviousDecl()); } /// \brief Retrieve the previous declaration of this class template, or /// NULL if no such declaration exists. const ClassTemplateDecl *getPreviousDecl() const { return cast_or_null( - RedeclarableTemplateDecl::getPreviousDecl()); + static_cast( + this)->getPreviousDecl()); } ClassTemplateDecl *getMostRecentDecl() { return cast( - RedeclarableTemplateDecl::getMostRecentDecl()); + static_cast(this)->getMostRecentDecl()); } const ClassTemplateDecl *getMostRecentDecl() const { return const_cast(this)->getMostRecentDecl(); @@ -2132,14 +2135,15 @@ public: /// NULL if no such declaration exists. TypeAliasTemplateDecl *getPreviousDecl() { return cast_or_null( - RedeclarableTemplateDecl::getPreviousDecl()); + static_cast(this)->getPreviousDecl()); } /// \brief Retrieve the previous declaration of this function template, or /// NULL if no such declaration exists. const TypeAliasTemplateDecl *getPreviousDecl() const { return cast_or_null( - RedeclarableTemplateDecl::getPreviousDecl()); + static_cast( + this)->getPreviousDecl()); } TypeAliasTemplateDecl *getInstantiatedFromMemberTemplate() { @@ -2317,7 +2321,7 @@ public: bool Qualified) const; VarTemplateSpecializationDecl *getMostRecentDecl() { - VarDecl *Recent = VarDecl::getMostRecentDecl(); + VarDecl *Recent = static_cast(this)->getMostRecentDecl(); return cast(Recent); } @@ -2547,7 +2551,8 @@ public: VarTemplatePartialSpecializationDecl *getMostRecentDecl() { return cast( - VarTemplateSpecializationDecl::getMostRecentDecl()); + static_cast( + this)->getMostRecentDecl()); } /// Get the list of template parameters @@ -2730,14 +2735,15 @@ public: /// NULL if no such declaration exists. VarTemplateDecl *getPreviousDecl() { return cast_or_null( - RedeclarableTemplateDecl::getPreviousDecl()); + static_cast(this)->getPreviousDecl()); } /// \brief Retrieve the previous declaration of this variable template, or /// NULL if no such declaration exists. const VarTemplateDecl *getPreviousDecl() const { return cast_or_null( - RedeclarableTemplateDecl::getPreviousDecl()); + static_cast( + this)->getPreviousDecl()); } VarTemplateDecl *getInstantiatedFromMemberTemplate() {