Skip to content

Commit

Permalink
Update the clang-format setting (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui authored Jun 14, 2022
1 parent 5e88baa commit 772203f
Show file tree
Hide file tree
Showing 39 changed files with 196 additions and 182 deletions.
4 changes: 3 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
BasedOnStyle: LLVM
AlignAfterOpenBracket: BlockIndent
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignOperands: Align
AlignTrailingComments: false
AlwaysBreakAfterReturnType: All
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBinaryOperators: NonAssignment
BreakStringLiterals: false
IncludeBlocks: Regroup
IndentCaseLabels: true
Expand Down
12 changes: 6 additions & 6 deletions include/poac/core/builder/ninja/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
// external
#include <ninja/build.h> // BuildConfig // NOLINT(build/include_order)
#include <ninja/build_log.h> // BuildLog, BuildLogUser // NOLINT(build/include_order)
#include <ninja/deps_log.h> // DepsLog // NOLINT(build/include_order)
#include <ninja/deps_log.h> // DepsLog // NOLINT(build/include_order)
#include <ninja/disk_interface.h> // RealDiskInterface // NOLINT(build/include_order)
#include <ninja/graph.h> // Node // NOLINT(build/include_order)
#include <ninja/metrics.h> // GetTimeMillis // NOLINT(build/include_order)
#include <ninja/state.h> // State // NOLINT(build/include_order)
#include <ninja/graph.h> // Node // NOLINT(build/include_order)
#include <ninja/metrics.h> // GetTimeMillis // NOLINT(build/include_order)
#include <ninja/state.h> // State // NOLINT(build/include_order)
#include <ninja/string_piece.h> // StringPiece // NOLINT(build/include_order)
#include <ninja/timestamp.h> // TimeStamp // NOLINT(build/include_order)
#include <spdlog/spdlog.h> // spdlog::error // NOLINT(build/include_order)
#include <ninja/timestamp.h> // TimeStamp // NOLINT(build/include_order)
#include <spdlog/spdlog.h> // spdlog::error // NOLINT(build/include_order)

// internal
#include "poac/poac.hpp"
Expand Down
4 changes: 2 additions & 2 deletions include/poac/core/builder/ninja/manifest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ is_outdated(const Path& build_dir) {
return true;
}
using poac::data::manifest::poac_toml_last_modified;
return ninja_manifest_last_modified(build_dir) <
poac_toml_last_modified(config::path::cur_dir);
return ninja_manifest_last_modified(build_dir)
< poac_toml_last_modified(config::path::cur_dir);
}

bool
Expand Down
4 changes: 2 additions & 2 deletions include/poac/core/resolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ using Unknown = Error<"unknown error occurred: {}", String>;

inline String
get_install_name(const resolve::Package& package) {
return boost::replace_first_copy(package.name, "/", "-") + "-" +
package.version_rq;
return boost::replace_first_copy(package.name, "/", "-") + "-"
+ package.version_rq;
}

inline Path
Expand Down
18 changes: 13 additions & 5 deletions include/poac/core/resolver/resolve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,19 @@ bool
duplicate_loose(const SinglePassRange& rng) {
const auto first = std::begin(rng);
const auto last = std::end(rng);
return std::find_if(first, last, [&](const auto& x) {
return std::count_if(first, last, [&](const auto& y) {
return get_package(x).name == get_package(y).name;
}) > 1;
}) != last;
return std::find_if(
first, last,
[&](const auto& x) {
return std::count_if(
first, last,
[&](const auto& y) {
return get_package(x).name == get_package(y).name;
}
)
> 1;
}
)
!= last;
}

// Interval to multiple versions
Expand Down
4 changes: 2 additions & 2 deletions include/poac/core/resolver/sat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
namespace poac::core::resolver::sat {

enum class Status {
satisfied, // found a satisfying assignment
satisfied, // found a satisfying assignment
unsatisfied, // found no satisfying assignment
normal, // Successful completion OR unsolved
normal, // Successful completion OR unsolved
};

Vec<i32>
Expand Down
4 changes: 2 additions & 2 deletions include/poac/data/lockfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ is_outdated(const Path& base_dir) {
if (!fs::exists(base_dir / lockfile_name)) {
return true;
}
return poac_lock_last_modified(base_dir) <
manifest::poac_toml_last_modified(base_dir);
return poac_lock_last_modified(base_dir)
< manifest::poac_toml_last_modified(base_dir);
}

} // namespace poac::data::lockfile
Expand Down
4 changes: 2 additions & 2 deletions include/poac/poac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <cstdint>
#include <filesystem>
#include <functional> // std::equal_to
#include <iterator> // std::begin, std::end
#include <iterator> // std::begin, std::end
#include <map>
#include <memory>
#include <optional>
Expand All @@ -20,7 +20,7 @@

