diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 15 | ||||
-rw-r--r-- | lib/Lex/PPMacroExpansion.cpp | 3 | ||||
-rw-r--r-- | lib/Lex/Pragma.cpp | 1 |
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 9e3d283d88..a719a541a3 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -406,6 +406,7 @@ void Preprocessor::PTHSkipExcludedConditionalBlock() { /// 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 *Preprocessor::LookupFile(const char *FilenameStart, 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 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok, // 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/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 80202ddb6d..1c8af8385b 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -561,7 +561,8 @@ static bool EvaluateHasIncludeCommon(bool &Result, Token &Tok, // 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/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index 8b46f71691..74692faf42 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -302,6 +302,7 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) { // 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) |