From: Argyrios Kyrtzidis Date: Sat, 23 Nov 2013 18:41:35 +0000 (+0000) Subject: [CodeGen] If there is a function definition with duplicate mangled name, emit an... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95056960417abcbbf81d95d1bad54ac020d8ba87;p=clang [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/trunk@195556 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 23ab143319..8f2903aaef 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2028,6 +2028,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 8240f8d38c..2acb2ec1e8 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -2100,6 +2100,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);