apply clang-format to all C++ sources
This is to prevent unrelated diff when applying clang-format in
following CLs.
Generated by
$ tools/run_formatter.sh
I'll add .git-blame-ignore-revs after submitting this.
Change-Id: If8d82dd952d11c283752fc7afce634a04088f476
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/16440
Reviewed-by: Brett Wilson <brettw@google.com>
Reviewed-by: Petr Hosek <phosek@google.com>
Commit-Queue: Takuto Ikuta <tikuta@google.com>
Reviewed-by: David Turner <digit@google.com>
diff --git a/.gitignore b/.gitignore
index da52c70..0b467f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,6 +45,7 @@
.pydevproject
.recipe_deps
.checkstyle
+/clang
compile_commands.json
cscope.*
out/
diff --git a/src/base/containers/flat_tree.h b/src/base/containers/flat_tree.h
index 65afe58..fba2a6d 100644
--- a/src/base/containers/flat_tree.h
+++ b/src/base/containers/flat_tree.h
@@ -546,7 +546,7 @@
const flat_tree&) -> flat_tree& = default;
template <class Key, class Value, class GetKeyFromValue, class KeyCompare>
-auto flat_tree<Key, Value, GetKeyFromValue, KeyCompare>::operator=(flat_tree &&)
+auto flat_tree<Key, Value, GetKeyFromValue, KeyCompare>::operator=(flat_tree&&)
-> flat_tree& = default;
template <class Key, class Value, class GetKeyFromValue, class KeyCompare>
diff --git a/src/base/containers/span.h b/src/base/containers/span.h
index 19b9503..de73fa1 100644
--- a/src/base/containers/span.h
+++ b/src/base/containers/span.h
@@ -296,9 +296,9 @@
return {data() + (size() - count), count};
}
- constexpr span<T, dynamic_extent> subspan(size_t offset,
- size_t count = dynamic_extent) const
- noexcept {
+ constexpr span<T, dynamic_extent> subspan(
+ size_t offset,
+ size_t count = dynamic_extent) const noexcept {
// Note: CHECK_LE is not constexpr, hence regular CHECK must be used.
CHECK(offset <= size());
CHECK(count == dynamic_extent || count <= size() - offset);
diff --git a/src/base/environment.cc b/src/base/environment.cc
index 427e3e5..7d80e16 100644
--- a/src/base/environment.cc
+++ b/src/base/environment.cc
@@ -188,8 +188,8 @@
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
-std::unique_ptr<char* []> AlterEnvironment(const char* const* const env,
- const EnvironmentMap& changes) {
+std::unique_ptr<char*[]> AlterEnvironment(const char* const* const env,
+ const EnvironmentMap& changes) {
std::string value_storage; // Holds concatenated null-terminated strings.
std::vector<size_t> result_indices; // Line indices into value_storage.
diff --git a/src/base/files/file.cc b/src/base/files/file.cc
index 020c40f..88cfecb 100644
--- a/src/base/files/file.cc
+++ b/src/base/files/file.cc
@@ -18,33 +18,28 @@
File::File() = default;
-File::File(const FilePath& path, uint32_t flags)
- : error_details_(FILE_OK) {
+File::File(const FilePath& path, uint32_t flags) : error_details_(FILE_OK) {
Initialize(path, flags);
}
File::File(ScopedPlatformFile platform_file)
- : file_(std::move(platform_file)),
- error_details_(FILE_OK) {
+ : file_(std::move(platform_file)), error_details_(FILE_OK) {
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
DCHECK_GE(file_.get(), -1);
#endif
}
File::File(PlatformFile platform_file)
- : file_(platform_file),
- error_details_(FILE_OK) {
+ : file_(platform_file), error_details_(FILE_OK) {
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
DCHECK_GE(platform_file, -1);
#endif
}
-File::File(Error error_details)
- : error_details_(error_details) {}
+File::File(Error error_details) : error_details_(error_details) {}
File::File(File&& other)
- : file_(other.TakePlatformFile()),
- error_details_(other.error_details()) {}
+ : file_(other.TakePlatformFile()), error_details_(other.error_details()) {}
File::~File() {
// Go through the AssertIOAllowed logic.
diff --git a/src/base/files/file_posix.cc b/src/base/files/file_posix.cc
index e837b69..ade826b 100644
--- a/src/base/files/file_posix.cc
+++ b/src/base/files/file_posix.cc
@@ -25,7 +25,7 @@
namespace {
#if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL) || \
- defined(OS_HAIKU) || defined(OS_MSYS) || defined(OS_ZOS) || \
+ defined(OS_HAIKU) || defined(OS_MSYS) || defined(OS_ZOS) || \
defined(OS_ANDROID) && __ANDROID_API__ < 21 || defined(OS_SERENITY)
int CallFstat(int fd, stat_wrapper_t* sb) {
return fstat(fd, sb);
diff --git a/src/base/files/file_util_win.cc b/src/base/files/file_util_win.cc
index c808bde..774d1e3 100644
--- a/src/base/files/file_util_win.cc
+++ b/src/base/files/file_util_win.cc
@@ -368,8 +368,7 @@
return true;
}
DLOG(WARNING) << "CreateDirectory(" << UTF16ToUTF8(full_path.value())
- << "), "
- << "conflicts with existing file.";
+ << "), " << "conflicts with existing file.";
if (error) {
*error = File::FILE_ERROR_NOT_A_DIRECTORY;
}
diff --git a/src/base/files/platform_file.h b/src/base/files/platform_file.h
index 67c2d30..d3229a6 100644
--- a/src/base/files/platform_file.h
+++ b/src/base/files/platform_file.h
@@ -9,8 +9,8 @@
#include "util/build_config.h"
#if defined(OS_WIN)
-#include "base/win/scoped_handle.h"
#include <windows.h>
+#include "base/win/scoped_handle.h"
#endif
// This file defines platform-independent types for dealing with
diff --git a/src/base/numerics/safe_conversions_impl.h b/src/base/numerics/safe_conversions_impl.h
index 8ae6a54..fd437c4 100644
--- a/src/base/numerics/safe_conversions_impl.h
+++ b/src/base/numerics/safe_conversions_impl.h
@@ -496,16 +496,16 @@
typename Lhs,
typename Rhs = Lhs,
bool is_intmax_type =
- std::is_integral<typename MaxExponentPromotion<Lhs, Rhs>::type>::value&&
- IntegerBitsPlusSign<typename MaxExponentPromotion<Lhs, Rhs>::type>::
+ std::is_integral<
+ typename MaxExponentPromotion<Lhs, Rhs>::type>::value &&
+ IntegerBitsPlusSign<typename MaxExponentPromotion<Lhs, Rhs>::type>::
value == IntegerBitsPlusSign<intmax_t>::value,
- bool is_max_exponent =
- StaticDstRangeRelationToSrcRange<
- typename MaxExponentPromotion<Lhs, Rhs>::type,
- Lhs>::value ==
- NUMERIC_RANGE_CONTAINED&& StaticDstRangeRelationToSrcRange<
- typename MaxExponentPromotion<Lhs, Rhs>::type,
- Rhs>::value == NUMERIC_RANGE_CONTAINED>
+ bool is_max_exponent = StaticDstRangeRelationToSrcRange<
+ typename MaxExponentPromotion<Lhs, Rhs>::type,
+ Lhs>::value == NUMERIC_RANGE_CONTAINED &&
+ StaticDstRangeRelationToSrcRange<
+ typename MaxExponentPromotion<Lhs, Rhs>::type,
+ Rhs>::value == NUMERIC_RANGE_CONTAINED>
struct BigEnoughPromotion;
// The side with the max exponent is big enough.
diff --git a/src/base/posix/safe_strerror.cc b/src/base/posix/safe_strerror.cc
index 252b5df..9084a2f 100644
--- a/src/base/posix/safe_strerror.cc
+++ b/src/base/posix/safe_strerror.cc
@@ -39,11 +39,11 @@
// glibc has two strerror_r functions: a historical GNU-specific one that
// returns type char *, and a POSIX.1-2001 compliant one available since 2.3.4
// that returns int. This wraps the GNU-specific one.
-static void POSSIBLY_UNUSED
-wrap_posix_strerror_r(char* (*strerror_r_ptr)(int, char*, size_t),
- int err,
- char* buf,
- size_t len) {
+static void POSSIBLY_UNUSED wrap_posix_strerror_r(
+ char* (*strerror_r_ptr)(int, char*, size_t),
+ int err,
+ char* buf,
+ size_t len) {
// GNU version.
char* rc = (*strerror_r_ptr)(err, buf, len);
if (rc != buf) {
diff --git a/src/gn/analyzer.cc b/src/gn/analyzer.cc
index be646ee..1e8ff3e 100644
--- a/src/gn/analyzer.cc
+++ b/src/gn/analyzer.cc
@@ -257,8 +257,7 @@
if (item->AsTarget()->IsBinary() ||
item->AsTarget()->output_type() == Target::ACTION ||
item->AsTarget()->output_type() == Target::ACTION_FOREACH) {
- const LabelPtrPair<Pool>& pool =
- item->AsTarget()->pool();
+ const LabelPtrPair<Pool>& pool = item->AsTarget()->pool();
if (pool.ptr)
dep_map_.insert(std::make_pair(pool.ptr, item));
}
@@ -418,7 +417,7 @@
}
if (const Config* config = item->AsConfig()) {
- for (const auto& config_pair: config->configs()) {
+ for (const auto& config_pair : config->configs()) {
if (ItemRefersToFile(config_pair.ptr, file))
return true;
}
diff --git a/src/gn/analyzer_unittest.cc b/src/gn/analyzer_unittest.cc
index e3d5696..dfd1486 100644
--- a/src/gn/analyzer_unittest.cc
+++ b/src/gn/analyzer_unittest.cc
@@ -4,9 +4,9 @@
#include "gn/analyzer.h"
-#include "gn/c_tool.h"
#include "gn/build_settings.h"
#include "gn/builder.h"
+#include "gn/c_tool.h"
#include "gn/config.h"
#include "gn/general_tool.h"
#include "gn/loader.h"
diff --git a/src/gn/binary_target_generator.cc b/src/gn/binary_target_generator.cc
index 07df7bf..a738dc9 100644
--- a/src/gn/binary_target_generator.cc
+++ b/src/gn/binary_target_generator.cc
@@ -218,10 +218,8 @@
}
}
if (!found_dep) {
- bool with_toolchain = scope_->settings()->ShouldShowToolchain({
- &target_->label(),
- &cur
- });
+ bool with_toolchain =
+ scope_->settings()->ShouldShowToolchain({&target_->label(), &cur});
*err_ = Err(*value, "Label not in deps.",
"The label \"" + cur.GetUserVisibleName(with_toolchain) +
"\"\nwas not in the deps of this target. "
diff --git a/src/gn/builder.cc b/src/gn/builder.cc
index 0ba827b..1f3ecd8 100644
--- a/src/gn/builder.cc
+++ b/src/gn/builder.cc
@@ -75,10 +75,12 @@
// Check that it's not been already defined.
if (record->item()) {
- bool with_toolchain = item->settings()->ShouldShowToolchain({&item->label()});
- err = Err(item->defined_from(), "Duplicate definition.",
- "The item\n " + item->label().GetUserVisibleName(with_toolchain) +
- "\nwas already defined.");
+ bool with_toolchain =
+ item->settings()->ShouldShowToolchain({&item->label()});
+ err =
+ Err(item->defined_from(), "Duplicate definition.",
+ "The item\n " + item->label().GetUserVisibleName(with_toolchain) +
+ "\nwas already defined.");
err.AppendSubErr(
Err(record->item()->defined_from(), "Previous definition:"));
g_scheduler->FailWithError(err);
@@ -255,8 +257,7 @@
!AddDeps(record, target->all_dependent_configs(), err) ||
!AddDeps(record, target->public_configs(), err) ||
!AddGenDeps(record, target->gen_deps(), err) ||
- !AddPoolDep(record, target, err) ||
- !AddToolchainDep(record, target, err))
+ !AddPoolDep(record, target, err) || !AddToolchainDep(record, target, err))
return false;
// All targets in the default toolchain get generated by default. We also
@@ -318,7 +319,8 @@
BuilderRecord* Builder::GetOrCreateRecordForTesting(const Label& label) {
Err err;
- return GetOrCreateRecordOfType(label, nullptr, BuilderRecord::ITEM_UNKNOWN, &err);
+ return GetOrCreateRecordOfType(label, nullptr, BuilderRecord::ITEM_UNKNOWN,
+ &err);
}
BuilderRecord* Builder::GetOrCreateRecordOfType(const Label& label,
@@ -439,9 +441,9 @@
if (target->pool().label.is_null())
return true;
- BuilderRecord* pool_record = GetOrCreateRecordOfType(
- target->pool().label, target->pool().origin,
- BuilderRecord::ITEM_POOL, err);
+ BuilderRecord* pool_record =
+ GetOrCreateRecordOfType(target->pool().label, target->pool().origin,
+ BuilderRecord::ITEM_POOL, err);
if (!pool_record)
return false;
record->AddDep(pool_record);
@@ -501,8 +503,7 @@
!ResolveConfigs(&target->configs(), err) ||
!ResolveConfigs(&target->all_dependent_configs(), err) ||
!ResolveConfigs(&target->public_configs(), err) ||
- !ResolvePool(target, err) ||
- !ResolveToolchain(target, err))
+ !ResolvePool(target, err) || !ResolveToolchain(target, err))
return false;
} else if (record->type() == BuilderRecord::ITEM_CONFIG) {
Config* config = record->item()->AsConfig();
@@ -584,9 +585,9 @@
if (target->pool().label.is_null())
return true;
- BuilderRecord* record = GetResolvedRecordOfType(
- target->pool().label, target->pool().origin,
- BuilderRecord::ITEM_POOL, err);
+ BuilderRecord* record =
+ GetResolvedRecordOfType(target->pool().label, target->pool().origin,
+ BuilderRecord::ITEM_POOL, err);
if (!record)
return false;
target->set_pool(LabelPtrPair<Pool>(record->item()->AsPool()));
@@ -623,7 +624,8 @@
std::string ret;
for (size_t i = 0; i < cycle.size(); i++) {
- ret += " " + cycle[i]->label().GetUserVisibleName(loader_->GetDefaultToolchain());
+ ret += " " +
+ cycle[i]->label().GetUserVisibleName(loader_->GetDefaultToolchain());
if (i != cycle.size() - 1)
ret += " ->";
ret += "\n";
diff --git a/src/gn/builder.h b/src/gn/builder.h
index e89e2e1..a9c01aa 100644
--- a/src/gn/builder.h
+++ b/src/gn/builder.h
@@ -101,9 +101,7 @@
bool AddGenDeps(BuilderRecord* record,
const LabelTargetVector& targets,
Err* err);
- bool AddPoolDep(BuilderRecord* record,
- const Target* target,
- Err* err);
+ bool AddPoolDep(BuilderRecord* record, const Target* target, Err* err);
bool AddToolchainDep(BuilderRecord* record, const Target* target, Err* err);
// Given a target, sets the "should generate" bit and pushes it through the
diff --git a/src/gn/builder_unittest.cc b/src/gn/builder_unittest.cc
index 79285ab..59068a6 100644
--- a/src/gn/builder_unittest.cc
+++ b/src/gn/builder_unittest.cc
@@ -211,7 +211,8 @@
a_record->AddDep(d_record);
a_record->AddDep(c_record);
- std::vector<const BuilderRecord*> a_unresolved = a_record->GetSortedUnresolvedDeps();
+ std::vector<const BuilderRecord*> a_unresolved =
+ a_record->GetSortedUnresolvedDeps();
EXPECT_EQ(3u, a_unresolved.size()) << a_unresolved.size();
EXPECT_EQ(b_record, a_unresolved[0]);
EXPECT_EQ(c_record, a_unresolved[1]);
diff --git a/src/gn/bundle_data.cc b/src/gn/bundle_data.cc
index feabf8d..3615731 100644
--- a/src/gn/bundle_data.cc
+++ b/src/gn/bundle_data.cc
@@ -202,6 +202,6 @@
return SourceDir(GetBundleRootDirOutput(settings).value());
}
-SourceDir BundleData::GetBundleDir(const Settings* settings) const{
+SourceDir BundleData::GetBundleDir(const Settings* settings) const {
return GetBundleRootDirOutput(settings).GetDir();
}
diff --git a/src/gn/c_include_iterator_unittest.cc b/src/gn/c_include_iterator_unittest.cc
index b162ced..f7b6c85 100644
--- a/src/gn/c_include_iterator_unittest.cc
+++ b/src/gn/c_include_iterator_unittest.cc
@@ -47,29 +47,34 @@
IncludeStringWithLocation include;
EXPECT_TRUE(iter.GetNextIncludeString(&include));
EXPECT_EQ("foo/bar.h", include.contents);
- EXPECT_TRUE(RangeIs(include.location, 3, 11, 20)) << include.location.begin().Describe(true);
+ EXPECT_TRUE(RangeIs(include.location, 3, 11, 20))
+ << include.location.begin().Describe(true);
EXPECT_FALSE(include.system_style_include);
EXPECT_TRUE(iter.GetNextIncludeString(&include));
EXPECT_EQ("stdio.h", include.contents);
- EXPECT_TRUE(RangeIs(include.location, 5, 11, 18)) << include.location.begin().Describe(true);
+ EXPECT_TRUE(RangeIs(include.location, 5, 11, 18))
+ << include.location.begin().Describe(true);
EXPECT_TRUE(include.system_style_include);
EXPECT_TRUE(iter.GetNextIncludeString(&include));
EXPECT_EQ("foo/baz.h", include.contents);
- EXPECT_TRUE(RangeIs(include.location, 7, 12, 21)) << include.location.begin().Describe(true);
+ EXPECT_TRUE(RangeIs(include.location, 7, 12, 21))
+ << include.location.begin().Describe(true);
EXPECT_FALSE(include.system_style_include);
EXPECT_TRUE(iter.GetNextIncludeString(&include));
EXPECT_EQ("la/deda.h", include.contents);
- EXPECT_TRUE(RangeIs(include.location, 8, 11, 20)) << include.location.begin().Describe(true);
+ EXPECT_TRUE(RangeIs(include.location, 8, 11, 20))
+ << include.location.begin().Describe(true);
EXPECT_FALSE(include.system_style_include);
// The line annotated with "nogncheck" should be skipped.
EXPECT_TRUE(iter.GetNextIncludeString(&include));
EXPECT_EQ("weird_mac_import.h", include.contents);
- EXPECT_TRUE(RangeIs(include.location, 10, 10, 28)) << include.location.begin().Describe(true);
+ EXPECT_TRUE(RangeIs(include.location, 10, 10, 28))
+ << include.location.begin().Describe(true);
EXPECT_FALSE(include.system_style_include);
EXPECT_FALSE(iter.GetNextIncludeString(&include));
diff --git a/src/gn/c_substitution_type.cc b/src/gn/c_substitution_type.cc
index 971d87a..b5ca3cd 100644
--- a/src/gn/c_substitution_type.cc
+++ b/src/gn/c_substitution_type.cc
@@ -46,12 +46,12 @@
const Substitution CSubstitutionCFlagsCc = {"{{cflags_cc}}", "cflags_cc"};
const Substitution CSubstitutionCFlagsObjC = {"{{cflags_objc}}", "cflags_objc"};
const Substitution CSubstitutionCFlagsObjCc = {"{{cflags_objcc}}",
- "cflags_objcc"};
+ "cflags_objcc"};
const Substitution CSubstitutionDefines = {"{{defines}}", "defines"};
const Substitution CSubstitutionFrameworkDirs = {"{{framework_dirs}}",
"framework_dirs"};
const Substitution CSubstitutionIncludeDirs = {"{{include_dirs}}",
- "include_dirs"};
+ "include_dirs"};
const Substitution CSubstitutionModuleDeps = {"{{module_deps}}", "module_deps"};
const Substitution CSubstitutionModuleDepsNoSelf = {"{{module_deps_no_self}}",
"module_deps_no_self"};
@@ -144,8 +144,7 @@
}
bool IsValidALinkSubstitution(const Substitution* type) {
- return IsValidToolSubstitution(type) ||
- type == &SubstitutionOutputDir ||
+ return IsValidToolSubstitution(type) || type == &SubstitutionOutputDir ||
type == &SubstitutionOutputExtension ||
type == &CSubstitutionLinkerInputs ||
type == &CSubstitutionLinkerInputsNewline ||
diff --git a/src/gn/command_clean_stale.cc b/src/gn/command_clean_stale.cc
index 72f621d..73dbb29 100644
--- a/src/gn/command_clean_stale.cc
+++ b/src/gn/command_clean_stale.cc
@@ -78,7 +78,8 @@
}
const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
- base::FilePath ninja_executable = cmdline->GetSwitchValuePath(switches::kNinjaExecutable);
+ base::FilePath ninja_executable =
+ cmdline->GetSwitchValuePath(switches::kNinjaExecutable);
if (ninja_executable.empty()) {
Err(Location(), "No --ninja-executable provided.",
"--clean-stale requires a ninja executable to run. You can "
diff --git a/src/gn/command_format.cc b/src/gn/command_format.cc
index 6907710..7f22493 100644
--- a/src/gn/command_format.cc
+++ b/src/gn/command_format.cc
@@ -543,7 +543,7 @@
#define RETURN_IF_SET(x) \
if (int result = (x); result >= 0) \
- return result
+ return result
if (const AccessorNode* accessor = node->AsAccessor()) {
RETURN_IF_SET(SuffixCommentTreeWalk(accessor->subscript()));
diff --git a/src/gn/command_gen.cc b/src/gn/command_gen.cc
index bf6d6df..0a2d7b8 100644
--- a/src/gn/command_gen.cc
+++ b/src/gn/command_gen.cc
@@ -78,9 +78,7 @@
using ResolvedMap = std::unordered_map<std::thread::id, ResolvedTargetData>;
std::unique_ptr<ResolvedMap> resolved_map = std::make_unique<ResolvedMap>();
- void LeakOnPurpose() {
- (void)resolved_map.release();
- }
+ void LeakOnPurpose() { (void)resolved_map.release(); }
};
// Called on worker thread to write the ninja file.
diff --git a/src/gn/err.cc b/src/gn/err.cc
index 13a0d48..e3f71c9 100644
--- a/src/gn/err.cc
+++ b/src/gn/err.cc
@@ -175,7 +175,8 @@
}
std::string toolchain_str;
if (!info_->toolchain_label.is_null()) {
- toolchain_str += "(" + info_->toolchain_label.GetUserVisibleName(false) + ")";
+ toolchain_str +=
+ "(" + info_->toolchain_label.GetUserVisibleName(false) + ")";
}
std::string colon;
if (!loc_str.empty() || !toolchain_str.empty())
diff --git a/src/gn/err.h b/src/gn/err.h
index 662d8b5..6e50b37 100644
--- a/src/gn/err.h
+++ b/src/gn/err.h
@@ -27,7 +27,9 @@
class Err {
private:
struct ErrInfo {
- ErrInfo(const Location& loc, const std::string& msg, const std::string& help)
+ ErrInfo(const Location& loc,
+ const std::string& msg,
+ const std::string& help)
: location(loc), message(msg), help_text(help) {}
Location location;
@@ -85,7 +87,9 @@
const std::string& message() const { return info_->message; }
const std::string& help_text() const { return info_->help_text; }
- void AppendRange(const LocationRange& range) { info_->ranges.push_back(range); }
+ void AppendRange(const LocationRange& range) {
+ info_->ranges.push_back(range);
+ }
const RangeList& ranges() const { return info_->ranges; }
void set_toolchain_label(const Label& toolchain_label) {
diff --git a/src/gn/file_writer.cc b/src/gn/file_writer.cc
index a4bb5be..6c77821 100644
--- a/src/gn/file_writer.cc
+++ b/src/gn/file_writer.cc
@@ -55,8 +55,8 @@
return false;
}
if (static_cast<size_t>(written) != str.size()) {
- PLOG(ERROR) << "wrote " << written << " bytes to "
- << file_path_ << " expected " << str.size();
+ PLOG(ERROR) << "wrote " << written << " bytes to " << file_path_
+ << " expected " << str.size();
valid_ = false;
return false;
}
diff --git a/src/gn/filesystem_utils_unittest.cc b/src/gn/filesystem_utils_unittest.cc
index 0eb786d..ef25324 100644
--- a/src/gn/filesystem_utils_unittest.cc
+++ b/src/gn/filesystem_utils_unittest.cc
@@ -459,12 +459,9 @@
RebasePath("//a/b/foo/bar", SourceDir("//a/b/"), source_root));
EXPECT_EQ("foo/bar/",
RebasePath("//a/b/foo/bar/", SourceDir("//a/b/"), source_root));
- EXPECT_EQ(".",
- RebasePath("//foo/bar", SourceDir("//foo/bar/"), source_root));
- EXPECT_EQ("..",
- RebasePath("//foo", SourceDir("//foo/bar/"), source_root));
- EXPECT_EQ("../",
- RebasePath("//foo/", SourceDir("//foo/bar/"), source_root));
+ EXPECT_EQ(".", RebasePath("//foo/bar", SourceDir("//foo/bar/"), source_root));
+ EXPECT_EQ("..", RebasePath("//foo", SourceDir("//foo/bar/"), source_root));
+ EXPECT_EQ("../", RebasePath("//foo/", SourceDir("//foo/bar/"), source_root));
// Check when only |input| is system-absolute
EXPECT_EQ("foo", RebasePath("/source/root/foo", SourceDir("//"),
diff --git a/src/gn/function_exec_script.cc b/src/gn/function_exec_script.cc
index 194dc31..489388d 100644
--- a/src/gn/function_exec_script.cc
+++ b/src/gn/function_exec_script.cc
@@ -237,10 +237,9 @@
{
if (!internal::ExecProcess(cmdline, startup_dir, &output, &stderr_output,
&exit_code)) {
- *err = Err(
- function->function(), "Could not execute interpreter.",
- "I was trying to execute \"" + FilePathToUTF8(interpreter_path) +
- "\".");
+ *err = Err(function->function(), "Could not execute interpreter.",
+ "I was trying to execute \"" +
+ FilePathToUTF8(interpreter_path) + "\".");
return Value();
}
}
diff --git a/src/gn/function_write_file_unittest.cc b/src/gn/function_write_file_unittest.cc
index ac83b19..5d33629 100644
--- a/src/gn/function_write_file_unittest.cc
+++ b/src/gn/function_write_file_unittest.cc
@@ -13,7 +13,8 @@
#include "gn/test_with_scope.h"
#include "util/test/test.h"
-#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_HAIKU) || defined(OS_MSYS) || defined(OS_SERENITY)
+#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_HAIKU) || \
+ defined(OS_MSYS) || defined(OS_SERENITY)
#include <sys/time.h>
#elif defined(OS_ZOS)
#include <utime.h>
diff --git a/src/gn/functions.cc b/src/gn/functions.cc
index 3ca1588..770ab02 100644
--- a/src/gn/functions.cc
+++ b/src/gn/functions.cc
@@ -1029,8 +1029,8 @@
std::string location_str = function->GetRange().begin().Describe(false);
std::string toolchain =
scope->settings()->toolchain_label().GetUserVisibleName(false);
- std::string output =
- "print_stack_trace() initiated at: " + location_str + " using: " + toolchain;
+ std::string output = "print_stack_trace() initiated at: " + location_str +
+ " using: " + toolchain;
output.push_back('\n');
for (const auto& entry : scope->GetTemplateInvocationEntries()) {
diff --git a/src/gn/functions.h b/src/gn/functions.h
index 890dcc7..1230501 100644
--- a/src/gn/functions.h
+++ b/src/gn/functions.h
@@ -306,10 +306,10 @@
extern const char kRustProcMacro_HelpShort[];
extern const char kRustProcMacro_Help[];
Value RunRustProcMacro(Scope* scope,
- const FunctionCallNode* function,
- const std::vector<Value>& args,
- BlockNode* block,
- Err* err);
+ const FunctionCallNode* function,
+ const std::vector<Value>& args,
+ BlockNode* block,
+ Err* err);
extern const char kSetDefaults[];
extern const char kSetDefaults_HelpShort[];
diff --git a/src/gn/functions_target.cc b/src/gn/functions_target.cc
index 72c95e2..9dff1c9 100644
--- a/src/gn/functions_target.cc
+++ b/src/gn/functions_target.cc
@@ -15,20 +15,19 @@
#define DEPENDENT_CONFIG_VARS \
" Dependent configs: all_dependent_configs, public_configs\n"
-#define DEPS_VARS \
+#define DEPS_VARS \
" Deps: assert_no_deps, data_deps, deps, public_deps, runtime_deps,\n" \
" write_runtime_deps\n"
#define GENERAL_TARGET_VARS \
" General: check_includes, configs, data, friend, inputs, metadata,\n" \
" output_extension, output_name, public, sources, testonly,\n" \
" visibility\n"
-#define RUST_VARS \
- " Rust variables: aliased_deps, crate_root, crate_name\n"
-#define RUST_SHARED_VARS \
+#define RUST_VARS " Rust variables: aliased_deps, crate_root, crate_name\n"
+#define RUST_SHARED_VARS \
" Rust variables: aliased_deps, crate_root, crate_name, crate_type\n"
-#define ACTION_VARS \
- " Action variables: args, bridge_header, configs, data, depfile,\n" \
- " framework_dirs, inputs, mnemonic, module_deps,\n" \
+#define ACTION_VARS \
+ " Action variables: args, bridge_header, configs, data, depfile,\n" \
+ " framework_dirs, inputs, mnemonic, module_deps,\n" \
" module_name, outputs*, pool, response_file_contents,\n" \
" script*, sources\n"
@@ -173,10 +172,9 @@
R"(
Variables
-)" CONFIG_VALUES_VARS_HELP DEPENDENT_CONFIG_VARS DEPS_VARS GENERAL_TARGET_VARS
-ACTION_VARS
+)" CONFIG_VALUES_VARS_HELP DEPENDENT_CONFIG_VARS DEPS_VARS GENERAL_TARGET_VARS ACTION_VARS
-R"( * = required
+ R"( * = required
Example
@@ -244,10 +242,9 @@
R"(
Variables
-)" CONFIG_VALUES_VARS_HELP DEPENDENT_CONFIG_VARS DEPS_VARS GENERAL_TARGET_VARS
-ACTION_VARS
+)" CONFIG_VALUES_VARS_HELP DEPENDENT_CONFIG_VARS DEPS_VARS GENERAL_TARGET_VARS ACTION_VARS
-R"( * = required
+ R"( * = required
Example
@@ -315,7 +312,7 @@
)" DEPENDENT_CONFIG_VARS DEPS_VARS GENERAL_TARGET_VARS
-R"( Bundle-specific: sources*, outputs*
+ R"( Bundle-specific: sources*, outputs*
* = required
Examples
@@ -403,7 +400,7 @@
)" DEPENDENT_CONFIG_VARS DEPS_VARS GENERAL_TARGET_VARS
-R"( Bundle vars: bundle_root_dir, bundle_contents_dir, bundle_resources_dir,
+ R"( Bundle vars: bundle_root_dir, bundle_contents_dir, bundle_resources_dir,
bundle_executable_dir, bundle_deps_filter, product_type,
code_signing_args, code_signing_script, code_signing_sources,
code_signing_outputs, xcode_extra_attributes,
@@ -547,7 +544,7 @@
)" DEPENDENT_CONFIG_VARS DEPS_VARS GENERAL_TARGET_VARS
-R"( Copy variables: sources*, outputs*
+ R"( Copy variables: sources*, outputs*
* = required
Examples
@@ -721,7 +718,8 @@
block, err);
}
-// rust_proc_macro ----------------------------------------------------------------
+// rust_proc_macro
+// ----------------------------------------------------------------
const char kRustProcMacro[] = "rust_proc_macro";
const char kRustProcMacro_HelpShort[] =
@@ -745,10 +743,10 @@
)" CONFIG_VALUES_VARS_HELP DEPS_VARS DEPENDENT_CONFIG_VARS GENERAL_TARGET_VARS
RUST_VARS;
Value RunRustProcMacro(Scope* scope,
- const FunctionCallNode* function,
- const std::vector<Value>& args,
- BlockNode* block,
- Err* err) {
+ const FunctionCallNode* function,
+ const std::vector<Value>& args,
+ BlockNode* block,
+ Err* err) {
return ExecuteGenericTarget(functions::kRustProcMacro, scope, function, args,
block, err);
}
@@ -847,8 +845,8 @@
Variables
complete_static_lib
-)" CONFIG_VALUES_VARS_HELP DEPS_VARS DEPENDENT_CONFIG_VARS GENERAL_TARGET_VARS
- RUST_VARS LANGUAGE_HELP;
+)" CONFIG_VALUES_VARS_HELP DEPS_VARS DEPENDENT_CONFIG_VARS GENERAL_TARGET_VARS RUST_VARS
+ LANGUAGE_HELP;
Value RunStaticLibrary(Scope* scope,
const FunctionCallNode* function,
@@ -886,7 +884,7 @@
)" DEPS_VARS DEPENDENT_CONFIG_VARS GENERAL_TARGET_VARS
-R"(
+ R"(
Targets will also have variables specific to that type, see "gn help <type>"
for more.
@@ -961,7 +959,7 @@
)" DEPENDENT_CONFIG_VARS DEPS_VARS GENERAL_TARGET_VARS
-R"( Generated file: contents, data_keys, rebase, walk_keys, output_conversion
+ R"( Generated file: contents, data_keys, rebase, walk_keys, output_conversion
Example (metadata collection)
diff --git a/src/gn/functions_unittest.cc b/src/gn/functions_unittest.cc
index bb7b0a3..c51c487 100644
--- a/src/gn/functions_unittest.cc
+++ b/src/gn/functions_unittest.cc
@@ -17,8 +17,8 @@
// Verify cases where the assertion passes.
std::vector<std::string> assert_pass_examples = {
- R"gn(assert(true))gn",
- R"gn(assert(true, "This message is ignored for passed assertions."))gn",
+ R"gn(assert(true))gn",
+ R"gn(assert(true, "This message is ignored for passed assertions."))gn",
};
for (const auto& assert_pass_example : assert_pass_examples) {
TestParseInput input(assert_pass_example);
@@ -51,15 +51,15 @@
// Verify usage errors are detected.
std::vector<std::string> bad_usage_examples = {
- // Number of arguments.
- R"gn(assert())gn",
- R"gn(assert(1, 2, 3))gn",
+ // Number of arguments.
+ R"gn(assert())gn",
+ R"gn(assert(1, 2, 3))gn",
- // Argument types.
- R"gn(assert(1))gn",
- R"gn(assert("oops"))gn",
- R"gn(assert(true, 1))gn",
- R"gn(assert(true, []))gn",
+ // Argument types.
+ R"gn(assert(1))gn",
+ R"gn(assert("oops"))gn",
+ R"gn(assert(true, 1))gn",
+ R"gn(assert(true, []))gn",
};
for (const auto& bad_usage_example : bad_usage_examples) {
TestParseInput input(bad_usage_example);
@@ -245,25 +245,26 @@
"xyz\n"
"xx\n"
"\n",
- setup.print_output()) << setup.print_output();
+ setup.print_output())
+ << setup.print_output();
}
// Verify usage errors are detected.
std::vector<std::string> bad_usage_examples = {
- // Number of arguments.
- R"gn(string_join())gn",
- R"gn(string_join(["oops"]))gn",
- R"gn(string_join("kk", [], "oops"))gn",
+ // Number of arguments.
+ R"gn(string_join())gn",
+ R"gn(string_join(["oops"]))gn",
+ R"gn(string_join("kk", [], "oops"))gn",
- // Argument types.
- R"gn(string_join(1, []))gn",
- R"gn(string_join("kk", "oops"))gn",
- R"gn(string_join(["oops"], []))gn",
+ // Argument types.
+ R"gn(string_join(1, []))gn",
+ R"gn(string_join("kk", "oops"))gn",
+ R"gn(string_join(["oops"], []))gn",
- // Non-string elements in list of strings.
- R"gn(string_join("kk", [1]))gn",
- R"gn(string_join("kk", ["hello", 1]))gn",
- R"gn(string_join("kk", ["hello", []]))gn",
+ // Non-string elements in list of strings.
+ R"gn(string_join("kk", [1]))gn",
+ R"gn(string_join("kk", ["hello", 1]))gn",
+ R"gn(string_join("kk", ["hello", []]))gn",
};
for (const auto& bad_usage_example : bad_usage_examples) {
TestParseInput input(bad_usage_example);
@@ -376,36 +377,37 @@
"[\"a\", \"b\", \"cc\", \"ddd\"]\n"
// Split on string.
- "[\"\"]\n" // Empty string (like Python)
- "[\"\", \"\"]\n" // Only a separator
- "[\"\", \"\", \"\"]\n" // Only separators
- "[\"ab\"]\n" // String is missing separator
- "[\"a\", \"b\"]\n" // Two elements
- "[\"\", \"a\", \"b\"]\n" // Leading
- "[\"a\", \"b\", \"\"]\n" // Trailing
- "[\"\", \"\", \"x\"]\n" // Leading consecutive separators
- "[\"x\", \"\", \"\"]\n" // Trailing consecutive separators
- "[\"a\", \"bb\", \"ccc\"]\n" // Multiple elements
- "[\"\", \"x\", \"\"]\n" // Self-overlapping separators 1
- "[\"x\", \"x.\"]\n" // Self-overlapping separators 2
+ "[\"\"]\n" // Empty string (like Python)
+ "[\"\", \"\"]\n" // Only a separator
+ "[\"\", \"\", \"\"]\n" // Only separators
+ "[\"ab\"]\n" // String is missing separator
+ "[\"a\", \"b\"]\n" // Two elements
+ "[\"\", \"a\", \"b\"]\n" // Leading
+ "[\"a\", \"b\", \"\"]\n" // Trailing
+ "[\"\", \"\", \"x\"]\n" // Leading consecutive separators
+ "[\"x\", \"\", \"\"]\n" // Trailing consecutive separators
+ "[\"a\", \"bb\", \"ccc\"]\n" // Multiple elements
+ "[\"\", \"x\", \"\"]\n" // Self-overlapping separators 1
+ "[\"x\", \"x.\"]\n" // Self-overlapping separators 2
,
- setup.print_output()) << setup.print_output();
+ setup.print_output())
+ << setup.print_output();
}
// Verify usage errors are detected.
std::vector<std::string> bad_usage_examples = {
- // Number of arguments.
- R"gn(string_split())gn",
- R"gn(string_split("a", "b", "c"))gn",
+ // Number of arguments.
+ R"gn(string_split())gn",
+ R"gn(string_split("a", "b", "c"))gn",
- // Argument types.
- R"gn(string_split(1))gn",
- R"gn(string_split(["oops"]))gn",
- R"gn(string_split("kk", 1))gn",
- R"gn(string_split("kk", ["oops"]))gn",
+ // Argument types.
+ R"gn(string_split(1))gn",
+ R"gn(string_split(["oops"]))gn",
+ R"gn(string_split("kk", 1))gn",
+ R"gn(string_split("kk", ["oops"]))gn",
- // Empty separator argument.
- R"gn(string_split("kk", ""))gn",
+ // Empty separator argument.
+ R"gn(string_split("kk", ""))gn",
};
for (const auto& bad_usage_example : bad_usage_examples) {
TestParseInput input(bad_usage_example);
@@ -491,12 +493,13 @@
ASSERT_FALSE(err.has_error()) << err.message();
EXPECT_EQ(
- "lala\n"
- "42\n"
- "print_stack_trace() initiated at: //test:4 using: //toolchain:default\n"
- " foo(\"lala\") //test:6\n"
- " print_stack_trace() //test:4\n",
- setup.print_output());
+ "lala\n"
+ "42\n"
+ "print_stack_trace() initiated at: //test:4 using: "
+ "//toolchain:default\n"
+ " foo(\"lala\") //test:6\n"
+ " print_stack_trace() //test:4\n",
+ setup.print_output());
}
TEST(Template, PrintStackTraceWithNoTemplates) {
@@ -509,12 +512,12 @@
ASSERT_FALSE(err.has_error()) << err.message() << "\n\n" << err.help_text();
EXPECT_EQ(
- "print_stack_trace() initiated at: //test:1 using: //toolchain:default\n"
- " print_stack_trace() //test:1\n",
- setup.print_output());
+ "print_stack_trace() initiated at: //test:1 using: "
+ "//toolchain:default\n"
+ " print_stack_trace() //test:1\n",
+ setup.print_output());
}
-
TEST(Template, PrintStackTraceWithNestedTemplates) {
TestWithScope setup;
TestParseInput input(
@@ -538,13 +541,14 @@
ASSERT_FALSE(err.has_error()) << err.message() << "\n\n" << err.help_text();
EXPECT_EQ(
- "lala.foo\n"
- "42\n"
- "print_stack_trace() initiated at: //test:4 using: //toolchain:default\n"
- " baz(\"lala\") //test:11\n"
- " foo(\"lala.foo\") //test:7\n"
- " print_stack_trace() //test:4\n",
- setup.print_output());
+ "lala.foo\n"
+ "42\n"
+ "print_stack_trace() initiated at: //test:4 using: "
+ "//toolchain:default\n"
+ " baz(\"lala\") //test:11\n"
+ " foo(\"lala.foo\") //test:7\n"
+ " print_stack_trace() //test:4\n",
+ setup.print_output());
}
TEST(Template, PrintStackTraceWithNonTemplateScopes) {
@@ -572,13 +576,14 @@
ASSERT_FALSE(err.has_error()) << err.message() << "\n\n" << err.help_text();
EXPECT_EQ(
- "lala.foo\n"
- "42\n"
- "print_stack_trace() initiated at: //test:5 using: //toolchain:default\n"
- " baz(\"lala\") //test:13\n"
- " foo(\"lala.foo\") //test:9\n"
- " print_stack_trace() //test:5\n",
- setup.print_output());
+ "lala.foo\n"
+ "42\n"
+ "print_stack_trace() initiated at: //test:5 using: "
+ "//toolchain:default\n"
+ " baz(\"lala\") //test:13\n"
+ " foo(\"lala.foo\") //test:9\n"
+ " print_stack_trace() //test:5\n",
+ setup.print_output());
}
TEST(Template, PrintStackTraceWithNonTemplateScopesBetweenTemplateInvocations) {
@@ -607,13 +612,14 @@
ASSERT_FALSE(err.has_error()) << err.message() << "\n\n" << err.help_text();
EXPECT_EQ(
- "lala.foo\n"
- "42\n"
- "print_stack_trace() initiated at: //test:5 using: //toolchain:default\n"
- " baz(\"lala\") //test:15\n"
- " foo(\"lala.foo\") //test:10\n"
- " print_stack_trace() //test:5\n",
- setup.print_output());
+ "lala.foo\n"
+ "42\n"
+ "print_stack_trace() initiated at: //test:5 using: "
+ "//toolchain:default\n"
+ " baz(\"lala\") //test:15\n"
+ " foo(\"lala.foo\") //test:10\n"
+ " print_stack_trace() //test:5\n",
+ setup.print_output());
}
TEST(Template, PrintStackTraceWithTemplateDefinedWithinATemplate) {
@@ -648,13 +654,14 @@
ASSERT_FALSE(err.has_error()) << err.message() << "\n\n" << err.help_text();
EXPECT_EQ(
- "lala.foo\n"
- "lala.foo.internal\n"
- "42\n"
- "print_stack_trace() initiated at: //test:6 using: //toolchain:default\n"
- " baz(\"lala\") //test:19\n"
- " foo(\"lala.foo\") //test:14\n"
- " foo_internal(\"lala.foo.internal\") //test:8\n"
- " print_stack_trace() //test:6\n",
- setup.print_output());
+ "lala.foo\n"
+ "lala.foo.internal\n"
+ "42\n"
+ "print_stack_trace() initiated at: //test:6 using: "
+ "//toolchain:default\n"
+ " baz(\"lala\") //test:19\n"
+ " foo(\"lala.foo\") //test:14\n"
+ " foo_internal(\"lala.foo.internal\") //test:8\n"
+ " print_stack_trace() //test:6\n",
+ setup.print_output());
}
diff --git a/src/gn/hash_table_base.h b/src/gn/hash_table_base.h
index a5d9e12..4e9e347 100644
--- a/src/gn/hash_table_base.h
+++ b/src/gn/hash_table_base.h
@@ -497,8 +497,7 @@
#if defined(__GNUC__) || defined(__clang__)
[[gnu::noinline]]
#endif
- void
- GrowBuckets() {
+ void GrowBuckets() {
size_t size = size_;
size_t new_size = (size == 1) ? 8 : size * 2;
size_t new_mask = new_size - 1;
diff --git a/src/gn/header_checker.cc b/src/gn/header_checker.cc
index 7bad781..1a93417 100644
--- a/src/gn/header_checker.cc
+++ b/src/gn/header_checker.cc
@@ -263,11 +263,11 @@
Value relative_file_value(nullptr, std::string(include.contents));
- auto find_predicate = [relative_file_value, err, this](const SourceDir& dir) -> bool {
- SourceFile include_file =
- dir.ResolveRelativeFile(relative_file_value, err);
- return file_map_.find(include_file) != file_map_.end();
- };
+ auto find_predicate = [relative_file_value, err,
+ this](const SourceDir& dir) -> bool {
+ SourceFile include_file = dir.ResolveRelativeFile(relative_file_value, err);
+ return file_map_.find(include_file) != file_map_.end();
+ };
if (!include.system_style_include) {
const SourceDir& file_dir = source_file.dir();
if (find_predicate(file_dir)) {
@@ -275,8 +275,8 @@
}
}
- auto it = std::find_if(
- include_dirs.begin(), include_dirs.end(), find_predicate);
+ auto it =
+ std::find_if(include_dirs.begin(), include_dirs.end(), find_predicate);
if (it != include_dirs.end())
return it->ResolveRelativeFile(relative_file_value, err);
@@ -335,10 +335,8 @@
continue;
Err err;
- SourceFile included_file = SourceFileForInclude(include,
- include_dirs,
- input_file,
- &err);
+ SourceFile included_file =
+ SourceFileForInclude(include, include_dirs, input_file, &err);
if (!included_file.is_null()) {
CheckInclude(from_target, input_file, included_file, include.location,
&no_dependency_cache, errors);
diff --git a/src/gn/input_file_manager.cc b/src/gn/input_file_manager.cc
index 4ecb80b..6e2f072 100644
--- a/src/gn/input_file_manager.cc
+++ b/src/gn/input_file_manager.cc
@@ -290,8 +290,8 @@
Err* err) {
std::vector<Token> tokens;
std::unique_ptr<ParseNode> root;
- bool success =
- DoLoadFile(origin, build_settings, name, load_file_callback_, file, &tokens, &root, err);
+ bool success = DoLoadFile(origin, build_settings, name, load_file_callback_,
+ file, &tokens, &root, err);
// Can't return early. We have to ensure that the completion event is
// signaled in all cases because another thread could be blocked on this one.
diff --git a/src/gn/json_project_writer.cc b/src/gn/json_project_writer.cc
index 27368ff..a37fa9b 100644
--- a/src/gn/json_project_writer.cc
+++ b/src/gn/json_project_writer.cc
@@ -496,7 +496,8 @@
std::string json_dict;
base::JSONWriter::WriteWithOptions(
toolchain, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_dict);
- json_writer.AddJSONDict(tool_chain_kv.first.GetUserVisibleName(false), json_dict);
+ json_writer.AddJSONDict(tool_chain_kv.first.GetUserVisibleName(false),
+ json_dict);
}
}
json_writer.EndDict(); // toolchains
diff --git a/src/gn/label_pattern_unittest.cc b/src/gn/label_pattern_unittest.cc
index 54fbb2e..5d65853 100644
--- a/src/gn/label_pattern_unittest.cc
+++ b/src/gn/label_pattern_unittest.cc
@@ -28,46 +28,46 @@
TEST(LabelPattern, PatternParse) {
SourceDir current_dir("//foo/");
PatternCase cases[] = {
- // Missing stuff.
- {"", false, LabelPattern::MATCH, "", "", ""},
- {":", false, LabelPattern::MATCH, "", "", ""},
- // Normal things.
- {":bar", true, LabelPattern::MATCH, "//foo/", "bar", ""},
- {"//la:bar", true, LabelPattern::MATCH, "//la/", "bar", ""},
- {"*", true, LabelPattern::RECURSIVE_DIRECTORY, "", "", ""},
- {":*", true, LabelPattern::DIRECTORY, "//foo/", "", ""},
- {"la:*", true, LabelPattern::DIRECTORY, "//foo/la/", "", ""},
- {"la/*:*", true, LabelPattern::RECURSIVE_DIRECTORY, "//foo/la/", "", ""},
- {"//la:*", true, LabelPattern::DIRECTORY, "//la/", "", ""},
- {"./*", true, LabelPattern::RECURSIVE_DIRECTORY, "//foo/", "", ""},
- {"foo/*", true, LabelPattern::RECURSIVE_DIRECTORY, "//foo/foo/", "", ""},
- {"//l/*", true, LabelPattern::RECURSIVE_DIRECTORY, "//l/", "", ""},
- // Toolchains.
- {"//foo()", true, LabelPattern::MATCH, "//foo/", "foo", ""},
- {"//foo(//bar)", true, LabelPattern::MATCH, "//foo/", "foo", "//bar:bar"},
- {"//foo:*(//bar)", true, LabelPattern::DIRECTORY, "//foo/", "",
- "//bar:bar"},
- {"//foo/*(//bar)", true, LabelPattern::RECURSIVE_DIRECTORY, "//foo/", "",
- "//bar:bar"},
- // Wildcards in invalid places.
- {"*foo*:bar", false, LabelPattern::MATCH, "", "", ""},
- {"foo*:*bar", false, LabelPattern::MATCH, "", "", ""},
- {"*foo:bar", false, LabelPattern::MATCH, "", "", ""},
- {"foo:bar*", false, LabelPattern::MATCH, "", "", ""},
- {"*:*", true, LabelPattern::RECURSIVE_DIRECTORY, "", "", ""},
- // Invalid toolchain stuff.
- {"//foo(//foo/bar:*)", false, LabelPattern::MATCH, "", "", ""},
- {"//foo/*(*)", false, LabelPattern::MATCH, "", "", ""},
- {"//foo(//bar", false, LabelPattern::MATCH, "", "", ""},
- // Absolute paths.
- {"/la/*", true, LabelPattern::RECURSIVE_DIRECTORY, "/la/", "", ""},
- {"/la:bar", true, LabelPattern::MATCH, "/la/", "bar", ""},
+ // Missing stuff.
+ {"", false, LabelPattern::MATCH, "", "", ""},
+ {":", false, LabelPattern::MATCH, "", "", ""},
+ // Normal things.
+ {":bar", true, LabelPattern::MATCH, "//foo/", "bar", ""},
+ {"//la:bar", true, LabelPattern::MATCH, "//la/", "bar", ""},
+ {"*", true, LabelPattern::RECURSIVE_DIRECTORY, "", "", ""},
+ {":*", true, LabelPattern::DIRECTORY, "//foo/", "", ""},
+ {"la:*", true, LabelPattern::DIRECTORY, "//foo/la/", "", ""},
+ {"la/*:*", true, LabelPattern::RECURSIVE_DIRECTORY, "//foo/la/", "", ""},
+ {"//la:*", true, LabelPattern::DIRECTORY, "//la/", "", ""},
+ {"./*", true, LabelPattern::RECURSIVE_DIRECTORY, "//foo/", "", ""},
+ {"foo/*", true, LabelPattern::RECURSIVE_DIRECTORY, "//foo/foo/", "", ""},
+ {"//l/*", true, LabelPattern::RECURSIVE_DIRECTORY, "//l/", "", ""},
+ // Toolchains.
+ {"//foo()", true, LabelPattern::MATCH, "//foo/", "foo", ""},
+ {"//foo(//bar)", true, LabelPattern::MATCH, "//foo/", "foo", "//bar:bar"},
+ {"//foo:*(//bar)", true, LabelPattern::DIRECTORY, "//foo/", "",
+ "//bar:bar"},
+ {"//foo/*(//bar)", true, LabelPattern::RECURSIVE_DIRECTORY, "//foo/", "",
+ "//bar:bar"},
+ // Wildcards in invalid places.
+ {"*foo*:bar", false, LabelPattern::MATCH, "", "", ""},
+ {"foo*:*bar", false, LabelPattern::MATCH, "", "", ""},
+ {"*foo:bar", false, LabelPattern::MATCH, "", "", ""},
+ {"foo:bar*", false, LabelPattern::MATCH, "", "", ""},
+ {"*:*", true, LabelPattern::RECURSIVE_DIRECTORY, "", "", ""},
+ // Invalid toolchain stuff.
+ {"//foo(//foo/bar:*)", false, LabelPattern::MATCH, "", "", ""},
+ {"//foo/*(*)", false, LabelPattern::MATCH, "", "", ""},
+ {"//foo(//bar", false, LabelPattern::MATCH, "", "", ""},
+ // Absolute paths.
+ {"/la/*", true, LabelPattern::RECURSIVE_DIRECTORY, "/la/", "", ""},
+ {"/la:bar", true, LabelPattern::MATCH, "/la/", "bar", ""},
#if defined(OS_WIN)
- {"/C:/la/*", true, LabelPattern::RECURSIVE_DIRECTORY, "/C:/la/", "", ""},
- {"C:/la/*", true, LabelPattern::RECURSIVE_DIRECTORY, "/C:/la/", "", ""},
- {"/C:/la:bar", true, LabelPattern::MATCH, "/C:/la/", "bar", ""},
- {"C:/la:bar", true, LabelPattern::MATCH, "/C:/la/", "bar", ""},
- {"C:foo", true, LabelPattern::MATCH, "//foo/C/", "foo", ""},
+ {"/C:/la/*", true, LabelPattern::RECURSIVE_DIRECTORY, "/C:/la/", "", ""},
+ {"C:/la/*", true, LabelPattern::RECURSIVE_DIRECTORY, "/C:/la/", "", ""},
+ {"/C:/la:bar", true, LabelPattern::MATCH, "/C:/la/", "bar", ""},
+ {"C:/la:bar", true, LabelPattern::MATCH, "/C:/la/", "bar", ""},
+ {"C:foo", true, LabelPattern::MATCH, "//foo/C/", "foo", ""},
#endif
};
diff --git a/src/gn/label_unittest.cc b/src/gn/label_unittest.cc
index 3a03337..00f881e 100644
--- a/src/gn/label_unittest.cc
+++ b/src/gn/label_unittest.cc
@@ -28,48 +28,52 @@
TEST(Label, Resolve) {
ParseDepStringCase cases[] = {
- {"//chrome/", "", false, "", "", "", ""},
- {"//chrome/", "/", false, "", "", "", ""},
- {"//chrome/", ":", false, "", "", "", ""},
- {"//chrome/", "/:", false, "", "", "", ""},
- {"//chrome/", "blah", true, "//chrome/blah/", "blah", "//t/", "d"},
- {"//chrome/", "blah:bar", true, "//chrome/blah/", "bar", "//t/", "d"},
- // Absolute paths.
- {"//chrome/", "/chrome:bar", true, "/chrome/", "bar", "//t/", "d"},
- {"//chrome/", "/chrome/:bar", true, "/chrome/", "bar", "//t/", "d"},
+ {"//chrome/", "", false, "", "", "", ""},
+ {"//chrome/", "/", false, "", "", "", ""},
+ {"//chrome/", ":", false, "", "", "", ""},
+ {"//chrome/", "/:", false, "", "", "", ""},
+ {"//chrome/", "blah", true, "//chrome/blah/", "blah", "//t/", "d"},
+ {"//chrome/", "blah:bar", true, "//chrome/blah/", "bar", "//t/", "d"},
+ // Absolute paths.
+ {"//chrome/", "/chrome:bar", true, "/chrome/", "bar", "//t/", "d"},
+ {"//chrome/", "/chrome/:bar", true, "/chrome/", "bar", "//t/", "d"},
#if defined(OS_WIN)
- {"//chrome/", "/C:/chrome:bar", true, "/C:/chrome/", "bar", "//t/", "d"},
- {"//chrome/", "/C:/chrome/:bar", true, "/C:/chrome/", "bar", "//t/", "d"},
- {"//chrome/", "C:/chrome:bar", true, "/C:/chrome/", "bar", "//t/", "d"},
+ {"//chrome/", "/C:/chrome:bar", true, "/C:/chrome/", "bar", "//t/", "d"},
+ {"//chrome/", "/C:/chrome/:bar", true, "/C:/chrome/", "bar", "//t/", "d"},
+ {"//chrome/", "C:/chrome:bar", true, "/C:/chrome/", "bar", "//t/", "d"},
#endif
- // Refers to root dir.
- {"//chrome/", "//:bar", true, "//", "bar", "//t/", "d"},
- // Implicit directory
- {"//chrome/", ":bar", true, "//chrome/", "bar", "//t/", "d"},
- {"//chrome/renderer/", ":bar", true, "//chrome/renderer/", "bar", "//t/",
- "d"},
- // Implicit names.
- {"//chrome/", "//base", true, "//base/", "base", "//t/", "d"},
- {"//chrome/", "//base/i18n", true, "//base/i18n/", "i18n", "//t/", "d"},
- {"//chrome/", "//base/i18n:foo", true, "//base/i18n/", "foo", "//t/", "d"},
- {"//chrome/", "//", false, "", "", "", ""},
- // Toolchain parsing.
- {"//chrome/", "//chrome:bar(//t:n)", true, "//chrome/", "bar", "//t/", "n"},
- {"//chrome/", "//chrome:bar(//t)", true, "//chrome/", "bar", "//t/", "t"},
- {"//chrome/", "//chrome:bar(//t:)", true, "//chrome/", "bar", "//t/", "t"},
- {"//chrome/", "//chrome:bar()", true, "//chrome/", "bar", "//t/", "d"},
- {"//chrome/", "//chrome:bar(foo)", true, "//chrome/", "bar",
- "//chrome/foo/", "foo"},
- {"//chrome/", "//chrome:bar(:foo)", true, "//chrome/", "bar", "//chrome/",
- "foo"},
- // TODO(brettw) it might be nice to make this an error:
- //{"//chrome/", "//chrome:bar())", false, "", "", "", "" },
- {"//chrome/", "//chrome:bar(//t:bar(tc))", false, "", "", "", ""},
- {"//chrome/", "//chrome:bar(()", false, "", "", "", ""},
- {"//chrome/", "(t:b)", false, "", "", "", ""},
- {"//chrome/", ":bar(//t/b)", true, "//chrome/", "bar", "//t/b/", "b"},
- {"//chrome/", ":bar(/t/b)", true, "//chrome/", "bar", "/t/b/", "b"},
- {"//chrome/", ":bar(t/b)", true, "//chrome/", "bar", "//chrome/t/b/", "b"},
+ // Refers to root dir.
+ {"//chrome/", "//:bar", true, "//", "bar", "//t/", "d"},
+ // Implicit directory
+ {"//chrome/", ":bar", true, "//chrome/", "bar", "//t/", "d"},
+ {"//chrome/renderer/", ":bar", true, "//chrome/renderer/", "bar", "//t/",
+ "d"},
+ // Implicit names.
+ {"//chrome/", "//base", true, "//base/", "base", "//t/", "d"},
+ {"//chrome/", "//base/i18n", true, "//base/i18n/", "i18n", "//t/", "d"},
+ {"//chrome/", "//base/i18n:foo", true, "//base/i18n/", "foo", "//t/",
+ "d"},
+ {"//chrome/", "//", false, "", "", "", ""},
+ // Toolchain parsing.
+ {"//chrome/", "//chrome:bar(//t:n)", true, "//chrome/", "bar", "//t/",
+ "n"},
+ {"//chrome/", "//chrome:bar(//t)", true, "//chrome/", "bar", "//t/", "t"},
+ {"//chrome/", "//chrome:bar(//t:)", true, "//chrome/", "bar", "//t/",
+ "t"},
+ {"//chrome/", "//chrome:bar()", true, "//chrome/", "bar", "//t/", "d"},
+ {"//chrome/", "//chrome:bar(foo)", true, "//chrome/", "bar",
+ "//chrome/foo/", "foo"},
+ {"//chrome/", "//chrome:bar(:foo)", true, "//chrome/", "bar", "//chrome/",
+ "foo"},
+ // TODO(brettw) it might be nice to make this an error:
+ //{"//chrome/", "//chrome:bar())", false, "", "", "", "" },
+ {"//chrome/", "//chrome:bar(//t:bar(tc))", false, "", "", "", ""},
+ {"//chrome/", "//chrome:bar(()", false, "", "", "", ""},
+ {"//chrome/", "(t:b)", false, "", "", "", ""},
+ {"//chrome/", ":bar(//t/b)", true, "//chrome/", "bar", "//t/b/", "b"},
+ {"//chrome/", ":bar(/t/b)", true, "//chrome/", "bar", "/t/b/", "b"},
+ {"//chrome/", ":bar(t/b)", true, "//chrome/", "bar", "//chrome/t/b/",
+ "b"},
};
Label default_toolchain(SourceDir("//t/"), "d");
diff --git a/src/gn/loader.cc b/src/gn/loader.cc
index 9d46103..6431e70 100644
--- a/src/gn/loader.cc
+++ b/src/gn/loader.cc
@@ -198,8 +198,8 @@
}
SourceFile LoaderImpl::BuildFileForLabel(const Label& label) const {
- return SourceFile(
- label.dir().value() + "BUILD" + build_file_extension_ + ".gn");
+ return SourceFile(label.dir().value() + "BUILD" + build_file_extension_ +
+ ".gn");
}
void LoaderImpl::ScheduleLoadFile(const Settings* settings,
diff --git a/src/gn/loader_unittest.cc b/src/gn/loader_unittest.cc
index ce14894..dcc5e61 100644
--- a/src/gn/loader_unittest.cc
+++ b/src/gn/loader_unittest.cc
@@ -110,14 +110,13 @@
}
InputFileManager::SyncLoadFileCallback MockInputFileManager::GetSyncCallback() {
- return
- [this](const SourceFile& file_name, InputFile* file) {
- CannedResponseMap::const_iterator found = canned_responses_.find(file_name);
- if (found == canned_responses_.end())
- return false;
- file->SetContents(found->second->input_file->contents());
- return true;
- };
+ return [this](const SourceFile& file_name, InputFile* file) {
+ CannedResponseMap::const_iterator found = canned_responses_.find(file_name);
+ if (found == canned_responses_.end())
+ return false;
+ file->SetContents(found->second->input_file->contents());
+ return true;
+ };
}
// Sets a given response for a given source file.
diff --git a/src/gn/ninja_action_target_writer_unittest.cc b/src/gn/ninja_action_target_writer_unittest.cc
index aafc779..3f41d97 100644
--- a/src/gn/ninja_action_target_writer_unittest.cc
+++ b/src/gn/ninja_action_target_writer_unittest.cc
@@ -217,7 +217,6 @@
EXPECT_EQ(expected, out.str());
}
-
TEST(NinjaActionTargetWriter, ForEach) {
Err err;
TestWithScope setup;
@@ -635,12 +634,15 @@
writer.Run();
const char expected[] =
- R"(rule __foo_bar___rule)" "\n"
+ R"(rule __foo_bar___rule)"
+ "\n"
// Escaping is different between Windows and Posix.
#if defined(OS_WIN)
- R"( command = "/Program$ Files/python" "../../foo/my$ script.py" "my$ argument")" "\n"
+ R"( command = "/Program$ Files/python" "../../foo/my$ script.py" "my$ argument")"
+ "\n"
#else
- R"( command = /Program\$ Files/python ../../foo/my\$ script.py my\$ argument)" "\n"
+ R"( command = /Program\$ Files/python ../../foo/my\$ script.py my\$ argument)"
+ "\n"
#endif
R"( description = ACTION //foo:bar()
restat = 1
diff --git a/src/gn/ninja_binary_target_writer.cc b/src/gn/ninja_binary_target_writer.cc
index 755d963..3cfa584 100644
--- a/src/gn/ninja_binary_target_writer.cc
+++ b/src/gn/ninja_binary_target_writer.cc
@@ -72,7 +72,7 @@
// file for it.
if (inputs.size() == 1) {
return std::vector<OutputFile>{
- OutputFile(settings_->build_settings(), *inputs[0])};
+ OutputFile(settings_->build_settings(), *inputs[0])};
}
std::vector<OutputFile> outs;
@@ -280,20 +280,16 @@
out_ << std::endl;
if (!sources.empty() && can_write_source_info) {
- out_ << " "
- << "source_file_part = " << sources[0].GetName();
+ out_ << " " << "source_file_part = " << sources[0].GetName();
out_ << std::endl;
- out_ << " "
- << "source_name_part = "
+ out_ << " " << "source_name_part = "
<< FindFilenameNoExtension(&sources[0].value());
out_ << std::endl;
}
}
-void NinjaBinaryTargetWriter::WriteCustomLinkerFlags(
- std::ostream& out,
- const Tool* tool) {
-
+void NinjaBinaryTargetWriter::WriteCustomLinkerFlags(std::ostream& out,
+ const Tool* tool) {
if (tool->AsC() || (tool->AsRust() && tool->AsRust()->MayLink())) {
// First the ldflags from the target and its config.
RecursiveTargetConfigStringsToStream(kRecursiveWriterKeepDuplicates,
@@ -302,9 +298,8 @@
}
}
-void NinjaBinaryTargetWriter::WriteLibrarySearchPath(
- std::ostream& out,
- const Tool* tool) {
+void NinjaBinaryTargetWriter::WriteLibrarySearchPath(std::ostream& out,
+ const Tool* tool) {
// Write library search paths that have been recursively pushed
// through the dependency tree.
const auto& all_lib_dirs = resolved().GetLinkedLibraryDirs(target_);
@@ -355,9 +350,9 @@
// Libraries that have been recursively pushed through the dependency tree.
// Since we're passing these on the command line to the linker and not
// to Ninja, we need to do shell escaping.
- PathOutput lib_path_output(
- path_output_.current_dir(), settings_->build_settings()->root_path_utf8(),
- ESCAPE_NINJA_COMMAND);
+ PathOutput lib_path_output(path_output_.current_dir(),
+ settings_->build_settings()->root_path_utf8(),
+ ESCAPE_NINJA_COMMAND);
EscapeOptions lib_escape_opts;
lib_escape_opts.mode = ESCAPE_NINJA_COMMAND;
const auto& all_libs = resolved().GetLinkedLibraries(target_);
diff --git a/src/gn/ninja_build_writer.cc b/src/gn/ninja_build_writer.cc
index 3c342ea..91e6860 100644
--- a/src/gn/ninja_build_writer.cc
+++ b/src/gn/ninja_build_writer.cc
@@ -388,8 +388,7 @@
}
for (const Target* target : all_targets_) {
- if (target->IsBinary() ||
- target->output_type() == Target::ACTION ||
+ if (target->IsBinary() || target->output_type() == Target::ACTION ||
target->output_type() == Target::ACTION_FOREACH) {
const LabelPtrPair<Pool>& pool = target->pool();
if (pool.ptr)
diff --git a/src/gn/ninja_build_writer_unittest.cc b/src/gn/ninja_build_writer_unittest.cc
index ba6af4f..f46cd5f 100644
--- a/src/gn/ninja_build_writer_unittest.cc
+++ b/src/gn/ninja_build_writer_unittest.cc
@@ -114,8 +114,7 @@
target_baz.action_values().outputs() = SubstitutionList::MakeForTest(
"//out/Debug/out5.out", "//out/Debug/out6.out");
target_baz.SetToolchain(&other_toolchain);
- target_baz.set_pool(
- LabelPtrPair<Pool>(&another_regular_pool));
+ target_baz.set_pool(LabelPtrPair<Pool>(&another_regular_pool));
ASSERT_TRUE(target_baz.OnResolved(&err));
// The console pool must be in the default toolchain.
diff --git a/src/gn/ninja_c_binary_target_writer.cc b/src/gn/ninja_c_binary_target_writer.cc
index ec2e0bb..f97c222 100644
--- a/src/gn/ninja_c_binary_target_writer.cc
+++ b/src/gn/ninja_c_binary_target_writer.cc
@@ -136,8 +136,8 @@
size_t num_stamp_uses = target_->sources().size();
- std::vector<OutputFile> input_deps = WriteInputsStampAndGetDep(
- num_stamp_uses);
+ std::vector<OutputFile> input_deps =
+ WriteInputsStampAndGetDep(num_stamp_uses);
// The input dependencies will be an order-only dependency. This will cause
// Ninja to make sure the inputs are up to date before compiling this source,
@@ -249,8 +249,7 @@
const Substitution* substitution,
const std::vector<ModuleDep>& module_dep_info,
bool include_self) {
- if (target_->toolchain()->substitution_bits().used.count(
- substitution)) {
+ if (target_->toolchain()->substitution_bits().used.count(substitution)) {
EscapeOptions options;
options.mode = ESCAPE_NINJA_COMMAND;
diff --git a/src/gn/ninja_c_binary_target_writer_unittest.cc b/src/gn/ninja_c_binary_target_writer_unittest.cc
index 38df42b..b4d49d9 100644
--- a/src/gn/ninja_c_binary_target_writer_unittest.cc
+++ b/src/gn/ninja_c_binary_target_writer_unittest.cc
@@ -509,7 +509,8 @@
Target target(setup.settings(), Label(SourceDir("//foo/"), "shlib"));
target.set_output_type(Target::SHARED_LIBRARY);
target.config_values().libs().push_back(LibFile(SourceFile("//foo/lib1.a")));
- target.config_values().libs().push_back(LibFile(SourceFile("//sysroot/DIA SDK/diaguids.lib")));
+ target.config_values().libs().push_back(
+ LibFile(SourceFile("//sysroot/DIA SDK/diaguids.lib")));
target.config_values().libs().push_back(LibFile("foo"));
target.config_values().lib_dirs().push_back(SourceDir("//foo/bar/"));
target.SetToolchain(setup.toolchain());
@@ -527,10 +528,12 @@
"target_output_name = libshlib\n"
"\n"
"\n"
- "build ./libshlib.so: solink | ../../foo/lib1.a ../../sysroot/DIA$ SDK/diaguids.lib\n"
+ "build ./libshlib.so: solink | ../../foo/lib1.a ../../sysroot/DIA$ "
+ "SDK/diaguids.lib\n"
" ldflags = -L../../foo/bar\n"
#ifdef _WIN32
- " libs = ../../foo/lib1.a \"../../sysroot/DIA$ SDK/diaguids.lib\" -lfoo\n"
+ " libs = ../../foo/lib1.a \"../../sysroot/DIA$ SDK/diaguids.lib\" "
+ "-lfoo\n"
#else
" libs = ../../foo/lib1.a ../../sysroot/DIA\\$ SDK/diaguids.lib -lfoo\n"
#endif
@@ -1541,7 +1544,6 @@
target.SetToolchain(setup.toolchain());
ASSERT_TRUE(target.OnResolved(&err));
-
std::ostringstream out;
NinjaCBinaryTargetWriter writer(&target, out);
writer.Run();
@@ -2119,7 +2121,7 @@
TestWithScope setup;
Target static1(setup.settings(),
- Label(SourceDir("//static1/"), "staticlib1"));
+ Label(SourceDir("//static1/"), "staticlib1"));
static1.set_output_type(Target::STATIC_LIBRARY);
static1.visibility().SetPublic();
static1.sources().push_back(SourceFile("//static1/c.cc"));
@@ -2128,7 +2130,7 @@
ASSERT_TRUE(static1.OnResolved(&err));
Target static2(setup.settings(),
- Label(SourceDir("//static2/"), "staticlib2"));
+ Label(SourceDir("//static2/"), "staticlib2"));
static2.set_output_type(Target::STATIC_LIBRARY);
static2.visibility().SetPublic();
static2.sources().push_back(SourceFile("//static2/c.cc"));
@@ -2137,7 +2139,7 @@
ASSERT_TRUE(static2.OnResolved(&err));
Target static3(setup.settings(),
- Label(SourceDir("//static3/"), "staticlib3"));
+ Label(SourceDir("//static3/"), "staticlib3"));
static3.set_output_type(Target::STATIC_LIBRARY);
static3.visibility().SetPublic();
static3.sources().push_back(SourceFile("//static3/c.cc"));
@@ -2146,7 +2148,7 @@
ASSERT_TRUE(static3.OnResolved(&err));
Target shared1(setup.settings(),
- Label(SourceDir("//shared1"), "mysharedlib1"));
+ Label(SourceDir("//shared1"), "mysharedlib1"));
shared1.set_output_type(Target::SHARED_LIBRARY);
shared1.set_output_name("mysharedlib1");
shared1.set_output_prefix_override("");
@@ -2168,7 +2170,7 @@
ASSERT_TRUE(rlib2.OnResolved(&err));
Target shared3(setup.settings(),
- Label(SourceDir("//shared3"), "mysharedlib3"));
+ Label(SourceDir("//shared3"), "mysharedlib3"));
shared3.set_output_type(Target::SHARED_LIBRARY);
shared3.set_output_name("mysharedlib3");
shared3.set_output_prefix_override("");
@@ -2250,7 +2252,8 @@
"target_out_dir = obj/foo\n"
"target_output_name = libbar\n"
"\n"
- "build obj/foo/libbar.bar.o: cxx ../../foo/bar.cc | obj/foo/libbar.bar.pcm\n"
+ "build obj/foo/libbar.bar.o: cxx ../../foo/bar.cc | "
+ "obj/foo/libbar.bar.pcm\n"
" source_file_part = bar.cc\n"
" source_name_part = bar\n"
"build obj/foo/libbar.bar.pcm: cxx_module ../../foo/bar.modulemap\n"
@@ -2713,9 +2716,9 @@
output_dir =
)"
#if defined(OS_WIN)
- " solibs = \"./Space$ Cadet.so\"\n";
+ " solibs = \"./Space$ Cadet.so\"\n";
#else
- " solibs = ./Space\\$ Cadet.so\n";
+ " solibs = ./Space\\$ Cadet.so\n";
#endif
std::string out_str = out.str();
diff --git a/src/gn/ninja_copy_target_writer.cc b/src/gn/ninja_copy_target_writer.cc
index 8a95cea..157b612 100644
--- a/src/gn/ninja_copy_target_writer.cc
+++ b/src/gn/ninja_copy_target_writer.cc
@@ -22,7 +22,8 @@
NinjaCopyTargetWriter::~NinjaCopyTargetWriter() = default;
void NinjaCopyTargetWriter::Run() {
- const Tool* copy_tool = target_->toolchain()->GetTool(GeneralTool::kGeneralToolCopy);
+ const Tool* copy_tool =
+ target_->toolchain()->GetTool(GeneralTool::kGeneralToolCopy);
if (!copy_tool) {
g_scheduler->FailWithError(Err(
nullptr, "Copy tool not defined",
@@ -33,7 +34,8 @@
return;
}
- const Tool* stamp_tool = target_->toolchain()->GetTool(GeneralTool::kGeneralToolStamp);
+ const Tool* stamp_tool =
+ target_->toolchain()->GetTool(GeneralTool::kGeneralToolStamp);
if (!stamp_tool) {
g_scheduler->FailWithError(Err(
nullptr, "Copy tool not defined",
@@ -66,8 +68,8 @@
<< "Should have one entry exactly.";
const SubstitutionPattern& output_subst = output_subst_list.list()[0];
- std::string tool_name = GetNinjaRulePrefixForToolchain(settings_) +
- GeneralTool::kGeneralToolCopy;
+ std::string tool_name =
+ GetNinjaRulePrefixForToolchain(settings_) + GeneralTool::kGeneralToolCopy;
size_t num_stamp_uses = target_->sources().size();
std::vector<OutputFile> input_deps = WriteInputDepsStampAndGetDep(
diff --git a/src/gn/ninja_generated_file_target_writer.cc b/src/gn/ninja_generated_file_target_writer.cc
index 1abdc05..6c157e4 100644
--- a/src/gn/ninja_generated_file_target_writer.cc
+++ b/src/gn/ninja_generated_file_target_writer.cc
@@ -56,7 +56,8 @@
base::FilePath output =
settings_->build_settings()->GetFullPath(outputs_as_sources[0]);
- ScopedTrace trace(TraceItem::TRACE_FILE_WRITE_GENERATED, outputs_as_sources[0].value());
+ ScopedTrace trace(TraceItem::TRACE_FILE_WRITE_GENERATED,
+ outputs_as_sources[0].value());
trace.SetToolchain(target_->settings()->toolchain_label());
// If this is a metadata target, populate the write value with the appropriate
@@ -69,7 +70,8 @@
contents = Value(target_->action_values().outputs().list()[0].origin(),
Value::LIST);
TargetSet targets_walked;
- ScopedTrace metadata_walk_trace(TraceItem::TRACE_WALK_METADATA, target_->label());
+ ScopedTrace metadata_walk_trace(TraceItem::TRACE_WALK_METADATA,
+ target_->label());
trace.SetToolchain(target_->settings()->toolchain_label());
if (!target_->GetMetadata(target_->data_keys(), target_->walk_keys(),
target_->rebase(), /*deps_only = */ true,
diff --git a/src/gn/ninja_rust_binary_target_writer_unittest.cc b/src/gn/ninja_rust_binary_target_writer_unittest.cc
index 9a21c1f..706f075 100644
--- a/src/gn/ninja_rust_binary_target_writer_unittest.cc
+++ b/src/gn/ninja_rust_binary_target_writer_unittest.cc
@@ -88,7 +88,8 @@
Err err;
TestWithScope setup;
- Target private_rlib(setup.settings(), Label(SourceDir("//baz/"), "privatelib"));
+ Target private_rlib(setup.settings(),
+ Label(SourceDir("//baz/"), "privatelib"));
private_rlib.set_output_type(Target::RUST_LIBRARY);
private_rlib.visibility().SetPublic();
SourceFile bazlib("//baz/lib.rs");
@@ -275,11 +276,13 @@
Err err;
TestWithScope setup;
- Target private_inside_dylib(setup.settings(), Label(SourceDir("//faz/"), "private_inside"));
+ Target private_inside_dylib(setup.settings(),
+ Label(SourceDir("//faz/"), "private_inside"));
private_inside_dylib.set_output_type(Target::RUST_LIBRARY);
private_inside_dylib.visibility().SetPublic();
SourceFile fazlib("//faz/lib.rs");
- private_inside_dylib.sources().push_back(SourceFile("//faz/private_inside.rs"));
+ private_inside_dylib.sources().push_back(
+ SourceFile("//faz/private_inside.rs"));
private_inside_dylib.sources().push_back(fazlib);
private_inside_dylib.source_types_used().Set(SourceFile::SOURCE_RS);
private_inside_dylib.rust_values().set_crate_root(fazlib);
@@ -400,7 +403,8 @@
EXPECT_EQ(expected, out_str) << expected << "\n" << out_str;
}
- Target private_dylib(setup.settings(), Label(SourceDir("//private_dylib/"), "private_dylib"));
+ Target private_dylib(setup.settings(),
+ Label(SourceDir("//private_dylib/"), "private_dylib"));
private_dylib.set_output_type(Target::SHARED_LIBRARY);
private_dylib.visibility().SetPublic();
SourceFile private_dyliblib("//private_dylib/lib.rs");
@@ -1046,7 +1050,6 @@
target.SetToolchain(setup.toolchain());
ASSERT_TRUE(target.OnResolved(&err));
-
std::ostringstream out;
NinjaRustBinaryTargetWriter writer(&target, out);
writer.Run();
@@ -1169,8 +1172,7 @@
target.sources().push_back(main);
target.source_types_used().Set(SourceFile::SOURCE_RS);
target.set_output_dir(SourceDir("//out/Debug/foo/"));
- target.config_values().libs().push_back(
- LibFile(SourceFile("//dir1/ar.a")));
+ target.config_values().libs().push_back(LibFile(SourceFile("//dir1/ar.a")));
target.config_values().libs().push_back(LibFile("binlib"));
target.config_values().lib_dirs().push_back(SourceDir("//binlibdir/"));
target.config_values().framework_dirs().push_back(SourceDir("//binfwdir/"));
@@ -1815,7 +1817,7 @@
ASSERT_TRUE(rlib_pub.OnResolved(&err));
Target rlib_priv(setup.settings(),
- Label(SourceDir("//private/"), "behind_sourceset_private"));
+ Label(SourceDir("//private/"), "behind_sourceset_private"));
rlib_priv.set_output_type(Target::RUST_LIBRARY);
rlib_priv.visibility().SetPublic();
SourceFile rlib_priv_root("//private/lib.rs");
diff --git a/src/gn/ninja_toolchain_writer.cc b/src/gn/ninja_toolchain_writer.cc
index 4ad17ca..917d068 100644
--- a/src/gn/ninja_toolchain_writer.cc
+++ b/src/gn/ninja_toolchain_writer.cc
@@ -63,7 +63,8 @@
const std::vector<NinjaWriter::TargetRulePair>& rules) {
base::FilePath ninja_file(settings->build_settings()->GetFullPath(
GetNinjaFileForToolchain(settings)));
- ScopedTrace trace(TraceItem::TRACE_FILE_WRITE_NINJA, FilePathToUTF8(ninja_file));
+ ScopedTrace trace(TraceItem::TRACE_FILE_WRITE_NINJA,
+ FilePathToUTF8(ninja_file));
base::CreateDirectory(ninja_file.DirName());
@@ -136,7 +137,7 @@
const SubstitutionPattern& command,
const EscapeOptions& options) {
CHECK(!command.empty()) << "Command should not be empty";
- out_ << kIndent << name << " = " ;
+ out_ << kIndent << name << " = ";
if (!launcher.empty())
out_ << launcher << " ";
SubstitutionWriter::WriteWithNinjaVariables(command, options, out_);
diff --git a/src/gn/ninja_toolchain_writer_unittest.cc b/src/gn/ninja_toolchain_writer_unittest.cc
index 12eeb00..863c174 100644
--- a/src/gn/ninja_toolchain_writer_unittest.cc
+++ b/src/gn/ninja_toolchain_writer_unittest.cc
@@ -33,7 +33,8 @@
EXPECT_EQ(
"rule prefix_cxx\n"
- " command = launcher c++ ${in} ${cflags} ${cflags_cc} ${defines} ${include_dirs} "
+ " command = launcher c++ ${in} ${cflags} ${cflags_cc} ${defines} "
+ "${include_dirs} "
"-o ${out}\n",
stream.str());
}
diff --git a/src/gn/ninja_tools.cc b/src/gn/ninja_tools.cc
index 2eaf31c..dce4639 100644
--- a/src/gn/ninja_tools.cc
+++ b/src/gn/ninja_tools.cc
@@ -15,8 +15,9 @@
namespace {
-base::CommandLine CreateNinjaToolCommandLine(const base::FilePath& ninja_executable,
- const std::string& tool) {
+base::CommandLine CreateNinjaToolCommandLine(
+ const base::FilePath& ninja_executable,
+ const std::string& tool) {
base::CommandLine cmdline(ninja_executable);
cmdline.SetParseSwitches(false);
cmdline.AppendArg("-t");
diff --git a/src/gn/ninja_tools.h b/src/gn/ninja_tools.h
index 9721296..fc774a5 100644
--- a/src/gn/ninja_tools.h
+++ b/src/gn/ninja_tools.h
@@ -41,4 +41,4 @@
const base::FilePath& build_dir,
Err* err);
-#endif // TOOLS_GN_NINJA_TOOLS_H_
+#endif // TOOLS_GN_NINJA_TOOLS_H_
diff --git a/src/gn/ninja_writer.cc b/src/gn/ninja_writer.cc
index 999718a..b6a03a3 100644
--- a/src/gn/ninja_writer.cc
+++ b/src/gn/ninja_writer.cc
@@ -32,7 +32,7 @@
Err* err) {
if (per_toolchain_rules.empty()) {
*err = Err(Location(), "No targets.",
- "I could not find any targets to write, so I'm doing nothing.");
+ "I could not find any targets to write, so I'm doing nothing.");
return false;
}
diff --git a/src/gn/operators_unittest.cc b/src/gn/operators_unittest.cc
index 415596c..6420aad 100644
--- a/src/gn/operators_unittest.cc
+++ b/src/gn/operators_unittest.cc
@@ -40,9 +40,7 @@
const std::string& help) const override {
return Err(this, msg);
}
- base::Value GetJSONNode() const override {
- return base::Value();
- }
+ base::Value GetJSONNode() const override { return base::Value(); }
private:
Value value_;
diff --git a/src/gn/parse_tree.cc b/src/gn/parse_tree.cc
index 0f1c27e..4041781 100644
--- a/src/gn/parse_tree.cc
+++ b/src/gn/parse_tree.cc
@@ -258,12 +258,12 @@
std::unique_ptr<ParseNode> ParseNode::BuildFromJSON(const base::Value& value) {
const std::string& str_type = value.FindKey(kJsonNodeType)->GetString();
-#define RETURN_IF_MATCHES_NAME(t) \
- do { \
- if (str_type == t::kDumpNodeName) { \
- return t::NewFromJSON(value); \
- } \
- } while(0)
+#define RETURN_IF_MATCHES_NAME(t) \
+ do { \
+ if (str_type == t::kDumpNodeName) { \
+ return t::NewFromJSON(value); \
+ } \
+ } while (0)
RETURN_IF_MATCHES_NAME(AccessorNode);
RETURN_IF_MATCHES_NAME(BinaryOpNode);
@@ -335,7 +335,7 @@
if (!child || !child->is_list()) { \
return nullptr; \
} \
- (void)(0) // this is to supress extra semicolon warning.
+ (void)(0) // this is to supress extra semicolon warning.
// static
std::unique_ptr<AccessorNode> AccessorNode::NewFromJSON(
diff --git a/src/gn/rust_project_writer_helpers.h b/src/gn/rust_project_writer_helpers.h
index 31efd40..3073fd5 100644
--- a/src/gn/rust_project_writer_helpers.h
+++ b/src/gn/rust_project_writer_helpers.h
@@ -154,5 +154,4 @@
const std::string& prefix,
const std::vector<std::string>& args);
-
#endif // TOOLS_GN_RUST_PROJECT_WRITER_HELPERS_H_
diff --git a/src/gn/rust_project_writer_unittest.cc b/src/gn/rust_project_writer_unittest.cc
index 81b24b0..f0b806b 100644
--- a/src/gn/rust_project_writer_unittest.cc
+++ b/src/gn/rust_project_writer_unittest.cc
@@ -3,8 +3,8 @@
// found in the LICENSE file.
#include "gn/rust_project_writer.h"
-#include "base/strings/string_util.h"
#include "base/files/file_path.h"
+#include "base/strings/string_util.h"
#include "gn/filesystem_utils.h"
#include "gn/substitution_list.h"
#include "gn/target.h"
@@ -13,9 +13,9 @@
#include "util/build_config.h"
#include "util/test/test.h"
-
-static void ExpectEqOrShowDiff(const char* expected, const std::string& actual) {
- if(expected != actual) {
+static void ExpectEqOrShowDiff(const char* expected,
+ const std::string& actual) {
+ if (expected != actual) {
printf("\nExpected: >>>\n%s<<<\n", expected);
printf(" Actual: >>>\n%s<<<\n", actual.c_str());
}
diff --git a/src/gn/rust_substitution_type.cc b/src/gn/rust_substitution_type.cc
index 5423d0d..ca62e30 100644
--- a/src/gn/rust_substitution_type.cc
+++ b/src/gn/rust_substitution_type.cc
@@ -7,14 +7,14 @@
#include <stddef.h>
#include <stdlib.h>
+#include "gn/c_substitution_type.h"
#include "gn/err.h"
#include "gn/substitution_type.h"
-#include "gn/c_substitution_type.h"
const SubstitutionTypes RustSubstitutions = {
- &kRustSubstitutionCrateName, &kRustSubstitutionCrateType,
- &kRustSubstitutionRustDeps, &kRustSubstitutionRustFlags,
- &kRustSubstitutionRustEnv, &kRustSubstitutionExterns,
+ &kRustSubstitutionCrateName, &kRustSubstitutionCrateType,
+ &kRustSubstitutionRustDeps, &kRustSubstitutionRustFlags,
+ &kRustSubstitutionRustEnv, &kRustSubstitutionExterns,
&kRustSubstitutionSources,
};
@@ -49,6 +49,5 @@
}
bool IsValidRustLinkerSubstitution(const Substitution* type) {
- return IsValidRustSubstitution(type) ||
- type == &CSubstitutionLdFlags;
+ return IsValidRustSubstitution(type) || type == &CSubstitutionLdFlags;
}
diff --git a/src/gn/rust_tool.cc b/src/gn/rust_tool.cc
index 65ed27a..5b5cc62 100644
--- a/src/gn/rust_tool.cc
+++ b/src/gn/rust_tool.cc
@@ -41,8 +41,8 @@
}
bool RustTool::MayLink() const {
- return name_ == kRsToolBin || name_ == kRsToolCDylib || name_ == kRsToolDylib ||
- name_ == kRsToolMacro;
+ return name_ == kRsToolBin || name_ == kRsToolCDylib ||
+ name_ == kRsToolDylib || name_ == kRsToolMacro;
}
void RustTool::SetComplete() {
diff --git a/src/gn/rust_tool.h b/src/gn/rust_tool.h
index 341c48f..857e205 100644
--- a/src/gn/rust_tool.h
+++ b/src/gn/rust_tool.h
@@ -44,7 +44,9 @@
std::string_view GetSysroot() const;
- const std::string& dynamic_link_switch() const { return dynamic_link_switch_; }
+ const std::string& dynamic_link_switch() const {
+ return dynamic_link_switch_;
+ }
void set_dynamic_link_switch(std::string s) {
DCHECK(!complete_);
dynamic_link_switch_ = std::move(s);
diff --git a/src/gn/rust_values.cc b/src/gn/rust_values.cc
index 3043458..a6da4ee 100644
--- a/src/gn/rust_values.cc
+++ b/src/gn/rust_values.cc
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "gn/rust_tool.h"
#include "gn/rust_values.h"
+#include "gn/rust_tool.h"
#include "gn/target.h"
RustValues::RustValues() : crate_type_(RustValues::CRATE_AUTO) {}
@@ -27,7 +27,7 @@
CrateType crate_type = target->rust_values().crate_type();
if (crate_type != CRATE_AUTO) {
- return crate_type;
+ return crate_type;
}
switch (target->output_type()) {
@@ -49,6 +49,6 @@
// static
bool RustValues::IsRustLibrary(const Target* target) {
return target->output_type() == Target::RUST_LIBRARY ||
- InferredCrateType(target) == CRATE_DYLIB ||
- InferredCrateType(target) == CRATE_PROC_MACRO;
+ InferredCrateType(target) == CRATE_DYLIB ||
+ InferredCrateType(target) == CRATE_PROC_MACRO;
}
diff --git a/src/gn/scope.cc b/src/gn/scope.cc
index d07426a..0efe1f9 100644
--- a/src/gn/scope.cc
+++ b/src/gn/scope.cc
@@ -259,11 +259,9 @@
"You set the variable \"" + std::string(pair.first) +
"\" here and it was unused before it went\nout of scope.";
-
// Gather the template invocations that led up to this scope.
auto entries = GetTemplateInvocationEntries();
if (entries.size() != 0) {
-
help.append("\n\nVia these template invocations:\n");
for (const auto& entry : entries) {
help.append(" " + entry.Describe() + "\n");
@@ -583,7 +581,8 @@
std::move(location)});
}
-const Scope::TemplateInvocationEntry* Scope::FindTemplateInvocationEntry() const {
+const Scope::TemplateInvocationEntry* Scope::FindTemplateInvocationEntry()
+ const {
if (template_invocation_entry_)
return template_invocation_entry_.get();
if (const Scope* scope = containing())
@@ -593,7 +592,6 @@
void Scope::AppendTemplateInvocationEntries(
std::vector<TemplateInvocationEntry>* out) const {
-
const Value* invoker = GetValue("invoker");
if (invoker && invoker->type() == Value::SCOPE)
invoker->scope_value()->AppendTemplateInvocationEntries(out);
diff --git a/src/gn/scope.h b/src/gn/scope.h
index eb38202..b852941 100644
--- a/src/gn/scope.h
+++ b/src/gn/scope.h
@@ -367,7 +367,8 @@
// Walk up the containing scopes and any "invoker" Value scopes to gather any
// previous template invocations.
- void AppendTemplateInvocationEntries(std::vector<TemplateInvocationEntry>* out) const;
+ void AppendTemplateInvocationEntries(
+ std::vector<TemplateInvocationEntry>* out) const;
// Walk up the containing scopes to find a TemplateInvocationEntry.
const TemplateInvocationEntry* FindTemplateInvocationEntry() const;
diff --git a/src/gn/source_file.cc b/src/gn/source_file.cc
index f9d816a..319adde 100644
--- a/src/gn/source_file.cc
+++ b/src/gn/source_file.cc
@@ -61,7 +61,7 @@
case TAG2('g', 'o'):
return SourceFile::SOURCE_GO; // .go
case TAG2('h', 'h'):
- return SourceFile::SOURCE_H; // .hh
+ return SourceFile::SOURCE_H; // .hh
case TAG2('m', 'm'):
return SourceFile::SOURCE_MM; // .mm
case TAG2('r', 'c'):
diff --git a/src/gn/standard_out.cc b/src/gn/standard_out.cc
index 1290b82..1d43e05 100644
--- a/src/gn/standard_out.cc
+++ b/src/gn/standard_out.cc
@@ -130,8 +130,8 @@
::SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_GREEN);
break;
case DECORATION_MAGENTA:
- ::SetConsoleTextAttribute(hstdout,
- FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
+ ::SetConsoleTextAttribute(
+ hstdout, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
break;
}
}
diff --git a/src/gn/string_atom.cc b/src/gn/string_atom.cc
index 5701a96..5c3f73f 100644
--- a/src/gn/string_atom.cc
+++ b/src/gn/string_atom.cc
@@ -219,7 +219,8 @@
StringAtom::StringAtom(std::string_view str) noexcept
#ifndef OS_ZOS
- : value_(*s_local_cache.find(str)) {}
+ : value_(*s_local_cache.find(str)){}
#else
- : value_(*s_local_cache->find(str)) {}
+ : value_(*s_local_cache->find(str)) {
+}
#endif
diff --git a/src/gn/substitution_list.cc b/src/gn/substitution_list.cc
index aed66a0..2a3e24c 100644
--- a/src/gn/substitution_list.cc
+++ b/src/gn/substitution_list.cc
@@ -62,8 +62,8 @@
Err err;
SubstitutionList result;
- CHECK(result.Parse(input_strings, nullptr, &err))
- << err.message() << "\n" << err.help_text();
+ CHECK(result.Parse(input_strings, nullptr, &err)) << err.message() << "\n"
+ << err.help_text();
return result;
}
diff --git a/src/gn/substitution_pattern.cc b/src/gn/substitution_pattern.cc
index 35c14fa..3692184 100644
--- a/src/gn/substitution_pattern.cc
+++ b/src/gn/substitution_pattern.cc
@@ -93,8 +93,8 @@
SubstitutionPattern SubstitutionPattern::MakeForTest(const char* str) {
Err err;
SubstitutionPattern pattern;
- CHECK(pattern.Parse(str, nullptr, &err))
- << err.message() << "\n" << err.help_text();
+ CHECK(pattern.Parse(str, nullptr, &err)) << err.message() << "\n"
+ << err.help_text();
return pattern;
}
diff --git a/src/gn/substitution_pattern.h b/src/gn/substitution_pattern.h
index 48f4eb7..f1bc433 100644
--- a/src/gn/substitution_pattern.h
+++ b/src/gn/substitution_pattern.h
@@ -20,7 +20,8 @@
public:
struct Subrange {
Subrange();
- explicit Subrange(const Substitution* t, const std::string& l = std::string());
+ explicit Subrange(const Substitution* t,
+ const std::string& l = std::string());
~Subrange();
inline bool operator==(const Subrange& other) const {
diff --git a/src/gn/target.cc b/src/gn/target.cc
index a6440f1..500dda5 100644
--- a/src/gn/target.cc
+++ b/src/gn/target.cc
@@ -45,8 +45,8 @@
Err MakeTestOnlyError(const Item* from, const Item* to) {
bool with_toolchain = from->settings()->ShouldShowToolchain({
- &from->label(),
- &to->label(),
+ &from->label(),
+ &to->label(),
});
return Err(
from->defined_from(), "Test-only dependency not allowed.",
@@ -933,9 +933,9 @@
if (config_values_->precompiled_header() != cur.precompiled_header() ||
config_values_->precompiled_source() != cur.precompiled_source()) {
bool with_toolchain = settings()->ShouldShowToolchain({
- &label(),
- pch_header_settings_from,
- &config->label(),
+ &label(),
+ pch_header_settings_from,
+ &config->label(),
});
*err = Err(
defined_from(), "Precompiled header setting conflict.",
diff --git a/src/gn/test_with_scope.cc b/src/gn/test_with_scope.cc
index 638bf32..21a4c22 100644
--- a/src/gn/test_with_scope.cc
+++ b/src/gn/test_with_scope.cc
@@ -307,7 +307,8 @@
staticlib_tool->set_default_output_extension(".a");
staticlib_tool->set_outputs(SubstitutionList::MakeForTest(
"{{target_out_dir}}/{{target_output_name}}{{output_extension}}"));
- static_cast<RustTool*>(staticlib_tool.get())->set_dynamic_link_switch("-Clink-arg=-Balternative-dynamic");
+ static_cast<RustTool*>(staticlib_tool.get())
+ ->set_dynamic_link_switch("-Clink-arg=-Balternative-dynamic");
toolchain->SetTool(std::move(staticlib_tool));
toolchain->ToolchainSetupComplete();
@@ -318,8 +319,8 @@
Err err;
SubstitutionPattern command;
command.Parse(cmd, nullptr, &err);
- CHECK(!err.has_error()) << "Couldn't parse \"" << cmd << "\", "
- << "got " << err.message();
+ CHECK(!err.has_error()) << "Couldn't parse \"" << cmd << "\", " << "got "
+ << err.message();
tool->set_command(command);
}
diff --git a/src/gn/tokenizer_unittest.cc b/src/gn/tokenizer_unittest.cc
index e3e0542..d32cc31 100644
--- a/src/gn/tokenizer_unittest.cc
+++ b/src/gn/tokenizer_unittest.cc
@@ -234,4 +234,3 @@
EXPECT_EQ(results[3].type(), Token::LEFT_BRACE);
EXPECT_EQ(results[3].value(), "{");
}
-
diff --git a/src/gn/variables.cc b/src/gn/variables.cc
index 4013e16..9cc3398 100644
--- a/src/gn/variables.cc
+++ b/src/gn/variables.cc
@@ -1436,8 +1436,7 @@
Specifies additional directories passed to the linker for searching for the
required libraries. If an item is not an absolute path, it will be treated as
being relative to the current build file.
-)" COMMON_LIB_INHERITANCE_HELP COMMON_ORDERING_HELP
- LIBS_AND_LIB_DIRS_ORDERING_HELP
+)" COMMON_LIB_INHERITANCE_HELP COMMON_ORDERING_HELP LIBS_AND_LIB_DIRS_ORDERING_HELP
R"(
Example
diff --git a/src/gn/visual_studio_writer.cc b/src/gn/visual_studio_writer.cc
index 31c6e0a..86fb2a1 100644
--- a/src/gn/visual_studio_writer.cc
+++ b/src/gn/visual_studio_writer.cc
@@ -677,9 +677,8 @@
project.SubElement("Target", XmlAttributes("Name", "Clean"));
clean->SubElement(
"Exec",
- XmlAttributes("Command",
- "call " + ninja_exe + " -C $(OutDir) -tclean " +
- ninja_target));
+ XmlAttributes("Command", "call " + ninja_exe +
+ " -C $(OutDir) -tclean " + ninja_target));
}
return true;
diff --git a/src/gn/xcode_writer.cc b/src/gn/xcode_writer.cc
index 2673d3c..9577295 100644
--- a/src/gn/xcode_writer.cc
+++ b/src/gn/xcode_writer.cc
@@ -538,8 +538,7 @@
break;
}
- out << "</dict>\n"
- << "</plist>\n";
+ out << "</dict>\n" << "</plist>\n";
return storage.WriteToFileIfChanged(build_settings_->GetFullPath(source_file),
err);
@@ -1039,8 +1038,7 @@
<< "\tobjects = {\n";
for (auto& pair : CollectPBXObjectsPerClass(&project_)) {
- out << "\n"
- << "/* Begin " << ToString(pair.first) << " section */\n";
+ out << "\n" << "/* Begin " << ToString(pair.first) << " section */\n";
std::sort(pair.second.begin(), pair.second.end(),
[](const PBXObject* a, const PBXObject* b) {
return a->id() < b->id();
diff --git a/src/util/build_config.h b/src/util/build_config.h
index 668518b..52c4f21 100644
--- a/src/util/build_config.h
+++ b/src/util/build_config.h
@@ -76,7 +76,7 @@
#if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) || \
defined(OS_FREEBSD) || defined(OS_LINUX) || defined(OS_MACOSX) || \
defined(OS_NACL) || defined(OS_NETBSD) || defined(OS_OPENBSD) || \
- defined(OS_QNX) || defined(OS_SOLARIS) || defined(OS_HAIKU) || \
+ defined(OS_QNX) || defined(OS_SOLARIS) || defined(OS_HAIKU) || \
defined(OS_MSYS) || defined(OS_ZOS) || defined(OS_SERENITY)
#define OS_POSIX 1
#endif
diff --git a/src/util/exe_path.cc b/src/util/exe_path.cc
index 7ae9024..55ad27e 100644
--- a/src/util/exe_path.cc
+++ b/src/util/exe_path.cc
@@ -97,7 +97,7 @@
#elif defined(OS_SOLARIS)
base::FilePath GetExePath() {
- const char *raw = getexecname();
+ const char* raw = getexecname();
if (raw == NULL) {
return base::FilePath();
}
diff --git a/src/util/msg_loop.cc b/src/util/msg_loop.cc
index 1797c90..e614b66 100644
--- a/src/util/msg_loop.cc
+++ b/src/util/msg_loop.cc
@@ -15,7 +15,7 @@
__tlssim<MsgLoop*> __g_current_impl(nullptr);
#define g_current (*__g_current_impl.access())
#endif
-}
+} // namespace
MsgLoop::MsgLoop() {
DCHECK(g_current == nullptr);
diff --git a/src/util/test/test.h b/src/util/test/test.h
index d3fc056..b598fd9 100644
--- a/src/util/test/test.h
+++ b/src/util/test/test.h
@@ -84,15 +84,19 @@
void RegisterTest(testing::Test* (*)(), const char*);
-#define TEST_F_(x, y, name) \
- struct y : public x { \
- static testing::Test* Create() { return testing::g_current_test = new y; } \
- virtual void Run(); \
- }; \
- struct Register##y { \
- Register##y() { RegisterTest(y::Create, name); } \
- }; \
- Register##y g_register_##y; \
+#define TEST_F_(x, y, name) \
+ struct y : public x { \
+ static testing::Test* Create() { \
+ return testing::g_current_test = new y; \
+ } \
+ virtual void Run(); \
+ }; \
+ struct Register##y { \
+ Register##y() { \
+ RegisterTest(y::Create, name); \
+ } \
+ }; \
+ Register##y g_register_##y; \
void y::Run()
#define TEST_F(x, y) TEST_F_(x, x##y, #x "." #y)
diff --git a/tools/run_formatter.sh b/tools/run_formatter.sh
new file mode 100755
index 0000000..d7197b9
--- /dev/null
+++ b/tools/run_formatter.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+cd $(dirname $(dirname $0))
+
+ensure_file=$(mktemp)
+
+# https://chrome-infra-packages.appspot.com/p/fuchsia/third_party/clang
+echo 'fuchsia/third_party/clang/${platform} integration' > $ensure_file
+cipd ensure -ensure-file $ensure_file -root clang
+
+git ls-files | egrep '\.(h|cc)$' | fgrep -v 'third_party' |\
+ xargs ./clang/bin/clang-format -i