Obj: make the Location constructors constexpr

This commit is contained in:
Max Kellermann 2020-02-04 13:38:08 +01:00
parent ba445d36f9
commit b4966858ce

View file

@ -8,20 +8,12 @@ class ODesc;
class Location final {
public:
Location(const char* fname, int line_f, int line_l, int col_f, int col_l)
{
filename = fname;
first_line = line_f;
last_line = line_l;
first_column = col_f;
last_column = col_l;
}
constexpr Location(const char* fname, int line_f, int line_l,
int col_f, int col_l) noexcept
:filename(fname), first_line(line_f), last_line(line_l),
first_column(col_f), last_column(col_l) {}
Location()
{
filename = 0;
first_line = last_line = first_column = last_column = 0;
}
Location() = default;
void Describe(ODesc* d) const;
@ -29,9 +21,9 @@ public:
bool operator!=(const Location& l) const
{ return ! (*this == l); }
const char* filename;
int first_line, last_line;
int first_column, last_column;
const char* filename = nullptr;
int first_line = 0, last_line = 0;
int first_column = 0, last_column = 0;
};
#define YYLTYPE yyltype