Add -isystem-prefix and -ino-system-prefix arguments, which can be used to
override whether headers are system headers by checking for prefixes of the
header name specified in the #include directive.

This allows warnings to be disabled for third-party code which is found in
specific subdirectories of include paths.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158418 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp
index d688e23..4531335 100644
--- a/lib/Lex/HeaderSearch.cpp
+++ b/lib/Lex/HeaderSearch.cpp
@@ -510,6 +510,16 @@
     if (HFI.DirInfo == SrcMgr::C_User && InUserSpecifiedSystemFramework)
       HFI.DirInfo = SrcMgr::C_System;
 
+    // If the filename matches a known system header prefix, override
+    // whether the file is a system header.
+    for (unsigned i = SystemHeaderPrefixes.size(); i; --i) {
+      if (Filename.startswith(SystemHeaderPrefixes[i-1].first)) {
+        HFI.DirInfo = SystemHeaderPrefixes[i-1].second ? SrcMgr::C_System
+                                                       : SrcMgr::C_User;
+        break;
+      }
+    }
+
     // If this file is found in a header map and uses the framework style of
     // includes, then this header is part of a framework we're building.
     if (CurDir->isIndexHeaderMap()) {