Skip to content

Commit e40a027

Browse files
author
Anthony Tran
committed
Address Michael's review and changed string descriptions
1 parent 0cf31b4 commit e40a027

23 files changed

+62
-55
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -88,53 +88,48 @@ enum VariableTypeDescriptorKind : uint16_t {
8888
static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) {
8989
switch (ID) {
9090
case SanitizerHandler::AddOverflow:
91-
return "The addition of two signed integers resulted in overflow.";
91+
return "Signed integer addition overflowed.";
9292

9393
case SanitizerHandler::BuiltinUnreachable:
94-
return "_builtin_unreachable encountered.";
94+
return "_builtin_unreachable() executed.";
9595

9696
case SanitizerHandler::CFICheckFail:
97-
return "Control flow integrity check failed.";
97+
return "Control flow integrity check failed";
9898

99-
case SanitizerHandler::DivremOverflow: // Unsure
100-
return "stub";
99+
case SanitizerHandler::DivremOverflow:
100+
return "Signed integer divide or remainder overflowed";
101101

102-
case SanitizerHandler::DynamicTypeCacheMiss: // Unsure
103-
return "Data requested for dynamic type not found in cache memory.";
102+
case SanitizerHandler::DynamicTypeCacheMiss:
103+
return "Dynamic-type cache miss";
104104

105-
case SanitizerHandler::FloatCastOverflow: // Pasted from LLVM docs, maybe
106-
// something better to put here.
107-
return "Conversion to, from, or between floating-point types which would "
108-
"overflow the destination.";
105+
case SanitizerHandler::FloatCastOverflow:
106+
return "Floating-point to integer conversion overflowed";
109107

110108
case SanitizerHandler::FunctionTypeMismatch:
111-
return "Function called with arguments of a different data type than "
112-
"expected";
109+
return "Function called with mismatched signature";
113110

114111
case SanitizerHandler::ImplicitConversion:
115-
return "Implicit conversion occurred.";
112+
return "Implicit integer conversion overflowed or lost data";
116113

117114
case SanitizerHandler::InvalidBuiltin:
118-
return "Built-in function or keyword not recognized.";
115+
return "Invalid use of builtin function";
119116

120117
case SanitizerHandler::InvalidObjCCast:
121118
return "Invalid Objective-C cast.";
122119

123120
case SanitizerHandler::LoadInvalidValue:
124-
return "stub";
121+
return "Loaded an invalid or uninitialized value";
125122

126123
case SanitizerHandler::MissingReturn:
127-
return "Function is missing a return.";
124+
return "Non-void function fell off end without return";
128125

129126
case SanitizerHandler::MulOverflow:
130-
return "The multiplication of two signed integers resulted in overflow.";
127+
return "Signed integer multiplication overflowed";
131128

132129
case SanitizerHandler::NegateOverflow:
133-
return "Underflow/negative overflow occurred.";
130+
return "Signed integer negation overflowed";
134131

135-
case SanitizerHandler::
136-
NullabilityArg: // Next 4 pasted from
137-
// https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
132+
case SanitizerHandler::NullabilityArg:
138133
return "Passing null as a function parameter which is annotated with "
139134
"_Nonnull";
140135

@@ -151,26 +146,25 @@ static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) {
151146
"be null";
152147

153148
case SanitizerHandler::OutOfBounds:
154-
return "Out of bounds -- memory accessed outside of expected boundaries.";
149+
return "Array index out of bounds";
155150

156151
case SanitizerHandler::PointerOverflow:
157-
return "stub";
152+
return "Pointer arithmetic overflowed bounds";
158153

159154
case SanitizerHandler::ShiftOutOfBounds:
160-
return "Bit shift attempted to move bits beyond boundaries of data type's "
161-
"bit size.";
155+
return "Shift amount exceeds bit-width of operand";
162156

163157
case SanitizerHandler::SubOverflow:
164-
return "The subtraction of two signed integers resulted in overflow.";
158+
return "Signed integer subtraction overflowed";
165159

166160
case SanitizerHandler::TypeMismatch:
167-
return "Type mismatch -- value type used does not match type expected.";
161+
return "Type mismatch in operation";
168162

169163
case SanitizerHandler::AlignmentAssumption: // Help on bottom 2
170-
return "stub";
164+
return "Alignment assumption violated";
171165

172166
case SanitizerHandler::VLABoundNotPositive:
173-
return "stub";
167+
return "Variable-length array bound is not positive";
174168

175169
default:
176170
return "";
@@ -4133,8 +4127,7 @@ void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {
41334127

41344128
void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
41354129
SanitizerHandler CheckHandlerID,
4136-
bool NoMerge, StringRef Annotation,
4137-
StringRef TrapMessage) {
4130+
bool NoMerge) {
41384131
llvm::BasicBlock *Cont = createBasicBlock("cont");
41394132

41404133
// If we're optimizing, collapse all calls to trap down to just one per
@@ -4145,7 +4138,8 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
41454138
llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID];
41464139

41474140
llvm::DILocation *TrapLocation = Builder.getCurrentDebugLocation();
4148-
llvm::StringRef Category = GetTrapMessageForHandler(CheckHandlerID);
4141+
llvm::StringRef Category = "UBSan Trap Reason";
4142+
llvm::StringRef TrapMessage = GetTrapMessageForHandler(CheckHandlerID);
41494143

41504144
if (getDebugInfo() && !Category.empty()) {
41514145
TrapLocation = getDebugInfo()->CreateTrapFailureMessageFor(

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5287,8 +5287,7 @@ class CodeGenFunction : public CodeGenTypeCache {
52875287
/// Create a basic block that will call the trap intrinsic, and emit a
52885288
/// conditional branch to it, for the -ftrapv checks.
52895289
void EmitTrapCheck(llvm::Value *Checked, SanitizerHandler CheckHandlerID,
5290-
bool NoMerge = false, StringRef Annotation = "",
5291-
StringRef TrapMessage = "");
5290+
bool NoMerge = false);
52925291

52935292
/// Emit a call to trap or debugtrap and attach function attribute
52945293
/// "trap-func-name" if specified.

clang/test/CodeGen/ubsan-trap-reason-add-overflow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ int add_overflow(int a, int b) {
77

88
// CHECK: call void @llvm.ubsantrap(i8 0) {{.*}}!dbg [[LOC:![0-9]+]]
99
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
10-
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$
10+
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$UBSan Trap Reason

clang/test/CodeGen/ubsan-trap-reason-builtin-unreachable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ int call_builtin_unreachable()
99

1010
// CHECK: call void @llvm.ubsantrap(i8 1) {{.*}}!dbg [[LOC:![0-9]+]]
1111
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
12-
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$
12+
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$UBSan Trap Reason

clang/test/CodeGen/ubsan-trap-reason-div-rem-overflow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ int div_rem_overflow(int a, int b) {
77

88
// CHECK: call void @llvm.ubsantrap(i8 3) {{.*}}!dbg [[LOC:![0-9]+]]
99
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
10-
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$
10+
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$UBSan Trap Reason

clang/test/CodeGen/ubsan-trap-reason-float-cast-overflow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ int f(float x) {
77

88
// CHECK: call void @llvm.ubsantrap(i8 5) {{.*}}!dbg [[LOC:![0-9]+]]
99
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
10-
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$
10+
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$UBSan Trap Reason

clang/test/CodeGen/ubsan-trap-reason-function-type-mismatch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ int function_type_mismatch() {
1313

1414
// CHECK: call void @llvm.ubsantrap(i8 6) {{.*}}!dbg [[LOC:![0-9]+]]
1515
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
16-
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$
16+
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$UBSan Trap Reason

clang/test/CodeGen/ubsan-trap-reason-implicit-conversion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ unsigned implicit_conversion()
1010

1111
// CHECK: call void @llvm.ubsantrap(i8 7) {{.*}}!dbg [[LOC:![0-9]+]]
1212
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
13-
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$
13+
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$UBSan Trap Reason

clang/test/CodeGen/ubsan-trap-reason-invalid-builtin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ unsigned invalid_builtin(unsigned x)
99

1010
// CHECK: call void @llvm.ubsantrap(i8 8) {{.*}}!dbg [[LOC:![0-9]+]]
1111
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
12-
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$
12+
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$UBSan Trap Reason

clang/test/CodeGen/ubsan-trap-reason-load-invalid-value.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ bool load_invalid_value()
1212

1313
// CHECK: call void @llvm.ubsantrap(i8 10) {{.*}}!dbg [[LOC:![0-9]+]]
1414
// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
15-
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$
15+
// CHECK: distinct !DISubprogram(name: "__clang_trap_msg$UBSan Trap Reason

0 commit comments

Comments
 (0)