Changeset 64f3b9f


Ignore:
Timestamp:
Dec 11, 2024, 6:09:10 PM (6 days ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
e797179
Parents:
ec22220
Message:

Fix support for partial autogen.

Partial autogen means that some lifecycle functions are possible to generate, and needed, while others are impossible to generate, but unneeded. It is a valid situation that a user can implicitly request.

Previous handling of "impossible to generate" left the function in a zombie state, where it could show up as an alternative later. This zombie state is problematic handling caused by a compiler bug. Without the fix, the added test fails by creating zombie states.

This change is also a prerequsite for an upcoming change to avoid gcc warnings by not emitting autogen forward declarations.

Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/AST/SymbolTable.cpp

    rec22220 r64f3b9f  
    522522}
    523523
     524void SymbolTable::reviseSpecialAsDeleted( const FunctionDecl * func ) {
     525        SpecialFunctionKind kind = getSpecialFunctionKind(func->name);
     526        assert( kind != NUMBER_OF_KINDS );
     527        assert( func->linkage.is_overrideable );
     528        IdTable::Ptr & idTable = specialFunctionTable[kind];
     529
     530        std::string otypeKey = getOtypeKey(func->type);
     531        IdTable::iterator idHit = idTable->find( otypeKey );
     532        assert( idHit != idTable->end() );
     533        MangleTable::Ptr mangleTable = idHit->second;
     534
     535        std::string mangleName = Mangle::mangle( func, Mangle::Mode{ Mangle::NoOverrideable } );
     536        MangleTable::iterator mangleHit = mangleTable->find( mangleName );
     537        assert( mangleHit != mangleTable->end() );
     538        IdData oldEntry = mangleHit->second;
     539        assert( oldEntry.id == func );
     540
     541        mangleTable = mangleTable->set( mangleName, oldEntry.withDeleter( func ) );
     542        idTable = idTable->set( otypeKey, mangleTable );
     543}
     544
    524545bool SymbolTable::removeSpecialOverrides(
    525546                SymbolTable::IdData & data, SymbolTable::MangleTable::Ptr & mangleTable ) {
  • src/AST/SymbolTable.hpp

    rec22220 r64f3b9f  
    177177        void addFunction( const FunctionDecl * );
    178178
     179        /// Reclassifies the previously-indexed special declaration, so `combine` shows it as deleted
     180        void reviseSpecialAsDeleted( const FunctionDecl * );
     181
    179182private:
    180183        void OnFindError( CodeLocation location, std::string error ) const;
  • src/ResolvExpr/Resolver.cpp

    rec22220 r64f3b9f  
    13311331                        mutDecl->isDeleted = true;
    13321332                        mutDecl->stmts = nullptr;
     1333                        symtab.reviseSpecialAsDeleted( functionDecl );
    13331334                        decl = mutDecl;
    13341335                        return false;
  • tests/Makefile.am

    rec22220 r64f3b9f  
    272272        -cp ${test} ${abspath ${@}}
    273273
     274raii/partial-ERR1 : raii/partial.cfa ${CFACCBIN}
     275        ${CFACOMPILE_SYNTAX} -DERR1
     276        -cp ${test} ${abspath ${@}}
     277
    274278# Exception Tests
    275279# Test with libcfathread; it changes how storage works.
Note: See TracChangeset for help on using the changeset viewer.