Changes in / [f7ac09d:3537dd7]
- Location:
- src
- Files:
-
- 6 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/GenType.cc
rf7ac09d r3537dd7 27 27 namespace CodeGen { 28 28 struct GenType : public WithVisitorRef<GenType>, public WithShortCircuiting { 29 GenType( const std::string &typeString, bool pretty = false, bool genC = false, bool lineMarks = false ); 30 std::string get_typeString() const { return typeString; } 31 void set_typeString( const std::string &newValue ) { typeString = newValue; } 29 std::string typeString; 30 GenType( const std::string &typeString, bool pretty, bool genC, bool lineMarks ); 32 31 33 32 void previsit( BaseSyntaxNode * ); … … 58 57 void genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic ); 59 58 60 std::string typeString; 61 bool pretty = false; // pretty print 62 bool genC = false; // generating C code? 63 bool lineMarks = false; 59 bool pretty = false; // pretty print 60 bool genC = false; // generating C code? 61 bool lineMarks = false; // lineMarks on for CodeGenerator? 64 62 }; 65 63 … … 74 72 75 73 type->accept( gt ); 76 return os.str() + gt.pass. get_typeString();74 return os.str() + gt.pass.typeString; 77 75 } 78 76 -
src/Common/SemanticError.h
rf7ac09d r3537dd7 58 58 {"aggregate-forward-decl" , "forward declaration of nested aggregate: %s" , Severity::Warn}, 59 59 {"superfluous-decl" , "declaration does not allocate storage: %s" , Severity::Warn}, 60 {"gcc-attributes" , "invalid attribute: %s" , Severity::Warn}, 60 61 }; 61 62 … … 66 67 AggrForwardDecl, 67 68 SuperfluousDecl, 69 GccAttributes, 68 70 NUMBER_OF_WARNINGS, // This MUST be the last warning 69 71 }; -
src/Common/module.mk
rf7ac09d r3537dd7 19 19 Common/DebugMalloc.cc \ 20 20 Common/Assert.cc \ 21 Common/Heap.cc 21 Common/Heap.cc \ 22 Common/Eval.cc -
src/Common/utility.h
rf7ac09d r3537dd7 31 31 #include "Common/Indenter.h" 32 32 33 class Expression; 34 33 35 template< typename T > 34 36 static inline T * maybeClone( const T *orig ) { … … 456 458 } // ilog2 457 459 460 // ----------------------------------------------------------------------------- 461 /// evaluates expr as a long long int. If second is false, expr could not be evaluated 462 std::pair<long long int, bool> eval(Expression * expr); 458 463 459 464 // Local Variables: // -
src/InitTweak/FixGlobalInit.cc
rf7ac09d r3537dd7 37 37 class GlobalFixer : public WithShortCircuiting { 38 38 public: 39 GlobalFixer( const std::string & name,bool inLibrary );39 GlobalFixer( bool inLibrary ); 40 40 41 41 void previsit( ObjectDecl *objDecl ); … … 52 52 }; 53 53 54 void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name,bool inLibrary ) {55 PassVisitor<GlobalFixer> visitor( name,inLibrary );54 void fixGlobalInit( std::list< Declaration * > & translationUnit, bool inLibrary ) { 55 PassVisitor<GlobalFixer> visitor( inLibrary ); 56 56 acceptAll( translationUnit, visitor ); 57 57 GlobalFixer & fixer = visitor.pass; … … 70 70 } 71 71 72 std::string globalFunctionName( const std::string & name ) { 73 // get basename 74 std::string ret = name.substr( 0, name.find( '.' ) ); 75 // replace invalid characters with _ 76 static std::string invalid = "/-@"; 77 replace_if( ret.begin(), ret.end(), []( char c ) { return invalid.find(c) != std::string::npos; }, '_' ); 78 return ret; 79 } 80 81 GlobalFixer::GlobalFixer( const std::string & name, bool inLibrary ) : tempNamer( "_global_init" ) { 82 std::string fixedName = globalFunctionName( name ); 72 GlobalFixer::GlobalFixer( bool inLibrary ) : tempNamer( "_global_init" ) { 83 73 std::list< Expression * > ctorParameters; 84 74 std::list< Expression * > dtorParameters; … … 90 80 // for library code are run before constructors and destructors for user code, 91 81 // specify a priority when building the library. Priorities 0-100 are reserved by gcc. 92 ctorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) ); 93 dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) ); 82 // Priorities 101-200 are reserved by cfa, so use priority 200 for CFA library globals, 83 // allowing room for overriding with a higher priority. 84 ctorParameters.push_back( new ConstantExpr( Constant::from_int( 200 ) ) ); 85 dtorParameters.push_back( new ConstantExpr( Constant::from_int( 200 ) ) ); 94 86 } 95 initFunction = new FunctionDecl( "_ init_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );87 initFunction = new FunctionDecl( "__global_init__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() ); 96 88 initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) ); 97 destroyFunction = new FunctionDecl( "_ destroy_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );89 destroyFunction = new FunctionDecl( "__global_destroy__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() ); 98 90 destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) ); 99 91 } … … 110 102 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 111 103 // a decision should have been made by the resolver, so ctor and init are not both non-NULL 112 assert( ! ctorInit-> get_ctor() || ! ctorInit->get_init());104 assert( ! ctorInit->ctor || ! ctorInit->init ); 113 105 114 Statement * dtor = ctorInit-> get_dtor();106 Statement * dtor = ctorInit->dtor; 115 107 if ( dtor && ! isIntrinsicSingleArgCallStmt( dtor ) ) { 116 108 // don't need to call intrinsic dtor, because it does nothing, but 117 109 // non-intrinsic dtors must be called 118 110 destroyStatements.push_front( dtor ); 119 ctorInit-> set_dtor( NULL );111 ctorInit->dtor = nullptr; 120 112 } // if 121 if ( Statement * ctor = ctorInit-> get_ctor()) {113 if ( Statement * ctor = ctorInit->ctor ) { 122 114 initStatements.push_back( ctor ); 123 objDecl-> set_init( NULL );124 ctorInit-> set_ctor( NULL );125 } else if ( Initializer * init = ctorInit-> get_init()) {126 objDecl-> set_init( init );127 ctorInit-> set_init( NULL );115 objDecl->init = nullptr; 116 ctorInit->ctor = nullptr; 117 } else if ( Initializer * init = ctorInit->init ) { 118 objDecl->init = init; 119 ctorInit->init = nullptr; 128 120 } else { 129 121 // no constructor and no initializer, which is okay 130 objDecl-> set_init( NULL );122 objDecl->init = nullptr; 131 123 } // if 132 124 delete ctorInit; -
src/InitTweak/FixGlobalInit.h
rf7ac09d r3537dd7 22 22 23 23 namespace InitTweak { 24 /// Moves global initialization into an _init function that is unique to the translation unit. 25 /// Sets the priority of the initialization function depending on whether the initialization 26 /// function is for library code. 27 void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ); 28 29 /// Apply transformations to a file name to get a valid C identifier which will be used as 30 /// the name of the generated initializer function. 31 std::string globalFunctionName( const std::string & name ); 24 /// Moves global initialization into an _init function that is unique to the translation unit. 25 /// Sets the priority of the initialization function depending on whether the initialization 26 /// function is for library code. 27 void fixGlobalInit( std::list< Declaration * > & translationUnit, bool inLibrary ); 32 28 } // namespace 33 29 -
src/InitTweak/FixInit.cc
rf7ac09d r3537dd7 238 238 } // namespace 239 239 240 void fix( std::list< Declaration * > & translationUnit, const std::string & filename,bool inLibrary ) {240 void fix( std::list< Declaration * > & translationUnit, bool inLibrary ) { 241 241 PassVisitor<SelfAssignChecker> checker; 242 242 acceptAll( translationUnit, checker ); 243 243 244 244 // fixes ConstructorInit for global variables. should happen before fixInitializers. 245 InitTweak::fixGlobalInit( translationUnit, filename,inLibrary );245 InitTweak::fixGlobalInit( translationUnit, inLibrary ); 246 246 247 247 UnqCount unqCount; -
src/InitTweak/FixInit.h
rf7ac09d r3537dd7 24 24 /// replace constructor initializers with expression statements 25 25 /// and unwrap basic C-style initializers 26 void fix( std::list< Declaration * > & translationUnit, const std::string & name,bool inLibrary );26 void fix( std::list< Declaration * > & translationUnit, bool inLibrary ); 27 27 } // namespace 28 28 -
src/InitTweak/InitTweak.cc
rf7ac09d r3537dd7 408 408 return allofCtorDtor( stmt, []( Expression * callExpr ){ 409 409 if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) { 410 FunctionType *funcType = GenPoly::getFunctionType( appExpr-> get_function()->get_result());410 FunctionType *funcType = GenPoly::getFunctionType( appExpr->function->result ); 411 411 assert( funcType ); 412 412 return funcType->get_parameters().size() == 1; -
src/Makefile.am
rf7ac09d r3537dd7 19 19 20 20 SRC = main.cc \ 21 MakeLibCfa.cc 21 MakeLibCfa.cc \ 22 CompilationState.cc 22 23 23 24 MAINTAINERCLEANFILES = … … 37 38 include SynTree/module.mk 38 39 include Tuples/module.mk 40 include Validate/module.mk 39 41 include Virtual/module.mk 40 42 -
src/Makefile.in
rf7ac09d r3537dd7 23 23 #SRC += ArgTweak/Rewriter.cc \ 24 24 # ArgTweak/Mutate.cc 25 26 ######################### -*- Mode: Makefile-Gmake -*- ######################## 27 ############################################################################### 25 28 26 29 ######################### -*- Mode: Makefile-Gmake -*- ######################## … … 150 153 am__objects_1 = driver_cfa_cpp-main.$(OBJEXT) \ 151 154 driver_cfa_cpp-MakeLibCfa.$(OBJEXT) \ 155 driver_cfa_cpp-CompilationState.$(OBJEXT) \ 152 156 CodeGen/driver_cfa_cpp-Generate.$(OBJEXT) \ 153 157 CodeGen/driver_cfa_cpp-CodeGenerator.$(OBJEXT) \ … … 165 169 Common/driver_cfa_cpp-Assert.$(OBJEXT) \ 166 170 Common/driver_cfa_cpp-Heap.$(OBJEXT) \ 171 Common/driver_cfa_cpp-Eval.$(OBJEXT) \ 167 172 ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT) \ 168 173 ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) \ … … 254 259 Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) \ 255 260 Tuples/driver_cfa_cpp-Explode.$(OBJEXT) \ 261 Validate/driver_cfa_cpp-HandleAttributes.$(OBJEXT) \ 256 262 Virtual/driver_cfa_cpp-ExpandCasts.$(OBJEXT) 257 263 am_driver_cfa_cpp_OBJECTS = $(am__objects_1) … … 352 358 $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk \ 353 359 $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk \ 354 $(srcdir)/Tuples/module.mk $(srcdir)/Virtual/module.mk \ 355 $(top_srcdir)/automake/depcomp $(top_srcdir)/automake/ylwrap \ 356 Parser/lex.cc Parser/parser.cc Parser/parser.hh 360 $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk \ 361 $(srcdir)/Virtual/module.mk $(top_srcdir)/automake/depcomp \ 362 $(top_srcdir)/automake/ylwrap Parser/lex.cc Parser/parser.cc \ 363 Parser/parser.hh 357 364 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 358 365 ACLOCAL = @ACLOCAL@ … … 483 490 # create object files in directory with source files 484 491 AUTOMAKE_OPTIONS = subdir-objects 485 SRC = main.cc MakeLibCfa.cc Co deGen/Generate.cc \492 SRC = main.cc MakeLibCfa.cc CompilationState.cc CodeGen/Generate.cc \ 486 493 CodeGen/CodeGenerator.cc CodeGen/GenType.cc \ 487 494 CodeGen/FixNames.cc CodeGen/FixMain.cc \ … … 490 497 Concurrency/Waitfor.cc Common/SemanticError.cc \ 491 498 Common/UniqueName.cc Common/DebugMalloc.cc Common/Assert.cc \ 492 Common/Heap.cc Co ntrolStruct/LabelGenerator.cc \499 Common/Heap.cc Common/Eval.cc ControlStruct/LabelGenerator.cc \ 493 500 ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \ 494 501 ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \ … … 532 539 SynTree/Attribute.cc SynTree/DeclReplacer.cc \ 533 540 Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \ 534 Tuples/Explode.cc Virtual/ExpandCasts.cc 541 Tuples/Explode.cc Validate/HandleAttributes.cc \ 542 Virtual/ExpandCasts.cc 535 543 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 536 544 ${cfa_cpplib_PROGRAMS}} … … 551 559 .SUFFIXES: 552 560 .SUFFIXES: .cc .ll .o .obj .yy 553 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/V irtual/module.mk $(am__configure_deps)561 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk $(srcdir)/Virtual/module.mk $(am__configure_deps) 554 562 @for dep in $?; do \ 555 563 case '$(am__configure_deps)' in \ … … 571 579 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 572 580 esac; 573 $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/V irtual/module.mk $(am__empty):581 $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk $(srcdir)/Virtual/module.mk $(am__empty): 574 582 575 583 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) … … 678 686 Common/$(DEPDIR)/$(am__dirstamp) 679 687 Common/driver_cfa_cpp-Heap.$(OBJEXT): Common/$(am__dirstamp) \ 688 Common/$(DEPDIR)/$(am__dirstamp) 689 Common/driver_cfa_cpp-Eval.$(OBJEXT): Common/$(am__dirstamp) \ 680 690 Common/$(DEPDIR)/$(am__dirstamp) 681 691 ControlStruct/$(am__dirstamp): … … 932 942 Tuples/driver_cfa_cpp-Explode.$(OBJEXT): Tuples/$(am__dirstamp) \ 933 943 Tuples/$(DEPDIR)/$(am__dirstamp) 944 Validate/$(am__dirstamp): 945 @$(MKDIR_P) Validate 946 @: > Validate/$(am__dirstamp) 947 Validate/$(DEPDIR)/$(am__dirstamp): 948 @$(MKDIR_P) Validate/$(DEPDIR) 949 @: > Validate/$(DEPDIR)/$(am__dirstamp) 950 Validate/driver_cfa_cpp-HandleAttributes.$(OBJEXT): \ 951 Validate/$(am__dirstamp) Validate/$(DEPDIR)/$(am__dirstamp) 934 952 Virtual/$(am__dirstamp): 935 953 @$(MKDIR_P) Virtual … … 962 980 -rm -f SynTree/*.$(OBJEXT) 963 981 -rm -f Tuples/*.$(OBJEXT) 982 -rm -f Validate/*.$(OBJEXT) 964 983 -rm -f Virtual/*.$(OBJEXT) 965 984 … … 967 986 -rm -f *.tab.c 968 987 988 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/driver_cfa_cpp-CompilationState.Po@am__quote@ 969 989 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/driver_cfa_cpp-MakeLibCfa.Po@am__quote@ 970 990 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/driver_cfa_cpp-main.Po@am__quote@ … … 979 999 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-Assert.Po@am__quote@ 980 1000 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-DebugMalloc.Po@am__quote@ 1001 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-Eval.Po@am__quote@ 981 1002 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-Heap.Po@am__quote@ 982 1003 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@ … … 1073 1094 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@ 1074 1095 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@ 1096 @AMDEP_TRUE@@am__include@ @am__quote@Validate/$(DEPDIR)/driver_cfa_cpp-HandleAttributes.Po@am__quote@ 1075 1097 @AMDEP_TRUE@@am__include@ @am__quote@Virtual/$(DEPDIR)/driver_cfa_cpp-ExpandCasts.Po@am__quote@ 1076 1098 … … 1119 1141 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o driver_cfa_cpp-MakeLibCfa.obj `if test -f 'MakeLibCfa.cc'; then $(CYGPATH_W) 'MakeLibCfa.cc'; else $(CYGPATH_W) '$(srcdir)/MakeLibCfa.cc'; fi` 1120 1142 1143 driver_cfa_cpp-CompilationState.o: CompilationState.cc 1144 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT driver_cfa_cpp-CompilationState.o -MD -MP -MF $(DEPDIR)/driver_cfa_cpp-CompilationState.Tpo -c -o driver_cfa_cpp-CompilationState.o `test -f 'CompilationState.cc' || echo '$(srcdir)/'`CompilationState.cc 1145 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/driver_cfa_cpp-CompilationState.Tpo $(DEPDIR)/driver_cfa_cpp-CompilationState.Po 1146 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='CompilationState.cc' object='driver_cfa_cpp-CompilationState.o' libtool=no @AMDEPBACKSLASH@ 1147 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1148 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o driver_cfa_cpp-CompilationState.o `test -f 'CompilationState.cc' || echo '$(srcdir)/'`CompilationState.cc 1149 1150 driver_cfa_cpp-CompilationState.obj: CompilationState.cc 1151 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT driver_cfa_cpp-CompilationState.obj -MD -MP -MF $(DEPDIR)/driver_cfa_cpp-CompilationState.Tpo -c -o driver_cfa_cpp-CompilationState.obj `if test -f 'CompilationState.cc'; then $(CYGPATH_W) 'CompilationState.cc'; else $(CYGPATH_W) '$(srcdir)/CompilationState.cc'; fi` 1152 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/driver_cfa_cpp-CompilationState.Tpo $(DEPDIR)/driver_cfa_cpp-CompilationState.Po 1153 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='CompilationState.cc' object='driver_cfa_cpp-CompilationState.obj' libtool=no @AMDEPBACKSLASH@ 1154 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1155 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o driver_cfa_cpp-CompilationState.obj `if test -f 'CompilationState.cc'; then $(CYGPATH_W) 'CompilationState.cc'; else $(CYGPATH_W) '$(srcdir)/CompilationState.cc'; fi` 1156 1121 1157 CodeGen/driver_cfa_cpp-Generate.o: CodeGen/Generate.cc 1122 1158 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT CodeGen/driver_cfa_cpp-Generate.o -MD -MP -MF CodeGen/$(DEPDIR)/driver_cfa_cpp-Generate.Tpo -c -o CodeGen/driver_cfa_cpp-Generate.o `test -f 'CodeGen/Generate.cc' || echo '$(srcdir)/'`CodeGen/Generate.cc … … 1329 1365 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-Heap.obj `if test -f 'Common/Heap.cc'; then $(CYGPATH_W) 'Common/Heap.cc'; else $(CYGPATH_W) '$(srcdir)/Common/Heap.cc'; fi` 1330 1366 1367 Common/driver_cfa_cpp-Eval.o: Common/Eval.cc 1368 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-Eval.o -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-Eval.Tpo -c -o Common/driver_cfa_cpp-Eval.o `test -f 'Common/Eval.cc' || echo '$(srcdir)/'`Common/Eval.cc 1369 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-Eval.Tpo Common/$(DEPDIR)/driver_cfa_cpp-Eval.Po 1370 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Common/Eval.cc' object='Common/driver_cfa_cpp-Eval.o' libtool=no @AMDEPBACKSLASH@ 1371 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1372 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-Eval.o `test -f 'Common/Eval.cc' || echo '$(srcdir)/'`Common/Eval.cc 1373 1374 Common/driver_cfa_cpp-Eval.obj: Common/Eval.cc 1375 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-Eval.obj -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-Eval.Tpo -c -o Common/driver_cfa_cpp-Eval.obj `if test -f 'Common/Eval.cc'; then $(CYGPATH_W) 'Common/Eval.cc'; else $(CYGPATH_W) '$(srcdir)/Common/Eval.cc'; fi` 1376 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-Eval.Tpo Common/$(DEPDIR)/driver_cfa_cpp-Eval.Po 1377 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Common/Eval.cc' object='Common/driver_cfa_cpp-Eval.obj' libtool=no @AMDEPBACKSLASH@ 1378 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1379 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-Eval.obj `if test -f 'Common/Eval.cc'; then $(CYGPATH_W) 'Common/Eval.cc'; else $(CYGPATH_W) '$(srcdir)/Common/Eval.cc'; fi` 1380 1331 1381 ControlStruct/driver_cfa_cpp-LabelGenerator.o: ControlStruct/LabelGenerator.cc 1332 1382 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelGenerator.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelGenerator.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelGenerator.o `test -f 'ControlStruct/LabelGenerator.cc' || echo '$(srcdir)/'`ControlStruct/LabelGenerator.cc … … 2574 2624 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2575 2625 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-Explode.obj `if test -f 'Tuples/Explode.cc'; then $(CYGPATH_W) 'Tuples/Explode.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/Explode.cc'; fi` 2626 2627 Validate/driver_cfa_cpp-HandleAttributes.o: Validate/HandleAttributes.cc 2628 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Validate/driver_cfa_cpp-HandleAttributes.o -MD -MP -MF Validate/$(DEPDIR)/driver_cfa_cpp-HandleAttributes.Tpo -c -o Validate/driver_cfa_cpp-HandleAttributes.o `test -f 'Validate/HandleAttributes.cc' || echo '$(srcdir)/'`Validate/HandleAttributes.cc 2629 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Validate/$(DEPDIR)/driver_cfa_cpp-HandleAttributes.Tpo Validate/$(DEPDIR)/driver_cfa_cpp-HandleAttributes.Po 2630 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Validate/HandleAttributes.cc' object='Validate/driver_cfa_cpp-HandleAttributes.o' libtool=no @AMDEPBACKSLASH@ 2631 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2632 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Validate/driver_cfa_cpp-HandleAttributes.o `test -f 'Validate/HandleAttributes.cc' || echo '$(srcdir)/'`Validate/HandleAttributes.cc 2633 2634 Validate/driver_cfa_cpp-HandleAttributes.obj: Validate/HandleAttributes.cc 2635 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Validate/driver_cfa_cpp-HandleAttributes.obj -MD -MP -MF Validate/$(DEPDIR)/driver_cfa_cpp-HandleAttributes.Tpo -c -o Validate/driver_cfa_cpp-HandleAttributes.obj `if test -f 'Validate/HandleAttributes.cc'; then $(CYGPATH_W) 'Validate/HandleAttributes.cc'; else $(CYGPATH_W) '$(srcdir)/Validate/HandleAttributes.cc'; fi` 2636 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Validate/$(DEPDIR)/driver_cfa_cpp-HandleAttributes.Tpo Validate/$(DEPDIR)/driver_cfa_cpp-HandleAttributes.Po 2637 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Validate/HandleAttributes.cc' object='Validate/driver_cfa_cpp-HandleAttributes.obj' libtool=no @AMDEPBACKSLASH@ 2638 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2639 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Validate/driver_cfa_cpp-HandleAttributes.obj `if test -f 'Validate/HandleAttributes.cc'; then $(CYGPATH_W) 'Validate/HandleAttributes.cc'; else $(CYGPATH_W) '$(srcdir)/Validate/HandleAttributes.cc'; fi` 2576 2640 2577 2641 Virtual/driver_cfa_cpp-ExpandCasts.o: Virtual/ExpandCasts.cc … … 2736 2800 -rm -f Tuples/$(DEPDIR)/$(am__dirstamp) 2737 2801 -rm -f Tuples/$(am__dirstamp) 2802 -rm -f Validate/$(DEPDIR)/$(am__dirstamp) 2803 -rm -f Validate/$(am__dirstamp) 2738 2804 -rm -f Virtual/$(DEPDIR)/$(am__dirstamp) 2739 2805 -rm -f Virtual/$(am__dirstamp) … … 2753 2819 2754 2820 distclean: distclean-am 2755 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) V irtual/$(DEPDIR)2821 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Validate/$(DEPDIR) Virtual/$(DEPDIR) 2756 2822 -rm -f Makefile 2757 2823 distclean-am: clean-am distclean-compile distclean-generic \ … … 2799 2865 2800 2866 maintainer-clean: maintainer-clean-am 2801 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) V irtual/$(DEPDIR)2867 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Validate/$(DEPDIR) Virtual/$(DEPDIR) 2802 2868 -rm -f Makefile 2803 2869 maintainer-clean-am: distclean-am maintainer-clean-generic -
src/ResolvExpr/CurrentObject.cc
rf7ac09d r3537dd7 139 139 ArrayIterator( ArrayType * at ) : array( at ) { 140 140 PRINT( std::cerr << "Creating array iterator: " << at << std::endl; ) 141 base = at-> get_base();141 base = at->base; 142 142 memberIter = createMemberIterator( base ); 143 if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @= " );144 setSize( at-> get_dimension());143 if ( at->isVarLen ) SemanticError( at, "VLA initialization does not support @=: " ); 144 setSize( at->dimension ); 145 145 } 146 146 … … 150 150 151 151 private: 152 void setSize( Expression * expr ) { 153 if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) { 154 try { 155 size = constExpr->intValue(); 156 PRINT( std::cerr << "array type with size: " << size << std::endl; ) 157 } catch ( SemanticErrorException & ) { 158 SemanticError( expr, "Constant expression of non-integral type in array dimension: " ); 159 } 160 } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) { 161 setSize( castExpr->get_arg() ); // xxx - need to perform the conversion specified by the cast 162 } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( expr ) ) { 163 if ( EnumInstType * inst = dynamic_cast< EnumInstType * > ( varExpr->result ) ) { 164 long long int value; 165 if ( inst->baseEnum->valueOf( varExpr->var, value ) ) { 166 size = value; 167 } 168 } 152 void setSize( Expression * expr ) { // replace this logic with an eval call 153 auto res = eval(expr); 154 if (res.second) { 155 size = res.first; 169 156 } else { 170 assertf( false, "unhandled expression in setSize: %s", toString( expr ).c_str() ); // xxx - if not a constant expression, it's not simple to determine how long the array actually is, which is necessary for initialization to be done correctly -- fix this157 SemanticError( expr->location, toString("Array designator must be a constant expression: ", expr) ); 171 158 } 172 159 } -
src/SymTab/Validate.cc
rf7ac09d r3537dd7 61 61 #include "Parser/LinkageSpec.h" // for C 62 62 #include "ResolvExpr/typeops.h" // for typesCompatible 63 #include "ResolvExpr/Resolver.h" // for findSingleExpression 63 64 #include "SymTab/Autogen.h" // for SizeType 64 65 #include "SynTree/Attribute.h" // for noAttributes, Attribute … … 72 73 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution 73 74 #include "SynTree/Visitor.h" // for Visitor 75 #include "Validate/HandleAttributes.h" // for handleAttributes 74 76 75 77 class CompoundStmt; … … 247 249 }; 248 250 249 struct ArrayLength {251 struct ArrayLength : public WithIndexer { 250 252 /// for array types without an explicit length, compute the length and store it so that it 251 253 /// is known to the rest of the phases. For example, … … 258 260 259 261 void previsit( ObjectDecl * objDecl ); 262 void previsit( ArrayType * arrayType ); 260 263 }; 261 264 … … 312 315 acceptAll( translationUnit, finder ); // xxx - remove this pass soon 313 316 mutateAll( translationUnit, labelAddrFixer ); 317 Validate::handleAttributes( translationUnit ); 314 318 } 315 319 … … 1232 1236 void ArrayLength::previsit( ObjectDecl * objDecl ) { 1233 1237 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) { 1234 if ( at-> get_dimension()) return;1238 if ( at->dimension ) return; 1235 1239 if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->init ) ) { 1236 at->set_dimension( new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ) ); 1237 } 1240 at->dimension = new ConstantExpr( Constant::from_ulong( init->initializers.size() ) ); 1241 } 1242 } 1243 } 1244 1245 void ArrayLength::previsit( ArrayType * type ) { 1246 if ( type->dimension ) { 1247 // need to resolve array dimensions early so that constructor code can correctly determine 1248 // if a type is a VLA (and hence whether its elements need to be constructed) 1249 ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer ); 1250 1251 // must re-evaluate whether a type is a VLA, now that more information is available 1252 // (e.g. the dimension may have been an enumerator, which was unknown prior to this step) 1253 type->isVarLen = ! InitTweak::isConstExpr( type->dimension ); 1238 1254 } 1239 1255 } -
src/main.cc
rf7ac09d r3537dd7 28 28 #include <string> // for char_traits, operator<< 29 29 30 #include "CompilationState.h" 30 31 #include "../config.h" // for CFA_LIBDIR 31 32 #include "CodeGen/FixMain.h" // for FixMain … … 72 73 DeclarationNode * parseTree = nullptr; // program parse tree 73 74 74 extern int yydebug; // set for -g flag (Grammar)75 bool76 astp = false,77 bresolvep = false,78 bboxp = false,79 bcodegenp = false,80 ctorinitp = false,81 declstatsp = false,82 exprp = false,83 expraltp = false,84 genericsp = false,85 libcfap = false,86 nopreludep = false,87 noprotop = false,88 nomainp = false,89 parsep = false,90 resolvep = false, // used in AlternativeFinder91 symtabp = false,92 treep = false,93 tuplep = false,94 validp = false,95 errorp = false,96 codegenp = false,97 prettycodegenp = false,98 linemarks = false;99 100 75 static void parse_cmdline( int argc, char *argv[], const char *& filename ); 101 76 static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false ); … … 208 183 209 184 // Read to gcc builtins, if not generating the cfa library 210 FILE * gcc_builtins = fopen( libcfap | treep? "../prelude/gcc-builtins.cf" : CFA_LIBDIR "/gcc-builtins.cf", "r" );185 FILE * gcc_builtins = fopen( buildingLibrary() ? "../prelude/gcc-builtins.cf" : CFA_LIBDIR "/gcc-builtins.cf", "r" ); 211 186 assertf( gcc_builtins, "cannot open gcc-builtins.cf\n" ); 212 187 parse( gcc_builtins, LinkageSpec::Compiler ); 213 188 214 189 // read the extra prelude in, if not generating the cfa library 215 FILE * extras = fopen( libcfap | treep? "../prelude/extras.cf" : CFA_LIBDIR "/extras.cf", "r" );190 FILE * extras = fopen( buildingLibrary() ? "../prelude/extras.cf" : CFA_LIBDIR "/extras.cf", "r" ); 216 191 assertf( extras, "cannot open extras.cf\n" ); 217 192 parse( extras, LinkageSpec::BuiltinC ); … … 219 194 if ( ! libcfap ) { 220 195 // read the prelude in, if not generating the cfa library 221 FILE * prelude = fopen( treep? "../prelude/prelude.cf" : CFA_LIBDIR "/prelude.cf", "r" );196 FILE * prelude = fopen( buildingLibrary() ? "../prelude/prelude.cf" : CFA_LIBDIR "/prelude.cf", "r" ); 222 197 assertf( prelude, "cannot open prelude.cf\n" ); 223 198 parse( prelude, LinkageSpec::Intrinsic ); 224 199 225 200 // Read to cfa builtins, if not generating the cfa library 226 FILE * builtins = fopen( libcfap | treep? "../prelude/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" );201 FILE * builtins = fopen( buildingLibrary() ? "../prelude/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" ); 227 202 assertf( builtins, "cannot open builtins.cf\n" ); 228 203 parse( builtins, LinkageSpec::BuiltinCFA ); … … 299 274 300 275 // fix ObjectDecl - replaces ConstructorInit nodes 301 PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep) );276 PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) ); 302 277 if ( ctorinitp ) { 303 278 dump ( translationUnit ); -
src/tests/.expect/attributes.x64.txt
rf7ac09d r3537dd7 316 316 ((void)sizeof(__attribute__ ((unused,unused)) signed int )); 317 317 ((void)sizeof(__attribute__ ((unused,unused,unused,unused)) signed int **)); 318 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int [ 5]));319 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[ 10]));318 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int [((unsigned long int )5)])); 319 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int (*)[((unsigned long int )10)])); 320 320 ((void)sizeof(__attribute__ ((unused,unused,unused)) signed int ())); 321 321 struct __attribute__ ((unused)) __anonymous3 {
Note:
See TracChangeset
for help on using the changeset viewer.