r195556 - [CodeGen] If there is a function definition with duplicate mangled name, emit an error instead of asserting.

Rafael Avila de Espindola rafael.espindola at gmail.com
Sun Nov 24 06:00:22 PST 2013


Can you add a test case?


Sent from my iPhone

> On Nov 23, 2013, at 13:41, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
> 
> Author: akirtzidis
> Date: Sat Nov 23 12:41:35 2013
> New Revision: 195556
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=195556&view=rev
> Log:
> [CodeGen] If there is a function definition with duplicate mangled name, emit an error instead of asserting.
> 
> rdar://15522601 & http://llvm.org/PR18031
> 
> Modified:
>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=195556&r1=195555&r2=195556&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Nov 23 12:41:35 2013
> @@ -2028,6 +2028,8 @@ def err_alias_not_supported_on_darwin :
>   "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<
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=195556&r1=195555&r2=195556&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Nov 23 12:41:35 2013
> @@ -2100,6 +2100,10 @@ void CodeGenModule::EmitGlobalFunctionDe
>     Entry = CE->getOperand(0);
>   }
> 
> +  if (!cast<llvm::GlobalValue>(Entry)->isDeclaration()) {
> +    getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name);
> +    return;
> +  }
> 
>   if (cast<llvm::GlobalValue>(Entry)->getType()->getElementType() != Ty) {
>     llvm::GlobalValue *OldFn = cast<llvm::GlobalValue>(Entry);
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list