Skip to content

Commit

Permalink
treewide: Fix unreachable to more appropriate macros.
Browse files Browse the repository at this point in the history
  • Loading branch information
xlauko committed Jan 23, 2024
1 parent 03fb74a commit e97cff4
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 46 deletions.
2 changes: 1 addition & 1 deletion include/vast/CodeGen/CodeGen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ namespace vast::cg
VAST_UNIMPLEMENTED;
} else if (body) {
if (mlir::failed(build_function_body(body))) {
VAST_UNREACHABLE("failed function body codegen");
VAST_FATAL("failed function body codegen");
}
} else {
VAST_UNIMPLEMENTED_MSG("no definition for emitted function");
Expand Down
2 changes: 1 addition & 1 deletion include/vast/CodeGen/CodeGenContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace vast::cg
if (const auto *d = llvm::dyn_cast< clang::NamedDecl >(dctx)) {
name += get_decl_name(d);
} else {
VAST_UNREACHABLE("unknown decl context: {0}", dctx->getDeclKindName());
VAST_FATAL("unknown decl context: {0}", dctx->getDeclKindName());
}

name += "::";
Expand Down
10 changes: 5 additions & 5 deletions include/vast/CodeGen/CodeGenDeclVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ namespace vast::cg {
return fn;
}

VAST_UNREACHABLE("NYI");
VAST_UNIMPLEMENTED;

// TODO: clang checks here if this is a llvm::GlobalAlias... how will we
// support this?
Expand Down Expand Up @@ -282,7 +282,7 @@ namespace vast::cg {
return fn;
}

VAST_UNREACHABLE("codegen of incomplete function");
VAST_FATAL("codegen of incomplete function");
}

vast_function get_addr_of_function(
Expand Down Expand Up @@ -486,7 +486,7 @@ namespace vast::cg {
case clang::SC_PrivateExtern: return hl::StorageClass::sc_private_extern;
case clang::SC_Register: return hl::StorageClass::sc_register;
}
VAST_UNREACHABLE("unknown storage class");
VAST_UNIMPLEMENTED_MSG("unknown storage class");
}

hl::TSClass VisitThreadStorageClass(const clang::VarDecl *decl) const {
Expand All @@ -496,7 +496,7 @@ namespace vast::cg {
case clang::TSCS_thread_local: return hl::TSClass::tsc_cxx_thread;
case clang::TSCS__Thread_local: return hl::TSClass::tsc_c_thread;
}
VAST_UNREACHABLE("unknown storage class");
VAST_UNIMPLEMENTED_MSG("unknown thread storage class");
}

operation VisitVarDecl(const clang::VarDecl *decl) {
Expand Down Expand Up @@ -713,7 +713,7 @@ namespace vast::cg {
case clang::AccessSpecifier::AS_none:
return hl::AccessSpecifier::as_none;
}
VAST_UNREACHABLE("unknown access specifier");
VAST_UNIMPLEMENTED_MSG("unknown access specifier");
}

//
Expand Down
2 changes: 1 addition & 1 deletion include/vast/CodeGen/CodeGenStmtVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ namespace vast::cg {
return VisitFunctionDeclRefExpr(expr);
}

VAST_UNREACHABLE("unknown underlying declaration to be referenced");
VAST_UNIMPLEMENTED_MSG("unknown underlying declaration to be referenced");
}

Operation *VisitPredefinedExpr(const clang::PredefinedExpr *expr)
Expand Down
10 changes: 5 additions & 5 deletions include/vast/CodeGen/UnreachableVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ namespace vast::cg
template< typename derived_t >
struct unreach_stmt_visitor {
operation Visit(const clang::Stmt *stmt) {
VAST_UNREACHABLE("unsupported stmt: {0}", stmt->getStmtClassName());
VAST_FATAL("unsupported stmt: {0}", stmt->getStmtClassName());
}
};

template< typename derived_t >
struct unreach_decl_visitor {
operation Visit(const clang::Decl *decl) {
VAST_UNREACHABLE("unsupported decl: {0}", decl->getDeclKindName());
VAST_FATAL("unsupported decl: {0}", decl->getDeclKindName());
}
};

