Index: tools/clang/plugins/ChromeClassTester.cpp |
diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp |
index 0bf4ba511adfc9e250fca7d2d4d602144e88d010..dea977f106d85725ed153e957e27cba0047b08d2 100644 |
--- a/tools/clang/plugins/ChromeClassTester.cpp |
+++ b/tools/clang/plugins/ChromeClassTester.cpp |
@@ -9,6 +9,8 @@ |
#include <sys/param.h> |
+#include <string> |
+ |
#include "clang/Basic/FileManager.h" |
using namespace clang; |
@@ -171,6 +173,22 @@ bool ChromeClassTester::InBannedNamespace(const Decl* record) { |
return false; |
} |
+bool ChromeClassTester::InImplementationFile( |
+ const SourceLocation& record_location) { |
+ const SourceManager &SM = instance().getSourceManager(); |
+ SourceLocation spelling_location = SM.getSpellingLoc(record_location); |
+ PresumedLoc ploc = SM.getPresumedLoc(spelling_location); |
+ if (ploc.isInvalid()) |
+ return false; |
+ |
+ std::string b = ploc.getFilename(); |
+ |
+ if (ends_with(b, ".cc") || ends_with(b, ".cpp") || ends_with(b, ".mm")) |
+ return true; |
+ |
+ return false; |
+} |
+ |
std::string ChromeClassTester::GetNamespace(const Decl* record) { |
return GetNamespaceImpl(record->getDeclContext(), ""); |
} |
@@ -217,11 +235,6 @@ bool ChromeClassTester::InBannedDirectory(SourceLocation loc) { |
if (b == "<scratch space>") |
return true; |
- // Don't complain about these things in implementation files. |
- if (ends_with(b, ".cc") || ends_with(b, ".cpp") || ends_with(b, ".mm")) { |
- return true; |
- } |
- |
// Don't complain about autogenerated protobuf files. |
if (ends_with(b, ".pb.h")) { |
return true; |