diff --git a/src/Debug.cc b/src/Debug.cc index b80fb2dbd1..ee0057f8f9 100644 --- a/src/Debug.cc +++ b/src/Debug.cc @@ -84,8 +84,7 @@ bool StmtLocMapping::StartsAfter(const StmtLocMapping* m2) { if ( ! m2 ) reporter->InternalError("Assertion failed: m2 != 0"); - return loc.FirstLine() > m2->loc.FirstLine() || - (loc.FirstLine() == m2->loc.FirstLine() && loc.FirstColumn() > m2->loc.FirstColumn()); + return loc.FirstLine() > m2->loc.FirstLine(); } // Generic debug message output. diff --git a/src/Obj.cc b/src/Obj.cc index da4aa0f747..5e11528e30 100644 --- a/src/Obj.cc +++ b/src/Obj.cc @@ -12,8 +12,8 @@ namespace zeek { namespace detail { -Location start_location("", 0, 0, 0, 0); -Location end_location("", 0, 0, 0, 0); +Location start_location("", 0, 0); +Location end_location("", 0, 0); void Location::Describe(ODesc* d) const { if ( FileName() ) { @@ -132,8 +132,7 @@ bool Obj::SetLocationInfo(const detail::Location* start, const detail::Location* // We already have a better location, so don't use this one. return true; - auto new_location = new detail::Location(start->FileName(), start->FirstLine(), end->LastLine(), - start->FirstColumn(), end->LastColumn()); + auto new_location = new detail::Location(start->FileName(), start->FirstLine(), end->LastLine()); // Don't delete this until we've constructed the new location, in case // "start" or "end" are our own location. @@ -148,7 +147,6 @@ void Obj::UpdateLocationEndInfo(const detail::Location& end) { SetLocationInfo(&end, &end); location->SetLastLine(end.LastLine()); - location->SetLastColumn(end.LastColumn()); } void Obj::DoMsg(ODesc* d, const char s1[], const Obj* obj2, bool pinpoint_only, diff --git a/src/Obj.h b/src/Obj.h index 392965d7ad..89e846e266 100644 --- a/src/Obj.h +++ b/src/Obj.h @@ -13,8 +13,7 @@ namespace detail { class Location final { public: - constexpr Location(const char* fname, int line_f, int line_l, int col_f, int col_l) noexcept - : filename(fname), first_column(col_f), last_column(col_l) { + constexpr Location(const char* fname, int line_f, int line_l) noexcept : filename(fname) { SetLines(line_f, line_l); } @@ -29,10 +28,6 @@ public: int FirstLine() const { return first_line; } int LastLine() const { return last_line; } - // Columns are actually not currently maintained. - auto FirstColumn() const { return first_column; } - auto LastColumn() const { return last_column; } - void SetFile(const char* fname) { filename = fname; } void SetLine(int line) { SetLines(line, line); } constexpr void SetLines(int first, int last) { @@ -53,14 +48,9 @@ public: last_line += incr; } - void SetFirstColumn(int col) { first_column = col; } - void SetLastColumn(int col) { last_column = col; } - - private: const char* filename = nullptr; int first_line = 0, last_line = 0; - int first_column = 0, last_column = 0; // not currently maintained }; #define YYLTYPE zeek::detail::yyltype @@ -69,7 +59,7 @@ YYLTYPE GetCurrentLocation(); void SetCurrentLocation(YYLTYPE currloc); // Used to mean "no location associated with this object". -inline constexpr Location no_location("", 0, 0, 0, 0); +inline constexpr Location no_location("", 0, 0); // Current start/end location. extern Location start_location; diff --git a/src/Type.cc b/src/Type.cc index cc0842bba9..f1e4660cb0 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -2626,7 +2626,7 @@ const TypePtr& base_type(TypeTag tag) { if ( ! base_types[tag] ) { base_types[tag] = make_intrusive(tag, true); // Give the base types a pseudo-location for easier identification. - detail::Location l(type_name(tag), 0, 0, 0, 0); + detail::Location l(type_name(tag), 0, 0); base_types[tag]->SetLocationInfo(&l); } diff --git a/src/rule-parse.y b/src/rule-parse.y index 26d71fec7b..bb0fd0c105 100644 --- a/src/rule-parse.y +++ b/src/rule-parse.y @@ -108,7 +108,7 @@ rule_list: rule: TOK_SIGNATURE TOK_IDENT { - zeek::detail::Location l(current_rule_file, rules_line_number+1, 0, 0, 0); + zeek::detail::Location l(current_rule_file, rules_line_number+1, 0); current_rule = new zeek::detail::Rule(yylval.str, l); } '{' rule_attr_list '}' diff --git a/src/scan.l b/src/scan.l index 7d89931b90..2e84ebb47d 100644 --- a/src/scan.l +++ b/src/scan.l @@ -53,7 +53,7 @@ using namespace zeek::detail; -extern YYLTYPE yylloc; // holds start line and column of token +extern YYLTYPE yylloc; // holds location of token extern zeek::EnumType* cur_enum_type; // Track the @if... depth. @@ -218,8 +218,6 @@ static int switch_to(const char* file, YY_BUFFER_STATE buffer); // for error reporting and debugging). static zeek::name_list input_files; static zeek::name_list essential_input_files; - -// ### TODO: columns too - use yyless with '.' action? %} %option nounput nodefault diff --git a/src/script_opt/CPP/Func.cc b/src/script_opt/CPP/Func.cc index d04f5df44f..4c83677f76 100644 --- a/src/script_opt/CPP/Func.cc +++ b/src/script_opt/CPP/Func.cc @@ -37,7 +37,7 @@ CPPStmt::CPPStmt(const char* _name, const char* filename, int line_num) : Stmt(S auto empty_args = make_intrusive(); ce = make_intrusive(make_intrusive(fv), empty_args); - Location loc(filename, line_num, line_num, 1, 1); + Location loc(filename, line_num, line_num); ce->SetLocationInfo(&loc); } diff --git a/src/script_opt/CPP/Stmts.cc b/src/script_opt/CPP/Stmts.cc index c07a42bbe1..61b3cde298 100644 --- a/src/script_opt/CPP/Stmts.cc +++ b/src/script_opt/CPP/Stmts.cc @@ -498,8 +498,8 @@ void CPPCompile::GenAssertStmt(const AssertStmt* a) { Emit("auto msg_val = zeek::val_mgr->EmptyString();"); auto loc = a->GetLocationInfo(); - Emit("static Location loc(\"%s\", %s, %s, %s, %s);", loc->FileName(), std::to_string(loc->FirstLine()), - std::to_string(loc->LastLine()), std::to_string(loc->FirstColumn()), std::to_string(loc->LastColumn())); + Emit("static Location loc(\"%s\", %s, %s);", loc->FileName(), std::to_string(loc->FirstLine()), + std::to_string(loc->LastLine())); Emit("report_assert(assert_result, \"%s\", msg_val, &loc);", CPPEscape(a->CondDesc().c_str()).c_str()); EndBlock(); diff --git a/src/script_opt/ZAM/Driver.cc b/src/script_opt/ZAM/Driver.cc index b299b9ee08..1970021a8a 100644 --- a/src/script_opt/ZAM/Driver.cc +++ b/src/script_opt/ZAM/Driver.cc @@ -23,8 +23,7 @@ ZAMCompiler::ZAMCompiler(ScriptFuncPtr f, std::shared_ptr _pfs, st auto loc = body->GetLocationInfo(); ASSERT(loc->FirstLine() != 0 || body->Tag() == STMT_NULL); - auto loc_copy = std::make_shared(loc->FileName(), loc->FirstLine(), loc->LastLine(), loc->FirstColumn(), - loc->LastColumn()); + auto loc_copy = std::make_shared(loc->FileName(), loc->FirstLine(), loc->LastLine()); ZAM::curr_func = func->GetName(); ZAM::curr_loc = std::make_shared(ZAM::curr_func, std::move(loc_copy), nullptr); diff --git a/src/script_opt/ZAM/Stmt.cc b/src/script_opt/ZAM/Stmt.cc index 86b324fe29..8cb29daf21 100644 --- a/src/script_opt/ZAM/Stmt.cc +++ b/src/script_opt/ZAM/Stmt.cc @@ -13,8 +13,7 @@ namespace zeek::detail { const ZAMStmt ZAMCompiler::CompileStmt(const Stmt* s) { auto loc = s->GetLocationInfo(); ASSERT(loc->FirstLine() != 0 || s->Tag() == STMT_NULL); - auto loc_copy = std::make_shared(loc->FileName(), loc->FirstLine(), loc->LastLine(), loc->FirstColumn(), - loc->LastColumn()); + auto loc_copy = std::make_shared(loc->FileName(), loc->FirstLine(), loc->LastLine()); ASSERT(! AST_blocks || s->Tag() == STMT_NULL || AST_blocks->HaveExpDesc(loc_copy.get())); auto loc_parent = ZAM::curr_loc->Parent(); ZAM::curr_loc = std::make_shared(ZAM::curr_func, std::move(loc_copy), ZAM::curr_loc->Parent()); diff --git a/src/spicy/manager.cc b/src/spicy/manager.cc index e5e1ead2ca..d28e811559 100644 --- a/src/spicy/manager.cc +++ b/src/spicy/manager.cc @@ -859,7 +859,7 @@ void Manager::searchModules(const std::string& paths) { detail::Location Manager::makeLocation(const std::string& fname) { auto x = _locations.insert(fname); - return {x.first->c_str(), 0, 0, 0, 0}; + return {x.first->c_str(), 0, 0}; } void Manager::autoDiscoverModules() {