@@ -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" );
@@ -283,7 +288,8 @@ void InterfaceGenerator::emitModelDecl(const Interface &interface) {
283288void InterfaceGenerator::emitModelMethodsDef (const Interface &interface) {
284289 for (auto &method : interface.getMethods ()) {
285290 os << " template<typename " << valueTemplate << " >\n " ;
286- emitCPPType (method.getReturnType (), os);
291+ auto returnType = method.getReturnType ();
292+ emitCPPType (returnType, os);
287293 os << " detail::" << interface.getName () << " InterfaceTraits::Model<"
288294 << valueTemplate << " >::" ;
289295 emitMethodNameAndArgs (method, os, valueType,
@@ -302,10 +308,15 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
302308 }
303309
304310 // Forward to the method on the concrete operation type.
305- if (method.isStatic ())
306- os << " return " << valueTemplate << " ::" ;
307- else
308- os << tblgen::tgfmt (" return $_self." , &nonStaticMethodFmt);
311+ if (returnType != " void" ) {
312+ os << " return " ;
313+ }
314+
315+ if (method.isStatic ()) {
316+ os << valueTemplate << " ::" ;
317+ } else {
318+ os << tblgen::tgfmt (" $_self." , &nonStaticMethodFmt);
319+ }
309320
310321 // Add the arguments to the call.
311322 os << method.getName () << ' (' ;
@@ -317,7 +328,8 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
317328
318329 for (auto &method : interface.getMethods ()) {
319330 os << " template<typename " << valueTemplate << " >\n " ;
320- emitCPPType (method.getReturnType (), os);
331+ auto returnType = method.getReturnType ();
332+ emitCPPType (returnType, os);
321333 os << " detail::" << interface.getName () << " InterfaceTraits::FallbackModel<"
322334 << valueTemplate << " >::" ;
323335 emitMethodNameAndArgs (method, os, valueType,
@@ -326,11 +338,15 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
326338 os << " {\n " ;
327339
328340 // Forward to the method on the concrete Model implementation.
329- if (method.isStatic ())
330- os << " return " << valueTemplate << " ::" ;
331- else
332- os << " return static_cast<const " << valueTemplate << " *>(impl)->" ;
333-
341+ if (returnType != " void" ) {
342+ os << " return " ;
343+ }
344+
345+ if (method.isStatic ()) {
346+ os << valueTemplate << " ::" ;
347+ } else {
348+ os << " static_cast<const " << valueTemplate << " *>(impl)->" ;
349+ }
334350 // Add the arguments to the call.
335351 os << method.getName () << ' (' ;
336352 if (!method.isStatic ())
@@ -368,7 +384,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
368384 if (!method.isStatic ())
369385 os << " const" ;
370386
371- os << " {\n " ;
387+ os << " {\n " ;
372388
373389 // Use the empty context for static methods.
374390 tblgen::FmtContext ctx;
@@ -443,7 +459,7 @@ void InterfaceGenerator::emitInterfaceDecl(const Interface &interface) {
443459 << " struct " << interfaceTraitsName << " {\n " ;
444460 emitConceptDecl (interface);
445461 emitModelDecl (interface);
446- os << " };" ;
462+ os << " };\n " ;
447463
448464 // Emit the derived trait for the interface.
449465 os << " template <typename " << valueTemplate << " >\n " ;
0 commit comments