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

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

Issue 1372833002: Update the clang plugin to optionally enforce rules for Blink code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « tools/clang/plugins/ChromeClassTester.h ('k') | tools/clang/plugins/FindBadConstructsAction.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/plugins/ChromeClassTester.cpp
diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp
index 8820407095efd974f3d465f1b87f6edb3337a5e2..846fd23b4016fce24fd4c0493e71c3de4ee4995f 100644
--- a/tools/clang/plugins/ChromeClassTester.cpp
+++ b/tools/clang/plugins/ChromeClassTester.cpp
@@ -150,6 +150,16 @@ bool ChromeClassTester::InBannedDirectory(SourceLocation loc) {
filename.insert(filename.begin(), '/');
#endif
+ for (const std::string& allowed_dir : allowed_directories_) {
+ // If any of the allowed directories occur as a component in filename,
+ // this file is allowed.
+ assert(allowed_dir.front() == '/' && "Allowed dir must start with '/'");
+ assert(allowed_dir.back() == '/' && "Allowed dir must end with '/'");
+
+ if (filename.find(allowed_dir) != std::string::npos)
+ return false;
+ }
+
for (const std::string& banned_dir : banned_directories_) {
// If any of the banned directories occur as a component in filename,
// this file is rejected.
@@ -191,38 +201,42 @@ bool ChromeClassTester::InImplementationFile(SourceLocation record_location) {
}
void ChromeClassTester::BuildBannedLists() {
- banned_namespaces_.push_back("std");
- banned_namespaces_.push_back("__gnu_cxx");
+ banned_namespaces_.insert("std");
dcheng 2015/10/01 21:42:48 IMO, if you're going to change all these, you may
Avi (use Gerrit) 2015/10/01 21:52:06 Wouldn't the same rules about no C++11 library fea
dcheng 2015/10/01 21:53:22 Nope =) The plugin already uses std::unique_ptr a
+ banned_namespaces_.insert("__gnu_cxx");
+
+ if (!options_.enforce_overriding_blink) {
+ banned_namespaces_.insert("blink");
+ banned_namespaces_.insert("WTF");
+ }
- if (!options_.enforce_blink) {
- banned_namespaces_.push_back("blink");
- banned_namespaces_.push_back("WTF");
+ if (options_.enforce_in_thirdparty_webkit) {
+ allowed_directories_.insert("/third_party/WebKit/");
}
- banned_directories_.push_back("/third_party/");
- banned_directories_.push_back("/native_client/");
- banned_directories_.push_back("/breakpad/");
- banned_directories_.push_back("/courgette/");
- banned_directories_.push_back("/pdf/");
- banned_directories_.push_back("/ppapi/");
- banned_directories_.push_back("/usr/include/");
- banned_directories_.push_back("/usr/lib/");
- banned_directories_.push_back("/usr/local/include/");
- banned_directories_.push_back("/usr/local/lib/");
- banned_directories_.push_back("/testing/");
- banned_directories_.push_back("/v8/");
- banned_directories_.push_back("/dart/");
- banned_directories_.push_back("/sdch/");
- banned_directories_.push_back("/icu4c/");
- banned_directories_.push_back("/frameworks/");
+ banned_directories_.insert("/third_party/");
+ banned_directories_.insert("/native_client/");
+ banned_directories_.insert("/breakpad/");
+ banned_directories_.insert("/courgette/");
+ banned_directories_.insert("/pdf/");
+ banned_directories_.insert("/ppapi/");
+ banned_directories_.insert("/usr/include/");
+ banned_directories_.insert("/usr/lib/");
+ banned_directories_.insert("/usr/local/include/");
+ banned_directories_.insert("/usr/local/lib/");
+ banned_directories_.insert("/testing/");
+ banned_directories_.insert("/v8/");
+ banned_directories_.insert("/dart/");
+ banned_directories_.insert("/sdch/");
+ banned_directories_.insert("/icu4c/");
+ banned_directories_.insert("/frameworks/");
// Don't check autogenerated headers.
// Make puts them below $(builddir_name)/.../gen and geni.
// Ninja puts them below OUTPUT_DIR/.../gen
// Xcode has a fixed output directory for everything.
- banned_directories_.push_back("/gen/");
- banned_directories_.push_back("/geni/");
- banned_directories_.push_back("/xcodebuild/");
+ banned_directories_.insert("/gen/");
+ banned_directories_.insert("/geni/");
+ banned_directories_.insert("/xcodebuild/");
// Used in really low level threading code that probably shouldn't be out of
// lined.
« no previous file with comments | « tools/clang/plugins/ChromeClassTester.h ('k') | tools/clang/plugins/FindBadConstructsAction.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698