[cfe-commits] r85435 - /cfe/trunk/lib/AST/ExprConstant.cpp

Mike Stump mrs at apple.com
Wed Oct 28 14:22:24 PDT 2009


Author: mrs
Date: Wed Oct 28 16:22:24 2009
New Revision: 85435

URL: http://llvm.org/viewvc/llvm-project?rev=85435&view=rev
Log:
Refine __builtin_object_size.  Don't try and get a size for things
that don't have sizes.

Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=85435&r1=85434&r2=85435&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Oct 28 16:22:24 2009
@@ -943,13 +943,18 @@
       if (const Expr *LVBase = Base.Val.getLValueBase())
         if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(LVBase)) {
           if (const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
-            uint64_t Size = Info.Ctx.getTypeSize(VD->getType()) / 8;
-            uint64_t Offset = Base.Val.getLValueOffset();
-            if (Offset <= Size)
-              Size -= Base.Val.getLValueOffset();
-            else
-              Size = 0;
-            return Success(Size, E);
+            if (!VD->getType()->isIncompleteType()
+                && VD->getType()->isObjectType()
+                && !VD->getType()->isVariablyModifiedType()
+                && !VD->getType()->isDependentType()) {
+              uint64_t Size = Info.Ctx.getTypeSize(VD->getType()) / 8;
+              uint64_t Offset = Base.Val.getLValueOffset();
+              if (Offset <= Size)
+                Size -= Base.Val.getLValueOffset();
+              else
+                Size = 0;
+              return Success(Size, E);
+            }
           }
         }
 





More information about the cfe-commits mailing list