]> granicus.if.org Git - clang/commitdiff
Properly update the FormattedArgs vector when the template type diffing falls
authorRichard Trieu <rtrieu@google.com>
Tue, 10 Jul 2012 01:46:04 +0000 (01:46 +0000)
committerRichard Trieu <rtrieu@google.com>
Tue, 10 Jul 2012 01:46:04 +0000 (01:46 +0000)
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
lib/AST/ASTDiagnostic.cpp
lib/Basic/Diagnostic.cpp

index e46bbb6d1b4f6de776302bc7a098eb6bef74e112..7e2227b52f67210d3027c2dc8e58e13ebc0d8ceb 100644 (file)
@@ -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
index fbeca43090251eac210ec308604f8b18e7c796db..35fcd41f26e5576db1c73257219fa87a77be6836 100644 (file)
@@ -254,7 +254,7 @@ void clang::FormatASTNodeDiagnosticArgument(
   switch (Kind) {
     default: llvm_unreachable("unknown ArgumentKind");
     case DiagnosticsEngine::ak_qualtype_pair: {
-      const TemplateDiffTypes &TDT = *reinterpret_cast<TemplateDiffTypes*>(Val);
+      TemplateDiffTypes &TDT = *reinterpret_cast<TemplateDiffTypes*>(Val);
       QualType FromType =
           QualType::getFromOpaquePtr(reinterpret_cast<void*>(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;
       }
 
index d5ccd64f875bed7cee5e3d1fb5590fc7c0beb66c..fdc37b63cba03360440e7eac1eadbd8d3a036173 100644 (file)
@@ -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<intptr_t>(&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;