[cfe-commits] r140495 - /cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp

Chandler Carruth chandlerc at gmail.com
Sun Sep 25 18:30:09 PDT 2011


Author: chandlerc
Date: Sun Sep 25 20:30:09 2011
New Revision: 140495

URL: http://llvm.org/viewvc/llvm-project?rev=140495&view=rev
Log:
Switch some of my recently added helper functions to use the proper
style, and add doxyments.

Modified:
    cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp

Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=140495&r1=140494&r2=140495&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Sun Sep 25 20:30:09 2011
@@ -1059,7 +1059,10 @@
   OS << ' ';
 }
 
-static void PrintDiagnosticLevel(raw_ostream &OS,
+/// \brief Print the diagonstic level to a raw_ostream.
+///
+/// Handles colorizing the level and formatting.
+static void printDiagnosticLevel(raw_ostream &OS,
                                  DiagnosticsEngine::Level Level,
                                  bool ShowColors) {
   if (ShowColors) {
@@ -1086,12 +1089,22 @@
     OS.resetColor();
 }
 
-static void PrintDiagnosticName(raw_ostream &OS, const Diagnostic &Info) {
+/// \brief Print the diagnostic name to a raw_ostream.
+///
+/// This prints the diagnostic name to a raw_ostream if it has one. It formats
+/// the name according to the expected diagnostic message formatting:
+///   " [diagnostic_name_here]"
+static void printDiagnosticName(raw_ostream &OS, const Diagnostic &Info) {
   if (!DiagnosticIDs::isBuiltinNote(Info.getID()))
     OS << " [" << DiagnosticIDs::getName(Info.getID()) << "]";
 }
 
-static void PrintDiagnosticOptions(raw_ostream &OS,
+/// \brief Print any diagnostic option information to a raw_ostream.
+///
+/// This implements all of the logic for adding diagnostic options to a message
+/// (via OS). Each relevant option is comma separated and all are enclosed in
+/// the standard bracketing: " [...]".
+static void printDiagnosticOptions(raw_ostream &OS,
                                    DiagnosticsEngine::Level Level,
                                    const Diagnostic &Info,
                                    const DiagnosticOptions &DiagOpts) {
@@ -1179,15 +1192,15 @@
       OS.resetColor();
   }
 
-  PrintDiagnosticLevel(OS, Level, DiagOpts->ShowColors);
+  printDiagnosticLevel(OS, Level, DiagOpts->ShowColors);
 
   llvm::SmallString<100> OutStr;
   Info.FormatDiagnostic(OutStr);
 
   llvm::raw_svector_ostream DiagMessageStream(OutStr);
   if (DiagOpts->ShowNames)
-    PrintDiagnosticName(DiagMessageStream, Info);
-  PrintDiagnosticOptions(DiagMessageStream, Level, Info, *DiagOpts);
+    printDiagnosticName(DiagMessageStream, Info);
+  printDiagnosticOptions(DiagMessageStream, Level, Info, *DiagOpts);
   DiagMessageStream.flush();
 
   if (DiagOpts->ShowColors) {





More information about the cfe-commits mailing list