[analyzer] Make CheckerManager::hasPathSensitiveCheckers() complete again

It turns out that the CheckerManager::hasPathSensitiveCheckers() missed
checking for the BeginFunctionCheckers.
It seems like other callbacks are also missing:
 - ObjCMessageNilCheckers
 - BeginFunctionCheckers
 - NewAllocatorCheckers
 - PointerEscapeCheckers
 - EndOfTranslationUnitCheckers

In this patch, I wanted to use a fold-expression, but until C++17
arrives we are left with the old-school method.

When I tried to write a unittest I observed an interesting behavior. I
subscribed only to the BeginFunction event, it was not fired.
However, when I also defined the PreCall with an empty handler, suddenly
both fired.
I could add this test demonstrating the issue, but I don't think it
would serve much value in a long run. I don't expect regressions for
this.

However, I think it would be great to enforce the completeness of this
list in a runtime check.
I could not come up with a solution for this though.

PS: Thank you @Szelethus for helping me debugging this.

Differential Revision: https://reviews.llvm.org/D105101

Reviewed by: vsavchenko
This commit is contained in:
Balazs Benics 2021-06-29 16:35:07 +02:00
parent 9de63367d8
commit 3dae01911b
1 changed files with 14 additions and 15 deletions

View File

@ -33,21 +33,20 @@ using namespace clang;
using namespace ento; using namespace ento;
bool CheckerManager::hasPathSensitiveCheckers() const { bool CheckerManager::hasPathSensitiveCheckers() const {
return !StmtCheckers.empty() || const auto IfAnyAreNonEmpty = [](const auto &... Callbacks) -> bool {
!PreObjCMessageCheckers.empty() || bool Result = false;
!PostObjCMessageCheckers.empty() || // FIXME: Use fold expressions in C++17.
!PreCallCheckers.empty() || LLVM_ATTRIBUTE_UNUSED int Unused[]{0, (Result |= !Callbacks.empty())...};
!PostCallCheckers.empty() || return Result;
!LocationCheckers.empty() || };
!BindCheckers.empty() || return IfAnyAreNonEmpty(
!EndAnalysisCheckers.empty() || StmtCheckers, PreObjCMessageCheckers, ObjCMessageNilCheckers,
!EndFunctionCheckers.empty() || PostObjCMessageCheckers, PreCallCheckers, PostCallCheckers,
!BranchConditionCheckers.empty() || LocationCheckers, BindCheckers, EndAnalysisCheckers,
!LiveSymbolsCheckers.empty() || BeginFunctionCheckers, EndFunctionCheckers, BranchConditionCheckers,
!DeadSymbolsCheckers.empty() || NewAllocatorCheckers, LiveSymbolsCheckers, DeadSymbolsCheckers,
!RegionChangesCheckers.empty() || RegionChangesCheckers, PointerEscapeCheckers, EvalAssumeCheckers,
!EvalAssumeCheckers.empty() || EvalCallCheckers, EndOfTranslationUnitCheckers);
!EvalCallCheckers.empty();
} }
void CheckerManager::finishedCheckerRegistration() { void CheckerManager::finishedCheckerRegistration() {