diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-07-02 23:00:20 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-07-02 23:00:20 +0000 |
| commit | 98a53124783a9b9b559b071628065659b9883783 (patch) | |
| tree | f434909e10aba4a18c7cfa11f69d78f8d6152296 /clang/Lex | |
| parent | e55e11ad040e559a4f281545563f12387303d685 (diff) | |
| download | bcm5719-llvm-98a53124783a9b9b559b071628065659b9883783.tar.gz bcm5719-llvm-98a53124783a9b9b559b071628065659b9883783.zip | |
Give tokens expanded from _Pragma directives correct source locations.
This implements test/Preprocessor/_Pragma-location.c
llvm-svn: 38619
Diffstat (limited to 'clang/Lex')
| -rw-r--r-- | clang/Lex/Pragma.cpp | 10 | ||||
| -rw-r--r-- | clang/Lex/Preprocessor.cpp | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/clang/Lex/Pragma.cpp b/clang/Lex/Pragma.cpp index 2cdbb72cf79..5aa1b23652e 100644 --- a/clang/Lex/Pragma.cpp +++ b/clang/Lex/Pragma.cpp @@ -114,11 +114,10 @@ void Preprocessor::Handle_Pragma(LexerToken &Tok) { // Plop the string (including the trailing null) into a buffer where we can // lex it. - SourceLocation TokLoc = ScratchBuf->getToken(&StrVal[0], StrVal.size()); + SourceLocation TokLoc = ScratchBuf->getToken(&StrVal[0], StrVal.size(), + PragmaLoc); const char *StrData = SourceMgr.getCharacterData(TokLoc); - // FIXME: Create appropriate mapping info for this FileID, so that we know the - // tokens are coming out of the input string (StrLoc). unsigned FileID = TokLoc.getFileID(); assert(FileID && "Could not create FileID for predefines?"); @@ -126,7 +125,6 @@ void Preprocessor::Handle_Pragma(LexerToken &Tok) { // like any others. Lexer *TL = new Lexer(SourceMgr.getBuffer(FileID), FileID, *this, StrData, StrData+StrVal.size()-1 /* no null */); - EnterSourceFileWithLexer(TL, 0); // Ensure that the lexer thinks it is inside a directive, so that end \n will // return an EOM token. @@ -134,7 +132,9 @@ void Preprocessor::Handle_Pragma(LexerToken &Tok) { // This lexer really is for _Pragma. TL->Is_PragmaLexer = true; - + + EnterSourceFileWithLexer(TL, 0); + // With everything set up, lex this as a #pragma directive. HandlePragmaDirective(); diff --git a/clang/Lex/Preprocessor.cpp b/clang/Lex/Preprocessor.cpp index 39b2572a5ab..9884eb25c9f 100644 --- a/clang/Lex/Preprocessor.cpp +++ b/clang/Lex/Preprocessor.cpp @@ -411,7 +411,7 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer, CurMacroExpander = 0; // Notify the client, if desired, that we are in a new source file. - if (FileChangeHandler) { + if (FileChangeHandler && !CurLexer->Is_PragmaLexer) { DirectoryLookup::DirType FileType = DirectoryLookup::NormalHeaderDir; // Get the file entry for the current file. |

