Changeset 8573729
- Timestamp:
- Mar 12, 2018, 5:28:11 PM (7 years ago)
- Branches:
- resolv-new
- Children:
- 4edf753
- Parents:
- 6171841
- Location:
- src
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.in
r6171841 r8573729 211 211 ResolvExpr/driver_cfa_cpp-CurrentObject.$(OBJEXT) \ 212 212 ResolvExpr/driver_cfa_cpp-ExplodedActual.$(OBJEXT) \ 213 ResolvExpr/driver_cfa_cpp-ResolveAssertions.$(OBJEXT) \ 213 214 SymTab/driver_cfa_cpp-Indexer.$(OBJEXT) \ 214 215 SymTab/driver_cfa_cpp-Mangler.$(OBJEXT) \ … … 509 510 ResolvExpr/Occurs.cc ResolvExpr/TypeEnvironment.cc \ 510 511 ResolvExpr/CurrentObject.cc ResolvExpr/ExplodedActual.cc \ 511 SymTab/Indexer.cc SymTab/Mangler.cc SymTab/Validate.cc \512 SymTab/ FixFunction.cc SymTab/Autogen.cc SynTree/Type.cc \513 Sy nTree/VoidType.cc SynTree/BasicType.cc \514 SynTree/ PointerType.cc SynTree/ArrayType.cc \515 SynTree/ ReferenceType.cc SynTree/FunctionType.cc \516 SynTree/ ReferenceToType.cc SynTree/TupleType.cc \517 SynTree/T ypeofType.cc SynTree/AttrType.cc \512 ResolvExpr/ResolveAssertions.cc SymTab/Indexer.cc \ 513 SymTab/Mangler.cc SymTab/Validate.cc SymTab/FixFunction.cc \ 514 SymTab/Autogen.cc SynTree/Type.cc SynTree/VoidType.cc \ 515 SynTree/BasicType.cc SynTree/PointerType.cc \ 516 SynTree/ArrayType.cc SynTree/ReferenceType.cc \ 517 SynTree/FunctionType.cc SynTree/ReferenceToType.cc \ 518 SynTree/TupleType.cc SynTree/TypeofType.cc SynTree/AttrType.cc \ 518 519 SynTree/VarArgsType.cc SynTree/ZeroOneType.cc \ 519 520 SynTree/Constant.cc SynTree/Expression.cc SynTree/TupleExpr.cc \ … … 824 825 ResolvExpr/$(am__dirstamp) \ 825 826 ResolvExpr/$(DEPDIR)/$(am__dirstamp) 827 ResolvExpr/driver_cfa_cpp-ResolveAssertions.$(OBJEXT): \ 828 ResolvExpr/$(am__dirstamp) \ 829 ResolvExpr/$(DEPDIR)/$(am__dirstamp) 826 830 SymTab/$(am__dirstamp): 827 831 @$(MKDIR_P) SymTab … … 1020 1024 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-PtrsCastable.Po@am__quote@ 1021 1025 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-RenameVars.Po@am__quote@ 1026 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ResolveAssertions.Po@am__quote@ 1022 1027 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ResolveTypeof.Po@am__quote@ 1023 1028 @AMDEP_TRUE@@am__include@ @am__quote@ResolvExpr/$(DEPDIR)/driver_cfa_cpp-Resolver.Po@am__quote@ … … 1966 1971 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ResolvExpr/driver_cfa_cpp-ExplodedActual.obj `if test -f 'ResolvExpr/ExplodedActual.cc'; then $(CYGPATH_W) 'ResolvExpr/ExplodedActual.cc'; else $(CYGPATH_W) '$(srcdir)/ResolvExpr/ExplodedActual.cc'; fi` 1967 1972 1973 ResolvExpr/driver_cfa_cpp-ResolveAssertions.o: ResolvExpr/ResolveAssertions.cc 1974 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ResolvExpr/driver_cfa_cpp-ResolveAssertions.o -MD -MP -MF ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ResolveAssertions.Tpo -c -o ResolvExpr/driver_cfa_cpp-ResolveAssertions.o `test -f 'ResolvExpr/ResolveAssertions.cc' || echo '$(srcdir)/'`ResolvExpr/ResolveAssertions.cc 1975 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ResolveAssertions.Tpo ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ResolveAssertions.Po 1976 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ResolvExpr/ResolveAssertions.cc' object='ResolvExpr/driver_cfa_cpp-ResolveAssertions.o' libtool=no @AMDEPBACKSLASH@ 1977 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1978 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ResolvExpr/driver_cfa_cpp-ResolveAssertions.o `test -f 'ResolvExpr/ResolveAssertions.cc' || echo '$(srcdir)/'`ResolvExpr/ResolveAssertions.cc 1979 1980 ResolvExpr/driver_cfa_cpp-ResolveAssertions.obj: ResolvExpr/ResolveAssertions.cc 1981 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ResolvExpr/driver_cfa_cpp-ResolveAssertions.obj -MD -MP -MF ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ResolveAssertions.Tpo -c -o ResolvExpr/driver_cfa_cpp-ResolveAssertions.obj `if test -f 'ResolvExpr/ResolveAssertions.cc'; then $(CYGPATH_W) 'ResolvExpr/ResolveAssertions.cc'; else $(CYGPATH_W) '$(srcdir)/ResolvExpr/ResolveAssertions.cc'; fi` 1982 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ResolveAssertions.Tpo ResolvExpr/$(DEPDIR)/driver_cfa_cpp-ResolveAssertions.Po 1983 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ResolvExpr/ResolveAssertions.cc' object='ResolvExpr/driver_cfa_cpp-ResolveAssertions.obj' libtool=no @AMDEPBACKSLASH@ 1984 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1985 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ResolvExpr/driver_cfa_cpp-ResolveAssertions.obj `if test -f 'ResolvExpr/ResolveAssertions.cc'; then $(CYGPATH_W) 'ResolvExpr/ResolveAssertions.cc'; else $(CYGPATH_W) '$(srcdir)/ResolvExpr/ResolveAssertions.cc'; fi` 1986 1968 1987 SymTab/driver_cfa_cpp-Indexer.o: SymTab/Indexer.cc 1969 1988 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SymTab/driver_cfa_cpp-Indexer.o -MD -MP -MF SymTab/$(DEPDIR)/driver_cfa_cpp-Indexer.Tpo -c -o SymTab/driver_cfa_cpp-Indexer.o `test -f 'SymTab/Indexer.cc' || echo '$(srcdir)/'`SymTab/Indexer.cc -
src/ResolvExpr/Resolver.cc
r6171841 r8573729 15 15 16 16 #include <stddef.h> // for NULL 17 #include <algorithm> // for sort 17 18 #include <cassert> // for strict_dynamic_cast, assert 18 19 #include <memory> // for allocator, allocator_traits<... … … 29 30 #include "InitTweak/InitTweak.h" // for isIntrinsicSingleArgCallStmt 30 31 #include "RenameVars.h" // for RenameVars, global_renamer 32 #include "ResolveAssertions.h" // for resolveAssertions 31 33 #include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment 32 34 #include "ResolveTypeof.h" // for resolveTypeof … … 169 171 } 170 172 171 // xxx - if > 1 alternative with same cost, ignore deleted and pick from remaining 172 // choose the lowest cost expression among the candidates 173 // sort candidates by cost 174 std::sort( candidates.begin(), candidates.end(), 175 [](const Alternative& a, const Alternative& b) { return a.cost < b.cost; } ); 176 // search for cheapest resolvable candidate 173 177 AltList winners; 174 findMinCost( candidates.begin(), candidates.end(), back_inserter( winners ) ); 178 for ( const Alternative& r : candidates ) { 179 if ( ! winners.empty() ) { 180 // break if already have a cheaper candidate 181 if ( winners[0].cost < r.cost ) break; 182 183 // ignore min-cost deleted alternatives if already found one alternative 184 if ( findDeletedExpr( r.expr ) ) continue; 185 } 186 187 // check candidate assertion resolution 188 if ( resolveAssertions( r.expr ) ) { 189 winners.push_back( r ); 190 } 191 } 192 175 193 if ( winners.size() == 0 ) { 176 194 SemanticError( untyped, toString( "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""), "expression: ") ); … … 281 299 Type *new_type = resolveTypeof( objectDecl->get_type(), indexer ); 282 300 objectDecl->set_type( new_type ); 283 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that class-variable284 // initContext is changed multiple time because the LHS is analysed twice. The second analysis changes285 // initContext because of a function type can contain object declarations in the return and parameter types. So286 // each value of initContext is retained, so the type on the first analysis is preserved and used for selecting287 // the RHS.301 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that 302 // class-variable initContext is changed multiple time because the LHS is analysed twice. 303 // The second analysis changes initContext because of a function type can contain object 304 // declarations in the return and parameter types. So each value of initContext is retained, 305 // so the type on the first analysis is preserved and used for selecting the RHS. 288 306 GuardValue( currentObject ); 289 307 currentObject = CurrentObject( objectDecl->get_type() ); … … 329 347 330 348 { 331 // resolve with-exprs with parameters in scope and add any newly generated declarations to the 332 // front of the function body. 333 auto guard = makeFuncGuard( [this]() { indexer.enterScope(); }, [this](){ indexer.leaveScope(); } ); 349 // resolve with-exprs with parameters in scope and add any newly generated declarations 350 // to the front of the function body. 351 auto guard = makeFuncGuard( 352 [this]() { indexer.enterScope(); }, [this](){ indexer.leaveScope(); } ); 334 353 indexer.addFunctionType( functionDecl->type ); 335 354 std::list< Statement * > newStmts; … … 344 363 345 364 void Resolver::postvisit( FunctionDecl *functionDecl ) { 346 // default value expressions have an environment which shouldn't be there and trips up later passes. 347 // xxx - it might be necessary to somehow keep the information from this environment, but I can't currently 348 // see how it's useful. 365 // default value expressions have an environment which shouldn't be there and trips up 366 // later passes. 367 // xxx - it might be necessary to somehow keep the information from this environment, but I 368 // can't currently see how it's useful. 349 369 for ( Declaration * d : functionDecl->type->parameters ) { 350 370 if ( ObjectDecl * obj = dynamic_cast< ObjectDecl * >( d ) ) { -
src/ResolvExpr/module.mk
r6171841 r8573729 33 33 ResolvExpr/TypeEnvironment.cc \ 34 34 ResolvExpr/CurrentObject.cc \ 35 ResolvExpr/ExplodedActual.cc 35 ResolvExpr/ExplodedActual.cc \ 36 ResolvExpr/ResolveAssertions.cc
Note: See TracChangeset
for help on using the changeset viewer.