OLD | NEW |
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 #ifndef TOOLS_GN_HEADER_CHECKER_H_ | 5 #ifndef TOOLS_GN_HEADER_CHECKER_H_ |
6 #define TOOLS_GN_HEADER_CHECKER_H_ | 6 #define TOOLS_GN_HEADER_CHECKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "tools/gn/err.h" | 18 #include "tools/gn/err.h" |
19 | 19 |
20 class BuildSettings; | 20 class BuildSettings; |
| 21 class InputFile; |
21 class Label; | 22 class Label; |
| 23 class LocationRange; |
22 class SourceFile; | 24 class SourceFile; |
23 class Target; | 25 class Target; |
24 | 26 |
25 namespace base { | 27 namespace base { |
26 class MessageLoop; | 28 class MessageLoop; |
27 } | 29 } |
28 | 30 |
29 class HeaderChecker : public base::RefCountedThreadSafe<HeaderChecker> { | 31 class HeaderChecker : public base::RefCountedThreadSafe<HeaderChecker> { |
30 public: | 32 public: |
31 HeaderChecker(const BuildSettings* build_settings, | 33 HeaderChecker(const BuildSettings* build_settings, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Resolves the contents of an include to a SourceFile. | 66 // Resolves the contents of an include to a SourceFile. |
65 SourceFile SourceFileForInclude(const base::StringPiece& input) const; | 67 SourceFile SourceFileForInclude(const base::StringPiece& input) const; |
66 | 68 |
67 // from_target is the target the file was defined from. It will be used in | 69 // from_target is the target the file was defined from. It will be used in |
68 // error messages. | 70 // error messages. |
69 bool CheckFile(const Target* from_target, | 71 bool CheckFile(const Target* from_target, |
70 const SourceFile& file, | 72 const SourceFile& file, |
71 Err* err) const; | 73 Err* err) const; |
72 | 74 |
73 // Checks that the given file in the given target can include the given | 75 // Checks that the given file in the given target can include the given |
74 // include file. If disallowed, returns false and sets the error. | 76 // include file. If disallowed, returns false and sets the error. The |
| 77 // range indicates the location of the include in the file for error |
| 78 // reporting. |
75 bool CheckInclude(const Target* from_target, | 79 bool CheckInclude(const Target* from_target, |
76 const SourceFile& source_file, | 80 const InputFile& source_file, |
77 const SourceFile& include_file, | 81 const SourceFile& include_file, |
| 82 const LocationRange& range, |
78 Err* err) const; | 83 Err* err) const; |
79 | 84 |
80 // Returns true if the given search_for target is a dependency of | 85 // Returns true if the given search_for target is a dependency of |
81 // search_from. Many subtrees are duplicated so this function avoids | 86 // search_from. Many subtrees are duplicated so this function avoids |
82 // duplicate checking across recursive calls by keeping track of checked | 87 // duplicate checking across recursive calls by keeping track of checked |
83 // targets in the given set. It should point to an empty set for the first | 88 // targets in the given set. It should point to an empty set for the first |
84 // call. A target is not considered to be a dependency of itself. | 89 // call. A target is not considered to be a dependency of itself. |
85 bool IsDependencyOf(const Target* search_for, | 90 bool IsDependencyOf(const Target* search_for, |
86 const Target* search_from) const; | 91 const Target* search_from) const; |
87 bool IsDependencyOf(const Target* search_for, | 92 bool IsDependencyOf(const Target* search_for, |
(...skipping 19 matching lines...) Expand all Loading... |
107 // These are mutable during runtime and require locking. | 112 // These are mutable during runtime and require locking. |
108 | 113 |
109 base::Lock lock_; | 114 base::Lock lock_; |
110 | 115 |
111 std::vector<Err> errors_; | 116 std::vector<Err> errors_; |
112 | 117 |
113 DISALLOW_COPY_AND_ASSIGN(HeaderChecker); | 118 DISALLOW_COPY_AND_ASSIGN(HeaderChecker); |
114 }; | 119 }; |
115 | 120 |
116 #endif // TOOLS_GN_HEADER_CHECKER_H_ | 121 #endif // TOOLS_GN_HEADER_CHECKER_H_ |
OLD | NEW |