summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/Decl.cpp14
-rw-r--r--clang/test/CodeGenCXX/inline-functions.cpp23
2 files changed, 36 insertions, 1 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 572d76ff72d..51a4731bfc2 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -838,8 +838,20 @@ unsigned FunctionDecl::getMinRequiredArguments() const {
}
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:
diff --git a/clang/test/CodeGenCXX/inline-functions.cpp b/clang/test/CodeGenCXX/inline-functions.cpp
new file mode 100644
index 00000000000..9af4c6e5bec
--- /dev/null
+++ b/clang/test/CodeGenCXX/inline-functions.cpp
@@ -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() { }
OpenPOWER on IntegriCloud