Skip to content

Commit 2622e6b

Browse files
authored
[NFC][CodeGen] Extract SanitizerHandler into own header (#142527)
1 parent 4583076 commit 2622e6b

File tree

2 files changed

+51
-34
lines changed

2 files changed

+51
-34
lines changed

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "CGValue.h"
1919
#include "CodeGenModule.h"
2020
#include "EHScopeStack.h"
21+
#include "SanitizerHandler.h"
2122
#include "VarBypassDetector.h"
2223
#include "clang/AST/CharUnits.h"
2324
#include "clang/AST/CurrentSourceLocExprScope.h"
@@ -115,40 +116,6 @@ enum TypeEvaluationKind {
115116
};
116117
// clang-format on
117118

118-
#define LIST_SANITIZER_CHECKS \
119-
SANITIZER_CHECK(AddOverflow, add_overflow, 0) \
120-
SANITIZER_CHECK(BuiltinUnreachable, builtin_unreachable, 0) \
121-
SANITIZER_CHECK(CFICheckFail, cfi_check_fail, 0) \
122-
SANITIZER_CHECK(DivremOverflow, divrem_overflow, 0) \
123-
SANITIZER_CHECK(DynamicTypeCacheMiss, dynamic_type_cache_miss, 0) \
124-
SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0) \
125-
SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 0) \
126-
SANITIZER_CHECK(ImplicitConversion, implicit_conversion, 0) \
127-
SANITIZER_CHECK(InvalidBuiltin, invalid_builtin, 0) \
128-
SANITIZER_CHECK(InvalidObjCCast, invalid_objc_cast, 0) \
129-
SANITIZER_CHECK(LoadInvalidValue, load_invalid_value, 0) \
130-
SANITIZER_CHECK(MissingReturn, missing_return, 0) \
131-
SANITIZER_CHECK(MulOverflow, mul_overflow, 0) \
132-
SANITIZER_CHECK(NegateOverflow, negate_overflow, 0) \
133-
SANITIZER_CHECK(NullabilityArg, nullability_arg, 0) \
134-
SANITIZER_CHECK(NullabilityReturn, nullability_return, 1) \
135-
SANITIZER_CHECK(NonnullArg, nonnull_arg, 0) \
136-
SANITIZER_CHECK(NonnullReturn, nonnull_return, 1) \
137-
SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0) \
138-
SANITIZER_CHECK(PointerOverflow, pointer_overflow, 0) \
139-
SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0) \
140-
SANITIZER_CHECK(SubOverflow, sub_overflow, 0) \
141-
SANITIZER_CHECK(TypeMismatch, type_mismatch, 1) \
142-
SANITIZER_CHECK(AlignmentAssumption, alignment_assumption, 0) \
143-
SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0) \
144-
SANITIZER_CHECK(BoundsSafety, bounds_safety, 0)
145-
146-
enum SanitizerHandler {
147-
#define SANITIZER_CHECK(Enum, Name, Version) Enum,
148-
LIST_SANITIZER_CHECKS
149-
#undef SANITIZER_CHECK
150-
};
151-
152119
/// Helper class with most of the code for saving a value for a
153120
/// conditional expression cleanup.
154121
struct DominatingLLVMValue {

clang/lib/CodeGen/SanitizerHandler.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//===-- SanitizerHandler.h - Definition of sanitizer handlers ---*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This is the internal per-function state used for llvm translation.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_CLANG_LIB_CODEGEN_SANITIZER_HANDLER_H
14+
#define LLVM_CLANG_LIB_CODEGEN_SANITIZER_HANDLER_H
15+
16+
#define LIST_SANITIZER_CHECKS \
17+
SANITIZER_CHECK(AddOverflow, add_overflow, 0) \
18+
SANITIZER_CHECK(BuiltinUnreachable, builtin_unreachable, 0) \
19+
SANITIZER_CHECK(CFICheckFail, cfi_check_fail, 0) \
20+
SANITIZER_CHECK(DivremOverflow, divrem_overflow, 0) \
21+
SANITIZER_CHECK(DynamicTypeCacheMiss, dynamic_type_cache_miss, 0) \
22+
SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0) \
23+
SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 0) \
24+
SANITIZER_CHECK(ImplicitConversion, implicit_conversion, 0) \
25+
SANITIZER_CHECK(InvalidBuiltin, invalid_builtin, 0) \
26+
SANITIZER_CHECK(InvalidObjCCast, invalid_objc_cast, 0) \
27+
SANITIZER_CHECK(LoadInvalidValue, load_invalid_value, 0) \
28+
SANITIZER_CHECK(MissingReturn, missing_return, 0) \
29+
SANITIZER_CHECK(MulOverflow, mul_overflow, 0) \
30+
SANITIZER_CHECK(NegateOverflow, negate_overflow, 0) \
31+
SANITIZER_CHECK(NullabilityArg, nullability_arg, 0) \
32+
SANITIZER_CHECK(NullabilityReturn, nullability_return, 1) \
33+
SANITIZER_CHECK(NonnullArg, nonnull_arg, 0) \
34+
SANITIZER_CHECK(NonnullReturn, nonnull_return, 1) \
35+
SANITIZER_CHECK(OutOfBounds, out_of_bounds, 0) \
36+
SANITIZER_CHECK(PointerOverflow, pointer_overflow, 0) \
37+
SANITIZER_CHECK(ShiftOutOfBounds, shift_out_of_bounds, 0) \
38+
SANITIZER_CHECK(SubOverflow, sub_overflow, 0) \
39+
SANITIZER_CHECK(TypeMismatch, type_mismatch, 1) \
40+
SANITIZER_CHECK(AlignmentAssumption, alignment_assumption, 0) \
41+
SANITIZER_CHECK(VLABoundNotPositive, vla_bound_not_positive, 0) \
42+
SANITIZER_CHECK(BoundsSafety, bounds_safety, 0)
43+
44+
enum SanitizerHandler {
45+
#define SANITIZER_CHECK(Enum, Name, Version) Enum,
46+
LIST_SANITIZER_CHECKS
47+
#undef SANITIZER_CHECK
48+
};
49+
50+
#endif // LLVM_CLANG_LIB_CODEGEN_SANITIZER_HANDLER_H

0 commit comments

Comments
 (0)