[PATCH] Add diagnostic capabilities in LLVM (frontend part)
Dmitri Gribenko
gribozavr at gmail.com
Tue Feb 4 14:26:35 PST 2014
LGTM with this.
================
Comment at: lib/CodeGen/CodeGenAction.cpp:211-214
@@ -197,2 +210,6 @@
+
void InlineAsmDiagHandler2(const llvm::SMDiagnostic &,
SourceLocation LocCookie);
+
+ void DiagnosticHandler2(const llvm::DiagnosticInfo &DI);
+ /// \brief Specialized handler for InlineAsm diagnostic.
----------------
Maybe name these functions with *Impl suffix, instead of '2'?
================
Comment at: lib/CodeGen/CodeGenAction.cpp:388
@@ -277,2 +387,3 @@
+}
//
----------------
Please replace this empty comment with #undef ComputeDiagID
================
Comment at: lib/CodeGen/CodeGenAction.cpp:380-383
@@ +379,6 @@
+ std::string MsgStorage;
+ raw_string_ostream Stream(MsgStorage);
+ DiagnosticPrinterRawOStream DP(Stream);
+ DI.print(DP);
+ Stream.flush();
+
----------------
There is no need to flush the stream. Just introduce a separate scope for the stream, and it will flush automatically in the destructor.
================
Comment at: lib/CodeGen/CodeGenAction.cpp:359
@@ +358,3 @@
+void BackendConsumer::DiagnosticHandler2(const DiagnosticInfo &DI) {
+ FullSourceLoc Loc;
+ unsigned DiagID = diag::err_fe_inline_asm;
----------------
Please move this variable down to its only user.
================
Comment at: test/Frontend/backend-diagnostic.c:16-18
@@ +15,5 @@
+
+// REGULAR: warning: stack size exceeded ({{[0-9]+}}) in stackSizeWarning
+// PROMOTE: error: stack size exceeded ({{[0-9]+}}) in stackSizeWarning
+// IGNORE-NOT: stack size exceeded ({{[0-9]+}}) in stackSizeWarning
+void stackSizeWarning() {
----------------
Please also add a test that these diagnostics can be checked with -verify.
http://llvm-reviews.chandlerc.com/D2430
More information about the cfe-commits
mailing list