diff options
author | Bruno Ricci <riccibrun@gmail.com> | 2019-02-03 19:50:56 +0000 |
---|---|---|
committer | Bruno Ricci <riccibrun@gmail.com> | 2019-02-03 19:50:56 +0000 |
commit | 749fd7613d081a12c0dd43ea88d5c63c2ead2a21 (patch) | |
tree | 34b491abc27542173921ecb14253eb81de381eb6 /lib/ARCMigrate/Transforms.cpp | |
parent | 52422ef96e9821d7608f58add4e458a005836429 (diff) | |
download | clang-749fd7613d081a12c0dd43ea88d5c63c2ead2a21.tar.gz |
[AST] Update the comments of the various Expr::Ignore* + Related cleanups
The description of what the various Expr::Ignore* do has drifted from the
actual implementation.
Inspection reveals that IgnoreParenImpCasts() is not equivalent to doing
IgnoreParens() + IgnoreImpCasts() until reaching a fixed point, but
IgnoreParenCasts() is equivalent to doing IgnoreParens() + IgnoreCasts()
until reaching a fixed point. There is also a fair amount of duplication
in the various Expr::Ignore* functions which increase the chance of further
future inconsistencies. In preparation for the next patch which will factor
out the implementation of the various Expr::Ignore*, do the following cleanups:
Remove Stmt::IgnoreImplicit, in favor of Expr::IgnoreImplicit. IgnoreImplicit
is the only function among all of the Expr::Ignore* which is available in Stmt.
There are only a few users of Stmt::IgnoreImplicit. They can just use instead
Expr::IgnoreImplicit like they have to do for the other Ignore*.
Move Expr::IgnoreImpCasts() from Expr.h to Expr.cpp. This made no difference
in the run-time with my usual benchmark (-fsyntax-only on all of Boost).
While we are at it, make IgnoreParenNoopCasts take a const reference to the
ASTContext for const correctness.
Update the comments to match what the Expr::Ignore* are actually doing.
I am not sure that listing exactly what each Expr::Ignore* do is optimal,
but it certainly looks better than the current state which is in my opinion
between misleading and just plain wrong.
The whole patch is NFC (if you count removing Stmt::IgnoreImplicit as NFC).
Differential Revision: https://reviews.llvm.org/D57266
Reviewed By: aaron.ballman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ARCMigrate/Transforms.cpp')
-rw-r--r-- | lib/ARCMigrate/Transforms.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/ARCMigrate/Transforms.cpp b/lib/ARCMigrate/Transforms.cpp index 6ca748bcdd..59b80a917e 100644 --- a/lib/ARCMigrate/Transforms.cpp +++ b/lib/ARCMigrate/Transforms.cpp @@ -286,10 +286,11 @@ private: void mark(Stmt *S) { if (!S) return; - while (LabelStmt *Label = dyn_cast<LabelStmt>(S)) + while (auto *Label = dyn_cast<LabelStmt>(S)) S = Label->getSubStmt(); - S = S->IgnoreImplicit(); - if (Expr *E = dyn_cast<Expr>(S)) + if (auto *E = dyn_cast<Expr>(S)) + S = E->IgnoreImplicit(); + if (auto *E = dyn_cast<Expr>(S)) Removables.insert(E); } }; |