diff options
author | Vedant Kumar <vsk@apple.com> | 2017-02-17 23:22:55 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-02-17 23:22:55 +0000 |
commit | 18348ea9b9d991ce70664187576a13f773496144 (patch) | |
tree | 4c7a08ca634546168477437770a762bbeb0e126d /clang/lib/CodeGen/CGClass.cpp | |
parent | f8346550bf967fb1c1767de17b602fae33452587 (diff) | |
download | llvm-18348ea9b9d991ce70664187576a13f773496144.zip llvm-18348ea9b9d991ce70664187576a13f773496144.tar.gz llvm-18348ea9b9d991ce70664187576a13f773496144.tar.bz2 |
[ubsan] Pass a set of checks to skip to EmitTypeCheck() (NFC)
CodeGenFunction::EmitTypeCheck accepts a bool flag which controls
whether or not null checks are emitted. Make this a bit more flexible by
changing the bool to a SanitizerSet.
Needed for an upcoming change which deals with a scenario in which we
only want to emit null checks.
llvm-svn: 295514
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGClass.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 03c3358..65961db 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -309,8 +309,10 @@ Address CodeGenFunction::GetAddressOfBaseClass( // just do a bitcast; null checks are unnecessary. if (NonVirtualOffset.isZero() && !VBase) { if (sanitizePerformTypeCheck()) { + SanitizerSet SkippedChecks; + SkippedChecks.set(SanitizerKind::Null, !NullCheckValue); EmitTypeCheck(TCK_Upcast, Loc, Value.getPointer(), - DerivedTy, DerivedAlign, !NullCheckValue); + DerivedTy, DerivedAlign, SkippedChecks); } return Builder.CreateBitCast(Value, BasePtrTy); } @@ -331,8 +333,10 @@ Address CodeGenFunction::GetAddressOfBaseClass( } if (sanitizePerformTypeCheck()) { + SanitizerSet SkippedChecks; + SkippedChecks.set(SanitizerKind::Null, true); EmitTypeCheck(VBase ? TCK_UpcastToVirtualBase : TCK_Upcast, Loc, - Value.getPointer(), DerivedTy, DerivedAlign, true); + Value.getPointer(), DerivedTy, DerivedAlign, SkippedChecks); } // Compute the virtual offset. |