Changes in src/SynTree/Attribute.cc [54c9000:50377a4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Attribute.cc
r54c9000 r50377a4 15 15 16 16 #include <ostream> // for operator<<, ostream, basic_ostream, endl 17 #include <set>18 17 19 18 #include "Attribute.h" … … 22 21 23 22 Attribute::Attribute( const Attribute &other ) : name( other.name ) { 24 23 cloneAll( other.parameters, parameters ); 25 24 } 26 25 27 26 Attribute::~Attribute() { 28 deleteAll( parameters ); 29 } 30 31 bool Attribute::isValidOnFuncParam() const { 32 // attributes such as aligned, cleanup, etc. produce GCC errors when they appear 33 // on function parameters. Maintain here a whitelist of attribute names that are 34 // allowed to appear on parameters. 35 static std::set< std::string > valid = { 36 "noreturn", "unused" 37 }; 38 return valid.count( normalizedName() ); 39 } 40 41 std::string Attribute::normalizedName() const { 42 // trim beginning/ending _, convert to lowercase 43 auto begin = name.find_first_not_of('_'); 44 auto end = name.find_last_not_of('_'); 45 if (begin == std::string::npos || end == std::string::npos) return ""; 46 std::string ret; 47 ret.reserve( end-begin+1 ); 48 std::transform( &name[begin], &name[end+1], back_inserter( ret ), tolower ); 49 return ret; 27 deleteAll( parameters ); 50 28 } 51 29 52 30 void Attribute::print( std::ostream &os, Indenter indent ) const { 53 54 31 using std::endl; 32 using std::string; 55 33 56 57 58 59 60 61 62 34 if ( ! empty() ) { 35 os << "Attribute with name: " << name; 36 if ( ! parameters.empty() ) { 37 os << " with parameters: " << endl; 38 printAll( parameters, os, indent+1 ); 39 } 40 } 63 41 } 64 42
Note:
See TracChangeset
for help on using the changeset viewer.