aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/TextDiagnosticPrinter.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-09-26 01:30:09 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-09-26 01:30:09 +0000
commita3ba6bbac30a3bec488ee7071d203df9d8bcd05d (patch)
tree3850eb1bc907da4ec322a6db0b3f74fe9c316c68 /lib/Frontend/TextDiagnosticPrinter.cpp
parent253d41d74cd449742fd8642753c3076514fb99c5 (diff)
Switch some of my recently added helper functions to use the proper
style, and add doxyments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140495 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/TextDiagnosticPrinter.cpp')
-rw-r--r--lib/Frontend/TextDiagnosticPrinter.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index 189a93cac5..9705b3c48b 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -1059,7 +1059,10 @@ void TextDiagnosticPrinter::EmitDiagnosticLoc(DiagnosticsEngine::Level Level,
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 @@ static void PrintDiagnosticLevel(raw_ostream &OS,
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 @@ void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
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) {