Skip to content

Commit d9a508d

Browse files
authored
[analyzer] Finish moving alpha.core.SizeofPtr to clang-tidy (#95118)
The checker `alpha.core.SizeofPtr` was a very simple checker that did not rely on path sensitive analysis and was very similar to the (more complex and refined) clang-tidy check `bugprone-sizeof-expression`. As there is no reason to maintain two separate implementations for the same goal (and clang-tidy is more lightweight and accessible than the Analyzer) I decided to move this functionality from the Static Analyzer to clang-tidy. Recently my commit 546c816 reimplemented the advantageous parts of `alpha.core.SizeofPtr` within clang-tidy; now this commit finishes the transfer by deleting `alpha.core.SizeofPtr`.
1 parent 3c9a9c7 commit d9a508d

File tree

6 files changed

+0
-140
lines changed

6 files changed

+0
-140
lines changed

clang/docs/analyzer/checkers.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,21 +2452,6 @@ Check for pointer subtractions on two pointers pointing to different memory chun
24522452
int d = &y - &x; // warn
24532453
}
24542454
2455-
.. _alpha-core-SizeofPtr:
2456-
2457-
alpha.core.SizeofPtr (C)
2458-
""""""""""""""""""""""""
2459-
Warn about unintended use of ``sizeof()`` on pointer expressions.
2460-
2461-
.. code-block:: c
2462-
2463-
struct s {};
2464-
2465-
int test(struct s *p) {
2466-
return sizeof(p);
2467-
// warn: sizeof(ptr) can produce an unexpected result
2468-
}
2469-
24702455
.. _alpha-core-StackAddressAsyncEscape:
24712456
24722457
alpha.core.StackAddressAsyncEscape (C)

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,6 @@ def PointerSubChecker : Checker<"PointerSub">,
296296
"different memory chunks">,
297297
Documentation<HasDocumentation>;
298298

299-
def SizeofPointerChecker : Checker<"SizeofPtr">,
300-
HelpText<"Warn about unintended use of sizeof() on pointer expressions">,
301-
Documentation<HasDocumentation>;
302-
303299
def TestAfterDivZeroChecker : Checker<"TestAfterDivZero">,
304300
HelpText<"Check for division by variable that is later compared against 0. "
305301
"Either the comparison is useless or there is division by zero.">,

clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ add_clang_library(clangStaticAnalyzerCheckers
2424
CheckObjCInstMethSignature.cpp
2525
CheckPlacementNew.cpp
2626
CheckSecuritySyntaxOnly.cpp
27-
CheckSizeofPointer.cpp
2827
CheckerDocumentation.cpp
2928
ChrootChecker.cpp
3029
CloneChecker.cpp

clang/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp

Lines changed: 0 additions & 96 deletions
This file was deleted.

clang/test/Analysis/sizeofpointer.c

Lines changed: 0 additions & 8 deletions
This file was deleted.

clang/www/analyzer/alpha_checks.html

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -239,22 +239,6 @@ <h3 id="core_alpha_checkers">Core Alpha Checkers</h3>
239239
</pre></div></div></td></tr>
240240

241241

242-
<tr><td><a id="alpha.core.SizeofPtr"><div class="namedescr expandable"><span class="name">
243-
alpha.core.SizeofPtr</span><span class="lang">
244-
(C)</span><div class="descr">
245-
Warn about unintended use of <code>sizeof()</code> on pointer
246-
expressions.</div></div></a></td>
247-
<td><div class="exampleContainer expandable">
248-
<div class="example"><pre>
249-
struct s {};
250-
251-
int test(struct s *p) {
252-
return sizeof(p);
253-
// warn: sizeof(ptr) can produce an unexpected result
254-
}
255-
</pre></div></div></td></tr>
256-
257-
258242
<tr><td><a id="alpha.core.StackAddressAsyncEscape"><div class="namedescr expandable"><span class="name">
259243
alpha.core.StackAddressAsyncEscape</span><span class="lang">
260244
(C)</span><div class="descr">

0 commit comments

Comments
 (0)