Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

[CrashReproducer] Handle indexing turned on with CLANG_PROJECT_INDEX_PATH. #354

Open
wants to merge 1 commit into
base: upstream-with-swift
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions include/clang/Driver/Job.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ class Tool;
struct CrashReportInfo {
StringRef Filename;
StringRef VFSPath;
StringRef IndexStorePath;
bool HaveIndexStorePath;

CrashReportInfo(StringRef Filename, StringRef VFSPath,
StringRef IndexStorePath)
: Filename(Filename), VFSPath(VFSPath), IndexStorePath(IndexStorePath) {}
bool HaveIndexStorePath)
: Filename(Filename), VFSPath(VFSPath),
HaveIndexStorePath(HaveIndexStorePath) {}
};

/// Command - An executable path/name and argument vector to
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ void Driver::generateCompilationDiagnostics(
// Assume associated files are based off of the first temporary file.
CrashReportInfo CrashInfo(
TempFiles[0], VFS,
C.getArgs().getLastArgValue(options::OPT_index_store_path));
llvm::is_contained(Cmd.getArguments(), StringRef("-index-store-path")));

llvm::SmallString<128> Script(CrashInfo.Filename);
llvm::sys::path::replace_extension(Script, "sh");
Expand Down
3 changes: 1 addition & 2 deletions lib/Driver/Job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ void Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
}

bool HaveCrashVFS = CrashInfo && !CrashInfo->VFSPath.empty();
bool HaveIndexStorePath = CrashInfo && !CrashInfo->IndexStorePath.empty();
for (size_t i = 0, e = Args.size(); i < e; ++i) {
const char *const Arg = Args[i];

Expand Down Expand Up @@ -293,7 +292,7 @@ void Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
printArg(OS, ModCachePath, Quote);
}

if (CrashInfo && HaveIndexStorePath) {
if (CrashInfo && CrashInfo->HaveIndexStorePath) {
SmallString<128> IndexStoreDir;

if (HaveCrashVFS) {
Expand Down
6 changes: 6 additions & 0 deletions test/Modules/crash-index-store-path.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
// RUN: %clang -fsyntax-only %s -index-store-path %t/index \
// RUN: 2>&1 | FileCheck --check-prefix=CHECK %s
// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-index-*.sh

// Turn on indexing with an environment variable.
// RUN: rm -rf %t
// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t CLANG_PROJECT_INDEX_PATH=%t/index \
// RUN: %clang -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK %s
// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-index-*.sh
int foo() { return 0; }

// CHECKMOD: Preprocessed source(s) and associated run script(s) are located at:
Expand Down