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

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

Issue 7824047: clang style plugin: Don't try to figure out src root. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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') | no next file » | 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 303f31db1711a9a4eb6d54dd41b47267117d5707..b92305de881b0952b2f089327d9574fbf2081a35 100644
--- a/tools/clang/plugins/ChromeClassTester.cpp
+++ b/tools/clang/plugins/ChromeClassTester.cpp
@@ -31,76 +31,37 @@ bool ends_with(const std::string& one, const std::string& two) {
ChromeClassTester::ChromeClassTester(CompilerInstance& instance)
: instance_(instance),
diagnostic_(instance.getDiagnostics()) {
- FigureOutSrcRoot();
BuildBannedLists();
}
-void ChromeClassTester::FigureOutSrcRoot() {
- char c_cwd[MAXPATHLEN];
- if (getcwd(c_cwd, MAXPATHLEN) > 0) {
- size_t pos = 1;
- std::string cwd = c_cwd;
-
- // Add a trailing '/' because the search below requires it.
- if (cwd[cwd.size() - 1] != '/')
- cwd += '/';
-
- // Search the directory tree downwards until we find a path that contains
- // "build/common.gypi" and assume that that is our srcroot.
- size_t next_slash = cwd.find('/', pos);
- while (next_slash != std::string::npos) {
- next_slash++;
- std::string candidate = cwd.substr(0, next_slash);
-
- if (ends_with(candidate, "src/")) {
- std::string common = candidate + "build/common.gypi";
- if (access(common.c_str(), F_OK) != -1) {
- src_root_ = candidate;
- break;
- }
- }
-
- pos = next_slash;
- next_slash = cwd.find('/', pos);
- }
- }
-
- if (src_root_.empty()) {
- unsigned id = diagnostic().getCustomDiagID(
- Diagnostic::Error,
- "WARNING: Can't figure out srcroot!\n");
- diagnostic().Report(id);
- }
-}
-
void ChromeClassTester::BuildBannedLists() {
banned_namespaces_.push_back("std");
banned_namespaces_.push_back("__gnu_cxx");
- 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("ppapi");
- banned_directories_.push_back("testing");
- banned_directories_.push_back("googleurl");
- banned_directories_.push_back("v8");
- banned_directories_.push_back("sdch");
+ 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("ppapi/");
+ banned_directories_.push_back("usr/");
hans 2012/01/16 11:14:22 It's not uncommon to have Chromium checked out in
+ banned_directories_.push_back("testing/");
+ banned_directories_.push_back("googleurl/");
+ banned_directories_.push_back("v8/");
+ banned_directories_.push_back("sdch/");
// Don't check autogenerated headers.
- banned_directories_.push_back("out");
- banned_directories_.push_back("llvm");
- banned_directories_.push_back("ninja");
- banned_directories_.push_back("xcodebuild");
- banned_directories_.push_back("clang");
+ banned_directories_.push_back("out/");
+ banned_directories_.push_back("llvm/");
+ banned_directories_.push_back("ninja/");
+ banned_directories_.push_back("xcodebuild/");
+ banned_directories_.push_back("clang/");
// You are standing in a mazy of twisty dependencies, all resolved by
// putting everything in the header.
- banned_directories_.push_back("chrome/test/automation");
+ banned_directories_.push_back("automation/");
// Don't check system headers.
- banned_directories_.push_back("/usr");
- banned_directories_.push_back("/Developer");
+ banned_directories_.push_back("/Developer/");
// Used in really low level threading code that probably shouldn't be out of
// lined.
@@ -265,17 +226,15 @@ bool ChromeClassTester::InBannedDirectory(SourceLocation loc) {
char resolvedPath[MAXPATHLEN];
if (realpath(b.c_str(), resolvedPath)) {
std::string resolved = resolvedPath;
- if (starts_with(resolved, src_root_)) {
- b = resolved.substr(src_root_.size());
- }
}
for (std::vector<std::string>::const_iterator it =
banned_directories_.begin();
it != banned_directories_.end(); ++it) {
- if (starts_with(b, *it)) {
+ // If we can find any of the banned path components in this path, then
+ // this file is rejected.
+ if (b.find(*it) != std::string::npos)
return true;
- }
}
}
« no previous file with comments | « tools/clang/plugins/ChromeClassTester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698