MTC added a comment.

In https://reviews.llvm.org/D45491#1063364, @george.karpenkov wrote:

> @MTC what happens for
>
>   this.j = 0;
>   for (int i=0; i<100; i++)
>      this.j++;
>
>
> ?


@george.karpenkov  `this`'s value will remain unchanged, `j` will be 
invalidated.

   1   void clang_analyzer_printState();
   2   struct A {
   3       int j;
   4       void foo() {
   5           this->j = 0;
   6           clang_analyzer_printState();
   7           for (int i = 0; i < 100; ++i)
   8               this->j++;
   9           clang_analyzer_printState();
  10     }
  11   };
  12
  13   void func() {
  14       A a;
  15       a.foo();
  16   }

For the above code, given the command `clang -cc1 -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config widen-loops=true 
test.cpp`. The output about `Store` is as follows.

  Store (direct and default bindings), 0x7fb7d008c068 :
   (a,0,direct) : 0 S32b
  
   (this,0,direct) : &a
  
  ----------------------------------------------------------------------------
  Store (direct and default bindings), 0x7fb7d080a618 :
   (a,0,default) : conj_$1{int}
  
   (this,0,direct) : &a


Repository:
  rC Clang

https://reviews.llvm.org/D45491



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to