On Mar 21, 2013, at 6:28 PM, Reid Kleckner <[email protected]> wrote:
> - implement John's comments.
+ llvm::Constant *getZero() {
+ return llvm::ConstantInt::get(CGM.PtrDiffTy, 0);
+ }
+
+ llvm::Constant *getAllOnes() {
+ return llvm::Constant::getAllOnesValue(CGM.PtrDiffTy);
+ }
Please encode the type into these in some way.
class ItaniumCXXABI : public CodeGen::CGCXXABI {
-private:
- llvm::IntegerType *PtrDiffTy;
Please do this in a separate patch.
+// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32
| FileCheck %s
+
+struct POD {
+ int a;
+ int b;
+};
+
+void podMemPtrs() {
+ int POD::*memptr;
+ memptr = &POD::a;
+ // CHECK: store i32 0,
+ memptr = &POD::b;
+ // CHECK: store i32 4,
+ if (memptr)
+ memptr = 0;
+ // Null is -1.
+ // CHECK: icmp ne i32 %{{.*}}, -1
+ // CHECK: store i32 -1,
+}
All these tests are pretty inadequate; you could be accidentally doing
a lot of stuff besides the stores. You should basically be testing the entire
function body, including the define line. This will also let you effectively
test that you're generating the right IR type, which will be important when
you start generating different IR types for different cases.
You're also not testing the generation of a null value.
John.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits