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
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);
}
}
--- /dev/null
+// 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();
+ }
+};