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).

llvm-svn: 90607
This commit is contained in:
Anders Carlsson 2009-12-04 22:35:50 +00:00
parent 1ed86de080
commit cfb65d7432
2 changed files with 36 additions and 1 deletions

View File

@ -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:

View File

@ -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() { }