__builtin_object_size refinements.  When we run out of object, be sure
to clamp at 0 bytes left.  WIP.

llvm-svn: 85157
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f1a446e..9992b69 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -884,7 +884,11 @@
         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;
-            Size -= Base.Val.getLValueOffset();
+            uint64_t Offset = Base.Val.getLValueOffset();
+            if (Offset <= Size)
+              Size -= Base.Val.getLValueOffset();
+            else
+              Size = 0;
             return Success(Size, E);
           }
         }