- Timestamp:
- May 20, 2022, 10:36:45 AM (4 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 25fa20a
- Parents:
- 29d8c02 (diff), 7831e8fb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 14 added
- 1 deleted
- 54 edited
-
AST/Convert.cpp (modified) (5 diffs)
-
AST/Copy.cpp (modified) (2 diffs)
-
AST/Decl.cpp (modified) (3 diffs)
-
AST/Decl.hpp (modified) (2 diffs)
-
AST/Eval.hpp (deleted)
-
AST/Expr.cpp (modified) (5 diffs)
-
AST/Expr.hpp (modified) (2 diffs)
-
AST/Label.hpp (modified) (1 diff)
-
AST/Node.hpp (modified) (2 diffs)
-
AST/Pass.proto.hpp (modified) (3 diffs)
-
AST/Stmt.cpp (modified) (2 diffs)
-
AST/Stmt.hpp (modified) (2 diffs)
-
AST/Util.cpp (modified) (3 diffs)
-
AST/module.mk (modified) (1 diff)
-
CodeGen/CodeGenerator.cc (modified) (1 diff)
-
CodeGen/FixMain.cc (modified) (1 diff)
-
CodeGen/FixMain2.cc (added)
-
CodeGen/LinkOnce.cc (modified) (1 diff)
-
CodeGen/module.mk (modified) (1 diff)
-
Common/CodeLocationTools.cpp (modified) (4 diffs)
-
Common/Indenter.cc (added)
-
Common/Indenter.h (modified) (2 diffs)
-
Common/SemanticError.h (modified) (4 diffs)
-
Common/module.mk (modified) (1 diff)
-
Common/utility.h (modified) (2 diffs)
-
Concurrency/module.mk (modified) (1 diff)
-
ControlStruct/LabelGeneratorNew.hpp (modified) (1 diff)
-
ControlStruct/MultiLevelExit.cpp (modified) (6 diffs)
-
ControlStruct/module.mk (modified) (2 diffs)
-
GenPoly/Lvalue.cc (modified) (2 diffs)
-
GenPoly/Lvalue2.cc (added)
-
GenPoly/module.mk (modified) (1 diff)
-
InitTweak/FixInitNew.cpp (modified) (4 diffs)
-
InitTweak/module.mk (modified) (2 diffs)
-
Parser/DeclarationNode.cc (modified) (3 diffs)
-
Parser/ParseNode.h (modified) (1 diff)
-
Parser/TypeData.cc (modified) (2 diffs)
-
Parser/parser.yy (modified) (21 diffs)
-
ResolvExpr/AlternativeFinder.cc (modified) (1 diff)
-
ResolvExpr/Resolver.cc (modified) (2 diffs)
-
SymTab/Autogen.h (modified) (14 diffs)
-
SymTab/Demangle.cc (modified) (1 diff)
-
SymTab/Demangle.h (added)
-
SymTab/Mangler.h (modified) (1 diff)
-
SymTab/Validate.cc (modified) (12 diffs)
-
SymTab/Validate.h (modified) (3 diffs)
-
SymTab/ValidateType.cc (added)
-
SymTab/ValidateType.h (added)
-
SymTab/demangler.cc (modified) (1 diff)
-
SymTab/module.mk (modified) (1 diff)
-
SynTree/BaseSyntaxNode.cc (added)
-
SynTree/module.mk (modified) (1 diff)
-
Tuples/TupleExpansion.cc (modified) (2 diffs)
-
Tuples/Tuples.cc (modified) (5 diffs)
-
Tuples/module.mk (modified) (2 diffs)
-
Validate/Autogen.cpp (modified) (2 diffs)
-
Validate/EliminateTypedef.cpp (added)
-
Validate/EliminateTypedef.hpp (added)
-
Validate/FixQualifiedTypes.cpp (added)
-
Validate/FixQualifiedTypes.hpp (added)
-
Validate/ForallPointerDecay.cpp (modified) (2 diffs)
-
Validate/ForallPointerDecay.hpp (modified) (2 diffs)
-
Validate/GenericParameter.cpp (modified) (3 diffs)
-
Validate/HoistStruct.cpp (added)
-
Validate/HoistStruct.hpp (added)
-
Validate/NoIdSymbolTable.hpp (added)
-
Validate/module.mk (modified) (2 diffs)
-
Virtual/module.mk (modified) (1 diff)
-
main.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r29d8c02 r74ec742 93 93 }; 94 94 95 template<typename T>96 Getter<T> get() {97 return Getter<T>{ *this };98 }95 template<typename T> 96 Getter<T> get() { 97 return Getter<T>{ *this }; 98 } 99 99 100 100 Label makeLabel(Statement * labelled, const ast::Label& label) { … … 1651 1651 // GET_ACCEPT_1(type, FunctionType), 1652 1652 std::move(forall), 1653 std::move(assertions), 1653 1654 std::move(paramVars), 1654 1655 std::move(returnVars), … … 1664 1665 cache.emplace( old, decl ); 1665 1666 1666 decl->assertions = std::move(assertions);1667 1667 decl->withExprs = GET_ACCEPT_V(withExprs, Expr); 1668 1668 decl->stmts = GET_ACCEPT_1(statements, CompoundStmt); … … 1730 1730 } 1731 1731 1732 // Convert SynTree::EnumDecl to AST::EnumDecl 1732 1733 1733 virtual void visit( const EnumDecl * old ) override final { 1734 1734 if ( inCache( old ) ) return; … … 2729 2729 ty->forall.emplace_back(new ast::TypeInstType(param)); 2730 2730 for (auto asst : param->assertions) { 2731 ty->assertions.emplace_back(new ast::VariableExpr({}, asst)); 2731 ty->assertions.emplace_back( 2732 new ast::VariableExpr(param->location, asst)); 2732 2733 } 2733 2734 } -
src/AST/Copy.cpp
r29d8c02 r74ec742 10 10 // Created On : Thr Nov 11 9:16:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T hr Nov 11 9:28:00 202113 // Update Count : 012 // Last Modified On : Tue May 3 16:28:00 2022 13 // Update Count : 1 14 14 // 15 15 … … 77 77 } 78 78 79 void postvisit( const UniqueExpr * node ) { 80 readonlyInsert( &node->object ); 81 } 82 79 83 void postvisit( const MemberExpr * node ) { 80 84 readonlyInsert( &node->member ); -
src/AST/Decl.cpp
r29d8c02 r74ec742 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Jan 12 16:54:55 202113 // Update Count : 2 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu May 5 12:10:00 2022 13 // Update Count : 24 14 14 // 15 15 … … 53 53 // --- FunctionDecl 54 54 55 FunctionDecl::FunctionDecl( const CodeLocation & loc, const std::string & name, 55 FunctionDecl::FunctionDecl( const CodeLocation & loc, const std::string & name, 56 56 std::vector<ptr<TypeDecl>>&& forall, 57 57 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, … … 74 74 } 75 75 this->type = ftype; 76 } 77 78 FunctionDecl::FunctionDecl( const CodeLocation & location, const std::string & name, 79 std::vector<ptr<TypeDecl>>&& forall, std::vector<ptr<DeclWithType>>&& assertions, 80 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, 81 CompoundStmt * stmts, Storage::Classes storage, Linkage::Spec linkage, 82 std::vector<ptr<Attribute>>&& attrs, Function::Specs fs, bool isVarArgs) 83 : DeclWithType( location, name, storage, linkage, std::move(attrs), fs ), 84 params( std::move(params) ), returns( std::move(returns) ), 85 type_params( std::move( forall) ), assertions( std::move( assertions ) ), 86 type( nullptr ), stmts( stmts ) { 87 FunctionType * type = new FunctionType( (isVarArgs) ? VariableArgs : FixedArgs ); 88 for ( auto & param : this->params ) { 89 type->params.emplace_back( param->get_type() ); 90 } 91 for ( auto & ret : this->returns ) { 92 type->returns.emplace_back( ret->get_type() ); 93 } 94 for ( auto & param : this->type_params ) { 95 type->forall.emplace_back( new TypeInstType( param ) ); 96 } 97 for ( auto & assertion : this->assertions ) { 98 type->assertions.emplace_back( 99 new VariableExpr( assertion->location, assertion ) ); 100 } 101 this->type = type; 76 102 } 77 103 -
src/AST/Decl.hpp
r29d8c02 r74ec742 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 12 18:25:05 202113 // Update Count : 3 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu May 5 12:09:00 2022 13 // Update Count : 33 14 14 // 15 15 … … 135 135 std::vector< ptr<Expr> > withExprs; 136 136 137 // The difference between the two constructors is in how they handle 138 // assertions. The first constructor uses the assertions from the type 139 // parameters, in the style of the old ast, and puts them on the type. 140 // The second takes an explicite list of assertions and builds a list of 141 // references to them on the type. 142 137 143 FunctionDecl( const CodeLocation & loc, const std::string & name, std::vector<ptr<TypeDecl>>&& forall, 138 144 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, 139 145 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, 140 146 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}, bool isVarArgs = false); 141 // : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), params(std::move(params)), returns(std::move(returns)), 142 // stmts( stmts ) {} 147 148 FunctionDecl( const CodeLocation & location, const std::string & name, 149 std::vector<ptr<TypeDecl>>&& forall, std::vector<ptr<DeclWithType>>&& assertions, 150 std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns, 151 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, 152 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}, bool isVarArgs = false); 143 153 144 154 const Type * get_type() const override; -
src/AST/Expr.cpp
r29d8c02 r74ec742 10 10 // Created On : Wed May 15 17:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Created On : Tue Nov 30 14:23:00 202113 // Update Count : 712 // Created On : Wed May 18 13:56:00 2022 13 // Update Count : 8 14 14 // 15 15 … … 21 21 22 22 #include "Copy.hpp" // for shallowCopy 23 #include "Eval.hpp" // for call24 23 #include "GenericSubstitution.hpp" 25 24 #include "LinkageSpec.hpp" … … 67 66 // --- UntypedExpr 68 67 68 bool UntypedExpr::get_lvalue() const { 69 std::string fname = InitTweak::getFunctionName( this ); 70 return lvalueFunctionNames.count( fname ); 71 } 72 69 73 UntypedExpr * UntypedExpr::createDeref( const CodeLocation & loc, const Expr * arg ) { 70 74 assert( arg ); 71 75 72 UntypedExpr * ret = c all( loc, "*?", arg);76 UntypedExpr * ret = createCall( loc, "*?", { arg } ); 73 77 if ( const Type * ty = arg->result ) { 74 78 const Type * base = InitTweak::getPointerBase( ty ); … … 87 91 } 88 92 89 bool UntypedExpr::get_lvalue() const {90 std::string fname = InitTweak::getFunctionName( this );91 return lvalueFunctionNames.count( fname );92 }93 94 93 UntypedExpr * UntypedExpr::createAssign( const CodeLocation & loc, const Expr * lhs, const Expr * rhs ) { 95 94 assert( lhs && rhs ); 96 95 97 UntypedExpr * ret = c all( loc, "?=?", lhs, rhs);96 UntypedExpr * ret = createCall( loc, "?=?", { lhs, rhs } ); 98 97 if ( lhs->result && rhs->result ) { 99 98 // if both expressions are typed, assumes that this assignment is a C bitwise assignment, … … 102 101 } 103 102 return ret; 103 } 104 105 UntypedExpr * UntypedExpr::createCall( const CodeLocation & loc, 106 const std::string & name, std::vector<ptr<Expr>> && args ) { 107 return new UntypedExpr( loc, 108 new NameExpr( loc, name ), std::move( args ) ); 104 109 } 105 110 -
src/AST/Expr.hpp
r29d8c02 r74ec742 230 230 /// Creates a new assignment expression 231 231 static UntypedExpr * createAssign( const CodeLocation & loc, const Expr * lhs, const Expr * rhs ); 232 /// Creates a new call of a variable. 233 static UntypedExpr * createCall( const CodeLocation & loc, 234 const std::string & name, std::vector<ptr<Expr>> && args ); 232 235 233 236 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } … … 784 787 public: 785 788 ptr<Expr> expr; 786 ptr<ObjectDecl> object;789 readonly<ObjectDecl> object; 787 790 ptr<VariableExpr> var; 788 791 unsigned long long id; -
src/AST/Label.hpp
r29d8c02 r74ec742 34 34 std::vector< ptr<Attribute> > attributes; 35 35 36 Label( CodeLocationloc, const std::string& name = "",36 Label( const CodeLocation& loc, const std::string& name = "", 37 37 std::vector<ptr<Attribute>> && attrs = std::vector<ptr<Attribute>>{} ) 38 38 : location( loc ), name( name ), attributes( attrs ) {} -
src/AST/Node.hpp
r29d8c02 r74ec742 10 10 // Created On : Wed May 8 10:27:04 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Mar 25 10:33:00 202213 // Update Count : 712 // Last Modified On : Mon May 9 10:20:00 2022 13 // Update Count : 8 14 14 // 15 15 … … 49 49 50 50 bool unique() const { return strong_count == 1; } 51 bool isManaged() const {return strong_count > 0; } 51 bool isManaged() const { return strong_count > 0; } 52 bool isReferenced() const { return weak_count > 0; } 53 bool isStable() const { 54 return (1 == strong_count || (1 < strong_count && 0 == weak_count)); 55 } 52 56 53 57 private: -
src/AST/Pass.proto.hpp
r29d8c02 r74ec742 131 131 template< typename node_t > 132 132 struct result1 { 133 bool differs ;134 const node_t * value ;133 bool differs = false; 134 const node_t * value = nullptr; 135 135 136 136 template< typename object_t, typename super_t, typename field_t > … … 151 151 }; 152 152 153 bool differs ;153 bool differs = false; 154 154 container_t< delta > values; 155 155 … … 167 167 template< template<class...> class container_t, typename node_t > 168 168 struct resultN { 169 bool differs ;169 bool differs = false; 170 170 container_t<ptr<node_t>> values; 171 171 -
src/AST/Stmt.cpp
r29d8c02 r74ec742 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 8 13:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Feb 2 19:01:20 202213 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue May 3 15:18:20 2022 13 // Update Count : 4 14 14 // 15 15 16 16 #include "Stmt.hpp" 17 17 18 18 #include "Copy.hpp" 19 19 #include "DeclReplacer.hpp" 20 20 #include "Type.hpp" … … 23 23 24 24 // --- CompoundStmt 25 CompoundStmt::CompoundStmt( const CompoundStmt& other ) : Stmt(other), kids(other.kids) { 25 CompoundStmt::CompoundStmt( const CompoundStmt& other ) : Stmt(other), kids() { 26 // Statements can have weak references to them, if that happens inserting 27 // the original node into the new list will put the original node in a 28 // bad state, where it cannot be mutated. To avoid this, just perform an 29 // additional shallow copy on the statement. 30 for ( const Stmt * kid : other.kids ) { 31 if ( kid->isReferenced() ) { 32 kids.emplace_back( ast::shallowCopy( kid ) ); 33 } else { 34 kids.emplace_back( kid ); 35 } 36 } 37 26 38 // when cloning a compound statement, we may end up cloning declarations which 27 39 // are referred to by VariableExprs throughout the block. Cloning a VariableExpr -
src/AST/Stmt.hpp
r29d8c02 r74ec742 58 58 // cannot be, they are sub-types of this type, for organization. 59 59 60 StmtClause( const CodeLocation & loc )60 StmtClause( const CodeLocation & loc ) 61 61 : ParseNode(loc) {} 62 62 … … 396 396 class WaitForClause final : public StmtClause { 397 397 public: 398 ptr<Expr> target_func;399 std::vector<ptr<Expr>> target_args;400 ptr<Stmt> stmt;401 ptr<Expr> cond;402 403 WaitForClause( const CodeLocation & loc )398 ptr<Expr> target_func; 399 std::vector<ptr<Expr>> target_args; 400 ptr<Stmt> stmt; 401 ptr<Expr> cond; 402 403 WaitForClause( const CodeLocation & loc ) 404 404 : StmtClause( loc ) {} 405 405 406 406 const WaitForClause * accept( Visitor & v ) const override { return v.visit( this ); } 407 407 private: 408 WaitForClause * clone() const override { return new WaitForClause{ *this }; }409 MUTATE_FRIEND408 WaitForClause * clone() const override { return new WaitForClause{ *this }; } 409 MUTATE_FRIEND 410 410 }; 411 411 -
src/AST/Util.cpp
r29d8c02 r74ec742 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Util. hpp -- General utilities for working with the AST.7 // Util.cpp -- General utilities for working with the AST. 8 8 // 9 9 // Author : Andrew Beach 10 10 // Created On : Wed Jan 19 9:46:00 2022 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Mar 11 18:07:00 202213 // Update Count : 112 // Last Modified On : Wed May 11 16:16:00 2022 13 // Update Count : 3 14 14 // 15 15 … … 46 46 47 47 /// Check that every note that can has a set CodeLocation. 48 struct SetCodeLocationsCore { 49 void previsit( const ParseNode * node ) { 50 assert( node->location.isSet() ); 48 void isCodeLocationSet( const ParseNode * node ) { 49 assert( node->location.isSet() ); 50 } 51 52 void areLabelLocationsSet( const Stmt * stmt ) { 53 for ( const Label& label : stmt->labels ) { 54 assert( label.location.isSet() ); 51 55 } 52 }; 56 } 57 58 /// Make sure the reference counts are in a valid combination. 59 void isStable( const Node * node ) { 60 assert( node->isStable() ); 61 } 62 63 /// Check that a FunctionDecl is synchronized with it's FunctionType. 64 void functionDeclMatchesType( const FunctionDecl * decl ) { 65 // The type is a cache of sorts, if it is missing that is only a 66 // problem if isTypeFixed is set. 67 if ( decl->isTypeFixed ) { 68 assert( decl->type ); 69 } else if ( !decl->type ) { 70 return; 71 } 72 73 const FunctionType * type = decl->type; 74 75 // Check that `type->forall` corresponds with `decl->type_params`. 76 assert( type->forall.size() == decl->type_params.size() ); 77 // Check that `type->assertions` corresponds with `decl->assertions`. 78 assert( type->assertions.size() == decl->assertions.size() ); 79 // Check that `type->params` corresponds with `decl->params`. 80 assert( type->params.size() == decl->params.size() ); 81 // Check that `type->returns` corresponds with `decl->returns`. 82 assert( type->returns.size() == decl->returns.size() ); 83 } 53 84 54 85 struct InvariantCore { … … 56 87 // None of the passes should make changes so ordering doesn't matter. 57 88 NoStrongCyclesCore no_strong_cycles; 58 SetCodeLocationsCore set_code_locations;59 89 60 90 void previsit( const Node * node ) { 61 91 no_strong_cycles.previsit( node ); 92 isStable( node ); 62 93 } 63 94 64 95 void previsit( const ParseNode * node ) { 65 no_strong_cycles.previsit( node ); 66 set_code_locations.previsit( node ); 96 previsit( (const Node *)node ); 97 isCodeLocationSet( node ); 98 } 99 100 void previsit( const FunctionDecl * node ) { 101 previsit( (const ParseNode *)node ); 102 functionDeclMatchesType( node ); 103 } 104 105 void previsit( const Stmt * node ) { 106 previsit( (const ParseNode *)node ); 107 areLabelLocationsSet( node ); 67 108 } 68 109 -
src/AST/module.mk
r29d8c02 r74ec742 29 29 AST/DeclReplacer.cpp \ 30 30 AST/DeclReplacer.hpp \ 31 AST/Eval.hpp \32 31 AST/Expr.cpp \ 33 32 AST/Expr.hpp \ -
src/CodeGen/CodeGenerator.cc
r29d8c02 r74ec742 1238 1238 } // namespace CodeGen 1239 1239 1240 1241 unsigned Indenter::tabsize = 2;1242 1243 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {1244 if ( node ) {1245 node->print( out );1246 } else {1247 out << "nullptr";1248 }1249 return out;1250 }1251 1252 1240 // Local Variables: // 1253 1241 // tab-width: 4 // -
src/CodeGen/FixMain.cc
r29d8c02 r74ec742 49 49 50 50 } 51 52 bool FixMain::replace_main = false;53 51 54 52 template<typename container> -
src/CodeGen/LinkOnce.cc
r29d8c02 r74ec742 53 53 new ConstantExpr( Constant::from_string( section_name ) ) 54 54 ); 55 56 // Unconditionnaly add "visibility(default)" to anything with gnu.linkonce 57 // visibility is a mess otherwise 58 attributes.push_back(new Attribute("visibility", {new ConstantExpr( Constant::from_string( "default" ) )})); 59 55 60 } 56 61 visit_children = false; -
src/CodeGen/module.mk
r29d8c02 r74ec742 10 10 ## Author : Richard C. Bilson 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 ## Last Modified By : Peter A. Buhr13 ## Last Modified On : Sat Dec 14 07:29:42 201914 ## Update Count : 412 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Tue May 17 14:26:00 2022 14 ## Update Count : 5 15 15 ############################################################################### 16 16 17 #SRC += ArgTweak/Rewriter.cc \ 18 # ArgTweak/Mutate.cc 17 SRC_CODEGEN = \ 18 CodeGen/FixMain2.cc \ 19 CodeGen/FixMain.h \ 20 CodeGen/OperatorTable.cc \ 21 CodeGen/OperatorTable.h 19 22 20 SRC _CODEGEN =\23 SRC += $(SRC_CODEGEN) \ 21 24 CodeGen/CodeGenerator.cc \ 22 25 CodeGen/CodeGenerator.h \ 26 CodeGen/Generate.cc \ 27 CodeGen/Generate.h \ 23 28 CodeGen/FixMain.cc \ 24 CodeGen/FixMain.h \ 29 CodeGen/FixNames.cc \ 30 CodeGen/FixNames.h \ 25 31 CodeGen/GenType.cc \ 26 32 CodeGen/GenType.h \ 27 33 CodeGen/LinkOnce.cc \ 28 34 CodeGen/LinkOnce.h \ 29 CodeGen/OperatorTable.cc \30 CodeGen/OperatorTable.h \31 35 CodeGen/Options.h 32 36 33 SRC += $(SRC_CODEGEN) CodeGen/Generate.cc CodeGen/Generate.h CodeGen/FixNames.cc CodeGen/FixNames.h34 37 SRCDEMANGLE += $(SRC_CODEGEN) -
src/Common/CodeLocationTools.cpp
r29d8c02 r74ec742 10 10 // Created On : Fri Dec 4 15:42:00 2020 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Mar 14 15:14:00 202213 // Update Count : 412 // Last Modified On : Wed May 11 16:16:00 2022 13 // Update Count : 5 14 14 // 15 15 … … 24 24 namespace { 25 25 26 // There are a lot of helpers in this file that could be used much more27 // generally if anyone has another use for them.28 29 // Check if a node type has a code location.30 template<typename node_t>31 struct has_code_location : public std::is_base_of<ast::ParseNode, node_t> {};32 33 template<typename node_t, bool has_location>34 struct __GetCL;35 36 template<typename node_t>37 struct __GetCL<node_t, true> {38 static inline CodeLocation const * get( node_t const * node ) {39 return &node->location;40 }41 42 static inline CodeLocation * get( node_t * node ) {43 return &node->location;44 }45 };46 47 template<typename node_t>48 struct __GetCL<node_t, false> {49 static inline CodeLocation * get( node_t const * ) {50 return nullptr;51 }52 };53 54 template<typename node_t>55 CodeLocation const * get_code_location( node_t const * node ) {56 return __GetCL< node_t, has_code_location< node_t >::value >::get( node );57 }58 59 template<typename node_t>60 CodeLocation * get_code_location( node_t * node ) {61 return __GetCL< node_t, has_code_location< node_t >::value >::get( node );62 }63 64 26 // Fill every location with a nearby (parent) location. 65 27 class FillCore : public ast::WithGuards { 66 28 CodeLocation const * parent; 29 30 template<typename node_t> 31 node_t const * parse_visit( node_t const * node ) { 32 if ( node->location.isUnset() ) { 33 assert( parent ); 34 node_t * newNode = ast::mutate( node ); 35 newNode->location = *parent; 36 return newNode; 37 } 38 GuardValue( parent ) = &node->location; 39 return node; 40 } 41 42 bool hasUnsetLabels( const ast::Stmt * stmt ) { 43 for ( const ast::Label& label : stmt->labels ) { 44 if ( label.location.isUnset() ) { 45 return true; 46 } 47 } 48 return false; 49 } 50 51 template<typename node_t> 52 node_t const * stmt_visit( node_t const * node ) { 53 assert( node->location.isSet() ); 54 55 if ( hasUnsetLabels( node ) ) { 56 node_t * newNode = ast::mutate( node ); 57 for ( ast::Label& label : newNode->labels ) { 58 if ( label.location.isUnset() ) { 59 label.location = newNode->location; 60 } 61 } 62 return newNode; 63 } 64 return node; 65 } 66 67 template<typename node_t> 68 auto visit( node_t const * node, long ) { 69 return node; 70 } 71 72 template<typename node_t> 73 auto visit( node_t const * node, int ) -> typename 74 std::remove_reference< decltype( node->location, node ) >::type { 75 return parse_visit( node ); 76 } 77 78 template<typename node_t> 79 auto visit( node_t const * node, char ) -> typename 80 std::remove_reference< decltype( node->labels, node ) >::type { 81 return stmt_visit( parse_visit( node ) ); 82 } 83 67 84 public: 68 85 FillCore() : parent( nullptr ) {} 86 FillCore( const CodeLocation& location ) : parent( &location ) { 87 assert( location.isSet() ); 88 } 69 89 70 90 template<typename node_t> 71 91 node_t const * previsit( node_t const * node ) { 72 GuardValue( parent ); 73 CodeLocation const * location = get_code_location( node ); 74 if ( location && location->isUnset() ) { 75 assert( parent ); 76 node_t * newNode = ast::mutate( node ); 77 CodeLocation * newLocation = get_code_location( newNode ); 78 assert( newLocation ); 79 *newLocation = *parent; 80 parent = newLocation; 81 return newNode; 82 } else if ( location ) { 83 parent = location; 84 } 85 return node; 92 return visit( node, '\0' ); 86 93 } 87 94 }; … … 233 240 234 241 template<typename node_t> 235 void previsit( node_t const * node ) { 236 CodeLocation const * location = get_code_location( node ); 237 if ( location && location->isUnset() ) { 242 auto previsit( node_t const * node ) -> decltype( node->location, void() ) { 243 if ( node->location.isUnset() ) { 238 244 unset.push_back( node ); 239 }240 }241 };242 243 class LocalFillCore : public ast::WithGuards {244 CodeLocation const * parent;245 public:246 LocalFillCore( CodeLocation const & location ) : parent( &location ) {247 assert( location.isSet() );248 }249 250 template<typename node_t>251 auto previsit( node_t const * node )252 -> typename std::enable_if<has_code_location<node_t>::value, node_t const *>::type {253 if ( node->location.isSet() ) {254 GuardValue( parent ) = &node->location;255 return node;256 } else {257 node_t * mut = ast::mutate( node );258 mut->location = *parent;259 return mut;260 245 } 261 246 } … … 304 289 ast::Node const * localFillCodeLocations( 305 290 CodeLocation const & location , ast::Node const * node ) { 306 ast::Pass< LocalFillCore> visitor( location );291 ast::Pass<FillCore> visitor( location ); 307 292 return node->accept( visitor ); 308 293 } -
src/Common/Indenter.h
r29d8c02 r74ec742 10 10 // Created On : Fri Jun 30 16:55:23 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Aug 11 11:15:00 201713 // Update Count : 112 // Last Modified On : Fri May 13 14:10:00 2022 13 // Update Count : 2 14 14 // 15 15 16 #ifndef INDENTER_H 17 #define INDENTER_H 16 #pragma once 17 18 #include <ostream> 18 19 19 20 struct Indenter { … … 37 38 return out << std::string(indent.indent * indent.amt, ' '); 38 39 } 39 40 #endif // INDENTER_H -
src/Common/SemanticError.h
r29d8c02 r74ec742 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 19 10:09:17 201813 // Update Count : 3 112 // Last Modified On : Wed May 4 14:08:26 2022 13 // Update Count : 35 14 14 // 15 15 … … 59 59 {"aggregate-forward-decl" , Severity::Warn , "forward declaration of nested aggregate: %s" }, 60 60 {"superfluous-decl" , Severity::Warn , "declaration does not allocate storage: %s" }, 61 {"superfluous-else" , Severity::Warn , "else clause never executed for empty loop conditional" }, 61 62 {"gcc-attributes" , Severity::Warn , "invalid attribute: %s" }, 62 63 {"c++-like-copy" , Severity::Warn , "Constructor from reference is not a valid copy constructor" }, … … 69 70 AggrForwardDecl, 70 71 SuperfluousDecl, 72 SuperfluousElse, 71 73 GccAttributes, 72 74 CppCopy, … … 79 81 ); 80 82 81 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, __VA_ARGS__)83 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, ##__VA_ARGS__) 82 84 83 85 void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4))); -
src/Common/module.mk
r29d8c02 r74ec742 10 10 ## Author : Richard C. Bilson 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 ## Last Modified By : Peter A. Buhr13 ## Last Modified On : Tue Sep 27 11:06:38 201614 ## Update Count : 412 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Tue May 17 14:27:00 2022 14 ## Update Count : 5 15 15 ############################################################################### 16 16 17 17 SRC_COMMON = \ 18 Common/Assert.cc \ 19 Common/CodeLocation.h \ 20 Common/CodeLocationTools.hpp \ 21 Common/CodeLocationTools.cpp \ 22 Common/CompilerError.h \ 23 Common/Debug.h \ 24 Common/DeclStats.hpp \ 25 Common/DeclStats.cpp \ 26 Common/ErrorObjects.h \ 27 Common/Eval.cc \ 28 Common/Examine.cc \ 29 Common/Examine.h \ 30 Common/FilterCombos.h \ 31 Common/Indenter.h \ 32 Common/PassVisitor.cc \ 33 Common/PassVisitor.h \ 34 Common/PassVisitor.impl.h \ 35 Common/PassVisitor.proto.h \ 36 Common/PersistentMap.h \ 37 Common/ResolvProtoDump.hpp \ 38 Common/ResolvProtoDump.cpp \ 39 Common/ScopedMap.h \ 40 Common/SemanticError.cc \ 41 Common/SemanticError.h \ 42 Common/Stats.h \ 43 Common/Stats/Base.h \ 44 Common/Stats/Counter.cc \ 45 Common/Stats/Counter.h \ 46 Common/Stats/Heap.cc \ 47 Common/Stats/Heap.h \ 48 Common/Stats/ResolveTime.cc \ 49 Common/Stats/ResolveTime.h \ 50 Common/Stats/Stats.cc \ 51 Common/Stats/Time.cc \ 52 Common/Stats/Time.h \ 53 Common/UnimplementedError.h \ 54 Common/UniqueName.cc \ 55 Common/UniqueName.h \ 56 Common/utility.h \ 57 Common/VectorMap.h 18 Common/Assert.cc \ 19 Common/CodeLocation.h \ 20 Common/CodeLocationTools.hpp \ 21 Common/CodeLocationTools.cpp \ 22 Common/CompilerError.h \ 23 Common/Debug.h \ 24 Common/DeclStats.hpp \ 25 Common/DeclStats.cpp \ 26 Common/ErrorObjects.h \ 27 Common/Eval.cc \ 28 Common/Examine.cc \ 29 Common/Examine.h \ 30 Common/FilterCombos.h \ 31 Common/Indenter.h \ 32 Common/Indenter.cc \ 33 Common/PassVisitor.cc \ 34 Common/PassVisitor.h \ 35 Common/PassVisitor.impl.h \ 36 Common/PassVisitor.proto.h \ 37 Common/PersistentMap.h \ 38 Common/ResolvProtoDump.hpp \ 39 Common/ResolvProtoDump.cpp \ 40 Common/ScopedMap.h \ 41 Common/SemanticError.cc \ 42 Common/SemanticError.h \ 43 Common/Stats.h \ 44 Common/Stats/Base.h \ 45 Common/Stats/Counter.cc \ 46 Common/Stats/Counter.h \ 47 Common/Stats/Heap.cc \ 48 Common/Stats/Heap.h \ 49 Common/Stats/ResolveTime.cc \ 50 Common/Stats/ResolveTime.h \ 51 Common/Stats/Stats.cc \ 52 Common/Stats/Time.cc \ 53 Common/Stats/Time.h \ 54 Common/UnimplementedError.h \ 55 Common/UniqueName.cc \ 56 Common/UniqueName.h \ 57 Common/utility.h \ 58 Common/VectorMap.h 58 59 59 SRC += $(SRC_COMMON) Common/DebugMalloc.cc 60 SRC += $(SRC_COMMON) \ 61 Common/DebugMalloc.cc 62 60 63 SRCDEMANGLE += $(SRC_COMMON) -
src/Common/utility.h
r29d8c02 r74ec742 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Feb 11 13:00:36 202013 // Update Count : 5 011 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Apr 25 14:26:00 2022 13 // Update Count : 51 14 14 // 15 15 … … 230 230 } 231 231 232 template<typename Container, typename Pred> 233 void erase_if( Container & cont, Pred && pred ) { 234 auto keep_end = std::remove_if( cont.begin(), cont.end(), pred ); 235 cont.erase( keep_end, cont.end() ); 236 } 237 232 238 template< typename... Args > 233 239 auto zip(Args&&... args) -> decltype(zipWith(std::forward<Args>(args)..., std::make_pair)) { -
src/Concurrency/module.mk
r29d8c02 r74ec742 10 10 ## Author : Thierry Delisle 11 11 ## Created On : Mon Mar 13 12:48:40 2017 12 ## Last Modified By : 13 ## Last Modified On : 14 ## Update Count : 012 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Tue May 17 13:28:00 2022 14 ## Update Count : 1 15 15 ############################################################################### 16 16 17 SRC _CONCURRENCY= \17 SRC += \ 18 18 Concurrency/KeywordsNew.cpp \ 19 Concurrency/Keywords.cc 20 21 SRC += $(SRC_CONCURRENCY) \ 19 Concurrency/Keywords.cc \ 22 20 Concurrency/Keywords.h \ 23 21 Concurrency/Waitfor.cc \ 24 22 Concurrency/Waitfor.h 25 26 SRCDEMANGLE += $(SRC_CONCURRENCY)27 -
src/ControlStruct/LabelGeneratorNew.hpp
r29d8c02 r74ec742 18 18 #include <string> // for string 19 19 20 classCodeLocation;20 struct CodeLocation; 21 21 22 22 namespace ast { -
src/ControlStruct/MultiLevelExit.cpp
r29d8c02 r74ec742 18 18 #include "AST/Pass.hpp" 19 19 #include "AST/Stmt.hpp" 20 #include "Common/CodeLocationTools.hpp" 20 21 #include "LabelGeneratorNew.hpp" 21 22 … … 228 229 // Labels on different stmts require different approaches to access 229 230 switch ( stmt->kind ) { 230 case BranchStmt::Goto:231 case BranchStmt::Goto: 231 232 return stmt; 232 case BranchStmt::Continue:233 case BranchStmt::Break: {234 bool isContinue = stmt->kind == BranchStmt::Continue;235 // Handle unlabeled break and continue.236 if ( stmt->target.empty() ) {237 if ( isContinue ) {238 targetEntry = findEnclosingControlStructure( isContinueTarget );239 } else {240 if ( enclosing_control_structures.empty() ) {233 case BranchStmt::Continue: 234 case BranchStmt::Break: { 235 bool isContinue = stmt->kind == BranchStmt::Continue; 236 // Handle unlabeled break and continue. 237 if ( stmt->target.empty() ) { 238 if ( isContinue ) { 239 targetEntry = findEnclosingControlStructure( isContinueTarget ); 240 } else { 241 if ( enclosing_control_structures.empty() ) { 241 242 SemanticError( stmt->location, 242 243 "'break' outside a loop, 'switch', or labelled block" ); 243 }244 targetEntry = findEnclosingControlStructure( isBreakTarget );245 }246 // Handle labeled break and continue.247 } else {248 // Lookup label in table to find attached control structure.249 targetEntry = findEnclosingControlStructure(250 [ targetStmt = target_table.at(stmt->target) ](auto entry){244 } 245 targetEntry = findEnclosingControlStructure( isBreakTarget ); 246 } 247 // Handle labeled break and continue. 248 } else { 249 // Lookup label in table to find attached control structure. 250 targetEntry = findEnclosingControlStructure( 251 [ targetStmt = target_table.at(stmt->target) ](auto entry){ 251 252 return entry.stmt == targetStmt; 252 } );253 }254 // Ensure that selected target is valid.255 if ( targetEntry == enclosing_control_structures.rend() || ( isContinue && ! isContinueTarget( *targetEntry ) ) ) {256 SemanticError( stmt->location, toString( (isContinue ? "'continue'" : "'break'"),253 } ); 254 } 255 // Ensure that selected target is valid. 256 if ( targetEntry == enclosing_control_structures.rend() || ( isContinue && ! isContinueTarget( *targetEntry ) ) ) { 257 SemanticError( stmt->location, toString( (isContinue ? "'continue'" : "'break'"), 257 258 " target must be an enclosing ", (isContinue ? "loop: " : "control structure: "), 258 259 stmt->originalTarget ) ); 259 }260 break;261 }262 // handle fallthrough in case/switch stmts263 case BranchStmt::FallThrough: {264 targetEntry = findEnclosingControlStructure( isFallthroughTarget );265 // Check that target is valid.266 if ( targetEntry == enclosing_control_structures.rend() ) {267 SemanticError( stmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" );268 }269 if ( ! stmt->target.empty() ) {270 // Labelled fallthrough: target must be a valid fallthough label.271 if ( ! fallthrough_labels.count( stmt->target ) ) {272 SemanticError( stmt->location, toString( "'fallthrough' target must be a later case statement: ",260 } 261 break; 262 } 263 // handle fallthrough in case/switch stmts 264 case BranchStmt::FallThrough: { 265 targetEntry = findEnclosingControlStructure( isFallthroughTarget ); 266 // Check that target is valid. 267 if ( targetEntry == enclosing_control_structures.rend() ) { 268 SemanticError( stmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" ); 269 } 270 if ( ! stmt->target.empty() ) { 271 // Labelled fallthrough: target must be a valid fallthough label. 272 if ( ! fallthrough_labels.count( stmt->target ) ) { 273 SemanticError( stmt->location, toString( "'fallthrough' target must be a later case statement: ", 273 274 stmt->originalTarget ) ); 274 }275 return new BranchStmt( stmt->location, BranchStmt::Goto, stmt->originalTarget );276 }277 break;278 }279 case BranchStmt::FallThroughDefault: {280 targetEntry = findEnclosingControlStructure( isFallthroughDefaultTarget );281 282 // Check if in switch or choose statement.283 if ( targetEntry == enclosing_control_structures.rend() ) {284 SemanticError( stmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" );285 }286 287 // Check if switch or choose has default clause.288 auto switchStmt = strict_dynamic_cast< const SwitchStmt * >( targetEntry->stmt );289 bool foundDefault = false;290 for ( auto caseStmt : switchStmt->cases ) {291 if ( caseStmt->isDefault() ) {292 foundDefault = true;293 break;294 }295 }296 if ( ! foundDefault ) {297 SemanticError( stmt->location, "'fallthrough default' must be enclosed in a 'switch' or 'choose'"298 "control structure with a 'default' clause" );299 }300 break;301 }302 default:275 } 276 return new BranchStmt( stmt->location, BranchStmt::Goto, stmt->originalTarget ); 277 } 278 break; 279 } 280 case BranchStmt::FallThroughDefault: { 281 targetEntry = findEnclosingControlStructure( isFallthroughDefaultTarget ); 282 283 // Check if in switch or choose statement. 284 if ( targetEntry == enclosing_control_structures.rend() ) { 285 SemanticError( stmt->location, "'fallthrough' must be enclosed in a 'switch' or 'choose'" ); 286 } 287 288 // Check if switch or choose has default clause. 289 auto switchStmt = strict_dynamic_cast< const SwitchStmt * >( targetEntry->stmt ); 290 bool foundDefault = false; 291 for ( auto caseStmt : switchStmt->cases ) { 292 if ( caseStmt->isDefault() ) { 293 foundDefault = true; 294 break; 295 } 296 } 297 if ( ! foundDefault ) { 298 SemanticError( stmt->location, "'fallthrough default' must be enclosed in a 'switch' or 'choose'" 299 "control structure with a 'default' clause" ); 300 } 301 break; 302 } 303 default: 303 304 assert( false ); 304 305 } … … 307 308 Label exitLabel( CodeLocation(), "" ); 308 309 switch ( stmt->kind ) { 309 case BranchStmt::Break:310 case BranchStmt::Break: 310 311 assert( ! targetEntry->useBreakExit().empty() ); 311 312 exitLabel = targetEntry->useBreakExit(); 312 313 break; 313 case BranchStmt::Continue:314 case BranchStmt::Continue: 314 315 assert( ! targetEntry->useContExit().empty() ); 315 316 exitLabel = targetEntry->useContExit(); 316 317 break; 317 case BranchStmt::FallThrough:318 case BranchStmt::FallThrough: 318 319 assert( ! targetEntry->useFallExit().empty() ); 319 320 exitLabel = targetEntry->useFallExit(); 320 321 break; 321 case BranchStmt::FallThroughDefault:322 case BranchStmt::FallThroughDefault: 322 323 assert( ! targetEntry->useFallDefaultExit().empty() ); 323 324 exitLabel = targetEntry->useFallDefaultExit(); … … 327 328 } 328 329 break; 329 default:330 default: 330 331 assert(0); 331 332 } … … 588 589 } 589 590 591 ptr<Stmt> else_stmt = nullptr; 592 Stmt * loop_kid = nullptr; 593 // check if loop node and if so add else clause if it exists 594 const WhileDoStmt * whilePtr = dynamic_cast<const WhileDoStmt *>(kid.get()); 595 if ( whilePtr && whilePtr->else_) { 596 else_stmt = whilePtr->else_; 597 WhileDoStmt * mutate_ptr = mutate(whilePtr); 598 mutate_ptr->else_ = nullptr; 599 loop_kid = mutate_ptr; 600 } 601 const ForStmt * forPtr = dynamic_cast<const ForStmt *>(kid.get()); 602 if ( forPtr && forPtr->else_) { 603 else_stmt = forPtr->else_; 604 ForStmt * mutate_ptr = mutate(forPtr); 605 mutate_ptr->else_ = nullptr; 606 loop_kid = mutate_ptr; 607 } 608 590 609 try { 591 ret.push_back( kid->accept( *visitor ) ); 610 if (else_stmt) ret.push_back( loop_kid->accept( *visitor ) ); 611 else ret.push_back( kid->accept( *visitor ) ); 592 612 } catch ( SemanticErrorException & e ) { 593 613 errors.append( e ); 594 614 } 615 616 if (else_stmt) ret.push_back(else_stmt); 595 617 596 618 if ( ! break_label.empty() ) { … … 612 634 Pass<MultiLevelExitCore> visitor( labelTable ); 613 635 const CompoundStmt * ret = stmt->accept( visitor ); 614 return ret; 636 // There are some unset code locations slipping in, possibly by Labels. 637 const Node * node = localFillCodeLocations( ret->location, ret ); 638 return strict_dynamic_cast<const CompoundStmt *>( node ); 615 639 } 616 640 } // namespace ControlStruct -
src/ControlStruct/module.mk
r29d8c02 r74ec742 10 10 ## Author : Richard C. Bilson 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 ## Last Modified By : Peter A. Buhr13 ## Last Modified On : Sat Jan 29 12:04:19202214 ## Update Count : 712 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Tue May 17 14:30:00 2022 14 ## Update Count : 8 15 15 ############################################################################### 16 16 17 SRC _CONTROLSTRUCT= \17 SRC += \ 18 18 ControlStruct/ExceptDecl.cc \ 19 19 ControlStruct/ExceptDecl.h \ 20 ControlStruct/ExceptTranslateNew.cpp \ 21 ControlStruct/ExceptTranslate.cc \ 22 ControlStruct/ExceptTranslate.h \ 20 23 ControlStruct/FixLabels.cpp \ 21 24 ControlStruct/FixLabels.hpp \ … … 37 40 ControlStruct/Mutate.h 38 41 39 SRC += $(SRC_CONTROLSTRUCT) \40 ControlStruct/ExceptTranslateNew.cpp \41 ControlStruct/ExceptTranslate.cc \42 ControlStruct/ExceptTranslate.h43 44 SRCDEMANGLE += $(SRC_CONTROLSTRUCT)45 -
src/GenPoly/Lvalue.cc
r29d8c02 r74ec742 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:14:38 201913 // Update Count : 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon May 16 14:09:00 2022 13 // Update Count : 8 14 14 // 15 15 … … 125 125 } // namespace 126 126 127 static bool referencesEliminated = false; 128 // used by UntypedExpr::createDeref to determine whether result type of dereference should be ReferenceType or value type. 129 bool referencesPermissable() { 130 return ! referencesEliminated; 131 } 127 // Stored elsewhere (Lvalue2, initially false). 128 extern bool referencesEliminated; 132 129 133 130 void convertLvalue( std::list< Declaration* > & translationUnit ) { -
src/GenPoly/module.mk
r29d8c02 r74ec742 10 10 ## Author : Richard C. Bilson 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 ## Last Modified By : Peter A. Buhr13 ## Last Modified On : Mon Jun 1 17:52:30 201514 ## Update Count : 112 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Tue May 17 14:31:00 2022 14 ## Update Count : 2 15 15 ############################################################################### 16 16 17 SRC += GenPoly/Box.cc \ 18 GenPoly/Box.h \ 19 GenPoly/ErasableScopedMap.h \ 20 GenPoly/FindFunction.cc \ 21 GenPoly/FindFunction.h \ 22 GenPoly/GenPoly.cc \ 23 GenPoly/GenPoly.h \ 24 GenPoly/InstantiateGeneric.cc \ 25 GenPoly/InstantiateGeneric.h \ 26 GenPoly/Lvalue.cc \ 27 GenPoly/Lvalue.h \ 28 GenPoly/ScopedSet.h \ 29 GenPoly/ScrubTyVars.cc \ 30 GenPoly/ScrubTyVars.h \ 31 GenPoly/Specialize.cc \ 32 GenPoly/Specialize.h 17 SRC_GENPOLY = \ 18 GenPoly/GenPoly.cc \ 19 GenPoly/GenPoly.h \ 20 GenPoly/Lvalue2.cc \ 21 GenPoly/Lvalue.h 33 22 34 SRCDEMANGLE += GenPoly/GenPoly.cc GenPoly/GenPoly.h GenPoly/Lvalue.cc GenPoly/Lvalue.h 23 SRC += $(SRC_GENPOLY) \ 24 GenPoly/Box.cc \ 25 GenPoly/Box.h \ 26 GenPoly/ErasableScopedMap.h \ 27 GenPoly/FindFunction.cc \ 28 GenPoly/FindFunction.h \ 29 GenPoly/InstantiateGeneric.cc \ 30 GenPoly/InstantiateGeneric.h \ 31 GenPoly/Lvalue.cc \ 32 GenPoly/ScopedSet.h \ 33 GenPoly/ScrubTyVars.cc \ 34 GenPoly/ScrubTyVars.h \ 35 GenPoly/Specialize.cc \ 36 GenPoly/Specialize.h 35 37 38 SRCDEMANGLE += $(SRC_GENPOLY) -
src/InitTweak/FixInitNew.cpp
r29d8c02 r74ec742 454 454 455 455 auto expr = new ast::ImplicitCopyCtorExpr( appExpr->location, mutExpr ); 456 // Move the type substitution to the new top-level, if it is attached to the appExpr. 457 // Ensure it is not deleted with the ImplicitCopyCtorExpr by removing it before deletion. 458 // The substitution is needed to obtain the type of temporary variables so that copy constructor 459 // calls can be resolved. 456 // Move the type substitution to the new top-level. The substitution 457 // is needed to obtain the type of temporary variables so that copy 458 // constructor calls can be resolved. 460 459 assert( typeSubs ); 461 // assert (mutExpr->env);462 460 expr->env = tmp; 463 // mutExpr->env = nullptr;464 //std::swap( expr->env, appExpr->env );465 461 return expr; 466 462 } 467 463 468 464 void ResolveCopyCtors::previsit(const ast::Expr * expr) { 469 if (expr->env) { 470 GuardValue(env); 471 GuardValue(envModified); 472 env = expr->env->clone(); 473 envModified = false; 474 } 465 if ( nullptr == expr->env ) { 466 return; 467 } 468 GuardValue( env ) = expr->env->clone(); 469 GuardValue( envModified ) = false; 475 470 } 476 471 477 472 const ast::Expr * ResolveCopyCtors::postvisit(const ast::Expr * expr) { 478 if (expr->env) { 479 if (envModified) { 480 auto mutExpr = mutate(expr); 481 mutExpr->env = env; 482 return mutExpr; 483 } 484 else { 485 // env was not mutated, skip and delete the shallow copy 486 delete env; 487 return expr; 488 } 489 } 490 else { 473 // No local environment, skip. 474 if ( nullptr == expr->env ) { 475 return expr; 476 // Environment was modified, mutate and replace. 477 } else if ( envModified ) { 478 auto mutExpr = mutate(expr); 479 mutExpr->env = env; 480 return mutExpr; 481 // Environment was not mutated, delete the shallow copy before guard. 482 } else { 483 delete env; 491 484 return expr; 492 485 } … … 497 490 const ast::Expr * ResolveCopyCtors::makeCtorDtor( const std::string & fname, const ast::ObjectDecl * var, const ast::Expr * cpArg ) { 498 491 assert( var ); 499 assert (var->isManaged());500 assert (!cpArg || cpArg->isManaged());492 assert( var->isManaged() ); 493 assert( !cpArg || cpArg->isManaged() ); 501 494 // arrays are not copy constructed, so this should always be an ExprStmt 502 495 ast::ptr< ast::Stmt > stmt = genCtorDtor(var->location, fname, var, cpArg ); … … 504 497 auto exprStmt = stmt.strict_as<ast::ImplicitCtorDtorStmt>()->callStmt.strict_as<ast::ExprStmt>(); 505 498 ast::ptr<ast::Expr> untyped = exprStmt->expr; // take ownership of expr 506 // exprStmt->expr = nullptr;507 499 508 500 // resolve copy constructor … … 516 508 env->add( *resolved->env ); 517 509 envModified = true; 518 // delete resolved->env;519 510 auto mut = mutate(resolved.get()); 520 511 assertf(mut == resolved.get(), "newly resolved expression must be unique"); 521 512 mut->env = nullptr; 522 513 } // if 523 // delete stmt;524 514 if ( auto assign = resolved.as<ast::TupleAssignExpr>() ) { 525 515 // fix newly generated StmtExpr -
src/InitTweak/module.mk
r29d8c02 r74ec742 10 10 ## Author : Richard C. Bilson 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 ## Last Modified By : Rob Schluntz13 ## Last Modified On : Fri May 13 11:36:24 201614 ## Update Count : 312 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Tue May 17 14:31:00 2022 14 ## Update Count : 4 15 15 ############################################################################### 16 16 17 SRC += \ 18 InitTweak/FixGlobalInit.cc \ 19 InitTweak/FixGlobalInit.h \ 20 InitTweak/FixInit.cc \ 21 InitTweak/FixInit.h \ 22 InitTweak/GenInit.cc \ 23 InitTweak/GenInit.h \ 24 InitTweak/InitTweak.cc \ 25 InitTweak/InitTweak.h \ 26 InitTweak/FixInitNew.cpp 27 28 SRCDEMANGLE += \ 17 SRC_INITTWEAK = \ 29 18 InitTweak/GenInit.cc \ 30 19 InitTweak/GenInit.h \ … … 32 21 InitTweak/InitTweak.h 33 22 23 SRC += $(SRC_INITTWEAK) \ 24 InitTweak/FixGlobalInit.cc \ 25 InitTweak/FixGlobalInit.h \ 26 InitTweak/FixInit.cc \ 27 InitTweak/FixInit.h \ 28 InitTweak/FixInitNew.cpp 29 30 SRCDEMANGLE += $(SRC_INITTWEAK) -
src/Parser/DeclarationNode.cc
r29d8c02 r74ec742 253 253 } // DeclarationNode::newAggregate 254 254 255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body ) {255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, DeclarationNode * base) { 256 256 DeclarationNode * newnode = new DeclarationNode; 257 257 newnode->type = new TypeData( TypeData::Enum ); … … 260 260 newnode->type->enumeration.body = body; 261 261 newnode->type->enumeration.anon = name == nullptr; 262 if ( base && base->type) { 263 newnode->type->base = base->type; 264 } // if 265 266 // Check: if base has TypeData 262 267 return newnode; 263 268 } // DeclarationNode::newEnum … … 290 295 return newName( name ); // Not explicitly inited enum value; 291 296 } // if 292 } // DeclarationNode::newEnum Generic297 } // DeclarationNode::newEnumValueGeneric 293 298 294 299 DeclarationNode * DeclarationNode::newFromTypedef( const string * name ) { -
src/Parser/ParseNode.h
r29d8c02 r74ec742 235 235 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 236 236 static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 237 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body );237 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, DeclarationNode * base = nullptr ); 238 238 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); 239 239 static DeclarationNode * newEnumValueGeneric( const std::string * name, InitializerNode * init ); -
src/Parser/TypeData.cc
r29d8c02 r74ec742 388 388 if ( enumeration.body ) { 389 389 os << string( indent + 2, ' ' ) << " with body" << endl; 390 } // if 391 if ( base ) { 392 os << "for "; 393 base->print( os, indent + 2 ); 390 394 } // if 391 395 break; … … 926 930 ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members); 927 931 member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ) ) ); 928 } else {932 } else if ( !cur->initializer ) { 929 933 if ( baseType && (!dynamic_cast<BasicType *>(baseType) || !dynamic_cast<BasicType *>(baseType)->isWholeNumber())) { 930 934 SemanticError( td->location, "A non whole number enum value decl must be explicitly initialized." ); 931 935 } 932 } // if 936 } 937 // else cur is a List Initializer and has been set as init in buildList() 938 // if 933 939 } // for 934 ret->set_body( td->enumeration.body ); // Boolean; if it has body940 ret->set_body( td->enumeration.body ); 935 941 return ret; 936 942 } // buildEnum -
src/Parser/parser.yy
r29d8c02 r74ec742 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 14 16:35:29202213 // Update Count : 5 27612 // Last Modified On : Sat May 14 09:16:22 2022 13 // Update Count : 5401 14 14 // 15 15 … … 54 54 #include "Common/SemanticError.h" // error_str 55 55 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild, CodeLo... 56 57 #include "SynTree/Attribute.h" // for Attribute 56 58 57 59 extern DeclarationNode * parseTree; … … 93 95 } // appendStr 94 96 95 DeclarationNode * distAttr( DeclarationNode * specifier, DeclarationNode * declList ) { 96 // distribute declaration_specifier across all declared variables, e.g., static, const, __attribute__. 97 DeclarationNode * cur = declList, * cl = (new DeclarationNode)->addType( specifier ); 97 DeclarationNode * distAttr( DeclarationNode * typeSpec, DeclarationNode * declList ) { 98 // distribute declaration_specifier across all declared variables, e.g., static, const, but not __attribute__. 99 assert( declList ); 100 // printf( "distAttr1 typeSpec %p\n", typeSpec ); typeSpec->print( std::cout ); 101 DeclarationNode * cur = declList, * cl = (new DeclarationNode)->addType( typeSpec ); 102 // printf( "distAttr2 cl %p\n", cl ); cl->type->print( std::cout ); 103 // cl->type->aggregate.name = cl->type->aggInst.aggregate->aggregate.name; 104 98 105 for ( cur = dynamic_cast<DeclarationNode *>( cur->get_next() ); cur != nullptr; cur = dynamic_cast<DeclarationNode *>( cur->get_next() ) ) { 99 106 cl->cloneBaseType( cur ); 100 107 } // for 101 108 declList->addType( cl ); 109 // printf( "distAttr3 declList %p\n", declList ); declList->print( std::cout, 0 ); 102 110 return declList; 103 111 } // distAttr … … 111 119 112 120 void distInl( DeclarationNode * declaration ) { 113 // distribute EXTENSIONacross all declarations121 // distribute INLINE across all declarations 114 122 for ( DeclarationNode *iter = declaration; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 115 123 iter->set_inLine( true ); … … 171 179 if ( ! ( typeSpec->type && (typeSpec->type->kind == TypeData::Aggregate || typeSpec->type->kind == TypeData::Enum) ) ) { 172 180 stringstream ss; 173 typeSpec->type->print( ss);181 // printf( "fieldDecl1 typeSpec %p\n", typeSpec ); typeSpec->type->print( std::cout ); 174 182 SemanticWarning( yylloc, Warning::SuperfluousDecl, ss.str().c_str() ); 175 183 return nullptr; 176 184 } // if 185 // printf( "fieldDecl2 typeSpec %p\n", typeSpec ); typeSpec->type->print( std::cout ); 177 186 fieldList = DeclarationNode::newName( nullptr ); 178 187 } // if 179 return distAttr( typeSpec, fieldList ); // mark all fields in list 188 // return distAttr( typeSpec, fieldList ); // mark all fields in list 189 190 // printf( "fieldDecl3 typeSpec %p\n", typeSpec ); typeSpec->print( std::cout, 0 ); 191 DeclarationNode * temp = distAttr( typeSpec, fieldList ); // mark all fields in list 192 // printf( "fieldDecl4 temp %p\n", temp ); temp->print( std::cout, 0 ); 193 return temp; 180 194 } // fieldDecl 181 195 … … 1221 1235 1222 1236 iteration_statement: 1223 WHILE '(' ')' statement // CFA => while ( 1 )1237 WHILE '(' ')' statement %prec THEN // CFA => while ( 1 ) 1224 1238 { $$ = new StatementNode( build_while( new CondCtl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); } 1239 | WHILE '(' ')' statement ELSE statement // CFA 1240 { 1241 $$ = new StatementNode( build_while( new CondCtl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); 1242 SemanticWarning( yylloc, Warning::SuperfluousElse ); 1243 } 1225 1244 | WHILE '(' conditional_declaration ')' statement %prec THEN 1226 1245 { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); } … … 1229 1248 | DO statement WHILE '(' ')' ';' // CFA => do while( 1 ) 1230 1249 { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); } 1231 | DO statement WHILE '(' comma_expression ')' ';' %prec THEN 1250 | DO statement WHILE '(' ')' ELSE statement // CFA 1251 { 1252 $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); 1253 SemanticWarning( yylloc, Warning::SuperfluousElse ); 1254 } 1255 | DO statement WHILE '(' comma_expression ')' ';' 1232 1256 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); } 1233 1257 | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA 1234 1258 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ), $8 ) ); } 1235 | FOR '(' ')' statement // CFA => for ( ;; )1259 | FOR '(' ')' statement %prec THEN // CFA => for ( ;; ) 1236 1260 { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); } 1261 | FOR '(' ')' statement ELSE statement // CFA 1262 { 1263 $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); 1264 SemanticWarning( yylloc, Warning::SuperfluousElse ); 1265 } 1237 1266 | FOR '(' for_control_expression_list ')' statement %prec THEN 1238 1267 { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); } … … 1605 1634 declaration: // old & new style declarations 1606 1635 c_declaration ';' 1636 { 1637 // printf( "C_DECLARATION1 %p %s\n", $$, $$->name ? $$->name->c_str() : "(nil)" ); 1638 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 1639 // printf( "\tattr %s\n", attr->name.c_str() ); 1640 // } // for 1641 } 1607 1642 | cfa_declaration ';' // CFA 1608 1643 | static_assert // C11 … … 1810 1845 basic_type_specifier 1811 1846 | sue_type_specifier 1847 { 1848 // printf( "sue_type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 1849 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 1850 // printf( "\tattr %s\n", attr->name.c_str() ); 1851 // } // for 1852 } 1812 1853 | type_type_specifier 1813 1854 ; … … 2026 2067 sue_declaration_specifier: // struct, union, enum + storage class + type specifier 2027 2068 sue_type_specifier 2069 { 2070 // printf( "sue_declaration_specifier %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2071 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 2072 // printf( "\tattr %s\n", attr->name.c_str() ); 2073 // } // for 2074 } 2028 2075 | declaration_qualifier_list sue_type_specifier 2029 2076 { $$ = $2->addQualifiers( $1 ); } … … 2036 2083 sue_type_specifier: // struct, union, enum + type specifier 2037 2084 elaborated_type 2085 { 2086 // printf( "sue_type_specifier %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2087 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 2088 // printf( "\tattr %s\n", attr->name.c_str() ); 2089 // } // for 2090 } 2038 2091 | type_qualifier_list 2039 2092 { if ( $1->type != nullptr && $1->type->forall ) forall = true; } // remember generic type … … 2108 2161 elaborated_type: // struct, union, enum 2109 2162 aggregate_type 2163 { 2164 // printf( "elaborated_type %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2165 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 2166 // printf( "\tattr %s\n", attr->name.c_str() ); 2167 // } // for 2168 } 2110 2169 | enum_type 2111 2170 ; … … 2127 2186 } 2128 2187 '{' field_declaration_list_opt '}' type_parameters_opt 2129 { $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); } 2188 { 2189 // printf( "aggregate_type1 %s\n", $3.str->c_str() ); 2190 // if ( $2 ) 2191 // for ( Attribute * attr: reverseIterate( $2->attributes ) ) { 2192 // printf( "copySpecifiers12 %s\n", attr->name.c_str() ); 2193 // } // for 2194 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); 2195 // printf( "aggregate_type2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2196 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 2197 // printf( "aggregate_type3 %s\n", attr->name.c_str() ); 2198 // } // for 2199 } 2130 2200 | aggregate_key attribute_list_opt TYPEDEFname // unqualified type name 2131 2201 { … … 2135 2205 '{' field_declaration_list_opt '}' type_parameters_opt 2136 2206 { 2207 // printf( "AGG3\n" ); 2137 2208 DeclarationNode::newFromTypedef( $3 ); 2138 2209 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); … … 2145 2216 '{' field_declaration_list_opt '}' type_parameters_opt 2146 2217 { 2218 // printf( "AGG4\n" ); 2147 2219 DeclarationNode::newFromTypeGen( $3, nullptr ); 2148 2220 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); … … 2221 2293 field_declaration: 2222 2294 type_specifier field_declaring_list_opt ';' 2223 { $$ = fieldDecl( $1, $2 ); } 2295 { 2296 // printf( "type_specifier1 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2297 $$ = fieldDecl( $1, $2 ); 2298 // printf( "type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" ); 2299 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) { 2300 // printf( "\tattr %s\n", attr->name.c_str() ); 2301 // } // for 2302 } 2224 2303 | EXTENSION type_specifier field_declaring_list_opt ';' // GCC 2225 2304 { $$ = fieldDecl( $2, $3 ); distExt( $$ ); } … … 2303 2382 ; 2304 2383 2305 enum_type: // static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed ); // enum2384 enum_type: 2306 2385 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2307 2386 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } … … 2318 2397 { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2319 2398 2320 $$ = DeclarationNode::newEnum( nullptr, $7, true ) ->addQualifiers( $5 ) -> addEnumBase( $3);2321 } 2322 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt // Question: why attributes/qualifier after identifier2399 $$ = DeclarationNode::newEnum( nullptr, $7, true, $3 )->addQualifiers( $5 ); 2400 } 2401 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt 2323 2402 { 2324 2403 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } … … 2327 2406 '{' enumerator_list comma_opt '}' 2328 2407 { 2329 $$ = DeclarationNode::newEnum( $6, $10, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3);2408 $$ = DeclarationNode::newEnum( $6, $10, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 ); 2330 2409 } 2331 2410 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}' … … 2333 2412 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2334 2413 typedefTable.makeTypedef( *$6->name ); 2335 $$ = DeclarationNode::newEnum( $6->name, $9, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3);2414 $$ = DeclarationNode::newEnum( $6->name, $9, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 ); 2336 2415 } 2337 2416 | enum_type_nobody … … 2830 2909 // empty 2831 2910 { $$ = nullptr; forall = false; } 2832 | WITH '(' tuple_expression_list ')' 2833 { $$ = $3; forall = false; } 2911 | WITH '(' tuple_expression_list ')' attribute_list_opt 2912 { 2913 $$ = $3; forall = false; 2914 if ( $5 ) { 2915 SemanticError( yylloc, "Attributes cannot be associated with function body. Move attribute(s) before \"with\" clause." ); 2916 $$ = nullptr; 2917 } // if 2918 } 2834 2919 ; 2835 2920 -
src/ResolvExpr/AlternativeFinder.cc
r29d8c02 r74ec742 42 42 #include "SymTab/Indexer.h" // for Indexer 43 43 #include "SymTab/Mangler.h" // for Mangler 44 #include "SymTab/Validate .h"// for validateType44 #include "SymTab/ValidateType.h" // for validateType 45 45 #include "SynTree/Constant.h" // for Constant 46 46 #include "SynTree/Declaration.h" // for DeclarationWithType, TypeDecl, Dec... -
src/ResolvExpr/Resolver.cc
r29d8c02 r74ec742 427 427 // enumerator initializers should not use the enum type to initialize, since 428 428 // the enum type is still incomplete at this point. Use signed int instead. 429 // TODO: BasicType::SignedInt may not longer be true 429 430 currentObject = CurrentObject( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 430 431 } … … 1477 1478 // enum type is still incomplete at this point. Use `int` instead. 1478 1479 1479 if (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base) { // const ast::PointerType & 1480 // const ast::Type * enumBase = (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get()); 1481 // const ast::PointerType * enumBaseAsPtr = dynamic_cast<const ast::PointerType *>(enumBase); 1482 1483 // if ( enumBaseAsPtr ) { 1484 // const ast::Type * pointerBase = enumBaseAsPtr->base.get(); 1485 // if ( dynamic_cast<const ast::BasicType *>(pointerBase) ) { 1486 // objectDecl = fixObjectType(objectDecl, context); 1487 // if (dynamic_cast<const ast::BasicType *>(pointerBase)->kind == ast::BasicType::Char) 1488 // currentObject = ast::CurrentObject{ 1489 // objectDecl->location, new ast::PointerType{ 1490 // new ast::BasicType{ ast::BasicType::Char } 1491 // } }; 1492 // } else { 1493 // objectDecl = fixObjectType(objectDecl, context); 1494 // currentObject = ast::CurrentObject{objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } }; 1495 // } 1496 // } 1480 if (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base) { 1497 1481 objectDecl = fixObjectType( objectDecl, context ); 1498 1482 const ast::Type * enumBase = (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get()); -
src/SymTab/Autogen.h
r29d8c02 r74ec742 21 21 22 22 #include "AST/Decl.hpp" 23 #include "AST/Eval.hpp"24 23 #include "AST/Expr.hpp" 25 24 #include "AST/Init.hpp" … … 71 70 template< typename OutIter > 72 71 ast::ptr< ast::Stmt > genCall( 73 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 74 const CodeLocation & loc, const std::string & fname, OutIter && out, 72 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 73 const CodeLocation & loc, const std::string & fname, OutIter && out, 75 74 const ast::Type * type, const ast::Type * addCast, LoopDirection forward = LoopForward ); 76 75 … … 128 127 } 129 128 130 /// inserts into out a generated call expression to function fname with arguments dstParam and 129 /// inserts into out a generated call expression to function fname with arguments dstParam and 131 130 /// srcParam. Should only be called with non-array types. 132 /// optionally returns a statement which must be inserted prior to the containing loop, if 131 /// optionally returns a statement which must be inserted prior to the containing loop, if 133 132 /// there is one 134 133 template< typename OutIter > 135 ast::ptr< ast::Stmt > genScalarCall( 136 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 137 const CodeLocation & loc, std::string fname, OutIter && out, const ast::Type * type, 134 ast::ptr< ast::Stmt > genScalarCall( 135 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 136 const CodeLocation & loc, std::string fname, OutIter && out, const ast::Type * type, 138 137 const ast::Type * addCast = nullptr 139 138 ) { … … 153 152 154 153 if ( addCast ) { 155 // cast to T& with qualifiers removed, so that qualified objects can be constructed and 156 // destructed with the same functions as non-qualified objects. Unfortunately, lvalue 157 // is considered a qualifier - for AddressExpr to resolve, its argument must have an 154 // cast to T& with qualifiers removed, so that qualified objects can be constructed and 155 // destructed with the same functions as non-qualified objects. Unfortunately, lvalue 156 // is considered a qualifier - for AddressExpr to resolve, its argument must have an 158 157 // lvalue-qualified type, so remove all qualifiers except lvalue. 159 158 // xxx -- old code actually removed lvalue too... 160 159 ast::ptr< ast::Type > guard = addCast; // prevent castType from mutating addCast 161 160 ast::ptr< ast::Type > castType = addCast; 162 ast::remove_qualifiers( 163 castType, 161 ast::remove_qualifiers( 162 castType, 164 163 ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Atomic ); 165 164 dstParam = new ast::CastExpr{ dstParam, new ast::ReferenceType{ castType } }; … … 181 180 182 181 srcParam.clearArrayIndices(); 183 182 184 183 return listInit; 185 184 } … … 249 248 } 250 249 251 /// Store in out a loop which calls fname on each element of the array with srcParam and 250 /// Store in out a loop which calls fname on each element of the array with srcParam and 252 251 /// dstParam as arguments. If forward is true, loop goes from 0 to N-1, else N-1 to 0 253 252 template< typename OutIter > 254 253 void genArrayCall( 255 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 256 const CodeLocation & loc, const std::string & fname, OutIter && out, 257 const ast::ArrayType * array, const ast::Type * addCast = nullptr, 258 LoopDirection forward = LoopForward 254 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 255 const CodeLocation & loc, const std::string & fname, OutIter && out, 256 const ast::ArrayType * array, const ast::Type * addCast = nullptr, 257 LoopDirection forward = LoopForward 259 258 ) { 260 259 static UniqueName indexName( "_index" ); … … 279 278 } else { 280 279 // generate: for ( int i = N-1; i >= 0; --i ) 281 begin = ast:: call(282 loc, "?-?", array->dimension, ast::ConstantExpr::from_int( loc, 1 ));280 begin = ast::UntypedExpr::createCall( loc, "?-?", 281 { array->dimension, ast::ConstantExpr::from_int( loc, 1 ) } ); 283 282 end = ast::ConstantExpr::from_int( loc, 0 ); 284 283 cmp = "?>=?"; … … 286 285 } 287 286 288 ast::ptr< ast::DeclWithType > index = new ast::ObjectDecl{ 289 loc, indexName.newName(), new ast::BasicType{ ast::BasicType::SignedInt }, 287 ast::ptr< ast::DeclWithType > index = new ast::ObjectDecl{ 288 loc, indexName.newName(), new ast::BasicType{ ast::BasicType::SignedInt }, 290 289 new ast::SingleInit{ loc, begin } }; 291 290 ast::ptr< ast::Expr > indexVar = new ast::VariableExpr{ loc, index }; 292 293 ast::ptr< ast::Expr > cond = ast::call( loc, cmp, indexVar, end ); 294 295 ast::ptr< ast::Expr > inc = ast::call( loc, update, indexVar ); 296 297 ast::ptr< ast::Expr > dstIndex = ast::call( loc, "?[?]", dstParam, indexVar ); 298 299 // srcParam must keep track of the array indices to build the source parameter and/or 291 292 ast::ptr< ast::Expr > cond = ast::UntypedExpr::createCall( 293 loc, cmp, { indexVar, end } ); 294 295 ast::ptr< ast::Expr > inc = ast::UntypedExpr::createCall( 296 loc, update, { indexVar } ); 297 298 ast::ptr< ast::Expr > dstIndex = ast::UntypedExpr::createCall( 299 loc, "?[?]", { dstParam, indexVar } ); 300 301 // srcParam must keep track of the array indices to build the source parameter and/or 300 302 // array list initializer 301 303 srcParam.addArrayIndex( indexVar, array->dimension ); … … 303 305 // for stmt's body, eventually containing call 304 306 ast::CompoundStmt * body = new ast::CompoundStmt{ loc }; 305 ast::ptr< ast::Stmt > listInit = genCall( 306 srcParam, dstIndex, loc, fname, std::back_inserter( body->kids ), array->base, addCast, 307 ast::ptr< ast::Stmt > listInit = genCall( 308 srcParam, dstIndex, loc, fname, std::back_inserter( body->kids ), array->base, addCast, 307 309 forward ); 308 310 309 311 // block containing the stmt and index variable 310 312 ast::CompoundStmt * block = new ast::CompoundStmt{ loc }; … … 328 330 template< typename OutIter > 329 331 ast::ptr< ast::Stmt > genCall( 330 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 331 const CodeLocation & loc, const std::string & fname, OutIter && out, 332 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 333 const CodeLocation & loc, const std::string & fname, OutIter && out, 332 334 const ast::Type * type, const ast::Type * addCast, LoopDirection forward 333 335 ) { 334 336 if ( auto at = dynamic_cast< const ast::ArrayType * >( type ) ) { 335 genArrayCall( 336 srcParam, dstParam, loc, fname, std::forward< OutIter >(out), at, addCast, 337 genArrayCall( 338 srcParam, dstParam, loc, fname, std::forward< OutIter >(out), at, addCast, 337 339 forward ); 338 340 return {}; 339 341 } else { 340 return genScalarCall( 342 return genScalarCall( 341 343 srcParam, dstParam, loc, fname, std::forward< OutIter >( out ), type, addCast ); 342 344 } … … 377 379 } 378 380 379 static inline ast::ptr< ast::Stmt > genImplicitCall( 380 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 381 const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj, 382 LoopDirection forward = LoopForward 381 static inline ast::ptr< ast::Stmt > genImplicitCall( 382 InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam, 383 const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj, 384 LoopDirection forward = LoopForward 383 385 ) { 384 386 // unnamed bit fields are not copied as they cannot be accessed … … 392 394 393 395 std::vector< ast::ptr< ast::Stmt > > stmts; 394 genCall( 396 genCall( 395 397 srcParam, dstParam, loc, fname, back_inserter( stmts ), obj->type, addCast, forward ); 396 398 … … 400 402 const ast::Stmt * callStmt = stmts.front(); 401 403 if ( addCast ) { 402 // implicitly generated ctor/dtor calls should be wrapped so that later passes are 404 // implicitly generated ctor/dtor calls should be wrapped so that later passes are 403 405 // aware they were generated. 404 406 callStmt = new ast::ImplicitCtorDtorStmt{ callStmt->location, callStmt }; … … 417 419 // compile-command: "make install" // 418 420 // End: // 419 -
src/SymTab/Demangle.cc
r29d8c02 r74ec742 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Demangle r.cc --7 // Demangle.cc -- Convert a mangled name into a human readable name. 8 8 // 9 9 // Author : Rob Schluntz -
src/SymTab/Mangler.h
r29d8c02 r74ec742 111 111 } 112 112 113 extern "C" {114 char * cforall_demangle(const char *, int);115 }116 117 113 // Local Variables: // 118 114 // tab-width: 4 // -
src/SymTab/Validate.cc
r29d8c02 r74ec742 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Nov 12 11:00:00 202113 // Update Count : 36 412 // Last Modified On : Tue May 17 14:36:00 2022 13 // Update Count : 366 14 14 // 15 15 … … 74 74 #include "ResolvExpr/ResolveTypeof.h" // for resolveTypeof 75 75 #include "SymTab/Autogen.h" // for SizeType 76 #include "SymTab/ValidateType.h" // for decayEnumsAndPointers, decayFo... 76 77 #include "SynTree/LinkageSpec.h" // for C 77 78 #include "SynTree/Attribute.h" // for noAttributes, Attribute … … 134 135 }; 135 136 136 /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers.137 struct EnumAndPointerDecay_old {138 void previsit( EnumDecl * aggregateDecl );139 void previsit( FunctionType * func );140 };141 142 /// Associates forward declarations of aggregates with their definitions143 struct LinkReferenceToTypes_old final : public WithIndexer, public WithGuards, public WithVisitorRef<LinkReferenceToTypes_old>, public WithShortCircuiting {144 LinkReferenceToTypes_old( const Indexer * indexer );145 void postvisit( TypeInstType * typeInst );146 147 void postvisit( EnumInstType * enumInst );148 void postvisit( StructInstType * structInst );149 void postvisit( UnionInstType * unionInst );150 void postvisit( TraitInstType * traitInst );151 void previsit( QualifiedType * qualType );152 void postvisit( QualifiedType * qualType );153 154 void postvisit( EnumDecl * enumDecl );155 void postvisit( StructDecl * structDecl );156 void postvisit( UnionDecl * unionDecl );157 void postvisit( TraitDecl * traitDecl );158 159 void previsit( StructDecl * structDecl );160 void previsit( UnionDecl * unionDecl );161 162 void renameGenericParams( std::list< TypeDecl * > & params );163 164 private:165 const Indexer * local_indexer;166 167 typedef std::map< std::string, std::list< EnumInstType * > > ForwardEnumsType;168 typedef std::map< std::string, std::list< StructInstType * > > ForwardStructsType;169 typedef std::map< std::string, std::list< UnionInstType * > > ForwardUnionsType;170 ForwardEnumsType forwardEnums;171 ForwardStructsType forwardStructs;172 ForwardUnionsType forwardUnions;173 /// true if currently in a generic type body, so that type parameter instances can be renamed appropriately174 bool inGeneric = false;175 };176 177 137 /// Does early resolution on the expressions that give enumeration constants their values 178 138 struct ResolveEnumInitializers final : public WithIndexer, public WithGuards, public WithVisitorRef<ResolveEnumInitializers>, public WithShortCircuiting { … … 192 152 void previsit( StructDecl * aggrDecl ); 193 153 void previsit( UnionDecl * aggrDecl ); 194 };195 196 // These structs are the sub-sub-passes of ForallPointerDecay_old.197 198 struct TraitExpander_old final {199 void previsit( FunctionType * );200 void previsit( StructDecl * );201 void previsit( UnionDecl * );202 };203 204 struct AssertionFixer_old final {205 void previsit( FunctionType * );206 void previsit( StructDecl * );207 void previsit( UnionDecl * );208 };209 210 struct CheckOperatorTypes_old final {211 void previsit( ObjectDecl * );212 };213 214 struct FixUniqueIds_old final {215 void previsit( DeclarationWithType * );216 154 }; 217 155 … … 357 295 358 296 void validate_A( std::list< Declaration * > & translationUnit ) { 359 PassVisitor<EnumAndPointerDecay_old> epc;360 297 PassVisitor<HoistTypeDecls> hoistDecls; 361 298 { … … 366 303 ReplaceTypedef::replaceTypedef( translationUnit ); 367 304 ReturnTypeFixer::fix( translationUnit ); // must happen before autogen 368 acceptAll( translationUnit, epc); // must happen before VerifyCtorDtorAssign, because void return objects should not exist; before LinkReferenceToTypes_old because it is an indexer and needs correct types for mangling305 decayEnumsAndPointers( translationUnit ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist; before LinkReferenceToTypes_old because it is an indexer and needs correct types for mangling 369 306 } 370 307 } 371 308 372 309 void validate_B( std::list< Declaration * > & translationUnit ) { 373 PassVisitor<LinkReferenceToTypes_old> lrt( nullptr );374 310 PassVisitor<FixQualifiedTypes> fixQual; 375 311 { 376 312 Stats::Heap::newPass("validate-B"); 377 313 Stats::Time::BlockGuard guard("validate-B"); 378 acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions314 //linkReferenceToTypes( translationUnit ); 379 315 mutateAll( translationUnit, fixQual ); // must happen after LinkReferenceToTypes_old, because aggregate members are accessed 380 316 HoistStruct::hoistStruct( translationUnit ); … … 407 343 }); 408 344 } 409 }410 411 static void decayForallPointers( std::list< Declaration * > & translationUnit ) {412 PassVisitor<TraitExpander_old> te;413 acceptAll( translationUnit, te );414 PassVisitor<AssertionFixer_old> af;415 acceptAll( translationUnit, af );416 PassVisitor<CheckOperatorTypes_old> cot;417 acceptAll( translationUnit, cot );418 PassVisitor<FixUniqueIds_old> fui;419 acceptAll( translationUnit, fui );420 345 } 421 346 … … 496 421 } 497 422 498 void validateType( Type * type, const Indexer * indexer ) {499 PassVisitor<EnumAndPointerDecay_old> epc;500 PassVisitor<LinkReferenceToTypes_old> lrt( indexer );501 PassVisitor<TraitExpander_old> te;502 PassVisitor<AssertionFixer_old> af;503 PassVisitor<CheckOperatorTypes_old> cot;504 PassVisitor<FixUniqueIds_old> fui;505 type->accept( epc );506 type->accept( lrt );507 type->accept( te );508 type->accept( af );509 type->accept( cot );510 type->accept( fui );511 }512 513 423 void HoistTypeDecls::handleType( Type * type ) { 514 424 // some type declarations are buried in expressions and not easy to hoist during parsing; hoist them here … … 703 613 } 704 614 705 void EnumAndPointerDecay_old::previsit( EnumDecl * enumDecl ) {706 // Set the type of each member of the enumeration to be EnumConstant707 for ( std::list< Declaration * >::iterator i = enumDecl->members.begin(); i != enumDecl->members.end(); ++i ) {708 ObjectDecl * obj = dynamic_cast< ObjectDecl * >( * i );709 assert( obj );710 obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->name ) );711 } // for712 }713 714 namespace {715 template< typename DWTList >716 void fixFunctionList( DWTList & dwts, bool isVarArgs, FunctionType * func ) {717 auto nvals = dwts.size();718 bool containsVoid = false;719 for ( auto & dwt : dwts ) {720 // fix each DWT and record whether a void was found721 containsVoid |= fixFunction( dwt );722 }723 724 // the only case in which "void" is valid is where it is the only one in the list725 if ( containsVoid && ( nvals > 1 || isVarArgs ) ) {726 SemanticError( func, "invalid type void in function type " );727 }728 729 // one void is the only thing in the list; remove it.730 if ( containsVoid ) {731 delete dwts.front();732 dwts.clear();733 }734 }735 }736 737 void EnumAndPointerDecay_old::previsit( FunctionType * func ) {738 // Fix up parameters and return types739 fixFunctionList( func->parameters, func->isVarArgs, func );740 fixFunctionList( func->returnVals, false, func );741 }742 743 LinkReferenceToTypes_old::LinkReferenceToTypes_old( const Indexer * other_indexer ) : WithIndexer( false ) {744 if ( other_indexer ) {745 local_indexer = other_indexer;746 } else {747 local_indexer = &indexer;748 } // if749 }750 751 void LinkReferenceToTypes_old::postvisit( EnumInstType * enumInst ) {752 const EnumDecl * st = local_indexer->lookupEnum( enumInst->name );753 // it's not a semantic error if the enum is not found, just an implicit forward declaration754 if ( st ) {755 enumInst->baseEnum = const_cast<EnumDecl *>(st); // Just linking in the node756 } // if757 if ( ! st || ! st->body ) {758 // use of forward declaration759 forwardEnums[ enumInst->name ].push_back( enumInst );760 } // if761 }762 763 void LinkReferenceToTypes_old::postvisit( StructInstType * structInst ) {764 const StructDecl * st = local_indexer->lookupStruct( structInst->name );765 // it's not a semantic error if the struct is not found, just an implicit forward declaration766 if ( st ) {767 structInst->baseStruct = const_cast<StructDecl *>(st); // Just linking in the node768 } // if769 if ( ! st || ! st->body ) {770 // use of forward declaration771 forwardStructs[ structInst->name ].push_back( structInst );772 } // if773 }774 775 void LinkReferenceToTypes_old::postvisit( UnionInstType * unionInst ) {776 const UnionDecl * un = local_indexer->lookupUnion( unionInst->name );777 // it's not a semantic error if the union is not found, just an implicit forward declaration778 if ( un ) {779 unionInst->baseUnion = const_cast<UnionDecl *>(un); // Just linking in the node780 } // if781 if ( ! un || ! un->body ) {782 // use of forward declaration783 forwardUnions[ unionInst->name ].push_back( unionInst );784 } // if785 }786 787 void LinkReferenceToTypes_old::previsit( QualifiedType * ) {788 visit_children = false;789 }790 791 void LinkReferenceToTypes_old::postvisit( QualifiedType * qualType ) {792 // linking only makes sense for the 'oldest ancestor' of the qualified type793 qualType->parent->accept( * visitor );794 }795 796 template< typename Decl >797 void normalizeAssertions( std::list< Decl * > & assertions ) {798 // ensure no duplicate trait members after the clone799 auto pred = [](Decl * d1, Decl * d2) {800 // only care if they're equal801 DeclarationWithType * dwt1 = dynamic_cast<DeclarationWithType *>( d1 );802 DeclarationWithType * dwt2 = dynamic_cast<DeclarationWithType *>( d2 );803 if ( dwt1 && dwt2 ) {804 if ( dwt1->name == dwt2->name && ResolvExpr::typesCompatible( dwt1->get_type(), dwt2->get_type(), SymTab::Indexer() ) ) {805 // std::cerr << "=========== equal:" << std::endl;806 // std::cerr << "d1: " << d1 << std::endl;807 // std::cerr << "d2: " << d2 << std::endl;808 return false;809 }810 }811 return d1 < d2;812 };813 std::set<Decl *, decltype(pred)> unique_members( assertions.begin(), assertions.end(), pred );814 // if ( unique_members.size() != assertions.size() ) {815 // std::cerr << "============different" << std::endl;816 // std::cerr << unique_members.size() << " " << assertions.size() << std::endl;817 // }818 819 std::list< Decl * > order;820 order.splice( order.end(), assertions );821 std::copy_if( order.begin(), order.end(), back_inserter( assertions ), [&]( Decl * decl ) {822 return unique_members.count( decl );823 });824 }825 826 615 // expand assertions from trait instance, performing the appropriate type variable substitutions 827 616 template< typename Iterator > … … 834 623 // substitute trait decl parameters for instance parameters 835 624 applySubstitution( inst->baseTrait->parameters.begin(), inst->baseTrait->parameters.end(), inst->parameters.begin(), asserts.begin(), asserts.end(), out ); 836 }837 838 void LinkReferenceToTypes_old::postvisit( TraitDecl * traitDecl ) {839 if ( traitDecl->name == "sized" ) {840 // "sized" is a special trait - flick the sized status on for the type variable841 assertf( traitDecl->parameters.size() == 1, "Built-in trait 'sized' has incorrect number of parameters: %zd", traitDecl->parameters.size() );842 TypeDecl * td = traitDecl->parameters.front();843 td->set_sized( true );844 }845 846 // move assertions from type parameters into the body of the trait847 for ( TypeDecl * td : traitDecl->parameters ) {848 for ( DeclarationWithType * assert : td->assertions ) {849 if ( TraitInstType * inst = dynamic_cast< TraitInstType * >( assert->get_type() ) ) {850 expandAssertions( inst, back_inserter( traitDecl->members ) );851 } else {852 traitDecl->members.push_back( assert->clone() );853 }854 }855 deleteAll( td->assertions );856 td->assertions.clear();857 } // for858 }859 860 void LinkReferenceToTypes_old::postvisit( TraitInstType * traitInst ) {861 // handle other traits862 const TraitDecl * traitDecl = local_indexer->lookupTrait( traitInst->name );863 if ( ! traitDecl ) {864 SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name );865 } // if866 if ( traitDecl->parameters.size() != traitInst->parameters.size() ) {867 SemanticError( traitInst, "incorrect number of trait parameters: " );868 } // if869 traitInst->baseTrait = const_cast<TraitDecl *>(traitDecl); // Just linking in the node870 871 // need to carry over the 'sized' status of each decl in the instance872 for ( auto p : group_iterate( traitDecl->parameters, traitInst->parameters ) ) {873 TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) );874 if ( ! expr ) {875 SemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " );876 }877 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) {878 TypeDecl * formalDecl = std::get<0>(p);879 TypeDecl * instDecl = inst->baseType;880 if ( formalDecl->get_sized() ) instDecl->set_sized( true );881 }882 }883 // normalizeAssertions( traitInst->members );884 }885 886 void LinkReferenceToTypes_old::postvisit( EnumDecl * enumDecl ) {887 // visit enum members first so that the types of self-referencing members are updated properly888 if ( enumDecl->body ) {889 ForwardEnumsType::iterator fwds = forwardEnums.find( enumDecl->name );890 if ( fwds != forwardEnums.end() ) {891 for ( std::list< EnumInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {892 (* inst)->baseEnum = enumDecl;893 } // for894 forwardEnums.erase( fwds );895 } // if896 } // if897 }898 899 void LinkReferenceToTypes_old::renameGenericParams( std::list< TypeDecl * > & params ) {900 // rename generic type parameters uniquely so that they do not conflict with user-defined function forall parameters, e.g.901 // forall(otype T)902 // struct Box {903 // T x;904 // };905 // forall(otype T)906 // void f(Box(T) b) {907 // ...908 // }909 // The T in Box and the T in f are different, so internally the naming must reflect that.910 GuardValue( inGeneric );911 inGeneric = ! params.empty();912 for ( TypeDecl * td : params ) {913 td->name = "__" + td->name + "_generic_";914 }915 }916 917 void LinkReferenceToTypes_old::previsit( StructDecl * structDecl ) {918 renameGenericParams( structDecl->parameters );919 }920 921 void LinkReferenceToTypes_old::previsit( UnionDecl * unionDecl ) {922 renameGenericParams( unionDecl->parameters );923 }924 925 void LinkReferenceToTypes_old::postvisit( StructDecl * structDecl ) {926 // visit struct members first so that the types of self-referencing members are updated properly927 // xxx - need to ensure that type parameters match up between forward declarations and definition (most importantly, number of type parameters and their defaults)928 if ( structDecl->body ) {929 ForwardStructsType::iterator fwds = forwardStructs.find( structDecl->name );930 if ( fwds != forwardStructs.end() ) {931 for ( std::list< StructInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {932 (* inst)->baseStruct = structDecl;933 } // for934 forwardStructs.erase( fwds );935 } // if936 } // if937 }938 939 void LinkReferenceToTypes_old::postvisit( UnionDecl * unionDecl ) {940 if ( unionDecl->body ) {941 ForwardUnionsType::iterator fwds = forwardUnions.find( unionDecl->name );942 if ( fwds != forwardUnions.end() ) {943 for ( std::list< UnionInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {944 (* inst)->baseUnion = unionDecl;945 } // for946 forwardUnions.erase( fwds );947 } // if948 } // if949 }950 951 void LinkReferenceToTypes_old::postvisit( TypeInstType * typeInst ) {952 // ensure generic parameter instances are renamed like the base type953 if ( inGeneric && typeInst->baseType ) typeInst->name = typeInst->baseType->name;954 if ( const NamedTypeDecl * namedTypeDecl = local_indexer->lookupType( typeInst->name ) ) {955 if ( const TypeDecl * typeDecl = dynamic_cast< const TypeDecl * >( namedTypeDecl ) ) {956 typeInst->set_isFtype( typeDecl->kind == TypeDecl::Ftype );957 } // if958 } // if959 625 } 960 626 … … 985 651 } 986 652 } 987 988 653 } 989 654 } … … 1073 738 void ForallPointerDecay_old::previsit( UnionDecl * aggrDecl ) { 1074 739 forallFixer( aggrDecl->parameters, aggrDecl ); 1075 }1076 1077 void TraitExpander_old::previsit( FunctionType * ftype ) {1078 expandTraits( ftype->forall );1079 }1080 1081 void TraitExpander_old::previsit( StructDecl * aggrDecl ) {1082 expandTraits( aggrDecl->parameters );1083 }1084 1085 void TraitExpander_old::previsit( UnionDecl * aggrDecl ) {1086 expandTraits( aggrDecl->parameters );1087 }1088 1089 void AssertionFixer_old::previsit( FunctionType * ftype ) {1090 fixAssertions( ftype->forall, ftype );1091 }1092 1093 void AssertionFixer_old::previsit( StructDecl * aggrDecl ) {1094 fixAssertions( aggrDecl->parameters, aggrDecl );1095 }1096 1097 void AssertionFixer_old::previsit( UnionDecl * aggrDecl ) {1098 fixAssertions( aggrDecl->parameters, aggrDecl );1099 }1100 1101 void CheckOperatorTypes_old::previsit( ObjectDecl * object ) {1102 // ensure that operator names only apply to functions or function pointers1103 if ( CodeGen::isOperator( object->name ) && ! dynamic_cast< FunctionType * >( object->type->stripDeclarator() ) ) {1104 SemanticError( object->location, toCString( "operator ", object->name.c_str(), " is not a function or function pointer." ) );1105 }1106 }1107 1108 void FixUniqueIds_old::previsit( DeclarationWithType * decl ) {1109 decl->fixUniqueId();1110 740 } 1111 741 -
src/SymTab/Validate.h
r29d8c02 r74ec742 10 10 // Author : Richard C. Bilson 11 11 // Created On : Sun May 17 21:53:34 2015 12 // Last Modified By : Peter A. Buhr13 // Last Modified On : Sat Jul 22 09:46:07 201714 // Update Count : 412 // Last Modified By : Andrew Beach 13 // Last Modified On : Tue May 17 14:35:00 2022 14 // Update Count : 5 15 15 // 16 16 … … 33 33 /// Normalizes struct and function declarations 34 34 void validate( std::list< Declaration * > &translationUnit, bool doDebug = false ); 35 void validateType( Type *type, const Indexer *indexer );36 35 37 36 // Sub-passes of validate. … … 42 41 void validate_E( std::list< Declaration * > &translationUnit ); 43 42 void validate_F( std::list< Declaration * > &translationUnit ); 44 45 const ast::Type * validateType(46 const CodeLocation & loc, const ast::Type * type, const ast::SymbolTable & symtab );47 43 } // namespace SymTab 48 44 -
src/SymTab/demangler.cc
r29d8c02 r74ec742 1 #include " Mangler.h"1 #include "Demangle.h" 2 2 #include <iostream> 3 3 #include <fstream> -
src/SymTab/module.mk
r29d8c02 r74ec742 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Andrew Beach 13 ## Last Modified On : T hr Aug 10 16:08:00 201714 ## Update Count : 413 ## Last Modified On : Tue May 17 14:46:00 2022 14 ## Update Count : 5 15 15 ############################################################################### 16 16 17 17 SRC_SYMTAB = \ 18 SymTab/Autogen.cc \19 SymTab/Autogen.h \20 SymTab/FixFunction.cc \21 SymTab/FixFunction.h \22 SymTab/Indexer.cc \23 SymTab/Indexer.h \24 SymTab/Mangler.cc \25 SymTab/ManglerCommon.cc \26 SymTab/Mangler.h \27 SymTab/Validate.cc \28 SymTab/Validate.h18 SymTab/Autogen.cc \ 19 SymTab/Autogen.h \ 20 SymTab/FixFunction.cc \ 21 SymTab/FixFunction.h \ 22 SymTab/Indexer.cc \ 23 SymTab/Indexer.h \ 24 SymTab/Mangler.cc \ 25 SymTab/ManglerCommon.cc \ 26 SymTab/Mangler.h \ 27 SymTab/ValidateType.cc \ 28 SymTab/ValidateType.h 29 29 30 SRC += $(SRC_SYMTAB) 31 SRCDEMANGLE += $(SRC_SYMTAB) SymTab/Demangle.cc 30 SRC += $(SRC_SYMTAB) \ 31 SymTab/Validate.cc \ 32 SymTab/Validate.h 33 34 SRCDEMANGLE += $(SRC_SYMTAB) \ 35 SymTab/Demangle.cc \ 36 SymTab/Demangle.h -
src/SynTree/module.mk
r29d8c02 r74ec742 24 24 SynTree/AttrType.cc \ 25 25 SynTree/BaseSyntaxNode.h \ 26 SynTree/BaseSyntaxNode.cc \ 26 27 SynTree/BasicType.cc \ 27 28 SynTree/CommaExpr.cc \ -
src/Tuples/TupleExpansion.cc
r29d8c02 r74ec742 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:45:51 201913 // Update Count : 2 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue May 17 15:02:00 2022 13 // Update Count : 25 14 14 // 15 15 … … 367 367 return nullptr; 368 368 } 369 370 namespace {371 /// determines if impurity (read: side-effects) may exist in a piece of code. Currently gives a very crude approximation, wherein any function call expression means the code may be impure372 struct ImpurityDetector : public WithShortCircuiting {373 ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {}374 375 void previsit( const ApplicationExpr * appExpr ) {376 visit_children = false;377 if ( const DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) {378 if ( function->linkage == LinkageSpec::Intrinsic ) {379 if ( function->name == "*?" || function->name == "?[?]" ) {380 // intrinsic dereference, subscript are pure, but need to recursively look for impurity381 visit_children = true;382 return;383 }384 }385 }386 maybeImpure = true;387 }388 void previsit( const UntypedExpr * ) { maybeImpure = true; visit_children = false; }389 void previsit( const UniqueExpr * ) {390 if ( ignoreUnique ) {391 // bottom out at unique expression.392 // The existence of a unique expression doesn't change the purity of an expression.393 // That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression.394 visit_children = false;395 return;396 }397 }398 399 bool maybeImpure = false;400 bool ignoreUnique;401 };402 } // namespace403 404 bool maybeImpure( const Expression * expr ) {405 PassVisitor<ImpurityDetector> detector( false );406 expr->accept( detector );407 return detector.pass.maybeImpure;408 }409 410 bool maybeImpureIgnoreUnique( const Expression * expr ) {411 PassVisitor<ImpurityDetector> detector( true );412 expr->accept( detector );413 return detector.pass.maybeImpure;414 }415 369 } // namespace Tuples 416 370 -
src/Tuples/Tuples.cc
r29d8c02 r74ec742 10 10 // Created On : Mon Jun 17 14:41:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jun 18 9:31:00 201913 // Update Count : 112 // Last Modified On : Mon May 16 16:15:00 2022 13 // Update Count : 2 14 14 // 15 15 … … 18 18 #include "AST/Pass.hpp" 19 19 #include "AST/LinkageSpec.hpp" 20 #include "Common/PassVisitor.h" 20 21 #include "InitTweak/InitTweak.h" 21 22 … … 23 24 24 25 namespace { 26 /// Checks if impurity (read: side-effects) may exist in a piece of code. 27 /// Currently gives a very crude approximation, wherein any function 28 /// call expression means the code may be impure. 29 struct ImpurityDetector_old : public WithShortCircuiting { 30 bool const ignoreUnique; 31 bool maybeImpure; 32 33 ImpurityDetector_old( bool ignoreUnique ) : 34 ignoreUnique( ignoreUnique ), maybeImpure( false ) 35 {} 36 37 void previsit( const ApplicationExpr * appExpr ) { 38 visit_children = false; 39 if ( const DeclarationWithType * function = 40 InitTweak::getFunction( appExpr ) ) { 41 if ( function->linkage == LinkageSpec::Intrinsic ) { 42 if ( function->name == "*?" || function->name == "?[?]" ) { 43 // intrinsic dereference, subscript are pure, 44 // but need to recursively look for impurity 45 visit_children = true; 46 return; 47 } 48 } 49 } 50 maybeImpure = true; 51 } 52 53 void previsit( const UntypedExpr * ) { 54 maybeImpure = true; 55 visit_children = false; 56 } 57 58 void previsit( const UniqueExpr * ) { 59 if ( ignoreUnique ) { 60 // bottom out at unique expression. 61 // The existence of a unique expression doesn't change the purity of an expression. 62 // That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression. 63 visit_children = false; 64 return; 65 } 66 } 67 }; 68 69 bool detectImpurity( const Expression * expr, bool ignoreUnique ) { 70 PassVisitor<ImpurityDetector_old> detector( ignoreUnique ); 71 expr->accept( detector ); 72 return detector.pass.maybeImpure; 73 } 74 25 75 /// Determines if impurity (read: side-effects) may exist in a piece of code. Currently gives 26 76 /// a very crude approximation, wherein any function call expression means the code may be 27 77 /// impure. 28 78 struct ImpurityDetector : public ast::WithShortCircuiting { 29 bool maybeImpure= false;79 bool result = false; 30 80 31 81 void previsit( ast::ApplicationExpr const * appExpr ) { … … 36 86 } 37 87 } 38 maybeImpure= true; visit_children = false;88 result = true; visit_children = false; 39 89 } 40 90 void previsit( ast::UntypedExpr const * ) { 41 maybeImpure= true; visit_children = false;91 result = true; visit_children = false; 42 92 } 43 93 }; 94 44 95 struct ImpurityDetectorIgnoreUnique : public ImpurityDetector { 45 96 using ImpurityDetector::previsit; … … 48 99 } 49 100 }; 50 51 template<typename Detector>52 bool detectImpurity( const ast::Expr * expr ) {53 ast::Pass<Detector> detector;54 expr->accept( detector );55 return detector.core.maybeImpure;56 }57 101 } // namespace 58 102 59 103 bool maybeImpure( const ast::Expr * expr ) { 60 return detectImpurity<ImpurityDetector>( expr );104 return ast::Pass<ImpurityDetector>::read( expr ); 61 105 } 62 106 63 107 bool maybeImpureIgnoreUnique( const ast::Expr * expr ) { 64 return detectImpurity<ImpurityDetectorIgnoreUnique>( expr ); 108 return ast::Pass<ImpurityDetectorIgnoreUnique>::read( expr ); 109 } 110 111 bool maybeImpure( const Expression * expr ) { 112 return detectImpurity( expr, false ); 113 } 114 115 bool maybeImpureIgnoreUnique( const Expression * expr ) { 116 return detectImpurity( expr, true ); 65 117 } 66 118 -
src/Tuples/module.mk
r29d8c02 r74ec742 10 10 ## Author : Richard C. Bilson 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 ## Last Modified By : Henry Xue13 ## Last Modified On : Mon Aug 23 15:36:09 202114 ## Update Count : 212 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Mon May 17 15:00:00 2022 14 ## Update Count : 3 15 15 ############################################################################### 16 16 … … 24 24 Tuples/Tuples.h 25 25 26 SRC += $(SRC_TUPLES) 26 27 27 SRC += $(SRC_TUPLES)28 28 SRCDEMANGLE += $(SRC_TUPLES) -
src/Validate/Autogen.cpp
r29d8c02 r74ec742 350 350 name, 351 351 std::move( type_params ), 352 std::move( assertions ), 352 353 std::move( params ), 353 354 std::move( returns ), … … 360 361 // Auto-generated routines are inline to avoid conflicts. 361 362 ast::Function::Specs( ast::Function::Inline ) ); 362 decl->assertions = std::move( assertions );363 363 decl->fixUniqueId(); 364 364 return decl; -
src/Validate/ForallPointerDecay.cpp
r29d8c02 r74ec742 10 10 // Created On : Tue Dec 7 16:15:00 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Feb 11 10:59:00 202213 // Update Count : 012 // Last Modified On : Sat Apr 23 13:10:00 2022 13 // Update Count : 1 14 14 // 15 15 … … 237 237 } 238 238 239 std::vector<ast::ptr<ast::DeclWithType>> expandAssertions( 240 std::vector<ast::ptr<ast::DeclWithType>> const & old ) { 241 return TraitExpander::expandAssertions( old ); 242 } 243 239 244 } // namespace Validate 240 245 -
src/Validate/ForallPointerDecay.hpp
r29d8c02 r74ec742 10 10 // Created On : Tue Dec 7 16:15:00 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Dec 8 11:50:00 202113 // Update Count : 012 // Last Modified On : Sat Apr 23 13:13:00 2022 13 // Update Count : 1 14 14 // 15 15 16 16 #pragma once 17 17 18 #include <vector> 19 #include "AST/Node.hpp" 20 18 21 namespace ast { 22 class DeclWithType; 19 23 class TranslationUnit; 20 24 } … … 27 31 void decayForallPointers( ast::TranslationUnit & transUnit ); 28 32 33 /// Expand all traits in an assertion list. 34 std::vector<ast::ptr<ast::DeclWithType>> expandAssertions( 35 std::vector<ast::ptr<ast::DeclWithType>> const & ); 36 29 37 } 30 38 -
src/Validate/GenericParameter.cpp
r29d8c02 r74ec742 10 10 // Created On : Fri Mar 21 10:02:00 2022 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Apr 13 10:09:00 202213 // Update Count : 012 // Last Modified On : Fri Apr 22 16:43:00 2022 13 // Update Count : 1 14 14 // 15 15 … … 22 22 #include "AST/TranslationUnit.hpp" 23 23 #include "AST/Type.hpp" 24 #include "Validate/NoIdSymbolTable.hpp" 24 25 25 26 namespace Validate { … … 138 139 // -------------------------------------------------------------------------- 139 140 140 // A SymbolTable that only has the operations used in the Translate Dimension 141 // pass. More importantly, it doesn't have some methods that should no be 142 // called by the Pass template (lookupId and addId). 143 class NoIdSymbolTable { 144 ast::SymbolTable base; 145 public: 146 # define FORWARD_X( func, types_and_names, just_names ) \ 147 inline auto func types_and_names -> decltype( base.func just_names ) { \ 148 return base.func just_names ; \ 149 } 150 # define FORWARD_0( func ) FORWARD_X( func, (), () ) 151 # define FORWARD_1( func, type ) FORWARD_X( func, (type arg), (arg) ) 152 # define FORWARD_2( func, t0, t1 ) FORWARD_X( func, (t0 a0, t1 a1), (a0, a1) ) 153 154 FORWARD_0( enterScope ) 155 FORWARD_0( leaveScope ) 156 FORWARD_1( lookupType, const std::string & ) 157 FORWARD_1( addType , const ast::NamedTypeDecl * ) 158 FORWARD_1( addStruct , const ast::StructDecl * ) 159 FORWARD_1( addEnum , const ast::EnumDecl * ) 160 FORWARD_1( addUnion , const ast::UnionDecl * ) 161 FORWARD_1( addTrait , const ast::TraitDecl * ) 162 FORWARD_2( addWith , const std::vector< ast::ptr<ast::Expr> > &, const ast::Decl * ) 163 }; 164 165 struct TranslateDimensionCore : public ast::WithGuards { 166 NoIdSymbolTable symtab; 141 struct TranslateDimensionCore : 142 public WithNoIdSymbolTable, public ast::WithGuards { 167 143 168 144 // SUIT: Struct- or Union- InstType -
src/Validate/module.mk
r29d8c02 r74ec742 10 10 ## Author : Rob Schluntz 11 11 ## Created On : Fri Jul 27 10:10:10 2018 12 ## Last Modified By : Rob Schluntz13 ## Last Modified On : Fri Jul 27 10:10:26 201814 ## Update Count : 212 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Tue May 17 14:59:00 2022 14 ## Update Count : 3 15 15 ############################################################################### 16 16 17 17 SRC_VALIDATE = \ 18 Validate/FindSpecialDecls.cc \ 19 Validate/FindSpecialDecls.h 20 21 SRC += $(SRC_VALIDATE) \ 18 22 Validate/Autogen.cpp \ 19 23 Validate/Autogen.hpp \ 20 24 Validate/CompoundLiteral.cpp \ 21 25 Validate/CompoundLiteral.hpp \ 26 Validate/EliminateTypedef.cpp \ 27 Validate/EliminateTypedef.hpp \ 28 Validate/FindSpecialDeclsNew.cpp \ 29 Validate/FixQualifiedTypes.cpp \ 30 Validate/FixQualifiedTypes.hpp \ 22 31 Validate/ForallPointerDecay.cpp \ 23 32 Validate/ForallPointerDecay.hpp \ … … 26 35 Validate/HandleAttributes.cc \ 27 36 Validate/HandleAttributes.h \ 37 Validate/HoistStruct.cpp \ 38 Validate/HoistStruct.hpp \ 28 39 Validate/InitializerLength.cpp \ 29 40 Validate/InitializerLength.hpp \ 30 41 Validate/LabelAddressFixer.cpp \ 31 42 Validate/LabelAddressFixer.hpp \ 43 Validate/NoIdSymbolTable.hpp \ 32 44 Validate/ReturnCheck.cpp \ 33 Validate/ReturnCheck.hpp \ 34 Validate/FindSpecialDeclsNew.cpp \ 35 Validate/FindSpecialDecls.cc \ 36 Validate/FindSpecialDecls.h 45 Validate/ReturnCheck.hpp 37 46 38 SRC += $(SRC_VALIDATE)39 47 SRCDEMANGLE += $(SRC_VALIDATE) -
src/Virtual/module.mk
r29d8c02 r74ec742 11 11 ## Created On : Tus Jul 25 10:18:00 2017 12 12 ## Last Modified By : Andrew Beach 13 ## Last Modified On : Tus Jul 25 10:18:00 201714 ## Update Count : 013 ## Last Modified On : Tus May 17 14:59:00 2022 14 ## Update Count : 1 15 15 ############################################################################### 16 16 17 SRC += Virtual/ExpandCasts.cc Virtual/ExpandCasts.h \ 18 Virtual/Tables.cc Virtual/Tables.h 19 20 SRCDEMANGLE += Virtual/Tables.cc 17 SRC += \ 18 Virtual/ExpandCasts.cc \ 19 Virtual/ExpandCasts.h \ 20 Virtual/Tables.cc \ 21 Virtual/Tables.h -
src/main.cc
r29d8c02 r74ec742 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Apr 13 11:11:00 202213 // Update Count : 67 212 // Last Modified On : Fri Apr 29 9:52:00 2022 13 // Update Count : 673 14 14 // 15 15 … … 70 70 #include "ResolvExpr/Resolver.h" // for resolve 71 71 #include "SymTab/Validate.h" // for validate 72 #include "SymTab/ValidateType.h" // for linkReferenceToTypes 72 73 #include "SynTree/LinkageSpec.h" // for Spec, Cforall, Intrinsic 73 74 #include "SynTree/Declaration.h" // for Declaration … … 75 76 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... 76 77 #include "Validate/Autogen.hpp" // for autogenerateRoutines 78 #include "Validate/CompoundLiteral.hpp" // for handleCompoundLiterals 79 #include "Validate/EliminateTypedef.hpp" // for eliminateTypedef 80 #include "Validate/FindSpecialDecls.h" // for findGlobalDecls 81 #include "Validate/FixQualifiedTypes.hpp" // for fixQualifiedTypes 82 #include "Validate/ForallPointerDecay.hpp" // for decayForallPointers 77 83 #include "Validate/GenericParameter.hpp" // for fillGenericParameters, tr... 78 #include "Validate/FindSpecialDecls.h" // for findGlobalDecls 79 #include "Validate/ForallPointerDecay.hpp" // for decayForallPointers 80 #include "Validate/CompoundLiteral.hpp" // for handleCompoundLiterals 84 #include "Validate/HoistStruct.hpp" // for hoistStruct 81 85 #include "Validate/InitializerLength.hpp" // for setLengthFromInitializer 82 86 #include "Validate/LabelAddressFixer.hpp" // for fixLabelAddresses … … 328 332 // add the assignment statement after the initialization of a type parameter 329 333 PASS( "Validate-A", SymTab::validate_A( translationUnit ) ); 330 PASS( "Validate-B", SymTab::validate_B( translationUnit ) ); 334 335 // Must happen before auto-gen, because it uses the sized flag. 336 PASS( "Link Reference To Types", SymTab::linkReferenceToTypes( translationUnit ) ); 331 337 332 338 CodeTools::fillLocations( translationUnit ); … … 342 348 343 349 forceFillCodeLocations( transUnit ); 350 351 // Must happen after Link References To Types, 352 // because aggregate members are accessed. 353 PASS( "Fix Qualified Types", Validate::fixQualifiedTypes( transUnit ) ); 354 355 PASS( "Hoist Struct", Validate::hoistStruct( transUnit ) ); 356 PASS( "Eliminate Typedef", Validate::eliminateTypedef( transUnit ) ); 344 357 345 358 // Check as early as possible. Can't happen before … … 438 451 translationUnit = convert( move( transUnit ) ); 439 452 } else { 453 PASS( "Validate-B", SymTab::validate_B( translationUnit ) ); 440 454 PASS( "Validate-C", SymTab::validate_C( translationUnit ) ); 441 455 PASS( "Validate-D", SymTab::validate_D( translationUnit ) );
Note:
See TracChangeset
for help on using the changeset viewer.