Skip to content

Commit 471effa

Browse files
committed
treewide: Fix unreachable to more appropriate macros.
1 parent 41f7b11 commit 471effa

22 files changed

+43
-46
lines changed

include/vast/CodeGen/CodeGen.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ namespace vast::cg
450450
VAST_UNIMPLEMENTED;
451451
} else if (body) {
452452
if (mlir::failed(build_function_body(body))) {
453-
VAST_UNREACHABLE("failed function body codegen");
453+
VAST_FATAL("failed function body codegen");
454454
}
455455
} else {
456456
VAST_UNIMPLEMENTED_MSG("no definition for emitted function");

include/vast/CodeGen/CodeGenContext.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ namespace vast::cg
215215
if (const auto *d = llvm::dyn_cast< clang::NamedDecl >(dctx)) {
216216
name += get_decl_name(d);
217217
} else {
218-
VAST_UNREACHABLE("unknown decl context: {0}", dctx->getDeclKindName());
218+
VAST_FATAL("unknown decl context: {0}", dctx->getDeclKindName());
219219
}
220220

221221
name += "::";

include/vast/CodeGen/CodeGenDeclVisitor.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ namespace vast::cg {
185185
return fn;
186186
}
187187

188-
VAST_UNREACHABLE("NYI");
188+
VAST_UNIMPLEMENTED;
189189

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

285-
VAST_UNREACHABLE("codegen of incomplete function");
285+
VAST_FATAL("codegen of incomplete function");
286286
}
287287

288288
vast_function get_addr_of_function(
@@ -486,7 +486,7 @@ namespace vast::cg {
486486
case clang::SC_PrivateExtern: return hl::StorageClass::sc_private_extern;
487487
case clang::SC_Register: return hl::StorageClass::sc_register;
488488
}
489-
VAST_UNREACHABLE("unknown storage class");
489+
VAST_UNIMPLEMENTED_MSG("unknown storage class");
490490
}
491491

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

502502
operation VisitVarDecl(const clang::VarDecl *decl) {
@@ -713,7 +713,7 @@ namespace vast::cg {
713713
case clang::AccessSpecifier::AS_none:
714714
return hl::AccessSpecifier::as_none;
715715
}
716-
VAST_UNREACHABLE("unknown access specifier");
716+
VAST_UNIMPLEMENTED_MSG("unknown access specifier");
717717
}
718718

719719
//

include/vast/CodeGen/CodeGenStmtVisitor.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ namespace vast::cg {
747747
return VisitFunctionDeclRefExpr(expr);
748748
}
749749

750-
VAST_UNREACHABLE("unknown underlying declaration to be referenced");
750+
VAST_UNIMPLEMENTED_MSG("unknown underlying declaration to be referenced");
751751
}
752752

753753
Operation *VisitPredefinedExpr(const clang::PredefinedExpr *expr)

include/vast/CodeGen/UnreachableVisitor.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@ namespace vast::cg
99
template< typename derived_t >
1010
struct unreach_stmt_visitor {
1111
operation Visit(const clang::Stmt *stmt) {
12-
VAST_UNREACHABLE("unsupported stmt: {0}", stmt->getStmtClassName());
12+
VAST_FATAL("unsupported stmt: {0}", stmt->getStmtClassName());
1313
}
1414
};
1515

1616
template< typename derived_t >
1717
struct unreach_decl_visitor {
1818
operation Visit(const clang::Decl *decl) {
19-
VAST_UNREACHABLE("unsupported decl: {0}", decl->getDeclKindName());
19+
VAST_FATAL("unsupported decl: {0}", decl->getDeclKindName());
2020
}
2121
};
2222

2323
template< typename derived_t >
2424
struct unreach_type_visitor {
2525
mlir_type Visit(clang::QualType type) {
26-
VAST_UNREACHABLE("unsupported type: {0}", type.getAsString());
26+
VAST_FATAL("unsupported type: {0}", type.getAsString());
2727
}
2828

2929
mlir_type Visit(const clang::Type *type) {
30-
VAST_UNREACHABLE("unsupported type: {0}", type->getTypeClassName());
30+
VAST_FATAL("unsupported type: {0}", type->getTypeClassName());
3131
}
3232
};
3333

3434
template< typename derived_t >
3535
struct unreach_attr_visitor {
3636
mlir_attr Visit(const clang::Attr *attr) {
37-
VAST_UNREACHABLE("unsupported attr: {0}", attr->getSpelling());
37+
VAST_FATAL("unsupported attr: {0}", attr->getSpelling());
3838
}
3939
};
4040

include/vast/Conversion/TypeConverters/HLToStd.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ namespace vast::conv::tc {
227227
case 128:
228228
return mlir::FloatType::getF128(&mctx);
229229
default:
230-
VAST_UNREACHABLE("Cannot lower float bitsize {0}", target_bw);
230+
VAST_FATAL("Cannot lower float bitsize {0}", target_bw);
231231
}
232232
};
233233
}

