This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] scan-build-py: Remove relative path hack for SATestsBuild.py
ClosedPublic

Authored by dcoughlin on Sep 12 2016, 1:35 PM.

Details

Summary

Remove the relative path hack in scan-build-py that converts a fully qualified directory name and a fully qualified file path to a relative path before running the analyzer on a file.

This hack is not needed: the bad interaction with SATestsBuild.py it was intended to address is actually the same underlying problem that D24163 fixed. Further, because the hack would always relativize paths, it caused SATestBuild.py to be unable to properly line up issues when the build system changed directory and then built a source file in a child directory but used a fully-qualified path for the source file.

Laszlo: Are you OK with me removing this hack? This is the last outstanding issue in scan-build-py preventing us in using it for our regression suite.

Note: I still think the approach used here (and especially in intercept-build) is not ideal. I really think we should be storing both the working directory and the actual path argument (even if it is relative) in the compilation database. Storing the fully-qualified paths loses information (i.e., which of the many possible paths for that file was actually used) and makes replaying the build with fidelity impossible. That said, after D24163 I don't have any examples where is actually an issue in practice.

Diff Detail

Repository
rL LLVM

Event Timeline

dcoughlin updated this revision to Diff 71046.Sep 12 2016, 1:35 PM
dcoughlin retitled this revision from to [analyzer] scan-build-py: Remove relative path hack for SATestsBuild.py.
dcoughlin updated this object.
dcoughlin added a reviewer: rizsotto.mailinglist.
dcoughlin added a subscriber: cfe-commits.
NoQ added a subscriber: NoQ.Sep 13 2016, 4:27 AM
rizsotto.mailinglist edited edge metadata.

thanks Devin, i like smaller code, have no problem with this change. :)

about the file/directory paths: i agree that the situation is not ideal. but there are/were strict constrains on how a compilation database shall look like. once a year i ask the question on the mailing list about it. the situation might have been improved since... besides, using absolute path is actually the safest bet we can make. (other tools doing the same (CMake is a good example)) would not invest time into this until i see it got broken.

This revision is now accepted and ready to land.Sep 13 2016, 5:07 AM
This revision was automatically updated to reflect the committed changes.