[analyzer] Improve CastToStruct checker so it can also detect widening casts of struc...
authorDaniel Marjamaki <daniel.marjamaki@evidente.se>
Mon, 26 Sep 2016 15:17:18 +0000 (15:17 +0000)
committerDaniel Marjamaki <daniel.marjamaki@evidente.se>
Mon, 26 Sep 2016 15:17:18 +0000 (15:17 +0000)
commit13264ebea47bdd60372af22262d782b6e6898167
treec8fd2e483dc2d109234c2892e880b72d08127de1
parent3f2cde91d8b66d2d086fa08ee874535ba3b6a4ec
[analyzer] Improve CastToStruct checker so it can also detect widening casts of struct data

Example:

struct AB {
  int A;
  int B;
};

struct ABC {
  int A;
  int B;
  int C;
};

void f() {
  struct AB Data;
  struct ABC *P = (struct ABC *)&Data;
}

Differential Revision: https://reviews.llvm.org/D23508

llvm-svn: 282411
clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
clang/test/Analysis/cast-to-struct.cpp [new file with mode: 0644]
clang/test/Analysis/casts.c