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)
commit0711d46a72580a943d60a770776a22aeb494e66c
tree6ea56e819506b4f06ed6a59c2bedbb41846e9bc9
parente18bce5317ff9f64b3c02418f28c6d383d88b294
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175819 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/Casting.h