From 4fd8b958be31fff43ab1aa01908de06ccce3d15d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 19 Jan 2009 08:01:53 +0000 Subject: do not use SourceManager::getFileCharacteristic(FileID), it is not safe because a #line can change the file characteristic on a per-loc basis. llvm-svn: 62502 --- clang/lib/Lex/PPLexerChange.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'clang/lib/Lex/PPLexerChange.cpp') diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index f8c8636fcb1..e425f6b737b 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -118,9 +118,10 @@ void Preprocessor::EnterSourceFileWithPTH(PTHLexer *PL, // Notify the client, if desired, that we are in a new source file. if (Callbacks) { FileID FID = CurPPLexer->getFileID(); - SrcMgr::CharacteristicKind FileType = SourceMgr.getFileCharacteristic(FID); - Callbacks->FileChanged(SourceMgr.getLocForStartOfFile(FID), - PPCallbacks::EnterFile, FileType); + SourceLocation EnterLoc = SourceMgr.getLocForStartOfFile(FID); + SrcMgr::CharacteristicKind FileType = + SourceMgr.getFileCharacteristic(EnterLoc); + Callbacks->FileChanged(EnterLoc, PPCallbacks::EnterFile, FileType); } } @@ -194,9 +195,9 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) { // Notify the client, if desired, that we are in a new source file. if (Callbacks && !isEndOfMacro && CurPPLexer) { SrcMgr::CharacteristicKind FileType = - SourceMgr.getFileCharacteristic(CurPPLexer->getFileID()); - Callbacks->FileChanged(CurPPLexer->getSourceLocation(), - PPCallbacks::ExitFile, FileType); + SourceMgr.getFileCharacteristic(CurPPLexer->getSourceLocation()); + Callbacks->FileChanged(CurPPLexer->getSourceLocation(), + PPCallbacks::ExitFile, FileType); } // Client should lex another token. -- cgit v1.2.3