[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:06:19 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))},
----------------
balazske wrote:

```suggestion
            .Case({ArgumentCondition(1, WithinRange, SingleValue(0)),
                   IsNull(Ret)},
                  ErrnoNEZeroIrrelevant,
                  "Assuming that argument 'size' is 0")
```

https://github.com/llvm/llvm-project/pull/77040


More information about the cfe-commits mailing list