Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Clang-tidy fixes for files relevant to TDFA determinization. #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/log_surgeon/Lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstdint>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
Expand Down
2 changes: 2 additions & 0 deletions src/log_surgeon/LexicalRule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#define LOG_SURGEON_LEXICAL_RULE_HPP
#include <cstdint>
#include <memory>
#include <vector>

#include <log_surgeon/finite_automata/Capture.hpp>
#include <log_surgeon/finite_automata/RegexAST.hpp>

namespace log_surgeon {
Expand Down
9 changes: 8 additions & 1 deletion src/log_surgeon/SchemaParser.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#include "SchemaParser.hpp"

#include <cerrno>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>

#include <log_surgeon/Constants.hpp>
#include <log_surgeon/FileReader.hpp>
#include <log_surgeon/finite_automata/Capture.hpp>
#include <log_surgeon/finite_automata/NfaState.hpp>
#include <log_surgeon/finite_automata/RegexAST.hpp>
#include <log_surgeon/Lalr1Parser.hpp>
#include <log_surgeon/Lexer.hpp>
#include <log_surgeon/Reader.hpp>
#include <log_surgeon/utils.hpp>

using ParserValueRegex = log_surgeon::ParserValue<std::unique_ptr<
Expand Down
8 changes: 4 additions & 4 deletions src/log_surgeon/finite_automata/DfaStatePair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ auto DfaStatePair<TypedDfaState>::get_reachable_pairs(
) const -> void {
// TODO: Handle UTF-8 (multi-byte transitions) as well
for (uint32_t i = 0; i < cSizeOfByte; i++) {
auto next_state1 = m_state1->next(i);
auto next_state2 = m_state2->next(i);
if (next_state1 != nullptr && next_state2 != nullptr) {
auto next_state1{m_state1->next(i)};
auto next_state2{m_state2->next(i)};
if (nullptr != next_state1 && nullptr != next_state2) {
DfaStatePair const reachable_pair{next_state1, next_state2};
if (visited_pairs.count(reachable_pair) == 0) {
if (false == visited_pairs.contains(reachable_pair)) {
unvisited_pairs.insert(reachable_pair);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/log_surgeon/finite_automata/Nfa.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef LOG_SURGEON_FINITE_AUTOMATA_NFA_HPP
#define LOG_SURGEON_FINITE_AUTOMATA_NFA_HPP

#include <cstddef>
#include <cstdint>
#include <memory>
#include <optional>
Expand Down Expand Up @@ -86,7 +87,7 @@ class Nfa {

auto set_root(TypedNfaState* root) -> void { m_root = root; }

auto get_root() -> TypedNfaState* { return m_root; }
auto get_root() const -> TypedNfaState* { return m_root; }

[[nodiscard]] auto get_capture_to_tag_id_pair(
) const -> std::unordered_map<Capture const*, std::pair<tag_id_t, tag_id_t>> const& {
Expand Down
2 changes: 1 addition & 1 deletion tests/test-register-handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST_CASE("`RegisterHandler` tests", "[RegisterHandler]") {
constexpr size_t cRegId2{1};

SECTION("Initial state is empty") {
RegisterHandler empty_handler{handler_init(0)};
RegisterHandler const empty_handler{handler_init(0)};
REQUIRE_THROWS_AS(empty_handler.get_reversed_positions(cRegId1), std::out_of_range);
}

Expand Down
Loading