This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][NFC] Prefer binary searches in CheckerRegistry
ClosedPublic

Authored by Szelethus on Mar 16 2019, 10:32 AM.

Diff Detail

Event Timeline

Szelethus created this revision.Mar 16 2019, 10:32 AM
baloghadamsoftware requested changes to this revision.Mar 19 2019, 6:28 AM
baloghadamsoftware added inline comments.
lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
70

Please note that llvm::lower_bound() uses std::lower_bound() which returns an iterator pointing to the first element that is not less than the sought value, or last if no such element is found. So it is mandatory to check the return value whether it is equal to sought value or greater. In latter case you should return Collection.end() to keep up compatibility with find_if.

This revision now requires changes to proceed.Mar 19 2019, 6:28 AM
Szelethus updated this revision to Diff 194768.Apr 11 2019, 2:53 PM

Change asserts according to reviewer feedback.

Szelethus marked an inline comment as done.Apr 11 2019, 2:54 PM
Szelethus added inline comments.
lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
70

Yup, nice catch!

Szelethus updated this revision to Diff 195358.Apr 16 2019, 5:34 AM

Avoid past-the-end iterator dereference, add it to the assert.

This revision is now accepted and ready to land.Apr 16 2019, 5:38 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2019, 10:34 AM