aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-11 20:15:17 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-11 20:15:17 +0000
commit9f185076dc8b79c8240b20a8746da96beb3f147b (patch)
treed18d41a3efaa8c75fcae701b6c252b3294899012 /lib/AST/Decl.cpp
parentd5d6778fb91d018cbd57456cae71289640ea8e66 (diff)
Tweak the semantics of FunctionDecl::isOutOfLine to consider an
instantiation of a member function template or member function of a class template to be out-of-line if the definition of that function template or member function was defined out-of-line. This ensures that we get the correct linkage for explicit instantiations of out-of-line definitions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81562 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 8fd6ebf5ee..a7d8216b00 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -704,6 +704,30 @@ FunctionDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK) {
Info->setTemplateSpecializationKind(TSK);
}
+bool FunctionDecl::isOutOfLine() const {
+ // FIXME: Should we restrict this to member functions?
+ if (Decl::isOutOfLine())
+ return true;
+
+ // If this function was instantiated from a member function of a
+ // class template, check whether that member function was defined out-of-line.
+ if (FunctionDecl *FD = getInstantiatedFromMemberFunction()) {
+ const FunctionDecl *Definition;
+ if (FD->getBody(Definition))
+ return Definition->isOutOfLine();
+ }
+
+ // If this function was instantiated from a function template,
+ // check whether that function template was defined out-of-line.
+ if (FunctionTemplateDecl *FunTmpl = getPrimaryTemplate()) {
+ const FunctionDecl *Definition;
+ if (FunTmpl->getTemplatedDecl()->getBody(Definition))
+ return Definition->isOutOfLine();
+ }
+
+ return false;
+}
+
//===----------------------------------------------------------------------===//
// TagDecl Implementation
//===----------------------------------------------------------------------===//