Skip to content

Commit 7af4e8b

Browse files
authored
[clang][analyzer] Change default value of checker option in unix.StdCLibraryFunctions. (#80457)
Default value of checker option `ModelPOSIX` is changed to `true`. Documentation is updated.
1 parent 96b2c3b commit 7af4e8b

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

clang/docs/analyzer/checkers.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,10 +1320,23 @@ range of the argument.
13201320
13211321
**Parameters**
13221322
1323-
The checker models functions (and emits diagnostics) from the C standard by
1324-
default. The ``ModelPOSIX`` option enables modeling (and emit diagnostics) of
1325-
additional functions that are defined in the POSIX standard. This option is
1326-
disabled by default.
1323+
The ``ModelPOSIX`` option controls if functions from the POSIX standard are
1324+
recognized by the checker.
1325+
1326+
With ``ModelPOSIX=true``, many POSIX functions are modeled according to the
1327+
`POSIX standard`_. This includes ranges of parameters and possible return
1328+
values. Furthermore the behavior related to ``errno`` in the POSIX case is
1329+
often that ``errno`` is set only if a function call fails, and it becomes
1330+
undefined after a successful function call.
1331+
1332+
With ``ModelPOSIX=false``, this checker follows the C99 language standard and
1333+
only models the functions that are described there. It is possible that the
1334+
same functions are modeled differently in the two cases because differences in
1335+
the standards. The C standard specifies less aspects of the functions, for
1336+
example exact ``errno`` behavior is often unspecified (and not modeled by the
1337+
checker).
1338+
1339+
Default value of the option is ``true``.
13271340
13281341
.. _osx-checkers:
13291342

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">,
578578
"ModelPOSIX",
579579
"If set to true, the checker models additional functions "
580580
"from the POSIX standard.",
581-
"false",
581+
"true",
582582
InAlpha>
583583
]>,
584584
WeakDependencies<[CallAndMessageChecker, NonNullParamChecker]>,

clang/test/Analysis/analyzer-config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
// CHECK-NEXT: unix.DynamicMemoryModeling:Optimistic = false
130130
// CHECK-NEXT: unix.Errno:AllowErrnoReadOutsideConditionExpressions = true
131131
// CHECK-NEXT: unix.StdCLibraryFunctions:DisplayLoadedSummaries = false
132-
// CHECK-NEXT: unix.StdCLibraryFunctions:ModelPOSIX = false
132+
// CHECK-NEXT: unix.StdCLibraryFunctions:ModelPOSIX = true
133133
// CHECK-NEXT: unroll-loops = false
134134
// CHECK-NEXT: verbose-report-filename = false
135135
// CHECK-NEXT: widen-loops = false

0 commit comments

Comments
 (0)