Chromium Code Reviews| 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 <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 // A class on top of ASTConsumer that forwards classes defined in Chromium | 16 // A class on top of ASTConsumer that forwards classes defined in Chromium |
| 17 // headers to subclasses which implement CheckChromeClass(). | 17 // headers to subclasses which implement CheckChromeClass(). |
| 18 class ChromeClassTester : public clang::ASTConsumer { | 18 class ChromeClassTester : public clang::ASTConsumer { |
| 19 public: | 19 public: |
| 20 explicit ChromeClassTester(clang::CompilerInstance& instance); | 20 explicit ChromeClassTester(clang::CompilerInstance& instance); |
| 21 virtual ~ChromeClassTester(); | 21 virtual ~ChromeClassTester(); |
| 22 | 22 |
| 23 void FigureOutSrcRoot(); | |
| 24 void BuildBannedLists(); | |
| 25 | |
| 23 // ASTConsumer: | 26 // ASTConsumer: |
| 24 virtual void HandleTagDeclDefinition(clang::TagDecl* tag); | 27 virtual void HandleTagDeclDefinition(clang::TagDecl* tag); |
| 25 | 28 |
| 26 protected: | 29 protected: |
| 27 clang::CompilerInstance& instance() { return instance_; } | 30 clang::CompilerInstance& instance() { return instance_; } |
| 28 clang::Diagnostic& diagnostic() { return diagnostic_; } | 31 clang::Diagnostic& diagnostic() { return diagnostic_; } |
| 29 | 32 |
| 30 // 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 |
| 31 // printing. | 34 // printing. |
| 32 void emitWarning(clang::SourceLocation loc, const char* error); | 35 void emitWarning(clang::SourceLocation loc, const char* error); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 47 bool InBannedNamespace(clang::Decl* record); | 50 bool InBannedNamespace(clang::Decl* record); |
| 48 std::string GetNamespace(clang::Decl* record); | 51 std::string GetNamespace(clang::Decl* record); |
| 49 std::string GetNamespaceImpl(const clang::DeclContext* context, | 52 std::string GetNamespaceImpl(const clang::DeclContext* context, |
| 50 std::string candidate); | 53 std::string candidate); |
| 51 bool InBannedDirectory(const clang::SourceLocation& loc); | 54 bool InBannedDirectory(const clang::SourceLocation& loc); |
| 52 bool IsIgnoredType(const std::string& base_name); | 55 bool IsIgnoredType(const std::string& base_name); |
| 53 | 56 |
| 54 clang::CompilerInstance& instance_; | 57 clang::CompilerInstance& instance_; |
| 55 clang::Diagnostic& diagnostic_; | 58 clang::Diagnostic& diagnostic_; |
| 56 | 59 |
| 60 std::string srcroot_; | |
|
Nico
2011/02/25 02:08:41
src_root_ for consistency with the method name
| |
| 61 | |
| 57 // List of banned namespaces. | 62 // List of banned namespaces. |
| 58 std::vector<std::string> banned_namespaces_; | 63 std::vector<std::string> banned_namespaces_; |
| 59 | 64 |
| 60 // List of banned directories. | 65 // List of banned directories. |
| 61 std::vector<std::string> banned_directories_; | 66 std::vector<std::string> banned_directories_; |
| 62 | 67 |
| 63 // List of types that we don't check. | 68 // List of types that we don't check. |
| 64 std::vector<std::string> ignored_record_names_; | 69 std::vector<std::string> ignored_record_names_; |
| 65 }; | 70 }; |
| 66 | 71 |
| 67 #endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ | 72 #endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ |
| OLD | NEW |