source: src/AST/Attribute.hpp @ c588acb

Last change on this file since c588acb was 2c8946b, checked in by Andrew Beach <ajbeach@…>, 6 months ago

Various whitespace and intentation updates.

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[7e89526]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
[624ba3a5]11// Last Modified By : Peter A. Buhr
[7e89526]12// Created On       : Fri May 10 10:30:00 2019
[624ba3a5]13// Update Count     : 2
[7e89526]14//
15
16#pragma once
17
18#include <string>
19#include <vector>
20
[6d51bd7]21#include "Fwd.hpp"
[7e89526]22#include "Node.hpp"     // for ptr
23#include "Visitor.hpp"
24
25namespace ast {
26
27class Expr;
28
[94c98f0e]29/// An entry in an attribute list: `__attribute__(( ... ))`
[7e89526]30class Attribute final : public Node {
31public:
32        std::string name;
[489bacf]33        std::vector<ptr<Expr>> params;
[7e89526]34
[6d51bd7]35        Attribute( const std::string & name = "", std::vector<ptr<Expr>> && params = {})
[624ba3a5]36                : name( name ), params( params ) {}
[6d51bd7]37        virtual ~Attribute() = default;
[7e89526]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
[6d51bd7]47        const Attribute * accept( Visitor & v ) const override { return v.visit( this ); }
[7e89526]48private:
[6d51bd7]49        Attribute * clone() const override { return new Attribute{ *this }; }
50
51        /// Must be copied in ALL derived classes
52        template<typename node_t>
[87701b6]53        friend node_t * mutate(const node_t * node);
[99da267]54        template<typename node_t>
[2c8946b]55        friend node_t * shallowCopy(const node_t * node);
[7e89526]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.