This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix issues in bugprone-assert-side-effect
AbandonedPublic

Authored by PiotrZSL on Mar 28 2023, 1:50 PM.

Details

Summary
  • Fixed problem when after changes in macros handling in Clang-tidy 14 cased issues from from this check be hidden when assert is defined in system headers. Now raising diagnostic for a place from where macro is called.
  • Added support for const, pure, constexpr functions/methods. Now they considered safe.
  • Split configuration options CheckFunctionCalls, IgnoredFunctions, to support enabling only checking of methods, or only of functions.

Fixes: #47605, #31825, #31821

Diff Detail

Event Timeline

PiotrZSL created this revision.Mar 28 2023, 1:50 PM
Herald added a project: Restricted Project. · View Herald Transcript
PiotrZSL requested review of this revision.Mar 28 2023, 1:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 1:50 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Eugene.Zelenko added inline comments.
clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
66

Please do not use auto if type is not spelled explicitly or iterator.

PiotrZSL added inline comments.Mar 28 2023, 2:15 PM
clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
66

That auto already was there, I just moved it... :)

Eugene.Zelenko added inline comments.Mar 28 2023, 2:17 PM
clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
66

So it's great reason to finally fix it :-)

PiotrZSL marked 2 inline comments as done.Mar 28 2023, 2:28 PM

You mention in the commit message that it fixes #25569, but that seems unrelated (and is already closed)?

Personally I find it hard to review 2 github issue fixes + 1 NFC (moving the assert code to assert.h) on the same patch, would it be possible to split to have a more focused review? I believe that would improve both speed and quality of the review.

PiotrZSL edited the summary of this revision. (Show Details)Apr 15 2023, 1:48 AM
PiotrZSL added a comment.EditedApr 15 2023, 1:52 AM

You right, I copied wrong issue id, should be #31825.
I do not plan to split this review. It's simply too big effort to do that, and then maintain
multiple reviews that have dependencies on each other, when they all are related to same check.

PiotrZSL abandoned this revision.Apr 15 2023, 8:43 AM