diff --git a/test/tools/llvm-rc/Inputs/deep-include.rc b/test/tools/llvm-rc/Inputs/deep-include.rc index b28fa8f243a..5097a90f960 100644 Binary files a/test/tools/llvm-rc/Inputs/deep-include.rc and b/test/tools/llvm-rc/Inputs/deep-include.rc differ diff --git a/test/tools/llvm-rc/Inputs/include-noquotes.rc b/test/tools/llvm-rc/Inputs/include-noquotes.rc new file mode 100644 index 00000000000..11c971f32b3 Binary files /dev/null and b/test/tools/llvm-rc/Inputs/include-noquotes.rc differ diff --git a/test/tools/llvm-rc/Inputs/nested/nested-bitmap.bmp b/test/tools/llvm-rc/Inputs/nested/nested_bitmap.bmp similarity index 100% rename from test/tools/llvm-rc/Inputs/nested/nested-bitmap.bmp rename to test/tools/llvm-rc/Inputs/nested/nested_bitmap.bmp diff --git a/test/tools/llvm-rc/include-paths.test b/test/tools/llvm-rc/include-paths.test index f24cc449504..e6c52b12d6d 100644 --- a/test/tools/llvm-rc/include-paths.test +++ b/test/tools/llvm-rc/include-paths.test @@ -3,6 +3,11 @@ ; RUN: llvm-rc /FO %t.include.res %p/Inputs/include.rc ; RUN: llvm-readobj %t.include.res | FileCheck --check-prefix=FOUND %s +; Try including files without quotes. +; RUN: rm -f %t.noquotes.res +; RUN: llvm-rc /FO %t.noquotes.res %p/Inputs/include-noquotes.rc +; RUN: llvm-readobj %t.noquotes.res | FileCheck --check-prefix=FOUND %s + ; Should find the bitmap if the folder is explicitly specified. ; RUN: rm -f %t.nested-include.res ; RUN: llvm-rc /FO %t.nested-include.res /I %p/Inputs/nested %p/Inputs/deep-include.rc @@ -41,4 +46,4 @@ FOUND-NEXT: 0050: FFFFFF0E C9FF0000 241CEDFF FFFF0000 |........$.......| FOUND-NEXT: ) MISSING: llvm-rc: Error in BITMAP statement (ID foo): -MISSING-NEXT: error : file not found : nested-bitmap.bmp +MISSING-NEXT: error : file not found : nested_bitmap.bmp diff --git a/test/tools/llvm-rc/parser.test b/test/tools/llvm-rc/parser.test index 112e4859a9b..66ed7386e82 100644 --- a/test/tools/llvm-rc/parser.test +++ b/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 , diff --git a/tools/llvm-rc/ResourceScriptParser.cpp b/tools/llvm-rc/ResourceScriptParser.cpp index ffa18bdf198..7123df9029a 100644 --- a/tools/llvm-rc/ResourceScriptParser.cpp +++ b/tools/llvm-rc/ResourceScriptParser.cpp @@ -214,6 +214,12 @@ Expected RCParser::readString() { 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::parseAcceleratorsResource() { } RCParser::ParseType RCParser::parseCursorResource() { - ASSIGN_OR_RETURN(Arg, readString()); + ASSIGN_OR_RETURN(Arg, readFilename()); return llvm::make_unique(*Arg); } @@ -427,8 +433,13 @@ RCParser::ParseType RCParser::parseUserDefinedResource(IntOrString Type) { 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 @@ Expected RCParser::parseControl() { } 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); } diff --git a/tools/llvm-rc/ResourceScriptParser.h b/tools/llvm-rc/ResourceScriptParser.h index e22619a5834..639ef63863c 100644 --- a/tools/llvm-rc/ResourceScriptParser.h +++ b/tools/llvm-rc/ResourceScriptParser.h @@ -84,6 +84,7 @@ private: 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. diff --git a/tools/llvm-rc/ResourceScriptToken.cpp b/tools/llvm-rc/ResourceScriptToken.cpp index 7bbf0d16f04..fc0a0e91845 100644 --- a/tools/llvm-rc/ResourceScriptToken.cpp +++ b/tools/llvm-rc/ResourceScriptToken.cpp @@ -281,13 +281,14 @@ bool Tokenizer::canStartIdentifier() const { 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 == '/' || CurChar == '\\'; } bool Tokenizer::canStartInt() const {