[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

Anna Zaks via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 24 21:53:39 PST 2017


zaks.anna added a comment.

I agree this can clarify the error message quite a bit!



================
Comment at: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:160
   if (ParamDecl->getType()->isPointerType()) {
-    Message = "Function call argument is a pointer to uninitialized value";
+    Message = "Function call argument number '" +
+              std::to_string(ArgumentNumber+1) +
----------------
Let's use llvm::getOrdinalSuffix() so that we write "1st argument" instead of "argument number '1'".


================
Comment at: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:211
       // Generate a report for this bug.
-      StringRef Desc =
-          describeUninitializedArgumentInCall(Call, IsFirstArgument);
+      std::string Desc =
+          describeUninitializedArgumentInCall(Call, ArgumentNumber);
----------------
Have you considered using  llvm::raw_svector_ostream here as well as passing it an argument to describeUninitializedArgumentInCall? For example, see  MallocChecker.cpp.


Repository:
  rL LLVM

https://reviews.llvm.org/D30341





More information about the cfe-commits mailing list