Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/FixNames.cc

    r8d7bef2 r6d611fb  
    1616#include "FixNames.h"
    1717
     18#include <memory>                  // for unique_ptr
    1819#include <string>                  // for string, operator!=, operator==
    1920
     
    4647        std::string mangle_main() {
    4748                FunctionType* main_type;
    48                 FunctionDecl* mainDecl = new FunctionDecl{
    49                         "main", Type::StorageClasses(), LinkageSpec::Cforall,
    50                         main_type = new FunctionType{ Type::Qualifiers(), true }, nullptr };
     49                std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall,
     50                                                                                                                                   main_type = new FunctionType( Type::Qualifiers(), true ), nullptr )
     51                                };
    5152                main_type->get_returnVals().push_back(
    5253                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
    5354                );
    5455
    55                 auto && name = SymTab::Mangler::mangle( mainDecl );
     56                auto && name = SymTab::Mangler::mangle( mainDecl.get() );
    5657                // std::cerr << name << std::endl;
    57                 return name;
     58                return std::move(name);
    5859        }
    5960        std::string mangle_main_args() {
    6061                FunctionType* main_type;
    61                 FunctionDecl* mainDecl = new FunctionDecl{
    62                         "main", Type::StorageClasses(), LinkageSpec::Cforall,
    63                         main_type = new FunctionType{ Type::Qualifiers(), false }, nullptr };
     62                std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall,
     63                                                                                                                                   main_type = new FunctionType( Type::Qualifiers(), false ), nullptr )
     64                                };
    6465                main_type->get_returnVals().push_back(
    6566                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
     
    7677                );
    7778
    78                 auto&& name = SymTab::Mangler::mangle( mainDecl );
     79                auto&& name = SymTab::Mangler::mangle( mainDecl.get() );
    7980                // std::cerr << name << std::endl;
    80                 return name;
     81                return std::move(name);
    8182        }
    8283
Note: See TracChangeset for help on using the changeset viewer.