[cfe-commits] r38619 - in /cfe/cfe/trunk/Lex: Pragma.cpp Preprocessor.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:23:15 PDT 2007
Author: sabre
Date: Wed Jul 11 11:23:15 2007
New Revision: 38619
URL: http://llvm.org/viewvc/llvm-project?rev=38619&view=rev
Log:
Give tokens expanded from _Pragma directives correct source locations.
This implements test/Preprocessor/_Pragma-location.c
Modified:
cfe/cfe/trunk/Lex/Pragma.cpp
cfe/cfe/trunk/Lex/Preprocessor.cpp
Modified: cfe/cfe/trunk/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Pragma.cpp?rev=38619&r1=38618&r2=38619&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/Pragma.cpp (original)
+++ cfe/cfe/trunk/Lex/Pragma.cpp Wed Jul 11 11:23:15 2007
@@ -114,11 +114,10 @@
// 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 @@
// 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 @@
// This lexer really is for _Pragma.
TL->Is_PragmaLexer = true;
-
+
+ EnterSourceFileWithLexer(TL, 0);
+
// With everything set up, lex this as a #pragma directive.
HandlePragmaDirective();
Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=38619&r1=38618&r2=38619&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:23:15 2007
@@ -411,7 +411,7 @@
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.
More information about the cfe-commits
mailing list