From: Ted Kremenek Date: Thu, 21 Feb 2013 21:40:44 +0000 (+0000) Subject: Teach serialized diagnostics about notes without locations. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c6ebda167f524ae32f2c2b97d7b1a2de76013ce7;p=platform%2Fupstream%2Fllvm.git Teach serialized diagnostics about notes without locations. Along the way, improve a diagnostic for "previous declaration here" for implicit parameters. Fixes . llvm-svn: 175802 --- diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 3377a68..64e4eab 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -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 " diff --git a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp index 8eb0e40..4bb662b 100644 --- a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -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; } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 2858f36..7411e80 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -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(ND) + ? diag::note_implicit_param_decl + : diag::note_previous_decl; + + Diag(ND->getLocation(), diag) << CorrectedQuotedStr; + } // Tell the callee to try to recover. return false;