mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Obj: make the Location constructors constexpr
This commit is contained in:
parent
ba445d36f9
commit
b4966858ce
1 changed files with 8 additions and 16 deletions
24
src/Obj.h
24
src/Obj.h
|
@ -8,20 +8,12 @@ class ODesc;
|
||||||
|
|
||||||
class Location final {
|
class Location final {
|
||||||
public:
|
public:
|
||||||
Location(const char* fname, int line_f, int line_l, int col_f, int col_l)
|
constexpr Location(const char* fname, int line_f, int line_l,
|
||||||
{
|
int col_f, int col_l) noexcept
|
||||||
filename = fname;
|
:filename(fname), first_line(line_f), last_line(line_l),
|
||||||
first_line = line_f;
|
first_column(col_f), last_column(col_l) {}
|
||||||
last_line = line_l;
|
|
||||||
first_column = col_f;
|
|
||||||
last_column = col_l;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location()
|
Location() = default;
|
||||||
{
|
|
||||||
filename = 0;
|
|
||||||
first_line = last_line = first_column = last_column = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Describe(ODesc* d) const;
|
void Describe(ODesc* d) const;
|
||||||
|
|
||||||
|
@ -29,9 +21,9 @@ public:
|
||||||
bool operator!=(const Location& l) const
|
bool operator!=(const Location& l) const
|
||||||
{ return ! (*this == l); }
|
{ return ! (*this == l); }
|
||||||
|
|
||||||
const char* filename;
|
const char* filename = nullptr;
|
||||||
int first_line, last_line;
|
int first_line = 0, last_line = 0;
|
||||||
int first_column, last_column;
|
int first_column = 0, last_column = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define YYLTYPE yyltype
|
#define YYLTYPE yyltype
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue