This is an archive of the discontinued LLVM Phabricator instance.

[scan-build] Fix clang++ pathname again
ClosedPublic

Authored by sberg on Oct 15 2020, 9:23 AM.

Details

Summary

e00629f777d9d62875730f40d266727df300dbb2 "[scan-build] Fix clang++ pathname" had
removed the -MAJOR.MINOR suffix, but since presumably LLVM 7 the suffix is only
-MAJOR, so ClangCXX (i.e., the CLANG_CXX environment variable passed to
clang/tools/scan-build/libexec/ccc-analyzer) now contained a non-existing
/path/to/clang-12++ (which apparently went largely unnoticed as
clang/tools/scan-build/libexec/ccc-analyzer falls back to just 'clang++' if the
executable denoted by CLANG_CXX does not exist).

For the new clang/test/Analysis/scan-build/cxx-name.test to be effective,
%scan-build must now take care to pass the clang executable's resolved pathname
(i.e., ending in .../clang-MAJOR rather than just .../clang) to --use-analyzer.

Diff Detail

Event Timeline

sberg created this revision.Oct 15 2020, 9:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 15 2020, 9:23 AM
Herald added a subscriber: Charusso. · View Herald Transcript
sberg requested review of this revision.Oct 15 2020, 9:23 AM
NoQ accepted this revision.Oct 27 2020, 10:31 AM
NoQ edited reviewers, added: NoQ, vsavchenko; removed: dergachev.a.
NoQ added a subscriber: NoQ.

Nice, thanks!

Since recently we started doing LIT tests for scan-build in test/Analysis/scan-build, if you find a good way to test this feature feel free to add a regression test.

sberg updated this revision to Diff 301273.Oct 28 2020, 7:24 AM
sberg edited the summary of this revision. (Show Details)

Is there a reason why "NoQ accepted this revision." kept this at "Needs Review" rather than moving it to "This revision is now accepted and ready to land."?

Anyway, I added a test now. Hope the use of REQUIRES: shell is appropriate guarding for using sh and basename (and as such would subsume the // FIXME: Actually, "perl". REQUIRES: shell found in other test files in that directory using %scan-build, or should it better also carry that FIXME comment for a perl requirement, as scan-build is written in perl?). (I didn't find out how 'shell' gets added to available_features for these tests. I only found it in clang-tools-extra/test/lit.cfg.py and compiler-rt/test/lit.common.cfg.py, but which should not be relevant here? Also, I didn't manage to verify this doesn't break anything on Windows; while my Linux build dir (at least after once having done cmake --build . --target check-all) has a tools/clang/test/Analysis/scan-build dir that I can test with bin/llvm-lit -v tools/clang/test/Analysis/scan-build, I don't get that directory at all on Windows.)

sylvestre.ledru accepted this revision.Oct 31 2020, 4:04 AM

Looks good to me

This revision is now accepted and ready to land.Oct 31 2020, 4:04 AM
NoQ added a comment.Nov 2 2020, 4:43 PM

Is there a reason why "NoQ accepted this revision." kept this at "Needs Review" rather than moving it to "This revision is now accepted and ready to land."?

Dunno! I think you should commit this.

Anyway, I added a test now. Hope the use of REQUIRES: shell is appropriate guarding for using sh and basename (and as such would subsume the // FIXME: Actually, "perl". REQUIRES: shell found in other test files in that directory using %scan-build, or should it better also carry that FIXME comment for a perl requirement, as scan-build is written in perl?).

Yes, this comment is there because scan-build itself is written in perl; scan-build tests would obviously fail without it. But we don't have an actual REQUIRES: perl and REQUIRES: shell seems to be precise enough.

This revision was automatically updated to reflect the committed changes.