Skip to content

Commit 17a6ef5

Browse files
author
Nathan Hawes
committed
Clear any LLVMArgs when initializing the CompilerInvocation for SourceKit's ASTManager
SourceKit doesn't use them and if any unrecognised LLVM options are passed to llvm::cl::ParseCommandLineOptions() it calls exit(), bringing down SourceKit. Also use fprintf instead of llvm::errs() in Logging.cpp as it uses a global C++ object that had already been destructed when logging the above failure. Resolves rdar://problem/38314383
1 parent 4058407 commit 17a6ef5

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
_ = ""
2+
3+
// rdar://problem/38314383
4+
// RUN: %sourcekitd-test -req=cursor -offset=0 %s -- -Xllvm -aarch64-use-tbi %s | %FileCheck %s
5+
6+
// CHECK: <empty cursor info>

tools/SourceKit/lib/Support/Logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Logger::~Logger() {
6363
OS << llvm::format("%7.4f] ", TR.getWallTime() - sBeginTR.getWallTime());
6464
OS << Msg.str();
6565

66-
llvm::errs() << LoggerName << ": " << LogMsg.str() << '\n';
66+
fprintf(stderr, "%s: %s", LoggerName.c_str(), LogMsg.c_str());
6767

6868
#if __APPLE__
6969
// Use the Apple System Log facility.

tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ bool SwiftASTManager::initCompilerInvocation(CompilerInvocation &Invocation,
459459
// SwiftONoneSupport module.
460460
FrontendOpts.RequestedAction = FrontendOptions::ActionType::Typecheck;
461461

462+
// We don't care about LLVMArgs
463+
FrontendOpts.LLVMArgs.clear();
464+
462465
return false;
463466
}
464467

0 commit comments

Comments
 (0)