From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/PCH/cxx_exprs.h | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 clang/test/PCH/cxx_exprs.h (limited to 'clang/test/PCH/cxx_exprs.h') diff --git a/clang/test/PCH/cxx_exprs.h b/clang/test/PCH/cxx_exprs.h new file mode 100644 index 0000000..67ab4a6 --- /dev/null +++ b/clang/test/PCH/cxx_exprs.h @@ -0,0 +1,83 @@ +// Header for PCH test cxx_exprs.cpp + + +// CXXStaticCastExpr +typedef __typeof__(static_cast(0)) static_cast_result; + +// CXXDynamicCastExpr +struct Base { Base(int); virtual void f(int x = 492); ~Base(); }; +struct Derived : Base { Derived(); void g(); }; +Base *base_ptr; +typedef __typeof__(dynamic_cast(base_ptr)) dynamic_cast_result; + +// CXXReinterpretCastExpr +typedef __typeof__(reinterpret_cast(0)) reinterpret_cast_result; + +// CXXConstCastExpr +const char *const_char_ptr_value; +typedef __typeof__(const_cast(const_char_ptr_value)) const_cast_result; + +// CXXFunctionalCastExpr +int int_value; +typedef __typeof__(double(int_value)) functional_cast_result; + +// CXXBoolLiteralExpr +typedef __typeof__(true) bool_literal_result; +const bool true_value = true; +const bool false_value = false; + +// CXXNullPtrLiteralExpr +typedef __typeof__(nullptr) cxx_null_ptr_result; + +void foo(Derived *P) { + // CXXMemberCallExpr + P->f(12); +} + + +// FIXME: This is a hack until works completely. +namespace std { + class type_info {}; +} + +// CXXTypeidExpr - Both expr and type forms. +typedef __typeof__(typeid(int))* typeid_result1; +typedef __typeof__(typeid(2))* typeid_result2; + +Derived foo(); + +Derived::Derived() : Base(4) { +} + +void Derived::g() { + // CXXThisExpr + f(2); // Implicit + this->f(1); // Explicit + + // CXXThrowExpr + throw; + throw 42; + + // CXXDefaultArgExpr + f(); + + const Derived &X = foo(); + + // FIXME: How do I make a CXXBindReferenceExpr, CXXConstructExpr? + + int A = int(0.5); // CXXFunctionalCastExpr + A = int(); // CXXZeroInitValueExpr + + Base *b = new Base(4); // CXXNewExpr + delete b; // CXXDeleteExpr +} + + +// FIXME: The comment on CXXTemporaryObjectExpr is broken, this doesn't make +// one. +struct CtorStruct { CtorStruct(int, float); }; + +CtorStruct create_CtorStruct() { + return CtorStruct(1, 3.14f); // CXXTemporaryObjectExpr +}; + -- cgit v1.2.3