[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

Valeriy Savchenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 6 09:07:51 PDT 2021


vsavchenko added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2801-2802
+  // Get a root symbol in case of SymbolCast.
+  while (isa<SymbolCast>(Sym))
+    Sym = cast<SymbolCast>(Sym)->getOperand();
+
----------------
ASDenysPetrov wrote:
> vsavchenko wrote:
> > This looks like a pattern and we should probably make into a method of `SymbolCast`
> I did it :) but refused. It will just turn into:
> ```
>   if (isa<SymbolCast>(Sym))
>     Sym = cast<SymbolCast>(Sym)->getRootOperand();
> ```
> It looks pretty the same and brings no benefit IMO, does it?
> Every time I used `getRootOperand` I also needed some additional traverse through the types te get some another information, so I couldn't avoid the `while` loop there. So I decided not to introduce a new method in `SymbolCast`.
Aha, I see your point.  I guess we can take it into `SymExpr` and call it not `getRootOperand`, which won't tell much to a person reading the name, but something like `ignoreCasts`.  It will fit well with `Expr::IgnoreCasts`, `Expr::IgnoreParens`, etc.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103096/new/

https://reviews.llvm.org/D103096



More information about the cfe-commits mailing list