Chromium Code Reviews| Index: tools/clang/plugins/ChromeClassTester.h |
| diff --git a/tools/clang/plugins/ChromeClassTester.h b/tools/clang/plugins/ChromeClassTester.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d74e361b33b2f514a2315d71ef3ccc424119ca9a |
| --- /dev/null |
| +++ b/tools/clang/plugins/ChromeClassTester.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ |
| +#define TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ |
| + |
| +#include "clang/AST/ASTConsumer.h" |
| +#include "clang/AST/AST.h" |
| +#include "clang/AST/TypeLoc.h" |
| +#include "clang/Basic/SourceManager.h" |
| +#include "clang/Frontend/CompilerInstance.h" |
| + |
| +#include <vector> |
| + |
| +// A class on top of ASTConsumer that forwards classes defined in Chromium |
| +// headers to subclasses which implement CheckChromeClass(). |
| +class ChromeClassTester : public clang::ASTConsumer { |
| + public: |
| + ChromeClassTester(clang::CompilerInstance& instance); |
|
Nico
2011/02/02 23:13:06
explicit
|
| + virtual ~ChromeClassTester(); |
| + |
| + // ASTConsumer: |
| + virtual void HandleTagDeclDefinition(clang::TagDecl* tag); |
| + |
| + protected: |
| + clang::CompilerInstance& instance() { return instance_; } |
| + clang::Diagnostic& diagnostic() { return d_; } |
| + |
| + // Emits a simple warning; this shouldn't be used if you require pritnf-style |
|
Nico
2011/02/02 23:13:06
printf
|
| + // printing. |
| + void emitWarning(clang::SourceLocation loc, const char* error); |
| + |
| + private: |
| + // Template method which is called with only class that are defined in chrome |
|
Nico
2011/02/02 23:13:06
classes
"source files"?
Elliot Glaysher
2011/02/02 23:57:49
Nope, header files. The project of deinlining all
|
| + // header files. |
| + virtual void CheckChromeClass(const clang::SourceLocation& record_location, |
| + clang::CXXRecordDecl* record) = 0; |
| + |
| + // Utility methods used for filtering out non-chrome classes (and ones we |
| + // delibrately ignore) in HandleTagDeclDefinition(). |
| + bool IsTestCode(clang::Decl* record); |
| + bool InBannedNamespace(clang::Decl* record); |
| + std::string GetNamespace(clang::Decl* record); |
| + std::string GetNamespaceImpl(const clang::DeclContext* context, |
| + std::string candidate); |
| + bool InBannedDirectory(const clang::SourceLocation& loc); |
| + bool IsIgnoredType(clang::RecordDecl* record); |
| + |
| + clang::CompilerInstance& instance_; |
| + clang::Diagnostic& d_; |
|
Nico
2011/02/02 23:13:06
"d_"?
|
| + |
| + // List of banned namespaces. |
| + std::vector<std::string> banned_namespaces_; |
| + |
| + // List of banned directories. |
| + std::vector<std::string> banned_directories_; |
| + |
| + // List of types that we don't check. |
| + std::vector<std::string> ignored_record_names_; |
| +}; |
| + |
| +#endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ |