martong created this revision. martong added reviewers: steakhal, gamesh411, NoQ. Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun. Herald added a reviewer: Szelethus. martong requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D117568 Files: clang/docs/analyzer/checkers.rst clang/include/clang/StaticAnalyzer/Checkers/Checkers.td Index: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td =================================================================== --- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -552,7 +552,7 @@ "or is EOF.">, Dependencies<[StdCLibraryFunctionsChecker]>, WeakDependencies<[CallAndMessageChecker, NonNullParamChecker, StreamChecker]>, - Documentation<NotDocumented>; + Documentation<HasAlphaDocumentation>; } // end "alpha.unix" Index: clang/docs/analyzer/checkers.rst =================================================================== --- clang/docs/analyzer/checkers.rst +++ clang/docs/analyzer/checkers.rst @@ -2333,6 +2333,43 @@ alpha.unix ^^^^^^^^^^^ +.. _alpha-unix-StdCLibraryFunctionArgs: + +alpha.unix.StdCLibraryFunctionArgs (C) +"""""""""""""""""""""""""""""""""""""" +Check for calls of standard library functions that violate predefined argument +constraints. For example, it is stated in the C standard that for the ``int +isalnum(int ch)`` function the behavior is undefined if the value of ``ch`` is +not representable as unsigned char and is not equal to ``EOF``. + +.. code-block:: c + + void test_alnum_concrete(int v) { + int ret = isalnum(256); // \ + // warning: Function argument constraint is not satisfied + (void)ret; + } + +If the argument's value is unknown then the value is assumed to hold the proper value range. + +.. code-block:: c + + #define EOF -1 + void test_alnum_symbolic(int x) { + int ret = isalnum(x); + (void)ret; + clang_analyzer_eval(EOF <= x && x <= 255); // this reports TRUE + } + +If the user disables the checker then the argument violation warning is +suppressed. However, the assumption about the argument is still modeled (otherwise we +would be further analyzing an illformed program). + +The checker models functions (and emits diagnostics) from the C standard by +default. The ``ModelPOSIX`` option enables the checker to model (and emit +diagnostics) for functions that are defined in the POSIX standard. This option +is disabled by default. + .. _alpha-unix-BlockInCriticalSection: alpha.unix.BlockInCriticalSection (C)
Index: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td =================================================================== --- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -552,7 +552,7 @@ "or is EOF.">, Dependencies<[StdCLibraryFunctionsChecker]>, WeakDependencies<[CallAndMessageChecker, NonNullParamChecker, StreamChecker]>, - Documentation<NotDocumented>; + Documentation<HasAlphaDocumentation>; } // end "alpha.unix" Index: clang/docs/analyzer/checkers.rst =================================================================== --- clang/docs/analyzer/checkers.rst +++ clang/docs/analyzer/checkers.rst @@ -2333,6 +2333,43 @@ alpha.unix ^^^^^^^^^^^ +.. _alpha-unix-StdCLibraryFunctionArgs: + +alpha.unix.StdCLibraryFunctionArgs (C) +"""""""""""""""""""""""""""""""""""""" +Check for calls of standard library functions that violate predefined argument +constraints. For example, it is stated in the C standard that for the ``int +isalnum(int ch)`` function the behavior is undefined if the value of ``ch`` is +not representable as unsigned char and is not equal to ``EOF``. + +.. code-block:: c + + void test_alnum_concrete(int v) { + int ret = isalnum(256); // \ + // warning: Function argument constraint is not satisfied + (void)ret; + } + +If the argument's value is unknown then the value is assumed to hold the proper value range. + +.. code-block:: c + + #define EOF -1 + void test_alnum_symbolic(int x) { + int ret = isalnum(x); + (void)ret; + clang_analyzer_eval(EOF <= x && x <= 255); // this reports TRUE + } + +If the user disables the checker then the argument violation warning is +suppressed. However, the assumption about the argument is still modeled (otherwise we +would be further analyzing an illformed program). + +The checker models functions (and emits diagnostics) from the C standard by +default. The ``ModelPOSIX`` option enables the checker to model (and emit +diagnostics) for functions that are defined in the POSIX standard. This option +is disabled by default. + .. _alpha-unix-BlockInCriticalSection: alpha.unix.BlockInCriticalSection (C)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits