| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return true; | 190 return true; |
| 191 if (HasIgnoredBases(base_record)) | 191 if (HasIgnoredBases(base_record)) |
| 192 return true; | 192 return true; |
| 193 } | 193 } |
| 194 return false; | 194 return false; |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool ChromeClassTester::InImplementationFile(SourceLocation record_location) { | 197 bool ChromeClassTester::InImplementationFile(SourceLocation record_location) { |
| 198 std::string filename; | 198 std::string filename; |
| 199 | 199 |
| 200 if (options_.follow_macro_expansion) { | 200 // If |record_location| is a macro, check the whole chain of expansions. |
| 201 // If |record_location| is a macro, check the whole chain of expansions. | 201 const SourceManager& source_manager = instance_.getSourceManager(); |
| 202 const SourceManager& source_manager = instance_.getSourceManager(); | 202 while (true) { |
| 203 while (true) { | 203 if (GetFilename(record_location, &filename)) { |
| 204 if (GetFilename(record_location, &filename)) { | 204 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || |
| 205 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || | 205 ends_with(filename, ".mm")) { |
| 206 ends_with(filename, ".mm")) { | 206 return true; |
| 207 return true; | |
| 208 } | |
| 209 } | 207 } |
| 210 if (!record_location.isMacroID()) { | |
| 211 break; | |
| 212 } | |
| 213 record_location = | |
| 214 source_manager.getImmediateExpansionRange(record_location).first; | |
| 215 } | 208 } |
| 216 } else { | 209 if (!record_location.isMacroID()) { |
| 217 if (!GetFilename(record_location, &filename)) | 210 break; |
| 218 return false; | |
| 219 | |
| 220 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || | |
| 221 ends_with(filename, ".mm")) { | |
| 222 return true; | |
| 223 } | 211 } |
| 212 record_location = |
| 213 source_manager.getImmediateExpansionRange(record_location).first; |
| 224 } | 214 } |
| 225 | 215 |
| 226 return false; | 216 return false; |
| 227 } | 217 } |
| 228 | 218 |
| 229 void ChromeClassTester::BuildBannedLists() { | 219 void ChromeClassTester::BuildBannedLists() { |
| 230 banned_namespaces_.emplace("std"); | 220 banned_namespaces_.emplace("std"); |
| 231 banned_namespaces_.emplace("__gnu_cxx"); | 221 banned_namespaces_.emplace("__gnu_cxx"); |
| 232 | 222 |
| 233 if (options_.enforce_in_thirdparty_webkit) { | 223 if (options_.enforce_in_thirdparty_webkit) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 327 } |
| 338 | 328 |
| 339 *filename = ploc.getFilename(); | 329 *filename = ploc.getFilename(); |
| 340 return true; | 330 return true; |
| 341 } | 331 } |
| 342 | 332 |
| 343 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { | 333 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { |
| 344 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error | 334 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error |
| 345 : DiagnosticsEngine::Warning; | 335 : DiagnosticsEngine::Warning; |
| 346 } | 336 } |
| OLD | NEW |