This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by steakhal on Jun 29 2021, 5:04 AM.

Details

Summary

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.

Diff Detail

Event Timeline

steakhal created this revision.Jun 29 2021, 5:04 AM
steakhal requested review of this revision.Jun 29 2021, 5:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2021, 5:04 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
vsavchenko accepted this revision.Jun 29 2021, 6:48 AM

Great! Thanks for the detailed explanation in your Summary.
I agree that there should be a runtime check, but it doesn't seem viable as long as Checker.h is organized the way it is organized now.

clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
40

Maybe we can use LLVM_ATTRIBUTE_UNUSED instead?

This revision is now accepted and ready to land.Jun 29 2021, 6:48 AM
This revision was landed with ongoing or failed builds.Jun 29 2021, 7:24 AM
This revision was automatically updated to reflect the committed changes.