OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "clang/AST/ASTConsumer.h" | 8 #include "clang/AST/ASTConsumer.h" |
9 #include "clang/AST/AST.h" | 9 #include "clang/AST/AST.h" |
10 #include "clang/AST/TypeLoc.h" | 10 #include "clang/AST/TypeLoc.h" |
11 #include "clang/Basic/SourceManager.h" | 11 #include "clang/Basic/SourceManager.h" |
12 #include "clang/Frontend/CompilerInstance.h" | 12 #include "clang/Frontend/CompilerInstance.h" |
13 | 13 |
14 #include <set> | 14 #include <set> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 // A class on top of ASTConsumer that forwards classes defined in Chromium | 17 // A class on top of ASTConsumer that forwards classes defined in Chromium |
18 // headers to subclasses which implement CheckChromeClass(). | 18 // headers to subclasses which implement CheckChromeClass(). |
19 class ChromeClassTester : public clang::ASTConsumer { | 19 class ChromeClassTester : public clang::ASTConsumer { |
20 public: | 20 public: |
21 explicit ChromeClassTester(clang::CompilerInstance& instance); | 21 explicit ChromeClassTester(clang::CompilerInstance& instance); |
22 virtual ~ChromeClassTester(); | 22 virtual ~ChromeClassTester(); |
23 | 23 |
24 void FigureOutSrcRoot(); | |
25 void BuildBannedLists(); | 24 void BuildBannedLists(); |
26 | 25 |
27 // ASTConsumer: | 26 // ASTConsumer: |
28 virtual void HandleTagDeclDefinition(clang::TagDecl* tag); | 27 virtual void HandleTagDeclDefinition(clang::TagDecl* tag); |
29 | 28 |
30 protected: | 29 protected: |
31 clang::CompilerInstance& instance() { return instance_; } | 30 clang::CompilerInstance& instance() { return instance_; } |
32 clang::Diagnostic& diagnostic() { return diagnostic_; } | 31 clang::Diagnostic& diagnostic() { return diagnostic_; } |
33 | 32 |
34 // Emits a simple warning; this shouldn't be used if you require printf-style | 33 // Emits a simple warning; this shouldn't be used if you require printf-style |
(...skipping 16 matching lines...) Expand all Loading... |
51 bool InBannedNamespace(clang::Decl* record); | 50 bool InBannedNamespace(clang::Decl* record); |
52 std::string GetNamespace(clang::Decl* record); | 51 std::string GetNamespace(clang::Decl* record); |
53 std::string GetNamespaceImpl(const clang::DeclContext* context, | 52 std::string GetNamespaceImpl(const clang::DeclContext* context, |
54 std::string candidate); | 53 std::string candidate); |
55 bool InBannedDirectory(clang::SourceLocation loc); | 54 bool InBannedDirectory(clang::SourceLocation loc); |
56 bool IsIgnoredType(const std::string& base_name); | 55 bool IsIgnoredType(const std::string& base_name); |
57 | 56 |
58 clang::CompilerInstance& instance_; | 57 clang::CompilerInstance& instance_; |
59 clang::Diagnostic& diagnostic_; | 58 clang::Diagnostic& diagnostic_; |
60 | 59 |
61 std::string src_root_; | |
62 | |
63 // List of banned namespaces. | 60 // List of banned namespaces. |
64 std::vector<std::string> banned_namespaces_; | 61 std::vector<std::string> banned_namespaces_; |
65 | 62 |
66 // List of banned directories. | 63 // List of banned directories. |
67 std::vector<std::string> banned_directories_; | 64 std::vector<std::string> banned_directories_; |
68 | 65 |
69 // List of types that we don't check. | 66 // List of types that we don't check. |
70 std::set<std::string> ignored_record_names_; | 67 std::set<std::string> ignored_record_names_; |
71 }; | 68 }; |
72 | 69 |
73 #endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ | 70 #endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ |
OLD | NEW |