Changeset 2f61765 for src


Ignore:
Timestamp:
Feb 3, 2023, 2:12:21 PM (23 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
e9b5043
Parents:
2125443a
Message:

Fixed a clang warning and cleaned up the rest of the function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/ScrubTyVars.cc

    r2125443a r2f61765  
    178178
    179179ast::Type const * ScrubTypeVars::postvisit( ast::TypeInstType const * type ) {
     180        ast::TypeDecl::Kind kind;
    180181        // This implies that mode == ScrubMode::All.
    181182        if ( !typeVars ) {
    182                 if ( ast::TypeDecl::Ftype == type->kind ) {
    183                         return new ast::PointerType(
    184                                 new ast::FunctionType( ast::FixedArgs ) );
    185                 } else {
    186                         return new ast::PointerType(
    187                                 new ast::VoidType( type->qualifiers ) );
    188                 }
    189         }
    190 
    191         auto typeVar = typeVars->find( *type );
    192         if ( typeVar == typeVars->end() ) {
    193                 return type;
    194         }
    195 
    196         switch ( typeVar->second.kind ) {
    197         case ::TypeDecl::Dtype:
    198         case ::TypeDecl::Ttype:
     183                kind = type->kind;
     184        } else {
     185                // Otherwise, only scrub the type var if it is in map.
     186                auto typeVar = typeVars->find( *type );
     187                if ( typeVar == typeVars->end() ) {
     188                        return type;
     189                }
     190                kind = typeVar->second.kind;
     191        }
     192
     193        switch ( kind ) {
     194        case ast::TypeDecl::Dtype:
     195        case ast::TypeDecl::Ttype:
    199196                return new ast::PointerType(
    200197                        new ast::VoidType( type->qualifiers ) );
    201         case ::TypeDecl::Ftype:
     198        case ast::TypeDecl::Ftype:
    202199                return new ast::PointerType(
    203200                        new ast::FunctionType( ast::VariableArgs ) );
    204201        default:
    205                 assertf( false,
    206                         "Unhandled type variable kind: %d", typeVar->second.kind );
     202                assertf( false, "Unhandled type variable kind: %d", kind );
    207203                throw; // Just in case the assert is removed, stop here.
    208204        }
Note: See TracChangeset for help on using the changeset viewer.