This is an archive of the discontinued LLVM Phabricator instance.

[clang][ScanDeps] Fix issue with multiple commands with the same input.
ClosedPublic

Authored by Bigcheese on Oct 30 2019, 2:21 PM.

Details

Summary

Previously, given a CompilationDatabase with two commands for the same
source file we would report that file twice with the union of the
dependencies for each command both times.

This was due to the way ClangTool runs actions given an input source
file (see the comment in DependencyScanningTool.cpp). This commit adds
a SingleCommandCompilationDatabase that is created with each
CompileCommand in the original CDB, which is then used for each
ClangTool invocation. This gives us a single run of
DependencyScanningAction per CompileCommand.

I looked at using AllTUsToolExecutor which is a parallel tool
executor, but I'm not sure it's suitable for clang-scan-deps as it
does a lot more sharing of state than AllTUsToolExecutor expects.

I've added Manuel as a reviewer to see if there's an obviously better way to do this with libTooling.

Diff Detail

Event Timeline

Bigcheese created this revision.Oct 30 2019, 2:21 PM
arphaman accepted this revision.Oct 30 2019, 6:22 PM

LGTM, Thanks

This revision is now accepted and ready to land.Oct 30 2019, 6:22 PM
This revision was automatically updated to reflect the committed changes.