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

tidy: Fix clang-tidy-17 warnings #2284

Merged
merged 1 commit into from
Oct 27, 2023
Merged
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
14 changes: 6 additions & 8 deletions src/common/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

#include "common/exception/internal.h"
#include "common/string_format.h"
#include "common/utils.h"

namespace kuzu {
namespace common {

void kuAssertInternal(bool condition, const char* condition_name, const char* file, int linenr) {
if (!condition) {
// LCOV_EXCL_START
throw InternalException(stringFormat(
"Assertion triggered in file \"{}\" on line {}: {}", file, linenr, condition_name));
// LCOV_EXCL_END
}
[[noreturn]] void kuAssertFailureInternal(

Check warning on line 9 in src/common/assert.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/assert.cpp#L9

Added line #L9 was not covered by tests
const char* condition_name, const char* file, int linenr) {
// LCOV_EXCL_START
throw InternalException(stringFormat(
"Assertion failed in file \"{}\" on line {}: {}", file, linenr, condition_name));
// LCOV_EXCL_END
}

} // namespace common
Expand Down
3 changes: 3 additions & 0 deletions src/common/types/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,9 @@ std::vector<std::string> LogicalTypeUtils::parseStructFields(const std::string&
startPos = curPos + 1;
}
} break;
default: {
// Normal character, continue.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use continue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because it's important that curPos++ (below) is run.

}
}
curPos++;
}
Expand Down
7 changes: 5 additions & 2 deletions src/include/common/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace kuzu {
namespace common {
void kuAssertInternal(bool condition, const char* condition_name, const char* file, int linenr);
[[noreturn]] void kuAssertFailureInternal(const char* condition_name, const char* file, int linenr);

#define KU_ASSERT(condition) \
kuzu::common::kuAssertInternal(bool(condition), #condition, __FILE__, __LINE__)
if (!(condition)) { \
[[unlikely]] kuzu::common::kuAssertFailureInternal(#condition, __FILE__, __LINE__); \
}

} // namespace common
} // namespace kuzu
25 changes: 11 additions & 14 deletions src/include/processor/operator/persistent/delete_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace processor {

class NodeDeleteExecutor {
public:
NodeDeleteExecutor(const DataPos& nodeIDPos) : nodeIDPos{nodeIDPos} {}
NodeDeleteExecutor(const DataPos& nodeIDPos) : nodeIDPos{nodeIDPos}, nodeIDVector(nullptr) {}
virtual ~NodeDeleteExecutor() = default;

virtual void init(ResultSet* resultSet, ExecutionContext* context);
Expand Down Expand Up @@ -67,7 +67,8 @@ class RelDeleteExecutor {
public:
RelDeleteExecutor(
const DataPos& srcNodeIDPos, const DataPos& dstNodeIDPos, const DataPos& relIDPos)
: srcNodeIDPos{srcNodeIDPos}, dstNodeIDPos{dstNodeIDPos}, relIDPos{relIDPos} {}
: srcNodeIDPos{srcNodeIDPos}, dstNodeIDPos{dstNodeIDPos}, relIDPos{relIDPos},
srcNodeIDVector(nullptr), dstNodeIDVector(nullptr), relIDVector(nullptr) {}
virtual ~RelDeleteExecutor() = default;

void init(ResultSet* resultSet, ExecutionContext* context);
Expand All @@ -86,19 +87,17 @@ class RelDeleteExecutor {
common::ValueVector* relIDVector;
};

class SingleLabelRelDeleteExecutor : public RelDeleteExecutor {
class SingleLabelRelDeleteExecutor final : public RelDeleteExecutor {
public:
SingleLabelRelDeleteExecutor(storage::RelsStoreStats* relsStatistic, storage::RelTable* table,
const DataPos& srcNodeIDPos, const DataPos& dstNodeIDPos, const DataPos& relIDPos)
: RelDeleteExecutor(srcNodeIDPos, dstNodeIDPos, relIDPos),
relsStatistic{relsStatistic}, table{table} {}
SingleLabelRelDeleteExecutor(const SingleLabelRelDeleteExecutor& other)
: RelDeleteExecutor(other.srcNodeIDPos, other.dstNodeIDPos, other.relIDPos),
relsStatistic{other.relsStatistic}, table{other.table} {}
SingleLabelRelDeleteExecutor(const SingleLabelRelDeleteExecutor& other) = default;

void delete_() final;
void delete_();

inline std::unique_ptr<RelDeleteExecutor> copy() const final {
inline std::unique_ptr<RelDeleteExecutor> copy() const {
return std::make_unique<SingleLabelRelDeleteExecutor>(*this);
}

Expand All @@ -107,7 +106,7 @@ class SingleLabelRelDeleteExecutor : public RelDeleteExecutor {
storage::RelTable* table;
};

class MultiLabelRelDeleteExecutor : public RelDeleteExecutor {
class MultiLabelRelDeleteExecutor final : public RelDeleteExecutor {
using rel_table_statistic_pair = std::pair<storage::RelTable*, storage::RelsStoreStats*>;

public:
Expand All @@ -116,13 +115,11 @@ class MultiLabelRelDeleteExecutor : public RelDeleteExecutor {
const DataPos& srcNodeIDPos, const DataPos& dstNodeIDPos, const DataPos& relIDPos)
: RelDeleteExecutor(srcNodeIDPos, dstNodeIDPos, relIDPos), tableIDToTableMap{std::move(
tableIDToTableMap)} {}
MultiLabelRelDeleteExecutor(const MultiLabelRelDeleteExecutor& other)
: RelDeleteExecutor(other.srcNodeIDPos, other.dstNodeIDPos, other.relIDPos),
tableIDToTableMap{other.tableIDToTableMap} {}
MultiLabelRelDeleteExecutor(const MultiLabelRelDeleteExecutor& other) = default;

void delete_() final;
void delete_();

inline std::unique_ptr<RelDeleteExecutor> copy() const final {
inline std::unique_ptr<RelDeleteExecutor> copy() const {
return std::make_unique<MultiLabelRelDeleteExecutor>(*this);
}

Expand Down
6 changes: 1 addition & 5 deletions src/parser/query/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
add_subdirectory(reading_clause)

add_library(kuzu_parser_query
OBJECT
single_query.cpp)

set(ALL_OBJECT_FILES
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:kuzu_parser_query>
${ALL_OBJECT_FILES}
PARENT_SCOPE)
Empty file removed src/parser/query/single_query.cpp
Empty file.
5 changes: 3 additions & 2 deletions src/processor/operator/persistent/reader/csv/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ void SniffCSVNameAndTypeDriver::addValue(uint64_t, common::column_id_t, std::str
try {
columnType = LogicalTypeUtils::dataTypeFromString(std::string(value.substr(it + 1)));
columnName = std::string(value.substr(0, it));
} catch (NotImplementedException) {
// Just use the whole name.
} catch (Exception) { // NOLINT(bugprone-empty-catch): This is how we check for a suitable
// datatype name.
// Didn't parse, just use the whole name.
}
}
columns.emplace_back(columnName, columnType);
Expand Down
2 changes: 2 additions & 0 deletions src/processor/result/factorized_table.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "processor/result/factorized_table.h"

#include "common/assert.h"
#include "common/data_chunk/data_chunk_state.h"
#include "common/null_buffer.h"
#include "common/vector/value_vector.h"
Expand Down Expand Up @@ -197,6 +198,7 @@ void FactorizedTable::lookup(std::vector<ValueVector*>& vectors,
uint64_t startPos, uint64_t numTuplesToRead) const {
assert(vectors.size() == colIdxesToScan.size());
auto tuplesToRead = std::make_unique<uint8_t*[]>(tupleIdxesToRead.size());
KU_ASSERT(numTuplesToRead > 0);
for (auto i = 0u; i < numTuplesToRead; i++) {
tuplesToRead[i] = getTuple(tupleIdxesToRead[i + startPos]);
}
Expand Down
5 changes: 5 additions & 0 deletions src/storage/buffer_manager/buffer_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
case PageState::LOCKED: {
continue;
}
default: {

Check warning on line 110 in src/storage/buffer_manager/buffer_manager.cpp

View check run for this annotation

Codecov / codecov/patch

src/storage/buffer_manager/buffer_manager.cpp#L110

Added line #L110 was not covered by tests
// LCOV_EXCL_START
throw NotImplementedException("Invalid PageState in BufferManager::pin!");
// LCOV_EXCL_END
}
}
}
}
Expand Down