]> granicus.if.org Git - clang/commitdiff
Added transfer function support for sizeof(void)
authorTed Kremenek <kremenek@apple.com>
Thu, 21 Feb 2008 18:15:29 +0000 (18:15 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 21 Feb 2008 18:15:29 +0000 (18:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47443 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRExprEngine.cpp

index fb6dc80e0dbd9a844d395cbad4f530bf2ef1cc39..1ca37615d81bf08ae98f59a82a5cbd61e050595c 100644 (file)
@@ -528,18 +528,22 @@ void GRExprEngine::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr* Ex,
   QualType T = Ex->getArgumentType();
   
   // FIXME: Implement alignof
-  // FIXME: Add support for sizeof(void)
-  // FIXME: Add support for VLAs.
 
+  // FIXME: Add support for VLAs.
   if (!T.getTypePtr()->isConstantSizeType())
     return;
   
-  SourceLocation Loc = Ex->getExprLoc();
-  uint64_t size = getContext().getTypeSize(T, Loc) / 8;
+  
+  uint64_t size = 1;  // Handle sizeof(void)
+  
+  if (T != getContext().VoidTy) {
+    SourceLocation Loc = Ex->getExprLoc();
+    size = getContext().getTypeSize(T, Loc) / 8;
+  }
   
   Nodify(Dst, Ex, Pred,
          SetRVal(Pred->getState(), Ex,
-                  NonLVal::MakeVal(ValMgr, size, Ex->getType(), Loc)));
+                  NonLVal::MakeVal(ValMgr, size, Ex->getType())));
   
 }