Changeset 4a8f150


Ignore:
Timestamp:
Dec 1, 2020, 3:39:24 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
a25f64b
Parents:
41c19b4
Message:

A quick-fix to get the self-assignment bug working and some clean-up I did on the way.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInitNew.cpp

    r41c19b4 r4a8f150  
    413413        void SelfAssignChecker::previsit( const ast::ApplicationExpr * appExpr ) {
    414414                auto function = getFunction( appExpr );
    415                 if ( function->name == "?=?" ) { // doesn't use isAssignment, because ?+=?, etc. should not count as self-assignment
    416                         if ( appExpr->args.size() == 2 ) {
    417                                 // check for structural similarity (same variable use, ignore casts, etc. - but does not look too deeply, anything looking like a function is off limits)
    418                                 if ( structurallySimilar( appExpr->args.front(), appExpr->args.back() ) ) {
    419                                         SemanticWarning( appExpr->location, Warning::SelfAssignment, toCString( appExpr->args.front() ) );
    420                                 }
    421                         }
     415                // Doesn't use isAssignment, because ?+=?, etc. should not count as self-assignment.
     416                if ( function->name == "?=?" && appExpr->args.size() == 2
     417                                // Check for structural similarity (same variable use, ignore casts, etc.
     418                                // (but does not look too deeply, anything looking like a function is off limits).
     419                                && structurallySimilar( appExpr->args.front(), appExpr->args.back() ) ) {
     420                        SemanticWarning( appExpr->location, Warning::SelfAssignment, toCString( appExpr->args.front() ) );
    422421                }
    423422        }
  • src/ResolvExpr/Resolver.cc

    r41c19b4 r4a8f150  
    14711471                                auto newDecl = fixObjectType(objectDecl, symtab);
    14721472                                auto mutDecl = mutate(newDecl);
    1473                                
     1473
    14741474                                // generate CtorInit wrapper when necessary.
    14751475                                // in certain cases, fixObjectType is called before reaching
     
    14891489                        currentObject = ast::CurrentObject{ objectDecl->location, objectDecl->get_type() };
    14901490                }
    1491                
     1491
    14921492                return objectDecl;
    14931493        }
  • src/main.cc

    r41c19b4 r4a8f150  
    99// Author           : Peter Buhr and Rob Schluntz
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Oct  8 18:17:46 2020
    13 // Update Count     : 637
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue Dec  1 14:52:00 2020
     13// Update Count     : 638
    1414//
    1515
     
    340340                } // if
    341341
    342                 if( useNewAST) {
     342                if( useNewAST ) {
    343343                        if (Stats::Counters::enabled) {
    344344                                ast::pass_visitor_stats.avg = Stats::Counters::build<Stats::Counters::AverageCounter<double>>("Average Depth - New");
     
    352352                                return EXIT_SUCCESS;
    353353                        } // if
     354
     355                        // TODO: This is a quick fix to get the build working.
     356                        // Get rid of fillLocations or at least make a new-ast version.
     357                        translationUnit = convert( move( transUnit ) );
     358                        CodeTools::fillLocations( translationUnit );
     359                        transUnit = convert( move( translationUnit ) );
    354360
    355361                        PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary()));
Note: See TracChangeset for help on using the changeset viewer.