nmusgrave created this revision.
nmusgrave added reviewers: eugenis, kcc.
nmusgrave added a subscriber: cfe-commits.
http://reviews.llvm.org/D11109
Files:
lib/CodeGen/CGClass.cpp
Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1448,6 +1448,27 @@
// Exit the try if applicable.
if (isTryBody)
ExitCXXTryStmt(*cast<CXXTryStmt>(Body), true);
+
+ // Insert memory-posioning instrumentation.
+ if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor) {
+ SmallVector<llvm::Value *, 4> Args;
+ SmallVector<llvm::Type *, 4> ArgTypes;
+
+ ArgTypes.push_back(Int8PtrTy);
+ Args.push_back(Builder.CreateBitCast(LoadCXXThis(), Int8PtrTy));
+
+ ArgTypes.push_back(IntTy);
+ const ASTRecordLayout &Layout =
+ getContext().getASTRecordLayout(Dtor->getParent());
+ Args.push_back(
+ llvm::ConstantInt::get(CGM.IntTy, Layout.getSize().getQuantity()));
+
+ llvm::FunctionType *FnType =
+ llvm::FunctionType::get(CGM.VoidTy, ArgTypes, false);
+ llvm::Value *Fn =
+ CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_exit_callback");
+ EmitNounwindRuntimeCall(Fn, Args);
+ }
}
void CodeGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList
&Args) {
Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1448,6 +1448,27 @@
// Exit the try if applicable.
if (isTryBody)
ExitCXXTryStmt(*cast<CXXTryStmt>(Body), true);
+
+ // Insert memory-posioning instrumentation.
+ if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor) {
+ SmallVector<llvm::Value *, 4> Args;
+ SmallVector<llvm::Type *, 4> ArgTypes;
+
+ ArgTypes.push_back(Int8PtrTy);
+ Args.push_back(Builder.CreateBitCast(LoadCXXThis(), Int8PtrTy));
+
+ ArgTypes.push_back(IntTy);
+ const ASTRecordLayout &Layout =
+ getContext().getASTRecordLayout(Dtor->getParent());
+ Args.push_back(
+ llvm::ConstantInt::get(CGM.IntTy, Layout.getSize().getQuantity()));
+
+ llvm::FunctionType *FnType =
+ llvm::FunctionType::get(CGM.VoidTy, ArgTypes, false);
+ llvm::Value *Fn =
+ CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_exit_callback");
+ EmitNounwindRuntimeCall(Fn, Args);
+ }
}
void CodeGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &Args) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits