Ignore:
Timestamp:
Jan 7, 2021, 3:27:00 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2b4daf2, 64aeca0
Parents:
3c64c668 (diff), eef8dfb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into park_unpark

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r3c64c668 r58fe85a  
    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
    6667#include "Concurrency/Keywords.h"      // for applyKeywords
    6768#include "FixFunction.h"               // for FixFunction
     
    270271        };
    271272
    272         struct ArrayLength : public WithIndexer {
     273        struct InitializerLength {
    273274                /// for array types without an explicit length, compute the length and store it so that it
    274275                /// is known to the rest of the phases. For example,
     
    281282
    282283                void previsit( ObjectDecl * objDecl );
     284        };
     285
     286        struct ArrayLength : public WithIndexer {
     287                static void computeLength( std::list< Declaration * > & translationUnit );
     288
    283289                void previsit( ArrayType * arrayType );
    284290        };
     
    368374                                mutateAll( translationUnit, compoundliteral );
    369375                        });
    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                         });
     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                        }
    373381                }
    374382                {
    375383                        Stats::Heap::newPass("validate-F");
    376384                        Stats::Time::BlockGuard guard("validate-F");
    377                         Stats::Time::TimeCall("Fix Object Type",
    378                                 FixObjectType::fix, translationUnit);
    379                         Stats::Time::TimeCall("Array Length",
    380                                 ArrayLength::computeLength, translationUnit);
     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                        }
    381395                        Stats::Time::TimeCall("Find Special Declarations",
    382396                                Validate::findSpecialDecls, translationUnit);
    383397                        Stats::Time::TimeCall("Fix Label Address",
    384398                                mutateAll<LabelAddressFixer>, translationUnit, labelAddrFixer);
    385                         Stats::Time::TimeCall("Handle Attributes",
    386                                 Validate::handleAttributes, translationUnit);
     399                        if (!useNewAST) {
     400                                Stats::Time::TimeCall("Handle Attributes",
     401                                        Validate::handleAttributes, translationUnit);
     402                        }
    387403                }
    388404        }
     
    960976        }
    961977
     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
    962990        Type * ReplaceTypedef::postmutate( TypeInstType * typeInst ) {
    963991                // instances of typedef types will come here. If it is an instance
     
    968996                        ret->location = typeInst->location;
    969997                        ret->get_qualifiers() |= typeInst->get_qualifiers();
    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                         }
     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 );
    9771003                        // place instance parameters on the typedef'd type
    9781004                        if ( ! typeInst->parameters.empty() ) {
     
    13151341        }
    13161342
     1343        void InitializerLength::computeLength( std::list< Declaration * > & translationUnit ) {
     1344                PassVisitor<InitializerLength> len;
     1345                acceptAll( translationUnit, len );
     1346        }
     1347
    13171348        void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) {
    13181349                PassVisitor<ArrayLength> len;
     
    13201351        }
    13211352
    1322         void ArrayLength::previsit( ObjectDecl * objDecl ) {
     1353        void InitializerLength::previsit( ObjectDecl * objDecl ) {
    13231354                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) {
    13241355                        if ( at->dimension ) return;
     
    13741405        /// Replaces enum types by int, and function/array types in function parameter and return
    13751406        /// lists by appropriate pointers
     1407        /*
    13761408        struct EnumAndPointerDecay_new {
    13771409                const ast::EnumDecl * previsit( const ast::EnumDecl * enumDecl ) {
     
    14241456                }
    14251457        };
     1458        */
    14261459
    14271460        /// expand assertions from a trait instance, performing appropriate type variable substitutions
     
    14421475        }
    14431476
     1477        /*
     1478
    14441479        /// Associates forward declarations of aggregates with their definitions
    14451480        class LinkReferenceToTypes_new final
     
    15081543                }
    15091544
    1510                 void checkGenericParameters( const ast::ReferenceToType * inst ) {
     1545                void checkGenericParameters( const ast::BaseInstType * inst ) {
    15111546                        for ( const ast::Expr * param : inst->params ) {
    15121547                                if ( ! dynamic_cast< const ast::TypeExpr * >( param ) ) {
     
    17721807                static const node_t * forallFixer(
    17731808                        const CodeLocation & loc, const node_t * node,
    1774                         ast::ParameterizedType::ForallList parent_t::* forallField
     1809                        ast::FunctionType::ForallList parent_t::* forallField
    17751810                ) {
    17761811                        for ( unsigned i = 0; i < (node->* forallField).size(); ++i ) {
     
    18231858                }
    18241859        };
     1860        */
    18251861} // anonymous namespace
    18261862
     1863/*
    18271864const ast::Type * validateType(
    18281865                const CodeLocation & loc, const ast::Type * type, const ast::SymbolTable & symtab ) {
    1829         ast::Pass< EnumAndPointerDecay_new > epc;
     1866        // ast::Pass< EnumAndPointerDecay_new > epc;
    18301867        ast::Pass< LinkReferenceToTypes_new > lrt{ loc, symtab };
    18311868        ast::Pass< ForallPointerDecay_new > fpd{ loc };
    18321869
    1833         return type->accept( epc )->accept( lrt )->accept( fpd );
     1870        return type->accept( lrt )->accept( fpd );
    18341871}
     1872*/
    18351873
    18361874} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.