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

Side by Side Diff: tools/gn/scope.h

Issue 2936923002: Add not_needed function (Closed)
Patch Set: Rename to not_needed Created 3 years, 6 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 (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 #ifndef TOOLS_GN_SCOPE_H_ 5 #ifndef TOOLS_GN_SCOPE_H_
6 #define TOOLS_GN_SCOPE_H_ 6 #define TOOLS_GN_SCOPE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 void RemovePrivateIdentifiers(); 197 void RemovePrivateIdentifiers();
198 198
199 // Templates associated with this scope. A template can only be set once, so 199 // Templates associated with this scope. A template can only be set once, so
200 // AddTemplate will fail and return false if a rule with that name already 200 // AddTemplate will fail and return false if a rule with that name already
201 // exists. GetTemplate returns NULL if the rule doesn't exist, and it will 201 // exists. GetTemplate returns NULL if the rule doesn't exist, and it will
202 // check all containing scoped rescursively. 202 // check all containing scoped rescursively.
203 bool AddTemplate(const std::string& name, const Template* templ); 203 bool AddTemplate(const std::string& name, const Template* templ);
204 const Template* GetTemplate(const std::string& name) const; 204 const Template* GetTemplate(const std::string& name) const;
205 205
206 // Marks the given identifier as (un)used in the current scope. 206 // Marks the given identifier as (un)used in the current scope.
207 void MarkUsed(const base::StringPiece& ident); 207 void MarkUsed(const base::StringPiece& ident, Err* err);
208 void MarkAllUsed(); 208 void MarkAllUsed(Err* err);
209 void MarkUnused(const base::StringPiece& ident); 209 void MarkUnused(const base::StringPiece& ident);
210 210
211 // Marks the given identifier as unusable in the current scope.
212 void MarkAllUnusable(Err* err, std::set<std::string> excluded_values);
brettw 2017/06/20 17:27:25 The set should be passed by const ref.
Petr Hosek 2017/06/21 02:17:40 Done.
213 void MarkUnusable(const base::StringPiece& ident, Err* err);
214
211 // Checks to see if the scope has a var set that hasn't been used. This is 215 // Checks to see if the scope has a var set that hasn't been used. This is
212 // called before replacing the var with a different one. It does not check 216 // called before replacing the var with a different one. It does not check
213 // containing scopes. 217 // containing scopes.
214 // 218 //
215 // If the identifier is present but hasnn't been used, return true. 219 // If the identifier is present but hasnn't been used, return true.
216 bool IsSetButUnused(const base::StringPiece& ident) const; 220 bool IsSetButUnused(const base::StringPiece& ident) const;
217 221
218 // Checks the scope to see if any values were set but not used, and fills in 222 // Checks the scope to see if any values were set but not used, and fills in
219 // the error and returns false if they were. 223 // the error and returns false if they were.
220 bool CheckForUnusedVars(Err* err) const; 224 bool CheckForUnusedVars(Err* err) const;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // Getting a property recursively searches all scopes, and the optional 317 // Getting a property recursively searches all scopes, and the optional
314 // |found_on_scope| variable will be filled with the actual scope containing 318 // |found_on_scope| variable will be filled with the actual scope containing
315 // the key (if the pointer is non-NULL). 319 // the key (if the pointer is non-NULL).
316 void SetProperty(const void* key, void* value); 320 void SetProperty(const void* key, void* value);
317 void* GetProperty(const void* key, const Scope** found_on_scope) const; 321 void* GetProperty(const void* key, const Scope** found_on_scope) const;
318 322
319 private: 323 private:
320 friend class ProgrammaticProvider; 324 friend class ProgrammaticProvider;
321 325
322 struct Record { 326 struct Record {
323 Record() : used(false) {} 327 Record() : used(false), unusable(false) {}
324 explicit Record(const Value& v) : used(false), value(v) {} 328 explicit Record(const Value& v) : used(false), unusable(false), value(v) {}
325 329
326 bool used; // Set to true when the variable is used. 330 bool used; // Set to true when the variable is used.
331 bool unusable;
327 Value value; 332 Value value;
328 }; 333 };
329 334
330 typedef base::hash_map<base::StringPiece, Record, base::StringPieceHash> 335 typedef base::hash_map<base::StringPiece, Record, base::StringPieceHash>
331 RecordMap; 336 RecordMap;
332 337
333 void AddProvider(ProgrammaticProvider* p); 338 void AddProvider(ProgrammaticProvider* p);
334 void RemoveProvider(ProgrammaticProvider* p); 339 void RemoveProvider(ProgrammaticProvider* p);
335 340
336 // Returns true if the two RecordMaps contain the same values (the origins 341 // Returns true if the two RecordMaps contain the same values (the origins
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 380
376 typedef std::set<ProgrammaticProvider*> ProviderSet; 381 typedef std::set<ProgrammaticProvider*> ProviderSet;
377 ProviderSet programmatic_providers_; 382 ProviderSet programmatic_providers_;
378 383
379 SourceDir source_dir_; 384 SourceDir source_dir_;
380 385
381 DISALLOW_COPY_AND_ASSIGN(Scope); 386 DISALLOW_COPY_AND_ASSIGN(Scope);
382 }; 387 };
383 388
384 #endif // TOOLS_GN_SCOPE_H_ 389 #endif // TOOLS_GN_SCOPE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698