Ignore:
Timestamp:
May 14, 2015, 1:44:55 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
4bf5298
Parents:
d4778a6
Message:

add inline and attribute qualifiers, cfa.y comment formatting, fix error message in isIntegralType

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/SynTree/FunctionDecl.cc

    rd4778a6 rc11e31c  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: FunctionDecl.cc,v 1.15 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
    7 
    81#include <cassert>
    92
     
    147
    158
    16 FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type,
    17                                             CompoundStmt *statements, bool isInline )
    18     : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline )
    19 {
    20     // this is a pretty brazen hack to force the function "main" to have C linkage
    21     if( name == "main" ) {
     9FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline )
     10        : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline ) {
     11    // this is a brazen hack to force the function "main" to have C linkage
     12    if ( name == "main" ) {
    2213        set_linkage( LinkageSpec::C );
    2314    }
     
    2516
    2617FunctionDecl::FunctionDecl( const FunctionDecl &other )
    27     : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ),
    28         isInline( other.isInline )
    29 {
     18    : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), isInline( other.isInline ) {
    3019}
    3120
    32 FunctionDecl::~FunctionDecl()
    33 {
     21FunctionDecl::~FunctionDecl() {
    3422    delete type;
    3523    delete statements;
    3624}
    3725
    38 Type*
    39 FunctionDecl::get_type() const
    40 {
     26Type * FunctionDecl::get_type() const {
    4127    return type;
    4228}
    4329
    44 void
    45 FunctionDecl::set_type(Type *t)
    46 {
     30void FunctionDecl::set_type( Type *t ) {
    4731    type = dynamic_cast< FunctionType* >( t );
    4832    assert( type );
    4933}
    5034
    51 void
    52 FunctionDecl::print( std::ostream &os, int indent ) const
    53 {
     35void FunctionDecl::print( std::ostream &os, int indent ) const {
    5436    using std::endl;
    5537    using std::string;
    5638   
    57     if( get_name() != "" ) {
     39    if ( get_name() != "" ) {
    5840        os << get_name() << ": a ";
    5941    }
    60     if( get_linkage() != LinkageSpec::Cforall ) {
     42    if ( get_linkage() != LinkageSpec::Cforall ) {
    6143        os << LinkageSpec::toString( get_linkage() ) << " ";
    6244    }
    63     if( isInline ) {
     45    if ( isInline ) {
    6446        os << "inline ";
    6547    }
    66     if( get_storageClass() != NoStorageClass ) {
     48    if ( get_storageClass() != NoStorageClass ) {
    6749        os << storageClassName[ get_storageClass() ] << ' ';
    6850    }
    69     if( get_type() ) {
     51    if ( get_type() ) {
    7052        get_type()->print( os, indent );
    7153    } else {
    7254        os << "untyped entity ";
    7355    }
    74     if( !oldIdents.empty() ) {
     56    if ( ! oldIdents.empty() ) {
    7557        os << string( indent+2, ' ' ) << "with parameter names" << endl;
    7658        for( std::list< std::string >::const_iterator i = oldIdents.begin(); i != oldIdents.end(); ++i ) {
     
    7860        }
    7961    }
    80     if( !oldDecls.empty() ) {
     62    if ( ! oldDecls.empty() ) {
    8163        os << string( indent+2, ' ' ) << "with parameter declarations" << endl;
    8264        printAll( oldDecls, os, indent+4 );
    8365    }
    84     if( statements ) {
     66    if ( statements ) {
    8567        os << string( indent+2, ' ' ) << "with body " << endl;
    8668        statements->print( os, indent+4 );
     
    8870}
    8971
    90 void
    91 FunctionDecl::printShort( std::ostream &os, int indent ) const
    92 {
     72void FunctionDecl::printShort( std::ostream &os, int indent ) const {
    9373    using std::endl;
    9474    using std::string;
    9575   
    96     if( get_name() != "" ) {
     76    if ( get_name() != "" ) {
    9777        os << get_name() << ": a ";
    9878    }
    99     if( isInline ) {
     79    if ( isInline ) {
    10080        os << "inline ";
    10181    }
    102     if( get_storageClass() != NoStorageClass ) {
     82    if ( get_storageClass() != NoStorageClass ) {
    10383        os << storageClassName[ get_storageClass() ] << ' ';
    10484    }
    105     if( get_type() ) {
     85    if ( get_type() ) {
    10686        get_type()->print( os, indent );
    10787    } else {
     
    10989    }
    11090}
    111 
Note: See TracChangeset for help on using the changeset viewer.