Changeset 779a4a3 for src/Common
- Timestamp:
- May 3, 2018, 4:33:19 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct, with_gc
- Children:
- f3152ab
- Parents:
- f465f0e (diff), c9d5c4f (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
- 6 edited
-
Heap.cc (added)
-
Heap.h (added)
-
PassVisitor.h (modified) (2 diffs)
-
PassVisitor.impl.h (modified) (1 diff)
-
SemanticError.cc (modified) (2 diffs)
-
SemanticError.h (modified) (4 diffs)
-
module.mk (modified) (2 diffs)
-
utility.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
rf465f0e r779a4a3 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; … … 168 169 virtual Statement * mutate( ExprStmt * exprStmt ) override final; 169 170 virtual Statement * mutate( AsmStmt * asmStmt ) override final; 171 virtual Statement * mutate( DirectiveStmt * dirStmt ) override final; 170 172 virtual Statement * mutate( IfStmt * ifStmt ) override final; 171 173 virtual Statement * mutate( WhileStmt * whileStmt ) override final; -
src/Common/PassVisitor.impl.h
rf465f0e r779a4a3 777 777 778 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 ); 790 791 MUTATE_END( Statement, node ); 792 } 793 794 //-------------------------------------------------------------------------- 779 795 // IfStmt 780 796 template< typename pass_type > -
src/Common/SemanticError.cc
rf465f0e r779a4a3 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 2 18:13:37 2018 13 // Update Count : 8 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" 25 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 26 72 SemanticErrorException::SemanticErrorException( CodeLocation location, std::string error ) { 27 73 append( location, error ); … … 69 115 70 116 void SemanticWarningImpl( CodeLocation location, Warning warning, const char * const fmt, ... ) { 71 Severity severity = WarningFormats[(int)warning].severity;117 Severity severity = get_severities()[(int)warning]; 72 118 switch(severity) { 73 119 case Severity::Suppress : -
src/Common/SemanticError.h
rf465f0e r779a4a3 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:03201813 // Update Count : 1912 // Last Modified On : Wed May 2 18:13:15 2018 13 // Update Count : 29 14 14 // 15 15 … … 17 17 18 18 #include "ErrorObjects.h" 19 #include <cstring> 19 20 20 21 //----------------------------------------------------------------------------- … … 46 47 const char * const name; 47 48 const char * const message; 48 mutable Severityseverity;49 const Severity default_severity; 49 50 }; 50 51 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},52 constexpr WarningData WarningFormats[] = { 53 {"self-assign" , "self assignment of expression: %s" , Severity::Warn}, 54 {"reference-conversion" , "rvalue to reference conversion of rvalue: %s" , Severity::Warn}, 54 55 {"qualifiers-zero_t-one_t", "questionable use of type qualifier %s with %s", Severity::Warn}, 55 56 }; … … 71 72 void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4))); 72 73 74 void SemanticWarning_SuppressAll (); 75 void SemanticWarning_EnableAll (); 76 void SemanticWarning_WarningAsError(); 77 void SemanticWarning_Set (const char * const name, Severity s); 78 79 // SKULLDUGGERY: cfa.cc is built before SemanticError.cc but needs this routine. 80 static inline bool SemanticWarning_Exist(const char * const name) { 81 for ( const auto & w : WarningFormats ) { 82 if ( std::strcmp( name, w.name ) == 0 ) return true; 83 } 84 return false; 85 } 73 86 74 87 //----------------------------------------------------------------------------- -
src/Common/module.mk
rf465f0e r779a4a3 6 6 ## file "LICENCE" distributed with Cforall. 7 7 ## 8 ## module.mk -- 8 ## module.mk -- 9 9 ## 10 10 ## Author : Richard C. Bilson … … 18 18 Common/UniqueName.cc \ 19 19 Common/DebugMalloc.cc \ 20 Common/Assert.cc 20 Common/Assert.cc \ 21 Common/Heap.cc -
src/Common/utility.h
rf465f0e r779a4a3 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 : 3 812 // Last Modified On : Thu May 3 12:18:31 2018 13 // Update Count : 39 14 14 // 15 15 … … 441 441 442 442 template<typename T> 443 inline constexpr T ilog2(const T & t) { 444 if ( std::is_integral<T>::value ) { 443 inline 444 #if __GNUC__ > 4 445 constexpr 446 #endif 447 T ilog2(const T & t) { 448 if(std::is_integral<T>::value) { 445 449 const constexpr int r = sizeof(t) * __CHAR_BIT__ - 1; 446 if ( sizeof(T) == sizeof(unsigned int ) ) return r - __builtin_clz( t ); 447 if ( sizeof(T) == sizeof(unsigned long) ) return r - __builtin_clzl( t ); 448 if ( sizeof(T) == sizeof(unsigned long long) ) return r - __builtin_clzll( t ); 449 } // if 450 if( sizeof(T) == sizeof(unsigned int) ) return r - __builtin_clz ( t ); 451 if( sizeof(T) == sizeof(unsigned long) ) return r - __builtin_clzl ( t ); 452 if( sizeof(T) == sizeof(unsigned long long) ) return r - __builtin_clzll( t ); 453 } 454 assert(false); 450 455 return -1; 451 } // ilo ng2456 } // ilog2 452 457 453 458
Note:
See TracChangeset
for help on using the changeset viewer.