[cfe-commits] r79200 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp utils/ABITest/layout/Makefile
Anders Carlsson
andersca at mac.com
Sun Aug 16 13:29:29 PDT 2009
Author: andersca
Date: Sun Aug 16 15:29:29 2009
New Revision: 79200
URL: http://llvm.org/viewvc/llvm-project?rev=79200&view=rev
Log:
Store the delete operator for delete expressions.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/utils/ABITest/layout/Makefile
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=79200&r1=79199&r2=79200&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Aug 16 15:29:29 2009
@@ -506,10 +506,11 @@
// We don't care about the actual value of this argument.
// FIXME: Should the Sema create the expression and embed it in the syntax
// tree? Or should the consumer just recalculate the value?
- AllocArgs[0] = new (Context) IntegerLiteral(llvm::APInt::getNullValue(
- Context.Target.getPointerWidth(0)),
- Context.getSizeType(),
- SourceLocation());
+ IntegerLiteral Size(llvm::APInt::getNullValue(
+ Context.Target.getPointerWidth(0)),
+ Context.getSizeType(),
+ SourceLocation());
+ AllocArgs[0] = &Size;
std::copy(PlaceArgs, PlaceArgs + NumPlaceArgs, AllocArgs.begin() + 1);
DeclarationName NewName = Context.DeclarationNames.getCXXOperatorName(
@@ -538,9 +539,6 @@
if (NumPlaceArgs > 0)
std::copy(&AllocArgs[1], AllocArgs.end(), PlaceArgs);
- // FIXME: This is leaked on error. But so much is currently in Sema that it's
- // easier to clean it in one go.
- AllocArgs[0]->Destroy(Context);
return false;
}
@@ -696,6 +694,8 @@
// type void."
// DR599 amends "pointer type" to "pointer to object type" in both cases.
+ FunctionDecl *OperatorDelete = 0;
+
Expr *Ex = (Expr *)Operand.get();
if (!Ex->isTypeDependent()) {
QualType Type = Ex->getType();
@@ -718,14 +718,45 @@
Ex->getSourceRange()))
return ExprError();
- // FIXME: Look up the correct operator delete overload and pass a pointer
- // along.
+ // FIXME: This should be shared with the code for finding the delete
+ // operator in ActOnCXXNew.
+ IntegerLiteral Size(llvm::APInt::getNullValue(
+ Context.Target.getPointerWidth(0)),
+ Context.getSizeType(),
+ SourceLocation());
+ ImplicitCastExpr Cast(Context.getPointerType(Context.VoidTy),
+ CastExpr::CK_Unknown, &Size, false);
+ Expr *DeleteArg = &Cast;
+
+ DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName(
+ ArrayForm ? OO_Array_Delete : OO_Delete);
+
+ if (Pointee->isRecordType() && !UseGlobal) {
+ CXXRecordDecl *Record
+ = cast<CXXRecordDecl>(Pointee->getAs<RecordType>()->getDecl());
+ // FIXME: We fail to find inherited overloads.
+ if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName,
+ &DeleteArg, 1, Record, /*AllowMissing=*/true,
+ OperatorDelete))
+ return ExprError();
+ }
+
+ if (!OperatorDelete) {
+ // Didn't find a member overload. Look for a global one.
+ DeclareGlobalNewDelete();
+ DeclContext *TUDecl = Context.getTranslationUnitDecl();
+ if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName,
+ &DeleteArg, 1, TUDecl, /*AllowMissing=*/false,
+ OperatorDelete))
+ return ExprError();
+ }
+
// FIXME: Check access and ambiguity of operator delete and destructor.
}
Operand.release();
return Owned(new (Context) CXXDeleteExpr(Context.VoidTy, UseGlobal, ArrayForm,
- 0, Ex, StartLoc));
+ OperatorDelete, Ex, StartLoc));
}
Modified: cfe/trunk/utils/ABITest/layout/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/layout/Makefile?rev=79200&r1=79199&r2=79200&view=diff
==============================================================================
--- cfe/trunk/utils/ABITest/layout/Makefile (original)
+++ cfe/trunk/utils/ABITest/layout/Makefile Sun Aug 16 15:29:29 2009
@@ -11,7 +11,7 @@
CFLAGS := -std=gnu99
-X_COMPILER := llvm-gcc
+X_COMPILER := /Developer/usr/bin/llvm-gcc-4.2
Y_COMPILER := clang
CC := gcc
More information about the cfe-commits
mailing list