forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 341
[IncludeTree] Fix PPCallback for include tree that can cause missing .d file #8624
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
cachemeifyoucan
merged 1 commit into
swiftlang:next
from
cachemeifyoucan:eng/PR-126885995
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
clang/test/ClangScanDeps/modules-include-tree-dependency-file.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// REQUIRES: ondisk_cas | ||
|
||
// RUN: rm -rf %t | ||
// RUN: split-file %s %t | ||
// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json | ||
|
||
// RUN: clang-scan-deps -compilation-database %t/cdb.json \ | ||
// RUN: -cas-path %t/cas -format experimental-include-tree-full > %t/deps.json | ||
|
||
// RUN: %deps-to-rsp %t/deps.json --module-name Mod_Private > %t/private.rsp | ||
// RUN: %deps-to-rsp %t/deps.json --module-name Mod > %t/mod.rsp | ||
// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp | ||
// RUN: %clang @%t/private.rsp | ||
// RUN: %clang @%t/mod.rsp | ||
// RUN: %clang @%t/tu.rsp -dependency-dot %t/tu.dot | ||
/// Check dependency file is generated. | ||
// RUN: find %t/module-cache -name "*.d" | wc -l | grep 2 | ||
// RUN: FileCheck %s -input-file=%t/tu.d | ||
|
||
// CHECK: dependencies: | ||
// CHECK-DAG: tu.m | ||
// CHECK-DAG: A.h | ||
|
||
// RUN: FileCheck %s -input-file=%t/tu.dot -check-prefix DOT | ||
// DOT: digraph "dependencies" | ||
// DOT-DAG: [[TU:header_[0-9]+]] [ shape="box", label="{{.*}}{{/|\\}}tu.m"]; | ||
// DOT-DAG: [[HEADER:header_[0-9]+]] [ shape="box", label="{{.*}}{{/|\\}}A.h"]; | ||
// DOT-DAG: [[PCM:header_[0-9]+]] [ shape="box", label="{{.*}}{{/|\\}}Mod-{{.*}}.pcm"]; | ||
// DOT-DAG: [[TU]] -> [[HEADER]] | ||
// DOT-DAG: [[HEADER]] -> [[PCM]] | ||
|
||
//--- cdb.json.template | ||
[{ | ||
"file": "DIR/tu.m", | ||
"directory": "DIR", | ||
"command": "clang -fsyntax-only DIR/tu.m -F DIR -I DIR -fmodule-name=A -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache -MMD -MT dependencies -MF DIR/tu.d" | ||
}] | ||
|
||
//--- Mod.framework/Modules/module.modulemap | ||
framework module Mod { header "Mod.h" } | ||
|
||
//--- Mod.framework/Modules/module.private.modulemap | ||
framework module Mod_Private { header "Priv.h" } | ||
|
||
//--- module.modulemap | ||
module A { | ||
header "A.h" | ||
export * | ||
} | ||
|
||
//--- A.h | ||
#include <Mod/Mod.h> | ||
|
||
//--- Mod.framework/Headers/Mod.h | ||
#include <Mod/Priv.h> | ||
void pub(void); | ||
|
||
//--- Mod.framework/PrivateHeaders/Priv.h | ||
void priv(void); | ||
|
||
//--- tu.m | ||
#import "A.h" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will behave correctly for the dependency file generator, but I'm concerned that other PPCallbacks do actually look at the file entry.
Some options
AddMissingHeaderDeps
, but not sure if this is exactly what we want or not.I'm leaning toward (1) or (2).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what that parameter means is kind of debatable. Doc says:
So technically ASTFile is the file getting "included" here but I don't know if it is a valid assumption till now that the file means "headerfile" and you can rely on this information. From all the code in tree, dependency is the only consumer that actually uses
File
, and dependency graph is the only one that cares about whatFile
points to.In this case, the dependency graph (.dot) file will have nodes for .pcm file and that include directive is an edge from source file to pcm file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see several consumers that look at the File, at least in this branch:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed a bunch in
clang-tools-extra
. I guess that makes (2) a less good option.