[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 28 01:02:14 PDT 2020


NoQ added a comment.

> Yes, indeed very poorly. A C++ operator call is either implemented as CXXOperatorCall or CXXMethodCall randomly. In the former case the this parameter is explicit at the beginning, in the latter case it is implicit.

We have methods on `CallEvent` to handle this, namely `getAdjustedParameterIndex()` and `getASTArgumentIndex()`. They were added in D49443 <https://reviews.llvm.org/D49443>.

> But this is not the only problem with indices. I have no solution for the following call (is it really a call?) resulting in an assertion because overindexing in `nullability.mm`:
> 
>   Dummy *_Nonnull (^myblock)(void) = ^Dummy *_Nonnull(void) {
> 
> 
> Even if I try to get the `FunctionDecl` it still says that it has `0` parameters, exactly what `CallExpr` says, but we //have// a parameter here with index of `0`. How can it be? How should I handle this strange case? I only have very basic //Objective-C// knowledge.

These are blocks. They are like lambdas, just different syntax. They aren't part of Objective-C; they're a non-standard extension to C supported by both gcc and clang.

The line you quoted is not a call, it only defines a block and assigns it into a variable of block pointer type. Here's the full code of the test:

  358 void testNilReturnWithBlock(Dummy *p) {
  359   p = 0;
  360   Dummy *_Nonnull (^myblock)(void) = ^Dummy *_Nonnull(void) {
  361     return p; // TODO: We should warn in blocks.
  362   };
  363   myblock();
  364 }

The block is invoked on line 363. Parameter `p` of the surrounding function is accessible from the block because it was captured; it is not a parameter of the block itself.

> As far as I know, you have more than 10 years experience in the Analyzer. I work on the analyzer for less than 5 years, and not full time, because I also create Tidy checkers sometimes, I also have our internal stuff (most of which I would like to upstream).

I started in mid-2014. I too am regularly distracted to stuff that isn't particularly educational about the analyzer.


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

https://reviews.llvm.org/D77229





More information about the cfe-commits mailing list