Skip to content

Commit cc01780

Browse files
[ClangImporter] Don't add clang path when creating from cc1 commands
When creating ClangImporter directly from cc1 args, there is no need for clang path, and it might even be mistaken as an input path. Don't use clang executable path in the arguments when creating from cc1 commands.
1 parent 68db1b4 commit cc01780

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,9 +976,10 @@ ClangImporter::getOrCreatePCH(const ClangImporterOptions &ImporterOptions,
976976
std::vector<std::string>
977977
ClangImporter::getClangArguments(ASTContext &ctx) {
978978
std::vector<std::string> invocationArgStrs;
979-
// Clang expects this to be like an actual command line. So we need to pass in
980-
// "clang" for argv[0]
981-
invocationArgStrs.push_back(ctx.ClangImporterOpts.clangPath);
979+
// When creating from driver commands, clang expects this to be like an actual
980+
// command line. So we need to pass in "clang" for argv[0]
981+
if (!ctx.ClangImporterOpts.DirectClangCC1ModuleBuild)
982+
invocationArgStrs.push_back(ctx.ClangImporterOpts.clangPath);
982983
if (ctx.ClangImporterOpts.ExtraArgsOnly) {
983984
invocationArgStrs.insert(invocationArgStrs.end(),
984985
ctx.ClangImporterOpts.ExtraArgs.begin(),

test/ClangImporter/pcm-emit-direct-cc1-mode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// CHECK-DUMP: Module map file: {{.*[/\\]}}Inputs{{/|\\}}custom-modules{{/|\\}}module.map
1010

1111
// Verify that the clang command-line used is cc1
12-
// RUN: %FileCheck -check-prefix CHECK-CLANG %s < %t.diags.txt
13-
// CHECK-CLANG: '{{.*[/\\]}}clang'{{.*}}'-fmodules'
12+
// RUN: %FileCheck -check-prefix CHECK-CLANG -DTRIPLE=%target-triple %s < %t.diags.txt
13+
// CHECK-CLANG: '{{.*[/\\]}}module.map' '-o' '{{.*[/\\]}}script.pcm' '-fmodules' '-triple' '[[TRIPLE]]' '-x' 'objective-c'
1414

1515
import script
1616
var _ : ScriptTy

0 commit comments

Comments
 (0)