[cfe-commits] r125579 - in /cfe/trunk: lib/CodeGen/ModuleBuilder.cpp test/CodeGenCXX/attr-used.cpp
Douglas Gregor
dgregor at apple.com
Tue Feb 15 10:11:42 PST 2011
Author: dgregor
Date: Tue Feb 15 12:11:42 2011
New Revision: 125579
URL: http://llvm.org/viewvc/llvm-project?rev=125579&view=rev
Log:
Emit in-class member function definitions that are marked
"used". Fixes <rdar://problem/8684363>.
Added:
cfe/trunk/test/CodeGenCXX/attr-used.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=125579&r1=125578&r2=125579&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Tue Feb 15 12:11:42 2011
@@ -71,6 +71,18 @@
/// (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) {
Added: cfe/trunk/test/CodeGenCXX/attr-used.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-used.cpp?rev=125579&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/attr-used.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/attr-used.cpp Tue Feb 15 12:11:42 2011
@@ -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() {}
+};
Propchange: cfe/trunk/test/CodeGenCXX/attr-used.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/CodeGenCXX/attr-used.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/CodeGenCXX/attr-used.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list