Changeset 90152a4 for src/SynTree/Attribute.cc
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b7c89aa
- Parents:
- f9feab8 (diff), 305581d (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Attribute.cc
rf9feab8 r90152a4 15 15 16 16 #include <ostream> // for operator<<, ostream, basic_ostream, endl 17 #include <set> 17 18 18 19 #include "Attribute.h" … … 21 22 22 23 Attribute::Attribute( const Attribute &other ) : name( other.name ) { 23 24 cloneAll( other.parameters, parameters ); 24 25 } 25 26 26 27 Attribute::~Attribute() { 27 deleteAll( parameters ); 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; 28 50 } 29 51 30 52 void Attribute::print( std::ostream &os, Indenter indent ) const { 31 32 53 using std::endl; 54 using std::string; 33 55 34 35 36 37 38 39 40 56 if ( ! empty() ) { 57 os << "Attribute with name: " << name; 58 if ( ! parameters.empty() ) { 59 os << " with parameters: " << endl; 60 printAll( parameters, os, indent+1 ); 61 } 62 } 41 63 } 42 64
Note:
See TracChangeset
for help on using the changeset viewer.