summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayoutBuilder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/RecordLayoutBuilder.cpp')
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index 3a1e248dbc0..4c7b9119348 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -663,6 +663,20 @@ void ASTRecordLayoutBuilder::UpdateAlignment(unsigned NewAlignment) {
Alignment = NewAlignment;
}
+static bool MethodHasBody(const CXXMethodDecl *MD, const FunctionDecl *&fn) {
+ // Simple case: function has a body
+ if (MD->getBody(fn))
+ return true;
+
+ // Complex case: function is an instantiation of a function which has a
+ // body, but the definition hasn't been instantiated.
+ const FunctionDecl *PatternDecl = MD->getTemplateInstantiationPattern();
+ if (PatternDecl && PatternDecl->getBody(fn))
+ return true;
+
+ return false;
+}
+
static const CXXMethodDecl *GetKeyFunction(const CXXRecordDecl *RD) {
if (!RD->isDynamicClass())
return 0;
@@ -683,7 +697,7 @@ static const CXXMethodDecl *GetKeyFunction(const CXXRecordDecl *RD) {
continue;
const FunctionDecl *fn;
- if (MD->getBody(fn) && !fn->isOutOfLine())
+ if (MethodHasBody(MD, fn) && !fn->isOutOfLine())
continue;
// We found it.
OpenPOWER on IntegriCloud