Expose a useful helper method.

llvm-svn: 38596
This commit is contained in:
Chris Lattner 2006-06-30 06:10:08 +00:00
parent 098dfc5e7e
commit 7d6a4f6746
2 changed files with 20 additions and 0 deletions

View File

@ -120,6 +120,20 @@ unsigned SourceManager::createFileIDForMacroExp(SourceLocation SourcePos,
return FileIDs.size();
}
/// getInstantiationLoc - Return a new SourceLocation that encodes the fact
/// that a token from physloc PhysLoc should actually be referenced from
/// InstantiationLoc.
SourceLocation SourceManager::getInstantiationLoc(SourceLocation PhysLoc,
SourceLocation InstantLoc) {
unsigned CharFilePos = PhysLoc.getRawFilePos();
unsigned CharFileID = PhysLoc.getFileID();
unsigned InstantiationFileID =
createFileIDForMacroExp(InstantLoc, CharFileID);
return SourceLocation(InstantiationFileID, CharFilePos);
}
/// getCharacterData - Return a pointer to the start of the specified location
/// in the appropriate SourceBuffer. This returns null if it cannot be

View File

@ -184,6 +184,12 @@ public:
return createFileID(createMemBufferInfoRec(Buffer), SourceLocation());
}
/// getInstantiationLoc - Return a new SourceLocation that encodes the fact
/// that a token from physloc PhysLoc should actually be referenced from
/// InstantiationLoc.
SourceLocation getInstantiationLoc(SourceLocation PhysLoc,
SourceLocation InstantiationLoc);
/// createFileIDForMacroExp - Return a new FileID for a macro expansion at
/// SourcePos, where the macro token character came from PhysicalFileID.
///