// external
#include <boost/container_hash/hash.hpp>
#include <fmt/core.h> // NOLINT(build/include_order)
#include <fmt/core.h> // NOLINT(build/include_order)
#include <fmt/format.h> // NOLINT(build/include_order)
#include <fmt/ranges.h> // fmt::join // NOLINT(build/include_order)
#include <mitama/anyhow/anyhow.hpp>
Expand Down
6 changes: 3 additions & 3 deletions include/poac/util/archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>

// external
#include <archive.h> // NOLINT(build/include_order)
#include <archive.h> // NOLINT(build/include_order)
#include <archive_entry.h> // NOLINT(build/include_order)

// internal
Expand Down Expand Up @@ -63,8 +63,8 @@ inline i32
make_flags() noexcept {
// Select which attributes we want to restore.
// int
return ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_UNLINK |
ARCHIVE_EXTRACT_SECURE_NODOTDOT;
return ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_UNLINK
| ARCHIVE_EXTRACT_SECURE_NODOTDOT;
}

inline void
Expand Down
52 changes: 26 additions & 26 deletions include/poac/util/cfg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ struct ident_error : public cfg::exception {
public:
explicit ident_error(const String& what_)
: exception(
"cfg expected parenthesis, comma, identifier, or string\n" + what_
) {}
"cfg expected parenthesis, comma, identifier, or string\n" + what_
) {}
explicit ident_error(const char* what_) : ident_error(String(what_)) {}
~ident_error() noexcept override = default;

Expand Down Expand Up @@ -160,24 +160,24 @@ struct Token {

explicit Token(Kind k)
: kind(
k != Kind::String && k != Kind::Ident
? k
: throw std::invalid_argument("poac::util::cfg::Token")
),
k != Kind::String && k != Kind::Ident
? k
: throw std::invalid_argument("poac::util::cfg::Token")
),
value() {}
Token(Kind k, string_type s)
: kind(
k == Kind::String
? k
: throw std::invalid_argument("poac::util::cfg::Token")
),
k == Kind::String
? k
: throw std::invalid_argument("poac::util::cfg::Token")
),
value(s) {}
Token(Kind k, ident i)
: kind(
k == Kind::Ident
? k
: throw std::invalid_argument("poac::util::cfg::Token")
),
k == Kind::Ident
? k
: throw std::invalid_argument("poac::util::cfg::Token")
),
value(i) {}

// clang-format off
Expand Down Expand Up @@ -360,24 +360,24 @@ struct CfgExpr {

CfgExpr(Kind kind, expr_type&& expr)
: kind(
kind == Kind::not_ || kind == Kind::cfg
? kind
: throw std::invalid_argument("poac::util::cfg::CfgExpr")
),
kind == Kind::not_ || kind == Kind::cfg
? kind
: throw std::invalid_argument("poac::util::cfg::CfgExpr")
),
expr(std::move(expr)) {}
CfgExpr(Kind kind, expr_list_type&& expr)
: kind(
kind == Kind::all || kind == Kind::any
? kind
: throw std::invalid_argument("poac::util::cfg::CfgExpr")
),
kind == Kind::all || kind == Kind::any
? kind
: throw std::invalid_argument("poac::util::cfg::CfgExpr")
),
expr(std::move(expr)) {}
CfgExpr(Kind kind, const Cfg& c)
: kind(
kind == Kind::value
? kind
: throw std::invalid_argument("poac::util::cfg::CfgExpr")
),
kind == Kind::value
? kind
: throw std::invalid_argument("poac::util::cfg::CfgExpr")
),
expr(c) {}

// clang-format off
Expand Down
4 changes: 2 additions & 2 deletions include/poac/util/lev_distance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

// std
#include <algorithm> // std::min, std::equal
#include <locale> // std::tolower
#include <span> // NOLINT(build/include_order)
#include <locale> // std::tolower
#include <span> // NOLINT(build/include_order)

