Changeset ff29f08 for src/Common
- Timestamp:
- May 18, 2018, 2:09:21 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- 2472a19
- Parents:
- f6f0cca3 (diff), c7d8100c (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/Common
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
rf6f0cca3 rff29f08 71 71 virtual void visit( ExprStmt * exprStmt ) override final; 72 72 virtual void visit( AsmStmt * asmStmt ) override final; 73 virtual void visit( DirectiveStmt * dirStmt ) override final; 73 74 virtual void visit( IfStmt * ifStmt ) override final; 74 75 virtual void visit( WhileStmt * whileStmt ) override final; … … 170 171 virtual Statement * mutate( ExprStmt * exprStmt ) override final; 171 172 virtual Statement * mutate( AsmStmt * asmStmt ) override final; 173 virtual Statement * mutate( DirectiveStmt * dirStmt ) override final; 172 174 virtual Statement * mutate( IfStmt * ifStmt ) override final; 173 175 virtual Statement * mutate( WhileStmt * whileStmt ) override final; -
src/Common/PassVisitor.impl.h
rf6f0cca3 rff29f08 690 690 VISIT_START( node ); 691 691 692 maybeAccept_impl( node->condition, *this);693 maybeAccept_impl( node->message 692 node->condition = visitExpression( node->condition ); 693 maybeAccept_impl( node->message, *this ); 694 694 695 695 VISIT_END( node ); … … 700 700 MUTATE_START( node ); 701 701 702 maybeMutate_impl( node->condition, *this);703 maybeMutate_impl( node->message 702 node->condition = mutateExpression( node->condition ); 703 maybeMutate_impl( node->message, *this ); 704 704 705 705 MUTATE_END( StaticAssertDecl, node ); … … 772 772 maybeMutate_impl( node->input, *this ); 773 773 maybeMutate_impl( node->clobber, *this ); 774 775 MUTATE_END( Statement, node ); 776 } 777 778 //-------------------------------------------------------------------------- 779 // AsmStmt 780 template< typename pass_type > 781 void PassVisitor< pass_type >::visit( DirectiveStmt * node ) { 782 VISIT_START( node ) 783 784 VISIT_END( node ); 785 } 786 787 template< typename pass_type > 788 Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) { 789 MUTATE_START( node ); 774 790 775 791 MUTATE_END( Statement, node ); -
src/Common/PassVisitor.proto.h
rf6f0cca3 rff29f08 47 47 48 48 operator bool() { return m_ref ? *m_ref : true; } 49 bool operator=( bool val ) { return *m_ref = val; }49 bool operator=( bool val ) { assert(m_ref); return *m_ref = val; } 50 50 51 51 private: … … 53 53 friend class ChildrenGuard; 54 54 55 bool * set( bool &val ) {55 bool * set( bool * val ) { 56 56 bool * prev = m_ref; 57 m_ref = &val;57 m_ref = val; 58 58 return prev; 59 59 } … … 67 67 ChildrenGuard( bool_ref * ref ) 68 68 : m_val ( true ) 69 , m_prev( ref ? ref->set( m_val ) : nullptr )69 , m_prev( ref ? ref->set( &m_val ) : nullptr ) 70 70 , m_ref ( ref ) 71 71 {} … … 73 73 ~ChildrenGuard() { 74 74 if( m_ref ) { 75 m_ref->set( *m_prev );75 m_ref->set( m_prev ); 76 76 } 77 77 } -
src/Common/SemanticError.cc
rf6f0cca3 rff29f08 7 7 // SemanticError.cc -- 8 8 // 9 // Author : Richard C. Bilson9 // Author : Thierry Delisle 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 29 18:17:35 201713 // Update Count : 312 // Last Modified On : Wed May 16 15:01:20 2018 13 // Update Count : 9 14 14 // 15 15 16 16 #include <cstdarg> 17 17 #include <cstdio> // for fileno, stderr 18 #include <cstring> 18 19 #include <unistd.h> // for isatty 19 20 #include <iostream> // for basic_ostream, operator<<, ostream 20 21 #include <list> // for list, _List_iterator 21 22 #include <string> // for string, operator<<, operator+, to_string 23 #include <vector> 22 24 23 25 #include "Common/utility.h" // for to_string, CodeLocation (ptr only) 24 26 #include "SemanticError.h" 27 28 //----------------------------------------------------------------------------- 29 // Severity Handling 30 std::vector<Severity> & get_severities() { 31 static std::vector<Severity> severities; 32 if(severities.empty()) { 33 severities.reserve((size_t)Warning::NUMBER_OF_WARNINGS); 34 for ( const auto w : WarningFormats ) { 35 severities.push_back( w.default_severity ); 36 } // for 37 } 38 return severities; 39 } 40 41 void SemanticWarning_SuppressAll() { 42 for( auto & s : get_severities() ) { 43 s = Severity::Suppress; 44 } 45 } 46 47 void SemanticWarning_EnableAll() { 48 for( auto & s : get_severities() ) { 49 s = Severity::Warn; 50 } 51 } 52 53 void SemanticWarning_WarningAsError() { 54 for( auto & s : get_severities() ) { 55 if(s == Severity::Warn) s = Severity::Error; 56 } 57 } 58 59 void SemanticWarning_Set(const char * const name, Severity s) { 60 size_t idx = 0; 61 for ( const auto & w : WarningFormats ) { 62 if ( std::strcmp( name, w.name ) == 0 ) { 63 get_severities()[idx] = s; 64 break; 65 } 66 idx++; 67 } 68 } 69 70 //----------------------------------------------------------------------------- 71 // Semantic Error 72 bool SemanticErrorThrow = false; 25 73 26 74 SemanticErrorException::SemanticErrorException( CodeLocation location, std::string error ) { … … 48 96 49 97 void SemanticError( CodeLocation location, std::string error ) { 98 SemanticErrorThrow = true; 50 99 throw SemanticErrorException(location, error); 51 100 } … … 69 118 70 119 void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) { 71 Severity severity = WarningFormats[(int)warning].severity;120 Severity severity = get_severities()[(int)warning]; 72 121 switch(severity) { 73 122 case Severity::Suppress : -
src/Common/SemanticError.h
rf6f0cca3 rff29f08 7 7 // SemanticError.h -- 8 8 // 9 // Author : Richard C. Bilson9 // Author : Thierry Delisle 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Apr 19 17:52:03 201813 // Update Count : 1912 // Last Modified On : Wed May 16 15:01:23 2018 13 // Update Count : 30 14 14 // 15 15 … … 17 17 18 18 #include "ErrorObjects.h" 19 #include <cstring> 19 20 20 21 //----------------------------------------------------------------------------- 21 22 // Errors 23 24 extern bool SemanticErrorThrow; 22 25 23 26 __attribute__((noreturn)) void SemanticError( CodeLocation location, std::string error ); … … 46 49 const char * const name; 47 50 const char * const message; 48 mutable Severityseverity;51 const Severity default_severity; 49 52 }; 50 53 51 constexpr constWarningData WarningFormats[] = {52 {"self-assign" , "self assignment of expression: %s", Severity::Warn},53 {"reference-conversion" , "rvalue to reference conversion of rvalue: %s", Severity::Warn},54 constexpr WarningData WarningFormats[] = { 55 {"self-assign" , "self assignment of expression: %s" , Severity::Warn}, 56 {"reference-conversion" , "rvalue to reference conversion of rvalue: %s" , Severity::Warn}, 54 57 {"qualifiers-zero_t-one_t", "questionable use of type qualifier %s with %s", Severity::Warn}, 55 58 }; … … 71 74 void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4))); 72 75 76 void SemanticWarning_SuppressAll (); 77 void SemanticWarning_EnableAll (); 78 void SemanticWarning_WarningAsError(); 79 void SemanticWarning_Set (const char * const name, Severity s); 80 81 // SKULLDUGGERY: cfa.cc is built before SemanticError.cc but needs this routine. 82 static inline bool SemanticWarning_Exist(const char * const name) { 83 for ( const auto & w : WarningFormats ) { 84 if ( std::strcmp( name, w.name ) == 0 ) return true; 85 } 86 return false; 87 } 73 88 74 89 //----------------------------------------------------------------------------- -
src/Common/module.mk
rf6f0cca3 rff29f08 19 19 Common/DebugMalloc.cc \ 20 20 Common/GC.cc \ 21 Common/Assert.cc 21 Common/Assert.cc \ 22 Common/Heap.cc -
src/Common/utility.h
rf6f0cca3 rff29f08 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 20 22:35:33201813 // Update Count : 3812 // Last Modified On : Sun May 6 22:24:16 2018 13 // Update Count : 40 14 14 // 15 15 … … 438 438 439 439 template<typename T> 440 inline constexpr T ilog2(const T & t) { 441 if ( std::is_integral<T>::value ) { 440 inline 441 #if defined(__GNUC__) && __GNUC__ > 4 442 constexpr 443 #endif 444 T ilog2(const T & t) { 445 if(std::is_integral<T>::value) { 442 446 const constexpr int r = sizeof(t) * __CHAR_BIT__ - 1; 443 if ( sizeof(T) == sizeof(unsigned int ) ) return r - __builtin_clz( t ); 444 if ( sizeof(T) == sizeof(unsigned long) ) return r - __builtin_clzl( t ); 445 if ( sizeof(T) == sizeof(unsigned long long) ) return r - __builtin_clzll( t ); 446 } // if 447 if( sizeof(T) == sizeof(unsigned int) ) return r - __builtin_clz ( t ); 448 if( sizeof(T) == sizeof(unsigned long) ) return r - __builtin_clzl ( t ); 449 if( sizeof(T) == sizeof(unsigned long long) ) return r - __builtin_clzll( t ); 450 } 451 assert(false); 447 452 return -1; 448 } // ilo ng2453 } // ilog2 449 454 450 455
Note: See TracChangeset
for help on using the changeset viewer.