diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-07-25 18:17:45 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-07-25 18:17:45 +0000 |
commit | b412e174db3846ec5aa83ecb8ead7fb54829237c (patch) | |
tree | c539a513916e5d7fb983ef42304a1386fe1fbb32 /clang/lib/Sema | |
parent | 5b11d49a7c2ea35903004198dd5570afe6ab0529 (diff) | |
download | bcm5719-llvm-b412e174db3846ec5aa83ecb8ead7fb54829237c.tar.gz bcm5719-llvm-b412e174db3846ec5aa83ecb8ead7fb54829237c.zip |
Remove the vast majority of the Destroy methods from the AST library,
since we aren't going to be calling them ever.
llvm-svn: 109377
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaAttr.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 28 | ||||
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 10 |
15 files changed, 15 insertions, 83 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 33a111f395c..815eba051f7 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -205,10 +205,8 @@ ImplicitCastExpr::ResultCategory Sema::CastCategory(Expr *E) { } void Sema::DeleteExpr(ExprTy *E) { - if (E) static_cast<Expr*>(E)->Destroy(Context); } void Sema::DeleteStmt(StmtTy *S) { - if (S) static_cast<Stmt*>(S)->Destroy(Context); } /// ActOnEndOfTranslationUnit - This is called at the very end of the diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index 540ee7a2af1..13a0c59bbdb 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -197,7 +197,6 @@ void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name, !(Val == 0 || Val.isPowerOf2()) || Val.getZExtValue() > 16) { Diag(PragmaLoc, diag::warn_pragma_pack_invalid_alignment); - Alignment->Destroy(Context); return; // Ignore } diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index e376dfab57c..cf22fcf5836 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -530,7 +530,6 @@ Sema::SemaBuiltinAtomicOverloaded(OwningExprResult TheCallResult) { if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) { Arg = ICE->getSubExpr(); ICE->setSubExpr(0); - ICE->Destroy(Context); TheCall->setArg(i+1, Arg); } @@ -736,7 +735,6 @@ bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) { assert(Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) && "promotion from float to double is the only expected cast here"); Cast->setSubExpr(0); - Cast->Destroy(Context); TheCall->setArg(NumArgs-1, CastArg); OrigArg = CastArg; } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7360805f60f..11e1ffe107a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4731,7 +4731,6 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg, if (!MD->isInvalidDecl()) DiagnoseUnusedParameters(MD->param_begin(), MD->param_end()); } else { - Body->Destroy(Context); return DeclPtrTy(); } @@ -4755,8 +4754,7 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg, // the function body so that they aren't leaked and that the AST is well // formed. if (Body == 0) { - // The whole function wasn't parsed correctly, just delete this. - L->Destroy(Context); + // The whole function wasn't parsed correctly. continue; } @@ -6576,7 +6574,6 @@ Sema::DeclPtrTy Sema::ActOnEnumConstant(Scope *S, DeclPtrTy theEnumDecl, else Diag(IdLoc, diag::err_redefinition) << Id; Diag(PrevDecl->getLocation(), diag::note_previous_definition); - if (Val) Val->Destroy(Context); return DeclPtrTy(); } } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 254f7c3b58b..d732746530f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -412,8 +412,6 @@ void Sema::CheckCXXDefaultArguments(FunctionDecl *FD) { for (p = 0; p <= LastMissingDefaultArg; ++p) { ParmVarDecl *Param = FD->getParamDecl(p); if (Param->hasDefaultArg()) { - if (!Param->hasUnparsedDefaultArg()) - Param->getDefaultArg()->Destroy(Context); Param->setDefaultArg(0); } } @@ -4584,10 +4582,8 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, ArrayTy->getElementType(), move(To), move(From), CopyingBaseSubobject, Depth+1); - if (Copy.isInvalid()) { - InitStmt->Destroy(S.Context); + if (Copy.isInvalid()) return S.StmtError(); - } // Construct the loop that copies all elements of this array. return S.ActOnForStmt(Loc, Loc, S.Owned(InitStmt), diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 5f2f37eb0b0..8f3ff5ddd00 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -280,7 +280,6 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context); CheckForwardProtocolDeclarationForCircularDependency( ProtocolName, ProtocolLoc, PDecl->getLocation(), PList); - PList.Destroy(Context); // Make sure the cached decl gets a valid start location. PDecl->setLocation(AtProtoInterfaceLoc); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5281f3ff793..2816c4a6139 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -553,7 +553,6 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc, if (BaseObject) { // BaseObject is an anonymous struct/union variable (and is, // therefore, not part of another non-anonymous record). - if (BaseObjectExpr) BaseObjectExpr->Destroy(Context); MarkDeclarationReferenced(Loc, BaseObject); BaseObjectExpr = new (Context) DeclRefExpr(BaseObject,BaseObject->getType(), SourceLocation()); @@ -3582,9 +3581,6 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc, SourceRange(Args[0]->getLocStart(), Args[NumArgs-1]->getLocEnd())); - for (unsigned I = 0; I != NumArgs; ++I) - Args[I]->Destroy(Context); - NumArgs = 0; } @@ -7042,11 +7038,9 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, if (OC.isBrackets) { // Offset of an array sub-field. TODO: Should we allow vector elements? const ArrayType *AT = Context.getAsArrayType(Res->getType()); - if (!AT) { - Res->Destroy(Context); + if (!AT) return ExprError(Diag(OC.LocEnd, diag::err_offsetof_array_type) << Res->getType()); - } // FIXME: C++: Verify that operator[] isn't overloaded. @@ -7068,11 +7062,9 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, } const RecordType *RC = Res->getType()->getAs<RecordType>(); - if (!RC) { - Res->Destroy(Context); + if (!RC) return ExprError(Diag(OC.LocEnd, diag::err_offsetof_record_type) << Res->getType()); - } // Get the decl corresponding to this. RecordDecl *RD = RC->getDecl(); @@ -7986,10 +7978,8 @@ Sema::OwningExprResult Sema::ActOnBooleanCondition(Scope *S, SourceLocation Loc, if (!Sub) return ExprError(); - if (CheckBooleanCondition(Sub, Loc)) { - Sub->Destroy(Context); + if (CheckBooleanCondition(Sub, Loc)) return ExprError(); - } return Owned(Sub); } diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 82c461128dd..0fe46ed607b 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1491,10 +1491,8 @@ Action::OwningExprResult Sema::CheckConditionVariable(VarDecl *ConditionVar, Expr *Condition = DeclRefExpr::Create(Context, 0, SourceRange(), ConditionVar, ConditionVar->getLocation(), ConditionVar->getType().getNonReferenceType()); - if (ConvertToBoolean && CheckBooleanCondition(Condition, StmtLoc)) { - Condition->Destroy(Context); + if (ConvertToBoolean && CheckBooleanCondition(Condition, StmtLoc)) return ExprError(); - } return Owned(Condition); } diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index b0f9b2cd246..4f2567eb553 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -55,9 +55,6 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs, // Get the locations of the string tokens. StrLocs.append(S->tokloc_begin(), S->tokloc_end()); - - // Free the temporary string. - S->Destroy(Context); } // Create the aggregate string with the appropriate content and location @@ -762,11 +759,8 @@ Sema::OwningExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, unsigned NumArgs = ArgsIn.size(); Expr **Args = reinterpret_cast<Expr **>(ArgsIn.release()); if (CheckMessageArgumentTypes(Args, NumArgs, Sel, Method, true, - LBracLoc, RBracLoc, ReturnType)) { - for (unsigned I = 0; I != NumArgs; ++I) - Args[I]->Destroy(Context); + LBracLoc, RBracLoc, ReturnType)) return ExprError(); - } // Construct the appropriate ObjCMessageExpr. Expr *Result; diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 9f02dae9f8d..1a22e2876b2 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -6407,14 +6407,6 @@ void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, PartialOverloading); } -static Sema::OwningExprResult Destroy(Sema &SemaRef, Expr *Fn, - Expr **Args, unsigned NumArgs) { - Fn->Destroy(SemaRef.Context); - for (unsigned Arg = 0; Arg < NumArgs; ++Arg) - Args[Arg]->Destroy(SemaRef.Context); - return SemaRef.ExprError(); -} - /// Attempts to recover from a call where no functions were found. /// /// Returns true if new candidates were found. @@ -6442,7 +6434,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(), Sema::LookupOrdinaryName); if (SemaRef.DiagnoseEmptyLookup(S, SS, R, Sema::CTC_Expression)) - return Destroy(SemaRef, Fn, Args, NumArgs); + return SemaRef.ExprError(); assert(!R.empty() && "lookup results empty despite recovery"); @@ -6457,9 +6449,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, NewFn = SemaRef.BuildDeclarationNameExpr(SS, R, false); if (NewFn.isInvalid()) - return Destroy(SemaRef, Fn, Args, NumArgs); - - Fn->Destroy(SemaRef.Context); + return SemaRef.ExprError(); // This shouldn't cause an infinite loop because we're giving it // an expression with non-empty lookup results, which should never @@ -6545,11 +6535,7 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, break; } - // Overload resolution failed. Destroy all of the subexpressions and - // return NULL. - Fn->Destroy(Context); - for (unsigned Arg = 0; Arg < NumArgs; ++Arg) - Args[Arg]->Destroy(Context); + // Overload resolution failed. return ExprError(); } @@ -7374,14 +7360,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, break; } - if (Best == CandidateSet.end()) { - // We had an error; delete all of the subexpressions and return - // the error. - Object->Destroy(Context); - for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx) - Args[ArgIdx]->Destroy(Context); + if (Best == CandidateSet.end()) return true; - } if (Best->Function == 0) { // Since there is no function declaration, this is one of the diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 075f6628247..58131daf830 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -458,10 +458,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch, SS->setBody(BodyStmt, SwitchLoc); getSwitchStack().pop_back(); - if (SS->getCond() == 0) { - SS->Destroy(Context); + if (SS->getCond() == 0) return StmtError(); - } Expr *CondExpr = SS->getCond(); Expr *CondExprBeforePromotion = CondExpr; @@ -1086,7 +1084,6 @@ Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { if (CurBlock->ReturnType->isVoidType()) { if (RetValExp) { Diag(ReturnLoc, diag::err_return_block_has_expr); - RetValExp->Destroy(Context); RetValExp = 0; } Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, 0); diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index c8b5338f28c..ea77a189f75 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -1102,7 +1102,6 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, DiagnoseDefaultTemplateArgument(*this, TPC, NewNonTypeParm->getLocation(), NewNonTypeParm->getDefaultArgument()->getSourceRange())) { - NewNonTypeParm->getDefaultArgument()->Destroy(Context); NewNonTypeParm->removeDefaultArgument(); } @@ -3660,7 +3659,6 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, diag::err_default_arg_in_partial_spec) << DefArg->getSourceRange(); NTTP->removeDefaultArgument(); - DefArg->Destroy(Context); } } else { TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(Param); diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 4209fd7a14b..d1503695bc2 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1718,13 +1718,8 @@ TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) { } // Clean up if we had an error. - if (Invalid) { - for (ParamVector::iterator PI = Params.begin(), PE = Params.end(); - PI != PE; ++PI) - if (*PI) - (*PI)->Destroy(SemaRef.Context); + if (Invalid) return NULL; - } TemplateParameterList *InstL = TemplateParameterList::Create(SemaRef.Context, L->getTemplateLoc(), diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 0734e74b17f..d3715aad974 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -672,7 +672,6 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, !ArraySize->getType()->isIntegerType()) { Diag(ArraySize->getLocStart(), diag::err_array_size_non_int) << ArraySize->getType() << ArraySize->getSourceRange(); - ArraySize->Destroy(Context); return QualType(); } llvm::APSInt ConstVal(32); diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 17103c515f8..9920e4e9eab 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -4116,20 +4116,14 @@ TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) { ExceptionDecl->getLocation(), /*FIXME: Inaccurate*/ SourceRange(ExceptionDecl->getLocation())); - if (!Var || Var->isInvalidDecl()) { - if (Var) - Var->Destroy(SemaRef.Context); + if (!Var || Var->isInvalidDecl()) return SemaRef.StmtError(); - } } // Transform the actual exception handler. OwningStmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock()); - if (Handler.isInvalid()) { - if (Var) - Var->Destroy(SemaRef.Context); + if (Handler.isInvalid()) return SemaRef.StmtError(); - } if (!getDerived().AlwaysRebuild() && !Var && |