[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness
Shuai Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 30 14:39:30 PDT 2018
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
More information about the cfe-commits
mailing list