From 5c801de13cc2b615e2248be9845190bd1f5ef60f Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Wed, 4 Nov 2020 22:58:25 +0000 Subject: [PATCH] [libc] Fix WrapperGen seeing no arguments as a void argument. This corrects WrapperGen generating incorrect wrappers for functions that take no arguments. Previously it would generate a wrapper with a single argument of type `void`. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D90800 --- libc/utils/tools/WrapperGen/Main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libc/utils/tools/WrapperGen/Main.cpp b/libc/utils/tools/WrapperGen/Main.cpp index ae606d1..0b064bc 100644 --- a/libc/utils/tools/WrapperGen/Main.cpp +++ b/libc/utils/tools/WrapperGen/Main.cpp @@ -47,6 +47,20 @@ static bool WrapperGenMain(llvm::raw_ostream &OS, llvm::RecordKeeper &Records) { for (size_t i = 0; i < ArgsList.size(); ++i) { llvm::Record *ArgType = ArgsList[i]->getValueAsDef("ArgType"); auto TypeName = Indexer.getTypeAsString(ArgType); + + if (TypeName.compare("void") == 0) { + if (ArgsList.size() == 1) { + break; + } else { + // the reason this is a fatal error is that a void argument means this + // function has no arguments; multiple copies of no arguments is an + // error. + llvm::PrintFatalError( + "The specification for function " + FunctionName + + " lists other arguments along with a void argument."); + } + } + OS << TypeName << " " << ArgPrefix << i; CallArgs << ArgPrefix << i; if (i < ArgsList.size() - 1) { -- 2.7.4