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
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
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.
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
)
43 Location
operator-= (location_t rhs
)
49 bool operator== (location_t rhs
) { return rhs
== gcc_loc_
; }
55 // The Rust frontend requires the ability to compare Locations.
58 operator< (Location loca
, Location locb
)
60 return loca
.gcc_location () < locb
.gcc_location ();
64 operator== (Location loca
, Location locb
)
66 return loca
.gcc_location () == locb
.gcc_location ();
70 operator+ (Location lhs
, location_t rhs
)
77 operator- (Location lhs
, location_t rhs
)
86 RichLocation (Location root
);
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
; }
102 rich_location gcc_rich_loc
;
105 #endif // !defined(RUST_LOCATION_H)