[PATCH] D95799: [analyzer] Symbolicate float values with integral casting

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 5 02:47:45 PST 2021


steakhal added a comment.

  void clang_analyzer_dumpi(int);
  void clang_analyzer_dumpf(float);
  void clang_analyzer_dumpip(int*);
  void clang_analyzer_dumpfp(float*);
  
  void SymbolCast_of_float_type_aux(int *p) {
    *p += 1;
    clang_analyzer_dumpi(*p); // (Previously): Unknown  ->  (Now): (float) (conj_$1{int, LC2, S790, #1})
    clang_analyzer_dumpf(*p); // (Previously): Unknown  ->  (Now): (float) (conj_$1{int, LC2, S790, #1})
    clang_analyzer_dumpip(p); // &Element{x1,1 S64b,float}
    clang_analyzer_dumpfp(p); // &Element{x1,1 S64b,float}
  }
  
  void SymbolCast_of_float_type() {
    extern float x1;
    extern double x2;
    extern long double x3;
  
    void (*f)() = SymbolCast_of_float_type_aux;
  
    clang_analyzer_dumpi(*(&x1 + 1));  // Unknown
    clang_analyzer_dumpf(*(&x1 + 1));  // Unknown
    clang_analyzer_dumpip(&x1 + 1);    // &Element{x1,1 S64b,int}
    clang_analyzer_dumpfp(&x1 + 1);    // &Element{x1,1 S64b,float}
  
    f(&x1 + 1);
    // f(&x2 + 1);
    // f(&x3 + 1);
  }

Only lines 8-9 have changed. But IMO, in a bad way.
We should have just `(conj_$1{float, LC2, S790, #1})` there, because the object you read from that location is of type `float`.
Reading an `int` and casting it to `float` means a different thing.

Before the patch - saying `Unknown`, it was not accurate, but at least correct.


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

https://reviews.llvm.org/D95799



More information about the cfe-commits mailing list