[cfe-commits] r44529 - in /cfe/trunk: CodeGen/CGExprScalar.cpp test/CodeGen/pointer-arithmetic.c
Seo Sanghyeon
sanxiyn at gmail.com
Sun Dec 2 22:23:43 PST 2007
Author: sanxiyn
Date: Mon Dec 3 00:23:43 2007
New Revision: 44529
URL: http://llvm.org/viewvc/llvm-project?rev=44529&view=rev
Log:
Ignore typedefs in pointer arithmetic codegen.
Added:
cfe/trunk/test/CodeGen/pointer-arithmetic.c
Modified:
cfe/trunk/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprScalar.cpp?rev=44529&r1=44528&r2=44529&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/CodeGen/CGExprScalar.cpp Mon Dec 3 00:23:43 2007
@@ -697,11 +697,11 @@
Value *LHS = Visit(E->getLHS());
Value *RHS = Visit(E->getRHS());
- const PointerType *LHSPtrType = E->getLHS()->getType()->getAsPointerType();
- assert(LHSPtrType == E->getRHS()->getType()->getAsPointerType() &&
- "Can't subtract different pointer types");
+ const QualType LHSType = E->getLHS()->getType().getCanonicalType();
+ const QualType RHSType = E->getRHS()->getType().getCanonicalType();
+ assert(LHSType == RHSType && "Can't subtract different pointer types");
- QualType LHSElementType = LHSPtrType->getPointeeType();
+ QualType LHSElementType = cast<PointerType>(LHSType)->getPointeeType();
uint64_t ElementSize = CGF.getContext().getTypeSize(LHSElementType,
SourceLocation()) / 8;
Added: cfe/trunk/test/CodeGen/pointer-arithmetic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pointer-arithmetic.c?rev=44529&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/pointer-arithmetic.c (added)
+++ cfe/trunk/test/CodeGen/pointer-arithmetic.c Mon Dec 3 00:23:43 2007
@@ -0,0 +1,5 @@
+// RUN: clang -emit-llvm %s
+
+typedef int Int;
+
+int test1(int *a, Int *b) { return a - b; }
More information about the cfe-commits
mailing list