[cfe-commits] r48386 - /cfe/trunk/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Fri Mar 14 20:13:21 PDT 2008


Author: kremenek
Date: Fri Mar 14 22:13:20 2008
New Revision: 48386

URL: http://llvm.org/viewvc/llvm-project?rev=48386&view=rev
Log:
Implement transfer function logic for alignof operator (types).

Modified:
    cfe/trunk/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRExprEngine.cpp?rev=48386&r1=48385&r2=48386&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/Analysis/GRExprEngine.cpp Fri Mar 14 22:13:20 2008
@@ -729,27 +729,27 @@
                                               NodeTy* Pred,
                                               NodeSet& Dst) {
 
-  assert (Ex->isSizeOf() && "FIXME: AlignOf(Expr) not yet implemented.");
-  
-  // 6.5.3.4 sizeof: "The result type is an integer."
-  
   QualType T = Ex->getArgumentType();
-
-
-  // FIXME: Add support for VLAs.
-  if (!T.getTypePtr()->isConstantSizeType())
-    return;
-  
+  uint64_t amt;  
   
-  uint64_t size = 1;  // Handle sizeof(void)
-  
-  if (T != getContext().VoidTy)
-    size = getContext().getTypeSize(T) / 8;
+  if (Ex->isSizeOf()) {
+
+    // FIXME: Add support for VLAs.
+    if (!T.getTypePtr()->isConstantSizeType())
+      return;
+    
+    amt = 1;  // Handle sizeof(void)
+    
+    if (T != getContext().VoidTy)
+      amt = getContext().getTypeSize(T) / 8;
+    
+  }
+  else  // Get alignment of the type.
+    amt = getContext().getTypeAlign(T);
   
   Nodify(Dst, Ex, Pred,
          SetRVal(GetState(Pred), Ex,
-                  NonLVal::MakeVal(BasicVals, size, Ex->getType())));
-  
+                 NonLVal::MakeVal(BasicVals, amt, Ex->getType())));  
 }
 
 void GRExprEngine::VisitDeref(UnaryOperator* U, NodeTy* Pred,





More information about the cfe-commits mailing list