@@ -167,15 +167,20 @@ static void emitInterfaceDef(const Interface &interface, StringRef valueType,
167167 // Insert the method definitions.
168168 bool isOpInterface = isa<OpInterface>(interface);
169169 for (auto &method : interface.getMethods ()) {
170- emitCPPType (method.getReturnType (), os);
170+ auto returnType = method.getReturnType ();
171+ emitCPPType (returnType, os);
171172 if (!cppNamespace.empty ())
172173 os << cppNamespace << " ::" ;
173174 os << interfaceName << " ::" ;
174175 emitMethodNameAndArgs (method, os, valueType, /* addThisArg=*/ false ,
175176 /* addConst=*/ !isOpInterface);
176177
177178 // Forward to the method on the concrete operation type.
178- os << " {\n return getImpl()->" << method.getName () << ' (' ;
179+ os << " {\n " ;
180+ if (returnType != " void" ) {
181+ os << " return " ;
182+ }
183+ os << " getImpl()->" << method.getName () << ' (' ;
179184 if (!method.isStatic ()) {
180185 os << " getImpl(), " ;
181186 os << (isOpInterface ? " getOperation()" : " *this" );
@@ -284,7 +289,8 @@ void InterfaceGenerator::emitModelDecl(const Interface &interface) {
284289void InterfaceGenerator::emitModelMethodsDef (const Interface &interface) {
285290 for (auto &method : interface.getMethods ()) {
286291 os << " template<typename " << valueTemplate << " >\n " ;
287- emitCPPType (method.getReturnType (), os);
292+ auto returnType = method.getReturnType ();
293+ emitCPPType (returnType, os);
288294 os << " detail::" << interface.getName () << " InterfaceTraits::Model<"
289295 << valueTemplate << " >::" ;
290296 emitMethodNameAndArgs (method, os, valueType,
@@ -303,10 +309,15 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
303309 }
304310
305311 // Forward to the method on the concrete operation type.
306- if (method.isStatic ())
307- os << " return " << valueTemplate << " ::" ;
308- else
309- os << tblgen::tgfmt (" return $_self." , &nonStaticMethodFmt);
312+ if (returnType != " void" ) {
313+ os << " return " ;
314+ }
315+
316+ if (method.isStatic ()) {
317+ os << valueTemplate << " ::" ;
318+ } else {
319+ os << tblgen::tgfmt (" $_self." , &nonStaticMethodFmt);
320+ }
310321
311322 // Add the arguments to the call.
312323 os << method.getName () << ' (' ;
@@ -318,7 +329,8 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
318329
319330 for (auto &method : interface.getMethods ()) {
320331 os << " template<typename " << valueTemplate << " >\n " ;
321- emitCPPType (method.getReturnType (), os);
332+ auto returnType = method.getReturnType ();
333+ emitCPPType (returnType, os);
322334 os << " detail::" << interface.getName () << " InterfaceTraits::FallbackModel<"
323335 << valueTemplate << " >::" ;
324336 emitMethodNameAndArgs (method, os, valueType,
@@ -327,11 +339,15 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
327339 os << " {\n " ;
328340
329341 // Forward to the method on the concrete Model implementation.
330- if (method.isStatic ())
331- os << " return " << valueTemplate << " ::" ;
332- else
333- os << " return static_cast<const " << valueTemplate << " *>(impl)->" ;
334-
342+ if (returnType != " void" ) {
343+ os << " return " ;
344+ }
345+
346+ if (method.isStatic ()) {
347+ os << valueTemplate << " ::" ;
348+ } else {
349+ os << " static_cast<const " << valueTemplate << " *>(impl)->" ;
350+ }
335351 // Add the arguments to the call.
336352 os << method.getName () << ' (' ;
337353 if (!method.isStatic ())
@@ -369,7 +385,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
369385 if (!method.isStatic ())
370386 os << " const" ;
371387
372- os << " {\n " ;
388+ os << " {\n " ;
373389
374390 // Use the empty context for static methods.
375391 tblgen::FmtContext ctx;
@@ -447,7 +463,7 @@ void InterfaceGenerator::emitInterfaceDecl(const Interface &interface) {
447463 << " struct " << interfaceTraitsName << " {\n " ;
448464 emitConceptDecl (interface);
449465 emitModelDecl (interface);
450- os << " };" ;
466+ os << " };\n " ;
451467
452468 // Emit the derived trait for the interface.
453469 os << " template <typename " << valueTemplate << " >\n " ;
0 commit comments