From a36ef5bd79b056bff82ff30449522b9e39a4363b Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 25 Nov 2013 07:42:52 +0000 Subject: [PATCH] Merging r195556: ------------------------------------------------------------------------ r195556 | akirtzidis | 2013-11-23 10:41:35 -0800 (Sat, 23 Nov 2013) | 3 lines [CodeGen] If there is a function definition with duplicate mangled name, emit an error instead of asserting. rdar://15522601 & http://llvm.org/PR18031 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@195623 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 2 ++ lib/CodeGen/CodeGenModule.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 43ecec533d..6c7cb00180 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2030,6 +2030,8 @@ def err_alias_not_supported_on_darwin : Error < "only weak aliases are supported on darwin">; def err_alias_to_undefined : Error< "alias must point to a defined variable or function">; +def err_duplicate_mangled_name : Error< + "definition with same mangled name as another definition">; def err_cyclic_alias : Error< "alias definition is part of a cycle">; def warn_attribute_wrong_decl_type : Warning< diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 4d51fb02bb..72f909fd53 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -2095,6 +2095,10 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) { Entry = CE->getOperand(0); } + if (!cast(Entry)->isDeclaration()) { + getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name); + return; + } if (cast(Entry)->getType()->getElementType() != Ty) { llvm::GlobalValue *OldFn = cast(Entry); -- 2.50.1