Skip to content

Commit df21c6c

Browse files
author
David Ungar
committed
Taking Jordan's suggestions.
1 parent ccb7378 commit df21c6c

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

include/swift/Frontend/FrontendOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ class FrontendOptions {
548548

549549
static bool doesActionProduceOutput(ActionType);
550550
static bool doesActionProduceTextualOutput(ActionType);
551-
static bool doesActionImplyMainModule(ActionType);
551+
static bool needsProperModuleName(ActionType);
552552
};
553553

554554
}

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ bool FrontendArgsToOptionsConverter::computeModuleName() {
640640
(Opts.ModuleName != STDLIB_NAME || Opts.ParseStdlib)) {
641641
return false;
642642
}
643-
if (FrontendOptions::doesActionImplyMainModule(Opts.RequestedAction) ||
643+
if (!FrontendOptions::needsProperModuleName(Opts.RequestedAction) ||
644644
Opts.isCompilingExactlyOneSwiftFile()) {
645645
Opts.ModuleName = "main";
646646
return false;
@@ -681,8 +681,9 @@ bool FrontendArgsToOptionsConverter::computeFallbackModuleName() {
681681
}
682682

683683
bool FrontendArgsToOptionsConverter::computeOutputFilenames() {
684+
assert(Opts.OutputFilenames.empty() &&
685+
"Output filename should not be set at this point");
684686
if (!FrontendOptions::doesActionProduceOutput(Opts.RequestedAction)) {
685-
Opts.OutputFilenames.clear();
686687
return false;
687688
}
688689
ArrayRef<std::string> outputFilenamesFromCommandLineOrFilelist =

lib/Frontend/FrontendOptions.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void FrontendInputs::transformInputFilenames(
9696
}
9797
}
9898

99-
bool FrontendOptions::doesActionImplyMainModule(ActionType action) {
99+
bool FrontendOptions::needsProperModuleName(ActionType action) {
100100
switch (action) {
101101
case ActionType::NoneAction:
102102
case ActionType::Parse:
@@ -108,24 +108,24 @@ bool FrontendOptions::doesActionImplyMainModule(ActionType action) {
108108
case ActionType::PrintAST:
109109
case ActionType::DumpScopeMaps:
110110
case ActionType::DumpTypeRefinementContexts:
111-
return true;
111+
return false;
112112
case ActionType::EmitPCH:
113113
case ActionType::EmitSILGen:
114114
case ActionType::EmitSIL:
115115
case ActionType::EmitSIBGen:
116116
case ActionType::EmitSIB:
117117
case ActionType::EmitModuleOnly:
118118
case ActionType::MergeModules:
119-
return false;
119+
return true;
120120
case ActionType::Immediate:
121121
case ActionType::REPL:
122-
return true;
122+
return false;
123123
case ActionType::EmitAssembly:
124124
case ActionType::EmitIR:
125125
case ActionType::EmitBC:
126126
case ActionType::EmitObject:
127127
case ActionType::EmitImportedModules:
128-
return false;
128+
return true;
129129
}
130130
llvm_unreachable("Unknown ActionType");
131131
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
// RUN: rm -rf %t && mkdir -p %t && cd %t && echo >test.swift && %swift -interpret test.swift && rm test.swift && test `ls | wc -w` -eq 0
1+
// RUN: %empty-directory(%t)
2+
// RUN: cd %t && %target-swift-frontend -interpret %S/../Inputs/empty.swift
3+
// RUN: not ls %t/*

0 commit comments

Comments
 (0)