ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change
on this file since 41870a5 was
0b57626,
checked in by Andrew Beach <ajbeach@…>, 5 years ago
|
Silenced a warning and removed trailing whitespace.
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // Attribute.cpp -- |
---|
8 | // |
---|
9 | // Author : Aaron B. Moss |
---|
10 | // Created On : Fri May 10 10:30:00 2019 |
---|
11 | // Last Modified By : Aaron B. Moss |
---|
12 | // Created On : Fri May 10 10:30:00 2019 |
---|
13 | // Update Count : 1 |
---|
14 | // |
---|
15 | |
---|
16 | #include "Attribute.hpp" |
---|
17 | |
---|
18 | #include <algorithm> // for transform |
---|
19 | #include <cctype> // for tolower |
---|
20 | #include <iterator> // for back_inserter |
---|
21 | #include <string> |
---|
22 | |
---|
23 | namespace ast { |
---|
24 | |
---|
25 | std::string Attribute::normalizedName() const { |
---|
26 | // trim underscores |
---|
27 | auto begin = name.find_first_not_of('_'); |
---|
28 | auto end = name.find_last_not_of('_'); |
---|
29 | if ( begin == std::string::npos || end == std::string::npos ) return ""; |
---|
30 | |
---|
31 | // convert to lowercase |
---|
32 | std::string ret; |
---|
33 | ret.reserve( end-begin+1 ); |
---|
34 | int (*tolower)(int) = std::tolower; |
---|
35 | std::transform( &name[begin], &name[end+1], back_inserter( ret ), tolower ); |
---|
36 | return ret; |
---|
37 | } |
---|
38 | |
---|
39 | bool Attribute::isValidOnFuncParam() const { |
---|
40 | // attributes such as aligned, cleanup, etc. produce GCC errors when they appear |
---|
41 | // on function parameters. Maintain here a whitelist of attribute names that are |
---|
42 | // allowed to appear on parameters. |
---|
43 | std::string norm = normalizedName(); |
---|
44 | return norm == "unused" || norm == "noreturn"; |
---|
45 | } |
---|
46 | |
---|
47 | } |
---|
48 | |
---|
49 | // Local Variables: // |
---|
50 | // tab-width: 4 // |
---|
51 | // mode: c++ // |
---|
52 | // compile-command: "make install" // |
---|
53 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.