Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: tools/clang/plugins/ChromeClassTester.h

Issue 14064011: Add url/ to banned_directories in clang style checker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chrome-plugins Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/clang/plugins/ChromeClassTester.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "clang/AST/ASTConsumer.h" 11 #include "clang/AST/ASTConsumer.h"
12 #include "clang/AST/TypeLoc.h" 12 #include "clang/AST/TypeLoc.h"
13 #include "clang/Frontend/CompilerInstance.h" 13 #include "clang/Frontend/CompilerInstance.h"
14 14
15 // A class on top of ASTConsumer that forwards classes defined in Chromium 15 // A class on top of ASTConsumer that forwards classes defined in Chromium
16 // headers to subclasses which implement CheckChromeClass(). 16 // headers to subclasses which implement CheckChromeClass().
17 class ChromeClassTester : public clang::ASTConsumer { 17 class ChromeClassTester : public clang::ASTConsumer {
18 public: 18 public:
19 explicit ChromeClassTester(clang::CompilerInstance& instance); 19 explicit ChromeClassTester(clang::CompilerInstance& instance,
20 bool check_url_directory);
20 virtual ~ChromeClassTester(); 21 virtual ~ChromeClassTester();
21 22
22 // clang::ASTConsumer: 23 // clang::ASTConsumer:
23 virtual void HandleTagDeclDefinition(clang::TagDecl* tag); 24 virtual void HandleTagDeclDefinition(clang::TagDecl* tag);
24 virtual bool HandleTopLevelDecl(clang::DeclGroupRef group_ref); 25 virtual bool HandleTopLevelDecl(clang::DeclGroupRef group_ref);
25 26
26 protected: 27 protected:
27 clang::CompilerInstance& instance() { return instance_; } 28 clang::CompilerInstance& instance() { return instance_; }
28 clang::DiagnosticsEngine& diagnostic() { return diagnostic_; } 29 clang::DiagnosticsEngine& diagnostic() { return diagnostic_; }
29 30
30 // Emits a simple warning; this shouldn't be used if you require printf-style 31 // Emits a simple warning; this shouldn't be used if you require printf-style
31 // printing. 32 // printing.
32 void emitWarning(clang::SourceLocation loc, const char* error); 33 void emitWarning(clang::SourceLocation loc, const char* error);
33 34
34 // Utility method for subclasses to check if this class is in a banned 35 // Utility method for subclasses to check if this class is in a banned
35 // namespace. 36 // namespace.
36 bool InBannedNamespace(const clang::Decl* record); 37 bool InBannedNamespace(const clang::Decl* record);
37 38
38 // Utility method for subclasses to determine the namespace of the 39 // Utility method for subclasses to determine the namespace of the
39 // specified record, if any. Unnamed namespaces will be identified as 40 // specified record, if any. Unnamed namespaces will be identified as
40 // "<anonymous namespace>". 41 // "<anonymous namespace>".
41 std::string GetNamespace(const clang::Decl* record); 42 std::string GetNamespace(const clang::Decl* record);
42 43
43 // Utility method for subclasses to check if this class is within an 44 // Utility method for subclasses to check if this class is within an
44 // implementation (.cc, .cpp, .mm) file. 45 // implementation (.cc, .cpp, .mm) file.
45 bool InImplementationFile(clang::SourceLocation location); 46 bool InImplementationFile(clang::SourceLocation location);
46 47
48 // TODO(tfarina): Remove once url/ directory compiles without warnings.
49 bool check_url_directory_;
Nico 2013/04/16 22:16:56 I think this can stay private. You only use this i
tfarina 2013/04/16 22:23:24 Done.
50
47 private: 51 private:
48 void BuildBannedLists(); 52 void BuildBannedLists();
49 53
50 void CheckTag(clang::TagDecl*); 54 void CheckTag(clang::TagDecl*);
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
(...skipping 18 matching lines...) Expand all
75 std::vector<std::string> banned_directories_; 79 std::vector<std::string> banned_directories_;
76 80
77 // List of types that we don't check. 81 // List of types that we don't check.
78 std::set<std::string> ignored_record_names_; 82 std::set<std::string> ignored_record_names_;
79 83
80 // List of decls to check once the current top-level decl is parsed. 84 // List of decls to check once the current top-level decl is parsed.
81 std::vector<clang::TagDecl*> pending_class_decls_; 85 std::vector<clang::TagDecl*> pending_class_decls_;
82 }; 86 };
83 87
84 #endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ 88 #endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_
OLDNEW
« no previous file with comments | « no previous file | tools/clang/plugins/ChromeClassTester.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698