diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-02-19 21:54:50 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-02-19 21:54:50 +0000 |
commit | 944ed3b8dba3a129937a4e627d235ad99d225da9 (patch) | |
tree | 1fecd847352f5b0353ad7d80b2fbbd1e77018bdc | |
parent | b1fba3145392dc0cf54691576a4e6141e5081869 (diff) |
In addition to in-class member functions marked with the "used"
attribute, we also care about those with the "constructor"
attribute. Fixes PR6521.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126055 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/ModuleBuilder.cpp | 3 | ||||
-rw-r--r-- | test/CodeGenCXX/constructor-attr.cpp | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp index d41d3ac268..8945028644 100644 --- a/lib/CodeGen/ModuleBuilder.cpp +++ b/lib/CodeGen/ModuleBuilder.cpp @@ -80,7 +80,8 @@ namespace { 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); } } diff --git a/test/CodeGenCXX/constructor-attr.cpp b/test/CodeGenCXX/constructor-attr.cpp new file mode 100644 index 0000000000..691795f776 --- /dev/null +++ b/test/CodeGenCXX/constructor-attr.cpp @@ -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(); + } +}; |