template< typename derived_t >
struct unreach_type_visitor {
mlir_type Visit(clang::QualType type) {
VAST_UNREACHABLE("unsupported type: {0}", type.getAsString());
VAST_FATAL("unsupported type: {0}", type.getAsString());
}

mlir_type Visit(const clang::Type *type) {
VAST_UNREACHABLE("unsupported type: {0}", type->getTypeClassName());
VAST_FATAL("unsupported type: {0}", type->getTypeClassName());
}
};

template< typename derived_t >
struct unreach_attr_visitor {
mlir_attr Visit(const clang::Attr *attr) {
VAST_UNREACHABLE("unsupported attr: {0}", attr->getSpelling());
VAST_FATAL("unsupported attr: {0}", attr->getSpelling());
}
};

Expand Down
2 changes: 1 addition & 1 deletion include/vast/Conversion/TypeConverters/HLToStd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ namespace vast::conv::tc {
case 128:
return mlir::FloatType::getF128(&mctx);
default:
VAST_UNREACHABLE("Cannot lower float bitsize {0}", target_bw);
VAST_FATAL("Cannot lower float bitsize {0}", target_bw);
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion include/vast/Dialect/HighLevel/HighLevelTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace vast::hl
.Case< LongDoubleType >([&] (auto t) { return fty::getF80(ctx); })
.Case< Float128Type >([&] (auto t) { return fty::getF128(ctx); })
.Default([] (auto t) {
VAST_UNREACHABLE("unknown float type: {0}", format_type(t));
VAST_FATAL("unknown float type: {0}", format_type(t));
return mlir_type();
});
}
Expand Down
2 changes: 1 addition & 1 deletion include/vast/Tower/Tower.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace vast::tw {
auto mod = _modules.back().get();

if (mlir::failed(pm.run(mod))) {
VAST_UNREACHABLE("error: some pass in apply() failed");
VAST_FATAL("some pass in apply() failed");
}

handle.mod.walk(loc_rewriter::remove);
Expand Down
2 changes: 1 addition & 1 deletion include/vast/Util/TypeList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace vast::util {
constexpr ret dispatch(mlir_type type, fn &&f)
{
if constexpr ( list::empty ) {
VAST_UNREACHABLE( "missing type to dispatch" );
VAST_FATAL( "missing type to dispatch" );
} else {
using head = typename list::head;

Expand Down
10 changes: 5 additions & 5 deletions include/vast/repl/command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace vast::repl
if (token == "ast") return enum_type::ast;
if (token == "module") return enum_type::module;
if (token == "symbols") return enum_type::symbols;
VAST_UNREACHABLE("uknnown show kind: {0}", token.str());
VAST_FATAL("uknnown show kind: {0}", token.str());
}

enum class meta_action { add, get };
Expand All @@ -69,7 +69,7 @@ namespace vast::repl
enum_type from_string(string_ref token) requires(std::is_same_v< enum_type, meta_action >) {
if (token == "add") return enum_type::add;
if (token == "get") return enum_type::get;
VAST_UNREACHABLE("uknnown action kind: {0}", token.str());
VAST_FATAL("uknnown action kind: {0}", token.str());
}

//
Expand Down Expand Up @@ -112,7 +112,7 @@ namespace vast::repl
template< const char *name, typename params_storage >
auto get_param(const params_storage &params) {
if constexpr (std::tuple_size_v< params_storage > == 0) {
VAST_UNREACHABLE(("unknown param name " + std::string(name)).c_str());
VAST_FATAL(("unknown param name " + std::string(name)).c_str());
} else {
using current = typename std::tuple_element< 0, params_storage >::type;

Expand Down Expand Up @@ -267,7 +267,7 @@ namespace vast::repl
}

if constexpr (params_list::empty) {
VAST_UNREACHABLE(("no match for param: " + tokens.front()).str().c_str());
VAST_FATAL(("no match for param: " + tokens.front()).str().c_str());
} else {
using current_param = typename params_list::head;
using rest = typename params_list::tail;
Expand Down Expand Up @@ -296,7 +296,7 @@ namespace vast::repl

if constexpr (commands::empty) {
// we did not recursivelly match any of known commands
VAST_UNREACHABLE(("no match for command: " + tokens.front()).str().c_str());
VAST_FATAL(("no match for command: " + tokens.front()).str().c_str());
} else {
using current_command = typename commands::head;
using rest = typename commands::tail;
Expand Down
4 changes: 2 additions & 2 deletions lib/vast/CodeGen/CodeGenDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace vast::cg
if (const auto *var = llvm::dyn_cast< clang::VarDecl >(decl))
return build_global_var_definition(var, !var->hasDefinition());

VAST_UNREACHABLE("Invalid argument to buildGlobalDefinition()");
VAST_FATAL("Invalid argument to buildGlobalDefinition()");

}

Expand Down Expand Up @@ -312,7 +312,7 @@ namespace vast::cg
return true;
}

VAST_UNREACHABLE("unsupported value decl");
VAST_UNIMPLEMENTED_MSG("unsupported value decl");
}

void codegen_driver::build_default_methods() {
Expand Down
2 changes: 1 addition & 1 deletion lib/vast/CodeGen/CodeGenStmtVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace vast::hl
case clang::CastKind::CK_MatrixCast: return CastKind::MatrixCast;
}

VAST_UNREACHABLE( "unsupported cast kind" );
VAST_UNIMPLEMENTED_MSG( "unsupported cast kind" );
}

IdentKind ident_kind(const clang::PredefinedExpr *expr)
Expand Down
4 changes: 2 additions & 2 deletions lib/vast/CodeGen/CodeGenTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace vast::cg {
case BuiltinType::UInt128:
return hl::IntegerKind::Int128;
default:
VAST_UNREACHABLE("unknown integer kind");
VAST_UNIMPLEMENTED_MSG("unknown integer kind");
}
}

Expand All @@ -51,7 +51,7 @@ namespace vast::cg {
case BuiltinType::Float128:
return hl::FloatingKind::Float128;
default:
VAST_UNREACHABLE("unknown floating kind");
VAST_UNIMPLEMENTED_MSG("unknown floating kind");
}
}

