[PATCH] D66333: [analyzer] NonNullParamChecker and CStringChecker parameter number in checker message

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 29 19:17:13 PDT 2019


Charusso added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1548
 
-  state = checkNonNull(C, state, Dst, DstVal);
+  state = checkNonNull(C, state, Dst, DstVal, 1);
   if (!state)
----------------
bruntib wrote:
> NoQ wrote:
> > You could also pass a description of the parameter (eg., "source" or "destination").
> Could you please give some hint, how to include this in the message? I don't know how to do it concisely.
I have made this for that purpose:
```
struct CallContext {
    CallContext(Optional<unsigned> DestinationPos,
                Optional<unsigned> SourcePos = None,
                Optional<unsigned> LengthPos = None)
        : DestinationPos(DestinationPos), SourcePos(SourcePos),
          LengthPos(LengthPos) {};
  
    Optional<unsigned> DestinationPos;
    Optional<unsigned> SourcePos;
    Optional<unsigned> LengthPos;
  };
```
```
// char *strcpy(char *dest, const char *src);
{{CDF_MaybeBuiltin, "stpcpy", 2}, {&CStringChecker::evalStpcpy, {0, 1}}},
```
May it helps.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66333





More information about the cfe-commits mailing list