]> granicus.if.org Git - clang/commitdiff
Make ASTReader/ASTWriter friends of SourceLocation. They already
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 19 Sep 2011 20:40:08 +0000 (20:40 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 19 Sep 2011 20:40:08 +0000 (20:40 +0000)
depend on internal knowledge of SourceLocation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140056 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/SourceLocation.h
include/clang/Serialization/ASTReader.h

index f3b5f266497a42f8606370dbce3e33c5cbac574a..51734ef748d2b636278f4ad29be6c05cf47f7187 100644 (file)
@@ -84,6 +84,8 @@ private:
 class SourceLocation {
   unsigned ID;
   friend class SourceManager;
+  friend class ASTReader;
+  friend class ASTWriter;
   enum {
     MacroIDBit = 1U << 31
   };
index ce980f775b11776063f252bf24c57d85651d7b35..1a4603d53ac5a190ebb0e0f8390fef1c25152b6f 100644 (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.