r177402 - Don't try to set attributes in alias, they have none.

Rafael Espindola rafael.espindola at gmail.com
Tue Mar 19 08:03:48 PDT 2013


Author: rafael
Date: Tue Mar 19 10:03:47 2013
New Revision: 177402

URL: http://llvm.org/viewvc/llvm-project?rev=177402&view=rev
Log:
Don't try to set attributes in alias, they have none.

Added:
    cfe/trunk/test/CodeGenCXX/constructor-alias.cpp
Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=177402&r1=177401&r2=177402&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Mar 19 10:03:47 2013
@@ -656,7 +656,9 @@ void CodeGenModule::SetCommonAttributes(
   if (const SectionAttr *SA = D->getAttr<SectionAttr>())
     GV->setSection(SA->getName());
 
-  getTargetCodeGenInfo().SetTargetAttributes(D, GV, *this);
+  // Alias cannot have attributes. Filter them here.
+  if (!isa<llvm::GlobalAlias>(GV))
+    getTargetCodeGenInfo().SetTargetAttributes(D, GV, *this);
 }
 
 void CodeGenModule::SetInternalFunctionAttributes(const Decl *D,

Added: cfe/trunk/test/CodeGenCXX/constructor-alias.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/constructor-alias.cpp?rev=177402&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/constructor-alias.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/constructor-alias.cpp Tue Mar 19 10:03:47 2013
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -triple mipsel--linux-gnu -mconstructor-aliases -o - %s | FileCheck %s
+
+// The target attribute code used to get confused with aliases. Make sure
+// we don't crash when an alias is used.
+
+struct B {
+  B();
+};
+B::B() {
+}
+
+// CHECK: @_ZN1BC1Ev = alias void (%struct.B*)* @_ZN1BC2Ev





More information about the cfe-commits mailing list