* pt.c (lookup_template_class_1): Splice out abi_tag attribute if
[official-gcc.git] / gcc / go / go-linemap.cc
blobb41559ed4ca94accbb87eae1f390af6fc5afab04
1 // go-linemap.cc -- GCC implementation of Linemap.
3 // Copyright 2011 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 #include "go-linemap.h"
9 // This class implements the Linemap interface defined by the
10 // frontend.
12 class Gcc_linemap : public Linemap
14 public:
15 Gcc_linemap()
16 : Linemap(),
17 in_file_(false)
18 { }
20 void
21 start_file(const char* file_name, unsigned int line_begin);
23 void
24 start_line(unsigned int line_number, unsigned int line_size);
26 Location
27 get_location(unsigned int column);
29 void
30 stop();
32 protected:
33 Location
34 get_predeclared_location();
36 Location
37 get_unknown_location();
39 bool
40 is_predeclared(Location);
42 bool
43 is_unknown(Location);
45 private:
46 // Whether we are currently reading a file.
47 bool in_file_;
50 Linemap* Linemap::instance_ = NULL;
52 // Start getting locations from a new file.
54 void
55 Gcc_linemap::start_file(const char *file_name, unsigned line_begin)
57 if (this->in_file_)
58 linemap_add(line_table, LC_LEAVE, 0, NULL, 0);
59 linemap_add(line_table, LC_ENTER, 0, file_name, line_begin);
60 this->in_file_ = true;
63 // Stop getting locations.
65 void
66 Gcc_linemap::stop()
68 linemap_add(line_table, LC_LEAVE, 0, NULL, 0);
69 this->in_file_ = false;
72 // Start a new line.
74 void
75 Gcc_linemap::start_line(unsigned lineno, unsigned linesize)
77 linemap_line_start(line_table, lineno, linesize);
80 // Get a location.
82 Location
83 Gcc_linemap::get_location(unsigned column)
85 return Location(linemap_position_for_column(line_table, column));
88 // Get the unknown location.
90 Location
91 Gcc_linemap::get_unknown_location()
93 return Location(UNKNOWN_LOCATION);
96 // Get the predeclared location.
98 Location
99 Gcc_linemap::get_predeclared_location()
101 return Location(BUILTINS_LOCATION);
104 // Return whether a location is the predeclared location.
106 bool
107 Gcc_linemap::is_predeclared(Location loc)
109 return loc.gcc_location() == BUILTINS_LOCATION;
112 // Return whether a location is the unknown location.
114 bool
115 Gcc_linemap::is_unknown(Location loc)
117 return loc.gcc_location() == UNKNOWN_LOCATION;
120 // Return the Linemap to use for the gcc backend.
122 Linemap*
123 go_get_linemap()
125 return new Gcc_linemap;