Changes in / [d66e7b7:896737b]
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
driver/Makefile.am
rd66e7b7 r896737b 19 19 20 20 # applies to both programs 21 AM_CXXFLAGS = @HOST_FLAGS@ -Wall -O2 -g -std=c++14 -I${abs_top_srcdir}/src 21 AM_CXXFLAGS = @HOST_FLAGS@ -Wall -O2 -g -std=c++14 -I${abs_top_srcdir}/src -I${abs_top_srcdir}/src/include 22 22 23 23 # don't install cfa directly -
driver/Makefile.in
rd66e7b7 r896737b 334 334 335 335 # applies to both programs 336 AM_CXXFLAGS = @HOST_FLAGS@ -Wall -O2 -g -std=c++14 -I${abs_top_srcdir}/src 336 AM_CXXFLAGS = @HOST_FLAGS@ -Wall -O2 -g -std=c++14 -I${abs_top_srcdir}/src -I${abs_top_srcdir}/src/include 337 337 cfa_SOURCES = cfa.cc 338 338 -
src/AST/Decl.hpp
rd66e7b7 r896737b 101 101 ptr<Expr> bitfieldWidth; 102 102 103 ObjectDecl( const CodeLocation & loc, const std::string& name, Type* type, Init* init = nullptr,104 Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, Expr * bitWd = nullptr,105 std::vector< ptr<Attribute>>&& attrs = {}, Function::Specs fs = {})103 ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type, Init * init = nullptr, 104 Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, Expr * bitWd = nullptr, 105 std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {}) 106 106 : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ), 107 107 init( init ), bitfieldWidth( bitWd ) {} -
src/AST/DeclReplacer.cpp
rd66e7b7 r896737b 14 14 // 15 15 16 # errorunimplemented16 #warning unimplemented 17 17 18 18 // Local Variables: // -
src/AST/Expr.cpp
rd66e7b7 r896737b 95 95 Type * addrType( const Type * type ) { 96 96 if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * >( type ) ) { 97 CV::Qualifiers quals = refType->qualifiers;98 97 return new ReferenceType{ addrType( refType->base ), refType->qualifiers }; 99 98 } else { … … 118 117 result = res; 119 118 } else { 120 SemanticError( loc, arg->result ,119 SemanticError( loc, arg->result.get(), 121 120 "Attempt to take address of non-lvalue expression: " ); 122 121 } … … 283 282 // --- ConstructorExpr 284 283 285 ConstructorExpr::ConstructorExpr( const CodeLocation & loc, const Expr * call ) 284 ConstructorExpr::ConstructorExpr( const CodeLocation & loc, const Expr * call ) 286 285 : Expr( loc ), callExpr( call ) { 287 // allow resolver to type a constructor used as an expression if it has the same type as its 286 // allow resolver to type a constructor used as an expression if it has the same type as its 288 287 // first argument 289 288 assert( callExpr ); … … 310 309 TupleIndexExpr::TupleIndexExpr( const CodeLocation & loc, const Expr * t, unsigned i ) 311 310 : Expr( loc ), tuple( t ), index( i ) { 312 const TupleType * type = strict_dynamic_cast< const TupleType * >( tuple->result );311 const TupleType * type = strict_dynamic_cast< const TupleType * >( tuple->result.get() ); 313 312 assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested " 314 313 "index %d in expr %s", type->size(), index, toString( tuple ).c_str() ); … … 319 318 // --- TupleAssignExpr 320 319 321 TupleAssignExpr::TupleAssignExpr( 322 const CodeLocation & loc, std::vector<ptr<Expr>> && assigns, 320 TupleAssignExpr::TupleAssignExpr( 321 const CodeLocation & loc, std::vector<ptr<Expr>> && assigns, 323 322 std::vector<ptr<ObjectDecl>> && tempDecls ) 324 323 : Expr( loc, Tuples::makeTupleType( assigns ) ), stmtExpr() { 325 // convert internally into a StmtExpr which contains the declarations and produces the tuple of 324 // convert internally into a StmtExpr which contains the declarations and produces the tuple of 326 325 // the assignments 327 326 std::list<ptr<Stmt>> stmts; … … 337 336 // --- StmtExpr 338 337 339 StmtExpr::StmtExpr( const CodeLocation & loc, const CompoundStmt * ss ) 338 StmtExpr::StmtExpr( const CodeLocation & loc, const CompoundStmt * ss ) 340 339 : Expr( loc ), stmts( ss ), returnDecls(), dtors() { computeResult(); } 341 340 … … 344 343 const std::list<ptr<Stmt>> & body = stmts->kids; 345 344 if ( ! returnDecls.empty() ) { 346 // prioritize return decl for result type, since if a return decl exists, then the StmtExpr 345 // prioritize return decl for result type, since if a return decl exists, then the StmtExpr 347 346 // is currently in an intermediate state where the body will always give a void result type 348 347 result = returnDecls.front()->get_type(); … … 360 359 unsigned long long UniqueExpr::nextId = 0; 361 360 362 UniqueExpr::UniqueExpr( const CodeLocation & loc, const Expr * e, unsigned long long i = -1)361 UniqueExpr::UniqueExpr( const CodeLocation & loc, const Expr * e, unsigned long long i ) 363 362 : Expr( loc, e->result ), id( i ) { 364 363 assert( expr ); 365 if ( id == -1 ) {366 assert( nextId != -1 );364 if ( id == -1ull ) { 365 assert( nextId != -1ull ); 367 366 id = nextId++; 368 367 } 368 } 369 369 370 } 370 371 -
src/AST/Fwd.hpp
rd66e7b7 r896737b 125 125 class ConstructorInit; 126 126 127 class Constant;128 129 127 class Label; 130 128 … … 135 133 std::string toString( const Node * ); 136 134 135 template < typename ... Params > 136 std::string toString( const Params & ... params ); 137 137 138 typedef unsigned int UniqueId; 138 139 -
src/AST/Node.cpp
rd66e7b7 r896737b 16 16 #include "Node.hpp" 17 17 #include "Fwd.hpp" 18 19 #include "Attribute.hpp" 18 20 #include "Decl.hpp" 19 21 #include "Expr.hpp" 22 #include "Init.hpp" 20 23 #include "Stmt.hpp" 21 24 #include "Type.hpp" 25 #include "TypeSubstitution.hpp" 22 26 23 27 template< typename node_t, enum ast::Node::ref_type ref_t > … … 26 30 template< typename node_t, enum ast::Node::ref_type ref_t > 27 31 void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node ) { node->decrement(ref_t); } 32 33 /// Sets this pointer to a mutated version of a pointer (possibly) owned elsehere. 34 /// Returns a mutable version of the pointer in this node. 35 template< typename node_t, enum ast::Node::ref_type ref_t > 36 node_t * ast::ptr_base<node_t, ref_t>::set_and_mutate( const node_t * n ) { 37 // ensure ownership of `n` by this node to avoid spurious single-owner mutates 38 assign( n ); 39 // get mutable version of `n` 40 auto r = mutate( node ); 41 // re-assign mutable version in case `mutate()` produced a new pointer 42 assign( r ); 43 return r; 44 } 28 45 29 46 template class ast::ptr_base< ast::Node, ast::Node::ref_type::weak >; … … 227 244 template class ast::ptr_base< ast::ConstructorInit, ast::Node::ref_type::weak >; 228 245 template class ast::ptr_base< ast::ConstructorInit, ast::Node::ref_type::strong >; 229 template class ast::ptr_base< ast::Constant, ast::Node::ref_type::weak >;230 template class ast::ptr_base< ast::Constant, ast::Node::ref_type::strong >;231 246 template class ast::ptr_base< ast::Attribute, ast::Node::ref_type::weak >; 232 247 template class ast::ptr_base< ast::Attribute, ast::Node::ref_type::strong >; -
src/AST/Node.hpp
rd66e7b7 r896737b 143 143 /// Sets this pointer to a mutated version of a pointer (possibly) owned elsehere. 144 144 /// Returns a mutable version of the pointer in this node. 145 node_t * set_and_mutate( const node_t * n ) { 146 // ensure ownership of `n` by this node to avoid spurious single-owner mutates 147 assign( n ); 148 // get mutable version of `n` 149 auto r = mutate( node ); 150 // re-assign mutable version in case `mutate()` produced a new pointer 151 assign( r ); 152 return r; 153 } 145 node_t * set_and_mutate( const node_t * n ); 154 146 155 147 using ptr = const node_t *; -
src/AST/Pass.hpp
rd66e7b7 r896737b 175 175 const ast::Init * visit( const ast::ListInit * ) override final; 176 176 const ast::Init * visit( const ast::ConstructorInit * ) override final; 177 const ast::Constant * visit( const ast::Constant * ) override final;178 177 const ast::Attribute * visit( const ast::Attribute * ) override final; 179 178 const ast::TypeSubstitution * visit( const ast::TypeSubstitution * ) override final; -
src/AST/Pass.impl.hpp
rd66e7b7 r896737b 791 791 792 792 //-------------------------------------------------------------------------- 793 // CatchStmt 794 template< typename pass_t > 795 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::CatchStmt * node ) { 796 VISIT_START( node ); 797 798 VISIT({ 799 // catch statements introduce a level of scope (for the caught exception) 800 guard_indexer guard { *this }; 801 maybe_accept( node, &CatchStmt::decl ); 802 maybe_accept( node, &CatchStmt::cond ); 803 maybe_accept( node, &CatchStmt::body ); 804 }) 805 806 VISIT_END( Stmt, node ); 807 } 808 809 //-------------------------------------------------------------------------- 810 // FinallyStmt 811 template< typename pass_t > 812 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::FinallyStmt * node ) { 813 VISIT_START( node ); 814 815 VISIT( 816 maybe_accept( node, &FinallyStmt::body ); 817 ) 818 819 VISIT_END( Stmt, node ); 820 } 821 822 //-------------------------------------------------------------------------- 823 // WaitForStmt 824 template< typename pass_t > 825 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WaitForStmt * node ) { 826 VISIT_START( node ); 827 // for( auto & clause : node->clauses ) { 828 // maybeAccept_impl( clause.target.function, *this ); 829 // maybeAccept_impl( clause.target.arguments, *this ); 830 831 // maybeAccept_impl( clause.statement, *this ); 832 // maybeAccept_impl( clause.condition, *this ); 833 // } 834 835 #define maybe_accept(field) \ 836 if(node->field) { \ 837 auto nval = call_accept( node->field ); \ 838 if(nval != node->field ) { \ 839 auto nparent = mutate(node); \ 840 nparent->field = nval; \ 841 node = nparent; \ 842 } \ 843 } 844 845 VISIT( 846 maybe_accept( timeout.time ); 847 maybe_accept( timeout.stmt ); 848 maybe_accept( timeout.cond ); 849 maybe_accept( orElse.stmt ); 850 maybe_accept( orElse.cond ); 851 ) 852 853 #undef maybe_accept 854 855 VISIT_END( Stmt, node ); 856 } 857 858 //-------------------------------------------------------------------------- 859 // WithStmt 860 template< typename pass_t > 861 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WithStmt * node ) { 862 VISIT_START( node ); 863 864 VISIT( 865 maybe_accept( node, &WithStmt::exprs ); 866 { 867 // catch statements introduce a level of scope (for the caught exception) 868 guard_indexer guard { *this }; 869 __pass::indexer::addWith( pass, 0, node->exprs, node ); 870 maybe_accept( node, &WithStmt::stmt ); 871 } 872 ) 873 VISIT_END( Stmt, node ); 874 } 875 876 //-------------------------------------------------------------------------- 877 // NullStmt 878 template< typename pass_t > 879 const ast::NullStmt * ast::Pass< pass_t >::visit( const ast::NullStmt * node ) { 880 VISIT_START( node ); 881 VISIT_END( NullStmt, node ); 882 } 883 884 //-------------------------------------------------------------------------- 885 // DeclStmt 886 template< typename pass_t > 887 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::DeclStmt * node ) { 888 VISIT_START( node ); 889 890 VISIT( 891 maybe_accept( node, &DeclStmt::decl ); 892 ) 893 894 VISIT_END( Stmt, node ); 895 } 896 897 //-------------------------------------------------------------------------- 898 // ImplicitCtorDtorStmt 899 template< typename pass_t > 900 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ImplicitCtorDtorStmt * node ) { 901 VISIT_START( node ); 902 903 // For now this isn't visited, it is unclear if this causes problem 904 // if all tests are known to pass, remove this code 905 // VISIT( 906 // maybe_accept( node, &ImplicitCtorDtorStmt::callStmt ); 907 // ) 908 909 VISIT_END( Stmt, node ); 910 } 911 912 913 914 915 916 917 //-------------------------------------------------------------------------- 793 918 // SingleInit 794 919 template< typename pass_t > -
src/AST/Pass.proto.hpp
rd66e7b7 r896737b 241 241 INDEXER_FUNC1( addUnion , const UnionDecl * ); 242 242 INDEXER_FUNC1( addTrait , const TraitDecl * ); 243 INDEXER_FUNC2( addWith , const std::list< ptr<Expr> > &, const Node * ); 243 INDEXER_FUNC2( addWith , const std::vector< ptr<Expr> > &, const Node * ); 244 INDEXER_FUNC2( addWith , const std::list < ptr<Expr> > &, const Node * ); 244 245 245 246 // A few extra functions have more complicated behaviour, they are hand written -
src/AST/Visitor.hpp
rd66e7b7 r896737b 111 111 virtual const ast::Init * visit( const ast::ListInit * ) = 0; 112 112 virtual const ast::Init * visit( const ast::ConstructorInit * ) = 0; 113 virtual const ast::Constant * visit( const ast::Constant * ) = 0;114 113 virtual const ast::Attribute * visit( const ast::Attribute * ) = 0; 115 114 virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * ) = 0; -
src/Common/SemanticError.h
rd66e7b7 r896737b 17 17 18 18 #include "ErrorObjects.h" 19 #include "AST/Node.hpp" 19 20 #include <cstring> 20 21 -
src/InitTweak/InitTweak.cc
rd66e7b7 r896737b 437 437 // const ast::Expr * callArg( const CallExpr * call, unsigned int pos ) { 438 438 // if( pos >= call->args.size() ) { 439 // assertf( false, "getCallArg for argument that doesn't exist: (%u); %s.", 439 // assertf( false, "getCallArg for argument that doesn't exist: (%u); %s.", 440 440 // pos, toString( call ).c_str() ); 441 441 // } … … 467 467 } 468 468 const ast::Expr * getCallArg( const ast::Expr * call, unsigned pos ) { 469 assert(!"implemented; needs to build AST/Expr.cpp"); 469 (void)call; 470 (void)pos; 471 #warning unimplemented; needs to build AST/Expr.cpp 472 assertf(false, "unimplemented; needs to build AST/Expr.cpp"); 470 473 // if ( auto app = dynamic_cast< const ast::ApplicationExpr * >( call ) ) { 471 474 // return callArg( app, pos ); … … 482 485 // return getCallArg( ctor->callExpr, pos ); 483 486 // } else { 484 // assertf( false, "Unexpected expression type passed to getCallArg: %s", 487 // assertf( false, "Unexpected expression type passed to getCallArg: %s", 485 488 // toString( call ).c_str() ); 486 489 // } … … 548 551 } 549 552 const ast::Type* getPointerBase( const ast::Type* t ) { 550 assert(!"needs to build Type.cpp before inclusion"); 553 (void)t; 554 #warning needs to build Type.cpp before inclusion 555 assertf(false, "needs to build Type.cpp before inclusion"); 551 556 // if ( const auto * p = dynamic_cast< const ast::PointerType * >( t ) ) { 552 557 // return p->base; -
src/SynTree/Declaration.cc
rd66e7b7 r896737b 31 31 32 32 Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) 33 : name( name ), linkage( linkage ), storageClasses( scs ), uniqueId( 0) {33 : name( name ), linkage( linkage ), uniqueId( 0 ), storageClasses( scs ) { 34 34 } 35 35 36 36 Declaration::Declaration( const Declaration &other ) 37 : BaseSyntaxNode( other ), name( other.name ), linkage( other.linkage ), extension( other.extension ), storageClasses( other.storageClasses ), uniqueId( other.uniqueId) {37 : BaseSyntaxNode( other ), name( other.name ), linkage( other.linkage ), extension( other.extension ), uniqueId( other.uniqueId ), storageClasses( other.storageClasses ) { 38 38 } 39 39 -
src/Tuples/TupleExpansion.cc
rd66e7b7 r896737b 320 320 } 321 321 const ast::Type * makeTupleType( const std::vector<ast::ptr<ast::Expr>> & exprs ) { 322 assert(!"implemented; needs Type.cpp in build"); 322 (void) exprs; 323 #warning Not implemented; needs Type.cpp in build 324 assertf(false, "Not implemented; needs Type.cpp in build"); 323 325 // // produce the TupleType which aggregates the types of the exprs 324 326 // std::vector<ast::ptr<ast::Type>> types; 325 // ast::CV::Qualifiers quals{ 326 // ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue | 327 // ast::CV::Qualifiers quals{ 328 // ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue | 327 329 // ast::CV::Atomic | ast::CV::Mutex }; 328 330 329 331 // for ( const ast::Expr * expr : exprs ) { 330 332 // assert( expr->result ); -
src/Tuples/Tuples.h
rd66e7b7 r896737b 29 29 namespace Tuples { 30 30 // TupleAssignment.cc 31 void handleTupleAssignment( ResolvExpr::AlternativeFinder & currentFinder, UntypedExpr * assign, 31 void handleTupleAssignment( ResolvExpr::AlternativeFinder & currentFinder, UntypedExpr * assign, 32 32 std::vector< ResolvExpr::AlternativeFinder >& args ); 33 33 34 34 // TupleExpansion.cc 35 35 /// expands z.[a, b.[x, y], c] into [z.a, z.b.x, z.b.y, z.c], inserting UniqueExprs as appropriate … … 48 48 /// returns a TypeInstType if `type` is a ttype, nullptr otherwise 49 49 TypeInstType * isTtype( Type * type ); 50 const ast::TypeInstType * isTtype( const ast::Type * type ); 50 51 51 52 /// returns true if the expression may contain side-effects.
Note: See TracChangeset
for help on using the changeset viewer.