зеркало из https://github.com/microsoft/clang-1.git
Emit in-class member function definitions that are marked
"used". Fixes <rdar://problem/8684363>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125579 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
8e3df4d086
Коммит
f552c20b3d
|
@ -71,6 +71,18 @@ namespace {
|
|||
/// (because these can be defined in declspecs).
|
||||
virtual void HandleTagDeclDefinition(TagDecl *D) {
|
||||
Builder->UpdateCompletedType(D);
|
||||
|
||||
// In C++, we may have member functions that need to be emitted at this
|
||||
// point.
|
||||
if (Ctx->getLangOptions().CPlusPlus && !D->isDependentContext()) {
|
||||
for (DeclContext::decl_iterator M = D->decls_begin(),
|
||||
MEnd = D->decls_end();
|
||||
M != MEnd; ++M)
|
||||
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(*M))
|
||||
if (Method->isThisDeclarationADefinition() &&
|
||||
Method->hasAttr<UsedAttr>())
|
||||
Builder->EmitTopLevelDecl(Method);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void HandleTranslationUnit(ASTContext &Ctx) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
// <rdar://problem/8684363>: clang++ not respecting __attribute__((used)) on destructors
|
||||
struct X0 {
|
||||
// CHECK: define linkonce_odr void @_ZN2X0C1Ev
|
||||
__attribute__((used)) X0() {}
|
||||
// CHECK: define linkonce_odr void @_ZN2X0D1Ev
|
||||
__attribute__((used)) ~X0() {}
|
||||
};
|
Загрузка…
Ссылка в новой задаче