OLD | NEW |
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 "tools/gn/scope.h" | 5 #include "tools/gn/scope.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "tools/gn/parse_tree.h" | 9 #include "tools/gn/parse_tree.h" |
10 #include "tools/gn/template.h" | 10 #include "tools/gn/template.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 return; | 212 return; |
213 } | 213 } |
214 found->second.used = true; | 214 found->second.used = true; |
215 } | 215 } |
216 | 216 |
217 void Scope::MarkAllUsed() { | 217 void Scope::MarkAllUsed() { |
218 for (auto& cur : values_) | 218 for (auto& cur : values_) |
219 cur.second.used = true; | 219 cur.second.used = true; |
220 } | 220 } |
221 | 221 |
| 222 void Scope::MarkAllUsed(const std::set<std::string>& excluded_values) { |
| 223 for (auto& cur : values_) { |
| 224 if (!excluded_values.empty() && |
| 225 excluded_values.find(cur.first.as_string()) != excluded_values.end()) { |
| 226 continue; // Skip this excluded value. |
| 227 } |
| 228 cur.second.used = true; |
| 229 } |
| 230 } |
| 231 |
222 void Scope::MarkUnused(const base::StringPiece& ident) { | 232 void Scope::MarkUnused(const base::StringPiece& ident) { |
223 RecordMap::iterator found = values_.find(ident); | 233 RecordMap::iterator found = values_.find(ident); |
224 if (found == values_.end()) { | 234 if (found == values_.end()) { |
225 NOTREACHED(); | 235 NOTREACHED(); |
226 return; | 236 return; |
227 } | 237 } |
228 found->second.used = false; | 238 found->second.used = false; |
229 } | 239 } |
230 | 240 |
231 bool Scope::IsSetButUnused(const base::StringPiece& ident) const { | 241 bool Scope::IsSetButUnused(const base::StringPiece& ident) const { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 return false; | 549 return false; |
540 for (const auto& pair : a) { | 550 for (const auto& pair : a) { |
541 const auto& found_b = b.find(pair.first); | 551 const auto& found_b = b.find(pair.first); |
542 if (found_b == b.end()) | 552 if (found_b == b.end()) |
543 return false; // Item in 'a' but not 'b'. | 553 return false; // Item in 'a' but not 'b'. |
544 if (pair.second.value != found_b->second.value) | 554 if (pair.second.value != found_b->second.value) |
545 return false; // Values for variable in 'a' and 'b' are different. | 555 return false; // Values for variable in 'a' and 'b' are different. |
546 } | 556 } |
547 return true; | 557 return true; |
548 } | 558 } |
OLD | NEW |