[PATCH] D90691: [analyzer] Add new checker for unchecked return value.

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 6 07:09:13 PST 2020


balazske marked 2 inline comments as done.
balazske added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/UncheckedReturnValueChecker.cpp:41
+                        BugReporter &BR) const {
+    auto FoundCall = callExpr().bind("call");
+    auto CallInCompound = compoundStmt(forEach(FoundCall));
----------------
baloghadamsoftware wrote:
> Please note that the `CallExpr` does not necessarily stands alone. It may be wrapped into an `ExprWithCleanUps`. We should consider these `CallExpr`s as unchecked too.
It looks like that the matcher finds these occurrences too. A test was added for it.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/UncheckedReturnValueChecker.cpp:85
+private:
+  llvm::StringMap<int> FunctionsToCheck = {
+      {"aligned_alloc", 2}, {"asctime_s", 3},     {"at_quick_exit", 1},
----------------
baloghadamsoftware wrote:
> Hmm, why `StringMap<>`? Why not `CallDescriptionMap<>`?
`CallDescriptionMap` is only usable with `CallEvent` that is not used in this checker. Or it can be extended with lookup from `FunctionDecl`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90691/new/

https://reviews.llvm.org/D90691



More information about the cfe-commits mailing list