summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ODRHash.cpp24
-rw-r--r--clang/lib/Serialization/ASTReader.cpp22
2 files changed, 45 insertions, 1 deletions
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 9c6f38c2d9d..35af0e98a91 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -26,7 +26,12 @@ void ODRHash::AddStmt(const Stmt *S) {
assert(S && "Expecting non-null pointer.");
S->ProcessODRHash(ID, *this);
}
-void ODRHash::AddIdentifierInfo(const IdentifierInfo *II) {}
+
+void ODRHash::AddIdentifierInfo(const IdentifierInfo *II) {
+ assert(II && "Expecting non-null pointer.");
+ ID.AddString(II->getName());
+}
+
void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {}
void ODRHash::AddTemplateName(TemplateName Name) {}
void ODRHash::AddDeclarationName(DeclarationName Name) {}
@@ -90,11 +95,23 @@ public:
}
}
+ void AddIdentifierInfo(const IdentifierInfo *II) {
+ Hash.AddBoolean(II);
+ if (II) {
+ Hash.AddIdentifierInfo(II);
+ }
+ }
+
void Visit(const Decl *D) {
ID.AddInteger(D->getKind());
Inherited::Visit(D);
}
+ void VisitNamedDecl(const NamedDecl *D) {
+ AddIdentifierInfo(D->getIdentifier());
+ Inherited::VisitNamedDecl(D);
+ }
+
void VisitAccessSpecDecl(const AccessSpecDecl *D) {
ID.AddInteger(D->getAccess());
Inherited::VisitAccessSpecDecl(D);
@@ -106,6 +123,10 @@ public:
Inherited::VisitStaticAssertDecl(D);
}
+
+ void VisitFieldDecl(const FieldDecl *D) {
+ Inherited::VisitFieldDecl(D);
+ }
};
// Only allow a small portion of Decl's to be processed. Remove this once
@@ -118,6 +139,7 @@ bool ODRHash::isWhitelistedDecl(const Decl *D, const CXXRecordDecl *Parent) {
default:
return false;
case Decl::AccessSpec:
+ case Decl::Field:
case Decl::StaticAssert:
return true;
}
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 977cc115ca1..72d4c75b063 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -8956,6 +8956,7 @@ void ASTReader::diagnoseOdrViolations() {
PrivateSpecifer,
ProtectedSpecifer,
StaticAssert,
+ Field,
Other
} FirstDiffType = Other,
SecondDiffType = Other;
@@ -8979,6 +8980,8 @@ void ASTReader::diagnoseOdrViolations() {
llvm_unreachable("Invalid access specifier");
case Decl::StaticAssert:
return StaticAssert;
+ case Decl::Field:
+ return Field;
}
};
@@ -9058,6 +9061,7 @@ void ASTReader::diagnoseOdrViolations() {
StaticAssertCondition,
StaticAssertMessage,
StaticAssertOnlyMessage,
+ FieldName,
};
// These lambdas have the common portions of the ODR diagnostics. This
@@ -9146,6 +9150,24 @@ void ASTReader::diagnoseOdrViolations() {
}
break;
}
+ case Field: {
+ FieldDecl *FirstField = cast<FieldDecl>(FirstDecl);
+ FieldDecl *SecondField = cast<FieldDecl>(SecondDecl);
+ IdentifierInfo *FirstII = FirstField->getIdentifier();
+ IdentifierInfo *SecondII = SecondField->getIdentifier();
+ if (FirstII->getName() != SecondII->getName()) {
+ ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
+ FieldName)
+ << FirstII;
+ ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
+ FieldName)
+ << SecondII;
+
+ Diagnosed = true;
+ break;
+ }
+ break;
+ }
}
if (Diagnosed == true)
OpenPOWER on IntegriCloud