diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2011-10-20 21:14:49 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2011-10-20 21:14:49 +0000 |
commit | 36981b17ed939300f6f8fc2355a255f711fcef71 (patch) | |
tree | ee2483e98b09cac943dc93a6969d83ca737ff139 /lib/Serialization/ASTReaderStmt.cpp | |
parent | 180abc3db9ae3b4fc63cd65b15697e6ffcc8a657 (diff) | |
download | src-36981b17ed939300f6f8fc2355a255f711fcef71.tar.gz src-36981b17ed939300f6f8fc2355a255f711fcef71.zip |
Notes
Diffstat (limited to 'lib/Serialization/ASTReaderStmt.cpp')
-rw-r--r-- | lib/Serialization/ASTReaderStmt.cpp | 352 |
1 files changed, 198 insertions, 154 deletions
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index 14927b9e3bc8..ab07b85bf4c3 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -22,34 +22,51 @@ using namespace clang::serialization; namespace clang { class ASTStmtReader : public StmtVisitor<ASTStmtReader> { + typedef ASTReader::RecordData RecordData; + ASTReader &Reader; - ASTReader::PerFileData &F; + Module &F; llvm::BitstreamCursor &DeclsCursor; const ASTReader::RecordData &Record; unsigned &Idx; - SourceLocation ReadSourceLocation(const ASTReader::RecordData &R, - unsigned &I) { + SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) { return Reader.ReadSourceLocation(F, R, I); } - SourceRange ReadSourceRange(const ASTReader::RecordData &R, unsigned &I) { + + SourceRange ReadSourceRange(const RecordData &R, unsigned &I) { return Reader.ReadSourceRange(F, R, I); } - TypeSourceInfo *GetTypeSourceInfo(const ASTReader::RecordData &R, - unsigned &I) { + + TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) { return Reader.GetTypeSourceInfo(F, R, I); } + + serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) { + return Reader.ReadDeclID(F, R, I); + } + + Decl *ReadDecl(const RecordData &R, unsigned &I) { + return Reader.ReadDecl(F, R, I); + } + + template<typename T> + T *ReadDeclAs(const RecordData &R, unsigned &I) { + return Reader.ReadDeclAs<T>(F, R, I); + } + void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name, const ASTReader::RecordData &R, unsigned &I) { Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I); } + void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, const ASTReader::RecordData &R, unsigned &I) { Reader.ReadDeclarationNameInfo(F, NameInfo, R, I); } public: - ASTStmtReader(ASTReader &Reader, ASTReader::PerFileData &F, + ASTStmtReader(ASTReader &Reader, Module &F, llvm::BitstreamCursor &Cursor, const ASTReader::RecordData &Record, unsigned &Idx) : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { } @@ -63,7 +80,7 @@ namespace clang { static const unsigned NumExprFields = NumStmtFields + 7; /// \brief Read and initialize a ExplicitTemplateArgumentList structure. - void ReadExplicitTemplateArgumentList(ExplicitTemplateArgumentList &ArgList, + void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList, unsigned NumTemplateArgs); void VisitStmt(Stmt *S); @@ -74,7 +91,7 @@ namespace clang { } void ASTStmtReader:: -ReadExplicitTemplateArgumentList(ExplicitTemplateArgumentList &ArgList, +ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList, unsigned NumTemplateArgs) { TemplateArgumentListInfo ArgInfo; ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx)); @@ -92,16 +109,16 @@ void ASTStmtReader::VisitStmt(Stmt *S) { void ASTStmtReader::VisitNullStmt(NullStmt *S) { VisitStmt(S); S->setSemiLoc(ReadSourceLocation(Record, Idx)); - S->LeadingEmptyMacro = ReadSourceLocation(Record, Idx); + S->HasLeadingEmptyMacro = Record[Idx++]; } void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) { VisitStmt(S); - llvm::SmallVector<Stmt *, 16> Stmts; + SmallVector<Stmt *, 16> Stmts; unsigned NumStmts = Record[Idx++]; while (NumStmts--) Stmts.push_back(Reader.ReadSubStmt()); - S->setStmts(*Reader.getContext(), Stmts.data(), Stmts.size()); + S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size()); S->setLBracLoc(ReadSourceLocation(Record, Idx)); S->setRBracLoc(ReadSourceLocation(Record, Idx)); } @@ -130,7 +147,7 @@ void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) { void ASTStmtReader::VisitLabelStmt(LabelStmt *S) { VisitStmt(S); - LabelDecl *LD = cast<LabelDecl>(Reader.GetDecl(Record[Idx++])); + LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx); LD->setStmt(S); S->setDecl(LD); S->setSubStmt(Reader.ReadSubStmt()); @@ -139,8 +156,8 @@ void ASTStmtReader::VisitLabelStmt(LabelStmt *S) { void ASTStmtReader::VisitIfStmt(IfStmt *S) { VisitStmt(S); - S->setConditionVariable(*Reader.getContext(), - cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); + S->setConditionVariable(Reader.getContext(), + ReadDeclAs<VarDecl>(Record, Idx)); S->setCond(Reader.ReadSubExpr()); S->setThen(Reader.ReadSubStmt()); S->setElse(Reader.ReadSubStmt()); @@ -150,8 +167,8 @@ void ASTStmtReader::VisitIfStmt(IfStmt *S) { void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) { VisitStmt(S); - S->setConditionVariable(*Reader.getContext(), - cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); + S->setConditionVariable(Reader.getContext(), + ReadDeclAs<VarDecl>(Record, Idx)); S->setCond(Reader.ReadSubExpr()); S->setBody(Reader.ReadSubStmt()); S->setSwitchLoc(ReadSourceLocation(Record, Idx)); @@ -172,8 +189,9 @@ void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) { void ASTStmtReader::VisitWhileStmt(WhileStmt *S) { VisitStmt(S); - S->setConditionVariable(*Reader.getContext(), - cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); + S->setConditionVariable(Reader.getContext(), + ReadDeclAs<VarDecl>(Record, Idx)); + S->setCond(Reader.ReadSubExpr()); S->setBody(Reader.ReadSubStmt()); S->setWhileLoc(ReadSourceLocation(Record, Idx)); @@ -192,8 +210,8 @@ void ASTStmtReader::VisitForStmt(ForStmt *S) { VisitStmt(S); S->setInit(Reader.ReadSubStmt()); S->setCond(Reader.ReadSubExpr()); - S->setConditionVariable(*Reader.getContext(), - cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); + S->setConditionVariable(Reader.getContext(), + ReadDeclAs<VarDecl>(Record, Idx)); S->setInc(Reader.ReadSubExpr()); S->setBody(Reader.ReadSubStmt()); S->setForLoc(ReadSourceLocation(Record, Idx)); @@ -203,7 +221,7 @@ void ASTStmtReader::VisitForStmt(ForStmt *S) { void ASTStmtReader::VisitGotoStmt(GotoStmt *S) { VisitStmt(S); - S->setLabel(cast<LabelDecl>(Reader.GetDecl(Record[Idx++]))); + S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx)); S->setGotoLoc(ReadSourceLocation(Record, Idx)); S->setLabelLoc(ReadSourceLocation(Record, Idx)); } @@ -229,7 +247,7 @@ void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) { VisitStmt(S); S->setRetValue(Reader.ReadSubExpr()); S->setReturnLoc(ReadSourceLocation(Record, Idx)); - S->setNRVOCandidate(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); + S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx)); } void ASTStmtReader::VisitDeclStmt(DeclStmt *S) { @@ -239,13 +257,13 @@ void ASTStmtReader::VisitDeclStmt(DeclStmt *S) { if (Idx + 1 == Record.size()) { // Single declaration - S->setDeclGroup(DeclGroupRef(Reader.GetDecl(Record[Idx++]))); + S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx))); } else { - llvm::SmallVector<Decl *, 16> Decls; - Decls.reserve(Record.size() - Idx); - for (unsigned N = Record.size(); Idx != N; ++Idx) - Decls.push_back(Reader.GetDecl(Record[Idx])); - S->setDeclGroup(DeclGroupRef(DeclGroup::Create(*Reader.getContext(), + SmallVector<Decl *, 16> Decls; + Decls.reserve(Record.size() - Idx); + for (unsigned N = Record.size(); Idx != N; ) + Decls.push_back(ReadDecl(Record, Idx)); + S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(), Decls.data(), Decls.size()))); } @@ -265,21 +283,21 @@ void ASTStmtReader::VisitAsmStmt(AsmStmt *S) { S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt())); // Outputs and inputs - llvm::SmallVector<IdentifierInfo *, 16> Names; - llvm::SmallVector<StringLiteral*, 16> Constraints; - llvm::SmallVector<Stmt*, 16> Exprs; + SmallVector<IdentifierInfo *, 16> Names; + SmallVector<StringLiteral*, 16> Constraints; + SmallVector<Stmt*, 16> Exprs; for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) { - Names.push_back(Reader.GetIdentifierInfo(Record, Idx)); + Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx)); Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt())); Exprs.push_back(Reader.ReadSubStmt()); } // Constraints - llvm::SmallVector<StringLiteral*, 16> Clobbers; + SmallVector<StringLiteral*, 16> Clobbers; for (unsigned I = 0; I != NumClobbers; ++I) Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt())); - S->setOutputsAndInputsAndClobbers(*Reader.getContext(), + S->setOutputsAndInputsAndClobbers(Reader.getContext(), Names.data(), Constraints.data(), Exprs.data(), NumOutputs, NumInputs, Clobbers.data(), NumClobbers); @@ -287,7 +305,7 @@ void ASTStmtReader::VisitAsmStmt(AsmStmt *S) { void ASTStmtReader::VisitExpr(Expr *E) { VisitStmt(E); - E->setType(Reader.GetType(Record[Idx++])); + E->setType(Reader.readType(F, Record, Idx)); E->setTypeDependent(Record[Idx++]); E->setValueDependent(Record[Idx++]); E->setInstantiationDependent(Record[Idx++]); @@ -309,6 +327,7 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { E->DeclRefExprBits.HasQualifier = Record[Idx++]; E->DeclRefExprBits.HasFoundDecl = Record[Idx++]; E->DeclRefExprBits.HasExplicitTemplateArgs = Record[Idx++]; + E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++]; unsigned NumTemplateArgs = 0; if (E->hasExplicitTemplateArgs()) NumTemplateArgs = Record[Idx++]; @@ -318,13 +337,13 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); if (E->hasFoundDecl()) - E->getInternalFoundDecl() = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); + E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx); if (E->hasExplicitTemplateArgs()) ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(), NumTemplateArgs); - E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++]))); + E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx)); E->setLocation(ReadSourceLocation(Record, Idx)); ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx); } @@ -332,12 +351,12 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) { VisitExpr(E); E->setLocation(ReadSourceLocation(Record, Idx)); - E->setValue(*Reader.getContext(), Reader.ReadAPInt(Record, Idx)); + E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx)); } void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) { VisitExpr(E); - E->setValue(*Reader.getContext(), Reader.ReadAPFloat(Record, Idx)); + E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx)); E->setExact(Record[Idx++]); E->setLocation(ReadSourceLocation(Record, Idx)); } @@ -353,12 +372,12 @@ void ASTStmtReader::VisitStringLiteral(StringLiteral *E) { assert(Record[Idx] == E->getNumConcatenated() && "Wrong number of concatenated tokens!"); ++Idx; - E->IsWide = Record[Idx++]; + E->Kind = static_cast<StringLiteral::StringKind>(Record[Idx++]); E->IsPascal = Record[Idx++]; // Read string data llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len); - E->setString(*Reader.getContext(), Str.str()); + E->setString(Reader.getContext(), Str.str()); Idx += Len; // Read source locations @@ -370,7 +389,7 @@ void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) { VisitExpr(E); E->setValue(Record[Idx++]); E->setLocation(ReadSourceLocation(Record, Idx)); - E->setWide(Record[Idx++]); + E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++])); } void ASTStmtReader::VisitParenExpr(ParenExpr *E) { @@ -383,7 +402,7 @@ void ASTStmtReader::VisitParenExpr(ParenExpr *E) { void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) { VisitExpr(E); unsigned NumExprs = Record[Idx++]; - E->Exprs = new (*Reader.getContext()) Stmt*[NumExprs]; + E->Exprs = new (Reader.getContext()) Stmt*[NumExprs]; for (unsigned i = 0; i != NumExprs; ++i) E->Exprs[i] = Reader.ReadSubStmt(); E->NumExprs = NumExprs; @@ -418,18 +437,18 @@ void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { break; case Node::Field: - E->setComponent(I, - Node(Start, - dyn_cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])), - End)); + E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End)); break; case Node::Identifier: - E->setComponent(I, Node(Start, Reader.GetIdentifier(Record[Idx++]), End)); + E->setComponent(I, + Node(Start, + Reader.GetIdentifierInfo(F, Record, Idx), + End)); break; case Node::Base: { - CXXBaseSpecifier *Base = new (*Reader.getContext()) CXXBaseSpecifier(); + CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier(); *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx); E->setComponent(I, Node(Base)); break; @@ -463,7 +482,7 @@ void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { void ASTStmtReader::VisitCallExpr(CallExpr *E) { VisitExpr(E); - E->setNumArgs(*Reader.getContext(), Record[Idx++]); + E->setNumArgs(Reader.getContext(), Record[Idx++]); E->setRParenLoc(ReadSourceLocation(Record, Idx)); E->setCallee(Reader.ReadSubExpr()); for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) @@ -509,7 +528,7 @@ void ASTStmtReader::VisitCastExpr(CastExpr *E) { E->setCastKind((CastExpr::CastKind)Record[Idx++]); CastExpr::path_iterator BaseI = E->path_begin(); while (NumBaseSpecs--) { - CXXBaseSpecifier *BaseSpec = new (*Reader.getContext()) CXXBaseSpecifier; + CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier; *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx); *BaseI++ = BaseSpec; } @@ -525,8 +544,8 @@ void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) { void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) { VisitBinaryOperator(E); - E->setComputationLHSType(Reader.GetType(Record[Idx++])); - E->setComputationResultType(Reader.GetType(Record[Idx++])); + E->setComputationLHSType(Reader.readType(F, Record, Idx)); + E->setComputationResultType(Reader.readType(F, Record, Idx)); } void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) { @@ -578,7 +597,7 @@ void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { VisitExpr(E); E->setBase(Reader.ReadSubExpr()); - E->setAccessor(Reader.GetIdentifierInfo(Record, Idx)); + E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx)); E->setAccessorLoc(ReadSourceLocation(Record, Idx)); } @@ -593,19 +612,18 @@ void ASTStmtReader::VisitInitListExpr(InitListExpr *E) { filler = Reader.ReadSubExpr(); E->ArrayFillerOrUnionFieldInit = filler; } else - E->ArrayFillerOrUnionFieldInit - = cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])); + E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx); E->sawArrayRangeDesignator(Record[Idx++]); unsigned NumInits = Record[Idx++]; - E->reserveInits(*Reader.getContext(), NumInits); + E->reserveInits(Reader.getContext(), NumInits); if (isArrayFiller) { for (unsigned I = 0; I != NumInits; ++I) { Expr *init = Reader.ReadSubExpr(); - E->updateInit(*Reader.getContext(), I, init ? init : filler); + E->updateInit(Reader.getContext(), I, init ? init : filler); } } else { for (unsigned I = 0; I != NumInits; ++I) - E->updateInit(*Reader.getContext(), I, Reader.ReadSubExpr()); + E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr()); } } @@ -620,11 +638,11 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx)); E->setGNUSyntax(Record[Idx++]); - llvm::SmallVector<Designator, 4> Designators; + SmallVector<Designator, 4> Designators; while (Idx < Record.size()) { switch ((DesignatorTypes)Record[Idx++]) { case DESIG_FIELD_DECL: { - FieldDecl *Field = cast<FieldDecl>(Reader.GetDecl(Record[Idx++])); + FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx); SourceLocation DotLoc = ReadSourceLocation(Record, Idx); SourceLocation FieldLoc @@ -636,7 +654,7 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { } case DESIG_FIELD_NAME: { - const IdentifierInfo *Name = Reader.GetIdentifierInfo(Record, Idx); + const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx); SourceLocation DotLoc = ReadSourceLocation(Record, Idx); SourceLocation FieldLoc @@ -669,7 +687,7 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { } } } - E->setDesignators(*Reader.getContext(), + E->setDesignators(Reader.getContext(), Designators.data(), Designators.size()); } @@ -689,7 +707,7 @@ void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) { VisitExpr(E); E->setAmpAmpLoc(ReadSourceLocation(Record, Idx)); E->setLabelLoc(ReadSourceLocation(Record, Idx)); - E->setLabel(cast<LabelDecl>(Reader.GetDecl(Record[Idx++]))); + E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx)); } void ASTStmtReader::VisitStmtExpr(StmtExpr *E) { @@ -715,23 +733,23 @@ void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) { void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { VisitExpr(E); - llvm::SmallVector<Expr *, 16> Exprs; + SmallVector<Expr *, 16> Exprs; unsigned NumExprs = Record[Idx++]; while (NumExprs--) Exprs.push_back(Reader.ReadSubExpr()); - E->setExprs(*Reader.getContext(), Exprs.data(), Exprs.size()); + E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size()); E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); E->setRParenLoc(ReadSourceLocation(Record, Idx)); } void ASTStmtReader::VisitBlockExpr(BlockExpr *E) { VisitExpr(E); - E->setBlockDecl(cast_or_null<BlockDecl>(Reader.GetDecl(Record[Idx++]))); + E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx)); } void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { VisitExpr(E); - E->setDecl(cast<VarDecl>(Reader.GetDecl(Record[Idx++]))); + E->setDecl(ReadDeclAs<VarDecl>(Record, Idx)); E->setLocation(ReadSourceLocation(Record, Idx)); E->setByRef(Record[Idx++]); E->setConstQualAdded(Record[Idx++]); @@ -740,9 +758,9 @@ void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) { VisitExpr(E); E->NumAssocs = Record[Idx++]; - E->AssocTypes = new (*Reader.getContext()) TypeSourceInfo*[E->NumAssocs]; + E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs]; E->SubExprs = - new(*Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs]; + new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs]; E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr(); for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) { @@ -756,6 +774,25 @@ void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) { E->RParenLoc = ReadSourceLocation(Record, Idx); } +void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) { + VisitExpr(E); + E->setOp(AtomicExpr::AtomicOp(Record[Idx++])); + E->setPtr(Reader.ReadSubExpr()); + E->setOrder(Reader.ReadSubExpr()); + E->setNumSubExprs(2); + if (E->getOp() != AtomicExpr::Load) { + E->setVal1(Reader.ReadSubExpr()); + E->setNumSubExprs(3); + } + if (E->isCmpXChg()) { + E->setOrderFail(Reader.ReadSubExpr()); + E->setVal2(Reader.ReadSubExpr()); + E->setNumSubExprs(5); + } + E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); + E->setRParenLoc(ReadSourceLocation(Record, Idx)); +} + //===----------------------------------------------------------------------===// // Objective-C Expressions and Statements @@ -774,21 +811,21 @@ void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { VisitExpr(E); - E->setSelector(Reader.GetSelector(Record, Idx)); + E->setSelector(Reader.ReadSelector(F, Record, Idx)); E->setAtLoc(ReadSourceLocation(Record, Idx)); E->setRParenLoc(ReadSourceLocation(Record, Idx)); } void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { VisitExpr(E); - E->setProtocol(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); + E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); E->setAtLoc(ReadSourceLocation(Record, Idx)); E->setRParenLoc(ReadSourceLocation(Record, Idx)); } void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { VisitExpr(E); - E->setDecl(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); + E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx)); E->setLocation(ReadSourceLocation(Record, Idx)); E->setBase(Reader.ReadSubExpr()); E->setIsArrow(Record[Idx++]); @@ -799,14 +836,11 @@ void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { VisitExpr(E); bool Implicit = Record[Idx++] != 0; if (Implicit) { - ObjCMethodDecl *Getter = - cast<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])); - ObjCMethodDecl *Setter = - cast<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])); + ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx); + ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx); E->setImplicitProperty(Getter, Setter); } else { - E->setExplicitProperty( - cast<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++]))); + E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx)); } E->setLocation(ReadSourceLocation(Record, Idx)); E->setReceiverLocation(ReadSourceLocation(Record, Idx)); @@ -815,11 +849,10 @@ void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { E->setBase(Reader.ReadSubExpr()); break; case 1: - E->setSuperReceiver(Reader.GetType(Record[Idx++])); + E->setSuperReceiver(Reader.readType(F, Record, Idx)); break; case 2: - E->setClassReceiver( - cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); + E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx)); break; } } @@ -828,6 +861,8 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { VisitExpr(E); assert(Record[Idx] == E->getNumArgs()); ++Idx; + unsigned NumStoredSelLocs = Record[Idx++]; + E->SelLocsKind = Record[Idx++]; E->setDelegateInitCall(Record[Idx++]); ObjCMessageExpr::ReceiverKind Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]); @@ -842,7 +877,7 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { case ObjCMessageExpr::SuperClass: case ObjCMessageExpr::SuperInstance: { - QualType T = Reader.GetType(Record[Idx++]); + QualType T = Reader.readType(F, Record, Idx); SourceLocation SuperLoc = ReadSourceLocation(Record, Idx); E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance); break; @@ -852,16 +887,19 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { assert(Kind == E->getReceiverKind()); if (Record[Idx++]) - E->setMethodDecl(cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); + E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx)); else - E->setSelector(Reader.GetSelector(Record, Idx)); + E->setSelector(Reader.ReadSelector(F, Record, Idx)); E->LBracLoc = ReadSourceLocation(Record, Idx); E->RBracLoc = ReadSourceLocation(Record, Idx); - E->SelectorLoc = ReadSourceLocation(Record, Idx); for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) E->setArg(I, Reader.ReadSubExpr()); + + SourceLocation *Locs = E->getStoredSelLocs(); + for (unsigned I = 0; I != NumStoredSelLocs; ++I) + Locs[I] = ReadSourceLocation(Record, Idx); } void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { @@ -876,7 +914,7 @@ void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { VisitStmt(S); S->setCatchBody(Reader.ReadSubStmt()); - S->setCatchParamDecl(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); + S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx)); S->setAtCatchLoc(ReadSourceLocation(Record, Idx)); S->setRParenLoc(ReadSourceLocation(Record, Idx)); } @@ -927,7 +965,7 @@ void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) { VisitStmt(S); S->CatchLoc = ReadSourceLocation(Record, Idx); - S->ExceptionDecl = cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])); + S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx); S->HandlerBlock = Reader.ReadSubStmt(); } @@ -963,12 +1001,13 @@ void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { VisitExpr(E); E->NumArgs = Record[Idx++]; if (E->NumArgs) - E->Args = new (*Reader.getContext()) Stmt*[E->NumArgs]; + E->Args = new (Reader.getContext()) Stmt*[E->NumArgs]; for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) E->setArg(I, Reader.ReadSubExpr()); - E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++]))); + E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx)); E->setLocation(ReadSourceLocation(Record, Idx)); - E->setElidable(Record[Idx++]); + E->setElidable(Record[Idx++]); + E->setHadMultipleCandidates(Record[Idx++]); E->setRequiresZeroInitialization(Record[Idx++]); E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]); E->ParenRange = ReadSourceRange(Record, Idx); @@ -1048,15 +1087,15 @@ void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { VisitExpr(E); - assert(Record[Idx] == E->Param.getInt() && "We messed up at creation ?"); + assert((bool)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->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx)); E->Loc = ReadSourceLocation(Record, Idx); } void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { VisitExpr(E); - E->setTemporary(Reader.ReadCXXTemporary(Record, Idx)); + E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx)); E->setSubExpr(Reader.ReadSubExpr()); } @@ -1072,13 +1111,12 @@ void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { E->Initializer = Record[Idx++]; E->UsualArrayDeleteWantsSize = Record[Idx++]; bool isArray = Record[Idx++]; + E->setHadMultipleCandidates(Record[Idx++]); unsigned NumPlacementArgs = Record[Idx++]; unsigned NumCtorArgs = Record[Idx++]; - E->setOperatorNew(cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); - E->setOperatorDelete( - cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); - E->setConstructor( - cast_or_null<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++]))); + E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx)); + E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx)); + E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx)); E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx); SourceRange TypeIdParens; TypeIdParens.setBegin(ReadSourceLocation(Record, Idx)); @@ -1089,7 +1127,7 @@ void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { E->ConstructorLParen = ReadSourceLocation(Record, Idx); E->ConstructorRParen = ReadSourceLocation(Record, Idx); - E->AllocateArgsArray(*Reader.getContext(), isArray, NumPlacementArgs, + E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs, NumCtorArgs); // Install all the subexpressions. @@ -1104,7 +1142,7 @@ void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) { E->ArrayForm = Record[Idx++]; E->ArrayFormAsWritten = Record[Idx++]; E->UsualArrayDeleteWantsSize = Record[Idx++]; - E->OperatorDelete = cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])); + E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx); E->Argument = Reader.ReadSubExpr(); E->Loc = ReadSourceLocation(Record, Idx); } @@ -1120,7 +1158,7 @@ void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { E->ColonColonLoc = ReadSourceLocation(Record, Idx); E->TildeLoc = ReadSourceLocation(Record, Idx); - IdentifierInfo *II = Reader.GetIdentifierInfo(Record, Idx); + IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx); if (II) E->setDestroyedType(II, ReadSourceLocation(Record, Idx)); else @@ -1131,9 +1169,9 @@ void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) { VisitExpr(E); unsigned NumTemps = Record[Idx++]; if (NumTemps) { - E->setNumTemporaries(*Reader.getContext(), NumTemps); + E->setNumTemporaries(Reader.getContext(), NumTemps); for (unsigned i = 0; i != NumTemps; ++i) - E->setTemporary(i, Reader.ReadCXXTemporary(Record, Idx)); + E->setTemporary(i, Reader.ReadCXXTemporary(F, Record, Idx)); } E->setSubExpr(Reader.ReadSubExpr()); } @@ -1147,12 +1185,11 @@ ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){ Record[Idx++]); E->Base = Reader.ReadSubExpr(); - E->BaseType = Reader.GetType(Record[Idx++]); + E->BaseType = Reader.readType(F, Record, Idx); E->IsArrow = Record[Idx++]; E->OperatorLoc = ReadSourceLocation(Record, Idx); E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - E->FirstQualifierFoundInScope - = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])); + E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx); ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx); } @@ -1191,11 +1228,11 @@ void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) { unsigned NumDecls = Record[Idx++]; UnresolvedSet<8> Decls; for (unsigned i = 0; i != NumDecls; ++i) { - NamedDecl *D = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); + NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx); AccessSpecifier AS = (AccessSpecifier)Record[Idx++]; Decls.addDecl(D, AS); } - E->initializeResults(*Reader.getContext(), Decls.begin(), Decls.end()); + E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end()); ReadDeclarationNameInfo(E->NameInfo, Record, Idx); E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); @@ -1206,7 +1243,7 @@ void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { E->IsArrow = Record[Idx++]; E->HasUnresolvedUsing = Record[Idx++]; E->Base = Reader.ReadSubExpr(); - E->BaseType = Reader.GetType(Record[Idx++]); + E->BaseType = Reader.readType(F, Record, Idx); E->OperatorLoc = ReadSourceLocation(Record, Idx); } @@ -1216,7 +1253,7 @@ void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { if (E->RequiresADL) E->StdIsAssociatedNamespace = Record[Idx++]; E->Overloaded = Record[Idx++]; - E->NamingClass = cast_or_null<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])); + E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx); } void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) { @@ -1280,14 +1317,13 @@ void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) { E->PackLoc = ReadSourceLocation(Record, Idx); E->RParenLoc = ReadSourceLocation(Record, Idx); E->Length = Record[Idx++]; - E->Pack = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])); + E->Pack = ReadDeclAs<NamedDecl>(Record, Idx); } void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr( SubstNonTypeTemplateParmExpr *E) { VisitExpr(E); - E->Param - = cast_or_null<NonTypeTemplateParmDecl>(Reader.GetDecl(Record[Idx++])); + E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx); E->NameLoc = ReadSourceLocation(Record, Idx); E->Replacement = Reader.ReadSubExpr(); } @@ -1295,8 +1331,7 @@ void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr( void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr( SubstNonTypeTemplateParmPackExpr *E) { VisitExpr(E); - E->Param - = cast_or_null<NonTypeTemplateParmDecl>(Reader.GetDecl(Record[Idx++])); + E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx); TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx); if (ArgPack.getKind() != TemplateArgument::Pack) return; @@ -1377,7 +1412,7 @@ void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) { // ASTReader Implementation //===----------------------------------------------------------------------===// -Stmt *ASTReader::ReadStmt(PerFileData &F) { +Stmt *ASTReader::ReadStmt(Module &F) { switch (ReadingKind) { case Read_Decl: case Read_Type: @@ -1390,7 +1425,7 @@ Stmt *ASTReader::ReadStmt(PerFileData &F) { return 0; } -Expr *ASTReader::ReadExpr(PerFileData &F) { +Expr *ASTReader::ReadExpr(Module &F) { return cast_or_null<Expr>(ReadStmt(F)); } @@ -1405,7 +1440,7 @@ 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(Module &F) { ReadingKindTracker ReadingKind(Read_Stmt, *this); llvm::BitstreamCursor &Cursor = F.DeclsCursor; @@ -1531,20 +1566,20 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { case EXPR_DECL_REF: S = DeclRefExpr::CreateEmpty( - *Context, + Context, /*HasQualifier=*/Record[ASTStmtReader::NumExprFields], /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1], /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2], /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ? - Record[ASTStmtReader::NumExprFields + 3] : 0); + Record[ASTStmtReader::NumExprFields + 4] : 0); break; case EXPR_INTEGER_LITERAL: - S = IntegerLiteral::Create(*Context, Empty); + S = IntegerLiteral::Create(Context, Empty); break; case EXPR_FLOATING_LITERAL: - S = FloatingLiteral::Create(*Context, Empty); + S = FloatingLiteral::Create(Context, Empty); break; case EXPR_IMAGINARY_LITERAL: @@ -1552,7 +1587,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_STRING_LITERAL: - S = StringLiteral::CreateEmpty(*Context, + S = StringLiteral::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields + 1]); break; @@ -1573,7 +1608,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_OFFSETOF: - S = OffsetOfExpr::CreateEmpty(*Context, + S = OffsetOfExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields], Record[ASTStmtReader::NumExprFields + 1]); break; @@ -1587,7 +1622,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_CALL: - S = new (Context) CallExpr(*Context, Stmt::CallExprClass, Empty); + S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty); break; case EXPR_MEMBER: { @@ -1610,25 +1645,29 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { for (unsigned i = 0; i != NumTemplateArgs; ++i) ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx)); } - - NamedDecl *FoundD = cast_or_null<NamedDecl>(GetDecl(Record[Idx++])); + + bool HadMultipleCandidates = Record[Idx++]; + + NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx); AccessSpecifier AS = (AccessSpecifier)Record[Idx++]; DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS); - QualType T = GetType(Record[Idx++]); + QualType T = readType(F, Record, Idx); ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]); ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]); Expr *Base = ReadSubExpr(); - ValueDecl *MemberD = cast<ValueDecl>(GetDecl(Record[Idx++])); + ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx); SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx); DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc); bool IsArrow = Record[Idx++]; - S = MemberExpr::Create(*Context, Base, IsArrow, QualifierLoc, + S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc, MemberD, FoundDecl, MemberNameInfo, HasExplicitTemplateArgs ? &ArgInfo : 0, T, VK, OK); ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc, MemberD->getDeclName(), Record, Idx); + if (HadMultipleCandidates) + cast<MemberExpr>(S)->setHadMultipleCandidates(true); break; } @@ -1649,12 +1688,12 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_IMPLICIT_CAST: - S = ImplicitCastExpr::CreateEmpty(*Context, + S = ImplicitCastExpr::CreateEmpty(Context, /*PathSize*/ Record[ASTStmtReader::NumExprFields]); break; case EXPR_CSTYLE_CAST: - S = CStyleCastExpr::CreateEmpty(*Context, + S = CStyleCastExpr::CreateEmpty(Context, /*PathSize*/ Record[ASTStmtReader::NumExprFields]); break; @@ -1667,11 +1706,11 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_INIT_LIST: - S = new (Context) InitListExpr(*getContext(), Empty); + S = new (Context) InitListExpr(getContext(), Empty); break; case EXPR_DESIGNATED_INIT: - S = DesignatedInitExpr::CreateEmpty(*Context, + S = DesignatedInitExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields] - 1); break; @@ -1738,8 +1777,9 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { llvm_unreachable("mismatching AST file"); break; case EXPR_OBJC_MESSAGE_EXPR: - S = ObjCMessageExpr::CreateEmpty(*Context, - Record[ASTStmtReader::NumExprFields]); + S = ObjCMessageExpr::CreateEmpty(Context, + Record[ASTStmtReader::NumExprFields], + Record[ASTStmtReader::NumExprFields + 1]); break; case EXPR_OBJC_ISA: S = new (Context) ObjCIsaExpr(Empty); @@ -1760,7 +1800,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { S = new (Context) ObjCAtFinallyStmt(Empty); break; case STMT_OBJC_AT_TRY: - S = ObjCAtTryStmt::CreateEmpty(*Context, + S = ObjCAtTryStmt::CreateEmpty(Context, Record[ASTStmtReader::NumStmtFields], Record[ASTStmtReader::NumStmtFields + 1]); break; @@ -1787,7 +1827,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case STMT_CXX_TRY: - S = CXXTryStmt::Create(*Context, Empty, + S = CXXTryStmt::Create(Context, Empty, /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]); break; @@ -1796,11 +1836,11 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_CXX_OPERATOR_CALL: - S = new (Context) CXXOperatorCallExpr(*Context, Empty); + S = new (Context) CXXOperatorCallExpr(Context, Empty); break; case EXPR_CXX_MEMBER_CALL: - S = new (Context) CXXMemberCallExpr(*Context, Empty); + S = new (Context) CXXMemberCallExpr(Context, Empty); break; case EXPR_CXX_CONSTRUCT: @@ -1812,26 +1852,26 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_CXX_STATIC_CAST: - S = CXXStaticCastExpr::CreateEmpty(*Context, + S = CXXStaticCastExpr::CreateEmpty(Context, /*PathSize*/ Record[ASTStmtReader::NumExprFields]); break; case EXPR_CXX_DYNAMIC_CAST: - S = CXXDynamicCastExpr::CreateEmpty(*Context, + S = CXXDynamicCastExpr::CreateEmpty(Context, /*PathSize*/ Record[ASTStmtReader::NumExprFields]); break; case EXPR_CXX_REINTERPRET_CAST: - S = CXXReinterpretCastExpr::CreateEmpty(*Context, + S = CXXReinterpretCastExpr::CreateEmpty(Context, /*PathSize*/ Record[ASTStmtReader::NumExprFields]); break; case EXPR_CXX_CONST_CAST: - S = CXXConstCastExpr::CreateEmpty(*Context); + S = CXXConstCastExpr::CreateEmpty(Context); break; case EXPR_CXX_FUNCTIONAL_CAST: - S = CXXFunctionalCastExpr::CreateEmpty(*Context, + S = CXXFunctionalCastExpr::CreateEmpty(Context, /*PathSize*/ Record[ASTStmtReader::NumExprFields]); break; @@ -1864,7 +1904,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields]; if (HasOtherExprStored) { Expr *SubExpr = ReadSubExpr(); - S = CXXDefaultArgExpr::Create(*Context, SourceLocation(), 0, SubExpr); + S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr); } else S = new (Context) CXXDefaultArgExpr(Empty); break; @@ -1891,7 +1931,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_CXX_DEPENDENT_SCOPE_MEMBER: - S = CXXDependentScopeMemberExpr::CreateEmpty(*Context, + S = CXXDependentScopeMemberExpr::CreateEmpty(Context, /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields], /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] ? Record[ASTStmtReader::NumExprFields + 1] @@ -1899,7 +1939,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF: - S = DependentScopeDeclRefExpr::CreateEmpty(*Context, + S = DependentScopeDeclRefExpr::CreateEmpty(Context, /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields], /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] ? Record[ASTStmtReader::NumExprFields + 1] @@ -1907,12 +1947,12 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_CXX_UNRESOLVED_CONSTRUCT: - S = CXXUnresolvedConstructExpr::CreateEmpty(*Context, + S = CXXUnresolvedConstructExpr::CreateEmpty(Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]); break; case EXPR_CXX_UNRESOLVED_MEMBER: - S = UnresolvedMemberExpr::CreateEmpty(*Context, + S = UnresolvedMemberExpr::CreateEmpty(Context, /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields], /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] ? Record[ASTStmtReader::NumExprFields + 1] @@ -1920,7 +1960,7 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { break; case EXPR_CXX_UNRESOLVED_LOOKUP: - S = UnresolvedLookupExpr::CreateEmpty(*Context, + S = UnresolvedLookupExpr::CreateEmpty(Context, /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields], /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] ? Record[ASTStmtReader::NumExprFields + 1] @@ -1983,12 +2023,16 @@ Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) { } case EXPR_CUDA_KERNEL_CALL: - S = new (Context) CUDAKernelCallExpr(*Context, Empty); + S = new (Context) CUDAKernelCallExpr(Context, Empty); break; case EXPR_ASTYPE: S = new (Context) AsTypeExpr(Empty); break; + + case EXPR_ATOMIC: + S = new (Context) AtomicExpr(Empty); + break; } // We hit a STMT_STOP, so we're done with this expression. |