History log of /external/llvm/include/llvm/Support/Casting.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
0711d46a72580a943d60a770776a22aeb494e66c 21-Feb-2013 David Blaikie <dblaikie@gmail.com> 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
/external/llvm/include/llvm/Support/Casting.h
8b8fa7b2f403ae2f342413239c4151e075022c97 12-Oct-2012 Sean Silva <silvas@purdue.edu> Casting.h: Automatically handle isa<Base>(Derived).

Additionally, all such cases are handled with no dynamic check.

All `classof()` of the form

class Foo {
[...]
static bool classof(const Bar *) { return true; }
[...]
}

where Foo is an ancestor of Bar are no longer necessary.
Don't write them!

Note: The exact test is `is_base_of<Foo, Bar>`, which is non-strict, so
that Foo is considered an ancestor of itself.

This leads to the following rule of thumb for LLVM-style RTTI:

The argument type of `classof()` should be a strict ancestor.

For more information about implementing LLVM-style RTTI, see
docs/HowToSetUpLLVMStyleRTTI.rst

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165765 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
f5091b476c46333ecfcf095cd2e422e9748e9546 22-Sep-2012 Jordan Rose <jordan_rose@apple.com> Casting: assert that pointer arguments to isa<> are non-null.

This silences several analyzer warnings within LLVM, and provides a slightly
nicer crash experience when someone calls isa<>, cast<>, or dyn_cast<> with
a null pointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164439 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
21c60904ce6b937cb0c8744375e9c1a95fe0e495 21-May-2011 Eli Friedman <eli.friedman@gmail.com> PR7952: Make isa<> use the same logic as cast<>, so that they both work
consistently.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131803 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
5fc25cccff3cdbfd34d08b9c1233f9af1879018c 09-Apr-2011 Chris Lattner <sabre@nondot.org> fix doc comment bug, noticed by Jochen


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129186 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
3fde69c0f1d2ccfcc0847cebffb3b9805bef8a06 18-Sep-2010 Gabor Greif <ggreif@gmail.com> restrict dyn_cast_or_null to pointer types, just like cast_or_null; re-commit of r114279, backed out in r114280

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114282 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
d299ab166958b481aa753c809615110fc295cd96 18-Sep-2010 Gabor Greif <ggreif@gmail.com> back out r114279 as some darwin buildbots get errors compiling clang:
svn merge -c -114279 llvm/include/llvm/Support/Casting.h

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114280 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
ce31f40295a0cd42f5df32f6295cf334a3a6df76 18-Sep-2010 Gabor Greif <ggreif@gmail.com> restrict dyn_cast_or_null to pointer types, just like cast_or_null

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114279 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
c4fd9afaf959309f9e522aae8facf936aaaf9ee4 20-Jul-2010 Gabor Greif <ggreif@gmail.com> remove testing cruft, this can be found in unittests/Support/Casting.cpp now

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108868 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
0179e977234fef45b1877eb93a3c7565cdd1862d 30-Mar-2010 Douglas Gregor <dgregor@apple.com> Switch isa_impl from a function template to a class template with a
static inline member function doit(). This enables the use of partial
specialization to override the last stage of the "isa" check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99898 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
3a3134ab12f3aa65f9791f702a73f6d0b2af423f 08-Feb-2010 Chris Lattner <sabre@nondot.org> use a c-style cast instead of reinterpret-cast, as sometimes the
cast needs to adjust for a vtable pointer when going from base to
derived type (when the base doesn't have a vtable but the
derived type does).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95585 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
0ff129f061233b724abe22fe048f06bcb06cd308 23-Dec-2009 David Greene <greened@obbligato.org> Convert debug messages to use dbgs(). Generally this means
s/errs/dbgs/g except for certain special cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92016 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
103289e9383ad1eb66caf28c9b166aebce963a35 23-Aug-2009 Chris Lattner <sabre@nondot.org> convert LoopInfo.h and GraphWriter.h to use raw_ostream


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79836 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
9a0b165cb58cb5cf49cb3a143c302029f389acb2 14-Aug-2009 Argyrios Kyrtzidis <akyrtzi@gmail.com> Revert r78424.

In order for the changes in r78424 to work properly, cast_retty<X,Y> should return an object instead of a reference, and it's not clear that this approach has real advantages.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79023 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
8b6d86df062f9402c0cde66eb6c7013afb414285 08-Aug-2009 Argyrios Kyrtzidis <akyrtzi@gmail.com> Modifications to dyn_cast/cast to make them work for objects too, instead of only pointers.

The use case is if you have a wrapper class:

class Base {
void *Ptr;
public:
Base() : Ptr(0) { }
operator bool() const { return Ptr; }
.....
}

and sub-wrappers that have exactly the same size:

class Sub : public Base {
public:
....
static bool classof(const Base*);
}

and in the code you would do:

