OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CLANG_PLUGINS_CHROMECLASSTESTER_H_ | 5 #ifndef TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ |
6 #define TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ | 6 #define TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 clang::DiagnosticsEngine& diagnostic() { return diagnostic_; } | 30 clang::DiagnosticsEngine& diagnostic() { return diagnostic_; } |
31 | 31 |
32 // Emits a simple warning; this shouldn't be used if you require printf-style | 32 // Emits a simple warning; this shouldn't be used if you require printf-style |
33 // printing. | 33 // printing. |
34 void emitWarning(clang::SourceLocation loc, const char* error); | 34 void emitWarning(clang::SourceLocation loc, const char* error); |
35 | 35 |
36 // Utility method for subclasses to check if this class is in a banned | 36 // Utility method for subclasses to check if this class is in a banned |
37 // namespace. | 37 // namespace. |
38 bool InBannedNamespace(const clang::Decl* record); | 38 bool InBannedNamespace(const clang::Decl* record); |
39 | 39 |
| 40 // Utility method for subclasses to check if the source location is in a |
| 41 // directory the plugin should ignore. |
| 42 bool InBannedDirectory(clang::SourceLocation loc); |
| 43 |
40 // Utility method for subclasses to determine the namespace of the | 44 // Utility method for subclasses to determine the namespace of the |
41 // specified record, if any. Unnamed namespaces will be identified as | 45 // specified record, if any. Unnamed namespaces will be identified as |
42 // "<anonymous namespace>". | 46 // "<anonymous namespace>". |
43 std::string GetNamespace(const clang::Decl* record); | 47 std::string GetNamespace(const clang::Decl* record); |
44 | 48 |
45 // Utility method for subclasses to check if this class is within an | 49 // Utility method for subclasses to check if this class is within an |
46 // implementation (.cc, .cpp, .mm) file. | 50 // implementation (.cc, .cpp, .mm) file. |
47 bool InImplementationFile(clang::SourceLocation location); | 51 bool InImplementationFile(clang::SourceLocation location); |
48 | 52 |
49 private: | 53 private: |
50 void BuildBannedLists(); | 54 void BuildBannedLists(); |
51 | 55 |
52 // Filtered versions of tags that are only called with things defined in | 56 // Filtered versions of tags that are only called with things defined in |
53 // chrome header files. | 57 // chrome header files. |
54 virtual void CheckChromeClass(clang::SourceLocation record_location, | 58 virtual void CheckChromeClass(clang::SourceLocation record_location, |
55 clang::CXXRecordDecl* record) = 0; | 59 clang::CXXRecordDecl* record) = 0; |
56 | 60 |
57 // Filtered versions of enum type that are only called with things defined | 61 // Filtered versions of enum type that are only called with things defined |
58 // in chrome header files. | 62 // in chrome header files. |
59 virtual void CheckChromeEnum(clang::SourceLocation enum_location, | 63 virtual void CheckChromeEnum(clang::SourceLocation enum_location, |
60 clang::EnumDecl* enum_decl) { | 64 clang::EnumDecl* enum_decl) { |
61 } | 65 } |
62 | 66 |
63 // Utility methods used for filtering out non-chrome classes (and ones we | 67 // Utility methods used for filtering out non-chrome classes (and ones we |
64 // deliberately ignore) in HandleTagDeclDefinition(). | 68 // deliberately ignore) in HandleTagDeclDefinition(). |
65 std::string GetNamespaceImpl(const clang::DeclContext* context, | 69 std::string GetNamespaceImpl(const clang::DeclContext* context, |
66 const std::string& candidate); | 70 const std::string& candidate); |
67 bool InBannedDirectory(clang::SourceLocation loc); | |
68 bool IsIgnoredType(const std::string& base_name); | 71 bool IsIgnoredType(const std::string& base_name); |
69 | 72 |
70 // Attempts to determine the filename for the given SourceLocation. | 73 // Attempts to determine the filename for the given SourceLocation. |
71 // Returns false if the filename could not be determined. | 74 // Returns false if the filename could not be determined. |
72 bool GetFilename(clang::SourceLocation loc, std::string* filename); | 75 bool GetFilename(clang::SourceLocation loc, std::string* filename); |
73 | 76 |
74 clang::CompilerInstance& instance_; | 77 clang::CompilerInstance& instance_; |
75 clang::DiagnosticsEngine& diagnostic_; | 78 clang::DiagnosticsEngine& diagnostic_; |
76 | 79 |
77 // List of banned namespaces. | 80 // List of banned namespaces. |
78 std::vector<std::string> banned_namespaces_; | 81 std::vector<std::string> banned_namespaces_; |
79 | 82 |
80 // List of banned directories. | 83 // List of banned directories. |
81 std::vector<std::string> banned_directories_; | 84 std::vector<std::string> banned_directories_; |
82 | 85 |
83 // List of types that we don't check. | 86 // List of types that we don't check. |
84 std::set<std::string> ignored_record_names_; | 87 std::set<std::string> ignored_record_names_; |
85 | 88 |
86 // List of decls to check once the current top-level decl is parsed. | 89 // List of decls to check once the current top-level decl is parsed. |
87 std::vector<clang::TagDecl*> pending_class_decls_; | 90 std::vector<clang::TagDecl*> pending_class_decls_; |
88 }; | 91 }; |
89 | 92 |
90 #endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ | 93 #endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ |
OLD | NEW |