Skip to content

Commit 2817883

Browse files
committed
[Compile Time Constant Extraction] Allow quoted protocol names inside argument list to '-const-gather-protocols-file'
1 parent 5d832bf commit 2817883

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/ConstExtract/ConstExtract.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ parseProtocolListFromFile(StringRef protocolListFilePath,
9898
ParseFailed = true;
9999
break;
100100
}
101-
protocols.insert(ScalarNode->getRawValue().str());
101+
auto protocolNameStr = ScalarNode->getRawValue().str();
102+
if (protocolNameStr.front() == '"' && protocolNameStr.back() == '"')
103+
protocolNameStr = protocolNameStr.substr(1, protocolNameStr.size() - 2);
104+
protocols.insert(protocolNameStr);
102105
}
103106
} else
104107
ParseFailed = true;

test/Frontend/emit-const-values-file.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: echo 'print("Hello, World!")' > %t/main.swift
3-
// RUN: echo "[Foo]" > %t/protocols.json
3+
// RUN: echo "["Foo"]" > %t/protocols.json
44
// RUN: cd %t
55

66
// RUN: %target-swift-frontend -typecheck -const-gather-protocols-file %t/protocols.json -emit-const-values-path %t/main.swiftconstvalues -primary-file %t/main.swift

0 commit comments

Comments
 (0)