[clang] 66d022f - [clang][analyzer] Fix incorrect range of 'ftell' in the StdLibraryFunctionsChecker (#77576)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 10 17:10:39 PST 2024
Author: Ben Shi
Date: 2024-01-11T09:10:34+08:00
New Revision: 66d022f326779c8abe80b272751fab1a10992222
URL: https://github.com/llvm/llvm-project/commit/66d022f326779c8abe80b272751fab1a10992222
DIFF: https://github.com/llvm/llvm-project/commit/66d022f326779c8abe80b272751fab1a10992222.diff
LOG: [clang][analyzer] Fix incorrect range of 'ftell' in the StdLibraryFunctionsChecker (#77576)
According to https://pubs.opengroup.org/onlinepubs/9699919799/, the
return value of `ftell` is not restricted to `> 0`, and may return `0`
in real world.
Added:
Modified:
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 32a2deab871c79..3b36565681a7f3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -2274,7 +2274,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
addToFunctionSummaryMap(
"ftell", Signature(ArgTypes{FilePtrTy}, RetType{LongTy}),
Summary(NoEvalCall)
- .Case({ReturnValueCondition(WithinRange, Range(1, LongMax))},
+ .Case({ReturnValueCondition(WithinRange, Range(0, LongMax))},
ErrnoUnchanged, GenericSuccessMsg)
.Case(ReturnsMinusOne, ErrnoNEZeroIrrelevant, GenericFailureMsg)
.ArgConstraint(NotNull(ArgNo(0))));
More information about the cfe-commits
mailing list