Skip to content

[SYCL] Filter out the header and footer from the dependency output. #14933

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
merged 6 commits into from
Aug 6, 2024
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
2 changes: 1 addition & 1 deletion clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -7696,7 +7696,7 @@ def show_includes : Flag<["--"], "show-includes">,
HelpText<"Print cl.exe style /showIncludes to stdout">;
def dependency_filter : Separate<["-"], "dependency-filter">,
HelpText<"Filter dependencies with prefix from the dependency output.">,
MarshallingInfoString<DependencyOutputOpts<"DependencyFilter">>;
MarshallingInfoStringVector<DependencyOutputOpts<"DependencyFilter">>;

} // let Visibility = [CC1Option]

Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Frontend/DependencyOutputOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class DependencyOutputOptions {
std::string ModuleDependencyOutputDir;

/// Dependency output which is prefixed with this string is filtered from
/// the dependency output.
std::string DependencyFilter;
/// the dependency output.
std::vector<std::string> DependencyFilter;

public:
DependencyOutputOptions()
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Frontend/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class DependencyFileGenerator : public DependencyCollector {
void outputDependencyFile(DiagnosticsEngine &Diags);

std::string OutputFile;
std::string DependencyFilter;
std::vector<std::string> DependencyFilter;
std::vector<std::string> Targets;
bool IncludeSystemHeaders;
bool PhonyTarget;
Expand Down
9 changes: 4 additions & 5 deletions clang/lib/Frontend/DependencyFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,10 @@ bool DependencyFileGenerator::sawDependency(StringRef Filename, bool FromModule,
if (isSpecialFilename(Filename))
return false;

if (DependencyFilter.size() &&
DependencyFilter.compare(0, DependencyFilter.size(), Filename.data(),
DependencyFilter.size()) == 0)
// Remove dependencies that are prefixed by the Filter string.
return false;
// Remove dependencies that are prefixed by the Filter string.
for (const std::string &FD : DependencyFilter)
if (FD.compare(0, FD.size(), Filename.data(), FD.size()) == 0)
return false;

if (IncludeSystemHeaders)
return true;
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Frontend/Inputs/dependency.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int dep() {
return 0;
}
8 changes: 8 additions & 0 deletions clang/test/Frontend/dependency-gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@
// RUN: %clang -MMD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_sanitizer_ignorelist -fsanitize=undefined -flto -fvisibility=hidden -I ./ | FileCheck -check-prefix=ONLY-USER-DEPS %s
// ONLY-USER-DEPS: dependency-gen.o:
// NOT-ONLY-USER-DEPS: ubsan_ignorelist.txt

// RUN: %clang -c -x c++ -fsycl \
// RUN: -MD -MF - %S/Inputs/dependency.cpp | FileCheck -check-prefix=FILTER %s

// FILTER: dependency.o:
// FILTER: {{.*}}dependency.cpp
// FILTER: dependency.o:
// FILTER: {{.*}}dependency.cpp
Loading