mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-12 07:21:56 +00:00
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
This commit is contained in:
parent
43ef3fbae1
commit
c4fd9afaf9
@ -236,73 +236,6 @@ inline typename cast_retty<X, Y>::ret_type dyn_cast_or_null(const Y &Val) {
|
||||
return (Val && isa<X>(Val)) ? cast<X, Y>(Val) : 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_CAST_OPERATORS
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
struct bar {
|
||||
bar() {}
|
||||
private:
|
||||
bar(const bar &);
|
||||
};
|
||||
struct foo {
|
||||
void ext() const;
|
||||
/* static bool classof(const bar *X) {
|
||||
cerr << "Classof: " << X << "\n";
|
||||
return true;
|
||||
}*/
|
||||
};
|
||||
|
||||
template <> struct isa_impl<foo,bar> {
|
||||
static inline bool doit(const bar &Val) {
|
||||
dbgs() << "Classof: " << &Val << "\n";
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bar *fub();
|
||||
void test(bar &B1, const bar *B2) {
|
||||
// test various configurations of const
|
||||
const bar &B3 = B1;
|
||||
const bar *const B4 = B2;
|
||||
|
||||
// test isa
|
||||
if (!isa<foo>(B1)) return;
|
||||
if (!isa<foo>(B2)) return;
|
||||
if (!isa<foo>(B3)) return;
|
||||
if (!isa<foo>(B4)) return;
|
||||
|
||||
// test cast
|
||||
foo &F1 = cast<foo>(B1);
|
||||
const foo *F3 = cast<foo>(B2);
|
||||
const foo *F4 = cast<foo>(B2);
|
||||
const foo &F8 = cast<foo>(B3);
|
||||
const foo *F9 = cast<foo>(B4);
|
||||
foo *F10 = cast<foo>(fub());
|
||||
|
||||
// test cast_or_null
|
||||
const foo *F11 = cast_or_null<foo>(B2);
|
||||
const foo *F12 = cast_or_null<foo>(B2);
|
||||
const foo *F13 = cast_or_null<foo>(B4);
|
||||
const foo *F14 = cast_or_null<foo>(fub()); // Shouldn't print.
|
||||
|
||||
// These lines are errors...
|
||||
//foo *F20 = cast<foo>(B2); // Yields const foo*
|
||||
//foo &F21 = cast<foo>(B3); // Yields const foo&
|
||||
//foo *F22 = cast<foo>(B4); // Yields const foo*
|
||||
//foo &F23 = cast_or_null<foo>(B1);
|
||||
//const foo &F24 = cast_or_null<foo>(B3);
|
||||
}
|
||||
|
||||
bar *fub() { return 0; }
|
||||
void main() {
|
||||
bar B;
|
||||
test(B, &B);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user