Commit 238f0a02 authored by vmpstr's avatar vmpstr Committed by Commit bot

tools/gn: Change auto to not deduce raw pointers.

This patch updates the code to prevent auto deducing to a raw pointer.

R=brettw@chromium.org, danakj, dcheng
BUG=554600

Review-Url: https://codereview.chromium.org/2105553005
Cr-Commit-Position: refs/heads/master@{#405292}
parent 8b05f575
......@@ -33,7 +33,7 @@ typedef BuilderRecord::BuilderRecordSet BuilderRecordSet;
bool RecursiveFindCycle(const BuilderRecord* search_in,
std::vector<const BuilderRecord*>* path) {
path->push_back(search_in);
for (const auto& cur : search_in->unresolved_deps()) {
for (auto* cur : search_in->unresolved_deps()) {
std::vector<const BuilderRecord*>::iterator found =
std::find(path->begin(), path->end(), cur);
if (found != path->end()) {
......@@ -182,7 +182,7 @@ bool Builder::CheckForBadItems(Err* err) const {
bad_records.push_back(src);
// Check dependencies.
for (const auto& dest : src->unresolved_deps()) {
for (auto* dest : src->unresolved_deps()) {
if (!dest->item()) {
depstring += src->label().GetUserVisibleName(true) +
"\n needs " + dest->label().GetUserVisibleName(true) + "\n";
......@@ -204,7 +204,7 @@ bool Builder::CheckForBadItems(Err* err) const {
// Something's very wrong, just dump out the bad nodes.
depstring = "I have no idea what went wrong, but these are unresolved, "
"possibly due to an\ninternal error:";
for (const auto& bad_record : bad_records) {
for (auto* bad_record : bad_records) {
depstring += "\n\"" +
bad_record->label().GetUserVisibleName(false) + "\"";
}
......@@ -252,7 +252,7 @@ bool Builder::ConfigDefined(BuilderRecord* record, Err* err) {
// anything they depend on is actually written, the "generate" flag isn't
// relevant and means extra book keeping. Just force load any deps of this
// config.
for (const auto& cur : record->all_deps())
for (auto* cur : record->all_deps())
ScheduleItemLoadIfNecessary(cur);
return true;
......@@ -408,7 +408,7 @@ void Builder::RecursiveSetShouldGenerate(BuilderRecord* record,
return; // Already set.
record->set_should_generate(true);
for (const auto& cur : record->all_deps()) {
for (auto* cur : record->all_deps()) {
if (!cur->should_generate()) {
ScheduleItemLoadIfNecessary(cur);
RecursiveSetShouldGenerate(cur, false);
......
......@@ -100,7 +100,7 @@ int RunLs(const std::vector<std::string>& args) {
matches = setup->builder()->GetAllResolvedTargets();
} else {
// List all resolved targets in the default toolchain.
for (const auto& target : setup->builder()->GetAllResolvedTargets()) {
for (auto* target : setup->builder()->GetAllResolvedTargets()) {
if (target->settings()->is_default())
matches.push_back(target);
}
......
......@@ -32,7 +32,7 @@ typedef std::multimap<const Target*, const Target*> DepMap;
// Populates the reverse dependency map for the targets in the Setup.
void FillDepMap(Setup* setup, DepMap* dep_map) {
for (const auto& target : setup->builder()->GetAllResolvedTargets()) {
for (auto* target : setup->builder()->GetAllResolvedTargets()) {
for (const auto& dep_pair : target->GetDeps(Target::DEPS_ALL))
dep_map->insert(std::make_pair(dep_pair.ptr, target));
}
......@@ -160,7 +160,7 @@ void GetTargetsContainingFile(Setup* setup,
bool all_toolchains,
UniqueVector<const Target*>* matches) {
Label default_toolchain = setup->loader()->default_toolchain_label();
for (const auto& target : all_targets) {
for (auto* target : all_targets) {
if (!all_toolchains) {
// Only check targets in the default toolchain.
if (target->label().GetToolchainLabel() != default_toolchain)
......@@ -189,7 +189,7 @@ void GetTargetsReferencingConfig(Setup* setup,
bool all_toolchains,
UniqueVector<const Target*>* matches) {
Label default_toolchain = setup->loader()->default_toolchain_label();
for (const auto& target : all_targets) {
for (auto* target : all_targets) {
if (!all_toolchains) {
// Only check targets in the default toolchain.
if (target->label().GetToolchainLabel() != default_toolchain)
......@@ -442,7 +442,7 @@ int RunRefs(const std::vector<std::string>& args) {
GetTargetsContainingFile(setup, all_targets, file, all_toolchains,
&explicit_target_matches);
}
for (const auto& config : config_matches) {
for (auto* config : config_matches) {
GetTargetsReferencingConfig(setup, all_targets, config, all_toolchains,
&explicit_target_matches);
}
......
......@@ -298,7 +298,7 @@ void PrintTargetsAsLabels(bool indent,
const std::vector<const Target*>& targets) {
// Putting the labels into a set automatically sorts them for us.
std::set<Label> unique_labels;
for (const auto& target : targets)
for (auto* target : targets)
unique_labels.insert(target->label());
// Grab the label of the default toolchain from the first target.
......@@ -446,7 +446,7 @@ bool ResolveFromCommandLineInput(
void FilterTargetsByPatterns(const std::vector<const Target*>& input,
const std::vector<LabelPattern>& filter,
std::vector<const Target*>* output) {
for (const auto& target : input) {
for (auto* target : input) {
for (const auto& pattern : filter) {
if (pattern.Matches(target->label())) {
output->push_back(target);
......@@ -459,7 +459,7 @@ void FilterTargetsByPatterns(const std::vector<const Target*>& input,
void FilterTargetsByPatterns(const std::vector<const Target*>& input,
const std::vector<LabelPattern>& filter,
UniqueVector<const Target*>* output) {
for (const auto& target : input) {
for (auto* target : input) {
for (const auto& pattern : filter) {
if (pattern.Matches(target->label())) {
output->push_back(target);
......
......@@ -92,7 +92,7 @@ Value RunGetTargetOutputs(Scope* scope,
*err = Err(function, "No targets defined in this context.");
return Value();
}
for (const auto& item : *collector) {
for (auto* item : *collector) {
if (item->label() != label)
continue;
......
......@@ -129,7 +129,7 @@ HeaderChecker::HeaderChecker(const BuildSettings* build_settings,
const std::vector<const Target*>& targets)
: main_loop_(base::MessageLoop::current()),
build_settings_(build_settings) {
for (const auto& target : targets)
for (auto* target : targets)
AddTargetToFileMap(target, &file_map_);
}
......@@ -140,7 +140,7 @@ bool HeaderChecker::Run(const std::vector<const Target*>& to_check,
bool force_check,
std::vector<Err>* errors) {
FileMap files_to_check;
for (const auto& check : to_check)
for (auto* check : to_check)
AddTargetToFileMap(check, &files_to_check);
RunCheckOverFiles(files_to_check, force_check);
......@@ -567,9 +567,9 @@ Err HeaderChecker::MakeUnreachableError(
std::string msg = "It is not in any dependency of\n " +
from_target->label().GetUserVisibleName(include_toolchain);
msg += "\nThe include file is in the target(s):\n";
for (const auto& target : targets_with_matching_toolchains)
for (auto* target : targets_with_matching_toolchains)
msg += " " + target->label().GetUserVisibleName(include_toolchain) + "\n";
for (const auto& target : targets_with_other_toolchains)
for (auto* target : targets_with_other_toolchains)
msg += " " + target->label().GetUserVisibleName(include_toolchain) + "\n";
if (targets_with_other_toolchains.size() +
targets_with_matching_toolchains.size() > 1)
......
......@@ -158,7 +158,7 @@ TEST_F(InputConversionTest, ValueError) {
"[rebase_path(\"//\")]",
};
for (auto test : kTests) {
for (auto* test : kTests) {
Err err;
std::string input(test);
Value result = ConvertInputToValue(settings(), input, nullptr,
......
......@@ -273,7 +273,7 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings,
// Pass all of the items that were defined off to the builder.
for (auto& item : collected_items) {
for (auto*& item : collected_items) {
settings->build_settings()->ItemDefined(base::WrapUnique(item));
item = nullptr;
}
......
......@@ -948,7 +948,7 @@ void NinjaBinaryTargetWriter::WriteSourceSetStamp(
DCHECK(extra_object_files.empty());
std::vector<OutputFile> order_only_deps;
for (const auto& dep : non_linkable_deps)
for (auto* dep : non_linkable_deps)
order_only_deps.push_back(dep->dependency_output_file());
WriteStampForTarget(object_files, order_only_deps);
......@@ -965,8 +965,7 @@ void NinjaBinaryTargetWriter::GetDeps(
}
// Inherited libraries.
for (const auto& inherited_target :
target_->inherited_libraries().GetOrdered()) {
for (auto* inherited_target : target_->inherited_libraries().GetOrdered()) {
ClassifyDependency(inherited_target, extra_object_files,
linkable_deps, non_linkable_deps);
}
......@@ -1029,7 +1028,7 @@ void NinjaBinaryTargetWriter::WriteOrderOnlyDependencies(
out_ << " ||";
// Non-linkable targets.
for (const auto& non_linkable_dep : non_linkable_deps) {
for (auto* non_linkable_dep : non_linkable_deps) {
out_ << " ";
path_output_.WriteFile(out_, non_linkable_dep->dependency_output_file());
}
......
......@@ -242,7 +242,7 @@ void NinjaBuildWriter::WriteAllPools() {
}
void NinjaBuildWriter::WriteSubninjas() {
for (const auto& elem : all_settings_) {
for (auto* elem : all_settings_) {
out_ << "subninja ";
path_output_.WriteFile(out_, GetNinjaFileForToolchain(elem));
out_ << std::endl;
......
......@@ -255,7 +255,7 @@ OutputFile NinjaTargetWriter::WriteInputDepsStampAndGetDep(
std::sort(
input_deps_targets.begin(), input_deps_targets.end(),
[](const Target* a, const Target* b) { return a->label() < b->label(); });
for (const auto& dep : input_deps_targets) {
for (auto* dep : input_deps_targets) {
DCHECK(!dep->dependency_output_file().value().empty());
out_ << " ";
path_output_.WriteFile(out_, dep->dependency_output_file());
......
......@@ -136,7 +136,7 @@ void NinjaToolchainWriter::WriteRulePattern(const char* name,
void NinjaToolchainWriter::WriteSubninjas() {
// Write subninja commands for each generated target.
for (const auto& target : targets_) {
for (auto* target : targets_) {
OutputFile ninja_file(target->settings()->build_settings(),
GetNinjaFileForTarget(target));
out_ << "subninja ";
......
......@@ -58,7 +58,7 @@ bool NinjaWriter::WriteToolchains(std::vector<const Settings*>* all_settings,
CategorizedMap categorized;
std::vector<const BuilderRecord*> all_records = builder_->GetAllRecords();
for (const auto& all_record : all_records) {
for (auto* all_record : all_records) {
if (all_record->type() == BuilderRecord::ITEM_TARGET &&
all_record->should_generate()) {
categorized[all_record->label().GetToolchainLabel()].push_back(
......
......@@ -225,7 +225,7 @@ TEST(ParseTree, Integers) {
"9223372036854775807", // INT64_MAX
"-9223372036854775808", // INT64_MIN
};
for (auto s : kGood) {
for (auto* s : kGood) {
TestParseInput input(std::string("x = ") + s);
EXPECT_FALSE(input.has_error());
......@@ -242,7 +242,7 @@ TEST(ParseTree, Integers) {
"9223372036854775808", // INT64_MAX + 1
"-9223372036854775809", // INT64_MIN - 1
};
for (auto s : kBad) {
for (auto* s : kBad) {
TestParseInput input(std::string("x = ") + s);
EXPECT_FALSE(input.has_error());
......
......@@ -711,7 +711,7 @@ void Parser::AssignComments(ParseNode* file) {
// Assign line comments to syntax immediately following.
int cur_comment = 0;
for (const auto& node : pre) {
for (auto* node : pre) {
const Location& start = node->GetRange().begin();
while (cur_comment < static_cast<int>(line_comment_tokens_.size())) {
if (start.byte() >= line_comment_tokens_[cur_comment].location().byte()) {
......
......@@ -69,7 +69,7 @@ Scope::~Scope() {
const Value* Scope::GetValue(const base::StringPiece& ident,
bool counts_as_used) {
// First check for programmatically-provided values.
for (const auto& provider : programmatic_providers_) {
for (auto* provider : programmatic_providers_) {
const Value* v = provider->GetProgrammaticValue(ident);
if (v)
return v;
......
......@@ -128,7 +128,7 @@ bool EnsureFileIsGeneratedByDependency(const Target* target,
return true; // Found a path.
}
if (target->output_type() == Target::CREATE_BUNDLE) {
for (const auto& dep : target->bundle_data().bundle_deps()) {
for (auto* dep : target->bundle_data().bundle_deps()) {
if (EnsureFileIsGeneratedByDependency(dep, file, false,
consider_object_files,
check_data_deps, seen_targets))
......@@ -521,7 +521,7 @@ void Target::PullRecursiveBundleData() {
bundle_data_.AddBundleData(pair.ptr);
// Recursive bundle_data informations from all dependencies.
for (const auto& target : pair.ptr->bundle_data().bundle_deps())
for (auto* target : pair.ptr->bundle_data().bundle_deps())
bundle_data_.AddBundleData(target);
}
......
......@@ -70,7 +70,7 @@ void SummarizeParses(std::vector<const TraceItem*>& loads,
out << "File parse times: (time in ms, name)\n";
std::sort(loads.begin(), loads.end(), &DurationGreater);
for (const auto& load : loads) {
for (auto* load : loads) {
out << base::StringPrintf(" %8.2f ", load->delta().InMillisecondsF());
out << load->name() << std::endl;
}
......@@ -80,7 +80,7 @@ void SummarizeCoalesced(std::vector<const TraceItem*>& items,
std::ostream& out) {
// Group by file name.
std::map<std::string, Coalesced> coalesced;
for (const auto& item : items) {
for (auto* item : items) {
Coalesced& c = coalesced[item->name()];
c.name_ptr = &item->name();
c.total_duration += item->delta().InMillisecondsF();
......@@ -186,7 +186,7 @@ std::string SummarizeTraces() {
std::vector<const TraceItem*> script_execs;
std::vector<const TraceItem*> check_headers;
int headers_checked = 0;
for (const auto& event : events) {
for (auto* event : events) {
switch (event->type()) {
case TraceItem::TRACE_FILE_PARSE:
parses.push_back(event);
......@@ -225,7 +225,7 @@ std::string SummarizeTraces() {
// parallel. Just report the total of all of them.
if (!check_headers.empty()) {
double check_headers_time = 0;
for (const auto& cur : check_headers)
for (auto* cur : check_headers)
check_headers_time += cur->delta().InMillisecondsF();
out << "Header check time: (total time in ms, files checked)\n";
......
......@@ -419,7 +419,7 @@ void XcodeWriter::WriteProjectContent(std::ostream& out, PBXProject* project) {
[](const PBXObject* a, const PBXObject* b) {
return a->id() < b->id();
});
for (const auto& object : pair.second) {
for (auto* object : pair.second) {
object->Print(out, 2);
}
out << "/* End " << ToString(pair.first) << " section */\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment