]> granicus.if.org Git - clang/commitdiff
[ODRHash] Change the fall-back diagnostic error.
authorRichard Trieu <rtrieu@google.com>
Thu, 8 Jun 2017 00:56:21 +0000 (00:56 +0000)
committerRichard Trieu <rtrieu@google.com>
Thu, 8 Jun 2017 00:56:21 +0000 (00:56 +0000)
Provide a little more information when a ODR violation is detected, but the
specific error could not be diagnosed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304956 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSerializationKinds.td
lib/Serialization/ASTReader.cpp

index f9e7b8fa9b567b617cea4f0d1f60ee442007744e..e4c9ead0d1ef7f11a8d9d444f648608cfa629c53 100644 (file)
@@ -174,6 +174,13 @@ def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "method %2 with %ordinal3 parameter of type %4%select{| decayed from %6}5|"
   "method %2 with %ordinal3 parameter named %4}1">;
 
+def err_module_odr_violation_mismatch_decl_unknown : Error<
+  "%q0 has different definitions in different modules; first difference is "
+  "%select{definition in module '%2'|defined here}1 found different "
+  "%select{||||static assert|field|method|other}3">;
+def note_module_odr_violation_mismatch_decl_unknown : Note<
+  "but in '%0' found different %select{||||static assert|field|method|other}1">;
+
 def warn_duplicate_module_file_extension : Warning<
   "duplicate module file extension block name '%0'">,
   InGroup<ModuleFileExtension>;
index 015a16eadeb5c91fcd6958ae0cb71ae69fe9f58a..94a8f609f57c0000257d9bdb77ac911f2828ce78 100644 (file)
@@ -9753,13 +9753,13 @@ void ASTReader::diagnoseOdrViolations() {
       if (Diagnosed == true)
         continue;
 
-      Diag(FirstRecord->getLocation(),
-           diag::err_module_odr_violation_different_definitions)
-          << FirstRecord << FirstModule.empty() << FirstModule;
-
-      Diag(SecondRecord->getLocation(),
-           diag::note_module_odr_violation_different_definitions)
-          << SecondModule;
+      Diag(FirstDecl->getLocation(),
+           diag::err_module_odr_violation_mismatch_decl_unknown)
+          << FirstRecord << FirstModule.empty() << FirstModule << FirstDiffType
+          << FirstDecl->getSourceRange();
+      Diag(SecondDecl->getLocation(),
+           diag::note_module_odr_violation_mismatch_decl_unknown)
+          << SecondModule << FirstDiffType << SecondDecl->getSourceRange();
       Diagnosed = true;
     }