[clang] [clang][analyzer] Change default value of checker option in unix.StdCLibraryFunctions. (PR #80457)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 29 08:19:02 PST 2024


https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/80457

>From 1f65abda712efce624c01ec99675c8261a8e6cea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= <balazs.keri at ericsson.com>
Date: Wed, 31 Jan 2024 17:40:21 +0100
Subject: [PATCH 1/2] {clang][analyzer] Change default value of checker option
 in unix.StdCLibraryFunctions.

Default value of checker option `ModelPOSIX` is changed to `true`.
Documentation is updated.
---
 clang/docs/analyzer/checkers.rst              | 19 +++++++++++++++----
 .../clang/StaticAnalyzer/Checkers/Checkers.td |  2 +-
 clang/test/Analysis/analyzer-config.c         |  2 +-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index bb637cf1b8007b..24522e56501e54 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1299,10 +1299,21 @@ range of the argument.
 
 **Parameters**
 
-The checker models functions (and emits diagnostics) from the C standard by
-default. The ``ModelPOSIX`` option enables modeling (and emit diagnostics) of
-additional functions that are defined in the POSIX standard. This option is
-disabled by default.
+The ``ModelPOSIX`` option controls if functions from the POSIX standard are
+recognized by the checker. If ``true``, a big amount of POSIX functions is
+modeled according to the
+`POSIX standard`_. This
+includes ranges of parameters and possible return values. Furthermore the
+behavior related to ``errno`` in the POSIX case is often that ``errno`` is set
+only if a function call fails, and it becomes undefined after a successful
+function call.
+If ``false``, functions are modeled according to the C99 language standard.
+This includes far less functions than the POSIX case. It is possible that the
+same functions are modeled differently in the two cases because differences in
+the standards. The C standard specifies less aspects of the functions, for
+example exact ``errno`` behavior is often unspecified (and not modeled by the
+checker).
+Default value of the option is ``true``.
 
 .. _osx-checkers:
 
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index e7774e5a9392d2..a224b81c33a624 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -578,7 +578,7 @@ def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">,
                   "ModelPOSIX",
                   "If set to true, the checker models additional functions "
                   "from the POSIX standard.",
-                  "false",
+                  "true",
                   InAlpha>
   ]>,
   WeakDependencies<[CallAndMessageChecker, NonNullParamChecker]>,
diff --git a/clang/test/Analysis/analyzer-config.c b/clang/test/Analysis/analyzer-config.c
index 373017f4b18bfc..2167a2b32f5962 100644
--- a/clang/test/Analysis/analyzer-config.c
+++ b/clang/test/Analysis/analyzer-config.c
@@ -129,7 +129,7 @@
 // CHECK-NEXT: unix.DynamicMemoryModeling:Optimistic = false
 // CHECK-NEXT: unix.Errno:AllowErrnoReadOutsideConditionExpressions = true
 // CHECK-NEXT: unix.StdCLibraryFunctions:DisplayLoadedSummaries = false
-// CHECK-NEXT: unix.StdCLibraryFunctions:ModelPOSIX = false
+// CHECK-NEXT: unix.StdCLibraryFunctions:ModelPOSIX = true
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: verbose-report-filename = false
 // CHECK-NEXT: widen-loops = false

>From 136b4c639dca08349e958f141620afea874924d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= <balazs.keri at ericsson.com>
Date: Thu, 29 Feb 2024 17:18:37 +0100
Subject: [PATCH 2/2] changed the documentation

---
 clang/docs/analyzer/checkers.rst | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 24522e56501e54..9ede1657dcc356 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1300,19 +1300,21 @@ range of the argument.
 **Parameters**
 
 The ``ModelPOSIX`` option controls if functions from the POSIX standard are
-recognized by the checker. If ``true``, a big amount of POSIX functions is
-modeled according to the
-`POSIX standard`_. This
-includes ranges of parameters and possible return values. Furthermore the
-behavior related to ``errno`` in the POSIX case is often that ``errno`` is set
-only if a function call fails, and it becomes undefined after a successful
-function call.
-If ``false``, functions are modeled according to the C99 language standard.
-This includes far less functions than the POSIX case. It is possible that the
+recognized by the checker.
+
+With ``ModelPOSIX=true``, many POSIX functions are modeled according to the
+`POSIX standard`_. This includes ranges of parameters and possible return
+values. Furthermore the behavior related to ``errno`` in the POSIX case is
+often that ``errno`` is set only if a function call fails, and it becomes
+undefined after a successful function call.
+
+With ``ModelPOSIX=false``, this checker follows the C99 language standard and
+only models the functions that are described there. It is possible that the
 same functions are modeled differently in the two cases because differences in
 the standards. The C standard specifies less aspects of the functions, for
 example exact ``errno`` behavior is often unspecified (and not modeled by the
 checker).
+
 Default value of the option is ``true``.
 
 .. _osx-checkers:



More information about the cfe-commits mailing list