diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-06-21 12:45:15 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-06-21 12:45:15 +0000 |
commit | 23f4c4b64f1a35be406c66ab4e0113a8522b4905 (patch) | |
tree | 32d612ab8a5015a669c0c918d0843099be1cf479 /clang/lib/Sema/SemaChecking.cpp | |
parent | ae4e1ec4e6c616e50794d895555f8ebb49dd05f5 (diff) | |
download | bcm5719-llvm-23f4c4b64f1a35be406c66ab4e0113a8522b4905.tar.gz bcm5719-llvm-23f4c4b64f1a35be406c66ab4e0113a8522b4905.zip |
[ms-cxxabi] Destroy temporary record arguments in the callee
Itanium destroys them in the caller at the end of the full expression,
but MSVC destroys them in the callee. This is further complicated by
the need to emit EH-only destructor cleanups in the caller.
This should help clang compile MSVC's debug iterators more correctly.
There is still an outstanding issue in PR5064 of a memcpy emitted by the
LLVM backend, which is not correct for C++ records.
Fixes PR16226.
Reviewers: rjmccall
Differential Revision: http://llvm-reviews.chandlerc.com/D929
llvm-svn: 184543
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 16b12ea91e1..87fe7635891 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -5777,6 +5777,15 @@ bool Sema::CheckParmsForFunctionDef(ParmVarDecl **P, ParmVarDecl **PEnd, } PType= AT->getElementType(); } + + // 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. + if (getLangOpts().CPlusPlus && + Context.getTargetInfo().getCXXABI().isArgumentDestroyedByCallee()) { + if (const RecordType *RT = Param->getType()->getAs<RecordType>()) + FinalizeVarWithDestructor(Param, RT); + } } return HasInvalidParm; |