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

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

Issue 610293003: Replace more for loops in GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 6 years, 2 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/function_rebase_path.cc ('k') | tools/gn/function_write_file.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 <algorithm> 5 #include <algorithm>
6 #include <limits> 6 #include <limits>
7 7
8 #include "tools/gn/err.h" 8 #include "tools/gn/err.h"
9 #include "tools/gn/functions.h" 9 #include "tools/gn/functions.h"
10 #include "tools/gn/parse_tree.h" 10 #include "tools/gn/parse_tree.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 (tool->*set)(v->string_value()); 55 (tool->*set)(v->string_value());
56 return true; 56 return true;
57 } 57 }
58 58
59 // Calls the given validate function on each type in the list. On failure, 59 // Calls the given validate function on each type in the list. On failure,
60 // sets the error, blame the value, and return false. 60 // sets the error, blame the value, and return false.
61 bool ValidateSubstitutionList(const std::vector<SubstitutionType>& list, 61 bool ValidateSubstitutionList(const std::vector<SubstitutionType>& list,
62 bool (*validate)(SubstitutionType), 62 bool (*validate)(SubstitutionType),
63 const Value* origin, 63 const Value* origin,
64 Err* err) { 64 Err* err) {
65 for (size_t i = 0; i < list.size(); i++) { 65 for (const auto& cur_type : list) {
66 SubstitutionType cur_type = list[i];
67 if (!validate(cur_type)) { 66 if (!validate(cur_type)) {
68 *err = Err(*origin, "Pattern not valid here.", 67 *err = Err(*origin, "Pattern not valid here.",
69 "You used the pattern " + std::string(kSubstitutionNames[cur_type]) + 68 "You used the pattern " + std::string(kSubstitutionNames[cur_type]) +
70 " which is not valid\nfor this variable."); 69 " which is not valid\nfor this variable.");
71 return false; 70 return false;
72 } 71 }
73 } 72 }
74 return true; 73 return true;
75 } 74 }
76 75
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 171 }
173 172
174 bool IsLinkerTool(Toolchain::ToolType type) { 173 bool IsLinkerTool(Toolchain::ToolType type) {
175 return type == Toolchain::TYPE_ALINK || 174 return type == Toolchain::TYPE_ALINK ||
176 type == Toolchain::TYPE_SOLINK || 175 type == Toolchain::TYPE_SOLINK ||
177 type == Toolchain::TYPE_LINK; 176 type == Toolchain::TYPE_LINK;
178 } 177 }
179 178
180 bool IsPatternInOutputList(const SubstitutionList& output_list, 179 bool IsPatternInOutputList(const SubstitutionList& output_list,
181 const SubstitutionPattern& pattern) { 180 const SubstitutionPattern& pattern) {
182 for (size_t output_i = 0; output_i < output_list.list().size(); output_i++) { 181 for (const auto& cur : output_list.list()) {
183 const SubstitutionPattern& cur = output_list.list()[output_i];
184 if (pattern.ranges().size() == cur.ranges().size() && 182 if (pattern.ranges().size() == cur.ranges().size() &&
185 std::equal(pattern.ranges().begin(), pattern.ranges().end(), 183 std::equal(pattern.ranges().begin(), pattern.ranges().end(),
186 cur.ranges().begin())) 184 cur.ranges().begin()))
187 return true; 185 return true;
188 } 186 }
189 return false; 187 return false;
190 } 188 }
191 189
192 } // namespace 190 } // namespace
193 191
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 return Value(); 911 return Value();
914 912
915 Scope::KeyValueMap values; 913 Scope::KeyValueMap values;
916 block_scope.GetCurrentScopeValues(&values); 914 block_scope.GetCurrentScopeValues(&values);
917 toolchain->args() = values; 915 toolchain->args() = values;
918 916
919 return Value(); 917 return Value();
920 } 918 }
921 919
922 } // namespace functions 920 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/function_rebase_path.cc ('k') | tools/gn/function_write_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698