Chromium Code Reviews| Index: tools/clang/plugins/ChromeClassTester.cpp |
| diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp |
| index 6565cf816cf660115840f872e9dfd779ff292817..53d6feddf2d3524027f0514facd4e24feeee1b47 100644 |
| --- a/tools/clang/plugins/ChromeClassTester.cpp |
| +++ b/tools/clang/plugins/ChromeClassTester.cpp |
| @@ -7,6 +7,8 @@ |
| #include "ChromeClassTester.h" |
| +#include <sys/param.h> |
| + |
| using namespace clang; |
| namespace { |
| @@ -30,20 +32,22 @@ ChromeClassTester::ChromeClassTester(CompilerInstance& instance) |
| 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("/usr"); |
| - banned_directories_.push_back("testing"); |
| - banned_directories_.push_back("googleurl"); |
| - banned_directories_.push_back("v8"); |
| - banned_directories_.push_back("sdch"); |
| + // If the path to the file in question has this as a path component, than |
|
Nico
2011/02/24 16:00:05
then
|
| + // abort. We just do a simple string find on the path. |
| + 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/"); |
| + banned_directories_.push_back("testing/"); |
| + banned_directories_.push_back("googleurl/"); |
| + banned_directories_.push_back("v8/"); |
| + banned_directories_.push_back("sdch/"); |
| // 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/"); |
| // Used in really low level threading code that probably shouldn't be out of |
| // lined. |
| @@ -184,20 +188,18 @@ bool ChromeClassTester::InBannedDirectory(const SourceLocation& loc) { |
| return true; |
| } |
| - // Strip out all preceding path garbage. Linux and mac builds have |
| - // different path garbage, but after doing this, the path should be |
| - // relative to the root of the source tree. (If we didn't require |
| - // relative paths, we could have just used realpath().) |
| - if (!b.empty() && b[0] != '/') { |
| - size_t i = 0; |
| - for (; i < b.size() && (b[i] == '.' || b[i] == '/'); ++i) {} |
| - b = b.substr(i); |
| + // Resolve the path. |
| + char resolvedPath[MAXPATHLEN]; |
| + if (realpath(b.c_str(), resolvedPath)) { |
|
Nico
2011/02/24 16:00:05
did you measure the build time impact of this?
Elliot Glaysher
2011/02/25 01:51:21
On linux, this adds 14 seconds to make -j8 chrome
|
| + b = resolvedPath; |
| } |
| 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, than |
|
Nico
2011/02/24 16:00:05
then
|
| + // this file is rejected. |
| + if (b.find(*it) != std::string::npos) |
|
Nico
2011/02/24 16:00:05
hm, i'm almost certain this will start banning dir
Elliot Glaysher
2011/02/25 01:51:21
The relative paths will often be bellow the direct
|
| return true; |
| } |
| } |