source: src/AST/Attribute.hpp @ 7aa209e7

Last change on this file since 7aa209e7 was 624ba3a5, checked in by Peter A. Buhr <pabuhr@…>, 4 months ago

formatting

  • Property mode set to 100644
File size: 1.6 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.hpp --
8//
9// Author           : Aaron B. Moss
10// Created On       : Fri May 10 10:30:00 2019
11// Last Modified By : Peter A. Buhr
12// Created On       : Fri May 10 10:30:00 2019
13// Update Count     : 2
14//
15
16#pragma once
17
18#include <string>
19#include <vector>
20
21#include "Fwd.hpp"
22#include "Node.hpp"     // for ptr
23#include "Visitor.hpp"
24
25namespace ast {
26
27class Expr;
28
29/// An entry in an attribute list: `__attribute__(( ... ))`
30class Attribute final : public Node {
31public:
32        std::string name;
33        std::vector<ptr<Expr>> params;
34
35        Attribute( const std::string & name = "", std::vector<ptr<Expr>> && params = {})
36                : name( name ), params( params ) {}
37        virtual ~Attribute() = default;
38
39        bool empty() const { return name.empty(); }
40
41        /// strip leading/trailing underscores and lowercase
42        std::string normalizedName() const;
43
44        /// true iff this attribute is allowed to appear attached to a function parameter
45        bool isValidOnFuncParam() const;
46
47        const Attribute * accept( Visitor & v ) const override { return v.visit( this ); }
48private:
49        Attribute * clone() const override { return new Attribute{ *this }; }
50
51        /// Must be copied in ALL derived classes
52        template<typename node_t>
53        friend node_t * mutate(const node_t * node);
54        template<typename node_t>
55    friend node_t * shallowCopy(const node_t * node);
56};
57
58}
59
60// Local Variables: //
61// tab-width: 4 //
62// mode: c++ //
63// compile-command: "make install" //
64// End: //
Note: See TracBrowser for help on using the repository browser.