From 7338102d46a2aa4ec3dfadd6f63e060ffbc12b1b Mon Sep 17 00:00:00 2001 From: Stefano Sanfilippo Date: Sun, 23 Feb 2020 10:50:57 +0100 Subject: [PATCH] Mark abort builtin as noreturn. --- src/codegen.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index 7a13f71..f47374d 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -168,7 +168,9 @@ llvm::Value* NestedScopes::lookup(const std::string& name) { } void IRGenerator::declareBuiltins() { - module_->getOrInsertFunction("abort", llvm::FunctionType::get(builder_.getVoidTy(), false)); + llvm::FunctionType* abort_type = llvm::FunctionType::get(builder_.getVoidTy(), false); + auto no_return = llvm::AttributeList().addAttribute(context_, 1, llvm::Attribute::NoReturn); + module_->getOrInsertFunction("abort", abort_type, no_return); llvm::FunctionType* printf_type = llvm::FunctionType::get(builder_.getInt32Ty(), {builder_.getInt8PtrTy()}, true); @@ -335,8 +337,8 @@ llvm::Value* IRGenerator::evalBooleanCondition(const Expression* condition_expre auto condition_type = condition->getType(); condition = evalTruthiness(condition); if (!condition) { - error(condition_expression, "cannot convert expression of type", - getSourceType(condition_type), "to boolean."); + error(condition_expression, "cannot convert expression of type", getSourceType(condition_type), + "to boolean."); } return condition; }