From 76dea9547d6aadbabbcb597b5e1d3f4ec529d031 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 14 Oct 2008 23:51:43 +0000 Subject: [PATCH] Prevent assert when using '"' in names (via hexadecimal). Update LangRef to mention \xx quoting in names. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57538 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LangRef.html | 5 +++-- lib/VMCore/AsmWriter.cpp | 3 +-- test/Assembler/2008-10-14-QuoteInName.ll | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 test/Assembler/2008-10-14-QuoteInName.ll diff --git a/docs/LangRef.html b/docs/LangRef.html index 27bcb920025..f8ca2879c44 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -335,8 +335,9 @@ the parser.

For example, %foo, @DivisionByZero, %a.really.long.identifier. The actual regular expression used is '[%@][a-zA-Z$._][a-zA-Z$._0-9]*'. Identifiers which require other characters in their names can be surrounded - with quotes. In this way, anything except a " character can - be used in a named value. + with quotes. Special characters may be escaped using "\xx" where xx is the + ASCII code for the character in hexadecimal. In this way, any character can + be used in a name value, even quotes themselves.
  • Unnamed values are represented as an unsigned numeric value with their prefix. For example, %12, @2, %44.
  • diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index ddcb8d6c0ab..0080d63b63a 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -112,10 +112,9 @@ static void PrintLLVMName(raw_ostream &OS, const char *NameStr, OS << '"'; for (unsigned i = 0; i != NameLen; ++i) { char C = NameStr[i]; - assert(C != '"' && "Illegal character in LLVM value name!"); if (C == '\\') { OS << "\\\\"; - } else if (isprint(C)) { + } else if (C != '"' && isprint(C)) { OS << C; } else { OS << '\\'; diff --git a/test/Assembler/2008-10-14-QuoteInName.ll b/test/Assembler/2008-10-14-QuoteInName.ll new file mode 100644 index 00000000000..ccd77791caa --- /dev/null +++ b/test/Assembler/2008-10-14-QuoteInName.ll @@ -0,0 +1,3 @@ +; RUN: llvm-as < %s | llvm-dis | grep "quote" + +@"a\22quote" = global i32 0