[PATCH] D11106: use-after-dtor cmd option
Naomi Musgrave
nmusgrave at google.com
Fri Jul 17 16:51:33 PDT 2015
nmusgrave marked an inline comment as done.
================
Comment at: include/clang/Driver/Options.td:561-563
@@ -560,2 +560,5 @@
HelpText<"Disable origins tracking in MemorySanitizer">;
+def fsanitize_memory_use_after_dtor : Flag<["-"], "fsanitize-memory-use-after-dtor">,
+ Group<f_clang_Group>, Flags<[CC1Option]>,
+ HelpText<"Enable use-after-destroy detection in MemorySanitizer">;
def fsanitize_address_field_padding : Joined<["-"], "fsanitize-address-field-padding=">,
----------------
echristo wrote:
> clang-format? also inverse option?
as in an option to explicitly turn off this type of checking...?
================
Comment at: lib/CodeGen/CGClass.cpp:1459
@@ +1458,3 @@
+
+ // insert memory-posioning instrumentation
+ if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor) {
----------------
echristo wrote:
> Comments are complete sentences.
resolved in d11109
================
Comment at: lib/CodeGen/CGClass.cpp:1468-1476
@@ +1467,11 @@
+ 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);
----------------
eugenis wrote:
> majnemer wrote:
> > I couldn't find a definition of `__sanitizer_dtor_exit_callback` but `int` seems like the wrong type if it is supposed to hold the size of the record.
> >
> > Consider:
> > struct S { char x[1ULL << 32]; ~S() {} } s;
> >
> > This type will have size 4294967296 but will be represent as 0 if coerced to an int type on most (all?) 64-bit platforms.
> __sanitizer_dtor_exit_callback is not implemented yet.
> Yes, it should accept (void *, size_t).
revision [[ http://reviews.llvm.org/D11109 | here ]] contains updated types
http://reviews.llvm.org/D11106
More information about the llvm-commits
mailing list