Skip to content

Commit 39d204d

Browse files
committed
[IDE, SourceKit] Pass in clang as arg[0] in initInvocationByClangArguments
This applies the same fix as cfdb8ac, but this time to libIDE so that SourceKit and swift-ide-test will also pass in an appropriate argv[0]. Re-enable the tests that broke. rdar://problem/24431137
1 parent 07e7949 commit 39d204d

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/IDE/Utils.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,15 @@ bool ide::initInvocationByClangArguments(ArrayRef<const char *> ArgList,
238238
&DiagBuf,
239239
/*ShouldOwnClient=*/false);
240240

241+
// Clang expects this to be like an actual command line. So we need to pass in
242+
// "clang" for argv[0].
243+
std::vector<const char *> ClangArgList;
244+
ClangArgList.push_back("clang");
245+
ClangArgList.insert(ClangArgList.end(), ArgList.begin(), ArgList.end());
246+
241247
// Create a new Clang compiler invocation.
242248
llvm::IntrusiveRefCntPtr<clang::CompilerInvocation> ClangInvok{
243-
clang::createInvocationFromCommandLine(ArgList, ClangDiags)
249+
clang::createInvocationFromCommandLine(ClangArgList, ClangDiags)
244250
};
245251
if (!ClangInvok || ClangDiags->hasErrorOccurred()) {
246252
for (auto I = DiagBuf.err_begin(), E = DiagBuf.err_end(); I != E; ++I) {

test/IDE/print_clang_header.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// FIXME: rdar://problem/19648117 Needs splitting objc parts out
22
// XFAIL: linux
3-
// REQUIRES: OS=macosx
43

54
// RUN: echo '#include "header-to-print.h"' > %t.m
65
// RUN: %target-swift-ide-test -source-filename %s -print-header -header-to-print %S/Inputs/print_clang_header/header-to-print.h -print-regular-comments --cc-args %target-cc-options -isysroot %clang-importer-sdk-path -fsyntax-only %t.m -I %S/Inputs/print_clang_header > %t.txt

test/IDE/print_clang_header_swift_name.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// RUN: -isysroot %clang-importer-sdk-path -fsyntax-only %t.m -I %S/Inputs | FileCheck %s
55

66
// REQUIRES: objc_interop
7-
// REQUIRES: OS=macosx
87

98
// CHECK: enum Normal : Int {
109
// CHECK-NOT: {{^}}}

0 commit comments

Comments
 (0)