Make ASTReader/ASTWriter friends of SourceLocation. They already

depend on internal knowledge of SourceLocation.

llvm-svn: 140056
This commit is contained in:
Argyrios Kyrtzidis 2011-09-19 20:40:08 +00:00
parent 9671ea9387
commit c284238aa2
2 changed files with 6 additions and 8 deletions

View File

@ -84,6 +84,8 @@ private:
class SourceLocation {
unsigned ID;
friend class SourceManager;
friend class ASTReader;
friend class ASTWriter;
enum {
MacroIDBit = 1U << 31
};

View File

@ -1143,15 +1143,11 @@ public:
/// \brief Read a source location from raw form.
SourceLocation ReadSourceLocation(Module &Module, unsigned Raw) const {
unsigned Flag = Raw & (1U << 31);
unsigned Offset = Raw & ~(1U << 31);
assert(Module.SLocRemap.find(Offset) != Module.SLocRemap.end() &&
SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw);
assert(Module.SLocRemap.find(Loc.getOffset()) != Module.SLocRemap.end() &&
"Cannot find offset to remap.");
int Remap = Module.SLocRemap.find(Offset)->second;
Offset += Remap;
assert((Offset & (1U << 31)) == 0 &&
"Bad offset in reading source location");
return SourceLocation::getFromRawEncoding(Offset | Flag);
int Remap = Module.SLocRemap.find(Loc.getOffset())->second;
return Loc.getFileLocWithOffset(Remap);
}
/// \brief Read a source location.