]> granicus.if.org Git - clang/commitdiff
Implement transfer function logic for alignof operator (types).
authorTed Kremenek <kremenek@apple.com>
Sat, 15 Mar 2008 03:13:20 +0000 (03:13 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 15 Mar 2008 03:13:20 +0000 (03:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48386 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRExprEngine.cpp

index a32999eb513f8f635d59920cc50f70a72df12c67..5d6c7122c1bb25649d04e1a84739da429a6ddc55 100644 (file)
@@ -729,27 +729,27 @@ void GRExprEngine::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr* Ex,
                                               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,