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; |
- } |
} |
} |