Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: tools/gn/command_refs.cc

Issue 2105553005: tools/gn: Change auto to not deduce raw pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/command_ls.cc ('k') | tools/gn/commands.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 14 matching lines...) Expand all
25 namespace { 25 namespace {
26 26
27 typedef std::set<const Target*> TargetSet; 27 typedef std::set<const Target*> TargetSet;
28 typedef std::vector<const Target*> TargetVector; 28 typedef std::vector<const Target*> TargetVector;
29 29
30 // Maps targets to the list of targets that depend on them. 30 // Maps targets to the list of targets that depend on them.
31 typedef std::multimap<const Target*, const Target*> DepMap; 31 typedef std::multimap<const Target*, const Target*> DepMap;
32 32
33 // Populates the reverse dependency map for the targets in the Setup. 33 // Populates the reverse dependency map for the targets in the Setup.
34 void FillDepMap(Setup* setup, DepMap* dep_map) { 34 void FillDepMap(Setup* setup, DepMap* dep_map) {
35 for (const auto& target : setup->builder()->GetAllResolvedTargets()) { 35 for (auto* target : setup->builder()->GetAllResolvedTargets()) {
36 for (const auto& dep_pair : target->GetDeps(Target::DEPS_ALL)) 36 for (const auto& dep_pair : target->GetDeps(Target::DEPS_ALL))
37 dep_map->insert(std::make_pair(dep_pair.ptr, target)); 37 dep_map->insert(std::make_pair(dep_pair.ptr, target));
38 } 38 }
39 } 39 }
40 40
41 // Forward declaration for function below. 41 // Forward declaration for function below.
42 size_t RecursivePrintTargetDeps(const DepMap& dep_map, 42 size_t RecursivePrintTargetDeps(const DepMap& dep_map,
43 const Target* target, 43 const Target* target,
44 TargetSet* seen_targets, 44 TargetSet* seen_targets,
45 int indent_level); 45 int indent_level);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 return false; 154 return false;
155 } 155 }
156 156
157 void GetTargetsContainingFile(Setup* setup, 157 void GetTargetsContainingFile(Setup* setup,
158 const std::vector<const Target*>& all_targets, 158 const std::vector<const Target*>& all_targets,
159 const SourceFile& file, 159 const SourceFile& file,
160 bool all_toolchains, 160 bool all_toolchains,
161 UniqueVector<const Target*>* matches) { 161 UniqueVector<const Target*>* matches) {
162 Label default_toolchain = setup->loader()->default_toolchain_label(); 162 Label default_toolchain = setup->loader()->default_toolchain_label();
163 for (const auto& target : all_targets) { 163 for (auto* target : all_targets) {
164 if (!all_toolchains) { 164 if (!all_toolchains) {
165 // Only check targets in the default toolchain. 165 // Only check targets in the default toolchain.
166 if (target->label().GetToolchainLabel() != default_toolchain) 166 if (target->label().GetToolchainLabel() != default_toolchain)
167 continue; 167 continue;
168 } 168 }
169 if (TargetContainsFile(target, file)) 169 if (TargetContainsFile(target, file))
170 matches->push_back(target); 170 matches->push_back(target);
171 } 171 }
172 } 172 }
173 173
174 bool TargetReferencesConfig(const Target* target, const Config* config) { 174 bool TargetReferencesConfig(const Target* target, const Config* config) {
175 for (const LabelConfigPair& cur : target->configs()) { 175 for (const LabelConfigPair& cur : target->configs()) {
176 if (cur.ptr == config) 176 if (cur.ptr == config)
177 return true; 177 return true;
178 } 178 }
179 for (const LabelConfigPair& cur : target->public_configs()) { 179 for (const LabelConfigPair& cur : target->public_configs()) {
180 if (cur.ptr == config) 180 if (cur.ptr == config)
181 return true; 181 return true;
182 } 182 }
183 return false; 183 return false;
184 } 184 }
185 185
186 void GetTargetsReferencingConfig(Setup* setup, 186 void GetTargetsReferencingConfig(Setup* setup,
187 const std::vector<const Target*>& all_targets, 187 const std::vector<const Target*>& all_targets,
188 const Config* config, 188 const Config* config,
189 bool all_toolchains, 189 bool all_toolchains,
190 UniqueVector<const Target*>* matches) { 190 UniqueVector<const Target*>* matches) {
191 Label default_toolchain = setup->loader()->default_toolchain_label(); 191 Label default_toolchain = setup->loader()->default_toolchain_label();
192 for (const auto& target : all_targets) { 192 for (auto* target : all_targets) {
193 if (!all_toolchains) { 193 if (!all_toolchains) {
194 // Only check targets in the default toolchain. 194 // Only check targets in the default toolchain.
195 if (target->label().GetToolchainLabel() != default_toolchain) 195 if (target->label().GetToolchainLabel() != default_toolchain)
196 continue; 196 continue;
197 } 197 }
198 if (TargetReferencesConfig(target, config)) 198 if (TargetReferencesConfig(target, config))
199 matches->push_back(target); 199 matches->push_back(target);
200 } 200 }
201 } 201 }
202 202
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // target_matches, however, since these targets should actually be listed in 435 // target_matches, however, since these targets should actually be listed in
436 // the output, while for normal targets you don't want to see the inputs, 436 // the output, while for normal targets you don't want to see the inputs,
437 // only what refers to them. 437 // only what refers to them.
438 std::vector<const Target*> all_targets = 438 std::vector<const Target*> all_targets =
439 setup->builder()->GetAllResolvedTargets(); 439 setup->builder()->GetAllResolvedTargets();
440 UniqueVector<const Target*> explicit_target_matches; 440 UniqueVector<const Target*> explicit_target_matches;
441 for (const auto& file : file_matches) { 441 for (const auto& file : file_matches) {
442 GetTargetsContainingFile(setup, all_targets, file, all_toolchains, 442 GetTargetsContainingFile(setup, all_targets, file, all_toolchains,
443 &explicit_target_matches); 443 &explicit_target_matches);
444 } 444 }
445 for (const auto& config : config_matches) { 445 for (auto* config : config_matches) {
446 GetTargetsReferencingConfig(setup, all_targets, config, all_toolchains, 446 GetTargetsReferencingConfig(setup, all_targets, config, all_toolchains,
447 &explicit_target_matches); 447 &explicit_target_matches);
448 } 448 }
449 449
450 // Tell the user if their input matches no files or labels. We need to check 450 // Tell the user if their input matches no files or labels. We need to check
451 // both that it matched no targets and no configs. File input will already 451 // both that it matched no targets and no configs. File input will already
452 // have been converted to targets at this point. Configs will have been 452 // have been converted to targets at this point. Configs will have been
453 // converted to targets also, but there could be no targets referencing the 453 // converted to targets also, but there could be no targets referencing the
454 // config, which is different than no config with that name. 454 // config, which is different than no config with that name.
455 bool quiet = cmdline->HasSwitch("q"); 455 bool quiet = cmdline->HasSwitch("q");
(...skipping 18 matching lines...) Expand all
474 474
475 // If you ask for the references of a valid target, but that target has 475 // If you ask for the references of a valid target, but that target has
476 // nothing referencing it, we'll get here without having printed anything. 476 // nothing referencing it, we'll get here without having printed anything.
477 if (!quiet && cnt == 0) 477 if (!quiet && cnt == 0)
478 OutputString("Nothing references this.\n", DECORATION_YELLOW); 478 OutputString("Nothing references this.\n", DECORATION_YELLOW);
479 479
480 return 0; 480 return 0;
481 } 481 }
482 482
483 } // namespace commands 483 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_ls.cc ('k') | tools/gn/commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698