[PATCH] MCParser: introduce Note and use it for ARM AsmParser

Saleem Abdulrasool compnerd at compnerd.org
Fri Dec 27 19:43:19 PST 2013


Hi logan, rengolin, grosbach,

Introduce a new virtual method Note into the AsmParser.  This complements the
existing Warning and Error methods.  Use the new method to clean up the output
of the unwind routines in the ARM AsmParser.

http://llvm-reviews.chandlerc.com/D2482

Files:
  include/llvm/MC/MCParser/MCAsmParser.h
  lib/MC/MCParser/AsmParser.cpp
  lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  test/MC/ARM/eh-directive-cantunwind-diagnostics.s
  test/MC/ARM/eh-directive-fnstart-diagnostics.s

Index: include/llvm/MC/MCParser/MCAsmParser.h
===================================================================
--- include/llvm/MC/MCParser/MCAsmParser.h
+++ include/llvm/MC/MCParser/MCAsmParser.h
@@ -118,6 +118,10 @@
                                 const MCInstPrinter *IP,
                                 MCAsmParserSemaCallback &SI) = 0;
 
+  /// Note - Emit a note at the location \p L, with the message \p Msg.
+  virtual void Note(SMLoc L, const Twine &Msg,
+                    ArrayRef<SMRange> Ranges = None) = 0;
+
   /// Warning - Emit a warning at the location \p L, with the message \p Msg.
   ///
   /// \return The return value is true, if warnings are fatal.
Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -211,6 +211,7 @@
     AssemblerDialect = i;
   }
 
+  virtual void Note(SMLoc L, const Twine &Msg, ArrayRef<SMRange> Ranges = None);
   virtual bool Warning(SMLoc L, const Twine &Msg,
                        ArrayRef<SMRange> Ranges = None);
   virtual bool Error(SMLoc L, const Twine &Msg,
@@ -537,6 +538,11 @@
                  "while in macro instantiation");
 }
 
+void AsmParser::Note(SMLoc L, const Twine &Msg, ArrayRef<SMRange> Ranges) {
+  printMessage(L, SourceMgr::DK_Note, Msg, Ranges);
+  printMacroInstantiations();
+}
+
 bool AsmParser::Warning(SMLoc L, const Twine &Msg, ArrayRef<SMRange> Ranges) {
   if (FatalAssemblerWarnings)
     return Error(L, Msg, Ranges);
Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -188,6 +188,9 @@
   MCAsmParser &getParser() const { return Parser; }
   MCAsmLexer &getLexer() const { return Parser.getLexer(); }
 
+  void Note(SMLoc L, const Twine &Msg, ArrayRef<SMRange> Ranges = None) {
+    return Parser.Note(L, Msg, Ranges);
+  }
   bool Warning(SMLoc L, const Twine &Msg,
                ArrayRef<SMRange> Ranges = None) {
     return Parser.Warning(L, Msg, Ranges);
@@ -8183,7 +8186,7 @@
 bool ARMAsmParser::parseDirectiveFnStart(SMLoc L) {
   if (FnStartLoc.isValid()) {
     Error(L, ".fnstart starts before the end of previous one");
-    Error(FnStartLoc, "previous .fnstart starts here");
+    Note(FnStartLoc, "previous .fnstart starts here");
     return true;
   }
 
@@ -8214,12 +8217,12 @@
     return Error(L, ".fnstart must precede .cantunwind directive");
   if (HandlerDataLoc.isValid()) {
     Error(L, ".cantunwind can't be used with .handlerdata directive");
-    Error(HandlerDataLoc, ".handlerdata was specified here");
+    Note(HandlerDataLoc, ".handlerdata was specified here");
     return true;
   }
   if (PersonalityLoc.isValid()) {
     Error(L, ".cantunwind can't be used with .personality directive");
-    Error(PersonalityLoc, ".personality was specified here");
+    Note(PersonalityLoc, ".personality was specified here");
     return true;
   }
 
@@ -8236,12 +8239,12 @@
     return Error(L, ".fnstart must precede .personality directive");
   if (CantUnwindLoc.isValid()) {
     Error(L, ".personality can't be used with .cantunwind directive");
-    Error(CantUnwindLoc, ".cantunwind was specified here");
+    Note(CantUnwindLoc, ".cantunwind was specified here");
     return true;
   }
   if (HandlerDataLoc.isValid()) {
     Error(L, ".personality must precede .handlerdata directive");
-    Error(HandlerDataLoc, ".handlerdata was specified here");
+    Note(HandlerDataLoc, ".handlerdata was specified here");
     return true;
   }
 
@@ -8267,7 +8270,7 @@
     return Error(L, ".fnstart must precede .personality directive");
   if (CantUnwindLoc.isValid()) {
     Error(L, ".handlerdata can't be used with .cantunwind directive");
-    Error(CantUnwindLoc, ".cantunwind was specified here");
+    Note(CantUnwindLoc, ".cantunwind was specified here");
     return true;
   }
 
Index: test/MC/ARM/eh-directive-cantunwind-diagnostics.s
===================================================================
--- test/MC/ARM/eh-directive-cantunwind-diagnostics.s
+++ test/MC/ARM/eh-directive-cantunwind-diagnostics.s
@@ -24,7 +24,7 @@
 @ CHECK: error: .personality can't be used with .cantunwind directive
 @ CHECK:        .personality __gxx_personality_v0
 @ CHECK:        ^
-@ CHECK: error: .cantunwind was specified here
+@ CHECK: note: .cantunwind was specified here
 @ CHECK:        .cantunwind
 @ CHECK:        ^
         .fnend
@@ -44,7 +44,7 @@
 @ CHECK: error: .handlerdata can't be used with .cantunwind directive
 @ CHECK:        .handlerdata
 @ CHECK:        ^
-@ CHECK: error: .cantunwind was specified here
+@ CHECK: note: .cantunwind was specified here
 @ CHECK:        .cantunwind
 @ CHECK:        ^
         .fnend
@@ -64,7 +64,7 @@
 @ CHECK: error: .cantunwind can't be used with .personality directive
 @ CHECK:        .cantunwind
 @ CHECK:        ^
-@ CHECK: error: .personality was specified here
+@ CHECK: note: .personality was specified here
 @ CHECK:        .personality __gxx_personality_v0
 @ CHECK:        ^
         .fnend
@@ -84,7 +84,7 @@
 @ CHECK: error: .cantunwind can't be used with .handlerdata directive
 @ CHECK:        .cantunwind
 @ CHECK:        ^
-@ CHECK: error: .handlerdata was specified here
+@ CHECK: note: .handlerdata was specified here
 @ CHECK:        .handlerdata
 @ CHECK:        ^
         .fnend
Index: test/MC/ARM/eh-directive-fnstart-diagnostics.s
===================================================================
--- test/MC/ARM/eh-directive-fnstart-diagnostics.s
+++ test/MC/ARM/eh-directive-fnstart-diagnostics.s
@@ -24,7 +24,7 @@
 @ CHECK: error: .fnstart starts before the end of previous one
 @ CHECK:        .fnstart
 @ CHECK:        ^
-@ CHECK: error: previous .fnstart starts here
+@ CHECK: note: previous .fnstart starts here
 @ CHECK:        .fnstart
 @ CHECK:        ^
 func2:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2482.1.patch
Type: text/x-patch
Size: 5959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131227/ee55706a/attachment.bin>


More information about the llvm-commits mailing list