Add DiagID and Warning Flag to DiagnosticsLog
authorSteven Wu <stevenwu@apple.com>
Fri, 14 Nov 2014 21:23:56 +0000 (21:23 +0000)
committerSteven Wu <stevenwu@apple.com>
Fri, 14 Nov 2014 21:23:56 +0000 (21:23 +0000)
llvm-svn: 222042

clang/include/clang/Frontend/LogDiagnosticPrinter.h
clang/lib/Frontend/LogDiagnosticPrinter.cpp

index 8d60e9b..98adf65 100644 (file)
@@ -35,6 +35,9 @@ class LogDiagnosticPrinter : public DiagnosticConsumer {
   
     /// The ID of the diagnostic.
     unsigned DiagnosticID;
+
+    /// The Option Flag for the diagnostic
+    std::string WarningOption;
   
     /// The level of the diagnostic.
     DiagnosticsEngine::Level DiagnosticLevel;
index c2dcd1b..c6a18e0 100644 (file)
@@ -63,6 +63,14 @@ LogDiagnosticPrinter::EmitDiagEntry(llvm::raw_ostream &OS,
        << "      ";
     EmitString(OS, DE.Message) << '\n';
   }
+  OS << "      <key>ID</key>\n"
+     << "      ";
+  EmitInteger(OS, DE.DiagnosticID) << '\n';
+  if (!DE.WarningOption.empty()) {
+    OS << "      <key>WarningOption</key>\n"
+       << "      ";
+    EmitString(OS, DE.WarningOption) << '\n';
+  }
   OS << "    </dict>\n";
 }
 
@@ -122,6 +130,8 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
   DE.DiagnosticID = Info.getID();
   DE.DiagnosticLevel = Level;
 
+  DE.WarningOption = DiagnosticIDs::getWarningOptionForDiag(DE.DiagnosticID);
+
   // Format the message.
   SmallString<100> MessageStr;
   Info.FormatDiagnostic(MessageStr);