]> granicus.if.org Git - clang/commitdiff
Revert "[CodeGen] Fix crash with duplicated mangled name."
authorRenato Golin <renato.golin@linaro.org>
Wed, 15 Apr 2015 08:44:40 +0000 (08:44 +0000)
committerRenato Golin <renato.golin@linaro.org>
Wed, 15 Apr 2015 08:44:40 +0000 (08:44 +0000)
This reverts commit r234767, as it was breaking all ARM buildbots for two days and the
assert is not in the code, making it difficult to spot the error, which would keep the
bots red for a few more days. New errors were silently introduced because of this bug,
and we don't want this to escalate.

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

lib/CodeGen/CodeGenModule.cpp
test/CodeGenCXX/duplicate-mangled-name2.cpp [deleted file]
test/CodeGenCXX/duplicate-mangled-name3.cpp [deleted file]

index 4dd965f24a775666edaaa99bbac69aa5d7c822d8..f60a68ab01158c088b1b95f1209b34f7d9bdfefa 100644 (file)
@@ -1372,15 +1372,6 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
                               /*DontDefer=*/false);
       return;
     }
-
-    if (llvm::GlobalValue *GV = GetGlobalValue(getMangledName(GD)))
-      if (!GV->isDeclaration()) {
-        getDiags().Report(FD->getLocation(), diag::err_duplicate_mangled_name);
-        GlobalDecl OldGD = Manglings.lookup(GV->getName());
-        if (auto *Prev = OldGD.getDecl())
-          getDiags().Report(Prev->getLocation(), diag::note_previous_definition);
-        return;
-      }
   } else {
     const auto *VD = cast<VarDecl>(Global);
     assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
@@ -2414,6 +2405,14 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
     }
   }
 
+  if (!GV->isDeclaration()) {
+    getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name);
+    GlobalDecl OldGD = Manglings.lookup(GV->getName());
+    if (auto *Prev = OldGD.getDecl())
+      getDiags().Report(Prev->getLocation(), diag::note_previous_definition);
+    return;
+  }
+
   if (GV->getType()->getElementType() != Ty) {
     // If the types mismatch then we have to rewrite the definition.
     assert(GV->isDeclaration() && "Shouldn't replace non-declaration");
diff --git a/test/CodeGenCXX/duplicate-mangled-name2.cpp b/test/CodeGenCXX/duplicate-mangled-name2.cpp
deleted file mode 100644 (file)
index e582733..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm-only %s -verify
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -femit-all-decls -emit-llvm-only %s -verify
-
-void foo(void *p) __asm("_ZN1SC2Ev");
-void foo(void *p) { } // expected-note {{previous}}
-
-struct S {
-  S() {} // expected-error {{definition with same mangled name as another definition}}
-} s;
diff --git a/test/CodeGenCXX/duplicate-mangled-name3.cpp b/test/CodeGenCXX/duplicate-mangled-name3.cpp
deleted file mode 100644 (file)
index 17dbc9b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify
-// RUN: %clang_cc1 -triple %itanium_abi_triple -femit-all-decls -emit-llvm-only %s -verify
-
-extern "C" {
-  void _ZN1SC2Ev(void *p) { } // expected-note {{previous}}
-}
-
-struct S {
-  S() {} // expected-error {{definition with same mangled name as another definition}}
-} s;