]> granicus.if.org Git - clang/commitdiff
Teach serialized diagnostics about notes without locations.
authorTed Kremenek <kremenek@apple.com>
Thu, 21 Feb 2013 21:40:44 +0000 (21:40 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 21 Feb 2013 21:40:44 +0000 (21:40 +0000)
Along the way, improve a diagnostic for "previous declaration here" for implicit parameters.

Fixes <rdar://problem/13211384>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175802 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Frontend/SerializedDiagnosticPrinter.cpp
lib/Sema/SemaExpr.cpp

index 3377a68911d46b819ccb8f28db27f54160d1b40e..64e4eab373a145ef7a8cbc7a3f34051a441df79d 100644 (file)
@@ -1090,6 +1090,7 @@ def note_field_decl : Note<"member is declared here">;
 def note_ivar_decl : Note<"instance variable is declared here">;
 def note_bitfield_decl : Note<"bit-field is declared here">;
 def note_previous_decl : Note<"%0 declared here">;
+def note_implicit_param_decl : Note<"%0 is an implicit parameter">;
 def note_member_synthesized_at : Note<
   "implicit default %select{constructor|copy constructor|move constructor|copy "
   "assignment operator|move assignment operator|destructor}0 for %1 first "
index 8eb0e40b01b8604c8f511074081322592cfd25eb..4bb662bb2650c81b173faf82c44affa7695d345e 100644 (file)
@@ -543,8 +543,18 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
     // Special-case diagnostics with no location. We may not have entered a
     // source file in this case, so we can't use the normal DiagnosticsRenderer
     // machinery.
+
+    // Make sure we bracket all notes as "sub-diagnostics".  This matches
+    // the behavior in SDiagsRenderer::emitDiagnostic().
+    if (DiagLevel == DiagnosticsEngine::Note)
+      EnterDiagBlock();
+
     EmitDiagnosticMessage(SourceLocation(), PresumedLoc(), DiagLevel,
                           State->diagBuf, 0, &Info);
+
+    if (DiagLevel == DiagnosticsEngine::Note)
+      ExitDiagBlock();
+
     return;
   }
 
index 2858f36511fa4aa02b22d1710c60a6c2a31b33c5..7411e809dbb9a2c5f97ec8592ddb138446293393 100644 (file)
@@ -1672,9 +1672,14 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
             << SS.getRange()
             << FixItHint::CreateReplacement(Corrected.getCorrectionRange(),
                                             CorrectedStr);
-        if (ND)
-          Diag(ND->getLocation(), diag::note_previous_decl)
+        if (ND) {
+          unsigned diag = isa<ImplicitParamDecl>(ND)
+            ? diag::note_implicit_param_decl
+            : diag::note_previous_decl;
+
+          Diag(ND->getLocation(), diag)
             << CorrectedQuotedStr;
+        }
 
         // Tell the callee to try to recover.
         return false;