Skip to content

Commit 6f82a48

Browse files
committed
Cleanup
1 parent fbadcee commit 6f82a48

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,7 @@ static Value *EmitOverflowCheckedAbs(CodeGenFunction &CGF, const CallExpr *E,
20492049
return EmitAbs(CGF, ArgValue, true);
20502050
}
20512051

2052-
SmallVector<SanitizerKind::SanitizerOrdinal, 3> Ordinals;
2052+
SmallVector<SanitizerKind::SanitizerOrdinal, 1> Ordinals;
20532053
if (SanitizeOverflow)
20542054
Ordinals.push_back(SanitizerKind::SO_SignedIntegerOverflow);
20552055
CodeGenFunction::SanitizerScope SanScope(&CGF, Ordinals);

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,9 +1249,11 @@ llvm::DILocation *CodeGenFunction::SanitizerAnnotateDebugInfo(
12491249
llvm::DILocation *CheckDI = Builder.getCurrentDebugLocation();
12501250

12511251
// TODO: the annotation could be more precise:
1252-
// 1) use the ordinal name if there is only one ordinal
1252+
// 1) use the ordinal name if there is only one ordinal; and/or,
12531253
// 2) use the overarching SanitizerHandler if there are multiple ordinals
1254+
// (this may be confusing to users)
12541255
for (auto Ord : Ordinals) {
1256+
// TODO: deprecate ClArrayBoundsPseudoFn
12551257
if (((ClArrayBoundsPseudoFn && Ord == SanitizerKind::SO_ArrayBounds) ||
12561258
CGM.getCodeGenOpts().SanitizeAnnotateDebugInfo.has(Ord)) &&
12571259
CheckDI) {
@@ -4029,9 +4031,10 @@ void CodeGenFunction::EmitCfiCheckFail() {
40294031

40304032
void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {
40314033
if (SanOpts.has(SanitizerKind::Unreachable)) {
4032-
SanitizerScope SanScope(this, {SanitizerKind::SO_Unreachable});
4034+
auto CheckOrdinal = SanitizerKind::SO_Unreachable;
4035+
SanitizerScope SanScope(this, {CheckOrdinal});
40334036
EmitCheck(std::make_pair(static_cast<llvm::Value *>(Builder.getFalse()),
4034-
SanitizerKind::SO_Unreachable),
4037+
CheckOrdinal),
40354038
SanitizerHandler::BuiltinUnreachable,
40364039
EmitCheckSourceLocation(Loc), {});
40374040
}
@@ -6270,7 +6273,8 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
62706273
!isa<FunctionNoProtoType>(PointeeType)) {
62716274
if (llvm::Constant *PrefixSig =
62726275
CGM.getTargetCodeGenInfo().getUBSanFunctionSignature(CGM)) {
6273-
SanitizerScope SanScope(this, {SanitizerKind::SO_Function});
6276+
auto CheckOrdinal = SanitizerKind::SO_Function;
6277+
SanitizerScope SanScope(this, {CheckOrdinal});
62746278
auto *TypeHash = getUBSanFunctionTypeHash(PointeeType);
62756279

62766280
llvm::Type *PrefixSigType = PrefixSig->getType();
@@ -6330,7 +6334,7 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
63306334
Builder.CreateICmpEQ(CalleeTypeHash, TypeHash);
63316335
llvm::Constant *StaticData[] = {EmitCheckSourceLocation(E->getBeginLoc()),
63326336
EmitCheckTypeDescriptor(CalleeType)};
6333-
EmitCheck(std::make_pair(CalleeTypeHashMatch, SanitizerKind::SO_Function),
6337+
EmitCheck(std::make_pair(CalleeTypeHashMatch, CheckOrdinal),
63346338
SanitizerHandler::FunctionTypeMismatch, StaticData,
63356339
{CalleePtr});
63366340

@@ -6349,10 +6353,9 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
63496353
// function pointer is a member of the bit set for the function type.
63506354
if (SanOpts.has(SanitizerKind::CFIICall) &&
63516355
(!TargetDecl || !isa<FunctionDecl>(TargetDecl))) {
6352-
SanitizerScope SanScope(this, {SanitizerKind::SO_CFIICall});
6356+
auto CheckOrdinal = SanitizerKind::SO_CFIICall;
6357+
SanitizerScope SanScope(this, {CheckOrdinal});
63536358
EmitSanitizerStatReport(llvm::SanStat_CFI_ICall);
6354-
ApplyDebugLocation ApplyTrapDI(
6355-
*this, SanitizerAnnotateDebugInfo(SanitizerKind::SO_CFIICall));
63566359

63576360
llvm::Metadata *MD;
63586361
if (CGM.getCodeGenOpts().SanitizeCfiICallGeneralizePointers)
@@ -6373,10 +6376,10 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
63736376
EmitCheckTypeDescriptor(QualType(FnType, 0)),
63746377
};
63756378
if (CGM.getCodeGenOpts().SanitizeCfiCrossDso && CrossDsoTypeId) {
6376-
EmitCfiSlowPathCheck(SanitizerKind::SO_CFIICall, TypeTest, CrossDsoTypeId,
6377-
CalleePtr, StaticData);
6379+
EmitCfiSlowPathCheck(CheckOrdinal, TypeTest, CrossDsoTypeId, CalleePtr,
6380+
StaticData);
63786381
} else {
6379-
EmitCheck(std::make_pair(TypeTest, SanitizerKind::SO_CFIICall),
6382+
EmitCheck(std::make_pair(TypeTest, CheckOrdinal),
63806383
SanitizerHandler::CFICheckFail, StaticData,
63816384
{CalleePtr, llvm::UndefValue::get(IntPtrTy)});
63826385
}

0 commit comments

Comments
 (0)