2010-08-19 07:57:11 +08:00
|
|
|
//===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===//
|
2009-04-27 13:14:47 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Statement/expression deserialization. This implements the
|
2010-08-19 07:56:43 +08:00
|
|
|
// ASTReader::ReadStmt method.
|
2009-04-27 13:14:47 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-19 07:57:17 +08:00
|
|
|
#include "clang/Serialization/ASTReader.h"
|
2009-09-10 07:08:42 +08:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2009-04-27 13:14:47 +08:00
|
|
|
#include "clang/AST/StmtVisitor.h"
|
|
|
|
using namespace clang;
|
2010-08-19 07:57:32 +08:00
|
|
|
using namespace clang::serialization;
|
2009-04-27 13:14:47 +08:00
|
|
|
|
2010-06-30 16:49:18 +08:00
|
|
|
namespace clang {
|
2010-06-28 17:31:42 +08:00
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
|
2010-08-19 07:56:43 +08:00
|
|
|
ASTReader &Reader;
|
2010-07-23 06:43:28 +08:00
|
|
|
llvm::BitstreamCursor &DeclsCursor;
|
2010-08-19 07:56:43 +08:00
|
|
|
const ASTReader::RecordData &Record;
|
2009-04-27 13:14:47 +08:00
|
|
|
unsigned &Idx;
|
|
|
|
|
|
|
|
public:
|
2010-08-19 07:56:52 +08:00
|
|
|
ASTStmtReader(ASTReader &Reader, llvm::BitstreamCursor &Cursor,
|
2010-08-19 07:56:43 +08:00
|
|
|
const ASTReader::RecordData &Record, unsigned &Idx)
|
2010-07-23 06:43:28 +08:00
|
|
|
: Reader(Reader), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
|
2009-04-27 13:14:47 +08:00
|
|
|
|
|
|
|
/// \brief The number of record fields required for the Stmt class
|
|
|
|
/// itself.
|
|
|
|
static const unsigned NumStmtFields = 0;
|
|
|
|
|
|
|
|
/// \brief The number of record fields required for the Expr class
|
|
|
|
/// itself.
|
|
|
|
static const unsigned NumExprFields = NumStmtFields + 3;
|
2010-06-28 17:31:48 +08:00
|
|
|
|
|
|
|
/// \brief Read and initialize a ExplicitTemplateArgumentList structure.
|
2010-06-29 06:28:35 +08:00
|
|
|
void ReadExplicitTemplateArgumentList(ExplicitTemplateArgumentList &ArgList,
|
|
|
|
unsigned NumTemplateArgs);
|
|
|
|
|
|
|
|
void VisitStmt(Stmt *S);
|
|
|
|
void VisitNullStmt(NullStmt *S);
|
|
|
|
void VisitCompoundStmt(CompoundStmt *S);
|
|
|
|
void VisitSwitchCase(SwitchCase *S);
|
|
|
|
void VisitCaseStmt(CaseStmt *S);
|
|
|
|
void VisitDefaultStmt(DefaultStmt *S);
|
|
|
|
void VisitLabelStmt(LabelStmt *S);
|
|
|
|
void VisitIfStmt(IfStmt *S);
|
|
|
|
void VisitSwitchStmt(SwitchStmt *S);
|
|
|
|
void VisitWhileStmt(WhileStmt *S);
|
|
|
|
void VisitDoStmt(DoStmt *S);
|
|
|
|
void VisitForStmt(ForStmt *S);
|
|
|
|
void VisitGotoStmt(GotoStmt *S);
|
|
|
|
void VisitIndirectGotoStmt(IndirectGotoStmt *S);
|
|
|
|
void VisitContinueStmt(ContinueStmt *S);
|
|
|
|
void VisitBreakStmt(BreakStmt *S);
|
|
|
|
void VisitReturnStmt(ReturnStmt *S);
|
|
|
|
void VisitDeclStmt(DeclStmt *S);
|
|
|
|
void VisitAsmStmt(AsmStmt *S);
|
|
|
|
void VisitExpr(Expr *E);
|
|
|
|
void VisitPredefinedExpr(PredefinedExpr *E);
|
|
|
|
void VisitDeclRefExpr(DeclRefExpr *E);
|
|
|
|
void VisitIntegerLiteral(IntegerLiteral *E);
|
|
|
|
void VisitFloatingLiteral(FloatingLiteral *E);
|
|
|
|
void VisitImaginaryLiteral(ImaginaryLiteral *E);
|
|
|
|
void VisitStringLiteral(StringLiteral *E);
|
|
|
|
void VisitCharacterLiteral(CharacterLiteral *E);
|
|
|
|
void VisitParenExpr(ParenExpr *E);
|
2010-06-30 16:49:18 +08:00
|
|
|
void VisitParenListExpr(ParenListExpr *E);
|
2010-06-29 06:28:35 +08:00
|
|
|
void VisitUnaryOperator(UnaryOperator *E);
|
|
|
|
void VisitOffsetOfExpr(OffsetOfExpr *E);
|
|
|
|
void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
|
|
|
|
void VisitArraySubscriptExpr(ArraySubscriptExpr *E);
|
|
|
|
void VisitCallExpr(CallExpr *E);
|
|
|
|
void VisitMemberExpr(MemberExpr *E);
|
|
|
|
void VisitCastExpr(CastExpr *E);
|
|
|
|
void VisitBinaryOperator(BinaryOperator *E);
|
|
|
|
void VisitCompoundAssignOperator(CompoundAssignOperator *E);
|
|
|
|
void VisitConditionalOperator(ConditionalOperator *E);
|
|
|
|
void VisitImplicitCastExpr(ImplicitCastExpr *E);
|
|
|
|
void VisitExplicitCastExpr(ExplicitCastExpr *E);
|
|
|
|
void VisitCStyleCastExpr(CStyleCastExpr *E);
|
|
|
|
void VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
|
|
|
|
void VisitExtVectorElementExpr(ExtVectorElementExpr *E);
|
|
|
|
void VisitInitListExpr(InitListExpr *E);
|
|
|
|
void VisitDesignatedInitExpr(DesignatedInitExpr *E);
|
|
|
|
void VisitImplicitValueInitExpr(ImplicitValueInitExpr *E);
|
|
|
|
void VisitVAArgExpr(VAArgExpr *E);
|
|
|
|
void VisitAddrLabelExpr(AddrLabelExpr *E);
|
|
|
|
void VisitStmtExpr(StmtExpr *E);
|
|
|
|
void VisitTypesCompatibleExpr(TypesCompatibleExpr *E);
|
|
|
|
void VisitChooseExpr(ChooseExpr *E);
|
|
|
|
void VisitGNUNullExpr(GNUNullExpr *E);
|
|
|
|
void VisitShuffleVectorExpr(ShuffleVectorExpr *E);
|
|
|
|
void VisitBlockExpr(BlockExpr *E);
|
|
|
|
void VisitBlockDeclRefExpr(BlockDeclRefExpr *E);
|
|
|
|
void VisitObjCStringLiteral(ObjCStringLiteral *E);
|
|
|
|
void VisitObjCEncodeExpr(ObjCEncodeExpr *E);
|
|
|
|
void VisitObjCSelectorExpr(ObjCSelectorExpr *E);
|
|
|
|
void VisitObjCProtocolExpr(ObjCProtocolExpr *E);
|
|
|
|
void VisitObjCIvarRefExpr(ObjCIvarRefExpr *E);
|
|
|
|
void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E);
|
|
|
|
void VisitObjCImplicitSetterGetterRefExpr(
|
2009-08-21 01:02:02 +08:00
|
|
|
ObjCImplicitSetterGetterRefExpr *E);
|
2010-06-29 06:28:35 +08:00
|
|
|
void VisitObjCMessageExpr(ObjCMessageExpr *E);
|
|
|
|
void VisitObjCSuperExpr(ObjCSuperExpr *E);
|
|
|
|
void VisitObjCIsaExpr(ObjCIsaExpr *E);
|
|
|
|
|
|
|
|
void VisitObjCForCollectionStmt(ObjCForCollectionStmt *);
|
|
|
|
void VisitObjCAtCatchStmt(ObjCAtCatchStmt *);
|
|
|
|
void VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *);
|
|
|
|
void VisitObjCAtTryStmt(ObjCAtTryStmt *);
|
|
|
|
void VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *);
|
|
|
|
void VisitObjCAtThrowStmt(ObjCAtThrowStmt *);
|
|
|
|
|
2010-07-23 00:03:56 +08:00
|
|
|
// C++ Statements
|
|
|
|
void VisitCXXCatchStmt(CXXCatchStmt *S);
|
|
|
|
void VisitCXXTryStmt(CXXTryStmt *S);
|
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
|
|
|
|
void VisitCXXConstructExpr(CXXConstructExpr *E);
|
2010-07-10 19:46:15 +08:00
|
|
|
void VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
|
2010-06-29 06:28:35 +08:00
|
|
|
void VisitCXXNamedCastExpr(CXXNamedCastExpr *E);
|
|
|
|
void VisitCXXStaticCastExpr(CXXStaticCastExpr *E);
|
|
|
|
void VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E);
|
|
|
|
void VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E);
|
|
|
|
void VisitCXXConstCastExpr(CXXConstCastExpr *E);
|
|
|
|
void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E);
|
|
|
|
void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
|
|
|
|
void VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
|
|
|
|
void VisitCXXTypeidExpr(CXXTypeidExpr *E);
|
|
|
|
void VisitCXXThisExpr(CXXThisExpr *E);
|
|
|
|
void VisitCXXThrowExpr(CXXThrowExpr *E);
|
|
|
|
void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E);
|
|
|
|
void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E);
|
2010-05-10 08:25:06 +08:00
|
|
|
|
2010-07-08 14:14:04 +08:00
|
|
|
void VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E);
|
2010-06-29 06:28:35 +08:00
|
|
|
void VisitCXXNewExpr(CXXNewExpr *E);
|
|
|
|
void VisitCXXDeleteExpr(CXXDeleteExpr *E);
|
|
|
|
void VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
|
2010-05-10 09:22:27 +08:00
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
|
2010-06-24 16:57:31 +08:00
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
void VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
|
|
|
|
void VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
|
|
|
|
void VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E);
|
2010-06-25 17:03:26 +08:00
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
void VisitOverloadExpr(OverloadExpr *E);
|
|
|
|
void VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E);
|
|
|
|
void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
|
2010-07-10 19:46:15 +08:00
|
|
|
|
|
|
|
void VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E);
|
2009-04-27 13:14:47 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::
|
2010-06-28 17:31:48 +08:00
|
|
|
ReadExplicitTemplateArgumentList(ExplicitTemplateArgumentList &ArgList,
|
2010-06-29 06:28:35 +08:00
|
|
|
unsigned NumTemplateArgs) {
|
2010-06-28 17:31:48 +08:00
|
|
|
TemplateArgumentListInfo ArgInfo;
|
|
|
|
ArgInfo.setLAngleLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
ArgInfo.setRAngleLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
for (unsigned i = 0; i != NumTemplateArgs; ++i)
|
2010-07-23 06:43:28 +08:00
|
|
|
ArgInfo.addArgument(
|
|
|
|
Reader.ReadTemplateArgumentLoc(DeclsCursor, Record, Idx));
|
2010-06-28 17:31:48 +08:00
|
|
|
ArgList.initializeFrom(ArgInfo);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitStmt(Stmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
assert(Idx == NumStmtFields && "Incorrect statement field count");
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitNullStmt(NullStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
S->setSemiLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-29 06:28:35 +08:00
|
|
|
llvm::SmallVector<Stmt *, 16> Stmts;
|
2009-04-27 13:14:47 +08:00
|
|
|
unsigned NumStmts = Record[Idx++];
|
2010-06-29 06:28:35 +08:00
|
|
|
while (NumStmts--)
|
2010-06-30 06:46:25 +08:00
|
|
|
Stmts.push_back(Reader.ReadSubStmt());
|
2010-06-29 06:28:35 +08:00
|
|
|
S->setStmts(*Reader.getContext(), Stmts.data(), Stmts.size());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setLBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
S->setRBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Reader.RecordSwitchCaseID(S, Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitSwitchCase(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setLHS(Reader.ReadSubExpr());
|
|
|
|
S->setRHS(Reader.ReadSubExpr());
|
|
|
|
S->setSubStmt(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setCaseLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-05-16 07:57:33 +08:00
|
|
|
S->setEllipsisLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitSwitchCase(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setSubStmt(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setDefaultLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-05-16 07:57:33 +08:00
|
|
|
S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
S->setID(Reader.GetIdentifierInfo(Record, Idx));
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setSubStmt(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setIdentLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
Reader.RecordLabelStmt(S, Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitIfStmt(IfStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-22 07:44:13 +08:00
|
|
|
S->setConditionVariable(*Reader.getContext(),
|
|
|
|
cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setCond(Reader.ReadSubExpr());
|
|
|
|
S->setThen(Reader.ReadSubStmt());
|
|
|
|
S->setElse(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setIfLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-05-16 02:53:42 +08:00
|
|
|
S->setElseLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-22 07:44:13 +08:00
|
|
|
S->setConditionVariable(*Reader.getContext(),
|
|
|
|
cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setCond(Reader.ReadSubExpr());
|
|
|
|
S->setBody(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setSwitchLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
SwitchCase *PrevSC = 0;
|
|
|
|
for (unsigned N = Record.size(); Idx != N; ++Idx) {
|
|
|
|
SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
|
|
|
|
if (PrevSC)
|
|
|
|
PrevSC->setNextSwitchCase(SC);
|
|
|
|
else
|
|
|
|
S->setSwitchCaseList(SC);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-08 09:41:12 +08:00
|
|
|
// Retain this SwitchCase, since SwitchStmt::addSwitchCase() would
|
|
|
|
// normally retain it (but we aren't calling addSwitchCase).
|
|
|
|
SC->Retain();
|
2009-04-27 13:14:47 +08:00
|
|
|
PrevSC = SC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-22 07:44:13 +08:00
|
|
|
S->setConditionVariable(*Reader.getContext(),
|
|
|
|
cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setCond(Reader.ReadSubExpr());
|
|
|
|
S->setBody(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitDoStmt(DoStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setCond(Reader.ReadSubExpr());
|
|
|
|
S->setBody(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setDoLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-05-16 05:56:04 +08:00
|
|
|
S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-06-13 07:04:47 +08:00
|
|
|
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitForStmt(ForStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setInit(Reader.ReadSubStmt());
|
|
|
|
S->setCond(Reader.ReadSubExpr());
|
2010-06-22 07:44:13 +08:00
|
|
|
S->setConditionVariable(*Reader.getContext(),
|
|
|
|
cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setInc(Reader.ReadSubExpr());
|
|
|
|
S->setBody(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-05-16 06:12:32 +08:00
|
|
|
S->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
Reader.SetLabelOf(S, Record[Idx++]);
|
|
|
|
S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
S->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-05-16 08:20:29 +08:00
|
|
|
S->setStarLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setTarget(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
S->setContinueLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
S->setBreakLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setRetValue(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setReturnLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-05-15 14:01:05 +08:00
|
|
|
S->setNRVOCandidate(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
S->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
S->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
|
|
|
|
if (Idx + 1 == Record.size()) {
|
|
|
|
// Single declaration
|
|
|
|
S->setDeclGroup(DeclGroupRef(Reader.GetDecl(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]));
|
2009-04-28 05:45:14 +08:00
|
|
|
S->setDeclGroup(DeclGroupRef(DeclGroup::Create(*Reader.getContext(),
|
2009-05-23 06:45:36 +08:00
|
|
|
Decls.data(),
|
|
|
|
Decls.size())));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
unsigned NumOutputs = Record[Idx++];
|
|
|
|
unsigned NumInputs = Record[Idx++];
|
|
|
|
unsigned NumClobbers = Record[Idx++];
|
|
|
|
S->setAsmLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
S->setVolatile(Record[Idx++]);
|
|
|
|
S->setSimple(Record[Idx++]);
|
2010-01-05 06:37:17 +08:00
|
|
|
S->setMSAsm(Record[Idx++]);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
|
2009-04-27 13:14:47 +08:00
|
|
|
|
|
|
|
// Outputs and inputs
|
2010-01-31 06:25:16 +08:00
|
|
|
llvm::SmallVector<IdentifierInfo *, 16> Names;
|
2009-04-27 13:14:47 +08:00
|
|
|
llvm::SmallVector<StringLiteral*, 16> Constraints;
|
|
|
|
llvm::SmallVector<Stmt*, 16> Exprs;
|
|
|
|
for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
|
2010-01-31 06:25:16 +08:00
|
|
|
Names.push_back(Reader.GetIdentifierInfo(Record, Idx));
|
2010-06-30 06:46:25 +08:00
|
|
|
Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
|
|
|
|
Exprs.push_back(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Constraints
|
|
|
|
llvm::SmallVector<StringLiteral*, 16> Clobbers;
|
|
|
|
for (unsigned I = 0; I != NumClobbers; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
|
2010-01-31 03:34:25 +08:00
|
|
|
|
2010-01-31 04:38:10 +08:00
|
|
|
S->setOutputsAndInputsAndClobbers(*Reader.getContext(),
|
|
|
|
Names.data(), Constraints.data(),
|
2010-01-31 03:34:25 +08:00
|
|
|
Exprs.data(), NumOutputs, NumInputs,
|
|
|
|
Clobbers.data(), NumClobbers);
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitExpr(Expr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(E);
|
|
|
|
E->setType(Reader.GetType(Record[Idx++]));
|
|
|
|
E->setTypeDependent(Record[Idx++]);
|
|
|
|
E->setValueDependent(Record[Idx++]);
|
|
|
|
assert(Idx == NumExprFields && "Incorrect expression field count");
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-07-08 21:09:47 +08:00
|
|
|
|
|
|
|
bool HasQualifier = Record[Idx++];
|
|
|
|
unsigned NumTemplateArgs = Record[Idx++];
|
|
|
|
|
|
|
|
E->DecoratedD.setInt((HasQualifier? DeclRefExpr::HasQualifierFlag : 0) |
|
|
|
|
(NumTemplateArgs ? DeclRefExpr::HasExplicitTemplateArgumentListFlag : 0));
|
|
|
|
|
|
|
|
if (HasQualifier) {
|
|
|
|
E->getNameQualifier()->NNS = Reader.ReadNestedNameSpecifier(Record, Idx);
|
|
|
|
E->getNameQualifier()->Range = Reader.ReadSourceRange(Record, Idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NumTemplateArgs)
|
2010-08-20 07:49:38 +08:00
|
|
|
ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
|
2010-07-08 21:09:47 +08:00
|
|
|
NumTemplateArgs);
|
|
|
|
|
2009-12-08 17:08:17 +08:00
|
|
|
E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-08-12 06:01:17 +08:00
|
|
|
// FIXME: read DeclarationNameLoc.
|
2010-07-08 21:09:47 +08:00
|
|
|
E->setLocation(Reader.ReadSourceLocation(Record, Idx));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-08-28 17:06:06 +08:00
|
|
|
E->setValue(*Reader.getContext(), Reader.ReadAPInt(Record, Idx));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-08-28 17:06:06 +08:00
|
|
|
E->setValue(*Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setExact(Record[Idx++]);
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubExpr(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
unsigned Len = Record[Idx++];
|
2009-09-09 23:08:12 +08:00
|
|
|
assert(Record[Idx] == E->getNumConcatenated() &&
|
2009-04-27 13:14:47 +08:00
|
|
|
"Wrong number of concatenated tokens!");
|
|
|
|
++Idx;
|
|
|
|
E->setWide(Record[Idx++]);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
// Read string data
|
2009-09-22 11:27:33 +08:00
|
|
|
llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
|
|
|
|
E->setString(*Reader.getContext(), Str.str());
|
2009-04-27 13:14:47 +08:00
|
|
|
Idx += Len;
|
|
|
|
|
|
|
|
// Read source locations
|
|
|
|
for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
|
|
|
|
E->setStrTokenLoc(I, SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setValue(Record[Idx++]);
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setWide(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setLParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubExpr(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
|
2010-06-30 16:49:18 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
unsigned NumExprs = Record[Idx++];
|
|
|
|
E->Exprs = new (*Reader.getContext()) Stmt*[NumExprs];
|
|
|
|
for (unsigned i = 0; i != NumExprs; ++i)
|
|
|
|
E->Exprs[i] = Reader.ReadSubStmt();
|
|
|
|
E->NumExprs = NumExprs;
|
|
|
|
E->LParenLoc = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
E->RParenLoc = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubExpr(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
|
|
|
|
E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
typedef OffsetOfExpr::OffsetOfNode Node;
|
|
|
|
VisitExpr(E);
|
|
|
|
assert(E->getNumComponents() == Record[Idx]);
|
|
|
|
++Idx;
|
|
|
|
assert(E->getNumExpressions() == Record[Idx]);
|
|
|
|
++Idx;
|
|
|
|
E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-07-23 06:43:28 +08:00
|
|
|
E->setTypeSourceInfo(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
|
|
|
|
Node::Kind Kind = static_cast<Node::Kind>(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));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Node::Field:
|
|
|
|
E->setComponent(I,
|
|
|
|
Node(Start,
|
|
|
|
dyn_cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])),
|
|
|
|
End));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Node::Identifier:
|
|
|
|
E->setComponent(I, Node(Start, Reader.GetIdentifier(Record[Idx++]), End));
|
|
|
|
break;
|
2010-04-29 08:18:15 +08:00
|
|
|
|
2010-07-30 02:16:10 +08:00
|
|
|
case Node::Base: {
|
|
|
|
CXXBaseSpecifier *Base = new (*Reader.getContext()) CXXBaseSpecifier();
|
|
|
|
*Base = Reader.ReadCXXBaseSpecifier(DeclsCursor, Record, Idx);
|
|
|
|
E->setComponent(I, Node(Base));
|
2010-04-29 08:18:15 +08:00
|
|
|
break;
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
}
|
2010-07-30 02:16:10 +08:00
|
|
|
}
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setIndexExpr(I, Reader.ReadSubExpr());
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setSizeof(Record[Idx++]);
|
|
|
|
if (Record[Idx] == 0) {
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setArgument(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
++Idx;
|
|
|
|
} else {
|
2010-07-23 06:43:28 +08:00
|
|
|
E->setArgument(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setLHS(Reader.ReadSubExpr());
|
|
|
|
E->setRHS(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setRBracketLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCallExpr(CallExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2009-04-28 05:45:14 +08:00
|
|
|
E->setNumArgs(*Reader.getContext(), Record[Idx++]);
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setCallee(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setArg(I, Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
|
2010-07-08 21:09:47 +08:00
|
|
|
// Don't call VisitExpr, this is fully initialized at creation.
|
|
|
|
assert(E->getStmtClass() == Stmt::MemberExprClass &&
|
|
|
|
"It's a subclass, we must advance Idx!");
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
|
2009-07-25 01:54:45 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setBase(Reader.ReadSubExpr());
|
2009-07-25 01:54:45 +08:00
|
|
|
E->setIsaMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setArrow(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCastExpr(CastExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-08-07 14:22:56 +08:00
|
|
|
unsigned NumBaseSpecs = Record[Idx++];
|
|
|
|
assert(NumBaseSpecs == E->path_size());
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubExpr(Reader.ReadSubExpr());
|
2009-07-31 08:48:10 +08:00
|
|
|
E->setCastKind((CastExpr::CastKind)Record[Idx++]);
|
2010-08-07 14:22:56 +08:00
|
|
|
CastExpr::path_iterator BaseI = E->path_begin();
|
2010-07-03 07:30:27 +08:00
|
|
|
while (NumBaseSpecs--) {
|
|
|
|
CXXBaseSpecifier *BaseSpec = new (*Reader.getContext()) CXXBaseSpecifier;
|
2010-07-27 00:56:01 +08:00
|
|
|
*BaseSpec = Reader.ReadCXXBaseSpecifier(DeclsCursor, Record, Idx);
|
2010-08-07 14:22:56 +08:00
|
|
|
*BaseI++ = BaseSpec;
|
2010-07-03 07:30:27 +08:00
|
|
|
}
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setLHS(Reader.ReadSubExpr());
|
|
|
|
E->setRHS(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
|
|
|
|
E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitBinaryOperator(E);
|
|
|
|
E->setComputationLHSType(Reader.GetType(Record[Idx++]));
|
|
|
|
E->setComputationResultType(Reader.GetType(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setCond(Reader.ReadSubExpr());
|
|
|
|
E->setLHS(Reader.ReadSubExpr());
|
|
|
|
E->setRHS(Reader.ReadSubExpr());
|
2010-09-01 02:02:20 +08:00
|
|
|
E->setSAVE(Reader.ReadSubExpr());
|
2009-08-26 22:37:04 +08:00
|
|
|
E->setQuestionLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitCastExpr(E);
|
2010-08-25 18:28:54 +08:00
|
|
|
E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitCastExpr(E);
|
2010-07-23 06:43:28 +08:00
|
|
|
E->setTypeInfoAsWritten(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExplicitCastExpr(E);
|
|
|
|
E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-07-23 06:43:28 +08:00
|
|
|
E->setTypeSourceInfo(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setInitializer(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setFileScope(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setBase(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setAccessor(Reader.GetIdentifierInfo(Record, Idx));
|
|
|
|
E->setAccessorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
unsigned NumInits = Record[Idx++];
|
2010-04-14 07:39:13 +08:00
|
|
|
E->reserveInits(*Reader.getContext(), NumInits);
|
2009-04-27 13:14:47 +08:00
|
|
|
for (unsigned I = 0; I != NumInits; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
E->updateInit(*Reader.getContext(), I, Reader.ReadSubExpr());
|
|
|
|
E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
|
2009-04-27 13:14:47 +08:00
|
|
|
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++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
typedef DesignatedInitExpr::Designator Designator;
|
|
|
|
|
|
|
|
VisitExpr(E);
|
|
|
|
unsigned NumSubExprs = Record[Idx++];
|
|
|
|
assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
|
|
|
|
for (unsigned I = 0; I != NumSubExprs; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubExpr(I, Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setEqualOrColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setGNUSyntax(Record[Idx++]);
|
|
|
|
|
|
|
|
llvm::SmallVector<Designator, 4> Designators;
|
|
|
|
while (Idx < Record.size()) {
|
2010-08-19 07:57:32 +08:00
|
|
|
switch ((DesignatorTypes)Record[Idx++]) {
|
|
|
|
case DESIG_FIELD_DECL: {
|
2009-04-27 13:14:47 +08:00
|
|
|
FieldDecl *Field = cast<FieldDecl>(Reader.GetDecl(Record[Idx++]));
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation DotLoc
|
2009-04-27 13:14:47 +08:00
|
|
|
= SourceLocation::getFromRawEncoding(Record[Idx++]);
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation FieldLoc
|
2009-04-27 13:14:47 +08:00
|
|
|
= SourceLocation::getFromRawEncoding(Record[Idx++]);
|
2009-09-09 23:08:12 +08:00
|
|
|
Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
|
2009-04-27 13:14:47 +08:00
|
|
|
FieldLoc));
|
|
|
|
Designators.back().setField(Field);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case DESIG_FIELD_NAME: {
|
2009-04-27 13:14:47 +08:00
|
|
|
const IdentifierInfo *Name = Reader.GetIdentifierInfo(Record, Idx);
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation DotLoc
|
2009-04-27 13:14:47 +08:00
|
|
|
= SourceLocation::getFromRawEncoding(Record[Idx++]);
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation FieldLoc
|
2009-04-27 13:14:47 +08:00
|
|
|
= SourceLocation::getFromRawEncoding(Record[Idx++]);
|
|
|
|
Designators.push_back(Designator(Name, DotLoc, FieldLoc));
|
|
|
|
break;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case DESIG_ARRAY: {
|
2009-04-27 13:14:47 +08:00
|
|
|
unsigned Index = Record[Idx++];
|
|
|
|
SourceLocation LBracketLoc
|
|
|
|
= SourceLocation::getFromRawEncoding(Record[Idx++]);
|
|
|
|
SourceLocation RBracketLoc
|
|
|
|
= SourceLocation::getFromRawEncoding(Record[Idx++]);
|
|
|
|
Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case DESIG_ARRAY_RANGE: {
|
2009-04-27 13:14:47 +08:00
|
|
|
unsigned Index = Record[Idx++];
|
|
|
|
SourceLocation LBracketLoc
|
|
|
|
= SourceLocation::getFromRawEncoding(Record[Idx++]);
|
|
|
|
SourceLocation EllipsisLoc
|
|
|
|
= SourceLocation::getFromRawEncoding(Record[Idx++]);
|
|
|
|
SourceLocation RBracketLoc
|
|
|
|
= SourceLocation::getFromRawEncoding(Record[Idx++]);
|
|
|
|
Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
|
|
|
|
RBracketLoc));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-01-07 07:17:19 +08:00
|
|
|
E->setDesignators(*Reader.getContext(),
|
|
|
|
Designators.data(), Designators.size());
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubExpr(Reader.ReadSubExpr());
|
2010-08-10 18:06:15 +08:00
|
|
|
E->setWrittenTypeInfo(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setAmpAmpLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setLabelLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
Reader.SetLabelOf(E, Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-08-10 16:50:03 +08:00
|
|
|
E->setArgTInfo1(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
|
|
|
E->setArgTInfo2(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setCond(Reader.ReadSubExpr());
|
|
|
|
E->setLHS(Reader.ReadSubExpr());
|
|
|
|
E->setRHS(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setTokenLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-29 06:28:35 +08:00
|
|
|
llvm::SmallVector<Expr *, 16> Exprs;
|
2009-04-27 13:14:47 +08:00
|
|
|
unsigned NumExprs = Record[Idx++];
|
2010-06-29 06:28:35 +08:00
|
|
|
while (NumExprs--)
|
2010-06-30 06:46:25 +08:00
|
|
|
Exprs.push_back(Reader.ReadSubExpr());
|
2010-06-29 06:28:35 +08:00
|
|
|
E->setExprs(*Reader.getContext(), Exprs.data(), Exprs.size());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setBlockDecl(cast_or_null<BlockDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
E->setHasBlockDeclRefExprs(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setByRef(Record[Idx++]);
|
2009-06-20 08:02:26 +08:00
|
|
|
E->setConstQualAdded(Record[Idx++]);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setCopyConstructorExpr(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Objective-C Expressions and Statements
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
2010-07-23 06:43:28 +08:00
|
|
|
E->setEncodedTypeSourceInfo(Reader.GetTypeSourceInfo(DeclsCursor,Record,Idx));
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setSelector(Reader.GetSelector(Record, Idx));
|
|
|
|
E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setProtocol(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setDecl(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setBase(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setIsArrow(Record[Idx++]);
|
|
|
|
E->setIsFreeIvar(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setProperty(cast<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setBase(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCImplicitSetterGetterRefExpr(
|
2009-08-21 01:02:02 +08:00
|
|
|
ObjCImplicitSetterGetterRefExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setGetterMethod(
|
|
|
|
cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
E->setSetterMethod(
|
|
|
|
cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
|
2009-08-19 05:37:33 +08:00
|
|
|
E->setInterfaceDecl(
|
2009-04-27 13:14:47 +08:00
|
|
|
cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setBase(Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:
1) Send to a object instance described by an expression (e.g., [x method:5])
2) Send to a class described by the class name (e.g., [NSString method:5])
3) Send to a superclass class (e.g, [super method:5] in class method)
4) Send to a superclass instance (e.g., [super method:5] in instance method)
Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:
1) Unchanged; the object instance is represented by an Expr*.
2) Previously stored the ObjCInterfaceDecl* referring to the class
receiving the message. Now stores a TypeSourceInfo* so that we know
how the class was spelled. This both maintains typedef information
and opens the door for more complicated C++ types (e.g., dependent
types). There was an alternative, unused representation of these
sends by naming the class via an IdentifierInfo *. In practice, we
either had an ObjCInterfaceDecl *, from which we would get the
IdentifierInfo *, or we fell into the case below...
3) Previously represented by a class message whose IdentifierInfo *
referred to "super". Sema and CodeGen would use isStr("super") to
determine if they had a send to super. Now represented as a
"class super" send, where we have both the location of the "super"
keyword and the ObjCInterfaceDecl* of the superclass we're
targetting (statically).
4) Previously represented by an instance message whose receiver is a
an ObjCSuperExpr, which Sema and CodeGen would check for via
isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
where we have both the location of the "super" keyword and the
ObjCInterfaceDecl* of the superclass we're targetting
(statically). Note that ObjCSuperExpr only has one remaining use in
the AST, which is for "super.prop" references.
The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!
This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:
if (message has a receiver expression) {
// instance message
if (isa<ObjCSuperExpr>(...)) {
// send to super
} else {
// send to an object
}
} else {
// class message
if (name->isStr("super")) {
// class send to super
} else {
// send to class
}
}
with a switch
switch (E->getReceiverKind()) {
case ObjCMessageExpr::SuperInstance: ...
case ObjCMessageExpr::Instance: ...
case ObjCMessageExpr::SuperClass: ...
case ObjCMessageExpr::Class:...
}
There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.
llvm-svn: 101972
2010-04-21 08:45:42 +08:00
|
|
|
assert(Record[Idx] == E->getNumArgs());
|
|
|
|
++Idx;
|
|
|
|
ObjCMessageExpr::ReceiverKind Kind
|
|
|
|
= static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
|
|
|
|
switch (Kind) {
|
|
|
|
case ObjCMessageExpr::Instance:
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setInstanceReceiver(Reader.ReadSubExpr());
|
Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:
1) Send to a object instance described by an expression (e.g., [x method:5])
2) Send to a class described by the class name (e.g., [NSString method:5])
3) Send to a superclass class (e.g, [super method:5] in class method)
4) Send to a superclass instance (e.g., [super method:5] in instance method)
Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:
1) Unchanged; the object instance is represented by an Expr*.
2) Previously stored the ObjCInterfaceDecl* referring to the class
receiving the message. Now stores a TypeSourceInfo* so that we know
how the class was spelled. This both maintains typedef information
and opens the door for more complicated C++ types (e.g., dependent
types). There was an alternative, unused representation of these
sends by naming the class via an IdentifierInfo *. In practice, we
either had an ObjCInterfaceDecl *, from which we would get the
IdentifierInfo *, or we fell into the case below...
3) Previously represented by a class message whose IdentifierInfo *
referred to "super". Sema and CodeGen would use isStr("super") to
determine if they had a send to super. Now represented as a
"class super" send, where we have both the location of the "super"
keyword and the ObjCInterfaceDecl* of the superclass we're
targetting (statically).
4) Previously represented by an instance message whose receiver is a
an ObjCSuperExpr, which Sema and CodeGen would check for via
isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
where we have both the location of the "super" keyword and the
ObjCInterfaceDecl* of the superclass we're targetting
(statically). Note that ObjCSuperExpr only has one remaining use in
the AST, which is for "super.prop" references.
The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!
This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:
if (message has a receiver expression) {
// instance message
if (isa<ObjCSuperExpr>(...)) {
// send to super
} else {
// send to an object
}
} else {
// class message
if (name->isStr("super")) {
// class send to super
} else {
// send to class
}
}
with a switch
switch (E->getReceiverKind()) {
case ObjCMessageExpr::SuperInstance: ...
case ObjCMessageExpr::Instance: ...
case ObjCMessageExpr::SuperClass: ...
case ObjCMessageExpr::Class:...
}
There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.
llvm-svn: 101972
2010-04-21 08:45:42 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ObjCMessageExpr::Class:
|
2010-07-23 06:43:28 +08:00
|
|
|
E->setClassReceiver(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:
1) Send to a object instance described by an expression (e.g., [x method:5])
2) Send to a class described by the class name (e.g., [NSString method:5])
3) Send to a superclass class (e.g, [super method:5] in class method)
4) Send to a superclass instance (e.g., [super method:5] in instance method)
Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:
1) Unchanged; the object instance is represented by an Expr*.
2) Previously stored the ObjCInterfaceDecl* referring to the class
receiving the message. Now stores a TypeSourceInfo* so that we know
how the class was spelled. This both maintains typedef information
and opens the door for more complicated C++ types (e.g., dependent
types). There was an alternative, unused representation of these
sends by naming the class via an IdentifierInfo *. In practice, we
either had an ObjCInterfaceDecl *, from which we would get the
IdentifierInfo *, or we fell into the case below...
3) Previously represented by a class message whose IdentifierInfo *
referred to "super". Sema and CodeGen would use isStr("super") to
determine if they had a send to super. Now represented as a
"class super" send, where we have both the location of the "super"
keyword and the ObjCInterfaceDecl* of the superclass we're
targetting (statically).
4) Previously represented by an instance message whose receiver is a
an ObjCSuperExpr, which Sema and CodeGen would check for via
isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
where we have both the location of the "super" keyword and the
ObjCInterfaceDecl* of the superclass we're targetting
(statically). Note that ObjCSuperExpr only has one remaining use in
the AST, which is for "super.prop" references.
The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!
This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:
if (message has a receiver expression) {
// instance message
if (isa<ObjCSuperExpr>(...)) {
// send to super
} else {
// send to an object
}
} else {
// class message
if (name->isStr("super")) {
// class send to super
} else {
// send to class
}
}
with a switch
switch (E->getReceiverKind()) {
case ObjCMessageExpr::SuperInstance: ...
case ObjCMessageExpr::Instance: ...
case ObjCMessageExpr::SuperClass: ...
case ObjCMessageExpr::Class:...
}
There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.
llvm-svn: 101972
2010-04-21 08:45:42 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ObjCMessageExpr::SuperClass:
|
|
|
|
case ObjCMessageExpr::SuperInstance: {
|
|
|
|
QualType T = Reader.GetType(Record[Idx++]);
|
|
|
|
SourceLocation SuperLoc = SourceLocation::getFromRawEncoding(Record[Idx++]);
|
|
|
|
E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
|
|
|
|
break;
|
|
|
|
}
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:
1) Send to a object instance described by an expression (e.g., [x method:5])
2) Send to a class described by the class name (e.g., [NSString method:5])
3) Send to a superclass class (e.g, [super method:5] in class method)
4) Send to a superclass instance (e.g., [super method:5] in instance method)
Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:
1) Unchanged; the object instance is represented by an Expr*.
2) Previously stored the ObjCInterfaceDecl* referring to the class
receiving the message. Now stores a TypeSourceInfo* so that we know
how the class was spelled. This both maintains typedef information
and opens the door for more complicated C++ types (e.g., dependent
types). There was an alternative, unused representation of these
sends by naming the class via an IdentifierInfo *. In practice, we
either had an ObjCInterfaceDecl *, from which we would get the
IdentifierInfo *, or we fell into the case below...
3) Previously represented by a class message whose IdentifierInfo *
referred to "super". Sema and CodeGen would use isStr("super") to
determine if they had a send to super. Now represented as a
"class super" send, where we have both the location of the "super"
keyword and the ObjCInterfaceDecl* of the superclass we're
targetting (statically).
4) Previously represented by an instance message whose receiver is a
an ObjCSuperExpr, which Sema and CodeGen would check for via
isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
where we have both the location of the "super" keyword and the
ObjCInterfaceDecl* of the superclass we're targetting
(statically). Note that ObjCSuperExpr only has one remaining use in
the AST, which is for "super.prop" references.
The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!
This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:
if (message has a receiver expression) {
// instance message
if (isa<ObjCSuperExpr>(...)) {
// send to super
} else {
// send to an object
}
} else {
// class message
if (name->isStr("super")) {
// class send to super
} else {
// send to class
}
}
with a switch
switch (E->getReceiverKind()) {
case ObjCMessageExpr::SuperInstance: ...
case ObjCMessageExpr::Instance: ...
case ObjCMessageExpr::SuperClass: ...
case ObjCMessageExpr::Class:...
}
There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.
llvm-svn: 101972
2010-04-21 08:45:42 +08:00
|
|
|
assert(Kind == E->getReceiverKind());
|
|
|
|
|
|
|
|
if (Record[Idx++])
|
|
|
|
E->setMethodDecl(cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
else
|
|
|
|
E->setSelector(Reader.GetSelector(Record, Idx));
|
|
|
|
|
|
|
|
E->setLeftLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRightLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
|
2009-04-27 13:14:47 +08:00
|
|
|
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setArg(I, Reader.ReadSubExpr());
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCSuperExpr(ObjCSuperExpr *E) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setElement(Reader.ReadSubStmt());
|
|
|
|
S->setCollection(Reader.ReadSubExpr());
|
|
|
|
S->setBody(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setCatchBody(Reader.ReadSubStmt());
|
2010-04-27 00:46:50 +08:00
|
|
|
S->setCatchParamDecl(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setAtCatchLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setFinallyBody(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setAtFinallyLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-04-24 06:50:49 +08:00
|
|
|
assert(Record[Idx] == S->getNumCatchStmts());
|
|
|
|
++Idx;
|
|
|
|
bool HasFinally = Record[Idx++];
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setTryBody(Reader.ReadSubStmt());
|
2010-06-29 06:28:35 +08:00
|
|
|
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
|
2010-04-24 06:50:49 +08:00
|
|
|
|
|
|
|
if (HasFinally)
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setFinallyStmt(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setAtTryLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setSynchExpr(Reader.ReadSubStmt());
|
|
|
|
S->setSynchBody(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setAtSynchronizedLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
|
2009-04-27 13:14:47 +08:00
|
|
|
VisitStmt(S);
|
2010-06-30 06:46:25 +08:00
|
|
|
S->setThrowExpr(Reader.ReadSubStmt());
|
2009-04-27 13:14:47 +08:00
|
|
|
S->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2009-07-14 11:19:21 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// C++ Expressions and Statements
|
2010-07-23 00:03:56 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
|
2010-07-23 00:03:56 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
S->CatchLoc = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
S->ExceptionDecl = cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
S->HandlerBlock = Reader.ReadSubStmt();
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
|
2010-07-23 00:03:56 +08:00
|
|
|
VisitStmt(S);
|
|
|
|
assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
|
|
|
|
++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();
|
|
|
|
}
|
2009-07-14 11:19:21 +08:00
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
|
2010-06-29 06:28:35 +08:00
|
|
|
VisitCallExpr(E);
|
2009-07-14 11:19:21 +08:00
|
|
|
E->setOperator((OverloadedOperatorKind)Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
|
2009-09-10 07:08:42 +08:00
|
|
|
VisitExpr(E);
|
2010-07-10 19:46:15 +08:00
|
|
|
E->NumArgs = Record[Idx++];
|
|
|
|
if (E->NumArgs)
|
|
|
|
E->Args = new (*Reader.getContext()) Stmt*[E->NumArgs];
|
2010-06-24 16:57:09 +08:00
|
|
|
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setArg(I, Reader.ReadSubExpr());
|
2009-09-10 07:08:42 +08:00
|
|
|
E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++])));
|
2009-12-16 09:38:02 +08:00
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-09-10 07:08:42 +08:00
|
|
|
E->setElidable(Record[Idx++]);
|
2009-12-17 02:50:27 +08:00
|
|
|
E->setRequiresZeroInitialization(Record[Idx++]);
|
2010-05-15 08:13:29 +08:00
|
|
|
E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
|
2009-09-10 07:08:42 +08:00
|
|
|
}
|
2009-04-27 13:14:47 +08:00
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
|
2010-07-10 19:46:15 +08:00
|
|
|
VisitCXXConstructExpr(E);
|
|
|
|
E->TyBeginLoc = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
E->RParenLoc = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
|
2010-06-29 06:28:35 +08:00
|
|
|
VisitExplicitCastExpr(E);
|
2010-01-17 05:21:01 +08:00
|
|
|
E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
return VisitCXXNamedCastExpr(E);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
return VisitCXXNamedCastExpr(E);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
return VisitCXXNamedCastExpr(E);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
|
2010-01-17 05:21:01 +08:00
|
|
|
return VisitCXXNamedCastExpr(E);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
|
2010-06-29 06:28:35 +08:00
|
|
|
VisitExplicitCastExpr(E);
|
2010-01-17 05:21:01 +08:00
|
|
|
E->setTypeBeginLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
|
2010-02-07 14:32:43 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setValue(Record[Idx++]);
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
|
2010-02-07 14:32:43 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
|
2010-05-09 14:03:39 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setSourceRange(Reader.ReadSourceRange(Record, Idx));
|
|
|
|
if (E->isTypeOperand()) { // typeid(int)
|
2010-07-23 06:43:28 +08:00
|
|
|
E->setTypeOperandSourceInfo(
|
|
|
|
Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
2010-06-29 06:28:35 +08:00
|
|
|
return;
|
2010-05-09 14:03:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// typeid(42+2)
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setExprOperand(Reader.ReadSubExpr());
|
2010-05-09 14:03:39 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
|
2010-05-09 14:15:05 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setImplicit(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
|
2010-05-09 14:15:05 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubExpr(Reader.ReadSubExpr());
|
2010-05-09 14:15:05 +08:00
|
|
|
}
|
2010-05-09 14:03:39 +08:00
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
|
2010-05-09 14:40:08 +08:00
|
|
|
VisitExpr(E);
|
2010-07-03 07:30:15 +08:00
|
|
|
|
|
|
|
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 = Reader.ReadSourceLocation(Record, Idx);
|
2010-05-10 08:25:06 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
|
2010-05-10 08:25:06 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setTemporary(Reader.ReadCXXTemporary(Record, Idx));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubExpr(Reader.ReadSubExpr());
|
2010-05-10 08:25:06 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
|
2010-05-10 09:22:27 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setTypeBeginLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
|
2010-05-10 09:22:27 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setGlobalNew(Record[Idx++]);
|
|
|
|
E->setHasInitializer(Record[Idx++]);
|
|
|
|
bool isArray = 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++])));
|
2010-09-08 05:49:58 +08:00
|
|
|
E->AllocatedTypeInfo = Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx);
|
2010-07-13 23:54:32 +08:00
|
|
|
SourceRange TypeIdParens;
|
|
|
|
TypeIdParens.setBegin(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
TypeIdParens.setEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->TypeIdParens = TypeIdParens;
|
2010-05-10 09:22:27 +08:00
|
|
|
E->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
E->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
|
|
|
|
E->AllocateArgsArray(*Reader.getContext(), isArray, NumPlacementArgs,
|
|
|
|
NumCtorArgs);
|
|
|
|
|
|
|
|
// Install all the subexpressions.
|
|
|
|
for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
|
|
|
|
I != e; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
*I = Reader.ReadSubStmt();
|
2010-05-10 09:22:27 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
|
2010-06-23 01:07:59 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->setGlobalDelete(Record[Idx++]);
|
|
|
|
E->setArrayForm(Record[Idx++]);
|
|
|
|
E->setOperatorDelete(
|
|
|
|
cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setArgument(Reader.ReadSubExpr());
|
2010-06-23 01:07:59 +08:00
|
|
|
E->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
}
|
2010-05-10 08:25:06 +08:00
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
|
2010-06-28 17:32:03 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setBase(Reader.ReadSubExpr());
|
2010-06-28 17:32:03 +08:00
|
|
|
E->setArrow(Record[Idx++]);
|
|
|
|
E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
|
|
|
E->setQualifierRange(Reader.ReadSourceRange(Record, Idx));
|
2010-07-23 06:43:28 +08:00
|
|
|
E->setScopeTypeInfo(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
2010-06-28 17:32:03 +08:00
|
|
|
E->setColonColonLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
E->setTildeLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
|
|
|
|
IdentifierInfo *II = Reader.GetIdentifierInfo(Record, Idx);
|
|
|
|
if (II)
|
|
|
|
E->setDestroyedType(II, Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
else
|
2010-07-23 06:43:28 +08:00
|
|
|
E->setDestroyedType(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
2010-06-28 17:32:03 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
|
2010-05-10 08:25:06 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
unsigned NumTemps = Record[Idx++];
|
|
|
|
if (NumTemps) {
|
2010-05-11 04:06:30 +08:00
|
|
|
E->setNumTemporaries(*Reader.getContext(), NumTemps);
|
2010-05-10 08:25:06 +08:00
|
|
|
for (unsigned i = 0; i != NumTemps; ++i)
|
|
|
|
E->setTemporary(i, Reader.ReadCXXTemporary(Record, Idx));
|
|
|
|
}
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setSubExpr(Reader.ReadSubExpr());
|
2010-05-09 14:40:08 +08:00
|
|
|
}
|
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
void
|
2010-08-19 07:56:52 +08:00
|
|
|
ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
|
2010-06-24 16:57:31 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
|
|
|
|
unsigned NumTemplateArgs = Record[Idx++];
|
|
|
|
assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() &&
|
|
|
|
"Read wrong record during creation ?");
|
2010-06-28 17:31:48 +08:00
|
|
|
if (E->hasExplicitTemplateArgs())
|
2010-08-20 07:49:38 +08:00
|
|
|
ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
|
2010-06-29 06:28:35 +08:00
|
|
|
NumTemplateArgs);
|
2010-06-24 16:57:31 +08:00
|
|
|
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setBase(Reader.ReadSubExpr());
|
2010-06-24 16:57:31 +08:00
|
|
|
E->setBaseType(Reader.GetType(Record[Idx++]));
|
|
|
|
E->setArrow(Record[Idx++]);
|
|
|
|
E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
|
|
|
E->setQualifierRange(Reader.ReadSourceRange(Record, Idx));
|
|
|
|
E->setFirstQualifierFoundInScope(
|
|
|
|
cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-08-12 06:01:17 +08:00
|
|
|
// FIXME: read whole DeclarationNameInfo.
|
2010-06-24 16:57:31 +08:00
|
|
|
E->setMember(Reader.ReadDeclarationName(Record, Idx));
|
|
|
|
E->setMemberLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
void
|
2010-08-19 07:56:52 +08:00
|
|
|
ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
|
2010-06-28 17:31:56 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
|
|
|
|
unsigned NumTemplateArgs = Record[Idx++];
|
|
|
|
assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() &&
|
|
|
|
"Read wrong record during creation ?");
|
|
|
|
if (E->hasExplicitTemplateArgs())
|
2010-06-29 06:28:35 +08:00
|
|
|
ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
|
|
|
|
NumTemplateArgs);
|
2010-06-28 17:31:56 +08:00
|
|
|
|
2010-08-12 06:01:17 +08:00
|
|
|
// FIXME: read whole DeclarationNameInfo.
|
2010-06-28 17:31:56 +08:00
|
|
|
E->setDeclName(Reader.ReadDeclarationName(Record, Idx));
|
|
|
|
E->setLocation(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
E->setQualifierRange(Reader.ReadSourceRange(Record, Idx));
|
|
|
|
E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
void
|
2010-08-19 07:56:52 +08:00
|
|
|
ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
|
2010-06-24 16:57:31 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
|
|
|
|
++Idx; // NumArgs;
|
|
|
|
for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setArg(I, Reader.ReadSubExpr());
|
2010-06-24 16:57:31 +08:00
|
|
|
E->setTypeBeginLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
E->setTypeAsWritten(Reader.GetType(Record[Idx++]));
|
|
|
|
E->setLParenLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
E->setRParenLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
|
2010-06-25 17:03:26 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
|
|
|
|
unsigned NumTemplateArgs = Record[Idx++];
|
|
|
|
assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() &&
|
|
|
|
"Read wrong record during creation ?");
|
2010-06-29 06:28:35 +08:00
|
|
|
if (E->hasExplicitTemplateArgs())
|
|
|
|
ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
|
|
|
|
NumTemplateArgs);
|
2010-06-25 17:03:26 +08:00
|
|
|
|
|
|
|
unsigned NumDecls = Record[Idx++];
|
|
|
|
UnresolvedSet<8> Decls;
|
|
|
|
for (unsigned i = 0; i != NumDecls; ++i) {
|
|
|
|
NamedDecl *D = cast<NamedDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
|
|
|
|
Decls.addDecl(D, AS);
|
|
|
|
}
|
|
|
|
E->initializeResults(*Reader.getContext(), Decls.begin(), Decls.end());
|
|
|
|
|
2010-08-12 06:01:17 +08:00
|
|
|
// FIXME: read whole DeclarationNameInfo.
|
2010-06-25 17:03:26 +08:00
|
|
|
E->setName(Reader.ReadDeclarationName(Record, Idx));
|
|
|
|
E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
|
|
|
E->setQualifierRange(Reader.ReadSourceRange(Record, Idx));
|
|
|
|
E->setNameLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
|
2010-06-29 06:28:35 +08:00
|
|
|
VisitOverloadExpr(E);
|
2010-06-25 17:03:26 +08:00
|
|
|
E->setArrow(Record[Idx++]);
|
|
|
|
E->setHasUnresolvedUsing(Record[Idx++]);
|
2010-06-30 06:46:25 +08:00
|
|
|
E->setBase(Reader.ReadSubExpr());
|
2010-06-25 17:03:26 +08:00
|
|
|
E->setBaseType(Reader.GetType(Record[Idx++]));
|
|
|
|
E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
|
2010-06-29 06:28:35 +08:00
|
|
|
VisitOverloadExpr(E);
|
2010-06-25 17:03:34 +08:00
|
|
|
E->setRequiresADL(Record[Idx++]);
|
|
|
|
E->setOverloaded(Record[Idx++]);
|
|
|
|
E->setNamingClass(cast_or_null<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:52 +08:00
|
|
|
void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
2010-07-10 19:46:15 +08:00
|
|
|
VisitExpr(E);
|
|
|
|
E->UTT = (UnaryTypeTrait)Record[Idx++];
|
|
|
|
SourceRange Range = Reader.ReadSourceRange(Record, Idx);
|
|
|
|
E->Loc = Range.getBegin();
|
|
|
|
E->RParen = Range.getEnd();
|
|
|
|
E->QueriedType = Reader.GetType(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:43 +08:00
|
|
|
Stmt *ASTReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
|
2010-06-29 06:28:35 +08:00
|
|
|
switch (ReadingKind) {
|
|
|
|
case Read_Decl:
|
|
|
|
case Read_Type:
|
2010-07-23 06:43:28 +08:00
|
|
|
return ReadStmtFromStream(Cursor);
|
2010-06-29 06:28:35 +08:00
|
|
|
case Read_Stmt:
|
2010-06-30 06:46:25 +08:00
|
|
|
return ReadSubStmt();
|
2010-06-29 06:28:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm_unreachable("ReadingKind not set ?");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:43 +08:00
|
|
|
Expr *ASTReader::ReadExpr(llvm::BitstreamCursor &Cursor) {
|
2010-07-23 06:43:28 +08:00
|
|
|
return cast_or_null<Expr>(ReadStmt(Cursor));
|
2010-06-29 06:28:35 +08:00
|
|
|
}
|
2010-05-09 14:40:08 +08:00
|
|
|
|
2010-08-19 07:56:43 +08:00
|
|
|
Expr *ASTReader::ReadSubExpr() {
|
2010-06-30 06:46:25 +08:00
|
|
|
return cast_or_null<Expr>(ReadSubStmt());
|
|
|
|
}
|
|
|
|
|
2009-04-27 13:41:06 +08:00
|
|
|
// Within the bitstream, expressions are stored in Reverse Polish
|
|
|
|
// Notation, with each of the subexpressions preceding the
|
2010-06-29 06:28:35 +08:00
|
|
|
// expression they are stored in. Subexpressions are stored from last to first.
|
|
|
|
// To evaluate expressions, we continue reading expressions and placing them on
|
|
|
|
// the stack, with expressions having operands removing those operands from the
|
2009-04-27 13:41:06 +08:00
|
|
|
// stack. Evaluation terminates when we see a STMT_STOP record, and
|
|
|
|
// the single remaining expression on the stack is our result.
|
2010-08-19 07:56:43 +08:00
|
|
|
Stmt *ASTReader::ReadStmtFromStream(llvm::BitstreamCursor &Cursor) {
|
2010-06-29 06:28:35 +08:00
|
|
|
|
|
|
|
ReadingKindTracker ReadingKind(Read_Stmt, *this);
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
unsigned PrevNumStmts = StmtStack.size();
|
|
|
|
#endif
|
|
|
|
|
2009-04-27 13:14:47 +08:00
|
|
|
RecordData Record;
|
|
|
|
unsigned Idx;
|
2010-08-19 07:56:52 +08:00
|
|
|
ASTStmtReader Reader(*this, Cursor, Record, Idx);
|
2009-04-27 13:14:47 +08:00
|
|
|
Stmt::EmptyShell Empty;
|
|
|
|
|
|
|
|
while (true) {
|
2009-04-27 13:41:06 +08:00
|
|
|
unsigned Code = Cursor.ReadCode();
|
2009-04-27 13:14:47 +08:00
|
|
|
if (Code == llvm::bitc::END_BLOCK) {
|
2009-04-27 13:41:06 +08:00
|
|
|
if (Cursor.ReadBlockEnd()) {
|
2010-08-19 07:57:06 +08:00
|
|
|
Error("error at end of block in AST file");
|
2009-04-27 13:14:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Code == llvm::bitc::ENTER_SUBBLOCK) {
|
|
|
|
// No known subblocks, always skip them.
|
2009-04-27 13:41:06 +08:00
|
|
|
Cursor.ReadSubBlockID();
|
|
|
|
if (Cursor.SkipBlock()) {
|
2010-08-19 07:57:06 +08:00
|
|
|
Error("malformed block record in AST file");
|
2009-04-27 13:14:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Code == llvm::bitc::DEFINE_ABBREV) {
|
2009-04-27 13:41:06 +08:00
|
|
|
Cursor.ReadAbbrevRecord();
|
2009-04-27 13:14:47 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Stmt *S = 0;
|
|
|
|
Idx = 0;
|
|
|
|
Record.clear();
|
|
|
|
bool Finished = false;
|
2010-08-19 07:57:32 +08:00
|
|
|
switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
|
|
|
|
case STMT_STOP:
|
2009-04-27 13:14:47 +08:00
|
|
|
Finished = true;
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_NULL_PTR:
|
2009-09-09 23:08:12 +08:00
|
|
|
S = 0;
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_NULL:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) NullStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_COMPOUND:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) CompoundStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_CASE:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) CaseStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_DEFAULT:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) DefaultStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_LABEL:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) LabelStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_IF:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) IfStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_SWITCH:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) SwitchStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_WHILE:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) WhileStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_DO:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) DoStmt(Empty);
|
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_FOR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ForStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_GOTO:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) GotoStmt(Empty);
|
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_INDIRECT_GOTO:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) IndirectGotoStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_CONTINUE:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ContinueStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_BREAK:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) BreakStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_RETURN:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ReturnStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_DECL:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) DeclStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_ASM:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) AsmStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_PREDEFINED:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) PredefinedExpr(Empty);
|
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_DECL_REF:
|
2010-07-08 21:09:47 +08:00
|
|
|
S = DeclRefExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
|
|
|
|
/*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1]);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_INTEGER_LITERAL:
|
2010-08-28 17:06:06 +08:00
|
|
|
S = IntegerLiteral::Create(*Context, Empty);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_FLOATING_LITERAL:
|
2010-08-28 17:06:06 +08:00
|
|
|
S = FloatingLiteral::Create(*Context, Empty);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_IMAGINARY_LITERAL:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ImaginaryLiteral(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_STRING_LITERAL:
|
2009-09-09 23:08:12 +08:00
|
|
|
S = StringLiteral::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
Record[ASTStmtReader::NumExprFields + 1]);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CHARACTER_LITERAL:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) CharacterLiteral(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_PAREN:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ParenExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_PAREN_LIST:
|
2010-06-30 16:49:18 +08:00
|
|
|
S = new (Context) ParenListExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_UNARY_OPERATOR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) UnaryOperator(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OFFSETOF:
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
S = OffsetOfExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
Record[ASTStmtReader::NumExprFields],
|
|
|
|
Record[ASTStmtReader::NumExprFields + 1]);
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_SIZEOF_ALIGN_OF:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) SizeOfAlignOfExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_ARRAY_SUBSCRIPT:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ArraySubscriptExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CALL:
|
2009-07-14 11:19:21 +08:00
|
|
|
S = new (Context) CallExpr(*Context, Stmt::CallExprClass, Empty);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_MEMBER: {
|
2010-07-08 21:09:47 +08:00
|
|
|
// We load everything here and fully initialize it at creation.
|
|
|
|
// That way we can use MemberExpr::Create and don't have to duplicate its
|
|
|
|
// logic with a MemberExpr::CreateEmpty.
|
|
|
|
|
|
|
|
assert(Idx == 0);
|
|
|
|
NestedNameSpecifier *NNS = 0;
|
|
|
|
SourceRange QualifierRange;
|
|
|
|
if (Record[Idx++]) { // HasQualifier.
|
|
|
|
NNS = ReadNestedNameSpecifier(Record, Idx);
|
|
|
|
QualifierRange = ReadSourceRange(Record, Idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
TemplateArgumentListInfo ArgInfo;
|
|
|
|
unsigned NumTemplateArgs = Record[Idx++];
|
|
|
|
if (NumTemplateArgs) {
|
|
|
|
ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
|
|
|
|
ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
|
|
|
|
for (unsigned i = 0; i != NumTemplateArgs; ++i)
|
2010-07-23 06:43:28 +08:00
|
|
|
ArgInfo.addArgument(ReadTemplateArgumentLoc(Cursor, Record, Idx));
|
2010-07-08 21:09:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NamedDecl *FoundD = cast_or_null<NamedDecl>(GetDecl(Record[Idx++]));
|
|
|
|
AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
|
|
|
|
DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
|
|
|
|
|
|
|
|
QualType T = GetType(Record[Idx++]);
|
|
|
|
Expr *Base = ReadSubExpr();
|
|
|
|
ValueDecl *MemberD = cast<ValueDecl>(GetDecl(Record[Idx++]));
|
2010-08-12 06:01:17 +08:00
|
|
|
// FIXME: read DeclarationNameLoc.
|
2010-07-08 21:09:47 +08:00
|
|
|
SourceLocation MemberLoc = ReadSourceLocation(Record, Idx);
|
2010-08-12 06:01:17 +08:00
|
|
|
DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
|
2010-07-08 21:09:47 +08:00
|
|
|
bool IsArrow = Record[Idx++];
|
|
|
|
|
|
|
|
S = MemberExpr::Create(*Context, Base, IsArrow, NNS, QualifierRange,
|
2010-08-12 06:01:17 +08:00
|
|
|
MemberD, FoundDecl, MemberNameInfo,
|
2010-07-08 21:09:47 +08:00
|
|
|
NumTemplateArgs ? &ArgInfo : 0, T);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
2010-07-08 21:09:47 +08:00
|
|
|
}
|
2009-04-27 13:14:47 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_BINARY_OPERATOR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) BinaryOperator(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_COMPOUND_ASSIGN_OPERATOR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) CompoundAssignOperator(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CONDITIONAL_OPERATOR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ConditionalOperator(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_IMPLICIT_CAST:
|
2010-08-07 14:22:56 +08:00
|
|
|
S = ImplicitCastExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CSTYLE_CAST:
|
2010-08-07 14:22:56 +08:00
|
|
|
S = CStyleCastExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_COMPOUND_LITERAL:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) CompoundLiteralExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_EXT_VECTOR_ELEMENT:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ExtVectorElementExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_INIT_LIST:
|
2010-04-14 07:39:13 +08:00
|
|
|
S = new (Context) InitListExpr(*getContext(), Empty);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_DESIGNATED_INIT:
|
2009-04-28 05:45:14 +08:00
|
|
|
S = DesignatedInitExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
Record[ASTStmtReader::NumExprFields] - 1);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_IMPLICIT_VALUE_INIT:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ImplicitValueInitExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_VA_ARG:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) VAArgExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_ADDR_LABEL:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) AddrLabelExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_STMT:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) StmtExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_TYPES_COMPATIBLE:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) TypesCompatibleExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CHOOSE:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ChooseExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_GNU_NULL:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) GNUNullExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_SHUFFLE_VECTOR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ShuffleVectorExpr(Empty);
|
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_BLOCK:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) BlockExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_BLOCK_DECL_REF:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) BlockDeclRefExpr(Empty);
|
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_STRING_LITERAL:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCStringLiteral(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_ENCODE:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCEncodeExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_SELECTOR_EXPR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCSelectorExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_PROTOCOL_EXPR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCProtocolExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_IVAR_REF_EXPR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCIvarRefExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_PROPERTY_REF_EXPR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCPropertyRefExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_KVC_REF_EXPR:
|
2009-08-21 01:02:02 +08:00
|
|
|
S = new (Context) ObjCImplicitSetterGetterRefExpr(Empty);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_MESSAGE_EXPR:
|
Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:
1) Send to a object instance described by an expression (e.g., [x method:5])
2) Send to a class described by the class name (e.g., [NSString method:5])
3) Send to a superclass class (e.g, [super method:5] in class method)
4) Send to a superclass instance (e.g., [super method:5] in instance method)
Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:
1) Unchanged; the object instance is represented by an Expr*.
2) Previously stored the ObjCInterfaceDecl* referring to the class
receiving the message. Now stores a TypeSourceInfo* so that we know
how the class was spelled. This both maintains typedef information
and opens the door for more complicated C++ types (e.g., dependent
types). There was an alternative, unused representation of these
sends by naming the class via an IdentifierInfo *. In practice, we
either had an ObjCInterfaceDecl *, from which we would get the
IdentifierInfo *, or we fell into the case below...
3) Previously represented by a class message whose IdentifierInfo *
referred to "super". Sema and CodeGen would use isStr("super") to
determine if they had a send to super. Now represented as a
"class super" send, where we have both the location of the "super"
keyword and the ObjCInterfaceDecl* of the superclass we're
targetting (statically).
4) Previously represented by an instance message whose receiver is a
an ObjCSuperExpr, which Sema and CodeGen would check for via
isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
where we have both the location of the "super" keyword and the
ObjCInterfaceDecl* of the superclass we're targetting
(statically). Note that ObjCSuperExpr only has one remaining use in
the AST, which is for "super.prop" references.
The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!
This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:
if (message has a receiver expression) {
// instance message
if (isa<ObjCSuperExpr>(...)) {
// send to super
} else {
// send to an object
}
} else {
// class message
if (name->isStr("super")) {
// class send to super
} else {
// send to class
}
}
with a switch
switch (E->getReceiverKind()) {
case ObjCMessageExpr::SuperInstance: ...
case ObjCMessageExpr::Instance: ...
case ObjCMessageExpr::SuperClass: ...
case ObjCMessageExpr::Class:...
}
There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.
llvm-svn: 101972
2010-04-21 08:45:42 +08:00
|
|
|
S = ObjCMessageExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
Record[ASTStmtReader::NumExprFields]);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_SUPER_EXPR:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCSuperExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_OBJC_ISA:
|
2009-07-25 01:54:45 +08:00
|
|
|
S = new (Context) ObjCIsaExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_OBJC_FOR_COLLECTION:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCForCollectionStmt(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_OBJC_CATCH:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCAtCatchStmt(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_OBJC_FINALLY:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCAtFinallyStmt(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_OBJC_AT_TRY:
|
2010-04-24 06:50:49 +08:00
|
|
|
S = ObjCAtTryStmt::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
Record[ASTStmtReader::NumStmtFields],
|
|
|
|
Record[ASTStmtReader::NumStmtFields + 1]);
|
2009-04-27 13:14:47 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_OBJC_AT_SYNCHRONIZED:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCAtSynchronizedStmt(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_OBJC_AT_THROW:
|
2009-04-27 13:14:47 +08:00
|
|
|
S = new (Context) ObjCAtThrowStmt(Empty);
|
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_CXX_CATCH:
|
2010-07-23 00:03:56 +08:00
|
|
|
S = new (Context) CXXCatchStmt(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case STMT_CXX_TRY:
|
2010-07-23 00:03:56 +08:00
|
|
|
S = CXXTryStmt::Create(*Context, Empty,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
|
2010-07-23 00:03:56 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_OPERATOR_CALL:
|
2009-07-14 11:19:21 +08:00
|
|
|
S = new (Context) CXXOperatorCallExpr(*Context, Empty);
|
|
|
|
break;
|
2010-05-09 13:36:05 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_MEMBER_CALL:
|
2010-05-09 13:36:05 +08:00
|
|
|
S = new (Context) CXXMemberCallExpr(*Context, Empty);
|
|
|
|
break;
|
2009-09-10 07:08:42 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_CONSTRUCT:
|
2010-07-10 19:46:15 +08:00
|
|
|
S = new (Context) CXXConstructExpr(Empty);
|
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_TEMPORARY_OBJECT:
|
2010-07-10 19:46:15 +08:00
|
|
|
S = new (Context) CXXTemporaryObjectExpr(Empty);
|
2009-09-10 07:08:42 +08:00
|
|
|
break;
|
2010-01-17 05:21:01 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_STATIC_CAST:
|
2010-08-07 14:22:56 +08:00
|
|
|
S = CXXStaticCastExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
|
2010-01-17 05:21:01 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_DYNAMIC_CAST:
|
2010-08-07 14:22:56 +08:00
|
|
|
S = CXXDynamicCastExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
|
2010-01-17 05:21:01 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_REINTERPRET_CAST:
|
2010-08-07 14:22:56 +08:00
|
|
|
S = CXXReinterpretCastExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
|
2010-01-17 05:21:01 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_CONST_CAST:
|
2010-08-07 14:22:56 +08:00
|
|
|
S = CXXConstCastExpr::CreateEmpty(*Context);
|
2010-01-17 05:21:01 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_FUNCTIONAL_CAST:
|
2010-08-07 14:22:56 +08:00
|
|
|
S = CXXFunctionalCastExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
|
2010-01-17 05:21:01 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_BOOL_LITERAL:
|
2010-02-07 14:32:43 +08:00
|
|
|
S = new (Context) CXXBoolLiteralExpr(Empty);
|
|
|
|
break;
|
2010-01-17 05:21:01 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_NULL_PTR_LITERAL:
|
2010-02-07 14:32:43 +08:00
|
|
|
S = new (Context) CXXNullPtrLiteralExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_TYPEID_EXPR:
|
2010-05-09 14:03:39 +08:00
|
|
|
S = new (Context) CXXTypeidExpr(Empty, true);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_TYPEID_TYPE:
|
2010-05-09 14:03:39 +08:00
|
|
|
S = new (Context) CXXTypeidExpr(Empty, false);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_THIS:
|
2010-05-09 14:15:05 +08:00
|
|
|
S = new (Context) CXXThisExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_THROW:
|
2010-05-09 14:15:05 +08:00
|
|
|
S = new (Context) CXXThrowExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_DEFAULT_ARG: {
|
2010-08-19 07:56:52 +08:00
|
|
|
bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
|
2010-07-03 07:30:15 +08:00
|
|
|
if (HasOtherExprStored) {
|
|
|
|
Expr *SubExpr = ReadSubExpr();
|
|
|
|
S = CXXDefaultArgExpr::Create(*Context, SourceLocation(), 0, SubExpr);
|
|
|
|
} else
|
|
|
|
S = new (Context) CXXDefaultArgExpr(Empty);
|
2010-05-09 14:40:08 +08:00
|
|
|
break;
|
2010-07-03 07:30:15 +08:00
|
|
|
}
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_BIND_TEMPORARY:
|
2010-05-10 08:25:06 +08:00
|
|
|
S = new (Context) CXXBindTemporaryExpr(Empty);
|
|
|
|
break;
|
2010-09-03 05:50:02 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_SCALAR_VALUE_INIT:
|
2010-07-08 14:14:04 +08:00
|
|
|
S = new (Context) CXXScalarValueInitExpr(Empty);
|
2010-05-10 09:22:27 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_NEW:
|
2010-05-10 09:22:27 +08:00
|
|
|
S = new (Context) CXXNewExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_DELETE:
|
2010-06-23 01:07:59 +08:00
|
|
|
S = new (Context) CXXDeleteExpr(Empty);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_PSEUDO_DESTRUCTOR:
|
2010-06-28 17:32:03 +08:00
|
|
|
S = new (Context) CXXPseudoDestructorExpr(Empty);
|
|
|
|
break;
|
2010-05-10 09:22:27 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_EXPR_WITH_TEMPORARIES:
|
2010-05-10 08:25:06 +08:00
|
|
|
S = new (Context) CXXExprWithTemporaries(Empty);
|
|
|
|
break;
|
2010-06-24 16:57:31 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
|
2010-06-24 16:57:31 +08:00
|
|
|
S = CXXDependentScopeMemberExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]);
|
2010-06-24 16:57:31 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
|
2010-06-28 17:31:56 +08:00
|
|
|
S = DependentScopeDeclRefExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]);
|
2010-06-28 17:31:56 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_UNRESOLVED_CONSTRUCT:
|
2010-06-24 16:57:31 +08:00
|
|
|
S = CXXUnresolvedConstructExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
|
2010-06-25 17:03:26 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_UNRESOLVED_MEMBER:
|
2010-06-25 17:03:26 +08:00
|
|
|
S = UnresolvedMemberExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]);
|
2010-06-24 16:57:31 +08:00
|
|
|
break;
|
2010-06-25 17:03:34 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_UNRESOLVED_LOOKUP:
|
2010-06-25 17:03:34 +08:00
|
|
|
S = UnresolvedLookupExpr::CreateEmpty(*Context,
|
2010-08-19 07:56:52 +08:00
|
|
|
/*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]);
|
2010-06-25 17:03:34 +08:00
|
|
|
break;
|
2010-07-10 19:46:15 +08:00
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case EXPR_CXX_UNARY_TYPE_TRAIT:
|
2010-07-10 19:46:15 +08:00
|
|
|
S = new (Context) UnaryTypeTraitExpr(Empty);
|
|
|
|
break;
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|
2010-07-10 19:46:15 +08:00
|
|
|
|
2009-04-27 13:14:47 +08:00
|
|
|
// We hit a STMT_STOP, so we're done with this expression.
|
|
|
|
if (Finished)
|
|
|
|
break;
|
|
|
|
|
|
|
|
++NumStatementsRead;
|
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
if (S)
|
|
|
|
Reader.Visit(S);
|
2009-04-27 13:14:47 +08:00
|
|
|
|
|
|
|
assert(Idx == Record.size() && "Invalid deserialization of statement");
|
|
|
|
StmtStack.push_back(S);
|
|
|
|
}
|
2010-06-29 06:28:35 +08:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
|
|
|
|
assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return StmtStack.pop_back_val();
|
2009-04-27 13:14:47 +08:00
|
|
|
}
|