include/vast/Dialect/HighLevel/HighLevelTypes.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ namespace vast::hl
166166
.Case< LongDoubleType >([&] (auto t) { return fty::getF80(ctx); })
167167
.Case< Float128Type >([&] (auto t) { return fty::getF128(ctx); })
168168
.Default([] (auto t) {
169-
VAST_UNREACHABLE("unknown float type: {0}", format_type(t));
169+
VAST_FATAL("unknown float type: {0}", format_type(t));
170170
return mlir_type();
171171
});
172172
}

include/vast/Tower/Tower.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace vast::tw {
4646
auto mod = _modules.back().get();
4747

4848
if (mlir::failed(pm.run(mod))) {
49-
VAST_UNREACHABLE("error: some pass in apply() failed");
49+
VAST_FATAL("some pass in apply() failed");
5050
}
5151

5252
handle.mod.walk(loc_rewriter::remove);

include/vast/Util/TypeList.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ namespace vast::util {
158158
constexpr ret dispatch(mlir_type type, fn &&f)
159159
{
160160
if constexpr ( list::empty ) {
161-
VAST_UNREACHABLE( "missing type to dispatch" );
161+
VAST_FATAL( "missing type to dispatch" );
162162
} else {
163163
using head = typename list::head;
164164

include/vast/repl/command.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace vast::repl
6060
if (token == "ast") return enum_type::ast;
6161
if (token == "module") return enum_type::module;
6262
if (token == "symbols") return enum_type::symbols;
63-
VAST_UNREACHABLE("uknnown show kind: {0}", token.str());
63+
VAST_FATAL("uknnown show kind: {0}", token.str());
6464
}
6565

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

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

@@ -267,7 +267,7 @@ namespace vast::repl
267267
}
268268

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

297297
if constexpr (commands::empty) {
298298
// we did not recursivelly match any of known commands
299-
VAST_UNREACHABLE(("no match for command: " + tokens.front()).str().c_str());
299+
VAST_FATAL(("no match for command: " + tokens.front()).str().c_str());
300300
} else {
301301
using current_command = typename commands::head;
302302
using rest = typename commands::tail;

lib/vast/CodeGen/CodeGenDriver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ namespace vast::cg
163163
if (const auto *var = llvm::dyn_cast< clang::VarDecl >(decl))
164164
return build_global_var_definition(var, !var->hasDefinition());
165165

166-
VAST_UNREACHABLE("Invalid argument to buildGlobalDefinition()");
166+
VAST_FATAL("Invalid argument to buildGlobalDefinition()");
167167

168168
}
169169

@@ -312,7 +312,7 @@ namespace vast::cg
312312
return true;
313313
}
314314

315-
VAST_UNREACHABLE("unsupported value decl");
315+
VAST_UNIMPLEMENTED_MSG("unsupported value decl");
316316
}
317317

318318
void codegen_driver::build_default_methods() {

lib/vast/CodeGen/CodeGenStmtVisitor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace vast::hl
8686
case clang::CastKind::CK_MatrixCast: return CastKind::MatrixCast;
8787
}
8888

89-
VAST_UNREACHABLE( "unsupported cast kind" );
89+
VAST_UNIMPLEMENTED_MSG( "unsupported cast kind" );
9090
}
9191

9292
IdentKind ident_kind(const clang::PredefinedExpr *expr)

lib/vast/CodeGen/CodeGenTypeVisitor.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace vast::cg {
3030
case BuiltinType::UInt128:
3131
return hl::IntegerKind::Int128;
3232
default:
33-
VAST_UNREACHABLE("unknown integer kind");
33+
VAST_UNIMPLEMENTED_MSG("unknown integer kind");
3434
}
3535
}
3636

@@ -51,7 +51,7 @@ namespace vast::cg {
5151
case BuiltinType::Float128:
5252
return hl::FloatingKind::Float128;
5353
default:
54-
VAST_UNREACHABLE("unknown floating kind");
54+
VAST_UNIMPLEMENTED_MSG("unknown floating kind");
5555
}
5656
}
5757

lib/vast/Dialect/Core/Linkage.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace vast::core {
3939
return true;
4040
}
4141

42-
VAST_UNREACHABLE("No such linkage");
42+
VAST_FATAL("No such linkage");
4343
}
4444

