| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A general interface for filtering and only acting on classes in Chromium C++ | 5 // A general interface for filtering and only acting on classes in Chromium C++ |
| 6 // code. | 6 // code. |
| 7 | 7 |
| 8 #include "ChromeClassTester.h" | 8 #include "ChromeClassTester.h" |
| 9 | 9 |
| 10 #include <sys/param.h> | 10 #include <sys/param.h> |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 banned_namespaces_.push_back("blink"); | 143 banned_namespaces_.push_back("blink"); |
| 144 banned_namespaces_.push_back("WTF"); | 144 banned_namespaces_.push_back("WTF"); |
| 145 | 145 |
| 146 banned_directories_.push_back("/third_party/"); | 146 banned_directories_.push_back("/third_party/"); |
| 147 banned_directories_.push_back("/native_client/"); | 147 banned_directories_.push_back("/native_client/"); |
| 148 banned_directories_.push_back("/breakpad/"); | 148 banned_directories_.push_back("/breakpad/"); |
| 149 banned_directories_.push_back("/courgette/"); | 149 banned_directories_.push_back("/courgette/"); |
| 150 banned_directories_.push_back("/pdf/"); | 150 banned_directories_.push_back("/pdf/"); |
| 151 banned_directories_.push_back("/ppapi/"); | 151 banned_directories_.push_back("/ppapi/"); |
| 152 banned_directories_.push_back("/usr/"); | 152 banned_directories_.push_back("/usr/include/"); |
| 153 banned_directories_.push_back("/usr/lib/"); |
| 154 banned_directories_.push_back("/usr/local/include/"); |
| 155 banned_directories_.push_back("/usr/local/lib/"); |
| 153 banned_directories_.push_back("/testing/"); | 156 banned_directories_.push_back("/testing/"); |
| 154 banned_directories_.push_back("/v8/"); | 157 banned_directories_.push_back("/v8/"); |
| 155 banned_directories_.push_back("/dart/"); | 158 banned_directories_.push_back("/dart/"); |
| 156 banned_directories_.push_back("/sdch/"); | 159 banned_directories_.push_back("/sdch/"); |
| 157 banned_directories_.push_back("/icu4c/"); | 160 banned_directories_.push_back("/icu4c/"); |
| 158 banned_directories_.push_back("/frameworks/"); | 161 banned_directories_.push_back("/frameworks/"); |
| 159 | 162 |
| 160 // Don't check autogenerated headers. | 163 // Don't check autogenerated headers. |
| 161 // Make puts them below $(builddir_name)/.../gen and geni. | 164 // Make puts them below $(builddir_name)/.../gen and geni. |
| 162 // Ninja puts them below OUTPUT_DIR/.../gen | 165 // Ninja puts them below OUTPUT_DIR/.../gen |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 259 } |
| 257 | 260 |
| 258 // We need to munge the paths so that they are relative to the repository | 261 // We need to munge the paths so that they are relative to the repository |
| 259 // srcroot. We first resolve the symlinktastic relative path and then | 262 // srcroot. We first resolve the symlinktastic relative path and then |
| 260 // remove our known srcroot from it if needed. | 263 // remove our known srcroot from it if needed. |
| 261 char resolvedPath[MAXPATHLEN]; | 264 char resolvedPath[MAXPATHLEN]; |
| 262 if (realpath(filename.c_str(), resolvedPath)) { | 265 if (realpath(filename.c_str(), resolvedPath)) { |
| 263 filename = resolvedPath; | 266 filename = resolvedPath; |
| 264 } | 267 } |
| 265 | 268 |
| 266 // On linux, chrome is often checked out to /usr/local/google. Due to the | |
| 267 // "usr" rule in banned_directories_, all diagnostics would be suppressed | |
| 268 // in that case. As a workaround, strip that prefix. | |
| 269 filename = lstrip(filename, "/usr/local/google"); | |
| 270 | |
| 271 for (size_t i = 0; i < banned_directories_.size(); ++i) { | 269 for (size_t i = 0; i < banned_directories_.size(); ++i) { |
| 272 // If any of the banned directories occur as a component in filename, | 270 // If any of the banned directories occur as a component in filename, |
| 273 // this file is rejected. | 271 // this file is rejected. |
| 274 const std::string& banned_dir = banned_directories_[i]; | 272 const std::string& banned_dir = banned_directories_[i]; |
| 275 assert(banned_dir.front() == '/' && "Banned dir must start with '/'"); | 273 assert(banned_dir.front() == '/' && "Banned dir must start with '/'"); |
| 276 assert(banned_dir.back() == '/' && "Banned dir must end with '/'"); | 274 assert(banned_dir.back() == '/' && "Banned dir must end with '/'"); |
| 277 | 275 |
| 278 if (filename.find(banned_dir) != std::string::npos) | 276 if (filename.find(banned_dir) != std::string::npos) |
| 279 return true; | 277 return true; |
| 280 } | 278 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 293 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); | 291 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); |
| 294 if (ploc.isInvalid()) { | 292 if (ploc.isInvalid()) { |
| 295 // If we're in an invalid location, we're looking at things that aren't | 293 // If we're in an invalid location, we're looking at things that aren't |
| 296 // actually stated in the source. | 294 // actually stated in the source. |
| 297 return false; | 295 return false; |
| 298 } | 296 } |
| 299 | 297 |
| 300 *filename = ploc.getFilename(); | 298 *filename = ploc.getFilename(); |
| 301 return true; | 299 return true; |
| 302 } | 300 } |
| OLD | NEW |