[PATCH] MC: do not try to parse invalid handled directives

Saleem Abdulrasool compnerd at compnerd.org
Sun Dec 15 13:38:03 PST 2013


  Add a test case.

Hi t.p.northover, dblaikie,

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

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2410?vs=6104&id=6110#toc

Files:
  lib/MC/MCParser/AsmParser.cpp
  test/MC/AsmParser/target-directives.s

Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -1327,6 +1327,9 @@
     if (!getTargetParser().ParseDirective(ID))
       return false;
 
+    if (HadError)
+      return false;
+
     // Next, check the extention directive map to see if any extension has
     // registered itself to parse this directive.
     std::pair<MCAsmParserExtension *, DirectiveHandler> Handler =
Index: test/MC/AsmParser/target-directives.s
===================================================================
--- /dev/null
+++ test/MC/AsmParser/target-directives.s
@@ -0,0 +1,8 @@
+# RUN: llvm-mc -triple i386-unknown-unknown -filetype obj -o /dev/null 2> %t \
+# RUN:   | FileCheck %s %t
+
+	.code42
+
+# CHECK: unexpected directive .code42
+# CHECK-NOT: unknown directive
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2410.2.patch
Type: text/x-patch
Size: 882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131215/936beafc/attachment.bin>


More information about the llvm-commits mailing list