Skip to content

Commit

Permalink
format: Cpp11BracedListStyle: false
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Jan 3, 2024
1 parent addd027 commit 8822969
Show file tree
Hide file tree
Showing 37 changed files with 284 additions and 272 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBinaryOperators: NonAssignment
BreakStringLiterals: false
Cpp11BracedListStyle: false
IncludeBlocks: Regroup
IndentCaseLabels: true
IndentPPDirectives: AfterHash
Expand Down
12 changes: 6 additions & 6 deletions src/Algos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ findSimilarStr(StringRef lhs, std::span<const StringRef> candidates) {
if (cur_dist <= max_dist) {
// The first similar string found || More similar string found
if (!similar_str.has_value() || cur_dist < similar_str->second) {
similar_str = {c, cur_dist};
similar_str = { c, cur_dist };
}
}
}
Expand Down Expand Up @@ -193,9 +193,9 @@ void test_levDistance2() {
// https://github.com/llvm/llvm-project/commit/a247ba9d15635d96225ef39c8c150c08f492e70a#diff-fd993637669817b267190e7de029b75af5a0328d43d9b70c2e8dd512512091a2

void test_findSimilarStr() {
constexpr Arr<StringRef, 8> CANDIDATES{"if", "ifdef", "ifndef",
"elif", "else", "endif",
"elifdef", "elifndef"};
constexpr Arr<StringRef, 8> CANDIDATES{
"if", "ifdef", "ifndef", "elif", "else", "endif", "elifdef", "elifndef"
};

ASSERT_EQ(findSimilarStr("id", CANDIDATES), "if"sv);
ASSERT_EQ(findSimilarStr("ifd", CANDIDATES), "if"sv);
Expand All @@ -214,11 +214,11 @@ void test_findSimilarStr() {
}

void test_findSimilarStr2() {
constexpr Arr<StringRef, 2> CANDIDATES{"aaab", "aaabc"};
constexpr Arr<StringRef, 2> CANDIDATES{ "aaab", "aaabc" };
ASSERT_EQ(findSimilarStr("aaaa", CANDIDATES), "aaab"sv);
ASSERT_EQ(findSimilarStr("1111111111", CANDIDATES), None);

constexpr Arr<StringRef, 1> CANDIDATES2{"AAAA"};
constexpr Arr<StringRef, 1> CANDIDATES2{ "AAAA" };
ASSERT_EQ(findSimilarStr("aaaa", CANDIDATES2), "AAAA"sv);
}

Expand Down
46 changes: 23 additions & 23 deletions src/BuildConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,31 +146,31 @@ void BuildConfig::defineSimpleVariable(
const String& name, const String& value,
const OrderedHashSet<String>& dependsOn
) {
defineVariable(name, {value, VarType::Simple}, dependsOn);
defineVariable(name, { value, VarType::Simple }, dependsOn);
}
void BuildConfig::defineCondVariable(
const String& name, const String& value,
const OrderedHashSet<String>& dependsOn
) {
defineVariable(name, {value, VarType::Cond}, dependsOn);
defineVariable(name, { value, VarType::Cond }, dependsOn);
}

void BuildConfig::defineTarget(
String name, const Vec<String>& commands,
const OrderedHashSet<String>& dependsOn
) {
targets[name] = {commands, dependsOn};
targets[name] = { commands, dependsOn };
for (const String& dep : dependsOn) {
// reverse dependency
targetDeps[dep].push_back(name);
}
}

void BuildConfig::setPhony(const OrderedHashSet<String>& dependsOn) {
phony = {{}, dependsOn};
phony = { {}, dependsOn };
}
void BuildConfig::setAll(const OrderedHashSet<String>& dependsOn) {
all = {{}, dependsOn};
all = { {}, dependsOn };
}

static void emitTarget(
Expand Down Expand Up @@ -347,7 +347,7 @@ static String buildCmd(const String& cmd) noexcept {
}

static void defineDirTarget(BuildConfig& config, const Path& directory) {
config.defineTarget(directory, {buildCmd("mkdir -p $@")});
config.defineTarget(directory, { buildCmd("mkdir -p $@") });
}

static String echoCmd(StringRef header, StringRef body) {
Expand Down Expand Up @@ -489,7 +489,7 @@ static BuildConfig configureBuild(const bool isDebug) {

// Build rules
defineDirTarget(config, config.buildOutDir);
config.setAll({config.packageName});
config.setAll({ config.packageName });

const Vec<Path> sourceFilePaths = listSourceFilePaths("src");
OrderedHashSet<String> buildObjTargets;
Expand Down Expand Up @@ -519,7 +519,7 @@ static BuildConfig configureBuild(const bool isDebug) {
}
// Project binary target.
const String mainObjTarget = config.buildOutDir / "main.o";
OrderedHashSet<String> projTargetDeps = {mainObjTarget};
OrderedHashSet<String> projTargetDeps = { mainObjTarget };
collectBinDepObjs(
projTargetDeps, config.targets.at(mainObjTarget).dependsOn, "",
buildObjTargets, config
Expand Down Expand Up @@ -568,7 +568,7 @@ static BuildConfig configureBuild(const bool isDebug) {
);

// Test binary target.
OrderedHashSet<String> testTargetDeps = {testObjTarget};
OrderedHashSet<String> testTargetDeps = { testObjTarget };
collectBinDepObjs(
testTargetDeps, objTargetDeps, sourceFileRelPath, buildObjTargets,
config
Expand All @@ -584,7 +584,7 @@ static BuildConfig configureBuild(const bool isDebug) {
testTargets.push_back(testTarget);
}

OrderedHashSet<String> phonies = {"all"};
OrderedHashSet<String> phonies = { "all" };
if (enableTesting) {
// Target to create the tests directory.
defineDirTarget(config, TEST_OUT_DIR);
Expand Down Expand Up @@ -658,18 +658,18 @@ String getMakeCommand(const bool isParallel) {

void test_cycle_vars() {
BuildConfig config;
config.defineSimpleVariable("a", "b", {"b"});
config.defineSimpleVariable("b", "c", {"c"});
config.defineSimpleVariable("c", "a", {"a"});
config.defineSimpleVariable("a", "b", { "b" });
config.defineSimpleVariable("b", "c", { "c" });
config.defineSimpleVariable("c", "a", { "a" });

ASSERT_EXCEPTION(std::stringstream ss; config.emitMakefile(ss), PoacError,
"too complex build graph");
}

void test_simple_vars() {
BuildConfig config;
config.defineSimpleVariable("c", "3", {"b"});
config.defineSimpleVariable("b", "2", {"a"});
config.defineSimpleVariable("c", "3", { "b" });
config.defineSimpleVariable("b", "2", { "a" });
config.defineSimpleVariable("a", "1");

std::stringstream ss;
Expand All @@ -685,7 +685,7 @@ void test_simple_vars() {

void test_depend_on_unregistered_var() {
BuildConfig config;
config.defineSimpleVariable("a", "1", {"b"});
config.defineSimpleVariable("a", "1", { "b" });

std::stringstream ss;
config.emitMakefile(ss);
Expand All @@ -695,19 +695,19 @@ void test_depend_on_unregistered_var() {

void test_cycle_targets() {
BuildConfig config;
config.defineTarget("a", {"echo a"}, {"b"});
config.defineTarget("b", {"echo b"}, {"c"});
config.defineTarget("c", {"echo c"}, {"a"});
config.defineTarget("a", { "echo a" }, { "b" });
config.defineTarget("b", { "echo b" }, { "c" });
config.defineTarget("c", { "echo c" }, { "a" });

ASSERT_EXCEPTION(std::stringstream ss; config.emitMakefile(ss), PoacError,
"too complex build graph");
}

void test_simple_targets() {
BuildConfig config;
config.defineTarget("a", {"echo a"});
config.defineTarget("b", {"echo b"}, {"a"});
config.defineTarget("c", {"echo c"}, {"b"});
config.defineTarget("a", { "echo a" });
config.defineTarget("b", { "echo b" }, { "a" });
config.defineTarget("c", { "echo c" }, { "b" });

std::stringstream ss;
config.emitMakefile(ss);
Expand All @@ -728,7 +728,7 @@ void test_simple_targets() {

void test_depend_on_unregistered_target() {
BuildConfig config;
config.defineTarget("a", {"echo a"}, {"b"});
config.defineTarget("a", { "echo a" }, { "b" });

std::stringstream ss;
config.emitMakefile(ss);
Expand Down
10 changes: 4 additions & 6 deletions src/BuildConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

#include "Rustify.hpp"

static inline const HashSet<String> SOURCE_FILE_EXTS{
".c", ".c++", ".cc", ".cpp", ".cxx"
};
static inline const HashSet<String> HEADER_FILE_EXTS{
".h", ".h++", ".hh", ".hpp", ".hxx"
};
static inline const HashSet<String> SOURCE_FILE_EXTS{ ".c", ".c++", ".cc",
".cpp", ".cxx" };
static inline const HashSet<String> HEADER_FILE_EXTS{ ".h", ".h++", ".hh",
".hpp", ".hxx" };

String emitMakefile(const bool);
String emitCompdb(const bool);
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/Build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int buildMain(std::span<const StringRef> args) {
bool isParallel = true;
for (usize i = 0; i < args.size(); ++i) {
StringRef arg = args[i];
HANDLE_GLOBAL_OPTS({{"build"}}) // workaround for std::span until C++26
HANDLE_GLOBAL_OPTS({ { "build" } }) // workaround for std::span until C++26

else if (arg == "-d" || arg == "--debug") {
isDebug = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/Clean.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int cleanMain(std::span<const StringRef> args) noexcept {
// Parse args
for (usize i = 0; i < args.size(); ++i) {
StringRef arg = args[i];
HANDLE_GLOBAL_OPTS({{"clean"}})
HANDLE_GLOBAL_OPTS({ { "clean" } })

else if (arg == "-p" || arg == "--profile") {
if (i + 1 >= args.size()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/Fmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int fmtMain(std::span<const StringRef> args) {
// Parse args
for (usize i = 0; i < args.size(); ++i) {
StringRef arg = args[i];
HANDLE_GLOBAL_OPTS({{"fmt"}})
HANDLE_GLOBAL_OPTS({ { "fmt" } })

else if (arg == "--check") {
isCheck = true;
Expand Down
8 changes: 4 additions & 4 deletions src/Cmd/Global.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
static inline constexpr Arr<
Tuple<StringRef, StringRef, StringRef, StringRef>, 4>
GLOBAL_OPT_HELPS{
std::make_tuple("-v", "--verbose", "", "Use verbose output"),
{"-q", "--quiet", "", "Do not print poac log messages"},
{"", "--color", "<WHEN>", "Coloring: auto, always, never"},
{"-h", "--help", "", "Print help"},
std::make_tuple("-v", "--verbose", "", "Use verbose output"),
{ "-q", "--quiet", "", "Do not print poac log messages" },
{ "", "--color", "<WHEN>", "Coloring: auto, always, never" },
{ "-h", "--help", "", "Print help" },
};

void printHeader(StringRef) noexcept;
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/Init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int initMain(std::span<const StringRef> args) {
bool isBin = true;
for (usize i = 0; i < args.size(); ++i) {
StringRef arg = args[i];
HANDLE_GLOBAL_OPTS({{"init"}})
HANDLE_GLOBAL_OPTS({ { "init" } })

else if (arg == "-b" || arg == "--bin") {
isBin = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/Lint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int lintMain(std::span<const StringRef> args) {
String cpplintArgs;
for (usize i = 0; i < args.size(); ++i) {
StringRef arg = args[i];
HANDLE_GLOBAL_OPTS({{"lint"}})
HANDLE_GLOBAL_OPTS({ { "lint" } })

else if (arg == "--exclude") {
if (i + 1 >= args.size()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/New.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ int newMain(std::span<const StringRef> args) {
String packageName;
for (usize i = 0; i < args.size(); ++i) {
StringRef arg = args[i];
HANDLE_GLOBAL_OPTS({{"new"}})
HANDLE_GLOBAL_OPTS({ { "new" } })

else if (arg == "-b" || arg == "--bin") {
isBin = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/Run.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int runMain(std::span<const StringRef> args) {
String runArgs;
for (usize i = 0; i < args.size(); ++i) {
StringRef arg = args[i];
HANDLE_GLOBAL_OPTS({{"run"}})
HANDLE_GLOBAL_OPTS({ { "run" } })

else if (arg == "-d" || arg == "--debug") {
isDebug = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/Test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int testMain(std::span<const StringRef> args) {
bool isParallel = true;
for (usize i = 0; i < args.size(); ++i) {
StringRef arg = args[i];
HANDLE_GLOBAL_OPTS({{"test"}})
HANDLE_GLOBAL_OPTS({ { "test" } })

else if (arg == "-d" || arg == "--debug") {
isDebug = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/Version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int versionMain(std::span<const StringRef> args) noexcept {
// Parse args
for (usize i = 0; i < args.size(); ++i) {
StringRef arg = args[i];
HANDLE_GLOBAL_OPTS({{"version"}})
HANDLE_GLOBAL_OPTS({ { "version" } })

else {
Logger::error("invalid argument: ", arg);
Expand Down
2 changes: 1 addition & 1 deletion src/Git/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class config {

/// Get the value of a string config variable as an owned string.
std::string get_string(const std::string& name) {
git_buf ret = {nullptr, 0, 0};
git_buf ret = { nullptr, 0, 0 };
git2_throw(git_config_get_string_buf(&ret, this->raw, name.c_str()));
return std::string(ret.ptr, ret.size);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Git/Describe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct describe {
}

std::string format(const describe_format_options& opts) {
git_buf ret = {nullptr, 0, 0};
git_buf ret = { nullptr, 0, 0 };
git2_throw(git_describe_format(&ret, this->raw, &opts.raw));
return std::string(ret.ptr, ret.size);
}
Expand Down
18 changes: 9 additions & 9 deletions src/Manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ static void validateGitTagAndBranch(StringRef target) {
}

static const HashMap<StringRef, Fn<void(StringRef)>> gitValidators = {
{"rev", validateGitRev},
{"tag", validateGitTagAndBranch},
{"branch", validateGitTagAndBranch},
{ "rev", validateGitRev },
{ "tag", validateGitTagAndBranch },
{ "branch", validateGitTagAndBranch },
};

static GitDependency parseGitDep(const String& name, const toml::table& info) {
Expand All @@ -288,7 +288,7 @@ static GitDependency parseGitDep(const String& name, const toml::table& info) {
validateGitUrl(gitUrlStr);

// rev, tag, or branch
for (const String key : {"rev", "tag", "branch"}) {
for (const String key : { "rev", "tag", "branch" }) {
if (info.contains(key)) {
const auto& value = info.at(key);
if (value.is_string()) {
Expand All @@ -299,7 +299,7 @@ static GitDependency parseGitDep(const String& name, const toml::table& info) {
}
}
}
return {name, gitUrlStr, target};
return { name, gitUrlStr, target };
}

static SystemDependency
Expand All @@ -311,7 +311,7 @@ parseSystemDep(const String& name, const toml::table& info) {
}

const String versionReq = version.as_string();
return {name, VersionReq::parse(versionReq)};
return { name, VersionReq::parse(versionReq) };
}

static void parseDependencies() {
Expand Down Expand Up @@ -381,9 +381,9 @@ DepMetadata GitDependency::install() const {
const Path includeDir = installDir / "include";
if (fs::exists(includeDir) && fs::is_directory(includeDir)
&& !fs::is_empty(includeDir)) {
return {"-I" + includeDir.string(), ""};
return { "-I" + includeDir.string(), "" };
} else {
return {"-I" + installDir.string(), ""};
return { "-I" + installDir.string(), "" };
}
// currently, no libs are supported.
}
Expand All @@ -398,7 +398,7 @@ DepMetadata SystemDependency::install() const {
String libs = getCmdOutput(libsCmd);
libs.pop_back(); // remove '\n'

return {cflags, libs};
return { cflags, libs };

// TODO: do this instead of above. We need to emit -MM depfile within
// the generated Makefile.
Expand Down
Loading

0 comments on commit 8822969

Please sign in to comment.