[PATCH] D16044: getDescriptiveName() for MemRegion

Alexander Droste via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 30 17:01:53 PDT 2016


Alexander_Droste added inline comments.

================
Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:653
@@ +652,3 @@
+    // name by calling 'getDescriptiveName' recursively.
+    else {
+      std::string Idx = ER->getDescriptiveName(false);
----------------
Alexander_Droste wrote:
> zaks.anna wrote:
> > xazax.hun wrote:
> > > Alexander_Droste wrote:
> > > > I wasn't able to build a test case yet for which the analyzer could not determine the constant value. Is there a way to trick the analyzer so that the else case is used ? Then I could test for something like `'sendReq1[a][7][b]'`.
> > > You can try use a value returned from a function that has an unknown body. E.g.:
> > > 
> > > int getUnknown();
> > > 
> > > void f() {
> > >   int a = getUnKnown();
> > > }
> > What happens when you try 'sendReq1[a][7][b]'? Does it know the values for "a" and "b" for some reason? If 'a' would be an input parameter and the analyzer did not see a call site, it won't know the value of 'a'.
> If the return value of a function is used for which the body is not known Clang crashes.
> 
> ```
>   int getUnknown(void);
>   int idxA = getUnknown();
>   MPI_Request sendReq1[10][10][10];
>   MPI_Wait(&sendReq1[1][idxA][9], MPI_STATUS_IGNORE); // expected-warning{{Request 'sendReq1[1][7][9]' has no matching nonblocking call.}}
> ```
> Clang also crashes if the index-variable is not initialized.
> 
> ```
>   int idxA;
>   MPI_Request sendReq1[10][10][10];
>   MPI_Wait(&sendReq1[1][idxA][9], MPI_STATUS_IGNORE); // expected-warning{{Request 'sendReq1[1][7][9]' has no matching nonblocking call.}}
> ```
> In case the variable is initialized with a constant, the `ConcreteInt` is determined.
..MPI-Checker doesn't emit diagnostics which include variable names as indices like `sendReq1[a][7][b]`. The problem is that the checker has to reason about single regions. If the specific index is not known, `getDescriptiveName()` tries to obtain the variable name. But those cases are skipped by the checker, as it does not know which specific region is used.


http://reviews.llvm.org/D16044





More information about the cfe-commits mailing list