[PATCH] D105340: [analyzer] Produce SymbolCast symbols for integral types in SValBuilder::evalCast

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 2 07:08:54 PDT 2021


steakhal added inline comments.


================
Comment at: clang/test/Analysis/produce-symbolcast.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-config handle-integral-cast-for-ranges=true -verify %s
+
----------------
vsavchenko wrote:
> ASDenysPetrov wrote:
> > vsavchenko wrote:
> > > This test is failing on my desktop, when I downloaded your patch:
> > > ```
> > > error: 'warning' diagnostics expected but not seen: 
> > >   File .../produce-symbolcast.cpp Line 67: (long) (reg_$0<char x>)
> > >   File .../produce-symbolcast.cpp Line 79: (long long) ((unsigned long) (reg_$0<char x>))
> > >   File .../produce-symbolcast.cpp Line 122: (unsigned long) (reg_$0<char x>)
> > >   File .../produce-symbolcast.cpp Line 134: (unsigned long long) ((unsigned long) (reg_$0<char x>))
> > >   File .../produce-symbolcast.cpp Line 192: (long) (reg_$0<short x>)
> > >   File .../produce-symbolcast.cpp Line 204: (long long) ((unsigned long) (reg_$0<short x>))
> > >   File .../produce-symbolcast.cpp Line 247: (unsigned long) (reg_$0<short x>)
> > >   File .../produce-symbolcast.cpp Line 259: (unsigned long long) ((unsigned long) (reg_$0<short x>))
> > >   File .../produce-symbolcast.cpp Line 317: (long) (reg_$0<int x>)
> > >   File .../produce-symbolcast.cpp Line 329: (long long) ((unsigned long) (reg_$0<int x>))
> > >   File .../produce-symbolcast.cpp Line 372: (unsigned long) (reg_$0<int x>)
> > >   File .../produce-symbolcast.cpp Line 384: (unsigned long long) ((unsigned long) (reg_$0<int x>))
> > >   File .../produce-symbolcast.cpp Line 448: (long long) (reg_$0<long x>)
> > >   File .../produce-symbolcast.cpp Line 454: (long long) ((unsigned long) (reg_$0<long x>))
> > >   File .../produce-symbolcast.cpp Line 492: (unsigned long) (reg_$0<long x>)
> > >   File .../produce-symbolcast.cpp Line 497: (unsigned long) (reg_$0<long x>)
> > >   File .../produce-symbolcast.cpp Line 503: (unsigned long long) (reg_$0<long x>)
> > >   File .../produce-symbolcast.cpp Line 509: (unsigned long long) ((unsigned long) (reg_$0<long x>))
> > >   File .../produce-symbolcast.cpp Line 562: (long) (reg_$0<llong x>)
> > >   File .../produce-symbolcast.cpp Line 567: (long) (reg_$0<llong x>)
> > >   File .../produce-symbolcast.cpp Line 574: (long) (reg_$0<llong x>)
> > >   File .../produce-symbolcast.cpp Line 579: (unsigned long) (reg_$0<llong x>)
> > >   File .../produce-symbolcast.cpp Line 617: (unsigned long) (reg_$0<llong x>)
> > >   File .../produce-symbolcast.cpp Line 622: (unsigned long) (reg_$0<llong x>)
> > >   File .../produce-symbolcast.cpp Line 629: (unsigned long long) ((long) (reg_$0<llong x>))
> > >   File .../produce-symbolcast.cpp Line 634: (unsigned long long) ((unsigned long) (reg_$0<llong x>))
> > >   File .../produce-symbolcast.cpp Line 937: (long) (reg_$0<uint x>)
> > >   File .../produce-symbolcast.cpp Line 949: (long long) ((long) (reg_$0<uint x>))
> > >   File .../produce-symbolcast.cpp Line 992: (unsigned long) (reg_$0<uint x>)
> > >   File .../produce-symbolcast.cpp Line 1004: (unsigned long long) ((long) (reg_$0<uint x>))
> > >   File .../produce-symbolcast.cpp Line 1062: (long) (reg_$0<ulong x>)
> > >   File .../produce-symbolcast.cpp Line 1067: (long) (reg_$0<ulong x>)
> > >   File .../produce-symbolcast.cpp Line 1074: (long long) ((long) (reg_$0<ulong x>))
> > >   File .../produce-symbolcast.cpp Line 1078: (long long) (reg_$0<ulong x>)
> > >   File .../produce-symbolcast.cpp Line 1129: (unsigned long long) ((long) (reg_$0<ulong x>))
> > >   File .../produce-symbolcast.cpp Line 1133: (unsigned long long) (reg_$0<ulong x>)
> > >   File .../produce-symbolcast.cpp Line 1187: (long) (reg_$0<ullong x>)
> > >   File .../produce-symbolcast.cpp Line 1192: (long) (reg_$0<ullong x>)
> > >   File .../produce-symbolcast.cpp Line 1199: (long long) ((long) (reg_$0<ullong x>))
> > >   File .../produce-symbolcast.cpp Line 1204: (long long) ((unsigned long) (reg_$0<ullong x>))
> > >   File .../produce-symbolcast.cpp Line 1242: (unsigned long) (reg_$0<ullong x>)
> > >   File .../produce-symbolcast.cpp Line 1247: (unsigned long) (reg_$0<ullong x>)
> > >   File .../produce-symbolcast.cpp Line 1254: (unsigned long long) ((long) (reg_$0<ullong x>))
> > >   File .../produce-symbolcast.cpp Line 1259: (unsigned long long) ((unsigned long) (reg_$0<ullong x>))
> > > error: 'warning' diagnostics seen but not expected: 
> > >   File .../produce-symbolcast.cpp Line 67: (long) ((unsigned int) (reg_$0<char x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 79: (long long) (reg_$0<char x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 122: (unsigned long) ((unsigned int) (reg_$0<char x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 134: (unsigned long long) (reg_$0<char x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 192: (long) ((unsigned int) (reg_$0<short x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 204: (long long) (reg_$0<short x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 247: (unsigned long) ((unsigned int) (reg_$0<short x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 259: (unsigned long long) (reg_$0<short x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 317: (long) ((unsigned int) (reg_$0<int x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 329: (long long) (reg_$0<int x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 372: (unsigned long) ((unsigned int) (reg_$0<int x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 384: (unsigned long long) (reg_$0<int x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 448: (long long) ((int) (reg_$0<long x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 454: (long long) (reg_$0<long x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 492: (unsigned long) ((int) (reg_$0<long x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 497: (unsigned long) ((unsigned int) (reg_$0<long x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 503: (unsigned long long) ((int) (reg_$0<long x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 509: (unsigned long long) (reg_$0<long x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 562: (long) ((int) (reg_$0<llong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 567: (long) ((unsigned int) (reg_$0<llong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 574: reg_$0<llong x> [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 579: reg_$0<llong x> [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 617: (unsigned long) ((int) (reg_$0<llong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 622: (unsigned long) ((unsigned int) (reg_$0<llong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 629: (unsigned long long) (reg_$0<llong x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 634: (unsigned long long) (reg_$0<llong x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 937: (long) ((int) (reg_$0<uint x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 949: (long long) (reg_$0<uint x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 992: (unsigned long) ((int) (reg_$0<uint x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1004: (unsigned long long) (reg_$0<uint x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1062: (long) ((int) (reg_$0<ulong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1067: (long) ((unsigned int) (reg_$0<ulong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1074: (long long) (reg_$0<ulong x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1078: (long long) ((unsigned int) (reg_$0<ulong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1129: (unsigned long long) (reg_$0<ulong x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1133: (unsigned long long) ((unsigned int) (reg_$0<ulong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1187: (long) ((int) (reg_$0<ullong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1192: (long) ((unsigned int) (reg_$0<ullong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1199: (long long) (reg_$0<ullong x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1204: (long long) (reg_$0<ullong x>) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1242: (unsigned long) ((int) (reg_$0<ullong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1247: (unsigned long) ((unsigned int) (reg_$0<ullong x>)) [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1254: reg_$0<ullong x> [debug.ExprInspection]
> > >   File .../produce-symbolcast.cpp Line 1259: reg_$0<ullong x> [debug.ExprInspection]
> > > 88 errors generated.
> > > ```
> > I expected something of that. Thank you for the log. Could you please tell me what is `sizeof(long)` on you PC while test running?
> `sizeof(long) == 8`
> 
> PS: buildbot also found it
> https://reviews.llvm.org/harbormaster/unit/view/800270/
Maybe we shall explicitly pass the triple, and test for the major archs, such as linux 32 bits, linux 64 bits, and probably at least one from Microsoft?
@ASDenysPetrov, you use Windows, don't you?


================
Comment at: clang/test/Analysis/produce-symbolcast.cpp:16
+
+  clang_analyzer_dump((char)x);   // expected-warning{{reg_$0<char x>}}
+  clang_analyzer_dump((short)x);  // expected-warning{{(short) (reg_$0<char x>)}}
----------------
`char` and `signed char` mean different types.
We should probably have `schar` and test it as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105340



More information about the cfe-commits mailing list