diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-12-18 00:22:45 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-12-18 00:22:45 +0000 |
commit | be024a815053546cedf5c54c528426d8da8d2530 (patch) | |
tree | 9b5ce296a906c6fa1a75f1c271afab9ea68f61dc /clang/lib/CodeGen/CGExpr.cpp | |
parent | 43b1e13386741b4a321c1be19608c863de00f6e8 (diff) | |
download | bcm5719-llvm-be024a815053546cedf5c54c528426d8da8d2530.tar.gz bcm5719-llvm-be024a815053546cedf5c54c528426d8da8d2530.zip |
Rein ubsan's vptr sanitizer back a bit. Per core issue 453, binding a reference
to an object outside its lifetime does not have undefined behavior.
llvm-svn: 170387
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 0be483a9071..19109d7b017 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -538,8 +538,15 @@ void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, // If possible, check that the vptr indicates that there is a subobject of // type Ty at offset zero within this object. + // + // C++11 [basic.life]p5,6: + // [For storage which does not refer to an object within its lifetime] + // The program has undefined behavior if: + // -- the [pointer or glvalue] is used to access a non-static data member + // or call a non-stastic member function CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); - if (getLangOpts().SanitizeVptr && TCK != TCK_ConstructorCall && + if (getLangOpts().SanitizeVptr && + (TCK == TCK_MemberAccess || TCK == TCK_MemberCall) && RD && RD->hasDefinition() && RD->isDynamicClass()) { // Compute a hash of the mangled name of the type. // |