[PATCH] D57266: [AST] Update the comments of the various Expr::Ignore* + Related cleanups

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 25 16:30:12 PST 2019


riccibruno created this revision.
riccibruno added a reviewer: aaron.ballman.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D57266

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  lib/ARCMigrate/TransformActions.cpp
  lib/ARCMigrate/Transforms.cpp
  lib/AST/Expr.cpp
  lib/AST/Stmt.cpp
  lib/Analysis/ReachableCode.cpp
  lib/Tooling/ASTDiff/ASTDiff.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57266.183642.patch
Type: text/x-patch
Size: 14279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190126/0f876c1c/attachment-0001.bin>


More information about the cfe-commits mailing list