diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-12-05 08:30:59 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-12-05 08:30:59 +0000 |
commit | f03bd30854adf16bc30fce18120ef5f31954275e (patch) | |
tree | 5759e1b3762dd5c08f4bdec0e6b220248d94054f /clang/lib/Sema | |
parent | 9ef5775a949d2c78ba01169d0eca962f5d7c1ae7 (diff) | |
download | bcm5719-llvm-f03bd30854adf16bc30fce18120ef5f31954275e.tar.gz bcm5719-llvm-f03bd30854adf16bc30fce18120ef5f31954275e.zip |
PR17983: Fix crasher bug in C++1y mode when performing a non-global array
delete on a class which has no array cookie and has no class-specific operator
new.
llvm-svn: 196488
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 162e46ecab1..846aba89727 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -6192,6 +6192,10 @@ bool Sema::CheckDestructor(CXXDestructorDecl *Destructor) { Context.DeclarationNames.getCXXOperatorName(OO_Delete); if (FindDeallocationFunction(Loc, RD, Name, OperatorDelete)) return true; + // If there's no class-specific operator delete, look up the global + // non-array delete. + if (!OperatorDelete) + OperatorDelete = FindUsualDeallocationFunction(Loc, true, Name); MarkFunctionReferenced(Loc, OperatorDelete); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 95a5cbb20ee..b2f740e8044 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2233,8 +2233,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, return true; } - // Look for a global declaration. - Operator = FindUsualDeallocationFunction(StartLoc, true, Name); + Operator = 0; return false; } @@ -2384,7 +2383,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // Otherwise, the usual operator delete[] should be the // function we just found. - else if (isa<CXXMethodDecl>(OperatorDelete)) + else if (OperatorDelete && isa<CXXMethodDecl>(OperatorDelete)) UsualArrayDeleteWantsSize = (OperatorDelete->getNumParams() == 2); } |