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. llvm-svn: 195155
This commit is contained in:
parent
92045bc37c
commit
09d689f90c
|
@ -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)
|
||||
|
|
|
@ -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