Skip to content

Commit 4cac6e2

Browse files
committed
Remove strict check and generalise error message
1 parent eb9ea2c commit 4cac6e2

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
17471747
SourceManager &SM = getContext().getSourceManager();
17481748
SourceLocation Loc = E->getOperatorNew()->getLocation();
17491749
bool IsCustomOverload = !SM.isInSystemHeader(Loc);
1750-
if (SanOpts.has(SanitizerKind::Alignment) && IsCustomOverload &&
1750+
if (SanOpts.has(SanitizerKind::Alignment) &&
17511751
(DefaultTargetAlignment >
17521752
CGM.getContext().getTypeAlignInChars(allocType).getQuantity()))
17531753
checkKind = CodeGenFunction::TCK_ConstructorCallOverloadedNew;

compiler-rt/lib/ubsan/ubsan_handlers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ extern const char *const TypeCheckKinds[] = {
9292
"cast to virtual base of",
9393
"_Nonnull binding to",
9494
"dynamic operation on",
95-
"constructor call with pointer from overloaded operator new on"};
95+
"constructor call with pointer from operator new on"};
9696
}
9797

9898
static void handleTypeMismatchImpl(TypeMismatchData *Data, ValueHandle Pointer,
@@ -134,7 +134,7 @@ static void handleTypeMismatchImpl(TypeMismatchData *Data, ValueHandle Pointer,
134134
case ErrorType::AlignmentOnOverloadedNew:
135135
Diag(Loc, DL_Error, ET,
136136
"%0 misaligned address %1 for type %2, "
137-
"which requires target minimum assumed alignment of %3")
137+
"which requires target minimum assumed %3 byte alignment")
138138
<< TypeCheckKinds[Data->TypeCheckKind] << (void *)Pointer << Data->Type
139139
<< Alignment;
140140
break;

compiler-rt/test/ubsan/TestCases/TypeCheck/minimum-alignment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct Foo {
3030

3131
static_assert(alignof(Foo) == 8);
3232
int main() {
33-
// CHECK: runtime error: constructor call with pointer from overloaded operator new on misaligned address 0x{{.*}} for type 'Foo', which requires target minimum assumed alignment of 16
33+
// CHECK: runtime error: constructor call with pointer from operator new on misaligned address 0x{{.*}} for type 'Foo', which requires target minimum assumed 16 byte alignment
3434
Foo *f = new Foo;
3535
return 0;
3636
}

compiler-rt/test/ubsan/TestCases/TypeCheck/misaligned.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int main(int, char **argv) {
101101
return s->f() && 0;
102102

103103
case 'n':
104-
// CHECK-NEW: misaligned.cpp:[[@LINE+4]]{{(:21)?}}: runtime error: constructor call on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires 4 byte alignment
104+
// CHECK-NEW: misaligned.cpp:[[@LINE+4]]{{(:21)?}}: runtime error: constructor call with pointer from operator new on misaligned address [[PTR:0x[0-9a-f]*]] for type 'S', which requires target minimum assumed 4 byte alignment
105105
// CHECK-NEW-NEXT: [[PTR]]: note: pointer points here
106106
// CHECK-NEW-NEXT: {{^ 00 00 00 01 02 03 04 05}}
107107
// CHECK-NEW-NEXT: {{^ \^}}

0 commit comments

Comments
 (0)