Changeset 2bfc6b2 for src/SymTab


Ignore:
Timestamp:
Aug 30, 2018, 1:00:41 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
bcc0946
Parents:
a715b5c
Message:

Refactor FindSpecialDeclarations? and associated special declarations

Location:
src/SymTab
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/SymTab/Autogen.cc

    ra715b5c r2bfc6b2  
    4141
    4242namespace SymTab {
    43         Type * SizeType = 0;
    44 
    4543        /// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype
    4644        struct FuncData {
  • TabularUnified src/SymTab/Autogen.h

    ra715b5c r2bfc6b2  
    3636        /// returns true if obj's name is the empty string and it has a bitfield width
    3737        bool isUnnamedBitfield( ObjectDecl * obj );
    38 
    39         /// size_t type - set when size_t typedef is seen. Useful in a few places,
    40         /// such as in determining array dimension type
    41         extern Type * SizeType;
    42 
    43         /// intrinsic dereference operator for unqualified types - set when *? function is seen in FindSpecialDeclarations.
    44         /// Useful for creating dereference ApplicationExprs without a full resolver pass.
    45         extern FunctionDecl * dereferenceOperator;
    4638
    4739        /// generate the type of an assignment function for paramType.
  • TabularUnified src/SymTab/Validate.cc

    ra715b5c r2bfc6b2  
    7575#include "SynTree/Visitor.h"           // for Visitor
    7676#include "Validate/HandleAttributes.h" // for handleAttributes
     77#include "Validate/FindSpecialDecls.h" // for FindSpecialDecls
    7778
    7879class CompoundStmt;
     
    287288        };
    288289
    289         FunctionDecl * dereferenceOperator = nullptr;
    290         struct FindSpecialDeclarations final {
    291                 void previsit( FunctionDecl * funcDecl );
    292         };
    293 
    294290        void validate( std::list< Declaration * > &translationUnit, __attribute__((unused)) bool doDebug ) {
    295291                PassVisitor<EnumAndPointerDecay> epc;
     
    298294                PassVisitor<CompoundLiteral> compoundliteral;
    299295                PassVisitor<ValidateGenericParameters> genericParams;
    300                 PassVisitor<FindSpecialDeclarations> finder;
    301296                PassVisitor<LabelAddressFixer> labelAddrFixer;
    302297                PassVisitor<HoistTypeDecls> hoistDecls;
     
    325320                FixObjectType::fix( translationUnit );
    326321                ArrayLength::computeLength( translationUnit );
    327                 acceptAll( translationUnit, finder ); // xxx - remove this pass soon
     322                Validate::findSpecialDecls( translationUnit );
    328323                mutateAll( translationUnit, labelAddrFixer );
    329324                Validate::handleAttributes( translationUnit );
     
    901896                if ( eliminator.pass.typedefNames.count( "size_t" ) ) {
    902897                        // grab and remember declaration of size_t
    903                         SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone();
     898                        Validate::SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone();
    904899                } else {
    905900                        // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong
    906901                        // eventually should have a warning for this case.
    907                         SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
     902                        Validate::SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    908903                }
    909904        }
     
    12931288                        // need to resolve array dimensions early so that constructor code can correctly determine
    12941289                        // if a type is a VLA (and hence whether its elements need to be constructed)
    1295                         ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer );
     1290                        ResolvExpr::findSingleExpression( type->dimension, Validate::SizeType->clone(), indexer );
    12961291
    12971292                        // must re-evaluate whether a type is a VLA, now that more information is available
     
    13301325                return addrExpr;
    13311326        }
    1332 
    1333         void FindSpecialDeclarations::previsit( FunctionDecl * funcDecl ) {
    1334                 if ( ! dereferenceOperator ) {
    1335                         // find and remember the intrinsic dereference operator for object pointers
    1336                         if ( funcDecl->name == "*?" && funcDecl->linkage == LinkageSpec::Intrinsic ) {
    1337                                 FunctionType * ftype = funcDecl->type;
    1338                                 if ( ftype->parameters.size() == 1 ) {
    1339                                         PointerType * ptrType = strict_dynamic_cast<PointerType *>( ftype->parameters.front()->get_type() );
    1340                                         if ( ptrType->base->get_qualifiers() == Type::Qualifiers() ) {
    1341                                                 TypeInstType * inst = dynamic_cast<TypeInstType *>( ptrType->base );
    1342                                                 if ( inst && ! inst->get_isFtype() ) {
    1343                                                         dereferenceOperator = funcDecl;
    1344                                                 }
    1345                                         }
    1346                                 }
    1347                         }
    1348                 }
    1349         }
    13501327} // namespace SymTab
    13511328
Note: See TracChangeset for help on using the changeset viewer.