Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r09867ec r98538288  
    6464#include "Common/UniqueName.h"         // for UniqueName
    6565#include "Common/utility.h"            // for operator+, cloneAll, deleteAll
    66 #include "CompilationState.h"          // skip some passes in new-ast build
    6766#include "Concurrency/Keywords.h"      // for applyKeywords
    6867#include "FixFunction.h"               // for FixFunction
     
    271270        };
    272271
    273         struct InitializerLength {
     272        struct ArrayLength : public WithIndexer {
    274273                /// for array types without an explicit length, compute the length and store it so that it
    275274                /// is known to the rest of the phases. For example,
     
    282281
    283282                void previsit( ObjectDecl * objDecl );
    284         };
    285 
    286         struct ArrayLength : public WithIndexer {
    287                 static void computeLength( std::list< Declaration * > & translationUnit );
    288 
    289283                void previsit( ArrayType * arrayType );
    290284        };
     
    374368                                mutateAll( translationUnit, compoundliteral );
    375369                        });
    376                         if (!useNewAST) {
    377                                 Stats::Time::TimeBlock("Resolve With Expressions", [&]() {
    378                                         ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables
    379                                 });
    380                         }
     370                        Stats::Time::TimeBlock("Resolve With Expressions", [&]() {
     371                                ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables
     372                        });
    381373                }
    382374                {
    383375                        Stats::Heap::newPass("validate-F");
    384376                        Stats::Time::BlockGuard guard("validate-F");
    385                         if (!useNewAST) {
    386                                 Stats::Time::TimeCall("Fix Object Type",
    387                                         FixObjectType::fix, translationUnit);
    388                         }
    389                         Stats::Time::TimeCall("Initializer Length",
    390                                 InitializerLength::computeLength, translationUnit);
    391                         if (!useNewAST) {
    392                                 Stats::Time::TimeCall("Array Length",
    393                                         ArrayLength::computeLength, translationUnit);
    394                         }
     377                        Stats::Time::TimeCall("Fix Object Type",
     378                                FixObjectType::fix, translationUnit);
     379                        Stats::Time::TimeCall("Array Length",
     380                                ArrayLength::computeLength, translationUnit);
    395381                        Stats::Time::TimeCall("Find Special Declarations",
    396382                                Validate::findSpecialDecls, translationUnit);
    397383                        Stats::Time::TimeCall("Fix Label Address",
    398384                                mutateAll<LabelAddressFixer>, translationUnit, labelAddrFixer);
    399                         if (!useNewAST) {
    400                                 Stats::Time::TimeCall("Handle Attributes",
    401                                         Validate::handleAttributes, translationUnit);
    402                         }
     385                        Stats::Time::TimeCall("Handle Attributes",
     386                                Validate::handleAttributes, translationUnit);
    403387                }
    404388        }
     
    976960        }
    977961
    978         static bool isNonParameterAttribute( Attribute * attr ) {
    979                 static const std::vector<std::string> bad_names = {
    980                         "aligned", "__aligned__",
    981                 };
    982                 for ( auto name : bad_names ) {
    983                         if ( name == attr->name ) {
    984                                 return true;
    985                         }
    986                 }
    987                 return false;
    988         }
    989 
    990962        Type * ReplaceTypedef::postmutate( TypeInstType * typeInst ) {
    991963                // instances of typedef types will come here. If it is an instance
     
    996968                        ret->location = typeInst->location;
    997969                        ret->get_qualifiers() |= typeInst->get_qualifiers();
    998                         // GCC ignores certain attributes if they arrive by typedef, this mimics that.
    999                         if ( inFunctionType ) {
    1000                                 ret->attributes.remove_if( isNonParameterAttribute );
    1001                         }
    1002                         ret->attributes.splice( ret->attributes.end(), typeInst->attributes );
     970                        // attributes are not carried over from typedef to function parameters/return values
     971                        if ( ! inFunctionType ) {
     972                                ret->attributes.splice( ret->attributes.end(), typeInst->attributes );
     973                        } else {
     974                                deleteAll( ret->attributes );
     975                                ret->attributes.clear();
     976                        }
    1003977                        // place instance parameters on the typedef'd type
    1004978                        if ( ! typeInst->parameters.empty() ) {
     
    13411315        }
    13421316
    1343         void InitializerLength::computeLength( std::list< Declaration * > & translationUnit ) {
    1344                 PassVisitor<InitializerLength> len;
    1345                 acceptAll( translationUnit, len );
    1346         }
    1347 
    13481317        void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) {
    13491318                PassVisitor<ArrayLength> len;
     
    13511320        }
    13521321
    1353         void InitializerLength::previsit( ObjectDecl * objDecl ) {
     1322        void ArrayLength::previsit( ObjectDecl * objDecl ) {
    13541323                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) {
    13551324                        if ( at->dimension ) return;
     
    14051374        /// Replaces enum types by int, and function/array types in function parameter and return
    14061375        /// lists by appropriate pointers
    1407         /*
    14081376        struct EnumAndPointerDecay_new {
    14091377                const ast::EnumDecl * previsit( const ast::EnumDecl * enumDecl ) {
     
    14561424                }
    14571425        };
    1458         */
    14591426
    14601427        /// expand assertions from a trait instance, performing appropriate type variable substitutions
     
    14751442        }
    14761443
    1477         /*
    1478 
    14791444        /// Associates forward declarations of aggregates with their definitions
    14801445        class LinkReferenceToTypes_new final
     
    15431508                }
    15441509
    1545                 void checkGenericParameters( const ast::BaseInstType * inst ) {
     1510                void checkGenericParameters( const ast::ReferenceToType * inst ) {
    15461511                        for ( const ast::Expr * param : inst->params ) {
    15471512                                if ( ! dynamic_cast< const ast::TypeExpr * >( param ) ) {
     
    18071772                static const node_t * forallFixer(
    18081773                        const CodeLocation & loc, const node_t * node,
    1809                         ast::FunctionType::ForallList parent_t::* forallField
     1774                        ast::ParameterizedType::ForallList parent_t::* forallField
    18101775                ) {
    18111776                        for ( unsigned i = 0; i < (node->* forallField).size(); ++i ) {
     
    18581823                }
    18591824        };
    1860         */
    18611825} // anonymous namespace
    18621826
    1863 /*
    18641827const ast::Type * validateType(
    18651828                const CodeLocation & loc, const ast::Type * type, const ast::SymbolTable & symtab ) {
    1866         // ast::Pass< EnumAndPointerDecay_new > epc;
     1829        ast::Pass< EnumAndPointerDecay_new > epc;
    18671830        ast::Pass< LinkReferenceToTypes_new > lrt{ loc, symtab };
    18681831        ast::Pass< ForallPointerDecay_new > fpd{ loc };
    18691832
    1870         return type->accept( lrt )->accept( fpd );
     1833        return type->accept( epc )->accept( lrt )->accept( fpd );
    18711834}
    1872 */
    18731835
    18741836} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.