Skip to content

Commit aead894

Browse files
committed
Replace manual ApplyDebugLocation with SanitizerDebugLocation, and also
remove redundant SanitizerDebugLocation from EmitVTablePtrCheck
1 parent 1df8fe4 commit aead894

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

clang/lib/CodeGen/CGClass.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,9 +2817,8 @@ void CodeGenFunction::EmitVTablePtrCheckForCall(const CXXRecordDecl *RD,
28172817
RD = LeastDerivedClassWithSameLayout(RD);
28182818

28192819
auto [Ordinal, _] = SanitizerInfoFromCFICheckKind(TCK);
2820-
ApplyDebugLocation ApplyTrapDI(
2821-
*this,
2822-
SanitizerAnnotateDebugInfo(Ordinal, SanitizerHandler::CFICheckFail));
2820+
SanitizerDebugLocation SanScope(this, {Ordinal},
2821+
SanitizerHandler::CFICheckFail);
28232822

28242823
EmitVTablePtrCheck(RD, VTable, TCK, Loc);
28252824
}
@@ -2844,9 +2843,8 @@ void CodeGenFunction::EmitVTablePtrCheckForCast(QualType T, Address Derived,
28442843
ClassDecl = LeastDerivedClassWithSameLayout(ClassDecl);
28452844

28462845
auto [Ordinal, _] = SanitizerInfoFromCFICheckKind(TCK);
2847-
ApplyDebugLocation ApplyTrapDI(
2848-
*this,
2849-
SanitizerAnnotateDebugInfo(Ordinal, SanitizerHandler::CFICheckFail));
2846+
SanitizerDebugLocation SanScope(this, {Ordinal},
2847+
SanitizerHandler::CFICheckFail);
28502848

28512849
llvm::BasicBlock *ContBlock = nullptr;
28522850

@@ -2878,6 +2876,8 @@ void CodeGenFunction::EmitVTablePtrCheck(const CXXRecordDecl *RD,
28782876
llvm::Value *VTable,
28792877
CFITypeCheckKind TCK,
28802878
SourceLocation Loc) {
2879+
// N.B. all callers have established SanitizerDebugLocation
2880+
28812881
if (!CGM.getCodeGenOpts().SanitizeCfiCrossDso &&
28822882
!CGM.HasHiddenLTOVisibility(RD))
28832883
return;
@@ -2889,8 +2889,6 @@ void CodeGenFunction::EmitVTablePtrCheck(const CXXRecordDecl *RD,
28892889
SanitizerMask::bitPosToMask(M), TypeName))
28902890
return;
28912891

2892-
auto CheckHandler = SanitizerHandler::CFICheckFail;
2893-
SanitizerDebugLocation SanScope(this, {M}, CheckHandler);
28942892
EmitSanitizerStatReport(SSK);
28952893

28962894
llvm::Metadata *MD =
@@ -2914,7 +2912,7 @@ void CodeGenFunction::EmitVTablePtrCheck(const CXXRecordDecl *RD,
29142912

29152913
if (CGM.getCodeGenOpts().SanitizeTrap.has(M)) {
29162914
bool NoMerge = !CGM.getCodeGenOpts().SanitizeMergeHandlers.has(M);
2917-
EmitTrapCheck(TypeTest, CheckHandler, NoMerge);
2915+
EmitTrapCheck(TypeTest, SanitizerHandler::CFICheckFail, NoMerge);
29182916
return;
29192917
}
29202918

@@ -2923,8 +2921,8 @@ void CodeGenFunction::EmitVTablePtrCheck(const CXXRecordDecl *RD,
29232921
llvm::MDString::get(CGM.getLLVMContext(), "all-vtables"));
29242922
llvm::Value *ValidVtable = Builder.CreateCall(
29252923
CGM.getIntrinsic(llvm::Intrinsic::type_test), {VTable, AllVtables});
2926-
EmitCheck(std::make_pair(TypeTest, M), CheckHandler, StaticData,
2927-
{VTable, ValidVtable});
2924+
EmitCheck(std::make_pair(TypeTest, M), SanitizerHandler::CFICheckFail,
2925+
StaticData, {VTable, ValidVtable});
29282926
}
29292927

29302928
bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) {

0 commit comments

Comments
 (0)