Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / tools / clang / plugins / ChromeClassTester.cpp
index 5ce04e5..c8bc543 100644 (file)
@@ -149,36 +149,34 @@ void ChromeClassTester::BuildBannedLists() {
   banned_namespaces_.push_back("std");
   banned_namespaces_.push_back("__gnu_cxx");
 
-  // We're in the process of renaming WebKit to blink.
-  // TODO(abarth): Remove WebKit once the rename is complete.
-  banned_namespaces_.push_back("WebKit");
   banned_namespaces_.push_back("blink");
-
-  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/");
-  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_.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/");
+  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/");
 
   // 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_.push_back("/gen/");
+  banned_directories_.push_back("/geni/");
+  banned_directories_.push_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_.push_back("/automation/");
 
   // Don't check system headers.
   banned_directories_.push_back("/Developer/");
@@ -279,19 +277,15 @@ bool ChromeClassTester::InBannedDirectory(SourceLocation loc) {
   // in that case. As a workaround, strip that prefix.
   filename = lstrip(filename, "/usr/local/google");
 
-  for (std::vector<std::string>::const_iterator it =
-           banned_directories_.begin();
-       it != banned_directories_.end(); ++it) {
-    // If we can find any of the banned path components in this path, then
+  for (size_t i = 0; i < banned_directories_.size(); ++i) {
+    // If any of the banned directories occur as a component in filename,
     // this file is rejected.
-    size_t index = filename.find(*it);
-    if (index != std::string::npos) {
-      bool matches_full_dir_name = index == 0 || filename[index - 1] == '/';
-      if ((*it)[0] == '/')
-        matches_full_dir_name = true;
-      if (matches_full_dir_name)
-        return true;
-    }
+    const std::string& banned_dir = banned_directories_[i];
+    assert(banned_dir.front() == '/' && "Banned dir must start with '/'");
+    assert(banned_dir.back() == '/' && "Banned dir must end with '/'");
+
+    if (filename.find(banned_dir) != std::string::npos)
+      return true;
   }
 
   return false;