[clang] [clang][analyzer] Improve modeling of 'realpath' in StdLibraryFunctionsChecker (PR #79939)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 30 07:55:42 PST 2024
================
@@ -2992,12 +2992,14 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
// char *realpath(const char *restrict file_name,
// char *restrict resolved_name);
- // FIXME: Improve for errno modeling.
addToFunctionSummaryMap(
"realpath",
Signature(ArgTypes{ConstCharPtrRestrictTy, CharPtrRestrictTy},
RetType{CharPtrTy}),
- Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0))));
+ Summary(NoEvalCall)
+ .Case({NotNull(Ret)}, ErrnoMustNotBeChecked, GenericSuccessMsg)
+ .Case({IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg)
+ .ArgConstraint(NotNull(ArgNo(0))));
----------------
balazske wrote:
The buffer at arg 1 should have size of `MAX_PATH` if not null, this can be additional improvement (probably add a FIXME for it).
https://github.com/llvm/llvm-project/pull/79939
More information about the cfe-commits
mailing list