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

Unified Diff: tools/clang/plugins/ChromeClassTester.h

Issue 2780113002: Refactor banned directory checking so Blink can opt into certain checks. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/clang/plugins/ChromeClassTester.cpp » ('j') | tools/clang/plugins/ChromeClassTester.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/plugins/ChromeClassTester.h
diff --git a/tools/clang/plugins/ChromeClassTester.h b/tools/clang/plugins/ChromeClassTester.h
index 22af158693683b471fd560ea9cdc1219ab477142..c7af0fa9d2f7532d288b5ac50e0ad57be2911566 100644
--- a/tools/clang/plugins/ChromeClassTester.h
+++ b/tools/clang/plugins/ChromeClassTester.h
@@ -32,15 +32,22 @@ class ChromeClassTester {
// Emits a simple warning; this shouldn't be used if you require printf-style
// printing.
+ // TODO(dcheng): This will be removed. Do not add new usage.
void emitWarning(clang::SourceLocation loc, const char* error);
// Utility method for subclasses to check if this class is in a banned
// namespace.
bool InBannedNamespace(const clang::Decl* record);
- // Utility method for subclasses to check if the source location is in a
- // directory the plugin should ignore.
- bool InBannedDirectory(clang::SourceLocation loc);
+ // Utility method for subclasses to check how a certain SourceLocation should
+ // be handled. The main criteria for classification is the SourceLocation's
+ // path (e.g. whether it's in //third_party).
+ enum class LocationType {
+ kNotIgnored,
+ kBlink,
+ kIgnored,
Nico 2017/04/06 19:03:13 kNotIgnored, kIgnored, kBlink sounds a bit like TR
dcheng 2017/04/11 08:38:40 Done.
+ };
+ LocationType ClassifyLocation(clang::SourceLocation loc);
// Utility method for subclasses to determine the namespace of the
// specified record, if any. Unnamed namespaces will be identified as
@@ -63,14 +70,15 @@ class ChromeClassTester {
// Filtered versions of tags that are only called with things defined in
// chrome header files.
- virtual void CheckChromeClass(clang::SourceLocation record_location,
+ virtual void CheckChromeClass(LocationType location_type,
+ clang::SourceLocation record_location,
clang::CXXRecordDecl* record) = 0;
// Filtered versions of enum type that are only called with things defined
// in chrome header files.
- virtual void CheckChromeEnum(clang::SourceLocation enum_location,
- clang::EnumDecl* enum_decl) {
- }
+ virtual void CheckChromeEnum(LocationType location_type,
+ clang::SourceLocation enum_location,
+ clang::EnumDecl* enum_decl) = 0;
// Utility methods used for filtering out non-chrome classes (and ones we
// deliberately ignore) in HandleTagDeclDefinition().
@@ -88,9 +96,8 @@ class ChromeClassTester {
// List of banned namespaces.
std::set<std::string> banned_namespaces_;
- // List of directories allowed even though their parent directories are in
- // |banned_directories_|, below.
- std::set<std::string> allowed_directories_;
+ // List of Blink directories.
+ std::set<std::string> blink_directories_;
// List of banned directories.
std::set<std::string> banned_directories_;
« no previous file with comments | « no previous file | tools/clang/plugins/ChromeClassTester.cpp » ('j') | tools/clang/plugins/ChromeClassTester.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698