From: Argyrios Kyrtzidis Date: Mon, 19 Sep 2011 20:40:08 +0000 (+0000) Subject: Make ASTReader/ASTWriter friends of SourceLocation. They already X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a4374812c56aa60672e291b07e14d3696bbb5a6;p=clang Make ASTReader/ASTWriter friends of SourceLocation. They already depend on internal knowledge of SourceLocation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140056 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index f3b5f26649..51734ef748 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -84,6 +84,8 @@ private: class SourceLocation { unsigned ID; friend class SourceManager; + friend class ASTReader; + friend class ASTWriter; enum { MacroIDBit = 1U << 31 }; diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index ce980f775b..1a4603d53a 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -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.