[cfe-commits] r59791 - /cfe/trunk/lib/Sema/SemaOverload.cpp
Douglas Gregor
doug.gregor at gmail.com
Thu Nov 20 19:04:22 PST 2008
Author: dgregor
Date: Thu Nov 20 21:04:22 2008
New Revision: 59791
URL: http://llvm.org/viewvc/llvm-project?rev=59791&view=rev
Log:
Cleanup memory management in overloading of operator->, slightly
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=59791&r1=59790&r2=59791&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Nov 20 21:04:22 2008
@@ -3205,6 +3205,8 @@
}
}
+ llvm::OwningPtr<Expr> BasePtr(Base);
+
// Perform overload resolution.
OverloadCandidateSet::iterator Best;
switch (BestViableFunction(CandidateSet, Best)) {
@@ -3215,29 +3217,28 @@
case OR_No_Viable_Function:
if (CandidateSet.empty())
Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
- << Base->getType().getAsString() << Base->getSourceRange();
+ << BasePtr->getType().getAsString() << BasePtr->getSourceRange();
else
Diag(OpLoc, diag::err_ovl_no_viable_oper)
- << "operator->" << Base->getSourceRange();
+ << "operator->" << BasePtr->getSourceRange();
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
- delete Base;
return true;
case OR_Ambiguous:
Diag(OpLoc, diag::err_ovl_ambiguous_oper)
<< "operator->"
- << Base->getSourceRange();
+ << BasePtr->getSourceRange();
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
- delete Base;
return true;
}
// Convert the object parameter.
CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
- if (PerformObjectArgumentInitialization(Base, Method)) {
- delete Base;
+ if (PerformObjectArgumentInitialization(Base, Method))
return true;
- }
+
+ // No concerns about early exits now.
+ BasePtr.take();
// Build the operator call.
Expr *FnExpr = new DeclRefExpr(Method, Method->getType(), SourceLocation());
More information about the cfe-commits
mailing list