summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rc/ResourceScriptParser.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-05-08 08:47:37 +0000
committerMartin Storsjo <martin@martin.st>2018-05-08 08:47:37 +0000
commit4021cee996f75e8f591991e53180d1d29dfd20d6 (patch)
tree4e932f1e242fc9ae996064de1f6995b0ce322717 /llvm/tools/llvm-rc/ResourceScriptParser.cpp
parent5e6e6cc7213616038cc781ca21d9c532beb8e220 (diff)
downloadbcm5719-llvm-4021cee996f75e8f591991e53180d1d29dfd20d6.tar.gz
bcm5719-llvm-4021cee996f75e8f591991e53180d1d29dfd20d6.zip
[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
Diffstat (limited to 'llvm/tools/llvm-rc/ResourceScriptParser.cpp')
-rw-r--r--llvm/tools/llvm-rc/ResourceScriptParser.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.cpp b/llvm/tools/llvm-rc/ResourceScriptParser.cpp
index ffa18bdf198..7123df9029a 100644
--- a/llvm/tools/llvm-rc/ResourceScriptParser.cpp
+++ b/llvm/tools/llvm-rc/ResourceScriptParser.cpp
@@ -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);
}
OpenPOWER on IntegriCloud