shuaiwang added inline comments.
================
Comment at: clang-tidy/cppcoreguidelines/ConstCheck.cpp:229-237
+ const auto *UseExpr = selectFirst<Expr>("use", Usage);
+
+ // The declared variables was used in non-const conserving way and can not
+ // be declared as const.
+ if (UseExpr && Scopes[Scope]->isMutated(UseExpr)) {
+ // diag(UseExpr->getLocStart(), "Investigating starting with this use",
+ // DiagnosticIDs::Note);
----------------
I think we need to loop over usages instead of just checking the first, i.e.:
```
for (const auto &Nodes : Usage) {
const auto* UseExpr = Nodes.getNodeAs<Expr>("use");
if (UseExpr && isMutated(UseExpr)) return true;
}
```
I'll add a helper function in the MutationAnalyzer for checking varDecl
directly as well per your comment there, which you'll be able to use directly
in this check. Before that's ready (and if you have time of course) could you
help check how many false positives are left with this change?
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D45444
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits