Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / rust / rust-location.h
blob9cb29b20919f1596052ee2d708c145d34fcc4e92
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
3 // This file is part of GCC.
5 // GCC is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 3, or (at your option) any later
8 // version.
10 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 // for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with GCC; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
19 // rust-location.h -- GCC specific Location declaration. -*- C++ -*-
21 #ifndef RUST_LOCATION_H
22 #define RUST_LOCATION_H
24 #include "rust-system.h"
26 // A location in an input source file.
28 class Location
30 public:
31 Location () : gcc_loc_ (UNKNOWN_LOCATION) {}
33 explicit Location (location_t loc) : gcc_loc_ (loc) {}
35 location_t gcc_location () const { return gcc_loc_; }
37 Location operator+= (location_t rhs)
39 gcc_loc_ += rhs;
40 return *this;
43 Location operator-= (location_t rhs)
45 gcc_loc_ -= rhs;
46 return *this;
49 bool operator== (location_t rhs) { return rhs == gcc_loc_; }
51 private:
52 location_t gcc_loc_;
55 // The Rust frontend requires the ability to compare Locations.
57 inline bool
58 operator< (Location loca, Location locb)
60 return loca.gcc_location () < locb.gcc_location ();
63 inline bool
64 operator== (Location loca, Location locb)
66 return loca.gcc_location () == locb.gcc_location ();
69 inline Location
70 operator+ (Location lhs, location_t rhs)
72 lhs += rhs;
73 return lhs;
76 inline Location
77 operator- (Location lhs, location_t rhs)
79 lhs -= rhs;
80 return lhs;
83 class RichLocation
85 public:
86 RichLocation (Location root);
87 ~RichLocation ();
89 void add_range (Location loc);
91 void add_fixit_insert_before (const std::string &new_parent);
93 void add_fixit_insert_before (Location where, const std::string &new_parent);
95 void add_fixit_insert_after (const std::string &new_parent);
97 void add_fixit_insert_after (Location where, const std::string &new_parent);
99 const rich_location &get () const { return gcc_rich_loc; }
101 private:
102 rich_location gcc_rich_loc;
105 #endif // !defined(RUST_LOCATION_H)