Implement transfer function logic for alignof operator (types).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48386 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp
index a32999e..5d6c712 100644
--- a/Analysis/GRExprEngine.cpp
+++ b/Analysis/GRExprEngine.cpp
@@ -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();
+  uint64_t amt;  
+  
+  if (Ex->isSizeOf()) {
 
-
-  // FIXME: Add support for VLAs.
-  if (!T.getTypePtr()->isConstantSizeType())
-    return;
-  
-  
-  uint64_t size = 1;  // Handle sizeof(void)
-  
-  if (T != getContext().VoidTy)
-    size = getContext().getTypeSize(T) / 8;
+    // 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,