Skip to content

Commit

Permalink
addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
balazske committed Feb 17, 2025
1 parent d60d9c7 commit 69f42e9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
30 changes: 15 additions & 15 deletions clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ The ``SuppressAddressSpaces`` option suppresses
warnings for null dereferences of all pointers with address spaces. You can
disable this behavior with the option
``-analyzer-config core.NullDereference:SuppressAddressSpaces=false``.
Value of this option is used for checker
:ref:`_alpha-core-FixedAddressDereference` too.
Value of this option is also used for checker
:ref:`_alpha-core-FixedAddressDereference`.
*Defaults to true*.

.. code-block:: objc
Expand Down Expand Up @@ -2925,19 +2925,7 @@ Check for assignment of a fixed address to a pointer.
alpha.core.FixedAddressDereference (C, C++, ObjC)
"""""""""""""""""""""""""""""""""""""""""""""""""
Check for dereferences of fixed values used as pointers.
Similarly as at :ref:`_core-NullDereference`, the checker specifically does
not report dereferences for x86 and x86-64 targets when the
address space is 256 (x86 GS Segment), 257 (x86 FS Segment), or 258 (x86 SS
segment). (See `X86/X86-64 Language Extensions
<https://clang.llvm.org/docs/LanguageExtensions.html#memory-references-to-specified-segments>`__
for reference.)
If you want to disable this behavior, set the ``SuppressAddressSpaces`` option
of checker ``core.NullDereference`` to false, like
``-analyzer-config core.NullDereference:SuppressAddressSpaces=false``. The value
of this option is used for both checkers.
Check for dereferences of fixed addresses.
.. code-block:: c
Expand All @@ -2957,6 +2945,18 @@ of this option is used for both checkers.
int x = (*p_function)('x', 'y'); // NO warning yet at functon pointer calls
}
Similarly to :ref:`_core-NullDereference`, the checker intentionally does
not report dereferences for x86 and x86-64 targets when the
address space is 256 (x86 GS Segment), 257 (x86 FS Segment), or 258 (x86 SS
Segment). (See `X86/X86-64 Language Extensions
<https://clang.llvm.org/docs/LanguageExtensions.html#memory-references-to-specified-segments>`__
for reference.)
If you want to disable this behavior, set the ``SuppressAddressSpaces`` option
of checker ``core.NullDereference`` to false, like
``-analyzer-config core.NullDereference:SuppressAddressSpaces=false``. The value
of this option is used for both checkers.
.. _alpha-core-PointerArithm:
alpha.core.PointerArithm (C)
Expand Down
22 changes: 12 additions & 10 deletions clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,17 @@ def DereferenceModeling : Checker<"DereferenceModeling">,
Documentation<NotDocumented>,
Hidden;

def NullDereferenceChecker
: Checker<"NullDereference">,
HelpText<"Check for dereferences of null pointers">,
CheckerOptions<[CmdLineOption<
Boolean, "SuppressAddressSpaces",
"Suppresses warning when pointer dereferences an address space",
"true", Released>]>,
Documentation<HasDocumentation>,
Dependencies<[DereferenceModeling]>;
def NullDereferenceChecker : Checker<"NullDereference">,
HelpText<"Check for dereferences of null pointers">,
CheckerOptions<[
CmdLineOption<Boolean,
"SuppressAddressSpaces",
"Suppresses warning when pointer dereferences an address space",
"true",
Released>
]>,
Documentation<HasDocumentation>,
Dependencies<[DereferenceModeling]>;

def NonNullParamChecker : Checker<"NonNullParamChecker">,
HelpText<"Check for null pointers passed as arguments to a function whose "
Expand Down Expand Up @@ -285,7 +287,7 @@ def FixedAddressChecker : Checker<"FixedAddr">,

def FixedAddressDereferenceChecker
: Checker<"FixedAddressDereference">,
HelpText<"Check for dereferences of fixed values used as pointers">,
HelpText<"Check for dereferences of fixed addresses">,
Documentation<HasDocumentation>,
Dependencies<[DereferenceModeling]>;

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DereferenceChecker
NullPointer,
UndefinedPointerValue,
AddressOfLabel,
FixedAddress
FixedAddress,
};

void reportBug(DerefKind K, ProgramStateRef State, const Stmt *S,
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/concrete-address.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern void __assert_fail (__const char *__assertion, __const char *__file,
#define assert(expr) \
((expr) ? (void)(0) : __assert_fail (#expr, __FILE__, __LINE__, __func__))

typedef unsigned long uintptr_t;
typedef unsigned long long uintptr_t;

void f0(void) {
int *p = (int*) 0x10000; // Should not crash here.
Expand Down

0 comments on commit 69f42e9

Please sign in to comment.