diff options
Diffstat (limited to 'clang/lib/Serialization/ASTReaderStmt.cpp')
| -rw-r--r-- | clang/lib/Serialization/ASTReaderStmt.cpp | 377 |
1 files changed, 181 insertions, 196 deletions
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index f361f0d2606..ab2bba7283b 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -22,28 +22,14 @@ namespace clang { class ASTStmtReader : public StmtVisitor<ASTStmtReader> { ASTReader &Reader; - ASTReader::PerFileData &F; llvm::BitstreamCursor &DeclsCursor; const ASTReader::RecordData &Record; unsigned &Idx; - SourceLocation ReadSourceLocation(const ASTReader::RecordData &R, - unsigned &I) { - return Reader.ReadSourceLocation(F, R, I); - } - SourceRange ReadSourceRange(const ASTReader::RecordData &R, unsigned &I) { - return Reader.ReadSourceRange(F, R, I); - } - TypeSourceInfo *GetTypeSourceInfo(const ASTReader::RecordData &R, - unsigned &I) { - return Reader.GetTypeSourceInfo(F, R, I); - } - public: - ASTStmtReader(ASTReader &Reader, ASTReader::PerFileData &F, - llvm::BitstreamCursor &Cursor, + ASTStmtReader(ASTReader &Reader, llvm::BitstreamCursor &Cursor, const ASTReader::RecordData &Record, unsigned &Idx) - : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { } + : Reader(Reader), DeclsCursor(Cursor), Record(Record), Idx(Idx) { } /// \brief The number of record fields required for the Stmt class /// itself. @@ -178,11 +164,11 @@ void ASTStmtReader:: ReadExplicitTemplateArgumentList(ExplicitTemplateArgumentList &ArgList, unsigned NumTemplateArgs) { TemplateArgumentListInfo ArgInfo; - ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx)); - ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx)); + ArgInfo.setLAngleLoc(Reader.ReadSourceLocation(Record, Idx)); + ArgInfo.setRAngleLoc(Reader.ReadSourceLocation(Record, Idx)); for (unsigned i = 0; i != NumTemplateArgs; ++i) ArgInfo.addArgument( - Reader.ReadTemplateArgumentLoc(F, Record, Idx)); + Reader.ReadTemplateArgumentLoc(DeclsCursor, Record, Idx)); ArgList.initializeFrom(ArgInfo); } @@ -192,7 +178,7 @@ void ASTStmtReader::VisitStmt(Stmt *S) { void ASTStmtReader::VisitNullStmt(NullStmt *S) { VisitStmt(S); - S->setSemiLoc(ReadSourceLocation(Record, Idx)); + S->setSemiLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) { @@ -202,8 +188,8 @@ void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) { while (NumStmts--) Stmts.push_back(Reader.ReadSubStmt()); S->setStmts(*Reader.getContext(), Stmts.data(), Stmts.size()); - S->setLBracLoc(ReadSourceLocation(Record, Idx)); - S->setRBracLoc(ReadSourceLocation(Record, Idx)); + S->setLBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setRBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitSwitchCase(SwitchCase *S) { @@ -216,23 +202,23 @@ void ASTStmtReader::VisitCaseStmt(CaseStmt *S) { S->setLHS(Reader.ReadSubExpr()); S->setRHS(Reader.ReadSubExpr()); S->setSubStmt(Reader.ReadSubStmt()); - S->setCaseLoc(ReadSourceLocation(Record, Idx)); - S->setEllipsisLoc(ReadSourceLocation(Record, Idx)); - S->setColonLoc(ReadSourceLocation(Record, Idx)); + S->setCaseLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setEllipsisLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) { VisitSwitchCase(S); S->setSubStmt(Reader.ReadSubStmt()); - S->setDefaultLoc(ReadSourceLocation(Record, Idx)); - S->setColonLoc(ReadSourceLocation(Record, Idx)); + S->setDefaultLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitLabelStmt(LabelStmt *S) { VisitStmt(S); S->setID(Reader.GetIdentifierInfo(Record, Idx)); S->setSubStmt(Reader.ReadSubStmt()); - S->setIdentLoc(ReadSourceLocation(Record, Idx)); + S->setIdentLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); S->setUsed(Record[Idx++]); S->setUnusedAttribute(Record[Idx++]); Reader.RecordLabelStmt(S, Record[Idx++]); @@ -245,8 +231,8 @@ void ASTStmtReader::VisitIfStmt(IfStmt *S) { S->setCond(Reader.ReadSubExpr()); S->setThen(Reader.ReadSubStmt()); S->setElse(Reader.ReadSubStmt()); - S->setIfLoc(ReadSourceLocation(Record, Idx)); - S->setElseLoc(ReadSourceLocation(Record, Idx)); + S->setIfLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setElseLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) { @@ -255,7 +241,7 @@ void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) { cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); S->setCond(Reader.ReadSubExpr()); S->setBody(Reader.ReadSubStmt()); - S->setSwitchLoc(ReadSourceLocation(Record, Idx)); + S->setSwitchLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); if (Record[Idx++]) S->setAllEnumCasesCovered(); @@ -280,16 +266,16 @@ void ASTStmtReader::VisitWhileStmt(WhileStmt *S) { cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); S->setCond(Reader.ReadSubExpr()); S->setBody(Reader.ReadSubStmt()); - S->setWhileLoc(ReadSourceLocation(Record, Idx)); + S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitDoStmt(DoStmt *S) { VisitStmt(S); S->setCond(Reader.ReadSubExpr()); S->setBody(Reader.ReadSubStmt()); - S->setDoLoc(ReadSourceLocation(Record, Idx)); - S->setWhileLoc(ReadSourceLocation(Record, Idx)); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); + S->setDoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitForStmt(ForStmt *S) { @@ -300,46 +286,46 @@ void ASTStmtReader::VisitForStmt(ForStmt *S) { cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); S->setInc(Reader.ReadSubExpr()); S->setBody(Reader.ReadSubStmt()); - S->setForLoc(ReadSourceLocation(Record, Idx)); - S->setLParenLoc(ReadSourceLocation(Record, Idx)); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); + S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitGotoStmt(GotoStmt *S) { VisitStmt(S); Reader.SetLabelOf(S, Record[Idx++]); - S->setGotoLoc(ReadSourceLocation(Record, Idx)); - S->setLabelLoc(ReadSourceLocation(Record, Idx)); + S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) { VisitStmt(S); - S->setGotoLoc(ReadSourceLocation(Record, Idx)); - S->setStarLoc(ReadSourceLocation(Record, Idx)); + S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setStarLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); S->setTarget(Reader.ReadSubExpr()); } void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) { VisitStmt(S); - S->setContinueLoc(ReadSourceLocation(Record, Idx)); + S->setContinueLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitBreakStmt(BreakStmt *S) { VisitStmt(S); - S->setBreakLoc(ReadSourceLocation(Record, Idx)); + S->setBreakLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) { VisitStmt(S); S->setRetValue(Reader.ReadSubExpr()); - S->setReturnLoc(ReadSourceLocation(Record, Idx)); + S->setReturnLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); S->setNRVOCandidate(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); } void ASTStmtReader::VisitDeclStmt(DeclStmt *S) { VisitStmt(S); - S->setStartLoc(ReadSourceLocation(Record, Idx)); - S->setEndLoc(ReadSourceLocation(Record, Idx)); + S->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); if (Idx + 1 == Record.size()) { // Single declaration @@ -360,8 +346,8 @@ void ASTStmtReader::VisitAsmStmt(AsmStmt *S) { unsigned NumOutputs = Record[Idx++]; unsigned NumInputs = Record[Idx++]; unsigned NumClobbers = Record[Idx++]; - S->setAsmLoc(ReadSourceLocation(Record, Idx)); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); + S->setAsmLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); S->setVolatile(Record[Idx++]); S->setSimple(Record[Idx++]); S->setMSAsm(Record[Idx++]); @@ -399,7 +385,7 @@ void ASTStmtReader::VisitExpr(Expr *E) { void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) { VisitExpr(E); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]); } @@ -414,7 +400,7 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { if (HasQualifier) { E->getNameQualifier()->NNS = Reader.ReadNestedNameSpecifier(Record, Idx); - E->getNameQualifier()->Range = ReadSourceRange(Record, Idx); + E->getNameQualifier()->Range = Reader.ReadSourceRange(Record, Idx); } if (NumTemplateArgs) @@ -423,12 +409,12 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); // FIXME: read DeclarationNameLoc. - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(Reader.ReadSourceLocation(Record, Idx)); } void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) { VisitExpr(E); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setValue(*Reader.getContext(), Reader.ReadAPInt(Record, Idx)); } @@ -436,7 +422,7 @@ void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) { VisitExpr(E); E->setValue(*Reader.getContext(), Reader.ReadAPFloat(Record, Idx)); E->setExact(Record[Idx++]); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) { @@ -459,20 +445,20 @@ void ASTStmtReader::VisitStringLiteral(StringLiteral *E) { // Read source locations for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I) - E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx)); + E->setStrTokenLoc(I, SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) { VisitExpr(E); E->setValue(Record[Idx++]); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setWide(Record[Idx++]); } void ASTStmtReader::VisitParenExpr(ParenExpr *E) { VisitExpr(E); - E->setLParen(ReadSourceLocation(Record, Idx)); - E->setRParen(ReadSourceLocation(Record, Idx)); + E->setLParen(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParen(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setSubExpr(Reader.ReadSubExpr()); } @@ -483,15 +469,15 @@ void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) { for (unsigned i = 0; i != NumExprs; ++i) E->Exprs[i] = Reader.ReadSubStmt(); E->NumExprs = NumExprs; - E->LParenLoc = ReadSourceLocation(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); + E->LParenLoc = Reader.ReadSourceLocation(Record, Idx); + E->RParenLoc = Reader.ReadSourceLocation(Record, Idx); } void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) { VisitExpr(E); E->setSubExpr(Reader.ReadSubExpr()); E->setOpcode((UnaryOperator::Opcode)Record[Idx++]); - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { @@ -501,13 +487,13 @@ void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { ++Idx; assert(E->getNumExpressions() == Record[Idx]); ++Idx; - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); - E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); + E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setTypeSourceInfo(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]); - SourceLocation Start = ReadSourceLocation(Record, Idx); - SourceLocation End = ReadSourceLocation(Record, Idx); + SourceLocation Start = SourceLocation::getFromRawEncoding(Record[Idx++]); + SourceLocation End = SourceLocation::getFromRawEncoding(Record[Idx++]); switch (Kind) { case Node::Array: E->setComponent(I, Node(Start, Record[Idx++], End)); @@ -526,7 +512,7 @@ void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { case Node::Base: { CXXBaseSpecifier *Base = new (*Reader.getContext()) CXXBaseSpecifier(); - *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx); + *Base = Reader.ReadCXXBaseSpecifier(DeclsCursor, Record, Idx); E->setComponent(I, Node(Base)); break; } @@ -544,23 +530,23 @@ void ASTStmtReader::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { E->setArgument(Reader.ReadSubExpr()); ++Idx; } else { - E->setArgument(GetTypeSourceInfo(Record, Idx)); + E->setArgument(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); } - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { VisitExpr(E); E->setLHS(Reader.ReadSubExpr()); E->setRHS(Reader.ReadSubExpr()); - E->setRBracketLoc(ReadSourceLocation(Record, Idx)); + E->setRBracketLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitCallExpr(CallExpr *E) { VisitExpr(E); E->setNumArgs(*Reader.getContext(), Record[Idx++]); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setCallee(Reader.ReadSubExpr()); for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) E->setArg(I, Reader.ReadSubExpr()); @@ -575,7 +561,7 @@ void ASTStmtReader::VisitMemberExpr(MemberExpr *E) { void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) { VisitExpr(E); E->setBase(Reader.ReadSubExpr()); - E->setIsaMemberLoc(ReadSourceLocation(Record, Idx)); + E->setIsaMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setArrow(Record[Idx++]); } @@ -588,7 +574,7 @@ void ASTStmtReader::VisitCastExpr(CastExpr *E) { CastExpr::path_iterator BaseI = E->path_begin(); while (NumBaseSpecs--) { CXXBaseSpecifier *BaseSpec = new (*Reader.getContext()) CXXBaseSpecifier; - *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx); + *BaseSpec = Reader.ReadCXXBaseSpecifier(DeclsCursor, Record, Idx); *BaseI++ = BaseSpec; } } @@ -598,7 +584,7 @@ void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) { E->setLHS(Reader.ReadSubExpr()); E->setRHS(Reader.ReadSubExpr()); E->setOpcode((BinaryOperator::Opcode)Record[Idx++]); - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) { @@ -613,8 +599,8 @@ void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) { E->setLHS(Reader.ReadSubExpr()); E->setRHS(Reader.ReadSubExpr()); E->setSAVE(Reader.ReadSubExpr()); - E->setQuestionLoc(ReadSourceLocation(Record, Idx)); - E->setColonLoc(ReadSourceLocation(Record, Idx)); + E->setQuestionLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) { @@ -624,19 +610,19 @@ void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) { void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) { VisitCastExpr(E); - E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx)); + E->setTypeInfoAsWritten(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); } void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) { VisitExplicitCastExpr(E); - E->setLParenLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { VisitExpr(E); - E->setLParenLoc(ReadSourceLocation(Record, Idx)); - E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); + E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setTypeSourceInfo(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); E->setInitializer(Reader.ReadSubExpr()); E->setFileScope(Record[Idx++]); } @@ -645,7 +631,7 @@ void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { VisitExpr(E); E->setBase(Reader.ReadSubExpr()); E->setAccessor(Reader.GetIdentifierInfo(Record, Idx)); - E->setAccessorLoc(ReadSourceLocation(Record, Idx)); + E->setAccessorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitInitListExpr(InitListExpr *E) { @@ -655,8 +641,8 @@ void ASTStmtReader::VisitInitListExpr(InitListExpr *E) { for (unsigned I = 0; I != NumInits; ++I) E->updateInit(*Reader.getContext(), I, Reader.ReadSubExpr()); E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt())); - E->setLBraceLoc(ReadSourceLocation(Record, Idx)); - E->setRBraceLoc(ReadSourceLocation(Record, Idx)); + E->setLBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setInitializedFieldInUnion( cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++]))); E->sawArrayRangeDesignator(Record[Idx++]); @@ -670,7 +656,7 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs"); for (unsigned I = 0; I != NumSubExprs; ++I) E->setSubExpr(I, Reader.ReadSubExpr()); - E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx)); + E->setEqualOrColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setGNUSyntax(Record[Idx++]); llvm::SmallVector<Designator, 4> Designators; @@ -679,9 +665,9 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { case DESIG_FIELD_DECL: { FieldDecl *Field = cast<FieldDecl>(Reader.GetDecl(Record[Idx++])); SourceLocation DotLoc - = ReadSourceLocation(Record, Idx); + = SourceLocation::getFromRawEncoding(Record[Idx++]); SourceLocation FieldLoc - = ReadSourceLocation(Record, Idx); + = SourceLocation::getFromRawEncoding(Record[Idx++]); Designators.push_back(Designator(Field->getIdentifier(), DotLoc, FieldLoc)); Designators.back().setField(Field); @@ -691,9 +677,9 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { case DESIG_FIELD_NAME: { const IdentifierInfo *Name = Reader.GetIdentifierInfo(Record, Idx); SourceLocation DotLoc - = ReadSourceLocation(Record, Idx); + = SourceLocation::getFromRawEncoding(Record[Idx++]); SourceLocation FieldLoc - = ReadSourceLocation(Record, Idx); + = SourceLocation::getFromRawEncoding(Record[Idx++]); Designators.push_back(Designator(Name, DotLoc, FieldLoc)); break; } @@ -701,9 +687,9 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { case DESIG_ARRAY: { unsigned Index = Record[Idx++]; SourceLocation LBracketLoc - = ReadSourceLocation(Record, Idx); + = SourceLocation::getFromRawEncoding(Record[Idx++]); SourceLocation RBracketLoc - = ReadSourceLocation(Record, Idx); + = SourceLocation::getFromRawEncoding(Record[Idx++]); Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); break; } @@ -711,11 +697,11 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { case DESIG_ARRAY_RANGE: { unsigned Index = Record[Idx++]; SourceLocation LBracketLoc - = ReadSourceLocation(Record, Idx); + = SourceLocation::getFromRawEncoding(Record[Idx++]); SourceLocation EllipsisLoc - = ReadSourceLocation(Record, Idx); + = SourceLocation::getFromRawEncoding(Record[Idx++]); SourceLocation RBracketLoc - = ReadSourceLocation(Record, Idx); + = SourceLocation::getFromRawEncoding(Record[Idx++]); Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, RBracketLoc)); break; @@ -733,31 +719,31 @@ void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) { VisitExpr(E); E->setSubExpr(Reader.ReadSubExpr()); - E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx)); - E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setWrittenTypeInfo(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); + E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) { VisitExpr(E); - E->setAmpAmpLoc(ReadSourceLocation(Record, Idx)); - E->setLabelLoc(ReadSourceLocation(Record, Idx)); + E->setAmpAmpLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); Reader.SetLabelOf(E, Record[Idx++]); } void ASTStmtReader::VisitStmtExpr(StmtExpr *E) { VisitExpr(E); - E->setLParenLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt())); } void ASTStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) { VisitExpr(E); - E->setArgTInfo1(GetTypeSourceInfo(Record, Idx)); - E->setArgTInfo2(GetTypeSourceInfo(Record, Idx)); - E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setArgTInfo1(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); + E->setArgTInfo2(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); + E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) { @@ -765,13 +751,13 @@ void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) { E->setCond(Reader.ReadSubExpr()); E->setLHS(Reader.ReadSubExpr()); E->setRHS(Reader.ReadSubExpr()); - E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) { VisitExpr(E); - E->setTokenLocation(ReadSourceLocation(Record, Idx)); + E->setTokenLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { @@ -781,8 +767,8 @@ void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { while (NumExprs--) Exprs.push_back(Reader.ReadSubExpr()); E->setExprs(*Reader.getContext(), Exprs.data(), Exprs.size()); - E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitBlockExpr(BlockExpr *E) { @@ -794,7 +780,7 @@ void ASTStmtReader::VisitBlockExpr(BlockExpr *E) { void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { VisitExpr(E); E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setByRef(Record[Idx++]); E->setConstQualAdded(Record[Idx++]); E->setCopyConstructorExpr(Reader.ReadSubExpr()); @@ -806,34 +792,34 @@ void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) { VisitExpr(E); E->setString(cast<StringLiteral>(Reader.ReadSubStmt())); - E->setAtLoc(ReadSourceLocation(Record, Idx)); + E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { VisitExpr(E); - E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); - E->setAtLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setEncodedTypeSourceInfo(Reader.GetTypeSourceInfo(DeclsCursor,Record,Idx)); + E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { VisitExpr(E); E->setSelector(Reader.GetSelector(Record, Idx)); - E->setAtLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { VisitExpr(E); E->setProtocol(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); - E->setAtLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { VisitExpr(E); E->setDecl(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setBase(Reader.ReadSubExpr()); E->setIsArrow(Record[Idx++]); E->setIsFreeIvar(Record[Idx++]); @@ -842,7 +828,7 @@ void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { VisitExpr(E); E->setProperty(cast<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++]))); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setBase(Reader.ReadSubExpr()); } @@ -856,8 +842,8 @@ void ASTStmtReader::VisitObjCImplicitSetterGetterRefExpr( E->setInterfaceDecl( cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); E->setBase(Reader.ReadSubExpr()); - E->setLocation(ReadSourceLocation(Record, Idx)); - E->setClassLoc(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { @@ -872,13 +858,13 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { break; case ObjCMessageExpr::Class: - E->setClassReceiver(GetTypeSourceInfo(Record, Idx)); + E->setClassReceiver(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); break; case ObjCMessageExpr::SuperClass: case ObjCMessageExpr::SuperInstance: { QualType T = Reader.GetType(Record[Idx++]); - SourceLocation SuperLoc = ReadSourceLocation(Record, Idx); + SourceLocation SuperLoc = SourceLocation::getFromRawEncoding(Record[Idx++]); E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance); break; } @@ -891,8 +877,8 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { else E->setSelector(Reader.GetSelector(Record, Idx)); - E->setLeftLoc(ReadSourceLocation(Record, Idx)); - E->setRightLoc(ReadSourceLocation(Record, Idx)); + E->setLeftLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRightLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) E->setArg(I, Reader.ReadSubExpr()); @@ -900,7 +886,7 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { void ASTStmtReader::VisitObjCSuperExpr(ObjCSuperExpr *E) { VisitExpr(E); - E->setLoc(ReadSourceLocation(Record, Idx)); + E->setLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { @@ -908,22 +894,22 @@ void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { S->setElement(Reader.ReadSubStmt()); S->setCollection(Reader.ReadSubExpr()); S->setBody(Reader.ReadSubStmt()); - S->setForLoc(ReadSourceLocation(Record, Idx)); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); + S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { VisitStmt(S); S->setCatchBody(Reader.ReadSubStmt()); S->setCatchParamDecl(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); - S->setAtCatchLoc(ReadSourceLocation(Record, Idx)); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); + S->setAtCatchLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { VisitStmt(S); S->setFinallyBody(Reader.ReadSubStmt()); - S->setAtFinallyLoc(ReadSourceLocation(Record, Idx)); + S->setAtFinallyLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { @@ -937,20 +923,20 @@ void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { if (HasFinally) S->setFinallyStmt(Reader.ReadSubStmt()); - S->setAtTryLoc(ReadSourceLocation(Record, Idx)); + S->setAtTryLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { VisitStmt(S); S->setSynchExpr(Reader.ReadSubStmt()); S->setSynchBody(Reader.ReadSubStmt()); - S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx)); + S->setAtSynchronizedLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { VisitStmt(S); S->setThrowExpr(Reader.ReadSubStmt()); - S->setThrowLoc(ReadSourceLocation(Record, Idx)); + S->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } //===----------------------------------------------------------------------===// @@ -959,7 +945,7 @@ void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) { VisitStmt(S); - S->CatchLoc = ReadSourceLocation(Record, Idx); + S->CatchLoc = Reader.ReadSourceLocation(Record, Idx); S->ExceptionDecl = cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])); S->HandlerBlock = Reader.ReadSubStmt(); } @@ -968,7 +954,7 @@ void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) { VisitStmt(S); assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?"); ++Idx; - S->TryLoc = ReadSourceLocation(Record, Idx); + S->TryLoc = Reader.ReadSourceLocation(Record, Idx); S->getStmts()[0] = Reader.ReadSubStmt(); for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i) S->getStmts()[i + 1] = Reader.ReadSubStmt(); @@ -987,7 +973,7 @@ void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) E->setArg(I, Reader.ReadSubExpr()); E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++]))); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setElidable(Record[Idx++]); E->setRequiresZeroInitialization(Record[Idx++]); E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]); @@ -995,13 +981,13 @@ void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) { VisitCXXConstructExpr(E); - E->Type = GetTypeSourceInfo(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); + E->Type = Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx); + E->RParenLoc = Reader.ReadSourceLocation(Record, Idx); } void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { VisitExplicitCastExpr(E); - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { @@ -1022,27 +1008,27 @@ void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) { void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { VisitExplicitCastExpr(E); - E->setTypeBeginLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setTypeBeginLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { VisitExpr(E); E->setValue(Record[Idx++]); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { VisitExpr(E); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); } void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) { VisitExpr(E); - E->setSourceRange(ReadSourceRange(Record, Idx)); + E->setSourceRange(Reader.ReadSourceRange(Record, Idx)); if (E->isTypeOperand()) { // typeid(int) E->setTypeOperandSourceInfo( - GetTypeSourceInfo(Record, Idx)); + Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); return; } @@ -1051,10 +1037,10 @@ void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) { } void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) { VisitExpr(E); - E->setSourceRange(ReadSourceRange(Record, Idx)); + E->setSourceRange(Reader.ReadSourceRange(Record, Idx)); if (E->isTypeOperand()) { // __uuidof(ComType) E->setTypeOperandSourceInfo( - GetTypeSourceInfo(Record, Idx)); + Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); return; } @@ -1064,13 +1050,13 @@ void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) { void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) { VisitExpr(E); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setImplicit(Record[Idx++]); } void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { VisitExpr(E); - E->setThrowLoc(ReadSourceLocation(Record, Idx)); + E->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); E->setSubExpr(Reader.ReadSubExpr()); } @@ -1080,7 +1066,7 @@ void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { assert(Record[Idx] == E->Param.getInt() && "We messed up at creation ?"); ++Idx; // HasOtherExprStored and SubExpr was handled during creation. E->Param.setPointer(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); - E->Loc = ReadSourceLocation(Record, Idx); + E->Loc = Reader.ReadSourceLocation(Record, Idx); } void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { @@ -1091,8 +1077,8 @@ void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) { VisitExpr(E); - E->TypeInfo = GetTypeSourceInfo(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); + E->TypeInfo = Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx); + E->RParenLoc = SourceLocation::getFromRawEncoding(Record[Idx++]); } void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { @@ -1107,13 +1093,13 @@ void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); E->setConstructor( cast_or_null<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++]))); - E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx); + E->AllocatedTypeInfo = Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx); SourceRange TypeIdParens; - TypeIdParens.setBegin(ReadSourceLocation(Record, Idx)); - TypeIdParens.setEnd(ReadSourceLocation(Record, Idx)); + TypeIdParens.setBegin(SourceLocation::getFromRawEncoding(Record[Idx++])); + TypeIdParens.setEnd(SourceLocation::getFromRawEncoding(Record[Idx++])); E->TypeIdParens = TypeIdParens; - E->setStartLoc(ReadSourceLocation(Record, Idx)); - E->setEndLoc(ReadSourceLocation(Record, Idx)); + E->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + E->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); E->AllocateArgsArray(*Reader.getContext(), isArray, NumPlacementArgs, NumCtorArgs); @@ -1131,7 +1117,7 @@ void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) { E->ArrayFormAsWritten = Record[Idx++]; E->OperatorDelete = cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])); E->Argument = Reader.ReadSubExpr(); - E->Loc = ReadSourceLocation(Record, Idx); + E->Loc = Reader.ReadSourceLocation(Record, Idx); } void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { @@ -1139,18 +1125,18 @@ void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { E->setBase(Reader.ReadSubExpr()); E->setArrow(Record[Idx++]); - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx)); E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); - E->setQualifierRange(ReadSourceRange(Record, Idx)); - E->setScopeTypeInfo(GetTypeSourceInfo(Record, Idx)); - E->setColonColonLoc(ReadSourceLocation(Record, Idx)); - E->setTildeLoc(ReadSourceLocation(Record, Idx)); + E->setQualifierRange(Reader.ReadSourceRange(Record, Idx)); + E->setScopeTypeInfo(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); + E->setColonColonLoc(Reader.ReadSourceLocation(Record, Idx)); + E->setTildeLoc(Reader.ReadSourceLocation(Record, Idx)); IdentifierInfo *II = Reader.GetIdentifierInfo(Record, Idx); if (II) - E->setDestroyedType(II, ReadSourceLocation(Record, Idx)); + E->setDestroyedType(II, Reader.ReadSourceLocation(Record, Idx)); else - E->setDestroyedType(GetTypeSourceInfo(Record, Idx)); + E->setDestroyedType(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx)); } void ASTStmtReader::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) { @@ -1178,14 +1164,14 @@ ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){ E->setBase(Reader.ReadSubExpr()); E->setBaseType(Reader.GetType(Record[Idx++])); E->setArrow(Record[Idx++]); - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx)); E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); - E->setQualifierRange(ReadSourceRange(Record, Idx)); + E->setQualifierRange(Reader.ReadSourceRange(Record, Idx)); E->setFirstQualifierFoundInScope( cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++]))); // FIXME: read whole DeclarationNameInfo. E->setMember(Reader.ReadDeclarationName(Record, Idx)); - E->setMemberLoc(ReadSourceLocation(Record, Idx)); + E->setMemberLoc(Reader.ReadSourceLocation(Record, Idx)); } void @@ -1201,8 +1187,8 @@ ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { // FIXME: read whole DeclarationNameInfo. E->setDeclName(Reader.ReadDeclarationName(Record, Idx)); - E->setLocation(ReadSourceLocation(Record, Idx)); - E->setQualifierRange(ReadSourceRange(Record, Idx)); + E->setLocation(Reader.ReadSourceLocation(Record, Idx)); + E->setQualifierRange(Reader.ReadSourceRange(Record, Idx)); E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); } @@ -1213,9 +1199,9 @@ ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) { ++Idx; // NumArgs; for (unsigned I = 0, N = E->arg_size(); I != N; ++I) E->setArg(I, Reader.ReadSubExpr()); - E->Type = GetTypeSourceInfo(Record, Idx); - E->setLParenLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->Type = Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx); + E->setLParenLoc(Reader.ReadSourceLocation(Record, Idx)); + E->setRParenLoc(Reader.ReadSourceLocation(Record, Idx)); } void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) { @@ -1240,8 +1226,8 @@ void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) { // FIXME: read whole DeclarationNameInfo. E->setName(Reader.ReadDeclarationName(Record, Idx)); E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); - E->setQualifierRange(ReadSourceRange(Record, Idx)); - E->setNameLoc(ReadSourceLocation(Record, Idx)); + E->setQualifierRange(Reader.ReadSourceRange(Record, Idx)); + E->setNameLoc(Reader.ReadSourceLocation(Record, Idx)); } void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { @@ -1250,7 +1236,7 @@ void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { E->setHasUnresolvedUsing(Record[Idx++]); E->setBase(Reader.ReadSubExpr()); E->setBaseType(Reader.GetType(Record[Idx++])); - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx)); } void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { @@ -1264,24 +1250,24 @@ void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) { VisitExpr(E); E->UTT = (UnaryTypeTrait)Record[Idx++]; E->Value = (bool)Record[Idx++]; - SourceRange Range = ReadSourceRange(Record, Idx); + SourceRange Range = Reader.ReadSourceRange(Record, Idx); E->Loc = Range.getBegin(); E->RParen = Range.getEnd(); - E->QueriedType = GetTypeSourceInfo(Record, Idx); + E->QueriedType = Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx); } void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { VisitExpr(E); E->Value = (bool)Record[Idx++]; - E->Range = ReadSourceRange(Record, Idx); + E->Range = Reader.ReadSourceRange(Record, Idx); E->Operand = Reader.ReadSubExpr(); } -Stmt *ASTReader::ReadStmt(PerFileData &F) { +Stmt *ASTReader::ReadStmt(llvm::BitstreamCursor &Cursor) { switch (ReadingKind) { case Read_Decl: case Read_Type: - return ReadStmtFromStream(F); + return ReadStmtFromStream(Cursor); case Read_Stmt: return ReadSubStmt(); } @@ -1290,8 +1276,8 @@ Stmt *ASTReader::ReadStmt(PerFileData &F) { return 0; } -Expr *ASTReader::ReadExpr(PerFileData &F) { - return cast_or_null<Expr>(ReadStmt(F)); +Expr *ASTReader::ReadExpr(llvm::BitstreamCursor &Cursor) { + return cast_or_null<Expr>(ReadStmt(Cursor)); } Expr *ASTReader::ReadSubExpr() { @@ -1305,18 +1291,17 @@ Expr *ASTReader::ReadSubExpr() { // the stack, with expressions having operands removing those operands from the // stack. Evaluation terminates when we see a STMT_STOP record, and // the single remaining expression on the stack is our result. -Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { +Stmt *ASTReader::ReadStmtFromStream(llvm::BitstreamCursor &Cursor) { ReadingKindTracker ReadingKind(Read_Stmt, *this); - llvm::BitstreamCursor &Cursor = F.DeclsCursor; - + #ifndef NDEBUG unsigned PrevNumStmts = StmtStack.size(); #endif RecordData Record; unsigned Idx; - ASTStmtReader Reader(*this, F, Cursor, Record, Idx); + ASTStmtReader Reader(*this, Cursor, Record, Idx); Stmt::EmptyShell Empty; while (true) { @@ -1496,16 +1481,16 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { SourceRange QualifierRange; if (Record[Idx++]) { // HasQualifier. NNS = ReadNestedNameSpecifier(Record, Idx); - QualifierRange = ReadSourceRange(F, Record, Idx); + QualifierRange = ReadSourceRange(Record, Idx); } TemplateArgumentListInfo ArgInfo; unsigned NumTemplateArgs = Record[Idx++]; if (NumTemplateArgs) { - ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx)); - ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx)); + ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx)); + ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx)); for (unsigned i = 0; i != NumTemplateArgs; ++i) - ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx)); + ArgInfo.addArgument(ReadTemplateArgumentLoc(Cursor, Record, Idx)); } NamedDecl *FoundD = cast_or_null<NamedDecl>(GetDecl(Record[Idx++])); @@ -1516,7 +1501,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { Expr *Base = ReadSubExpr(); ValueDecl *MemberD = cast<ValueDecl>(GetDecl(Record[Idx++])); // FIXME: read DeclarationNameLoc. - SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx); + SourceLocation MemberLoc = ReadSourceLocation(Record, Idx); DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc); bool IsArrow = Record[Idx++]; |

