This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] SValBuilder should have an easy access to AnalyzerOptions
ClosedPublic

Authored by steakhal on Aug 27 2021, 8:09 AM.

Details

Summary

SVB.getStateManager().getOwningEngine().getAnalysisManager().getAnalyzerOptions()
is quite a mouthful and might involve a few pointer indirections to get
such a simple thing like an analyzer option.

This patch introduces an AnalyzerOptions reference to the SValBuilder
abstract class, while refactors a few cases to use this simpler accessor.

Diff Detail

Event Timeline

steakhal created this revision.Aug 27 2021, 8:09 AM
NoQ added inline comments.Aug 27 2021, 4:04 PM
clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
55–56

You can move this code inside the constructor. This will keep the functionality but eliminate the extra constructor argument.

steakhal updated this revision to Diff 369384.Aug 30 2021, 12:09 AM
steakhal marked an inline comment as done.

Now acquire the AnalyzerOptions in the ctor.
Also, move the ctor to the implementation to prevent the ExprEngine header inclusion from the SValBuilder.h.

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
190

To be fair, I don't know why don't we use a plain old public const const field for this.
Similarly how AnalysisManager::options is defined.

What should be our preference? Should I follow the getter antipattern?

clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
55–56

I wanted to signify that the SValBuilder will have the AnalyzerOptions, thus I made it this way.
But you might be right that in long term that will be better.

martong accepted this revision.Aug 30 2021, 5:27 AM

Looks good to me, thanks!

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
190

I'd stick to the existing style. IMHO, consistency is very important, b/c later if someone decides to refactor then they could do that even automatically.

This revision is now accepted and ready to land.Aug 30 2021, 5:27 AM
Szelethus accepted this revision.Sep 3 2021, 5:07 AM

Lets go! Mind that you wrote "eazy" instead of "easy" in the revision name. But, if you are just being that "kewl", I don't mind!

steakhal retitled this revision from [analyzer] SValBuilder should have an eazy access to AnalyzerOptions to [analyzer] SValBuilder should have an easy access to AnalyzerOptions.Sep 3 2021, 7:30 AM
steakhal edited the summary of this revision. (Show Details)

Lets go! Mind that you wrote "eazy" instead of "easy" in the revision name. But, if you are just being that "kewl", I don't mind!

Thanks!

This revision was landed with ongoing or failed builds.Sep 4 2021, 1:21 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 4 2021, 1:21 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript