Skip to content

Commit cceafcf

Browse files
committed
[Frontend] Move the package name option from frontend to LangOptions
1 parent 732a7f6 commit cceafcf

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ namespace swift {
396396
/// Access or distribution level of the whole module being parsed.
397397
LibraryLevel LibraryLevel = LibraryLevel::Other;
398398

399+
/// The name of the package this module belongs to.
400+
std::string PackageName;
401+
399402
/// Warn about cases where Swift 3 would infer @objc but later versions
400403
/// of Swift do not.
401404
Swift3ObjCInferenceWarnings WarnSwift3ObjCInference =

include/swift/Frontend/FrontendOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ class FrontendOptions {
6464
/// The name of the library to link against when using this module.
6565
std::string ModuleLinkName;
6666

67-
/// The name of the package this module belongs to.
68-
std::string PackageName;
69-
7067
/// Module name to use when referenced in clients module interfaces.
7168
std::string ExportAsName;
7269

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,6 @@ bool ArgsToFrontendOptionsConverter::convert(
269269
if (const Arg *A = Args.getLastArg(OPT_module_link_name))
270270
Opts.ModuleLinkName = A->getValue();
271271

272-
if (const Arg *A = Args.getLastArg(OPT_package_name)) {
273-
auto pkgName = A->getValue();
274-
if (!Lexer::isIdentifier(pkgName))
275-
Diags.diagnose(SourceLoc(), diag::error_bad_package_name, pkgName);
276-
else if (pkgName == STDLIB_NAME)
277-
Diags.diagnose(SourceLoc(), diag::error_stdlib_package_name, pkgName);
278-
else
279-
Opts.PackageName = pkgName;
280-
}
281-
282272
if (const Arg *A = Args.getLastArg(OPT_export_as)) {
283273
auto exportAs = A->getValue();
284274
if (!Lexer::isIdentifier(exportAs))

lib/Frontend/CompilerInvocation.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,16 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
739739
}
740740
}
741741

742+
if (const Arg *A = Args.getLastArg(OPT_package_name)) {
743+
auto pkgName = A->getValue();
744+
if (!Lexer::isIdentifier(pkgName))
745+
Diags.diagnose(SourceLoc(), diag::error_bad_package_name, pkgName);
746+
else if (pkgName == STDLIB_NAME)
747+
Diags.diagnose(SourceLoc(), diag::error_stdlib_package_name, pkgName);
748+
else
749+
Opts.PackageName = pkgName;
750+
}
751+
742752
if (const Arg *A = Args.getLastArg(OPT_require_explicit_availability_EQ)) {
743753
StringRef diagLevel = A->getValue();
744754
if (diagLevel == "warn") {

lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,9 +1088,9 @@ ModuleDecl *CompilerInstance::getMainModule() const {
10881088
MainModule->setABIName(getASTContext().getIdentifier(
10891089
Invocation.getFrontendOptions().ModuleABIName));
10901090
}
1091-
if (!Invocation.getFrontendOptions().PackageName.empty()) {
1091+
if (!Invocation.getLangOptions().PackageName.empty()) {
10921092
MainModule->setPackageName(getASTContext().getIdentifier(
1093-
Invocation.getFrontendOptions().PackageName));
1093+
Invocation.getLangOptions().PackageName));
10941094
}
10951095
if (!Invocation.getFrontendOptions().ExportAsName.empty()) {
10961096
MainModule->setExportAsName(getASTContext().getIdentifier(

0 commit comments

Comments
 (0)