[cfe-commits] r140056 - in /cfe/trunk/include/clang: Basic/SourceLocation.h Serialization/ASTReader.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Sep 19 13:40:08 PDT 2011
Author: akirtzidis
Date: Mon Sep 19 15:40:08 2011
New Revision: 140056
URL: http://llvm.org/viewvc/llvm-project?rev=140056&view=rev
Log:
Make ASTReader/ASTWriter friends of SourceLocation. They already
depend on internal knowledge of SourceLocation.
Modified:
cfe/trunk/include/clang/Basic/SourceLocation.h
cfe/trunk/include/clang/Serialization/ASTReader.h
Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=140056&r1=140055&r2=140056&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Mon Sep 19 15:40:08 2011
@@ -84,6 +84,8 @@
class SourceLocation {
unsigned ID;
friend class SourceManager;
+ friend class ASTReader;
+ friend class ASTWriter;
enum {
MacroIDBit = 1U << 31
};
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=140056&r1=140055&r2=140056&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Sep 19 15:40:08 2011
@@ -1143,15 +1143,11 @@
/// \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.
More information about the cfe-commits
mailing list