COFF: Fix lexer for the module-definition file.
authorRui Ueyama <ruiu@google.com>
Thu, 25 Jun 2015 21:06:00 +0000 (21:06 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 25 Jun 2015 21:06:00 +0000 (21:06 +0000)
Previously it would hang if there's a stray punctuation (e.g. ?).

llvm-svn: 240697

lld/COFF/ModuleDef.cpp
lld/test/COFF/defparser.test [new file with mode: 0644]

index 8c19519..c7bc2b2 100644 (file)
@@ -82,9 +82,7 @@ public:
       return Token(Identifier, S);
     }
     default: {
-      size_t End = Buf.find_first_not_of(
-          "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-          "0123456789_.*~+!@#$%^&*()/");
+      size_t End = Buf.find_first_of("=,\r\n \t\v");
       StringRef Word = Buf.substr(0, End);
       Kind K = llvm::StringSwitch<Kind>(Word)
                    .Case("BASE", KwBase)
diff --git a/lld/test/COFF/defparser.test b/lld/test/COFF/defparser.test
new file mode 100644 (file)
index 0000000..a964839
--- /dev/null
@@ -0,0 +1,13 @@
+# RUN: yaml2obj < %p/Inputs/ret42.yaml > %t.obj
+
+# RUN: echo -e "LIBRARY foo\nEXPORTS ? @" > %t.def
+# RUN: not lld -flavor link2 /def:%t.def %t.obj
+
+# RUN: echo -e "LIBRARY foo\nHEAP abc" > %t.def
+# RUN: not lld -flavor link2 /def:%t.def %t.obj
+
+# RUN: echo -e "LIBRARY foo\nSTACK abc" > %t.def
+# RUN: not lld -flavor link2 /def:%t.def %t.obj
+
+# RUN: echo -e "foo" > %t.def
+# RUN: not lld -flavor link2 /def:%t.def %t.obj