implement rdar://7520940: published framework headers should
import other headers within the same framework with the full
framework path, not with a relative include.

llvm-svn: 93083
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 9e3d283..a719a54 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -406,6 +406,7 @@
 /// for system #include's or not (i.e. using <> instead of "").
 const FileEntry *Preprocessor::LookupFile(const char *FilenameStart,
                                           const char *FilenameEnd,
+                                          SourceLocation FilenameTokLoc,
                                           bool isAngled,
                                           const DirectoryLookup *FromDir,
                                           const DirectoryLookup *&CurDir) {
@@ -433,7 +434,16 @@
   const FileEntry *FE =
     HeaderInfo.LookupFile(FilenameStart, FilenameEnd,
                           isAngled, FromDir, CurDir, CurFileEnt);
-  if (FE) return FE;
+  if (FE) {
+    // Warn about normal quoted #include from framework headers.  Since
+    // framework headers are published (both public and private ones) they
+    // should not do relative searches, they should do an include relative to
+    // their framework.
+    if (!isAngled && CurDir && FilenameTokLoc.isValid() &&
+        CurDir->isFramework() && CurDir == CurDirLookup)
+      Diag(FilenameTokLoc, diag::warn_pp_relative_include_from_framework);
+    return FE;
+  }
 
   // Otherwise, see if this is a subframework header.  If so, this is relative
   // to one of the headers on the #include stack.  Walk the list of the current
@@ -1080,13 +1090,14 @@
   // Search include directories.
   const DirectoryLookup *CurDir;
   const FileEntry *File = LookupFile(FilenameStart, FilenameEnd,
+                                     FilenameTok.getLocation(),
                                      isAngled, LookupFrom, CurDir);
   if (File == 0) {
     Diag(FilenameTok, diag::err_pp_file_not_found)
        << std::string(FilenameStart, FilenameEnd);
     return;
   }
-
+  
   // Ask HeaderInfo if we should enter this #include file.  If not, #including
   // this file will have no effect.
   if (!HeaderInfo.ShouldEnterIncludeFile(File, isImport))
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 80202dd..1c8af83 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -561,7 +561,8 @@
   // Search include directories.
   const DirectoryLookup *CurDir;
   const FileEntry *File = PP.LookupFile(FilenameStart, FilenameEnd,
-                                     isAngled, LookupFrom, CurDir);
+                                        SourceLocation(),// produce no warnings.
+                                        isAngled, LookupFrom, CurDir);
 
   // Get the result value.  Result = true means the file exists.
   Result = File != 0;
diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index 8b46f71..74692fa 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -302,6 +302,7 @@
   // Search include directories for this file.
   const DirectoryLookup *CurDir;
   const FileEntry *File = LookupFile(FilenameStart, FilenameEnd,
+                                     FilenameTok.getLocation(),
                                      isAngled, 0, CurDir);
   if (File == 0) {
     Diag(FilenameTok, diag::err_pp_file_not_found)