AsmParser: Don't allow null bytes in BB labels
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 10 Dec 2014 02:10:35 +0000 (02:10 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 10 Dec 2014 02:10:35 +0000 (02:10 +0000)
Since Value objects can't have null bytes in their name, we shouldn't
allow them in the labels of basic blocks.

llvm-svn: 223907

llvm/lib/AsmParser/LLLexer.cpp
llvm/test/Assembler/invalid-name2.ll [new file with mode: 0644]

index cd7f09b..ca3c9e8 100644 (file)
@@ -393,7 +393,12 @@ lltok::Kind LLLexer::LexQuote() {
 
   if (CurPtr[0] == ':') {
     ++CurPtr;
-    kind = lltok::LabelStr;
+    if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
+      Error("Null bytes are not allowed in names");
+      kind = lltok::Error;
+    } else {
+      kind = lltok::LabelStr;
+    }
   }
 
   return kind;
diff --git a/llvm/test/Assembler/invalid-name2.ll b/llvm/test/Assembler/invalid-name2.ll
new file mode 100644 (file)
index 0000000..384dee6
Binary files /dev/null and b/llvm/test/Assembler/invalid-name2.ll differ