LLVM:运行-创建空输入和输出函数的时间错误

LLVM: run-time error in creating a function of empty input and output

我想在 LLVM IR 中创建一个空函数

void foo(){
}

我用

LLVMContext Context;
std::unique_ptr<Module> Owner(new Module("test", Context));
Module *M = Owner.get();    
Function *foo =
cast<Function>(M->getOrInsertFunction("foo", Type::getVoidTy(Context),
                                      Type::getVoidTy(Context),
                                      (Type *)0));

编译但给我这个错误在运行时间:

llvm-3.7.src/lib/IR/Type.cpp:350: llvm::FunctionType::FunctionType(llvm::Type*, llvm::ArrayRef, bool): 断言`isValidArgumentType(Params[i]) && "Not a valid type for function argument!"' 失败。 * 使用 return 代码崩溃:0 *

知道我们如何在 LLVM 中执行此 void foo(){} 函数吗?

Void 不是有效的参数类型。仅对 return 类型使用 void,然后传入 null 以创建一个空参数列表。