]> granicus.if.org Git - clang/commitdiff
fix a fixme, don't leak the expr on error.
authorChris Lattner <sabre@nondot.org>
Sat, 24 Jan 2009 19:49:13 +0000 (19:49 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 24 Jan 2009 19:49:13 +0000 (19:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62927 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp

index 9a4977d09b9a78a4ea78199888201daad6781b20..fa4c9d620af49a4eef46db2c741dcf9e9938d44a 100644 (file)
@@ -1049,18 +1049,23 @@ Sema::ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
   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,