[cfe-commits] r44455 - in /cfe/trunk: CodeGen/CGExpr.cpp test/CodeGen/typedef.c

Chris Lattner sabre at nondot.org
Fri Nov 30 10:02:20 PST 2007


Author: lattner
Date: Fri Nov 30 12:02:19 2007
New Revision: 44455

URL: http://llvm.org/viewvc/llvm-project?rev=44455&view=rev
Log:
fix a bug handling typedefs in member expr codegen.  Patch 
by Seo Sanghyeon

Added:
    cfe/trunk/test/CodeGen/typedef.c
Modified:
    cfe/trunk/CodeGen/CGExpr.cpp

Modified: cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExpr.cpp?rev=44455&r1=44454&r2=44455&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Fri Nov 30 12:02:19 2007
@@ -393,10 +393,11 @@
     BaseValue = BaseLV.getAddress();
     
     if (E->isArrow()) {
-      QualType PTy = cast<PointerType>(BaseExpr->getType())->getPointeeType();
+      QualType Ty = BaseExpr->getType();
+      Ty = cast<PointerType>(Ty.getCanonicalType())->getPointeeType();
       BaseValue =  
         Builder.CreateBitCast(BaseValue, 
-                              llvm::PointerType::get(ConvertType(PTy)), "tmp");
+                              llvm::PointerType::get(ConvertType(Ty)), "tmp");
     }
   } else
     BaseValue = EmitScalarExpr(BaseExpr);

Added: cfe/trunk/test/CodeGen/typedef.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/typedef.c?rev=44455&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/typedef.c (added)
+++ cfe/trunk/test/CodeGen/typedef.c Fri Nov 30 12:02:19 2007
@@ -0,0 +1,8 @@
+// RUN: clang -emit-llvm %s
+
+typedef struct { int i; } Value;
+typedef Value *PValue;
+
+int get_value(PValue v) {
+  return v->i;
+}





More information about the cfe-commits mailing list