Changeset 7030dab for src/SymTab


Ignore:
Timestamp:
Apr 6, 2020, 4:46:28 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
e3bc51c
Parents:
71d6bd8 (diff), 057298e (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 new-ast

Location:
src/SymTab
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.h

    r71d6bd8 r7030dab  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:50:25 2017
    13 // Update Count     : 15
     12// Last Modified On : Fri Dec 13 16:38:06 2019
     13// Update Count     : 16
    1414//
    1515
     
    3535#include "SynTree/Expression.h"   // for NameExpr, ConstantExpr, UntypedExpr...
    3636#include "SynTree/Type.h"         // for Type, ArrayType, Type::Qualifiers
     37#include "SynTree/Statement.h"    // for CompoundStmt, DeclStmt, ExprStmt
    3738
    3839class CompoundStmt;
  • src/SymTab/Demangle.cc

    r71d6bd8 r7030dab  
    1010// Created On       : Thu Jul 19 12:52:41 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 30 13:46:33 2019
    13 // Update Count     : 3
     12// Last Modified On : Tue Feb 11 15:09:18 2020
     13// Update Count     : 10
    1414//
    1515
     
    1919#include "CodeGen/GenType.h"
    2020#include "Common/PassVisitor.h"
     21#include "Common/utility.h"                                                             // isPrefix
    2122#include "Mangler.h"
    2223#include "SynTree/Type.h"
     
    366367                                // type variable types
    367368                                for (size_t k = 0; k < TypeDecl::NUMBER_OF_KINDS; ++k) {
    368                                         static const std::string typeVariableNames[] = { "DT", "FT", "TT", };
     369                                        static const std::string typeVariableNames[] = { "DT", "OT", "FT", "TT", };
    369370                                        static_assert(
    370371                                                sizeof(typeVariableNames)/sizeof(typeVariableNames[0]) == TypeDecl::NUMBER_OF_KINDS,
     
    416417
    417418                        bool StringView::isPrefix(const std::string & pref) {
    418                                 if ( pref.size() > str.size()-idx ) return false;
    419                                 auto its = std::mismatch( pref.begin(), pref.end(), std::next(str.begin(), idx) );
    420                                 if (its.first == pref.end()) {
     419                                // if ( pref.size() > str.size()-idx ) return false;
     420                                // auto its = std::mismatch( pref.begin(), pref.end(), std::next(str.begin(), idx) );
     421                                // if (its.first == pref.end()) {
     422                                //      idx += pref.size();
     423                                //      return true;
     424                                // }
     425
     426                                // This update is untested because there are no tests for this code.
     427                                if ( ::isPrefix( str, pref, idx ) ) {
    421428                                        idx += pref.size();
    422429                                        return true;
     
    429436                                PRINT( std::cerr << "====== " << str.size() << " " << str << std::endl; )
    430437                                if (str.size() < 2+Encoding::manglePrefix.size()) return false; // +2 for at least _1 suffix
    431                                 if (! isPrefix(Encoding::manglePrefix) || ! isdigit(str.back())) return false;
     438                                if ( ! isPrefix(Encoding::manglePrefix) || ! isdigit(str.back() ) ) return false;
    432439
    433440                                // get name
  • src/SymTab/Indexer.cc

    r71d6bd8 r7030dab  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:37:33 2015
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Fri Mar  8 13:55:00 2019
    13 // Update Count     : 21
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:43:19 2019
     13// Update Count     : 22
    1414//
    1515
     
    3131#include "InitTweak/InitTweak.h"   // for isConstructor, isCopyFunction, isC...
    3232#include "Mangler.h"               // for Mangler
    33 #include "Parser/LinkageSpec.h"    // for isMangled, isOverridable, Spec
    3433#include "ResolvExpr/typeops.h"    // for typesCompatible
     34#include "SynTree/LinkageSpec.h"   // for isMangled, isOverridable, Spec
    3535#include "SynTree/Constant.h"      // for Constant
    3636#include "SynTree/Declaration.h"   // for DeclarationWithType, FunctionDecl
  • src/SymTab/Mangler.cc

    r71d6bd8 r7030dab  
    1010// Created On       : Sun May 17 21:40:29 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 30 13:46:10 2019
    13 // Update Count     : 26
     12// Last Modified On : Sat Feb 15 13:55:12 2020
     13// Update Count     : 33
    1414//
    1515#include "Mangler.h"
     
    2626#include "Common/SemanticError.h"        // for SemanticError
    2727#include "Common/utility.h"              // for toString
    28 #include "Parser/LinkageSpec.h"          // for Spec, isOverridable, AutoGen, Int...
    2928#include "ResolvExpr/TypeEnvironment.h"  // for TypeEnvironment
     29#include "SynTree/LinkageSpec.h"         // for Spec, isOverridable, AutoGen, Int...
    3030#include "SynTree/Declaration.h"         // for TypeDecl, DeclarationWithType
    3131#include "SynTree/Expression.h"          // for TypeExpr, Expression, operator<<
     
    128128                                } // if
    129129                                mangleName << Encoding::manglePrefix;
    130                                 CodeGen::OperatorInfo opInfo;
    131                                 if ( operatorLookup( declaration->get_name(), opInfo ) ) {
    132                                         mangleName << opInfo.outputName.size() << opInfo.outputName;
     130                                const CodeGen::OperatorInfo * opInfo = CodeGen::operatorLookup( declaration->get_name() );
     131                                if ( opInfo ) {
     132                                        mangleName << opInfo->outputName.size() << opInfo->outputName;
    133133                                } else {
    134134                                        mangleName << declaration->name.size() << declaration->name;
     
    471471                        } // if
    472472                        mangleName << Encoding::manglePrefix;
    473                         CodeGen::OperatorInfo opInfo;
    474                         if ( operatorLookup( decl->name, opInfo ) ) {
    475                                 mangleName << opInfo.outputName.size() << opInfo.outputName;
     473                        const CodeGen::OperatorInfo * opInfo = CodeGen::operatorLookup( decl->name );
     474                        if ( opInfo ) {
     475                                mangleName << opInfo->outputName.size() << opInfo->outputName;
    476476                        } else {
    477477                                mangleName << decl->name.size() << decl->name;
     
    654654                        // aside from the assert false.
    655655                        assertf(false, "Mangler_new should not visit typedecl: %s", toCString(decl));
    656                         assertf( decl->kind < ast::TypeVar::Kind::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind );
     656                        assertf( decl->kind < ast::TypeDecl::Kind::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind );
    657657                        mangleName << Encoding::typeVariables[ decl->kind ] << ( decl->name.length() ) << decl->name;
    658658                }
     
    674674                                        for ( const ast::TypeDecl * decl : ptype->forall ) {
    675675                                                switch ( decl->kind ) {
    676                                                 case ast::TypeVar::Kind::Dtype:
     676                                                case ast::TypeDecl::Kind::Dtype:
    677677                                                        dcount++;
    678678                                                        break;
    679                                                 case ast::TypeVar::Kind::Ftype:
     679                                                case ast::TypeDecl::Kind::Ftype:
    680680                                                        fcount++;
    681681                                                        break;
    682                                                 case ast::TypeVar::Kind::Ttype:
     682                                                case ast::TypeDecl::Kind::Ttype:
    683683                                                        vcount++;
    684684                                                        break;
  • src/SymTab/ManglerCommon.cc

    r71d6bd8 r7030dab  
    1010// Created On       : Sun May 17 21:44:03 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 14 17:06:37 2019
    13 // Update Count     : 26
     12// Last Modified On : Fri Dec 13 14:54:38 2019
     13// Update Count     : 28
    1414//
    1515
     
    104104                        const std::string typeVariables[] = {
    105105                                "BD", // dtype
     106                                "BO", // otype
    106107                                "BF", // ftype
    107108                                "BT", // ttype
  • src/SymTab/Validate.cc

    r71d6bd8 r7030dab  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  7 6:42:00 2019
    13 // Update Count     : 360
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:43:34 2019
     13// Update Count     : 363
    1414//
    1515
     
    6969#include "InitTweak/GenInit.h"         // for fixReturnStatements
    7070#include "InitTweak/InitTweak.h"       // for isCtorDtorAssign
    71 #include "Parser/LinkageSpec.h"        // for C
    7271#include "ResolvExpr/typeops.h"        // for typesCompatible
    7372#include "ResolvExpr/Resolver.h"       // for findSingleExpression
    7473#include "ResolvExpr/ResolveTypeof.h"  // for resolveTypeof
    7574#include "SymTab/Autogen.h"            // for SizeType
     75#include "SynTree/LinkageSpec.h"       // for C
    7676#include "SynTree/Attribute.h"         // for noAttributes, Attribute
    7777#include "SynTree/Constant.h"          // for Constant
     
    311311                        Stats::Heap::newPass("validate-A");
    312312                        Stats::Time::BlockGuard guard("validate-A");
     313                        VerifyCtorDtorAssign::verify( translationUnit );  // must happen before autogen, because autogen examines existing ctor/dtors
    313314                        acceptAll( translationUnit, hoistDecls );
    314315                        ReplaceTypedef::replaceTypedef( translationUnit );
     
    336337                        Stats::Time::BlockGuard guard("validate-C");
    337338                        acceptAll( translationUnit, genericParams );  // check as early as possible - can't happen before LinkReferenceToTypes_old
    338                         VerifyCtorDtorAssign::verify( translationUnit );  // must happen before autogen, because autogen examines existing ctor/dtors
    339339                        ReturnChecker::checkFunctionReturns( translationUnit );
    340340                        InitTweak::fixReturnStatements( translationUnit ); // must happen before autogen
     
    375375                        Stats::Heap::newPass("validate-F");
    376376                        Stats::Time::BlockGuard guard("validate-F");
    377                         Stats::Time::TimeBlock("Fix Object Type", [&]() {
    378                                 FixObjectType::fix( translationUnit );
    379                         });
    380                         Stats::Time::TimeBlock("Array Length", [&]() {
    381                                 ArrayLength::computeLength( translationUnit );
    382                         });
    383                         Stats::Time::TimeBlock("Find Special Declarations", [&]() {
    384                                 Validate::findSpecialDecls( translationUnit );
    385                         });
    386                         Stats::Time::TimeBlock("Fix Label Address", [&]() {
    387                                 mutateAll( translationUnit, labelAddrFixer );
    388                         });
    389                         Stats::Time::TimeBlock("Handle Attributes", [&]() {
    390                                 Validate::handleAttributes( translationUnit );
    391                         });
     377                        Stats::Time::TimeCall("Fix Object Type",
     378                                FixObjectType::fix, translationUnit);
     379                        Stats::Time::TimeCall("Array Length",
     380                                ArrayLength::computeLength, translationUnit);
     381                        Stats::Time::TimeCall("Find Special Declarations",
     382                                Validate::findSpecialDecls, translationUnit);
     383                        Stats::Time::TimeCall("Fix Label Address",
     384                                mutateAll<LabelAddressFixer>, translationUnit, labelAddrFixer);
     385                        Stats::Time::TimeCall("Handle Attributes",
     386                                Validate::handleAttributes, translationUnit);
    392387                }
    393388        }
     
    10491044                Type * designatorType = tyDecl->base->stripDeclarator();
    10501045                if ( StructInstType * aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) {
    1051                         declsToAddBefore.push_back( new StructDecl( aggDecl->name, DeclarationNode::Struct, noAttributes, tyDecl->linkage ) );
     1046                        declsToAddBefore.push_back( new StructDecl( aggDecl->name, AggregateDecl::Struct, noAttributes, tyDecl->linkage ) );
    10521047                } else if ( UnionInstType * aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) {
    10531048                        declsToAddBefore.push_back( new UnionDecl( aggDecl->name, noAttributes, tyDecl->linkage ) );
     
    11871182                if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc.
    11881183                        if ( params.size() == 0 ) {
    1189                                 SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " );
     1184                                SemanticError( funcDecl->location, "Constructors, destructors, and assignment functions require at least one parameter." );
    11901185                        }
    11911186                        ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() );
    11921187                        if ( ! refType ) {
    1193                                 SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " );
     1188                                SemanticError( funcDecl->location, "First parameter of a constructor, destructor, or assignment function must be a reference." );
    11941189                        }
    11951190                        if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {
    1196                                 SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " );
     1191                                if(!returnVals.front()->get_type()->isVoid()) {
     1192                                        SemanticError( funcDecl->location, "Constructors and destructors cannot have explicit return values." );
     1193                                }
    11971194                        }
    11981195                }
Note: See TracChangeset for help on using the changeset viewer.