[clang] Improve modeling of 'getcwd' in the StdLibraryFunctionsChecker (PR #77040)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 8 01:10:06 PST 2024
================
@@ -2519,12 +2519,17 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
addToFunctionSummaryMap(
"getcwd", Signature(ArgTypes{CharPtrTy, SizeTy}, RetType{CharPtrTy}),
Summary(NoEvalCall)
- .Case({ReturnValueCondition(BO_EQ, ArgNo(0))},
+ .Case({ArgumentCondition(1, WithinRange, Range(1, SizeMax)),
+ ReturnValueCondition(BO_EQ, ArgNo(0))},
ErrnoMustNotBeChecked, GenericSuccessMsg)
+ .Case({ArgumentCondition(1, WithinRange, SingleValue(0))},
+ ErrnoNEZeroIrrelevant, GenericFailureMsg)
.Case({IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg)
----------------
balazske wrote:
```suggestion
.Case({ArgumentCondition(1, WithinRange, Range(1, SizeMax)), IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg)
```
https://github.com/llvm/llvm-project/pull/77040
More information about the cfe-commits
mailing list