[clang] 4eae6fc - [clang] Fix incorrect call to TextDiagnostic::printDiagnosticMessage

Andrzej Warzynski via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 21 01:42:37 PDT 2020


Author: Andrzej Warzynski
Date: 2020-09-21T09:41:39+01:00
New Revision: 4eae6fc95f95563a73a510a8b09cfce01004930a

URL: https://github.com/llvm/llvm-project/commit/4eae6fc95f95563a73a510a8b09cfce01004930a
DIFF: https://github.com/llvm/llvm-project/commit/4eae6fc95f95563a73a510a8b09cfce01004930a.diff

LOG: [clang] Fix incorrect call to TextDiagnostic::printDiagnosticMessage

As per the documentation, the 2nd argument in printDiagnosticMessage
should be a bool that specifies whether the underlying message is a
continuation note diagnostic or not. More specifically, it should be:
```
Level == DiagnosticsEngine::Note
```
instead of:
```
Level
```

This change means that `no input file` in the following scenario will be
now correctly printed in bold:
```
$ bin/clang
clang: error: no input files
```
In terminals that don't support text formatting the behaviour doesn't
change.

Differential Revision: https://reviews.llvm.org/D87816

Added: 
    

Modified: 
    clang/lib/Frontend/TextDiagnosticPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
index 0c0a44a1388b..9feb3c64039f 100644
--- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -135,10 +135,10 @@ void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
   if (!Info.getLocation().isValid()) {
     TextDiagnostic::printDiagnosticLevel(OS, Level, DiagOpts->ShowColors,
                                          DiagOpts->CLFallbackMode);
-    TextDiagnostic::printDiagnosticMessage(OS, Level, DiagMessageStream.str(),
-                                           OS.tell() - StartOfLocationInfo,
-                                           DiagOpts->MessageLength,
-                                           DiagOpts->ShowColors);
+    TextDiagnostic::printDiagnosticMessage(
+        OS, /*IsSupplemental=*/Level == DiagnosticsEngine::Note,
+        DiagMessageStream.str(), OS.tell() - StartOfLocationInfo,
+        DiagOpts->MessageLength, DiagOpts->ShowColors);
     OS.flush();
     return;
   }


        


More information about the cfe-commits mailing list