]> granicus.if.org Git - clang/commitdiff
Make the mangled name collision diagnostic a bit more useful by listing the mangling.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 30 May 2018 01:52:16 +0000 (01:52 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 30 May 2018 01:52:16 +0000 (01:52 +0000)
This helps especially when the collision is for a template specialization,
where the template arguments are not available from anywhere else in the
diagnostic, and are likely relevant to the problem.

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/CodeGen/CodeGenModule.cpp
test/CodeGenCXX/duplicate-mangled-name.cpp
test/Sema/attr-ifunc.c

index 052eb4d91d513b0cdf387d4bd4a748f23d25f9b1..1fa66cbcfc72c3115644bac5601e6d0086257784 100644 (file)
@@ -2820,7 +2820,7 @@ def warn_alias_with_section : Warning<
   "%select{alias|ifunc}1 will not be in section '%0' but in the same section as the %select{aliasee|resolver}2">,
   InGroup<IgnoredAttributes>;
 def err_duplicate_mangled_name : Error<
-  "definition with same mangled name as another definition">;
+  "definition with same mangled name '%0' as another definition">;
 def err_cyclic_alias : Error<
   "%select{alias|ifunc}0 definition is part of a cycle">;
 def err_ifunc_resolver_return : Error<
index 50b653c70ff96b06d901e879e45cf07f18324fed..3098e0f984c2fb6c59a9fc527a3de9b65cab866c 100644 (file)
@@ -2445,8 +2445,8 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
           (GD.getCanonicalDecl().getDecl() !=
            OtherGD.getCanonicalDecl().getDecl()) &&
           DiagnosedConflictingDefinitions.insert(GD).second) {
-        getDiags().Report(D->getLocation(),
-                          diag::err_duplicate_mangled_name);
+        getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name)
+            << MangledName;
         getDiags().Report(OtherGD.getDecl()->getLocation(),
                           diag::note_previous_definition);
       }
@@ -2744,8 +2744,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
           (OtherD = dyn_cast<VarDecl>(OtherGD.getDecl())) &&
           OtherD->hasInit() &&
           DiagnosedConflictingDefinitions.insert(D).second) {
-        getDiags().Report(D->getLocation(),
-                          diag::err_duplicate_mangled_name);
+        getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name)
+            << MangledName;
         getDiags().Report(OtherGD.getDecl()->getLocation(),
                           diag::note_previous_definition);
       }
@@ -3783,7 +3783,8 @@ void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
     GlobalDecl OtherGD;
     if (lookupRepresentativeDecl(MangledName, OtherGD) &&
         DiagnosedConflictingDefinitions.insert(GD).second) {
-      Diags.Report(D->getLocation(), diag::err_duplicate_mangled_name);
+      Diags.Report(D->getLocation(), diag::err_duplicate_mangled_name)
+          << MangledName;
       Diags.Report(OtherGD.getDecl()->getLocation(),
                    diag::note_previous_definition);
     }
index 086255260c68c4983c8b36c4a498e723099f18e6..741e021db984747c7fe574913527838676d1e110 100644 (file)
@@ -11,7 +11,7 @@ class MyClass {
 };
 void MyClass::meth() { } // expected-note {{previous}}
 extern "C" {
-  void _ZN7MyClass4methEv() { } // expected-error {{definition with same mangled name as another definition}}
+  void _ZN7MyClass4methEv() { } // expected-error {{definition with same mangled name '_ZN7MyClass4methEv' as another definition}}
 }
 
 #elif TEST2
@@ -49,7 +49,7 @@ float foo() {
 extern "C" void _ZN2T2D2Ev() {}; // expected-note {{previous definition is here}}
 
 struct T2 {
-  ~T2() {} // expected-error {{definition with same mangled name as another definition}}
+  ~T2() {} // expected-error {{definition with same mangled name '_ZN2T2D2Ev' as another definition}}
 };
 
 void foo() {
@@ -64,7 +64,7 @@ extern "C" {
 }
 
 namespace nm {
-  float abc = 2; // expected-error {{definition with same mangled name as another definition}}
+  float abc = 2; // expected-error {{definition with same mangled name '_ZN2nm3abcE' as another definition}}
 }
 
 float foo() {
index 16fd0dfc98206a48f31391d2053a8931c37ccdd2..af7a7e33da0967b54df59419043b47b41ca48952 100644 (file)
@@ -36,7 +36,7 @@ void f1a() __asm("f1");
 void f1a() {}
 //expected-note@-1 {{previous definition is here}}
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{definition with same mangled name as another definition}}
+//expected-error@-1 {{definition with same mangled name 'f1' as another definition}}
 void* f1_ifunc() { return 0; }
 
 void* f6_ifunc(int i);