diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ODRHash.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 23 |
2 files changed, 32 insertions, 0 deletions
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp index d8c2e20ede6..78a3eeca034 100644 --- a/clang/lib/AST/ODRHash.cpp +++ b/clang/lib/AST/ODRHash.cpp @@ -194,6 +194,14 @@ public: Inherited::VisitFieldDecl(D); } + + void VisitFunctionDecl(const FunctionDecl *D) { + Inherited::VisitFunctionDecl(D); + } + + void VisitCXXMethodDecl(const CXXMethodDecl *D) { + Inherited::VisitCXXMethodDecl(D); + } }; // Only allow a small portion of Decl's to be processed. Remove this once @@ -206,6 +214,7 @@ bool ODRHash::isWhitelistedDecl(const Decl *D, const CXXRecordDecl *Parent) { default: return false; case Decl::AccessSpec: + case Decl::CXXMethod: case Decl::Field: case Decl::StaticAssert: return true; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 982f59272e9..e9cb51dec6e 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -8957,6 +8957,7 @@ void ASTReader::diagnoseOdrViolations() { ProtectedSpecifer, StaticAssert, Field, + CXXMethod, Other } FirstDiffType = Other, SecondDiffType = Other; @@ -8982,6 +8983,8 @@ void ASTReader::diagnoseOdrViolations() { return StaticAssert; case Decl::Field: return Field; + case Decl::CXXMethod: + return CXXMethod; } }; @@ -9068,6 +9071,7 @@ void ASTReader::diagnoseOdrViolations() { FieldSingleMutable, FieldSingleInitializer, FieldDifferentInitializers, + MethodName, }; // These lambdas have the common portions of the ODR diagnostics. This @@ -9288,6 +9292,25 @@ void ASTReader::diagnoseOdrViolations() { break; } + case CXXMethod: { + const CXXMethodDecl *FirstMethod = cast<CXXMethodDecl>(FirstDecl); + const CXXMethodDecl *SecondMethod = cast<CXXMethodDecl>(SecondDecl); + IdentifierInfo *FirstII = FirstMethod->getIdentifier(); + IdentifierInfo *SecondII = SecondMethod->getIdentifier(); + if (FirstII->getName() != SecondII->getName()) { + ODRDiagError(FirstMethod->getLocation(), + FirstMethod->getSourceRange(), MethodName) + << FirstII; + ODRDiagNote(SecondMethod->getLocation(), + SecondMethod->getSourceRange(), MethodName) + << SecondII; + + Diagnosed = true; + break; + } + + break; + } } if (Diagnosed == true) |