mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Allow module aliases to use escaped identifiers as the alias name.
The original module names themselves must still be valid unescaped identifiers; most of the serialization logic in the compiler depends on the name of a module matching its name on the file system, and it would be very complex to turn escaped identifiers into file-safe names.
This commit is contained in:
committed by
Tony Allevato
parent
329261593e
commit
2b0f9aa765
@@ -936,9 +936,12 @@ bool ModuleAliasesConverter::computeModuleAliases(std::vector<std::string> args,
|
||||
// it should be called only once
|
||||
options.ModuleAliasMap.clear();
|
||||
|
||||
auto validate = [&options, &diags](StringRef value, bool allowModuleName) -> bool
|
||||
{
|
||||
if (!allowModuleName) {
|
||||
// validatingModuleName should be true if validating the alias target (an
|
||||
// actual module name), or true if validating the alias name (which can be
|
||||
// an escaped identifier).
|
||||
auto validate = [&options, &diags](StringRef value,
|
||||
bool validatingModuleName) -> bool {
|
||||
if (!validatingModuleName) {
|
||||
if (value == options.ModuleName ||
|
||||
value == options.ModuleABIName ||
|
||||
value == options.ModuleLinkName ||
|
||||
@@ -947,7 +950,8 @@ bool ModuleAliasesConverter::computeModuleAliases(std::vector<std::string> args,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!Lexer::isIdentifier(value)) {
|
||||
if ((validatingModuleName && !Lexer::isIdentifier(value)) ||
|
||||
!Lexer::isValidAsEscapedIdentifier(value)) {
|
||||
diags.diagnose(SourceLoc(), diag::error_bad_module_name, value, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user