[clang-tools-extra] [clang-tidy] Add `bugprone-pointer-arithmetic-on-polymorphic-object` check (PR #91951)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 10 12:48:58 PDT 2024


https://github.com/PiotrZSL requested changes to this pull request.

Few nits:
- storeOptions needs fix
- Consider excluding implicit code with TK_IgnoreUnlessSpelledInSource (not this may exclude also template instances, so I leave it up to you)
- Documentation require small work
- Make check more strict by default, and add options to relax it (as thats what [CTR56-CPP](https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR56-CPP.+Do+not+use+pointer+arithmetic+on+polymorphic+objects) require). I undestand that on your project this may cause some false-positives, but still thats your project problem. Consider adding options to "Allow classes where only virtual function is destructor", "Classes where all virtual functions are marked final",  "Classes that do not add new virtual functions or members". (Just check what suit your project most).

Note that next release branch out is in a ~month. Would be nice if this check could fit-in.

https://github.com/llvm/llvm-project/pull/91951


More information about the cfe-commits mailing list