[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

GitOrigin-RevId: 5c801de13cc2b615e2248be9845190bd1f5ef60f
diff --git a/utils/tools/WrapperGen/Main.cpp b/utils/tools/WrapperGen/Main.cpp
index ae606d1..0b064bc 100644
--- a/utils/tools/WrapperGen/Main.cpp
+++ b/utils/tools/WrapperGen/Main.cpp
@@ -47,6 +47,20 @@
   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) {