[llvm-commits] [PATCH] Allow single quoted strings in integrated-as .

dl9pf at gmx.de dl9pf at gmx.de
Wed Oct 31 14:55:25 PDT 2012


From: Jan-Simon Möller <dl9pf at gmx.de>

pax-linux-llvm x86_integrated-as-single-quoted-string.patch

Patch from series at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120507/142707.html by PaX Team.
---
 lib/MC/MCParser/AsmLexer.cpp    |   12 ++++++++++--
 test/MC/AsmParser/singlequote.s |   11 +++++++++++
 2 Dateien geändert, 21 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
 create mode 100644 test/MC/AsmParser/singlequote.s

diff --git a/lib/MC/MCParser/AsmLexer.cpp b/lib/MC/MCParser/AsmLexer.cpp
index f93f685..2841e20 100644
--- a/lib/MC/MCParser/AsmLexer.cpp
+++ b/lib/MC/MCParser/AsmLexer.cpp
@@ -279,8 +279,16 @@ AsmToken AsmLexer::LexSingleQuote() {
 
   CurChar = getNextChar();
 
-  if (CurChar != '\'')
-    return ReturnError(TokStart, "single quote way too long");
+  if (CurChar != '\'') {
+    while (CurChar != '\'') {
+      if (CurChar == EOF)
+        return ReturnError(TokStart, "unterminated string constant");
+
+      CurChar = getNextChar();
+    }
+
+    return AsmToken(AsmToken::String, StringRef(TokStart, CurPtr - TokStart));
+  }
 
   // The idea here being that 'c' is basically just an integral
   // constant.
diff --git a/test/MC/AsmParser/singlequote.s b/test/MC/AsmParser/singlequote.s
new file mode 100644
index 0000000..314ee74
--- /dev/null
+++ b/test/MC/AsmParser/singlequote.s
@@ -0,0 +1,11 @@
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+
+# CHECK: TEST0:
+# CHECK: a = aaa
+TEST0:
+        a = 'aaa'
+
+# CHECK: TEST1:
+# CHECK: a = 97
+TEST1:
+        a = 'a'
-- 
1.7.10.4




More information about the llvm-commits mailing list