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

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

Issue 986113002: tools/gn: Convert for loops to use the new range-based loops in C++11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fixes Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "tools/gn/substitution_pattern.h" 5 #include "tools/gn/substitution_pattern.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "tools/gn/build_settings.h" 8 #include "tools/gn/build_settings.h"
9 #include "tools/gn/err.h" 9 #include "tools/gn/err.h"
10 #include "tools/gn/filesystem_utils.h" 10 #include "tools/gn/filesystem_utils.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // static 94 // static
95 SubstitutionPattern SubstitutionPattern::MakeForTest(const char* str) { 95 SubstitutionPattern SubstitutionPattern::MakeForTest(const char* str) {
96 Err err; 96 Err err;
97 SubstitutionPattern pattern; 97 SubstitutionPattern pattern;
98 CHECK(pattern.Parse(str, nullptr, &err)) << err.message(); 98 CHECK(pattern.Parse(str, nullptr, &err)) << err.message();
99 return pattern; 99 return pattern;
100 } 100 }
101 101
102 std::string SubstitutionPattern::AsString() const { 102 std::string SubstitutionPattern::AsString() const {
103 std::string result; 103 std::string result;
104 for (size_t i = 0; i < ranges_.size(); i++) { 104 for (const auto& elem : ranges_) {
105 if (ranges_[i].type == SUBSTITUTION_LITERAL) 105 if (elem.type == SUBSTITUTION_LITERAL)
106 result.append(ranges_[i].literal); 106 result.append(elem.literal);
107 else 107 else
108 result.append(kSubstitutionNames[ranges_[i].type]); 108 result.append(kSubstitutionNames[elem.type]);
109 } 109 }
110 return result; 110 return result;
111 } 111 }
112 112
113 void SubstitutionPattern::FillRequiredTypes(SubstitutionBits* bits) const { 113 void SubstitutionPattern::FillRequiredTypes(SubstitutionBits* bits) const {
114 for (size_t i = 0; i < ranges_.size(); i++) { 114 for (const auto& elem : ranges_) {
115 if (ranges_[i].type != SUBSTITUTION_LITERAL) 115 if (elem.type != SUBSTITUTION_LITERAL)
116 bits->used[static_cast<size_t>(ranges_[i].type)] = true; 116 bits->used[static_cast<size_t>(elem.type)] = true;
117 } 117 }
118 } 118 }
119 119
120 bool SubstitutionPattern::IsInOutputDir(const BuildSettings* build_settings, 120 bool SubstitutionPattern::IsInOutputDir(const BuildSettings* build_settings,
121 Err* err) const { 121 Err* err) const {
122 if (ranges_.empty()) { 122 if (ranges_.empty()) {
123 *err = Err(origin_, "This is empty but I was expecting an output file."); 123 *err = Err(origin_, "This is empty but I was expecting an output file.");
124 return false; 124 return false;
125 } 125 }
126 126
(...skipping 11 matching lines...) Expand all
138 "File is not inside output directory.", 138 "File is not inside output directory.",
139 "The given file should be in the output directory. Normally you\n" 139 "The given file should be in the output directory. Normally you\n"
140 "would specify\n\"$target_out_dir/foo\" or " 140 "would specify\n\"$target_out_dir/foo\" or "
141 "\"{{source_gen_dir}}/foo\"."); 141 "\"{{source_gen_dir}}/foo\".");
142 return false; 142 return false;
143 } 143 }
144 } 144 }
145 145
146 return true; 146 return true;
147 } 147 }
OLDNEW
« tools/gn/pattern.cc ('K') | « tools/gn/standard_out.cc ('k') | tools/gn/toolchain.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698