Skip to content

[IncludeTree] Do not pass compilation directories #11034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
3 changes: 3 additions & 0 deletions clang/lib/Tooling/DependencyScanning/ScanAndUpdateArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ void tooling::dependencies::configureInvocationForCaching(
// Clear APINotes options.
CI.getAPINotesOpts().ModuleSearchPaths = {};

// Reset debug/coverage compilation dir as include-tree uses absolute path.
CodeGenOpts.DebugCompilationDir.clear();
CodeGenOpts.CoverageCompilationDir.clear();
// Update output paths, and clear working directory.
auto CWD = FileSystemOpts.WorkingDir;
updateRelativePath(FrontendOpts.OutputFile, CWD);
Expand Down
6 changes: 5 additions & 1 deletion clang/test/ClangScanDeps/include-tree-preserve-pch-path.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// REQUIRES: ondisk_cas

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed -e "s|DIR|%/t|g" %t/cdb_pch.json.template > %t/cdb_pch.json
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
Expand All @@ -10,6 +11,7 @@

// CHECK: "-fmodule-format=obj"
// CHECK: "-dwarf-ext-refs"
// CHECK-NOT: -fdebug-compilation-dir

// RUN: %deps-to-rsp %t/deps_pch.json --tu-index 0 > %t/pch.rsp
// RUN: %clang @%t/pch.rsp
Expand All @@ -21,7 +23,9 @@
// RUN: %clang @%t/tu.rsp

// RUN: cat %t/tu.ll | FileCheck %s -check-prefix=LLVMIR -DPREFIX=%/t
// LLVMIR: !DICompileUnit({{.*}}, splitDebugFilename: "prefix.pch"
// LLVMIR: !DIFile(filename: "[[PREFIX]]/tu.c", directory: "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the PREFIX FileCheck variable initialized?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would have expected [[PREFIX:.*]] here

Copy link
Author

@cachemeifyoucan cachemeifyoucan Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RUN: cat %t/tu.ll | FileCheck %s -check-prefix=LLVMIR -DPREFIX=%/t It is initialized from the command-line.

// LLVMIR: !DICompileUnit({{.*}}, splitDebugFilename: "[[PREFIX]]/prefix.pch"
// LLVMIR: !DIFile(filename: "prefix.h", directory: "")

// Extract include-tree casid
// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
Expand Down