Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewriter: avoid segfaulting on non-scalar, non-struct direct types #395

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tools/rewriter/DetermineAbi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// chosen to pass directly in registers
static std::vector<CAbiArgKind> classifyDirectType(const clang::Type &type,
const clang::ASTContext &astContext) {
if (type.isVoidType())
if (type.isVoidType()) {
return {};
if (type.isScalarType()) {
} else if (type.isScalarType()) {
switch (type.getScalarTypeKind()) {
case clang::Type::ScalarTypeKind::STK_CPointer:
case clang::Type::ScalarTypeKind::STK_Bool:
Expand All @@ -42,7 +42,7 @@ static std::vector<CAbiArgKind> classifyDirectType(const clang::Type &type,
llvm::report_fatal_error(
"unsupported scalar type (obj-C object, Clang block, or C++ member) found during ABI computation");
}
} else {
} else if (type.getAsStructureType()) {
// Handle the case where we pass a struct directly in a register.
// The strategy here is to iterate through each field of the struct
// and record the ABI type each time we exit an eightbyte chunk.
Expand Down Expand Up @@ -115,6 +115,7 @@ static std::vector<CAbiArgKind> classifyDirectType(const clang::Type &type,
return out;
}
}
type.dump();
llvm::report_fatal_error(
"classifyDirectType called on non-scalar, non-canPassInRegisters type");
}
Expand Down