Change SourceManager::getInstantiationLoc to take virtual locations, doing its

virtual->physical mapping explicitly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39867 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-07-15 06:35:27 +00:00
Родитель fa2eaabd30
Коммит abca2bba54
3 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -166,11 +166,12 @@ unsigned SourceManager::createFileID(const InfoRec *File,
/// getInstantiationLoc - Return a new SourceLocation that encodes the fact /// getInstantiationLoc - Return a new SourceLocation that encodes the fact
/// that a token from physloc PhysLoc should actually be referenced from /// that a token from physloc PhysLoc should actually be referenced from
/// InstantiationLoc. /// InstantiationLoc.
SourceLocation SourceManager::getInstantiationLoc(SourceLocation PhysLoc, SourceLocation SourceManager::getInstantiationLoc(SourceLocation VirtLoc,
SourceLocation InstantLoc) { SourceLocation InstantLoc) {
assert(getFIDInfo(PhysLoc.getFileID())->IDType != // The specified source location may be a mapped location, due to a macro
SrcMgr::FileIDInfo::MacroExpansion && // instantiation or #line directive. Strip off this information to find out
"Location instantiated in a macro?"); // where the characters are actually located.
SourceLocation PhysLoc = getPhysicalLoc(VirtLoc);
// Resolve InstantLoc down to a real logical location. // Resolve InstantLoc down to a real logical location.
InstantLoc = getLogicalLoc(InstantLoc); InstantLoc = getLogicalLoc(InstantLoc);

Просмотреть файл

@ -499,8 +499,8 @@ void MacroExpander::Lex(LexerToken &Tok) {
// The token could have come from a prior macro expansion. In that case, // The token could have come from a prior macro expansion. In that case,
// ignore the macro expand part to get to the physloc. This happens for // ignore the macro expand part to get to the physloc. This happens for
// stuff like: #define A(X) X A(A(X)) A(1) // stuff like: #define A(X) X A(A(X)) A(1)
SourceLocation PhysLoc = SrcMgr.getPhysicalLoc(Tok.getLocation()); Tok.setLocation(SrcMgr.getInstantiationLoc(Tok.getLocation(),
Tok.setLocation(SrcMgr.getInstantiationLoc(PhysLoc, InstantiateLoc)); InstantiateLoc));
} }
// If this is the first token, set the lexical properties of the token to // If this is the first token, set the lexical properties of the token to

Просмотреть файл

@ -195,9 +195,8 @@ public:
} }
/// getInstantiationLoc - Return a new SourceLocation that encodes the fact /// getInstantiationLoc - Return a new SourceLocation that encodes the fact
/// that a token from physloc PhysLoc should actually be referenced from /// that a token at Loc should actually be referenced from InstantiationLoc.
/// InstantiationLoc. SourceLocation getInstantiationLoc(SourceLocation Loc,
SourceLocation getInstantiationLoc(SourceLocation PhysLoc,
SourceLocation InstantiationLoc); SourceLocation InstantiationLoc);
/// getBuffer - Return the buffer for the specified FileID. /// getBuffer - Return the buffer for the specified FileID.