// internal
#include "poac/poac.hpp"
Expand Down
4 changes: 2 additions & 2 deletions include/poac/util/semver/comparison.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace detail {

inline bool
operator==(const Version& lhs, const Version& rhs) {
return lhs.major == rhs.major && lhs.minor == rhs.minor &&
lhs.patch == rhs.patch && detail::eq_pre(lhs, rhs);
return lhs.major == rhs.major && lhs.minor == rhs.minor
&& lhs.patch == rhs.patch && detail::eq_pre(lhs, rhs);
}
inline bool
operator==(const Version& lhs, const std::string& rhs) {
Expand Down
12 changes: 6 additions & 6 deletions include/poac/util/semver/interval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ inline const std::string NON_NUMERIC_IDENTIFIER =

// ## Main Version
// Three dot-separated numeric identifiers.
inline const std::string MAIN_VERSION = "(" + NUMERIC_IDENTIFIER + R"()\.)" +
"(" + NUMERIC_IDENTIFIER + R"()\.)" +
"(" + NUMERIC_IDENTIFIER + ")";
inline const std::string MAIN_VERSION = "(" + NUMERIC_IDENTIFIER + R"()\.)"
+ "(" + NUMERIC_IDENTIFIER + R"()\.)"
+ "(" + NUMERIC_IDENTIFIER + ")";

// ## Pre-release Version Identifier
// A numeric identifier, or a non-numeric identifier.
Expand All @@ -174,9 +174,9 @@ inline const std::string PRE_RELEASE_IDENTIFIER =
// ## Pre-release Version
// Hyphen, followed by one or more dot-separated pre-release version
// identifiers.
inline const std::string PRE_RELEASE = "(?:-(" + PRE_RELEASE_IDENTIFIER +
R"((?:\.)" + PRE_RELEASE_IDENTIFIER +
")*))";
inline const std::string PRE_RELEASE = "(?:-(" + PRE_RELEASE_IDENTIFIER
+ R"((?:\.)" + PRE_RELEASE_IDENTIFIER
+ ")*))";

// ## Build Metadata Identifier
// Any combination of digits, letters, or hyphens.
Expand Down
8 changes: 4 additions & 4 deletions include/poac/util/semver/range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ struct Op {

constexpr explicit Op(Kind k)
: kind(
k == Kind::Wildcard ? throw std::invalid_argument("semver::Op") : k
),
k == Kind::Wildcard ? throw std::invalid_argument("semver::Op") : k
),
component() {}

constexpr Op(Kind k, WildcardVersion wv)
: kind(
k != Kind::Wildcard ? throw std::invalid_argument("semver::Op") : k
),
k != Kind::Wildcard ? throw std::invalid_argument("semver::Op") : k
),
component(wv) {}
};

Expand Down
42 changes: 20 additions & 22 deletions include/poac/util/semver/token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,23 @@ struct Token {

constexpr Token(Kind k, const std::size_t& s1, const std::size_t& s2)
: kind(
k != Kind::Whitespace ? throw std::invalid_argument("semver::Token")
: Kind::Whitespace
),
k != Kind::Whitespace ? throw std::invalid_argument("semver::Token")
: Kind::Whitespace
),
component(std::make_pair(s1, s2)) {}

constexpr Token(Kind k, const numeric_type& n)
: kind(
k != Kind::Numeric ? throw std::invalid_argument("semver::Token")
: Kind::Numeric
),
k != Kind::Numeric ? throw std::invalid_argument("semver::Token")
: Kind::Numeric
),
component(n) {}

constexpr Token(Kind k, alphanumeric_type c)
: kind(
k != Kind::AlphaNumeric
? throw std::invalid_argument("semver::Token")
: Kind::AlphaNumeric
),
k != Kind::AlphaNumeric ? throw std::invalid_argument("semver::Token")
: Kind::AlphaNumeric
),
component(c) {}

Token(const Token&) = default;
Expand All @@ -106,10 +105,10 @@ struct Token {

constexpr bool
is_wildcard() const noexcept {
return kind == Kind::Star ||
(std::holds_alternative<alphanumeric_type>(component) &&
(std::get<alphanumeric_type>(component) == "X" ||
std::get<alphanumeric_type>(component) == "x"));
return kind == Kind::Star
|| (std::holds_alternative<alphanumeric_type>(component)
&& (std::get<alphanumeric_type>(component) == "X"
|| std::get<alphanumeric_type>(component) == "x"));
}
};

Expand Down Expand Up @@ -168,18 +167,17 @@ struct Identifier {

constexpr Identifier(Kind k, const numeric_type& n)
: kind(
k != Kind::Numeric
? throw std::invalid_argument("semver::Identifier")
: Kind::Numeric
),
k != Kind::Numeric ? throw std::invalid_argument("semver::Identifier")
: Kind::Numeric
),
component(n) {}

constexpr Identifier(Kind k, alphanumeric_type c)
: kind(
k != Kind::AlphaNumeric
? throw std::invalid_argument("semver::Identifier")
: Kind::AlphaNumeric
),
k != Kind::AlphaNumeric
? throw std::invalid_argument("semver::Identifier")
: Kind::AlphaNumeric
),
component(c) {}

constexpr bool
Expand Down
2 changes: 1 addition & 1 deletion include/poac/util/termcolor2/literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// std
#include <cstddef> // std::size_t
#include <string> // std::basic_string
#include <string> // std::basic_string

// internal
#include "poac/util/termcolor2/to_color.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/poac/util/termcolor2/literals_extra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// std
#include <cstddef> // std::size_t
#include <string> // std::basic_string
#include <string> // std::basic_string

// internal
#include "poac/util/termcolor2/to_color_extra.hpp"
Expand Down
4 changes: 2 additions & 2 deletions include/poac/util/termcolor2/to_color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define POAC_UTIL_TERMCOLOR2_TO_COLOR_HPP_

// std
#include <cstddef> // std::size_t
#include <string> // std::basic_string
#include <cstddef> // std::size_t
#include <string> // std::basic_string
#include <string_view> // std::basic_string_view

// internal
Expand Down
Loading

0 comments on commit 772203f

Please sign in to comment.