Expand Down
6 changes: 2 additions & 4 deletions lib/vast/Dialect/Core/Linkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace vast::core {
return true;
}

VAST_UNREACHABLE("No such linkage");
VAST_FATAL("No such linkage");
}

bool is_vardecl_strong_definition(const clang::VarDecl* decl) {
Expand Down Expand Up @@ -149,10 +149,8 @@ namespace vast::core {
case GlobalLinkageKind::PrivateLinkage:
return Visibility::Private;
default:
VAST_UNREACHABLE("unsupported linkage kind {0}", stringifyGlobalLinkageKind(linkage));
VAST_FATAL("unsupported linkage kind {0}", stringifyGlobalLinkageKind(linkage));
}

VAST_UNREACHABLE("missed linkage kind");
}

GlobalLinkageKind get_declarator_linkage(
Expand Down
6 changes: 3 additions & 3 deletions lib/vast/Dialect/HighLevel/HighLevelTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace vast::hl
}
}

VAST_UNREACHABLE("unknown typedef name");
VAST_FATAL("unknown typedef name");
}

auto name_of_record(mlir_type t) -> std::optional< std::string >
Expand All @@ -77,7 +77,7 @@ namespace vast::hl
if (auto ty = type.dyn_cast< TypedefType >())
return getFunctionType(getTypedefType(ty, mod), mod);

VAST_UNREACHABLE("unknown type to extract function type");
VAST_UNIMPLEMENTED_MSG("unknown type to extract function type");
}

core::FunctionType getFunctionType(Value callee) {
Expand All @@ -102,7 +102,7 @@ namespace vast::hl
return getFunctionType(value.getType(), mod);
}

VAST_UNREACHABLE("unknown callee type");
VAST_UNIMPLEMENTED_MSG("unknown callee type");
}


