diff options
author | Rahul Joshi <rjoshi@nvidia.com> | 2024-08-29 08:00:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-29 08:00:25 -0700 |
commit | fc110202dffa06950716e0cc4535b07aaa2c439c (patch) | |
tree | 8a8e1b4b3e33bd883d9e9c06f3f4c3e28fa1bd4a /clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | |
parent | 9edd998e10fabfff067b9e6e5b044f85a24d0dd5 (diff) | |
download | llvm-fc110202dffa06950716e0cc4535b07aaa2c439c.zip llvm-fc110202dffa06950716e0cc4535b07aaa2c439c.tar.gz llvm-fc110202dffa06950716e0cc4535b07aaa2c439c.tar.bz2 |
[Support] Validate number of arguments passed to formatv() (#105745)
Change formatv() to validate that the number of arguments passed matches
number of replacement fields in the format string, and that the replacement
indices do not contain holes.
To support cases where this cannot be guaranteed, introduce a formatv()
overload that allows disabling validation with a bool flag as its first argument.
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp index 8f4bd17..4f30b2a 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -1401,7 +1401,10 @@ void StdLibraryFunctionsChecker::checkPostCall(const CallEvent &Call, ErrnoNote = llvm::formatv("After calling '{0}' {1}", FunctionName, ErrnoNote); } else { - CaseNote = llvm::formatv(Case.getNote().str().c_str(), FunctionName); + // Disable formatv() validation as the case note may not always have the + // {0} placeholder for function name. + CaseNote = + llvm::formatv(false, Case.getNote().str().c_str(), FunctionName); } const SVal RV = Call.getReturnValue(); |