Added llvm-mc support for parsing the .abort directive.
[oota-llvm.git] / tools / llvm-mc / AsmParser.cpp
index fe9d4f3352ffc9c6dc1964c4ea49a629ab44cf78..c105801632830b6d78105e4def794061ccf7da93 100644 (file)
@@ -529,6 +529,8 @@ bool AsmParser::ParseStatement() {
 
     if (!strcmp(IDVal, ".subsections_via_symbols"))
       return ParseDirectiveDarwinSubsectionsViaSymbols();
+    if (!strcmp(IDVal, ".abort"))
+      return ParseDirectiveAbort();
 
     Warning(IDLoc, "ignoring directive for now");
     EatToEndOfStatement();
@@ -1068,3 +1070,26 @@ bool AsmParser::ParseDirectiveDarwinSubsectionsViaSymbols() {
 
   return false;
 }
+
+/// ParseDirectiveAbort
+///  ::= .abort [ "abort_string" ]
+bool AsmParser::ParseDirectiveAbort() {
+  const char *Str = NULL;
+  if (Lexer.isNot(asmtok::EndOfStatement)) {
+    if (Lexer.isNot(asmtok::String))
+      return TokError("expected string in '.abort' directive");
+    
+    Str = Lexer.getCurStrVal();
+
+    Lexer.Lex();
+  }
+
+  if (Lexer.isNot(asmtok::EndOfStatement))
+    return TokError("unexpected token in '.abort' directive");
+  
+  Lexer.Lex();
+
+  Out.AbortAssembly(Str);
+
+  return false;
+}