Restore r101841 without modification. Also mark 'operator delete' as used for

actual delete expressions, not just new expressions.

llvm-svn: 101861
This commit is contained in:
John McCall 2010-04-20 02:18:25 +00:00
parent 0c862a86fa
commit 0f55a035cf
6 changed files with 57 additions and 5 deletions

View File

@ -886,6 +886,13 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
return true;
}
// We don't need an operator delete if we're running under
// -fno-exceptions.
if (!getLangOptions().Exceptions) {
OperatorDelete = 0;
return false;
}
// FindAllocationOverload can change the passed in arguments, so we need to
// copy them back.
if (NumPlaceArgs > 0)
@ -1392,6 +1399,8 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
return ExprError();
}
MarkDeclarationReferenced(StartLoc, OperatorDelete);
// FIXME: Check access and ambiguity of operator delete and destructor.
}

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s
typedef __SIZE_TYPE__ size_t;
// Operator delete template for placement new with global lookup

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fexceptions %s
typedef __SIZE_TYPE__ size_t;
struct S {

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s
typedef __SIZE_TYPE__ size_t;
// Overloaded operator delete with two arguments

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 %s -emit-llvm -o %t
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
void t1(int *a) {
delete a;
@ -19,8 +19,11 @@ struct T {
int a;
};
// CHECK: define void @_Z2t4P1T
void t4(T *t) {
// RUN: grep "call void @_ZN1TD1Ev" %t | count 1
// CHECK: call void @_ZN1TD1Ev
// CHECK-NEXT: bitcast
// CHECK-NEXT: call void @_ZdlPv
delete t;
}
@ -35,3 +38,22 @@ void f() {
delete a;
}
namespace test0 {
struct A {
void *operator new(__SIZE_TYPE__ sz);
void operator delete(void *p) { ::operator delete(p); }
~A() {}
};
// CHECK: define void @_ZN5test04testEPNS_1AE(
void test(A *a) {
// CHECK: call void @_ZN5test01AD1Ev
// CHECK-NEXT: bitcast
// CHECK-NEXT: call void @_ZN5test01AdlEPv
delete a;
}
// CHECK: define linkonce_odr void @_ZN5test01AD1Ev
// CHECK: define linkonce_odr void @_ZN5test01AdlEPv
}

View File

@ -0,0 +1,21 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// Various tests for -fno-exceptions
typedef __SIZE_TYPE__ size_t;
namespace test0 {
// rdar://problem/7878149
class Foo {
public:
void* operator new(size_t x);
private:
void operator delete(void *x);
};
void test() {
// Under -fexceptions, this does access control for the associated
// 'operator delete'.
(void) new Foo();
}
}