aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-05-07 09:03:25 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-05-07 09:03:25 +0000
commitb8590f3572158bde97f14037c4cc8f4a57c8d810 (patch)
tree6c05c5b75bbe232f21aabf95c569cda5bd493563 /lib/Sema/Sema.cpp
parent4a7376d00df98cbfcad29ee709637707a2f3d46c (diff)
When we suppress an error due to SFINAE, stash the diagnostic away with the
overload candidate, and include its message in any subsequent 'candidate not viable due to substitution failure' note we may produce. To keep the note small (since the 'overload resolution failed' diagnostics are often already very verbose), the text of the SFINAE diagnostic is included as part of the text of the note, and any notes which were attached to it are discarded. There happened to be spare space in OverloadCandidate into which a PartialDiagnosticAt could be squeezed, and this patch goes to lengths to avoid unnecessary PartialDiagnostic copies, resulting in no slowdown that I could measure. (Removal in passing of some PartialDiagnostic copies has resulted in a slightly smaller clang binary overall.) Even on a torture test, I was unable to measure a memory increase of above 0.2%. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r--lib/Sema/Sema.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 5017c2cdf5..9f2880fb4e 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -698,6 +698,15 @@ void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
// Count this failure so that we know that template argument deduction
// has failed.
++NumSFINAEErrors;
+
+ // Make a copy of this suppressed diagnostic and store it with the
+ // template-deduction information.
+ if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
+ Diagnostic DiagInfo(&Diags);
+ (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
+ PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
+ }
+
Diags.setLastDiagnosticIgnored();
Diags.Clear();
return;
@@ -714,6 +723,15 @@ void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
// Suppress this diagnostic.
++NumSFINAEErrors;
+
+ // Make a copy of this suppressed diagnostic and store it with the
+ // template-deduction information.
+ if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
+ Diagnostic DiagInfo(&Diags);
+ (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
+ PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
+ }
+
Diags.setLastDiagnosticIgnored();
Diags.Clear();
@@ -730,13 +748,13 @@ void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
case DiagnosticIDs::SFINAE_Suppress:
// Make a copy of this suppressed diagnostic and store it with the
// template-deduction information;
- Diagnostic DiagInfo(&Diags);
-
- if (*Info)
+ if (*Info) {
+ Diagnostic DiagInfo(&Diags);
(*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(),
- PartialDiagnostic(DiagInfo,Context.getDiagAllocator()));
-
- // Suppress this diagnostic.
+ PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
+ }
+
+ // Suppress this diagnostic.
Diags.setLastDiagnosticIgnored();
Diags.Clear();
return;