summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-01-13 17:23:24 +0000
committerHans Wennborg <hans@hanshq.net>2014-01-13 17:23:24 +0000
commit0f3c10cb8a3b54b95077eb980358a11448d84d1e (patch)
tree086da72711f0c8a592efb30c05fdbe505d5bc380 /clang/lib/Sema/SemaChecking.cpp
parent9bc0415c1fd937bdbc7d87bb7486b83c0aab32c9 (diff)
downloadbcm5719-llvm-0f3c10cb8a3b54b95077eb980358a11448d84d1e.tar.gz
bcm5719-llvm-0f3c10cb8a3b54b95077eb980358a11448d84d1e.zip
[ms-cxxabi] Elide dtor access checks for pass-by-val objects in callees
The ABI requires the destructor to be invoked in the callee, but the standard does not require access checks here so we avoid doing direct access checks on the destructor. If we end up needing to define an implicit destructor, we don't skip access checks for the base class, etc. Those checks are effectively part of generating the destructor definition, and aren't affected by which TU the check is performed in. Differential Revision: http://llvm-reviews.chandlerc.com/D2409 llvm-svn: 199120
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 82b3da6c2e1..0e2b1f64d60 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6241,12 +6241,21 @@ bool Sema::CheckParmsForFunctionDef(ParmVarDecl *const *P,
// MSVC destroys objects passed by value in the callee. Therefore a
// function definition which takes such a parameter must be able to call the
- // object's destructor.
+ // object's destructor. However, we don't perform any direct access check
+ // on the dtor.
if (getLangOpts().CPlusPlus && Context.getTargetInfo()
.getCXXABI()
.areArgsDestroyedLeftToRightInCallee()) {
- if (const RecordType *RT = Param->getType()->getAs<RecordType>())
- FinalizeVarWithDestructor(Param, RT);
+ if (const RecordType *RT = Param->getType()->getAs<RecordType>()) {
+ CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RT->getDecl());
+ if (!ClassDecl->isInvalidDecl() &&
+ !ClassDecl->hasIrrelevantDestructor() &&
+ !ClassDecl->isDependentContext()) {
+ CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
+ MarkFunctionReferenced(Param->getLocation(), Destructor);
+ DiagnoseUseOfDecl(Destructor, Param->getLocation());
+ }
+ }
}
}
OpenPOWER on IntegriCloud