Index: tools/clang/plugins/ChromeClassTester.cpp |
diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp |
index a08ead4bd5d39f6c885d0ec2f7648451d14464c5..d0b0b3c773b9c3147a796c49cf9a6229b44f2048 100644 |
--- a/tools/clang/plugins/ChromeClassTester.cpp |
+++ b/tools/clang/plugins/ChromeClassTester.cpp |
@@ -7,6 +7,8 @@ |
#include "ChromeClassTester.h" |
+#include <algorithm> |
+ |
#include "clang/AST/AST.h" |
#include "clang/Basic/FileManager.h" |
#include "clang/Basic/SourceManager.h" |
@@ -129,83 +131,87 @@ bool ChromeClassTester::InImplementationFile(SourceLocation record_location) { |
} |
void ChromeClassTester::BuildBannedLists() { |
- banned_namespaces_.push_back("std"); |
- banned_namespaces_.push_back("__gnu_cxx"); |
- |
- banned_namespaces_.push_back("blink"); |
- banned_namespaces_.push_back("WTF"); |
- |
- banned_directories_.push_back("/third_party/"); |
- banned_directories_.push_back("/native_client/"); |
- banned_directories_.push_back("/breakpad/"); |
- banned_directories_.push_back("/courgette/"); |
- banned_directories_.push_back("/pdf/"); |
- banned_directories_.push_back("/ppapi/"); |
- banned_directories_.push_back("/usr/include/"); |
- banned_directories_.push_back("/usr/lib/"); |
- banned_directories_.push_back("/usr/local/include/"); |
- banned_directories_.push_back("/usr/local/lib/"); |
- banned_directories_.push_back("/testing/"); |
- banned_directories_.push_back("/v8/"); |
- banned_directories_.push_back("/dart/"); |
- banned_directories_.push_back("/sdch/"); |
- banned_directories_.push_back("/icu4c/"); |
- banned_directories_.push_back("/frameworks/"); |
+ banned_namespaces_.emplace_back("std"); |
Nico
2015/04/12 04:19:14
nit: I'd keep push_back since everybody knows what
dcheng
2015/04/12 06:29:30
But but but C++11!
I'll probably revisit this in
|
+ banned_namespaces_.emplace_back("__gnu_cxx"); |
+ |
+ banned_namespaces_.emplace_back("blink"); |
+ banned_namespaces_.emplace_back("WTF"); |
+ |
+ // System headers: |
+#if defined(LLVM_ON_UNIX) |
+ banned_directories_.emplace_back("/usr/include/"); |
+ banned_directories_.emplace_back("/usr/lib/"); |
+ banned_directories_.emplace_back("/usr/local/include/"); |
+ banned_directories_.emplace_back("/usr/local/lib/"); |
+#endif |
+ |
+ banned_directories_.emplace_back("/third_party/"); |
+ banned_directories_.emplace_back("/native_client/"); |
+ banned_directories_.emplace_back("/breakpad/"); |
+ banned_directories_.emplace_back("/courgette/"); |
+ banned_directories_.emplace_back("/pdf/"); |
+ banned_directories_.emplace_back("/ppapi/"); |
+ banned_directories_.emplace_back("/testing/"); |
+ banned_directories_.emplace_back("/v8/"); |
+ banned_directories_.emplace_back("/dart/"); |
+ banned_directories_.emplace_back("/sdch/"); |
+ banned_directories_.emplace_back("/icu4c/"); |
+ banned_directories_.emplace_back("/frameworks/"); |
// Don't check autogenerated headers. |
// Make puts them below $(builddir_name)/.../gen and geni. |
// Ninja puts them below OUTPUT_DIR/.../gen |
// Xcode has a fixed output directory for everything. |
- banned_directories_.push_back("/gen/"); |
- banned_directories_.push_back("/geni/"); |
- banned_directories_.push_back("/xcodebuild/"); |
+ banned_directories_.emplace_back("/gen/"); |
+ banned_directories_.emplace_back("/geni/"); |
+ banned_directories_.emplace_back("/xcodebuild/"); |
// You are standing in a mazy of twisty dependencies, all resolved by |
// putting everything in the header. |
- banned_directories_.push_back("/automation/"); |
+ banned_directories_.emplace_back("/automation/"); |
// Don't check system headers. |
- banned_directories_.push_back("/Developer/"); |
+ banned_directories_.emplace_back("/Developer/"); |
// Used in really low level threading code that probably shouldn't be out of |
// lined. |
- ignored_record_names_.insert("ThreadLocalBoolean"); |
+ ignored_record_names_.emplace("ThreadLocalBoolean"); |
// A complicated pickle derived struct that is all packed integers. |
- ignored_record_names_.insert("Header"); |
+ ignored_record_names_.emplace("Header"); |
// Part of the GPU system that uses multiple included header |
// weirdness. Never getting this right. |
- ignored_record_names_.insert("Validators"); |
+ ignored_record_names_.emplace("Validators"); |
// Has a UNIT_TEST only constructor. Isn't *terribly* complex... |
- ignored_record_names_.insert("AutocompleteController"); |
- ignored_record_names_.insert("HistoryURLProvider"); |
+ ignored_record_names_.emplace("AutocompleteController"); |
+ ignored_record_names_.emplace("HistoryURLProvider"); |
// Because of chrome frame |
- ignored_record_names_.insert("ReliabilityTestSuite"); |
+ ignored_record_names_.emplace("ReliabilityTestSuite"); |
// Used over in the net unittests. A large enough bundle of integers with 1 |
// non-pod class member. Probably harmless. |
- ignored_record_names_.insert("MockTransaction"); |
+ ignored_record_names_.emplace("MockTransaction"); |
// Enum type with _LAST members where _LAST doesn't mean last enum value. |
- ignored_record_names_.insert("ServerFieldType"); |
+ ignored_record_names_.emplace("ServerFieldType"); |
// Used heavily in ui_base_unittests and once in views_unittests. Fixing this |
// isn't worth the overhead of an additional library. |
- ignored_record_names_.insert("TestAnimationDelegate"); |
+ ignored_record_names_.emplace("TestAnimationDelegate"); |
// Part of our public interface that nacl and friends use. (Arguably, this |
// should mean that this is a higher priority but fixing this looks hard.) |
- ignored_record_names_.insert("PluginVersionInfo"); |
+ ignored_record_names_.emplace("PluginVersionInfo"); |
// Measured performance improvement on cc_perftests. See |
// https://codereview.chromium.org/11299290/ |
- ignored_record_names_.insert("QuadF"); |
+ ignored_record_names_.emplace("QuadF"); |
// Enum type with _LAST members where _LAST doesn't mean last enum value. |
- ignored_record_names_.insert("ViewID"); |
+ ignored_record_names_.emplace("ViewID"); |
} |
std::string ChromeClassTester::GetNamespaceImpl(const DeclContext* context, |
@@ -232,6 +238,9 @@ std::string ChromeClassTester::GetNamespaceImpl(const DeclContext* context, |
} |
bool ChromeClassTester::InBannedDirectory(SourceLocation loc) { |
+ if (instance().getSourceManager().isInSystemHeader(loc)) |
+ return true; |
+ |
std::string filename; |
if (!GetFilename(loc, &filename)) { |
// If the filename cannot be determined, simply treat this as a banned |
@@ -250,7 +259,7 @@ bool ChromeClassTester::InBannedDirectory(SourceLocation loc) { |
return true; |
} |
-#ifdef LLVM_ON_UNIX |
+#if defined(LLVM_ON_UNIX) |
// We need to munge the paths so that they are relative to the repository |
// srcroot. We first resolve the symlinktastic relative path and then |
// remove our known srcroot from it if needed. |
@@ -260,6 +269,10 @@ bool ChromeClassTester::InBannedDirectory(SourceLocation loc) { |
} |
#endif |
+#if defined(LLVM_ON_WIN32) |
+ std::replace(filename.begin(), filename.end(), '\\', '/'); |
+#endif |
+ |
for (const std::string& banned_dir : banned_directories_) { |
// If any of the banned directories occur as a component in filename, |
// this file is rejected. |