From c640ff63e236d48d90a29f548799ea8342a7aa04 Mon Sep 17 00:00:00 2001 From: Renato Golin Date: Wed, 15 Apr 2015 08:44:40 +0000 Subject: Revert "[CodeGen] Fix crash with duplicated mangled name." 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. llvm-svn: 234983 --- clang/lib/CodeGen/CodeGenModule.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4dd965f..f60a68ab 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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(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"); -- cgit v1.1