Limit cast machinery to preserve const and not accept temporaries
authorDavid Blaikie <dblaikie@gmail.com>
Thu, 21 Feb 2013 22:48:34 +0000 (22:48 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Thu, 21 Feb 2013 22:48:34 +0000 (22:48 +0000)
commit65615996b9db7c9a5700277007d71477f3cb745a
tree17428e662c32c24a6deabf3faf3c3bd3cf8655f8
parentcf928cb53f3eb110c12d58081f455ad4ffeb06a7
Limit cast machinery to preserve const and not accept temporaries

After cleaning up the following type hierarchies:
  * TypeLoc: r175462
  * SVal: r175594
  * CFGElement: r175462
  * ProgramPoint: r175812
that all invoked undefined behavior by causing a derived copy construction of a
base object through an invalid cast (thus supporting code that relied on
casting temporaries that were direct base objects) Clang/LLVM is now clean of
casts of temporaries. So here's some fun SFINAE machinery (courtesy of Eli
Friedman, with some porting back from C++11 to LLVM's traits by me) to cause
compile-time failures if llvm::cast & friends are ever passed an rvalue.

This should avoid a repeat of anything even remotely like PR14321/r168124.

Thanks to Jordan Rose for the help with the various Static Analyzer related
hierarchies that needed cleaning up, Eli for the SFINAE, Richard Smith, John
McCall, Ted Kremenek, and Anna Zaks for their input/reviews/patience along the
way.

llvm-svn: 175819
llvm/include/llvm/Support/Casting.h