Chromium Code Reviews| 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 <algorithm> | 10 #include <algorithm> |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 // On Posix, realpath() has made the path absolute. On Windows, this isn't | 143 // On Posix, realpath() has made the path absolute. On Windows, this isn't |
| 144 // necessarily true, so prepend a '/' to the path to make sure the | 144 // necessarily true, so prepend a '/' to the path to make sure the |
| 145 // banned_directories_ loop below works correctly. | 145 // banned_directories_ loop below works correctly. |
| 146 // This turns e.g. "gen/dir/file.cc" to "/gen/dir/file.cc" which lets the | 146 // This turns e.g. "gen/dir/file.cc" to "/gen/dir/file.cc" which lets the |
| 147 // "/gen/" banned_dir work. | 147 // "/gen/" banned_dir work. |
| 148 // This seems simpler than converting to utf16, calling GetFullPathNameW(), | 148 // This seems simpler than converting to utf16, calling GetFullPathNameW(), |
| 149 // and converting back to utf8. | 149 // and converting back to utf8. |
| 150 filename.insert(filename.begin(), '/'); | 150 filename.insert(filename.begin(), '/'); |
| 151 #endif | 151 #endif |
| 152 | 152 |
| 153 for (const std::string& allowed_dir : allowed_directories_) { | |
| 154 // If any of the allowed directories occur as a component in filename, | |
| 155 // this file is allowed. | |
| 156 assert(allowed_dir.front() == '/' && "Allowed dir must start with '/'"); | |
| 157 assert(allowed_dir.back() == '/' && "Allowed dir must end with '/'"); | |
| 158 | |
| 159 if (filename.find(allowed_dir) != std::string::npos) | |
| 160 return false; | |
| 161 } | |
| 162 | |
| 153 for (const std::string& banned_dir : banned_directories_) { | 163 for (const std::string& banned_dir : banned_directories_) { |
| 154 // If any of the banned directories occur as a component in filename, | 164 // If any of the banned directories occur as a component in filename, |
| 155 // this file is rejected. | 165 // this file is rejected. |
| 156 assert(banned_dir.front() == '/' && "Banned dir must start with '/'"); | 166 assert(banned_dir.front() == '/' && "Banned dir must start with '/'"); |
| 157 assert(banned_dir.back() == '/' && "Banned dir must end with '/'"); | 167 assert(banned_dir.back() == '/' && "Banned dir must end with '/'"); |
| 158 | 168 |
| 159 if (filename.find(banned_dir) != std::string::npos) | 169 if (filename.find(banned_dir) != std::string::npos) |
| 160 return true; | 170 return true; |
| 161 } | 171 } |
| 162 | 172 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 184 | 194 |
| 185 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || | 195 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || |
| 186 ends_with(filename, ".mm")) { | 196 ends_with(filename, ".mm")) { |
| 187 return true; | 197 return true; |
| 188 } | 198 } |
| 189 | 199 |
| 190 return false; | 200 return false; |
| 191 } | 201 } |
| 192 | 202 |
| 193 void ChromeClassTester::BuildBannedLists() { | 203 void ChromeClassTester::BuildBannedLists() { |
| 194 banned_namespaces_.push_back("std"); | 204 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
| |
| 195 banned_namespaces_.push_back("__gnu_cxx"); | 205 banned_namespaces_.insert("__gnu_cxx"); |
| 196 | 206 |
| 197 if (!options_.enforce_blink) { | 207 if (!options_.enforce_overriding_blink) { |
| 198 banned_namespaces_.push_back("blink"); | 208 banned_namespaces_.insert("blink"); |
| 199 banned_namespaces_.push_back("WTF"); | 209 banned_namespaces_.insert("WTF"); |
| 200 } | 210 } |
| 201 | 211 |
| 202 banned_directories_.push_back("/third_party/"); | 212 if (options_.enforce_in_thirdparty_webkit) { |
| 203 banned_directories_.push_back("/native_client/"); | 213 allowed_directories_.insert("/third_party/WebKit/"); |
| 204 banned_directories_.push_back("/breakpad/"); | 214 } |
| 205 banned_directories_.push_back("/courgette/"); | 215 |
| 206 banned_directories_.push_back("/pdf/"); | 216 banned_directories_.insert("/third_party/"); |
| 207 banned_directories_.push_back("/ppapi/"); | 217 banned_directories_.insert("/native_client/"); |
| 208 banned_directories_.push_back("/usr/include/"); | 218 banned_directories_.insert("/breakpad/"); |
| 209 banned_directories_.push_back("/usr/lib/"); | 219 banned_directories_.insert("/courgette/"); |
| 210 banned_directories_.push_back("/usr/local/include/"); | 220 banned_directories_.insert("/pdf/"); |
| 211 banned_directories_.push_back("/usr/local/lib/"); | 221 banned_directories_.insert("/ppapi/"); |
| 212 banned_directories_.push_back("/testing/"); | 222 banned_directories_.insert("/usr/include/"); |
| 213 banned_directories_.push_back("/v8/"); | 223 banned_directories_.insert("/usr/lib/"); |
| 214 banned_directories_.push_back("/dart/"); | 224 banned_directories_.insert("/usr/local/include/"); |
| 215 banned_directories_.push_back("/sdch/"); | 225 banned_directories_.insert("/usr/local/lib/"); |
| 216 banned_directories_.push_back("/icu4c/"); | 226 banned_directories_.insert("/testing/"); |
| 217 banned_directories_.push_back("/frameworks/"); | 227 banned_directories_.insert("/v8/"); |
| 228 banned_directories_.insert("/dart/"); | |
| 229 banned_directories_.insert("/sdch/"); | |
| 230 banned_directories_.insert("/icu4c/"); | |
| 231 banned_directories_.insert("/frameworks/"); | |
| 218 | 232 |
| 219 // Don't check autogenerated headers. | 233 // Don't check autogenerated headers. |
| 220 // Make puts them below $(builddir_name)/.../gen and geni. | 234 // Make puts them below $(builddir_name)/.../gen and geni. |
| 221 // Ninja puts them below OUTPUT_DIR/.../gen | 235 // Ninja puts them below OUTPUT_DIR/.../gen |
| 222 // Xcode has a fixed output directory for everything. | 236 // Xcode has a fixed output directory for everything. |
| 223 banned_directories_.push_back("/gen/"); | 237 banned_directories_.insert("/gen/"); |
| 224 banned_directories_.push_back("/geni/"); | 238 banned_directories_.insert("/geni/"); |
| 225 banned_directories_.push_back("/xcodebuild/"); | 239 banned_directories_.insert("/xcodebuild/"); |
| 226 | 240 |
| 227 // Used in really low level threading code that probably shouldn't be out of | 241 // Used in really low level threading code that probably shouldn't be out of |
| 228 // lined. | 242 // lined. |
| 229 ignored_record_names_.insert("ThreadLocalBoolean"); | 243 ignored_record_names_.insert("ThreadLocalBoolean"); |
| 230 | 244 |
| 231 // A complicated pickle derived struct that is all packed integers. | 245 // A complicated pickle derived struct that is all packed integers. |
| 232 ignored_record_names_.insert("Header"); | 246 ignored_record_names_.insert("Header"); |
| 233 | 247 |
| 234 // Part of the GPU system that uses multiple included header | 248 // Part of the GPU system that uses multiple included header |
| 235 // weirdness. Never getting this right. | 249 // weirdness. Never getting this right. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 return true; | 318 return true; |
| 305 } | 319 } |
| 306 | 320 |
| 307 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { | 321 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { |
| 308 if (options_.warn_only) | 322 if (options_.warn_only) |
| 309 return DiagnosticsEngine::Warning; | 323 return DiagnosticsEngine::Warning; |
| 310 | 324 |
| 311 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error | 325 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error |
| 312 : DiagnosticsEngine::Warning; | 326 : DiagnosticsEngine::Warning; |
| 313 } | 327 } |
| OLD | NEW |