Skip to content

Commit ad0b26c

Browse files
authored
Merge pull request #395 from immunant/kkysen/dont-segfault-on-non-scalar-or-struct-direct-types
rewriter: avoid segfaulting on non-scalar, non-struct direct types
2 parents 05e2920 + 9c2346d commit ad0b26c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tools/rewriter/DetermineAbi.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
// chosen to pass directly in registers
2020
static std::vector<CAbiArgKind> classifyDirectType(const clang::Type &type,
2121
const clang::ASTContext &astContext) {
22-
if (type.isVoidType())
22+
if (type.isVoidType()) {
2323
return {};
24-
if (type.isScalarType()) {
24+
} else if (type.isScalarType()) {
2525
switch (type.getScalarTypeKind()) {
2626
case clang::Type::ScalarTypeKind::STK_CPointer:
2727
case clang::Type::ScalarTypeKind::STK_Bool:
@@ -42,7 +42,7 @@ static std::vector<CAbiArgKind> classifyDirectType(const clang::Type &type,
4242
llvm::report_fatal_error(
4343
"unsupported scalar type (obj-C object, Clang block, or C++ member) found during ABI computation");
4444
}
45-
} else {
45+
} else if (type.getAsStructureType()) {
4646
// Handle the case where we pass a struct directly in a register.
4747
// The strategy here is to iterate through each field of the struct
4848
// and record the ABI type each time we exit an eightbyte chunk.
@@ -115,6 +115,7 @@ static std::vector<CAbiArgKind> classifyDirectType(const clang::Type &type,
115115
return out;
116116
}
117117
}
118+
type.dump();
118119
llvm::report_fatal_error(
119120
"classifyDirectType called on non-scalar, non-canPassInRegisters type");
120121
}

0 commit comments

Comments
 (0)