[PATCH] D101041: [analyzer] Find better description for tracked symbolic values

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 25 23:50:06 PDT 2021


NoQ added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:163-165
+      ProgramStateManager &StateMgr = N->getState()->getStateManager();
+      MemRegionManager &MRMgr = StateMgr.getRegionManager();
+      return MRMgr.getVarRegion(VD, N->getLocationContext());
----------------
This isn't your code but it came to my attention that there's a convenient (but equally confusing) shortcut for this:
```lang=c++
return N->getState()->getLValue(VD, N->getLocationContext());
```


================
Comment at: clang/test/Analysis/uninit-const.cpp:78
   int t;       //expected-note {{'t' declared without an initial value}}
-  int &p = t;  //expected-note {{'p' initialized here}}
-  int &s = p;  //expected-note {{'s' initialized here}}
-  int &q = s;  //expected-note {{'q' initialized here}}
+  int &p = t;  //expected-note {{'p' initialized to the value of 't'}}
+  int &s = p;  //expected-note {{'s' initialized to the value of 'p'}}
----------------
I suspect that this wording can be improved a lot. The note "`'p' initialized to the value of 't'`" sounds like an accurate description for `int p = t` but not so much for `int &p = t`. Can we detect this case and say something like "`'p' refers to 't'`" instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101041



More information about the cfe-commits mailing list