Skip to content

Commit 4ad3a55

Browse files
committed
Exit early args are invalid
Add batch-code-compelte test
1 parent 0fc4fe2 commit 4ad3a55

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ class CompilerInvocation {
316316
/// of the binary on disk, /path/to/Bar.swiftmodule(interface), under the hood.
317317
/// \param diags Used to print diagnostics in case validation of the string args fails.
318318
/// See \c ModuleAliasesConverter::computeModuleAliases on validation details.
319-
void setModuleAliasMap(std::vector<std::string> args, DiagnosticEngine &diags);
319+
/// \return Whether setting module alias map succeeded; false if args validation fails.
320+
bool setModuleAliasMap(std::vector<std::string> args, DiagnosticEngine &diags);
320321

321322
std::string getOutputFilename() const {
322323
return FrontendOpts.InputsAndOutputs.getSingleOutputFilename();

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ void CompilerInvocation::setSDKPath(const std::string &Path) {
262262
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts.Target);
263263
}
264264

265-
void CompilerInvocation::setModuleAliasMap(std::vector<std::string> args,
265+
bool CompilerInvocation::setModuleAliasMap(std::vector<std::string> args,
266266
DiagnosticEngine &diags) {
267-
ModuleAliasesConverter::computeModuleAliases(args, FrontendOpts, diags);
267+
return ModuleAliasesConverter::computeModuleAliases(args, FrontendOpts, diags);
268268
}
269269

270270
static bool ParseFrontendArgs(

test/IDE/module-aliasing-repl-code-complete.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
// CHECK: Begin completions
2121
// CHECK-NOT: AppleLogging
22-
// CHECK-DAG: XLogging
22+
// CHECK: XLogging
2323
// CHECK: End completions
2424

2525
// BEGIN FileLogging.swift

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4242,7 +4242,10 @@ int main(int argc, char *argv[]) {
42424242
SourceManager SM;
42434243
DiagnosticEngine Diags(SM);
42444244
Diags.addConsumer(PDC);
4245-
InitInvok.setModuleAliasMap(options::ModuleAliases, Diags);
4245+
if (!InitInvok.setModuleAliasMap(options::ModuleAliases, Diags)) {
4246+
llvm::errs() << "invalid module alias arguments\n";
4247+
return 1;
4248+
}
42464249
}
42474250

42484251
// Process the clang arguments last and allow them to override previously

0 commit comments

Comments
 (0)