[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 2 11:18:06 PDT 2018
aaron.ballman added inline comments.
================
Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:42
+ const auto Memoized = Results.find(Exp);
+ if (Memoized != Results.end()) {
+ return Memoized->second;
----------------
Can elide the braces.
================
Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:71
+ for (const auto &DeclNodes : Matches) {
+ if (const auto *S = findDeclMutation(DeclNodes.getNodeAs<Decl>("decl")))
+ return S;
----------------
Don't use `auto` here.
================
Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:82-83
+ const auto *E = RefNodes.getNodeAs<Expr>("expr");
+ if (findMutation(E))
+ return E;
+ }
----------------
Why does this not return the result of `findMutation()` like the other call above?
================
Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:88
+
+const Stmt *ExprMutationAnalyzer::findDirectMutation(const Expr *Exp) {
+ // LHS of any assignment operators.
----------------
Should this also consider a DeclRefExpr to a volatile-qualified variable as a direct mutation?
What about using `Expr::HasSideEffect()`?
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D45679
More information about the cfe-commits
mailing list