void f(Base b) {
Sub sub = dyn_cast<Sub>(b);
if (sub) {
....
}
}



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78424 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
2cd91804ec4d631cc432dac2828d8ee0b1a3390f 23-Nov-2008 Scott Michel <scottm@aero.org> Roll back rev 59890, since Chris says this can never happen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59914 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
bab6436b1726a2db21ab1e024540e98c02a5a009 23-Nov-2008 Scott Michel <scottm@aero.org> Check for NULL before traversing the isa<> type hierarchy checking with a
NULL-based reference.

Note: Encountered this a few times on Tiger + gcc 4.0.1. Might just be a
platform-specific compiler issue, but it's good defensive programming in any
case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59890 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
e4706a0b51cbb6ba74844dd70a51a5fea0d2c336 07-Jul-2008 Dan Gohman <gohman@apple.com> Remove uses of "llvm/Support/Debug.h" from LLVM include files, which
all happened be unnecessary.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53182 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
917365bef1cfb8493558b76f8e6ceb1e76eba2c5 16-Apr-2008 Gabor Greif <ggreif@gmail.com> merge of r49785 (from branches/ggreif/use-diet): pass V to dyn_cast by const reference, this avoids copy-constructing and destructing all the time. especially important if these constructors are not accessible

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49787 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
7ed47a13356daed2a34cd2209a31f92552e3bdd8 29-Dec-2007 Chris Lattner <sabre@nondot.org> Don't attribute in file headers anymore. See llvmdev for the
discussion of this change. Boy are my fingers tired. ;-)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45411 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
e81561909d128c6e2d8033cb5465a49b2596b26a 07-Dec-2006 Bill Wendling <isanbard@gmail.com> Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32298 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
52883e7a9a637c0d6dea091917090a8ac63e7736 17-Nov-2006 Bill Wendling <isanbard@gmail.com> Used llvm_ostream instead of std::ostream objects. This will reduce use
of the icky <iostream> class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31818 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
c7365a9ec96ff434d93d0d8052812283b33e537d 13-May-2006 Reid Spencer <rspencer@reidspencer.com> Add a #include <cassert> for situations where Casting.h is used standalone.
Patch contributed by Vladimir Prus.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28280 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
63b3afa98460ce38a1c48d3c44ef6edfdaf37b77 21-Apr-2005 Misha Brukman <brukman+llvm@gmail.com> Remove trailing whitespace


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21411 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
551ccae044b0ff658fe629dd67edd5ffe75d10e8 02-Sep-2004 Reid Spencer <rspencer@reidspencer.com> Changes For Bug 352
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16137 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
8b70b78ba489b090d9866e6a4084ab1e8613b527 16-Nov-2003 Chris Lattner <sabre@nondot.org> Fixes for PR114: Thanks to Reid Spencer!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10029 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
d0fde30ce850b78371fd1386338350591f9ff494 11-Nov-2003 Brian Gaeke <gaeke@uiuc.edu> Put all LLVM code into the llvm namespace, as per bug 109.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9903 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
b2109ce97881269a610fa4afbcbca350e975174d 20-Oct-2003 John Criswell <criswell@uiuc.edu> Added LLVM notice.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9300 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
48486893f46d2e12e926682a3ecb908716bc66c4 30-Sep-2003 Chris Lattner <sabre@nondot.org> Standardize header file comments


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8782 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
776f776838d6e2f83d899bc99452dc83779c341b 10-Sep-2003 Chris Lattner <sabre@nondot.org> Fix spello


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8432 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
88d942d8983aadecae477fee523c23312d194515 27-Aug-2003 Misha Brukman <brukman+llvm@gmail.com> Spell `incompatible' correctly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8163 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
7a73b80b9052136c8cd2234eb3433a07df7cf38e 30-Jun-2003 John Criswell <criswell@uiuc.edu> Merged in autoconf branch. This provides configuration via the autoconf
system.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7014 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
1ff1da7ac9bff43ba24445ff30ba2fd79bd95cd7 29-May-2003 Chris Lattner <sabre@nondot.org> dyn_cast_or_null should work just the same as dyn_cast does


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6394 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
ea0f49e52436272c65b52fe1e83f5009aa191a21 23-Apr-2003 Chris Lattner <sabre@nondot.org> Allow dyn_cast to operate on things that aren't OBVIOUSLY a pointer type.
These things can be converted to a pointer, like ilist_iterators


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5861 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
5a6d63ae29512d654c8c697f42f32f97b9dc010b 24-Jul-2002 Chris Lattner <sabre@nondot.org> Add missing typename's that GCC3.1 is whining about.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3051 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
7e70829632f82de15db187845666aaca6e04b792 25-Jun-2002 Chris Lattner <sabre@nondot.org> MEGAPATCH checkin.

For details, See: docs/2002-06-25-MegaPatchInfo.txt


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2779 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/include/llvm/Support/Casting.h
589df88ba03a81b2b3dc9d084c191a3a74724ecd 08-Apr-2002 Chris Lattner <sabre@nondot.org> Pull casting operators out of Value.h


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