Index: test/tools/llvm-rc/Inputs/include.rc =================================================================== --- test/tools/llvm-rc/Inputs/include.rc +++ test/tools/llvm-rc/Inputs/include.rc @@ -1,2 +1,3 @@ -// Found because bitmap.bmp is in same directory -foo BITMAP "bitmap.bmp" \ No newline at end of file +// Found because bitmap.bmp is in same directory. +// Test including filenames without quotes. +foo BITMAP bitmap.bmp Index: test/tools/llvm-rc/parser.test =================================================================== --- test/tools/llvm-rc/parser.test +++ test/tools/llvm-rc/parser.test @@ -145,11 +145,6 @@ ; PLANGUAGE2: llvm-rc: Error parsing file: expected '-', '~', integer or '(', got , -; RUN: not llvm-rc /dry-run /V %p/Inputs/parser-html-bad-string.rc 2>&1 | FileCheck %s --check-prefix PHTML1 - -; PHTML1: llvm-rc: Error parsing file: expected string, got ThisPassesInTheOriginalToolButDocSaysItShouldBeQuoted - - ; RUN: not llvm-rc /dry-run /V %p/Inputs/parser-html-extra-comma.rc 2>&1 | FileCheck %s --check-prefix PHTML2 ; PHTML2: llvm-rc: Error parsing file: expected string, got , Index: tools/llvm-rc/ResourceScriptParser.h =================================================================== --- tools/llvm-rc/ResourceScriptParser.h +++ tools/llvm-rc/ResourceScriptParser.h @@ -84,6 +84,7 @@ Expected readInt(); // Parse an integer. Expected readString(); // Parse a string. Expected readIdentifier(); // Parse an identifier. + Expected readFilename(); // Parse a filename. Expected readIntOrString(); // Parse an integer or a string. Expected readTypeOrName(); // Parse an integer or an identifier. Index: tools/llvm-rc/ResourceScriptParser.cpp =================================================================== --- tools/llvm-rc/ResourceScriptParser.cpp +++ tools/llvm-rc/ResourceScriptParser.cpp @@ -214,6 +214,12 @@ return read().value(); } +Expected RCParser::readFilename() { + if (!isNextTokenKind(Kind::String) && !isNextTokenKind(Kind::Identifier)) + return getExpectedError("string"); + return read().value(); +} + Expected RCParser::readIdentifier() { if (!isNextTokenKind(Kind::Identifier)) return getExpectedError("identifier"); @@ -385,7 +391,7 @@ } RCParser::ParseType RCParser::parseCursorResource() { - ASSIGN_OR_RETURN(Arg, readString()); + ASSIGN_OR_RETURN(Arg, readFilename()); return llvm::make_unique(*Arg); } @@ -427,8 +433,13 @@ return getExpectedError("filename, '{' or BEGIN"); // Check if this is a file resource. - if (look().kind() == Kind::String) + switch (look().kind()) { + case Kind::String: + case Kind::Identifier: return llvm::make_unique(Type, read().value()); + default: + break; + } RETURN_IF_ERROR(consumeType(Kind::BlockBegin)); std::vector Data; @@ -487,17 +498,17 @@ } RCParser::ParseType RCParser::parseBitmapResource() { - ASSIGN_OR_RETURN(Arg, readString()); + ASSIGN_OR_RETURN(Arg, readFilename()); return llvm::make_unique(*Arg); } RCParser::ParseType RCParser::parseIconResource() { - ASSIGN_OR_RETURN(Arg, readString()); + ASSIGN_OR_RETURN(Arg, readFilename()); return llvm::make_unique(*Arg); } RCParser::ParseType RCParser::parseHTMLResource() { - ASSIGN_OR_RETURN(Arg, readString()); + ASSIGN_OR_RETURN(Arg, readFilename()); return llvm::make_unique(*Arg); } Index: tools/llvm-rc/ResourceScriptToken.cpp =================================================================== --- tools/llvm-rc/ResourceScriptToken.cpp +++ tools/llvm-rc/ResourceScriptToken.cpp @@ -281,13 +281,13 @@ assert(!streamEof()); const char CurChar = Data[Pos]; - return std::isalpha(CurChar) || CurChar == '_'; + return std::isalpha(CurChar) || CurChar == '_' || CurChar == '.'; } bool Tokenizer::canContinueIdentifier() const { assert(!streamEof()); const char CurChar = Data[Pos]; - return std::isalnum(CurChar) || CurChar == '_'; + return std::isalnum(CurChar) || CurChar == '_' || CurChar == '.' || CurChar == '/'; } bool Tokenizer::canStartInt() const {