[PATCH] Adding ID and Warning Option to Diagnostic Log

Argyrios Kyrtzidis kyrtzidis at apple.com
Thu Nov 13 14:47:57 PST 2014


+  DE.WarningOption = "";
+  StringRef WarningOption = DiagnosticIDs::getWarningOptionForDiag(DE.DiagnosticID);
+  if (!WarningOption.empty()) {
+    DE.WarningOption = WarningOption.str();
+  }
+

Is there a reason this can’t be simplified to

DE.WarningOption = DiagnosticIDs::getWarningOptionForDiag(DE.DiagnosticID);

?

Otherwise LGTM.

> On Nov 5, 2014, at 1:31 PM, Steven Wu <stevenwu at apple.com> wrote:
> 
> Ping. Is there anyone concerned about this change? 
> 
>> On Oct 15, 2014, at 6:08 PM, Steven Wu <stevenwu at apple.com <mailto:stevenwu at apple.com>> wrote:
>> 
>> Hi
>> 
>> This patch adds two more fields to diagnostic log (not serialize-diagnostic). The two new fields are DiagnosticID and Warning Option. I find them very handy in detecting and categorizing diagnostics.
>> The added fields are in a dict type in a plist so it is unlikely to break any existing tools that read diagnostic logs. 
>> 
>> Steven
>> 
>> --
>> include/clang/Frontend/LogDiagnosticPrinter.h |  3 +++
>> lib/Frontend/LogDiagnosticPrinter.cpp         | 14 ++++++++++++++
>> 2 files changed, 17 insertions(+)
>> 
>> diff --git a/include/clang/Frontend/LogDiagnosticPrinter.h b/include/clang/Frontend/LogDiagnosticPrinter.h
>> index 8d60e9b..98adf65 100644
>> --- a/include/clang/Frontend/LogDiagnosticPrinter.h
>> +++ b/include/clang/Frontend/LogDiagnosticPrinter.h
>> @@ -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;
>> diff --git a/lib/Frontend/LogDiagnosticPrinter.cpp b/lib/Frontend/LogDiagnosticPrinter.cpp
>> index c2dcd1b..19a4660 100644
>> --- a/lib/Frontend/LogDiagnosticPrinter.cpp
>> +++ b/lib/Frontend/LogDiagnosticPrinter.cpp
>> @@ -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,12 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
>>  DE.DiagnosticID = Info.getID();
>>  DE.DiagnosticLevel = Level;
>> 
>> +  DE.WarningOption = "";
>> +  StringRef WarningOption = DiagnosticIDs::getWarningOptionForDiag(DE.DiagnosticID);
>> +  if (!WarningOption.empty()) {
>> +    DE.WarningOption = WarningOption.str();
>> +  }
>> +
>>  // Format the message.
>>  SmallString<100> MessageStr;
>>  Info.FormatDiagnostic(MessageStr);
>> 
>> <Diaglog.patch>
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu <mailto:cfe-commits at cs.uiuc.edu>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits <http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141113/dbe8a356/attachment.html>


More information about the cfe-commits mailing list