@@ -179,13 +179,18 @@ static void emitInterfaceDefMethods(StringRef interfaceQualName,
179179 raw_ostream &os, bool isOpInterface) {
180180 for (auto &method : interface.getMethods ()) {
181181 emitInterfaceMethodDoc (method, os);
182- emitCPPType (method.getReturnType (), os);
182+ auto returnType = method.getReturnType ();
183+ emitCPPType (returnType, os);
183184 os << interfaceQualName << " ::" ;
184185 emitMethodNameAndArgs (method, os, valueType, /* addThisArg=*/ false ,
185186 /* addConst=*/ !isOpInterface);
186187
187188 // Forward to the method on the concrete operation type.
188- os << " {\n return " << implValue << " ->" << method.getName () << ' (' ;
189+ os << " {\n " ;
190+ if (returnType != " void" ) {
191+ os << " return " ;
192+ }
193+ os << implValue << " ->" << method.getName () << ' (' ;
189194 if (!method.isStatic ()) {
190195 os << implValue << " , " ;
191196 os << (isOpInterface ? " getOperation()" : " *this" );
@@ -345,7 +350,8 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
345350
346351 for (auto &method : interface.getMethods ()) {
347352 os << " template<typename " << valueTemplate << " >\n " ;
348- emitCPPType (method.getReturnType (), os);
353+ auto returnType = method.getReturnType ();
354+ emitCPPType (returnType, os);
349355 os << " detail::" << interface.getName () << " InterfaceTraits::Model<"
350356 << valueTemplate << " >::" ;
351357 emitMethodNameAndArgs (method, os, valueType,
@@ -364,10 +370,15 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
364370 }
365371
366372 // Forward to the method on the concrete operation type.
367- if (method.isStatic ())
368- os << " return " << valueTemplate << " ::" ;
369- else
370- os << tblgen::tgfmt (" return $_self." , &nonStaticMethodFmt);
373+ if (returnType != " void" ) {
374+ os << " return " ;
375+ }
376+
377+ if (method.isStatic ()) {
378+ os << valueTemplate << " ::" ;
379+ } else {
380+ os << tblgen::tgfmt (" $_self." , &nonStaticMethodFmt);
381+ }
371382
372383 // Add the arguments to the call.
373384 os << method.getName () << ' (' ;
@@ -379,7 +390,8 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
379390
380391 for (auto &method : interface.getMethods ()) {
381392 os << " template<typename " << valueTemplate << " >\n " ;
382- emitCPPType (method.getReturnType (), os);
393+ auto returnType = method.getReturnType ();
394+ emitCPPType (returnType, os);
383395 os << " detail::" << interface.getName () << " InterfaceTraits::FallbackModel<"
384396 << valueTemplate << " >::" ;
385397 emitMethodNameAndArgs (method, os, valueType,
@@ -388,11 +400,15 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
388400 os << " {\n " ;
389401
390402 // Forward to the method on the concrete Model implementation.
391- if (method.isStatic ())
392- os << " return " << valueTemplate << " ::" ;
393- else
394- os << " return static_cast<const " << valueTemplate << " *>(impl)->" ;
403+ if (returnType != " void" ) {
404+ os << " return " ;
405+ }
395406
407+ if (method.isStatic ()) {
408+ os << valueTemplate << " ::" ;
409+ } else {
410+ os << " static_cast<const " << valueTemplate << " *>(impl)->" ;
411+ }
396412 // Add the arguments to the call.
397413 os << method.getName () << ' (' ;
398414 if (!method.isStatic ())
@@ -430,7 +446,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
430446 if (!method.isStatic ())
431447 os << " const" ;
432448
433- os << " {\n " ;
449+ os << " {\n " ;
434450
435451 // Use the empty context for static methods.
436452 tblgen::FmtContext ctx;
@@ -533,7 +549,7 @@ void InterfaceGenerator::emitInterfaceDecl(const Interface &interface) {
533549 << " struct " << interfaceTraitsName << " {\n " ;
534550 emitConceptDecl (interface);
535551 emitModelDecl (interface);
536- os << " };" ;
552+ os << " };\n " ;
537553
538554 // Emit the derived trait for the interface.
539555 os << " template <typename " << valueTemplate << " >\n " ;
0 commit comments