4545
bool is_vardecl_strong_definition(const clang::VarDecl* decl) {
@@ -149,10 +149,8 @@ namespace vast::core {
149149
case GlobalLinkageKind::PrivateLinkage:
150150
return Visibility::Private;
151151
default:
152-
VAST_UNREACHABLE("unsupported linkage kind {0}", stringifyGlobalLinkageKind(linkage));
152+
VAST_FATAL("unsupported linkage kind {0}", stringifyGlobalLinkageKind(linkage));
153153
}
154-
155-
VAST_UNREACHABLE("missed linkage kind");
156154
}
157155

158156
GlobalLinkageKind get_declarator_linkage(

lib/vast/Dialect/HighLevel/HighLevelTypes.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace vast::hl
5757
}
5858
}
5959

60-
VAST_UNREACHABLE("unknown typedef name");
60+
VAST_FATAL("unknown typedef name");
6161
}
6262

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

80-
VAST_UNREACHABLE("unknown type to extract function type");
80+
VAST_UNIMPLEMENTED_MSG("unknown type to extract function type");
8181
}
8282

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

105-
VAST_UNREACHABLE("unknown callee type");
105+
VAST_UNIMPLEMENTED_MSG("unknown callee type");
106106
}
107107

108108

lib/vast/Dialect/HighLevel/HighLevelVar.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace vast::hl
3838
return DeclContextKind::dc_record;
3939
if (mlir::isa< EnumDeclOp >(st))
4040
return DeclContextKind::dc_enum;
41-
VAST_UNREACHABLE("unknown declaration context");
41+
VAST_UNIMPLEMENTED_MSG("unknown declaration context");
4242
}
4343

4444
bool VarDeclOp::isStaticDataMember() {
@@ -63,7 +63,7 @@ namespace vast::hl
6363
case StorageClass::sc_private_extern: return false;
6464
}
6565

66-
VAST_UNREACHABLE("unknown starage class");
66+
VAST_UNIMPLEMENTED_MSG("unknown starage class");
6767
}
6868

6969
bool VarDeclOp::isStaticLocal() {

lib/vast/Frontend/Action.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace vast::cc {
4444
break;
4545
}
4646

47-
VAST_UNREACHABLE("unsupported action type");
47+
VAST_FATAL("unsupported action type");
4848
}
4949

5050
static auto get_output_stream(compiler_instance &ci, string_ref in, output_type act)

lib/vast/Frontend/Consumer.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace vast::cc {
7979

8080
if (!vargs.has_option(opt::disable_vast_verifier)) {
8181
if (!codegen->verify_module()) {
82-
VAST_UNREACHABLE("codegen: module verification error before running vast passes");
82+
VAST_FATAL("codegen: module verification error before running vast passes");
8383
}
8484
}
8585
}
@@ -213,7 +213,7 @@ namespace vast::cc {
213213
// diagnostics matched.
214214
if (verify_diagnostics && src_mgr_handler.verify().failed()) {
215215
llvm::sys::RunInterruptHandlers();
216-
VAST_UNREACHABLE("failed mlir codegen");
216+
VAST_FATAL("failed mlir codegen");
217217
}
218218

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

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

241240
source_language get_source_language(const cc::language_options &opts) {

lib/vast/Frontend/Targets.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace vast::cc {
1515
if (trg == "cir") {
1616
return target_dialect::cir;
1717
}
18-
VAST_UNREACHABLE("Unknown option of target dialect: {0}", trg);
18+
VAST_FATAL("Unknown option of target dialect: {0}", trg);
1919
}
2020

2121
std::string to_string(target_dialect target) {

tools/vast-front/compiler_invocation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace vast::cc
5151
case EmitAssembly: return std::make_unique< vast::cc::emit_assembly_action >(vargs);
5252
case EmitLLVM: return std::make_unique< vast::cc::emit_llvm_action >(vargs);
5353
case EmitObj: return std::make_unique< vast::cc::emit_obj_action >(vargs);
54-
default: VAST_UNREACHABLE("unsupported frontend action");
54+
default: VAST_UNIMPLEMENTED_MSG("unsupported frontend action");
5555
}
5656

5757
VAST_UNIMPLEMENTED_MSG("not implemented frontend action");

tools/vast-repl/command.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace vast::repl::cmd {
145145
auto th = state.tower->top();
146146
for (auto pass : passes) {
147147
if (mlir::failed(mlir::parsePassPipeline(pass, pm))) {
148-
VAST_UNREACHABLE("error: failed to parse pass pipeline");
148+
VAST_FATAL("failed to parse pass pipeline");
149149
}
150150
th = state.tower->apply(th, pm);
151151
}

tools/vast-repl/vast-repl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace vast::repl
4444
auto params = parse_params< cmd::load::command_params >(args);
4545
cli.exec(make_command< cmd::load >(params));
4646
} else {
47-
VAST_UNREACHABLE("unsupported arguments");
47+
VAST_FATAL("unsupported arguments");
4848
}
4949
}
5050

0 commit comments

Comments
 (0)