Changeset 4a8f150 for src/InitTweak


Ignore:
Timestamp:
Dec 1, 2020, 3:39:24 PM (14 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
a25f64b
Parents:
41c19b4
Message:

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

File:
1 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        }
Note: See TracChangeset for help on using the changeset viewer.