Skip to content

Commit ecc241a

Browse files
authored
Merge pull request #61555 from artemcm/SanitizeProtocolListForConstExtraction
[Compile Time Constant Extraction] Allow quoted protocol names insideargument list to '-const-gather-protocols-file'
2 parents 73dddfc + 2817883 commit ecc241a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/ConstExtract/ConstExtract.cpp

Lines changed: 4 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)