[llvm] r223907 - AsmParser: Don't allow null bytes in BB labels

David Majnemer david.majnemer at gmail.com
Tue Dec 9 18:10:36 PST 2014


Author: majnemer
Date: Tue Dec  9 20:10:35 2014
New Revision: 223907

URL: http://llvm.org/viewvc/llvm-project?rev=223907&view=rev
Log:
AsmParser: Don't allow null bytes in BB labels

Since Value objects can't have null bytes in their name, we shouldn't
allow them in the labels of basic blocks.

Added:
    llvm/trunk/test/Assembler/invalid-name2.ll
Modified:
    llvm/trunk/lib/AsmParser/LLLexer.cpp

Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=223907&r1=223906&r2=223907&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp Tue Dec  9 20:10:35 2014
@@ -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;

Added: llvm/trunk/test/Assembler/invalid-name2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-name2.ll?rev=223907&view=auto
==============================================================================
Binary files llvm/trunk/test/Assembler/invalid-name2.ll (added) and llvm/trunk/test/Assembler/invalid-name2.ll Tue Dec  9 20:10:35 2014 differ





More information about the llvm-commits mailing list