https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/182037
From 9bbbc9b3522999fe7d79459848f37c5851a5e4b4 Mon Sep 17 00:00:00 2001 From: Balazs Benics <[email protected]> Date: Wed, 18 Feb 2026 15:55:57 +0100 Subject: [PATCH 1/2] [analyzer][docs] Further improve the optin.core.FixedAddressDereference docs This addresses the raised points in: https://github.com/llvm/llvm-project/pull/181858#pullrequestreview-3820145678 --- clang/docs/analyzer/checkers.rst | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst index e51015655de65..29cb261d26aeb 100644 --- a/clang/docs/analyzer/checkers.rst +++ b/clang/docs/analyzer/checkers.rst @@ -877,26 +877,30 @@ numerical value. int x = (*p_function)('x', 'y'); // NO warning yet at functon pointer calls } +Access of fixed numerical addresses can be legitimate in low-level projects (e.g. firmware) and hardware interop. +These values are often marked as ``volatile`` (to prevent unwanted compiler optimizations), +so this checker doesn't report situations where the pointee of the fixed address is ``volatile``. +If this suppression is not sufficient on a low-level project, then consider disabling this ``optin`` checker. +Note that null pointers will still be reported by :ref:`core.NullDereference <core-NullDereference>` +regardless if the pointee is ``volatile`` or not. + +.. code-block:: c + void volatile_pointee() { - *(volatile int *)0x404 = 1; // no warning: constant non-null "volatile" pointee, you must know what you are doing + *(volatile int *)0x404 = 1; // no warning: fixed non-null "volatile" pointee, you must know what you are doing } void deref_volatile_nullptr() { *(volatile int *)0 = 1; // core.NullDereference still warns about this } -If your project is low-level (e.g., firmware), or deals with hardware interop with a lot of genuine constant addresses, then consider disabling this checker. -The checker automatically suppresses issues if the type of the pointee of the address is ``volatile``. -You probably already need this to be ``volatile`` for legitimate access, so the checker suppresses such issues to avoid false-positives. -Note that null pointers will still be reported by :ref:`core.NullDereference <core-NullDereference>` -regardless if the pointee is ``volatile`` or not. - If the analyzer option ``suppress-dereferences-from-any-address-space`` is set to true (the default value), then this checker never reports dereference of pointers with a specified address space. If the option is set to false, then reports from the specific x86 address spaces 256, 257 and 258 are still suppressed, but fixed address dereferences from other address spaces are -reported. +reported. Do not use ``address_space`` attributes to suppress the reports - +it just happens so that the checker also doesn't raise issues if the attribute is present. .. _optin-cplusplus-UninitializedObject: From 75393b916c57b5ec66dce5bb17a8a2043deee7b4 Mon Sep 17 00:00:00 2001 From: Balazs Benics <[email protected]> Date: Wed, 18 Feb 2026 22:50:31 +0100 Subject: [PATCH 2/2] Now that the attr is documented, xref it from the checker --- clang/docs/analyzer/checkers.rst | 5 +++-- clang/include/clang/Basic/AttrDocs.td | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst index 29cb261d26aeb..0afb094ecf0d2 100644 --- a/clang/docs/analyzer/checkers.rst +++ b/clang/docs/analyzer/checkers.rst @@ -899,8 +899,9 @@ to true (the default value), then this checker never reports dereference of pointers with a specified address space. If the option is set to false, then reports from the specific x86 address spaces 256, 257 and 258 are still suppressed, but fixed address dereferences from other address spaces are -reported. Do not use ``address_space`` attributes to suppress the reports - -it just happens so that the checker also doesn't raise issues if the attribute is present. +reported. +Do not use the :ref:`address_space <langext-address_space_documentation>` +attribute to suppress the reports - it just happens so that the checker also doesn't raise issues if the attribute is present. .. _optin-cplusplus-UninitializedObject: diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 43bfa15d2646f..68fdc3b976d66 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -196,6 +196,7 @@ TLS models are mutually exclusive. def AddressSpaceDocs : Documentation { let Category = DocCatType; let Heading = "address_space"; + let Label = "langext-address_space_documentation"; let Content = [{ .. Note:: This attribute is mainly intended to be used by target headers provided by the toolchain. End users should prefer the documented, named _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
