Changeset d1f5054 for src


Ignore:
Timestamp:
Aug 14, 2024, 11:55:20 AM (15 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
960665c
Parents:
26d40a1 (diff), 2870cb6 (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.hpp

    r26d40a1 rd1f5054  
    1111// Last Modified By : Peter A. Buhr
    1212// Created On       : Fri May 10 10:30:00 2019
    13 // Update Count     : 7
     13// Update Count     : 8
    1414//
    1515
     
    8686
    8787                /// initializes from other InferUnion
    88                 void init_from( const InferUnion& o ) {
     88                void init_from( const InferUnion & o ) {
    8989                        if (o.data.resnSlots) {
    9090                                data.resnSlots = new ResnSlots(*o.data.resnSlots);
     
    9696
    9797                /// initializes from other InferUnion (move semantics)
    98                 void init_from( InferUnion&& o ) {
     98                void init_from( InferUnion && o ) {
    9999                        data.resnSlots = o.data.resnSlots;
    100100                        data.inferParams = o.data.inferParams;
     
    104104
    105105                InferUnion() : mode(Empty), data() {}
    106                 InferUnion( const InferUnion& o ) : mode( o.mode ), data() { init_from( o ); }
    107                 InferUnion( InferUnion&& o ) : mode( o.mode ), data() { init_from( std::move(o) ); }
    108                 InferUnion& operator= ( const InferUnion& ) = delete;
    109                 InferUnion& operator= ( InferUnion&& ) = delete;
     106                InferUnion( const InferUnion & o ) : mode( o.mode ), data() { init_from( o ); }
     107                InferUnion( InferUnion && o ) : mode( o.mode ), data() { init_from( std::move(o) ); }
     108                InferUnion & operator= ( const InferUnion & ) = delete;
     109                InferUnion & operator= ( InferUnion && ) = delete;
    110110
    111111                bool hasSlots() const { return data.resnSlots; }
    112112                bool hasParams() const { return data.inferParams; }
    113113
    114                 ResnSlots& resnSlots() {
     114                ResnSlots & resnSlots() {
    115115                        if (!data.resnSlots) {
    116116                                data.resnSlots = new ResnSlots();
     
    119119                }
    120120
    121                 const ResnSlots& resnSlots() const {
     121                const ResnSlots & resnSlots() const {
    122122                        if (data.resnSlots) {
    123123                                return *data.resnSlots;
     
    127127                }
    128128
    129                 InferredParams& inferParams() {
     129                InferredParams & inferParams() {
    130130                        if (!data.inferParams) {
    131131                                data.inferParams = new InferredParams();
     
    134134                }
    135135
    136                 const InferredParams& inferParams() const {
     136                const InferredParams & inferParams() const {
    137137                        if (data.inferParams) {
    138138                                return *data.inferParams;
     
    669669        ptr<ApplicationExpr> callExpr;
    670670
    671         ImplicitCopyCtorExpr( const CodeLocation& loc, const ApplicationExpr * call )
     671        ImplicitCopyCtorExpr( const CodeLocation & loc, const ApplicationExpr * call )
    672672        : Expr( loc, call->result ), callExpr(call) { assert( call ); assert(call->result); }
    673673
  • src/CodeGen/CodeGenerator.cpp

    r26d40a1 rd1f5054  
    7979                currentLocation.first_line += 2;
    8080        } else {
    81                 output << "\n# " << to.first_line << " \"" << to.filename
     81                output << "\n# " << to.first_line << " \"" << to.filename.c_str()
    8282                       << "\"\n" << indent;
    8383                currentLocation = to;
  • src/Common/CodeLocation.hpp

    r26d40a1 rd1f5054  
    1717
    1818#include <iostream>
    19 #include <string>
     19#include "Symbol.hpp"
    2020
    2121struct CodeLocation {
    2222        int first_line = -1, first_column = -1, last_line = -1, last_column = -1;
    23         std::string filename = "";
     23        Symbol filename = "";
    2424
    2525        /// Create a new unset CodeLocation.
     
    4646
    4747        bool startsBefore( CodeLocation const & other ) const {
    48                 if( filename < other.filename ) return true;
    49                 if( filename > other.filename ) return false;
     48                if( filename.str() < other.filename.str() ) return true;
     49                if( filename.str() > other.filename.str() ) return false;
    5050
    5151                if( first_line < other.first_line ) return true;
     
    7272inline std::ostream & operator<<( std::ostream & out, const CodeLocation & location ) {
    7373        // Column number ":1" allows IDEs to parse the error message and position the cursor in the source text.
    74         return location.isSet() ? out << location.filename << ":" << location.first_line << ":1 " : out;
     74        return location.isSet() ? out << location.filename.str() << ":" << location.first_line << ":1 " : out;
    7575}
  • src/Common/module.mk

    r26d40a1 rd1f5054  
    4848        Common/Stats/Time.cpp \
    4949        Common/Stats/Time.hpp \
     50        Common/Symbol.cpp \
     51        Common/Symbol.hpp \
    5052        Common/ToString.hpp \
    5153        Common/UniqueName.cpp \
  • src/GenPoly/Lvalue.cpp

    r26d40a1 rd1f5054  
    1010// Created On       : Thu Sep 15 14:08:00 2022
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Oct  6  9:59:00 2022
    13 // Update Count     : 0
     12// Last Modified On : Mon Aug 12 18:07:00 2024
     13// Update Count     : 1
    1414//
    1515
     
    119119/// Replace all reference types with pointer types.
    120120struct ReferenceTypeElimination final {
     121        ast::SizeofExpr const * previsit( ast::SizeofExpr const * expr );
     122        ast::AlignofExpr const * previsit( ast::AlignofExpr const * expr );
    121123        ast::Type const * postvisit( ast::ReferenceType const * type );
    122124};
     
    603605}
    604606
     607ast::SizeofExpr const * ReferenceTypeElimination::previsit(
     608                ast::SizeofExpr const * expr ) {
     609        if ( expr->expr ) return expr;
     610        return ast::mutate_field( expr, &ast::SizeofExpr::type,
     611                expr->type->stripReferences() );
     612}
     613
     614ast::AlignofExpr const * ReferenceTypeElimination::previsit(
     615                ast::AlignofExpr const * expr ) {
     616        if ( expr->expr ) return expr;
     617        return ast::mutate_field( expr, &ast::AlignofExpr::type,
     618                expr->type->stripReferences() );
     619}
     620
    605621ast::Type const * ReferenceTypeElimination::postvisit(
    606622                ast::ReferenceType const * type ) {
  • src/InitTweak/FixInit.cpp

    r26d40a1 rd1f5054  
    731731        try {
    732732                mutLast->expr = makeCtorDtor( "?{}", ret, mutLast->expr );
    733         } catch(...) {
     733        } catch (...) {
    734734                std::cerr << "*CFA internal error: ";
    735735                std::cerr << "can't resolve implicit constructor";
    736                 std::cerr << " at " << stmtExpr->location.filename;
     736                std::cerr << " at " << stmtExpr->location.filename.c_str();
    737737                std::cerr << ":" << stmtExpr->location.first_line << std::endl;
    738738
  • src/Parser/parser.yy

    r26d40a1 rd1f5054  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 26 14:09:30 2024
    13 // Update Count     : 6733
     12// Last Modified On : Tue Aug 13 11:25:16 2024
     13// Update Count     : 6740
    1414//
    1515
     
    952952                }
    953953        | COUNTOF unary_expression
    954                 {  $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
     954                { $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
    955955        | COUNTOF '(' type_no_function ')'
    956956                { $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
     
    16261626enum_key:
    16271627        type_name
    1628                 {       typedefTable.makeTypedef( *$1->symbolic.name, "enum_type_nobody 1" );
    1629                         $$ = DeclarationNode::newEnum( $1->symbolic.name, nullptr, false, false ); }
     1628                {
     1629                        typedefTable.makeTypedef( *$1->symbolic.name, "enum_type_nobody 1" );
     1630                        $$ = DeclarationNode::newEnum( $1->symbolic.name, nullptr, false, false );
     1631                }
    16301632        | ENUM identifier
    1631                 {       typedefTable.makeTypedef( *$2, "enum_type_nobody 2" );
    1632                         $$ = DeclarationNode::newEnum( $2, nullptr, false, false ); }
     1633                {
     1634                        typedefTable.makeTypedef( *$2, "enum_type_nobody 2" );
     1635                        $$ = DeclarationNode::newEnum( $2, nullptr, false, false );
     1636                }
    16331637        | ENUM type_name
    1634                 {       typedefTable.makeTypedef( *$2->symbolic.name, "enum_type_nobody 3" );
    1635                         $$ = DeclarationNode::newEnum( $2->symbolic.name, nullptr, false, false ); }
     1638                {
     1639                        typedefTable.makeTypedef( *$2->symbolic.name, "enum_type_nobody 3" );
     1640                        $$ = DeclarationNode::newEnum( $2->symbolic.name, nullptr, false, false );
     1641                }
    16361642        ;
    16371643
     
    18491855
    18501856handler_clause:
    1851         handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1852                 { $$ = new ClauseNode( build_catch( yylloc, $1, $4, $6, $8 ) ); }
    1853         | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1854                 { $$ = $1->set_last( new ClauseNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); }
     1857        handler_key '(' exception_declaration handler_predicate_opt ')' compound_statement
     1858                { $$ = new ClauseNode( build_catch( yylloc, $1, $3, $4, $6 ) ); }
     1859        | handler_clause handler_key '(' exception_declaration handler_predicate_opt ')' compound_statement
     1860                { $$ = $1->set_last( new ClauseNode( build_catch( yylloc, $2, $4, $5, $7 ) ) ); }
    18551861        ;
    18561862
     
    28502856
    28512857enumerator_list:
    2852         visible_hide_opt identifier_or_type_name enumerator_value_opt
     2858        // empty
     2859                { SemanticError( yylloc, "enumeration must have a minimum of one enumerator, empty enumerator list is meaningless." );  $$ = nullptr; }
     2860        | visible_hide_opt identifier_or_type_name enumerator_value_opt
    28532861                { $$ = DeclarationNode::newEnumValueGeneric( $2, $3 ); }
    28542862        | INLINE type_name
     
    31553163        '|' identifier_or_type_name '(' type_list ')'
    31563164                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    3157         | '|' '{' push trait_declaration_list pop '}'
    3158                 { $$ = $4; }
     3165        | '|' '{' trait_declaration_list '}'
     3166                { $$ = $3; }
    31593167        // | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}' '(' type_list ')'
    31603168        //      { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; }
     
    32083216        | forall TRAIT identifier_or_type_name '{' '}'          // alternate
    32093217                { $$ = DeclarationNode::newTrait( $3, $1, nullptr ); }
    3210         | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
     3218        | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' trait_declaration_list '}'
    32113219                {
    32123220                        SemanticWarning( yylloc, Warning::DeprecTraitSyntax );
    3213                         $$ = DeclarationNode::newTrait( $2, $4, $8 );
    3214                 }
    3215         | forall TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate
    3216                 { $$ = DeclarationNode::newTrait( $3, $1, $6 ); }
     3221                        $$ = DeclarationNode::newTrait( $2, $4, $7 );
     3222                }
     3223        | forall TRAIT identifier_or_type_name '{' trait_declaration_list '}' // alternate
     3224                { $$ = DeclarationNode::newTrait( $3, $1, $5 ); }
    32173225        ;
    32183226
    32193227trait_declaration_list:                                                                 // CFA
    32203228        trait_declaration
    3221         | trait_declaration_list pop push trait_declaration
    3222                 { $$ = $1->set_last( $4 ); }
     3229        | trait_declaration_list trait_declaration
     3230                { $$ = $1->set_last( $2 ); }
    32233231        ;
    32243232
     
    32313239        cfa_variable_specifier
    32323240        | cfa_function_specifier
    3233         | cfa_trait_declaring_list pop ',' push identifier_or_type_name
    3234                 { $$ = $1->set_last( $1->cloneType( $5 ) ); }
     3241        | cfa_trait_declaring_list ',' identifier_or_type_name
     3242                { $$ = $1->set_last( $1->cloneType( $3 ) ); }
    32353243        ;
    32363244
    32373245trait_declaring_list:                                                                   // CFA
    3238         type_specifier declarator
     3246                // Cannot declare an aggregate or enumeration in a trait.
     3247        type_specifier_nobody declarator
    32393248                { $$ = $2->addType( $1 ); }
    3240         | trait_declaring_list pop ',' push declarator
    3241                 { $$ = $1->set_last( $1->cloneBaseType( $5 ) ); }
     3249        | trait_declaring_list ',' declarator
     3250                { $$ = $1->set_last( $1->cloneBaseType( $3 ) ); }
     3251        | error
     3252                { SemanticError( yylloc, "Possible cause is declaring an aggregate or enumeration type in a trait." ); $$ = nullptr; }
    32423253        ;
    32433254
  • src/ResolvExpr/CandidateFinder.cpp

    r26d40a1 rd1f5054  
    12811281                                // count one safe conversion for each value that is thrown away
    12821282                                thisCost.incSafe( discardedValues );
     1283
     1284                                // See Aaron Moss, page 47; this reasoning does not hold since implicit conversions
     1285                                // can create the same resolution issue. The C intrinsic interpretations are pruned
     1286                                // immediately for the lowest cost option regardless of result type. Related code in
     1287                                // postvisit (UntypedExpr).
     1288                                // Cast expression costs are updated now to use the general rules.
     1289                                /*
    12831290                                // select first on argument cost, then conversion cost
    12841291                                if ( cand->cost < minExprCost || ( cand->cost == minExprCost && thisCost < minCastCost ) ) {
     
    12891296                                // ambigious case, still output candidates to print in error message
    12901297                                if ( cand->cost == minExprCost && thisCost == minCastCost ) {
     1298                                */
     1299                                cand->cost += thisCost;
     1300                                if (cand->cost < minExprCost) {
     1301                                        minExprCost = cand->cost;
     1302                                        matches.clear();
     1303                                }
     1304                                if (cand->cost == minExprCost) {
    12911305                                        CandidateRef newCand = std::make_shared<Candidate>(
    12921306                                                restructureCast( cand->expr, toType, castExpr->isGenerated ),
    1293                                                 copy( cand->env ), std::move( open ), std::move( need ), cand->cost + thisCost);
     1307                                                copy( cand->env ), std::move( open ), std::move( need ), cand->cost);
    12941308                                        // currently assertions are always resolved immediately so this should have no effect.
    12951309                                        // if this somehow changes in the future (e.g. delayed by indeterminate return type)
Note: See TracChangeset for help on using the changeset viewer.