From 5409d28b6167032696f4915bb765a6f7db579f3f Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Tue, 10 Jul 2012 01:46:04 +0000 Subject: [PATCH] Properly update the FormattedArgs vector when the template type diffing falls back to regular type printing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159976 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Diagnostic.h | 2 ++ lib/AST/ASTDiagnostic.cpp | 3 ++- lib/Basic/Diagnostic.cpp | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index e46bbb6d1b..7e2227b52f 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -1286,6 +1286,8 @@ struct TemplateDiffTypes { unsigned PrintFromType : 1; unsigned ElideType : 1; unsigned ShowColors : 1; + // The printer sets this variable to true if the template diff was used. + unsigned TemplateDiffUsed : 1; }; /// Special character that the diagnostic printer will use to toggle the bold diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index fbeca43090..35fcd41f26 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -254,7 +254,7 @@ void clang::FormatASTNodeDiagnosticArgument( switch (Kind) { default: llvm_unreachable("unknown ArgumentKind"); case DiagnosticsEngine::ak_qualtype_pair: { - const TemplateDiffTypes &TDT = *reinterpret_cast(Val); + TemplateDiffTypes &TDT = *reinterpret_cast(Val); QualType FromType = QualType::getFromOpaquePtr(reinterpret_cast(TDT.FromType)); QualType ToType = @@ -264,6 +264,7 @@ void clang::FormatASTNodeDiagnosticArgument( TDT.PrintFromType, TDT.ElideType, TDT.ShowColors, S)) { NeedQuotes = !TDT.PrintTree; + TDT.TemplateDiffUsed = true; break; } diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index d5ccd64f87..fdc37b63cb 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -821,6 +821,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, TDT.ToType = getRawArg(ArgNo2); TDT.ElideType = getDiags()->ElideType; TDT.ShowColors = getDiags()->ShowColors; + TDT.TemplateDiffUsed = false; intptr_t val = reinterpret_cast(&TDT); const char *ArgumentEnd = Argument + ArgumentLen; @@ -859,6 +860,10 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, Argument, ArgumentLen, FormattedArgs.data(), FormattedArgs.size(), OutStr, QualTypeVals); + if (!TDT.TemplateDiffUsed) + FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, + TDT.FromType)); + // Append middle text FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr); @@ -869,6 +874,10 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, Argument, ArgumentLen, FormattedArgs.data(), FormattedArgs.size(), OutStr, QualTypeVals); + if (!TDT.TemplateDiffUsed) + FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype, + TDT.ToType)); + // Append end text FormatDiagnostic(SecondDollar + 1, Pipe, OutStr); break; -- 2.40.0