diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-27 07:28:06 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-27 07:28:06 +0000 |
| commit | cb34bd3abb773bd3e3957f10b52d36a6366081b2 (patch) | |
| tree | 42c545a505f31ee8100f4bccb640fdf6d84afdee /clang/lib/Serialization | |
| parent | 34da7514843016409da42513b668242600b0b45f (diff) | |
| download | bcm5719-llvm-cb34bd3abb773bd3e3957f10b52d36a6366081b2.tar.gz bcm5719-llvm-cb34bd3abb773bd3e3957f10b52d36a6366081b2.zip | |
Encapsulate a couple of on-disk structures a little more.
llvm-svn: 264534
Diffstat (limited to 'clang/lib/Serialization')
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 12 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 22 |
2 files changed, 17 insertions, 17 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 180b65bf16a..d344cf7c606 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4897,8 +4897,8 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) { return nullptr; // Read the record. - SourceRange Range(ReadSourceLocation(M, PPOffs.Begin), - ReadSourceLocation(M, PPOffs.End)); + SourceRange Range(TranslateSourceLocation(M, PPOffs.getBegin()), + TranslateSourceLocation(M, PPOffs.getEnd())); PreprocessingRecord &PPRec = *PP.getPreprocessingRecord(); StringRef Blob; RecordData Record; @@ -5089,7 +5089,7 @@ Optional<bool> ASTReader::isPreprocessedEntityInFileID(unsigned Index, unsigned LocalIndex = PPInfo.second; const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex]; - SourceLocation Loc = ReadSourceLocation(M, PPOffs.Begin); + SourceLocation Loc = TranslateSourceLocation(M, PPOffs.getBegin()); if (Loc.isInvalid()) return false; @@ -6426,9 +6426,9 @@ SourceLocation ASTReader::getSourceLocationForDeclID(GlobalDeclID ID) { if (Decl *D = DeclsLoaded[Index]) return D->getLocation(); - unsigned RawLocation = 0; - RecordLocation Rec = DeclCursorForID(ID, RawLocation); - return ReadSourceLocation(*Rec.F, RawLocation); + SourceLocation Loc; + DeclCursorForID(ID, Loc); + return Loc; } static Decl *getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID) { diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index dad3a1450e3..b2fdbb8aa2d 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -40,7 +40,7 @@ namespace clang { ModuleFile &F; uint64_t Offset; const DeclID ThisDeclID; - const unsigned RawLocation; + const SourceLocation ThisDeclLoc; typedef ASTReader::RecordData RecordData; const RecordData &Record; unsigned &Idx; @@ -207,10 +207,10 @@ namespace clang { public: ASTDeclReader(ASTReader &Reader, ASTReader::RecordLocation Loc, - DeclID thisDeclID, unsigned RawLocation, + DeclID thisDeclID, SourceLocation ThisDeclLoc, const RecordData &Record, unsigned &Idx) : Reader(Reader), F(*Loc.F), Offset(Loc.Offset), ThisDeclID(thisDeclID), - RawLocation(RawLocation), Record(Record), Idx(Idx), + ThisDeclLoc(ThisDeclLoc), Record(Record), Idx(Idx), TypeIDForTypeDecl(0), NamedDeclForTagDecl(0), TypedefNameForLinkage(nullptr), HasPendingBody(false) {} @@ -509,7 +509,7 @@ void ASTDeclReader::VisitDecl(Decl *D) { D->setDeclContextsImpl(MergedSemaDC ? MergedSemaDC : SemaDC, LexicalDC, Reader.getContext()); } - D->setLocation(Reader.ReadSourceLocation(F, RawLocation)); + D->setLocation(ThisDeclLoc); D->setInvalidDecl(Record[Idx++]); if (Record[Idx++]) { // hasAttrs AttrVec Attrs; @@ -2481,13 +2481,13 @@ static bool isConsumerInterestedIn(Decl *D, bool HasBody) { /// \brief Get the correct cursor and offset for loading a declaration. ASTReader::RecordLocation -ASTReader::DeclCursorForID(DeclID ID, unsigned &RawLocation) { +ASTReader::DeclCursorForID(DeclID ID, SourceLocation &Loc) { GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID); assert(I != GlobalDeclMap.end() && "Corrupted global declaration map"); ModuleFile *M = I->second; const DeclOffset &DOffs = M->DeclOffsets[ID - M->BaseDeclID - NUM_PREDEF_DECL_IDS]; - RawLocation = DOffs.Loc; + Loc = TranslateSourceLocation(*M, DOffs.getLocation()); return RecordLocation(M, DOffs.BitOffset); } @@ -3163,8 +3163,8 @@ void ASTReader::markIncompleteDeclChain(Decl *D) { /// \brief Read the declaration at the given offset from the AST file. Decl *ASTReader::ReadDeclRecord(DeclID ID) { unsigned Index = ID - NUM_PREDEF_DECL_IDS; - unsigned RawLocation = 0; - RecordLocation Loc = DeclCursorForID(ID, RawLocation); + SourceLocation DeclLoc; + RecordLocation Loc = DeclCursorForID(ID, DeclLoc); llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor; // Keep track of where we are in the stream, then jump back there // after reading this declaration. @@ -3179,7 +3179,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { RecordData Record; unsigned Code = DeclsCursor.ReadCode(); unsigned Idx = 0; - ASTDeclReader Reader(*this, Loc, ID, RawLocation, Record,Idx); + ASTDeclReader Reader(*this, Loc, ID, DeclLoc, Record,Idx); Decl *D = nullptr; switch ((DeclCode)DeclsCursor.readRecord(Code, Record)) { @@ -3472,8 +3472,8 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) { assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!"); unsigned Idx = 0; - ASTDeclReader Reader(*this, RecordLocation(F, Offset), ID, 0, Record, - Idx); + ASTDeclReader Reader(*this, RecordLocation(F, Offset), ID, + SourceLocation(), Record, Idx); Reader.UpdateDecl(D, *F, Record); // We might have made this declaration interesting. If so, remember that |

