ASDenysPetrov added a comment.

In D105340#2855387 <https://reviews.llvm.org/D105340#2855387>, @vsavchenko 
wrote:

> Also, although the test is very extensive, it is pretty lopsided at the same 
> time.  C-style cast is only one case out of the myriad of all explicit and, 
> more importantly, implicit casts.

I agree in a part of size, but these C-style casts generates the same AST tree 
as all other ex/implicit forms of casts . Though, casts can look completely 
differently but at a low level they are very similar.
Here is an example:

  void test(long x) {
    (llong)(short)(char)x; 
  }
  
  FunctionDecl 0xbc306b8 <test.cpp:1:1, line:3:1> line:1:6 test 'void (long)'
    |-ParmVarDecl 0xbc305f0 <col:11, col:16> col:16 used x 'long'
    `-CompoundStmt 0xbc9f4b0 <col:19, line:3:1>
      `-CStyleCastExpr 0xbc9f488 <line:2:3, col:27> 'long long' <NoOp>
        `-ImplicitCastExpr 0xbc9f470 <col:14, col:27> 'long long' 
<IntegralCast> part_of_explicit_cast
          `-CStyleCastExpr 0xbc9f430 <col:14, col:27> 'short' <NoOp>
            `-ImplicitCastExpr 0xbc9f418 <col:21, col:27> 'short' 
<IntegralCast> part_of_explicit_cast
              `-CStyleCastExpr 0xbc9f3d8 <col:21, col:27> 'char' <NoOp>
                `-ImplicitCastExpr 0xbc9f3c0 <col:27> 'char' <IntegralCast> 
part_of_explicit_cast
                  `-ImplicitCastExpr 0xbc9f3a8 <col:27> 'long' <LValueToRValue> 
part_of_explicit_cast
                    `-DeclRefExpr 0xbc9f378 <col:27> 'long' lvalue ParmVar 
0xbc305f0 'x' 'long'

and

  void test(long x) {  
    char c = x;
    if(static_cast<short>(c) == -1ll);
  }
  
  `-FunctionDecl 0xbc606b8 <test.cpp:1:1, line:4:1> line:1:6 test 'void (long)'
    |-ParmVarDecl 0xbc605f0 <col:11, col:16> col:16 used x 'long'
    `-CompoundStmt 0xbcd0598 <col:19, line:4:1>
      |-DeclStmt 0xbcd0450 <line:2:3, col:13>
      | `-VarDecl 0xbcd0398 <col:3, col:12> col:8 used c 'char' cinit
      |   `-ImplicitCastExpr 0xbcd0438 <col:12> 'char' <IntegralCast>
      |     `-ImplicitCastExpr 0xbcd0420 <col:12> 'long' <LValueToRValue>
      |       `-DeclRefExpr 0xbcd0400 <col:12> 'long' lvalue ParmVar 0xbc605f0 
'x' 'long'
      `-IfStmt 0xbcd0578 <line:3:3, col:36>
        |-BinaryOperator 0xbcd0550 <col:6, col:32> 'bool' '=='
        | |-ImplicitCastExpr 0xbcd0538 <col:6, col:26> 'long long' 
<IntegralCast>
        | | `-CXXStaticCastExpr 0xbcd04d0 <col:6, col:26> 'short' 
static_cast<short> <NoOp>
        | |   `-ImplicitCastExpr 0xbcd04b8 <col:25> 'short' <IntegralCast> 
part_of_explicit_cast
        | |     `-ImplicitCastExpr 0xbcd04a0 <col:25> 'char' <LValueToRValue> 
part_of_explicit_cast
        | |       `-DeclRefExpr 0xbcd0468 <col:25> 'char' lvalue Var 0xbcd0398 
'c' 'char'
        | `-UnaryOperator 0xbcd0520 <col:31, col:32> 'long long' prefix '-'
        |   `-IntegerLiteral 0xbcd0500 <col:32> 'long long' 1
        `-NullStmt 0xbcd0570 <col:36>

We can see similar `IntegralCast` for both variants. I was aiming to generate 
all the cases of `IntegralCast` and C-style cast is enough for me.



================
Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:318
+ANALYZER_OPTION(bool, ShouldHandleIntegralCastForRanges,
+                "handle-integral-cast-for-ranges",
+                "Handle truncations, promotions and conversions for ranges of "
----------------
vsavchenko wrote:
> BTW, mb it should be less specific?  Something like 
> `ShouldSupportSymbolicIntegerCasts`?
> BTW 2, do you even plan on supporting symbolic casts in other cases?
> ShouldSupportSymbolicIntegerCasts?
Thanks. I thought about an appropriate name but failed to come up. That's what 
we need!
> BTW 2, do you even plan on supporting symbolic casts in other cases?
I think about adding //bool-int//, //int-bool//, //ptr-int//, //int-ptr// to 
the list.


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

https://reviews.llvm.org/D105340

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to