[cfe-commits] r62927 - /cfe/trunk/lib/Sema/SemaExpr.cpp

Chris Lattner sabre at nondot.org
Sat Jan 24 11:49:14 PST 2009


Author: lattner
Date: Sat Jan 24 13:49:13 2009
New Revision: 62927

URL: http://llvm.org/viewvc/llvm-project?rev=62927&view=rev
Log:
fix a fixme, don't leak the expr on error.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=62927&r1=62926&r2=62927&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Jan 24 13:49:13 2009
@@ -1049,18 +1049,23 @@
   if (isType) {
     ArgTy = QualType::getFromOpaquePtr(TyOrEx);
     Range = ArgRange;
+    
+    // Verify that the operand is valid.
+    if (CheckSizeOfAlignOfOperand(ArgTy, OpLoc, Range, isSizeof))
+      return ExprError();
   } else {
     // Get the end location.
     Expr *ArgEx = (Expr *)TyOrEx;
     Range = ArgEx->getSourceRange();
     ArgTy = ArgEx->getType();
+    
+    // Verify that the operand is valid.
+    if (CheckSizeOfAlignOfOperand(ArgTy, OpLoc, Range, isSizeof)) {
+      DeleteExpr(ArgEx);
+      return ExprError();
+    }
   }
 
-  // Verify that the operand is valid.
-  // FIXME: This might leak the expression.
-  if (CheckSizeOfAlignOfOperand(ArgTy, OpLoc, Range, isSizeof))
-    return ExprError();
-
   // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
   return Owned(new (Context) SizeOfAlignOfExpr(isSizeof, isType, TyOrEx,
                                                Context.getSizeType(), OpLoc,





More information about the cfe-commits mailing list