1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[llvm-rc] Don't strictly require quotes around external file names

Regardless of what docs may say, existing resource files in the
wild can use this syntax.

Rename a file used in an existing test, to make it usable for unquoted
paths.

Differential Revision: https://reviews.llvm.org/D46511

llvm-svn: 331747
This commit is contained in:
Martin Storsjo 2018-05-08 08:47:37 +00:00
parent 6671624d13
commit 86c2d3ee20
8 changed files with 26 additions and 13 deletions

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 110 B

After

Width:  |  Height:  |  Size: 110 B

View File

@ -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

View File

@ -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 ,

View File

@ -214,6 +214,12 @@ Expected<StringRef> RCParser::readString() {
return read().value();
}
Expected<StringRef> RCParser::readFilename() {
if (!isNextTokenKind(Kind::String) && !isNextTokenKind(Kind::Identifier))
return getExpectedError("string");
return read().value();
}
Expected<StringRef> 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<CursorResource>(*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<UserDefinedResource>(Type, read().value());
default:
break;
}
RETURN_IF_ERROR(consumeType(Kind::BlockBegin));
std::vector<IntOrString> Data;
@ -487,17 +498,17 @@ Expected<Control> RCParser::parseControl() {
}
RCParser::ParseType RCParser::parseBitmapResource() {
ASSIGN_OR_RETURN(Arg, readString());
ASSIGN_OR_RETURN(Arg, readFilename());
return llvm::make_unique<BitmapResource>(*Arg);
}
RCParser::ParseType RCParser::parseIconResource() {
ASSIGN_OR_RETURN(Arg, readString());
ASSIGN_OR_RETURN(Arg, readFilename());
return llvm::make_unique<IconResource>(*Arg);
}
RCParser::ParseType RCParser::parseHTMLResource() {
ASSIGN_OR_RETURN(Arg, readString());
ASSIGN_OR_RETURN(Arg, readFilename());
return llvm::make_unique<HTMLResource>(*Arg);
}

View File

@ -84,6 +84,7 @@ private:
Expected<RCInt> readInt(); // Parse an integer.
Expected<StringRef> readString(); // Parse a string.
Expected<StringRef> readIdentifier(); // Parse an identifier.
Expected<StringRef> readFilename(); // Parse a filename.
Expected<IntOrString> readIntOrString(); // Parse an integer or a string.
Expected<IntOrString> readTypeOrName(); // Parse an integer or an identifier.

View File

@ -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 {