[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 2 04:42:47 PDT 2018


JonasToth added a comment.

I see. Thank you for fixing + explaining :)

Am 30.04.2018 um 23:39 schrieb Shuai Wang via Phabricator:

> shuaiwang added a comment.
> 
>> Why do you think that looping is required? From my understanding, we
>> 
>>   need the first usage (DeclRefExpr) to get the analysis started. The
>>   analysis itself will check all remaining uses. Is this necessary,
>>   because we analysis on a `Expr` basis?
> 
> Yes. the analyzer traces starting from the given DeclRefExpr, e.g.:
> 
>   int a; // <- varDecl
>   const int& b = a;  // <- first DeclRefExpr
>   int& c = a; // <- second DeclRefExpr
>   
>   const int& b2 = b;
>   int& c2 = c;
>   c2 = 10;
> 
> If we start from the first DeclRefExpr, we'll only trace to `b` and then to `b2`. We need to start from varDecl (or loop over all DeclRefExpr) to be able to trace to the second DeclRefExpr from where we can get to `c` -> `c2` -> `c2 = 10`.
> 
> Repository:
> 
>   rCTE Clang Tools Extra
> 
> https://reviews.llvm.org/D45444


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444





More information about the cfe-commits mailing list