Expand Down
4 changes: 2 additions & 2 deletions lib/vast/Dialect/HighLevel/HighLevelVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace vast::hl
return DeclContextKind::dc_record;
if (mlir::isa< EnumDeclOp >(st))
return DeclContextKind::dc_enum;
VAST_UNREACHABLE("unknown declaration context");
VAST_UNIMPLEMENTED_MSG("unknown declaration context");
}

bool VarDeclOp::isStaticDataMember() {
Expand All @@ -63,7 +63,7 @@ namespace vast::hl
case StorageClass::sc_private_extern: return false;
}

VAST_UNREACHABLE("unknown starage class");
VAST_UNIMPLEMENTED_MSG("unknown starage class");
}

bool VarDeclOp::isStaticLocal() {
Expand Down
2 changes: 1 addition & 1 deletion lib/vast/Frontend/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace vast::cc {
break;
}

VAST_UNREACHABLE("unsupported action type");
VAST_FATAL("unsupported action type");
}

static auto get_output_stream(compiler_instance &ci, string_ref in, output_type act)
Expand Down
9 changes: 4 additions & 5 deletions lib/vast/Frontend/Consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace vast::cc {

if (!vargs.has_option(opt::disable_vast_verifier)) {
if (!codegen->verify_module()) {
VAST_UNREACHABLE("codegen: module verification error before running vast passes");
VAST_FATAL("codegen: module verification error before running vast passes");
}
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ namespace vast::cc {
// diagnostics matched.
if (verify_diagnostics && src_mgr_handler.verify().failed()) {
llvm::sys::RunInterruptHandlers();
VAST_UNREACHABLE("failed mlir codegen");
VAST_FATAL("failed mlir codegen");
}

// Emit remaining defaulted C++ methods
Expand All @@ -233,9 +233,8 @@ namespace vast::cc {
pipeline_source::ast, output_type::emit_mlir, *mctx, vargs, default_pipelines_config()
);

if (mlir::failed(pipeline->run(mod))) {
VAST_UNREACHABLE("MLIR pass manager failed when running vast passes");
}
auto result = pipeline->run(mod);
VAST_CHECK(mlir::succeeded(result), "MLIR pass manager failed when running vast passes");
}

source_language get_source_language(const cc::language_options &opts) {
Expand Down
2 changes: 1 addition & 1 deletion lib/vast/Frontend/Targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace vast::cc {
if (trg == "cir") {
return target_dialect::cir;
}
VAST_UNREACHABLE("Unknown option of target dialect: {0}", trg);
VAST_FATAL("Unknown option of target dialect: {0}", trg);
}

std::string to_string(target_dialect target) {
Expand Down
2 changes: 1 addition & 1 deletion tools/vast-front/compiler_invocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace vast::cc
case EmitAssembly: return std::make_unique< vast::cc::emit_assembly_action >(vargs);
case EmitLLVM: return std::make_unique< vast::cc::emit_llvm_action >(vargs);
case EmitObj: return std::make_unique< vast::cc::emit_obj_action >(vargs);
default: VAST_UNREACHABLE("unsupported frontend action");
default: VAST_UNIMPLEMENTED_MSG("unsupported frontend action");
}

VAST_UNIMPLEMENTED_MSG("not implemented frontend action");
Expand Down
2 changes: 1 addition & 1 deletion tools/vast-repl/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace vast::repl::cmd {
auto th = state.tower->top();
for (auto pass : passes) {
if (mlir::failed(mlir::parsePassPipeline(pass, pm))) {
VAST_UNREACHABLE("error: failed to parse pass pipeline");
VAST_FATAL("failed to parse pass pipeline");
}
th = state.tower->apply(th, pm);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/vast-repl/vast-repl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace vast::repl
auto params = parse_params< cmd::load::command_params >(args);
cli.exec(make_command< cmd::load >(params));
} else {
VAST_UNREACHABLE("unsupported arguments");
VAST_FATAL("unsupported arguments");
}
}

Expand Down

0 comments on commit e97cff4

Please sign in to comment.