summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiate.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-05-25 22:47:05 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-05-25 22:47:05 +0000
commit883dbc43d9b3f939c129d557833989c61dbae27d (patch)
tree4d03f0ad102e3995a12096f12ebf1795693520cd /clang/lib/Sema/SemaTemplateInstantiate.cpp
parent5099ddfdf7ecf0221c5b808e0726235e289a40ab (diff)
downloadbcm5719-llvm-883dbc43d9b3f939c129d557833989c61dbae27d.tar.gz
bcm5719-llvm-883dbc43d9b3f939c129d557833989c61dbae27d.zip
Switch from using a DiagnosticTrap and a note for "while defining a special
member function" context notes to registering an entry on the context stack. Also reorder the steps within defining special members to be consistent. This has a few benefits: if multiple diagnostics are produced while checking such a member, the note is now attached to the first such diagnostic rather than the last, this prepares us for persisting these diagnostics between the point at which we require the implicit instantiation of a template and the point at which that instantiation is actually performed, and this fixes some cases where we would fail to produce a full note stack leading back to user code in the case of such a diagnostic. The reordering exposed a case where we could recursively attempt to define a defaulted destructor while we're already defining one (and other such cases also appear to be possible, with or without this change), so this change also reuses the "willHaveBody" flag on function declarations to track that we're in the middle of synthesizing a body for the function and bails out if we try to define a function that we're already defining. llvm-svn: 303930
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 2d44489023e..a654ca800b0 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -197,6 +197,7 @@ bool Sema::CodeSynthesisContext::isInstantiationRecord() const {
case DefaultTemplateArgumentChecking:
case DeclaringSpecialMember:
+ case DefiningSynthesizedFunction:
return false;
}
@@ -624,6 +625,17 @@ void Sema::PrintInstantiationStack() {
diag::note_in_declaration_of_implicit_special_member)
<< cast<CXXRecordDecl>(Active->Entity) << Active->SpecialMember;
break;
+
+ case CodeSynthesisContext::DefiningSynthesizedFunction:
+ // FIXME: For synthesized members other than special members, produce a note.
+ auto *MD = dyn_cast<CXXMethodDecl>(Active->Entity);
+ auto CSM = MD ? getSpecialMember(MD) : CXXInvalid;
+ if (CSM != CXXInvalid) {
+ Diags.Report(Active->PointOfInstantiation,
+ diag::note_member_synthesized_at)
+ << CSM << Context.getTagDeclType(MD->getParent());
+ }
+ break;
}
}
}
@@ -666,6 +678,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const {
return Active->DeductionInfo;
case CodeSynthesisContext::DeclaringSpecialMember:
+ case CodeSynthesisContext::DefiningSynthesizedFunction:
// This happens in a context unrelated to template instantiation, so
// there is no SFINAE.
return None;
OpenPOWER on IntegriCloud