Skip to content

Commit 21c6076

Browse files
committed
generic: clang-tidy warning fixes
1 parent 387d1cf commit 21c6076

File tree

14 files changed

+127
-290
lines changed

14 files changed

+127
-290
lines changed

source/citnames/config.json

Lines changed: 0 additions & 77 deletions
This file was deleted.

source/citnames/source/semantic/ToolExtendingWrapper.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace cs {
3737
rust::Result<cs::semantic::SemanticPtrs> semantic::ToolExtendingWrapper::compilations(const report::Command &command) const {
3838
return ToolGcc().compilations(command)
3939
.map<cs::semantic::SemanticPtrs>([this](auto semantics) {
40-
for (auto semantic : semantics) {
40+
for (auto& semantic : semantics) {
4141
semantic->extend_flags(compilers_to_recognize_.additional_flags);
4242
}
4343
return semantics;

source/intercept-library/library/source/Array.h

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -21,78 +21,76 @@
2121

2222
#include <cstddef>
2323

24-
namespace el {
25-
namespace array {
24+
namespace el::array {
2625

27-
/**
28-
* Return a pointer to the last element of a nullptr terminated array.
29-
*
30-
* @param it the input array to count,
31-
* @return the pointer which points the nullptr.
32-
*/
33-
template <typename T>
34-
constexpr T* end(T* it) noexcept
35-
{
36-
if (it == nullptr)
37-
return nullptr;
26+
/**
27+
* Return a pointer to the last element of a nullptr terminated array.
28+
*
29+
* @param it the input array to count,
30+
* @return the pointer which points the nullptr.
31+
*/
32+
template <typename T>
33+
constexpr T* end(T* it) noexcept
34+
{
35+
if (it == nullptr)
36+
return nullptr;
3837

39-
while (*it != 0)
40-
++it;
41-
return it;
42-
}
38+
while (*it != 0)
39+
++it;
40+
return it;
41+
}
4342

44-
/**
45-
* Return the size of a nullptr terminated array.
46-
*
47-
* @param begin the input array to count,
48-
* @return the size of the array.
49-
*/
50-
template <typename T>
51-
constexpr size_t length(T* const begin) noexcept
52-
{
53-
return end(begin) - begin;
54-
}
43+
/**
44+
* Return the size of a nullptr terminated array.
45+
*
46+
* @param begin the input array to count,
47+
* @return the size of the array.
48+
*/
49+
template <typename T>
50+
constexpr size_t length(T* const begin) noexcept
51+
{
52+
return end(begin) - begin;
53+
}
5554

56-
/**
57-
* Re-implementation of std::copy to avoid `memmove` symbol.
58-
*
59-
* @tparam I input type
60-
* @tparam O output type
61-
* @param src_begin
62-
* @param src_end
63-
* @param dst_begin
64-
* @param dst_end
65-
* @return output iterator to the last copied element.
66-
*/
67-
template <typename I, typename O>
68-
constexpr O* copy(I* const src_begin, I* const src_end,
69-
O* const dst_begin, O* const dst_end) noexcept
70-
{
71-
auto src_it = src_begin;
72-
auto dst_it = dst_begin;
73-
for (; src_it != src_end && dst_it != dst_end;)
74-
*dst_it++ = *src_it++;
55+
/**
56+
* Re-implementation of std::copy to avoid `memmove` symbol.
57+
*
58+
* @tparam I input type
59+
* @tparam O output type
60+
* @param src_begin
61+
* @param src_end
62+
* @param dst_begin
63+
* @param dst_end
64+
* @return output iterator to the last copied element.
65+
*/
66+
template <typename I, typename O>
67+
constexpr O* copy(I* const src_begin, I* const src_end,
68+
O* const dst_begin, O* const dst_end) noexcept
69+
{
70+
auto src_it = src_begin;
71+
auto dst_it = dst_begin;
72+
for (; src_it != src_end && dst_it != dst_end;)
73+
*dst_it++ = *src_it++;
7574

76-
return (src_it == src_end) ? dst_it : nullptr;
77-
}
75+
return (src_it == src_end) ? dst_it : nullptr;
76+
}
7877

79-
/**
80-
* Check if two nullptr terminated array is equal till the limit.
81-
*
82-
* @tparam T
83-
* @param lhs
84-
* @param rhs
85-
* @param length
86-
* @return true if the two array is equal till the limit.
87-
*/
88-
template <typename T>
89-
constexpr bool equal_n(T* const lhs, T* const rhs, const size_t length) noexcept
90-
{
91-
for (size_t idx = 0; idx < length; ++idx) {
92-
if (lhs[idx] != rhs[idx])
93-
return false;
94-
}
95-
return true;
78+
/**
79+
* Check if two nullptr terminated array is equal till the limit.
80+
*
81+
* @tparam T
82+
* @param lhs
83+
* @param rhs
84+
* @param length
85+
* @return true if the two array is equal till the limit.
86+
*/
87+
template <typename T>
88+
constexpr bool equal_n(T* const lhs, T* const rhs, const size_t length) noexcept
89+
{
90+
for (size_t idx = 0; idx < length; ++idx) {
91+
if (lhs[idx] != rhs[idx])
92+
return false;
9693
}
94+
return true;
9795
}
9896
}

source/intercept-library/library/source/Executor.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ namespace {
4949

5050
#define CHECK_SESSION(SESSION_) \
5151
do { \
52-
if (!el::session::is_valid(SESSION_)) { \
52+
if (!el::session::is_valid(SESSION_)) { \
5353
LOGGER.warning("session is not initialized"); \
5454
return failure(EIO); \
5555
} \
5656
} while (false)
5757

5858
#define CHECK_POINTER(PTR_) \
5959
do { \
60-
if (nullptr == PTR_) { \
60+
if (nullptr == (PTR_)) { \
6161
LOGGER.debug("null pointer received"); \
6262
return failure(EFAULT); \
6363
} \

source/intercept-library/library/source/Logger.h

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,33 @@
1919

2020
#pragma once
2121

22-
namespace el {
22+
namespace el::log {
2323

24-
namespace log {
24+
enum Level {
25+
SILENT = 0,
26+
VERBOSE = 1
27+
};
2528

26-
enum Level {
27-
SILENT = 0,
28-
VERBOSE = 1
29-
};
29+
// Not MT safe
30+
void set(Level);
3031

31-
// Not MT safe
32-
void set(Level);
32+
class Logger {
33+
public:
34+
constexpr explicit Logger(const char *name) noexcept;
3335

34-
class Logger {
35-
public:
36-
constexpr explicit Logger(const char *name) noexcept;
36+
~Logger() noexcept = default;
3737

38-
~Logger() noexcept = default;
38+
void debug(char const *message) const noexcept;
39+
void debug(char const *message, char const *variable) const noexcept;
3940

40-
void debug(char const* message) const noexcept;
41-
void debug(char const* message, char const* variable) const noexcept;
41+
void warning(char const *message) const noexcept;
4242

43-
void warning(char const* message) const noexcept;
43+
private:
44+
const char *name_;
45+
};
4446

45-
private:
46-
const char* name_;
47-
};
48-
49-
inline constexpr
50-
Logger::Logger(const char* name) noexcept
51-
: name_(name)
52-
{
53-
}
54-
}
47+
inline constexpr
48+
Logger::Logger(const char *name) noexcept
49+
: name_(name)
50+
{ }
5551
}

source/intercept-library/library/source/Resolver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ namespace el {
5656

5757
virtual size_t confstr(int name, char* buf, size_t len) const noexcept;
5858

59-
virtual const char** environment() const noexcept;
59+
[[nodiscard]] virtual const char** environment() const noexcept;
6060

61-
virtual int error_code() const noexcept;
61+
[[nodiscard]] virtual int error_code() const noexcept;
6262
};
6363
}

source/intercept-library/library/source/Session.cc

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,30 @@
2323
#include "Environment.h"
2424
#include "libexec/Environment.h"
2525

26-
namespace el {
27-
28-
namespace session {
29-
30-
void from(Session& session, const char** environment) noexcept
31-
{
32-
if (nullptr == environment)
33-
return;
34-
35-
session.reporter = env::get_env_value(environment, env::KEY_REPORTER);
36-
session.destination = env::get_env_value(environment, env::KEY_DESTINATION);
37-
session.verbose = env::get_env_value(environment, env::KEY_VERBOSE) != nullptr;
38-
}
39-
40-
void persist(Session& session, char* begin, char* end) noexcept
41-
{
42-
if (!is_valid(session))
43-
return;
44-
45-
Buffer buffer(begin, end);
46-
session.reporter = buffer.store(session.reporter);
47-
session.destination = buffer.store(session.destination);
48-
}
49-
50-
bool is_valid(Session const& session) noexcept
51-
{
52-
return (session.reporter != nullptr && session.destination != nullptr);
53-
}
26+
namespace el::session {
27+
28+
void from(Session &session, const char **environment) noexcept
29+
{
30+
if (nullptr == environment)
31+
return;
32+
33+
session.reporter = env::get_env_value(environment, env::KEY_REPORTER);
34+
session.destination = env::get_env_value(environment, env::KEY_DESTINATION);
35+
session.verbose = env::get_env_value(environment, env::KEY_VERBOSE) != nullptr;
36+
}
37+
38+
void persist(Session &session, char *begin, char *end) noexcept
39+
{
40+
if (!is_valid(session))
41+
return;
42+
43+
Buffer buffer(begin, end);
44+
session.reporter = buffer.store(session.reporter);
45+
session.destination = buffer.store(session.destination);
46+
}
47+
48+
bool is_valid(Session const &session) noexcept
49+
{
50+
return (session.reporter != nullptr && session.destination != nullptr);
5451
}
5552
}

0 commit comments

Comments
 (0)