[all-commits] [llvm/llvm-project] f329e3: [clang-tidy] Add `bugprone-pointer-arithmetic-on-p...
Discookie via All-commits
all-commits at lists.llvm.org
Thu Jul 4 06:44:52 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f329e3ed9070aee3f4c0ebc80ed62f5c4b645d73
https://github.com/llvm/llvm-project/commit/f329e3ed9070aee3f4c0ebc80ed62f5c4b645d73
Author: Discookie <viktor.cseh at ericsson.com>
Date: 2024-07-04 (Thu, 04 Jul 2024)
Changed paths:
M clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
M clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
A clang-tools-extra/clang-tidy/bugprone/PointerArithmeticOnPolymorphicObjectCheck.cpp
A clang-tools-extra/clang-tidy/bugprone/PointerArithmeticOnPolymorphicObjectCheck.h
M clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
M clang-tools-extra/docs/ReleaseNotes.rst
A clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst
A clang-tools-extra/docs/clang-tidy/checks/cert/ctr56-cpp.rst
M clang-tools-extra/docs/clang-tidy/checks/list.rst
A clang-tools-extra/test/clang-tidy/checkers/bugprone/pointer-arithmetic-on-polymorphic-object-all.cpp
A clang-tools-extra/test/clang-tidy/checkers/bugprone/pointer-arithmetic-on-polymorphic-object-decl-only.cpp
Log Message:
-----------
[clang-tidy] Add `bugprone-pointer-arithmetic-on-polymorphic-object` check (#91951)
Finds pointer arithmetic on classes that declare a virtual function.
This check corresponds to the SEI Cert rule [CTR56-CPP: Do not use
pointer arithmetic on polymorphic
objects](https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR56-CPP.+Do+not+use+pointer+arithmetic+on+polymorphic+objects).
```cpp
struct Base {
virtual void ~Base();
};
struct Derived : public Base {};
void foo(Base *b) {
b += 1; // passing `Derived` to `foo()` results in UB
}
```
[Results on open-source
projects](https://codechecker-demo.eastus.cloudapp.azure.com/Default/runs?run=Discookie-ctr56-with-classnames).
Most of the Qtbase reports are from having a `virtual override`
declaration, and the LLVM reports are true positives, as far as I can
tell.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list