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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 } | 181 } |
| 182 | 182 |
| 183 return false; | 183 return false; |
| 184 } | 184 } |
| 185 | 185 |
| 186 std::string ChromeClassTester::GetNamespace(const Decl* record) { | 186 std::string ChromeClassTester::GetNamespace(const Decl* record) { |
| 187 return GetNamespaceImpl(record->getDeclContext(), ""); | 187 return GetNamespaceImpl(record->getDeclContext(), ""); |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool ChromeClassTester::InImplementationFile(SourceLocation record_location) { | 190 bool ChromeClassTester::InImplementationFile(SourceLocation record_location) { |
| 191 if (options_.follow_macro_expansion) { | |
| 192 // If |record_location| is a macro, check where it was called. | |
| 193 const SourceManager& source_manager = instance_.getSourceManager(); | |
| 194 record_location = source_manager.getExpansionRange(record_location).first; | |
|
Jeffrey Yasskin
2015/12/10 04:19:20
I thought I could just go to the outermost macro a
| |
| 195 } | |
| 196 | |
| 191 std::string filename; | 197 std::string filename; |
| 192 if (!GetFilename(record_location, &filename)) | 198 if (!GetFilename(record_location, &filename)) |
| 193 return false; | 199 return false; |
| 194 | 200 |
| 195 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || | 201 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || |
| 196 ends_with(filename, ".mm")) { | 202 ends_with(filename, ".mm")) { |
| 197 return true; | 203 return true; |
| 198 } | 204 } |
| 199 | 205 |
| 200 return false; | 206 return false; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 } | 321 } |
| 316 | 322 |
| 317 *filename = ploc.getFilename(); | 323 *filename = ploc.getFilename(); |
| 318 return true; | 324 return true; |
| 319 } | 325 } |
| 320 | 326 |
| 321 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { | 327 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { |
| 322 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error | 328 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error |
| 323 : DiagnosticsEngine::Warning; | 329 : DiagnosticsEngine::Warning; |
| 324 } | 330 } |
| OLD | NEW |