Example #1
0
 private IType getReturnType() {
   ICPPASTFunctionDeclarator lambdaDtor = fLambdaExpression.getDeclarator();
   if (lambdaDtor != null) {
     IASTTypeId trailingReturnType = lambdaDtor.getTrailingReturnType();
     if (trailingReturnType != null) {
       return CPPVisitor.createType(trailingReturnType);
     }
   }
   IASTCompoundStatement body = fLambdaExpression.getBody();
   if (body != null) {
     IASTStatement[] stmts = body.getStatements();
     if (stmts.length > 0) {
       // Gnu extension allows to deduce return type in complex compound statements
       IASTStatement stmt = stmts[stmts.length - 1];
       if (stmt instanceof IASTReturnStatement) {
         IASTReturnStatement rtstmt = (IASTReturnStatement) stmt;
         IASTExpression expr = rtstmt.getReturnValue();
         if (expr != null) {
           IType type = expr.getExpressionType();
           type = Conversions.lvalue_to_rvalue(type, false);
           if (type != null) {
             return type;
           }
         }
       }
     }
   }
   return CPPSemantics.VOID_TYPE;
 }
Example #2
0
 private void writeReturnStatement(IASTReturnStatement returnStatement) {
   scribe.noNewLines();
   scribe.print(RETURN);
   IASTExpression returnValue = returnStatement.getReturnValue();
   if (returnValue != null) {
     scribe.printSpaces(1);
     returnValue.accept(visitor);
   }
   scribe.newLines();
   scribe.printSemicolon();
 }