[cfe-commits] r126055 - in /cfe/trunk: lib/CodeGen/ModuleBuilder.cpp test/CodeGenCXX/constructor-attr.cpp
Douglas Gregor
dgregor at apple.com
Sat Feb 19 13:54:50 PST 2011
Author: dgregor
Date: Sat Feb 19 15:54:50 2011
New Revision: 126055
URL: http://llvm.org/viewvc/llvm-project?rev=126055&view=rev
Log:
In addition to in-class member functions marked with the "used"
attribute, we also care about those with the "constructor"
attribute. Fixes PR6521.
Added:
cfe/trunk/test/CodeGenCXX/constructor-attr.cpp (with props)
Modified:
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=126055&r1=126054&r2=126055&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Sat Feb 19 15:54:50 2011
@@ -80,7 +80,8 @@
M != MEnd; ++M)
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(*M))
if (Method->isThisDeclarationADefinition() &&
- Method->hasAttr<UsedAttr>())
+ (Method->hasAttr<UsedAttr>() ||
+ Method->hasAttr<ConstructorAttr>()))
Builder->EmitTopLevelDecl(Method);
}
}
Added: cfe/trunk/test/CodeGenCXX/constructor-attr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/constructor-attr.cpp?rev=126055&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/constructor-attr.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/constructor-attr.cpp Sat Feb 19 15:54:50 2011
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @llvm.global_ctors
+
+// PR6521
+void bar();
+struct Foo {
+ // CHECK: define linkonce_odr void @_ZN3Foo3fooEv
+ static void foo() __attribute__((constructor)) {
+ bar();
+ }
+};
Propchange: cfe/trunk/test/CodeGenCXX/constructor-attr.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/CodeGenCXX/constructor-attr.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/CodeGenCXX/constructor-attr.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list