[cfe-commits] r90607 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/inline-functions.cpp
Anders Carlsson
andersca at mac.com
Fri Dec 4 14:35:50 PST 2009
Author: andersca
Date: Fri Dec 4 16:35:50 2009
New Revision: 90607
URL: http://llvm.org/viewvc/llvm-project?rev=90607&view=rev
Log:
Be a little more clever about inline member functions that are marked inline in the inline class declaration but not in the actual definition:
class A {
inline void f();
}
void A::f() { }
This is not the most ideal solution, since it doesn't work 100% with regular functions (as my FIXME comment states).
Added:
cfe/trunk/test/CodeGenCXX/inline-functions.cpp
Modified:
cfe/trunk/lib/AST/Decl.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=90607&r1=90606&r2=90607&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Dec 4 16:35:50 2009
@@ -838,8 +838,20 @@
}
bool FunctionDecl::isInlined() const {
- if (isInlineSpecified() || (isa<CXXMethodDecl>(this) && !isOutOfLine()))
+ // FIXME: This is not enough. Consider:
+ //
+ // inline void f();
+ // void f() { }
+ //
+ // f is inlined, but does not have inline specified.
+ // To fix this we should add an 'inline' flag to FunctionDecl.
+ if (isInlineSpecified())
return true;
+
+ if (isa<CXXMethodDecl>(this)) {
+ if (!isOutOfLine() || getCanonicalDecl()->isInlineSpecified())
+ return true;
+ }
switch (getTemplateSpecializationKind()) {
case TSK_Undeclared:
Added: cfe/trunk/test/CodeGenCXX/inline-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/inline-functions.cpp?rev=90607&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/inline-functions.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/inline-functions.cpp Fri Dec 4 16:35:50 2009
@@ -0,0 +1,23 @@
+// RUN: clang-cc %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// CHECK: ; ModuleID
+
+struct A {
+ inline void f();
+};
+
+// CHECK-NOT: define void @_ZN1A1fEv
+void A::f() { }
+
+template<typename> struct B { };
+
+template<> struct B<char> {
+ inline void f();
+};
+
+// CHECK-NOT: _ZN1BIcE1fEv
+void B<char>::f() { }
+
+// We need a final CHECK line here.
+
+// CHECK: define void @_Z1fv
+void f() { }
More information about the cfe-commits
mailing list