[libc-commits] [libc] 5c801de - [libc] Fix WrapperGen seeing no arguments as a void argument.
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Thu Nov 5 11:13:43 PST 2020
Author: Michael Jones
Date: 2020-11-05T19:13:37Z
New Revision: 5c801de13cc2b615e2248be9845190bd1f5ef60f
URL: https://github.com/llvm/llvm-project/commit/5c801de13cc2b615e2248be9845190bd1f5ef60f
DIFF: https://github.com/llvm/llvm-project/commit/5c801de13cc2b615e2248be9845190bd1f5ef60f.diff
LOG: [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
Added:
Modified:
libc/utils/tools/WrapperGen/Main.cpp
Removed:
################################################################################
diff --git a/libc/utils/tools/WrapperGen/Main.cpp b/libc/utils/tools/WrapperGen/Main.cpp
index ae606d1b66fa..0b064bcbb814 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) {
More information about the libc-commits
mailing list