This is an archive of the discontinued LLVM Phabricator instance.

[clang-check] Adjust argument adjusters for clang-check to strip options blocking the static analyzer
ClosedPublic

Authored by OikawaKirie on Dec 27 2021, 11:50 PM.

Details

Summary

Output generation options (like -save-temps) will make the analyzer not executed even --analyze option is provided in the driver arguments.
Besides, the original approach of adding --analyze option will not work when (more than one) -fsyntax-only options are provided in the driver arguments.

This patch fixes these two problems by using the syntax-only adjuster to remove output generation options and manually filter out redundant -fsyntax-only options.

In the new implementation, the adjusters added by ClangTool will not be removed but used as dependencies for clang-check adjusters for analyzer options.

Diff Detail

Event Timeline

OikawaKirie created this revision.Dec 27 2021, 11:50 PM
OikawaKirie requested review of this revision.Dec 27 2021, 11:50 PM
labath resigned from this revision.Dec 28 2021, 5:48 AM

I'm sorry, but I don't feel qualified to review this. Last time I saw this file was in 2013.

sammccall added inline comments.Jan 6 2022, 5:25 AM
clang/tools/clang-check/ClangCheck.cpp
217

you can pass a vector to getInsertArgumentsAdjuster

225

You've removed the mention of the default syntax-only adjuster, so this comment seems confusing.

"The syntax-only adjuster is installed by default.
Good: It strips options that trigger extra output, like --save-temps.
Bad: We don't want the -fsyntax-only arg itself, as it suppresses analyzer output"

Then strip -fsyntax-only, then add -analyze?

236

this seems like a particularly confusing way to say "if (Arg == "-fsyntax-only && !HasAnalyze)"

The "replace first -fsyntax-only with -analyze, strip others" seems more clearly expressed as "strip -fsyntax-only" and "add -analyze" as separate steps.

Updated as suggested.

sammccall accepted this revision.Jan 13 2022, 10:51 PM

Thanks, LG!

This revision is now accepted and ready to land.Jan 13 2022, 10:51 PM

Could you please commit it on my behalf (Ella Ma <alansnape3058@gmail.com>)?
Thanks a lot.

It seems that it is not committed on my behalf. Maybe you have forgotten to add me as the author?
Sad : (