diff options
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 22 | ||||
-rw-r--r-- | clang/lib/Lex/PPLexerChange.cpp | 22 | ||||
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 11 |
3 files changed, 24 insertions, 31 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 70cd0ed1d0b..504bc45dca4 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -600,7 +600,8 @@ static bool ConcatenateIncludeName(llvm::SmallVector<char, 128> &FilenameBuffer, /// HandleIncludeDirective - The "#include" tokens have just been read, read the /// file to be included from the lexer, then include it! This is a common /// routine with functionality shared between #include, #include_next and -/// #import. +/// #import. LookupFrom is set when this is a #include_next directive, it +/// specifies the file to start searching from. void Preprocessor::HandleIncludeDirective(Token &IncludeTok, const DirectoryLookup *LookupFrom, bool isImport) { @@ -666,15 +667,22 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok, return Diag(FilenameTok, diag::err_pp_file_not_found, std::string(FilenameStart, FilenameEnd)); - // Ask HeaderInfo if we should enter this #include file. - if (!HeaderInfo.ShouldEnterIncludeFile(File, isImport)) { - // If it returns true, #including this file will have no effect. + // Ask HeaderInfo if we should enter this #include file. If not, #including + // this file will have no effect. + if (!HeaderInfo.ShouldEnterIncludeFile(File, isImport)) return; - } - + + // The #included file will be considered to be a system header if either it is + // in a system include directory, or if the #includer is a system include + // header. + unsigned FileCharacter = + // FIXME: Casts + std::max((unsigned)HeaderInfo.getFileDirFlavor(File), + SourceMgr.getDirCharacteristic(getCurrentFileLexer()->getFileLoc())); + // Look up the file, create a File ID for it. unsigned FileID = SourceMgr.createFileID(File, FilenameTok.getLocation(), - isSystemHeader(File)); + FileCharacter); if (FileID == 0) return Diag(FilenameTok, diag::err_pp_file_not_found, std::string(FilenameStart, FilenameEnd)); diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index d1c44cfcdfc..1522bf5e8ca 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -78,7 +78,7 @@ void Preprocessor::EnterSourceFile(unsigned FileID, Lexer *TheLexer = new Lexer(SourceLocation::getFileLoc(FileID, 0), *this); EnterSourceFileWithLexer(TheLexer, CurDir); } - + /// EnterSourceFile - Add a source file to the top of the include stack and /// start lexing tokens from it instead of the current buffer. void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer, @@ -95,12 +95,10 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer, // Notify the client, if desired, that we are in a new source file. if (Callbacks && !CurLexer->Is_PragmaLexer) { - DirectoryLookup::DirType FileType = DirectoryLookup::NormalHeaderDir; - - // Get the file entry for the current file. - if (const FileEntry *FE = - SourceMgr.getFileEntryForLoc(CurLexer->getFileLoc())) - FileType = HeaderInfo.getFileDirFlavor(FE); + DirectoryLookup::DirType FileType = + // FIXME: + (DirectoryLookup::DirType) + SourceMgr.getDirCharacteristic(CurLexer->getFileLoc()); Callbacks->FileChanged(CurLexer->getFileLoc(), PPCallbacks::EnterFile, FileType); @@ -182,13 +180,11 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) { // Notify the client, if desired, that we are in a new source file. if (Callbacks && !isEndOfMacro && CurLexer) { - DirectoryLookup::DirType FileType = DirectoryLookup::NormalHeaderDir; + DirectoryLookup::DirType FileType = + // FIXME: + (DirectoryLookup::DirType) + SourceMgr.getDirCharacteristic(CurLexer->getFileLoc()); - // Get the file entry for the current file. - if (const FileEntry *FE = - SourceMgr.getFileEntryForLoc(CurLexer->getFileLoc())) - FileType = HeaderInfo.getFileDirFlavor(FE); - Callbacks->FileChanged(CurLexer->getSourceLocation(CurLexer->BufferPtr), PPCallbacks::ExitFile, FileType); } diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 36e80c91cfa..691f46ac2d1 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -117,17 +117,6 @@ Preprocessor::~Preprocessor() { delete Callbacks; } -bool Preprocessor::isSystemHeader(const FileEntry* F) const { - if (F) { - DirectoryLookup::DirType DirInfo = HeaderInfo.getFileDirFlavor(F); - if (DirInfo == DirectoryLookup::SystemHeaderDir || - DirInfo == DirectoryLookup::ExternCSystemHeaderDir) - return true; - } - return false; -} - - /// Diag - Forwarding function for diagnostics. This emits a diagnostic at /// the specified Token's location, translating the token's start /// position in the current buffer into a SourcePosition object for rendering. |