mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 20:59:51 +00:00
Make it explicit that nulls are not allowed in names.
The object files we support use null terminated strings, so there is no way to support these. This patch adds an assert to catch bad API use and an error check in the .ll parser. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a49e1f55da
commit
edeaa6454e
@ -275,6 +275,10 @@ lltok::Kind LLLexer::LexAt() {
|
||||
if (CurChar == '"') {
|
||||
StrVal.assign(TokStart+2, CurPtr-1);
|
||||
UnEscapeLexed(StrVal);
|
||||
if (StringRef(StrVal).find_first_of(0) != StringRef::npos) {
|
||||
Error("Null bytes are not allowed in names");
|
||||
return lltok::Error;
|
||||
}
|
||||
return lltok::GlobalVar;
|
||||
}
|
||||
}
|
||||
|
@ -182,6 +182,8 @@ void Value::setName(const Twine &NewName) {
|
||||
|
||||
SmallString<256> NameData;
|
||||
StringRef NameRef = NewName.toStringRef(NameData);
|
||||
assert(NameRef.find_first_of(0) == StringRef::npos &&
|
||||
"Null bytes are not allowed in names");
|
||||
|
||||
// Name isn't changing?
|
||||
if (getName() == NameRef)
|
||||
|
6
test/Assembler/invalid-name.ll
Normal file
6
test/Assembler/invalid-name.ll
Normal file
@ -0,0 +1,6 @@
|
||||
; RUN: not llvm-as %s 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: expected function name
|
||||
define void @"zed\00bar"() {
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue
Block a user