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