[cfe-commits] r107218 - in /cfe/trunk: include/clang/Frontend/PCHReader.h lib/Frontend/PCHReaderStmt.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Jun 29 15:46:25 PDT 2010
Author: akirtzidis
Date: Tue Jun 29 17:46:25 2010
New Revision: 107218
URL: http://llvm.org/viewvc/llvm-project?rev=107218&view=rev
Log:
When we know that we are at sub-statement reading (which is all of PCHStmtReader) use the "faster" ReadSubStmt. No functionality change.
Modified:
cfe/trunk/include/clang/Frontend/PCHReader.h
cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=107218&r1=107217&r2=107218&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Tue Jun 29 17:46:25 2010
@@ -774,6 +774,19 @@
/// \brief Reads an expression.
Expr *ReadExpr();
+ /// \brief Reads a sub-statement operand during statement reading.
+ Stmt *ReadSubStmt() {
+ assert(ReadingKind == Read_Stmt &&
+ "Should be called only during statement reading!");
+ // Subexpressions are stored from last to first, so the next Stmt we need
+ // is at the back of the stack.
+ assert(!StmtStack.empty() && "Read too many sub statements!");
+ return StmtStack.pop_back_val();
+ }
+
+ /// \brief Reads a sub-expression operand during statement reading.
+ Expr *ReadSubExpr();
+
/// \brief Reads the macro record located at the given offset.
void ReadMacroRecord(uint64_t Offset);
Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=107218&r1=107217&r2=107218&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Tue Jun 29 17:46:25 2010
@@ -173,7 +173,7 @@
llvm::SmallVector<Stmt *, 16> Stmts;
unsigned NumStmts = Record[Idx++];
while (NumStmts--)
- Stmts.push_back(Reader.ReadStmt());
+ Stmts.push_back(Reader.ReadSubStmt());
S->setStmts(*Reader.getContext(), Stmts.data(), Stmts.size());
S->setLBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setRBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
@@ -186,9 +186,9 @@
void PCHStmtReader::VisitCaseStmt(CaseStmt *S) {
VisitSwitchCase(S);
- S->setLHS(Reader.ReadExpr());
- S->setRHS(Reader.ReadExpr());
- S->setSubStmt(Reader.ReadStmt());
+ S->setLHS(Reader.ReadSubExpr());
+ S->setRHS(Reader.ReadSubExpr());
+ S->setSubStmt(Reader.ReadSubStmt());
S->setCaseLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setEllipsisLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
@@ -196,7 +196,7 @@
void PCHStmtReader::VisitDefaultStmt(DefaultStmt *S) {
VisitSwitchCase(S);
- S->setSubStmt(Reader.ReadStmt());
+ S->setSubStmt(Reader.ReadSubStmt());
S->setDefaultLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -204,7 +204,7 @@
void PCHStmtReader::VisitLabelStmt(LabelStmt *S) {
VisitStmt(S);
S->setID(Reader.GetIdentifierInfo(Record, Idx));
- S->setSubStmt(Reader.ReadStmt());
+ S->setSubStmt(Reader.ReadSubStmt());
S->setIdentLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
Reader.RecordLabelStmt(S, Record[Idx++]);
}
@@ -213,9 +213,9 @@
VisitStmt(S);
S->setConditionVariable(*Reader.getContext(),
cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
- S->setCond(Reader.ReadExpr());
- S->setThen(Reader.ReadStmt());
- S->setElse(Reader.ReadStmt());
+ S->setCond(Reader.ReadSubExpr());
+ S->setThen(Reader.ReadSubStmt());
+ S->setElse(Reader.ReadSubStmt());
S->setIfLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setElseLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -224,8 +224,8 @@
VisitStmt(S);
S->setConditionVariable(*Reader.getContext(),
cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
- S->setCond(Reader.ReadExpr());
- S->setBody(Reader.ReadStmt());
+ S->setCond(Reader.ReadSubExpr());
+ S->setBody(Reader.ReadSubStmt());
S->setSwitchLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
SwitchCase *PrevSC = 0;
for (unsigned N = Record.size(); Idx != N; ++Idx) {
@@ -246,15 +246,15 @@
VisitStmt(S);
S->setConditionVariable(*Reader.getContext(),
cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
- S->setCond(Reader.ReadExpr());
- S->setBody(Reader.ReadStmt());
+ S->setCond(Reader.ReadSubExpr());
+ S->setBody(Reader.ReadSubStmt());
S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
void PCHStmtReader::VisitDoStmt(DoStmt *S) {
VisitStmt(S);
- S->setCond(Reader.ReadExpr());
- S->setBody(Reader.ReadStmt());
+ S->setCond(Reader.ReadSubExpr());
+ S->setBody(Reader.ReadSubStmt());
S->setDoLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setWhileLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
@@ -262,12 +262,12 @@
void PCHStmtReader::VisitForStmt(ForStmt *S) {
VisitStmt(S);
- S->setInit(Reader.ReadStmt());
- S->setCond(Reader.ReadExpr());
+ S->setInit(Reader.ReadSubStmt());
+ S->setCond(Reader.ReadSubExpr());
S->setConditionVariable(*Reader.getContext(),
cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
- S->setInc(Reader.ReadExpr());
- S->setBody(Reader.ReadStmt());
+ S->setInc(Reader.ReadSubExpr());
+ S->setBody(Reader.ReadSubStmt());
S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
@@ -284,7 +284,7 @@
VisitStmt(S);
S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setStarLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
- S->setTarget(Reader.ReadExpr());
+ S->setTarget(Reader.ReadSubExpr());
}
void PCHStmtReader::VisitContinueStmt(ContinueStmt *S) {
@@ -299,7 +299,7 @@
void PCHStmtReader::VisitReturnStmt(ReturnStmt *S) {
VisitStmt(S);
- S->setRetValue(Reader.ReadExpr());
+ S->setRetValue(Reader.ReadSubExpr());
S->setReturnLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setNRVOCandidate(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
}
@@ -334,7 +334,7 @@
S->setSimple(Record[Idx++]);
S->setMSAsm(Record[Idx++]);
- S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadStmt()));
+ S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
// Outputs and inputs
llvm::SmallVector<IdentifierInfo *, 16> Names;
@@ -342,14 +342,14 @@
llvm::SmallVector<Stmt*, 16> Exprs;
for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Names.push_back(Reader.GetIdentifierInfo(Record, Idx));
- Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadStmt()));
- Exprs.push_back(Reader.ReadStmt());
+ Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
+ Exprs.push_back(Reader.ReadSubStmt());
}
// Constraints
llvm::SmallVector<StringLiteral*, 16> Clobbers;
for (unsigned I = 0; I != NumClobbers; ++I)
- Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadStmt()));
+ Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
S->setOutputsAndInputsAndClobbers(*Reader.getContext(),
Names.data(), Constraints.data(),
@@ -394,7 +394,7 @@
void PCHStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
VisitExpr(E);
- E->setSubExpr(Reader.ReadExpr());
+ E->setSubExpr(Reader.ReadSubExpr());
}
void PCHStmtReader::VisitStringLiteral(StringLiteral *E) {
@@ -426,12 +426,12 @@
VisitExpr(E);
E->setLParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setSubExpr(Reader.ReadExpr());
+ E->setSubExpr(Reader.ReadSubExpr());
}
void PCHStmtReader::VisitUnaryOperator(UnaryOperator *E) {
VisitExpr(E);
- E->setSubExpr(Reader.ReadExpr());
+ E->setSubExpr(Reader.ReadSubExpr());
E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -474,14 +474,14 @@
}
for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
- E->setIndexExpr(I, Reader.ReadExpr());
+ E->setIndexExpr(I, Reader.ReadSubExpr());
}
void PCHStmtReader::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
VisitExpr(E);
E->setSizeof(Record[Idx++]);
if (Record[Idx] == 0) {
- E->setArgument(Reader.ReadExpr());
+ E->setArgument(Reader.ReadSubExpr());
++Idx;
} else {
E->setArgument(Reader.GetTypeSourceInfo(Record, Idx));
@@ -492,8 +492,8 @@
void PCHStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
VisitExpr(E);
- E->setLHS(Reader.ReadExpr());
- E->setRHS(Reader.ReadExpr());
+ E->setLHS(Reader.ReadSubExpr());
+ E->setRHS(Reader.ReadSubExpr());
E->setRBracketLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -501,14 +501,14 @@
VisitExpr(E);
E->setNumArgs(*Reader.getContext(), Record[Idx++]);
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setCallee(Reader.ReadExpr());
+ E->setCallee(Reader.ReadSubExpr());
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- E->setArg(I, Reader.ReadExpr());
+ E->setArg(I, Reader.ReadSubExpr());
}
void PCHStmtReader::VisitMemberExpr(MemberExpr *E) {
VisitExpr(E);
- E->setBase(Reader.ReadExpr());
+ E->setBase(Reader.ReadSubExpr());
E->setMemberDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++])));
E->setMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setArrow(Record[Idx++]);
@@ -516,21 +516,21 @@
void PCHStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
VisitExpr(E);
- E->setBase(Reader.ReadExpr());
+ E->setBase(Reader.ReadSubExpr());
E->setIsaMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setArrow(Record[Idx++]);
}
void PCHStmtReader::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
- E->setSubExpr(Reader.ReadExpr());
+ E->setSubExpr(Reader.ReadSubExpr());
E->setCastKind((CastExpr::CastKind)Record[Idx++]);
}
void PCHStmtReader::VisitBinaryOperator(BinaryOperator *E) {
VisitExpr(E);
- E->setLHS(Reader.ReadExpr());
- E->setRHS(Reader.ReadExpr());
+ E->setLHS(Reader.ReadSubExpr());
+ E->setRHS(Reader.ReadSubExpr());
E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -543,9 +543,9 @@
void PCHStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
VisitExpr(E);
- E->setCond(Reader.ReadExpr());
- E->setLHS(Reader.ReadExpr());
- E->setRHS(Reader.ReadExpr());
+ E->setCond(Reader.ReadSubExpr());
+ E->setLHS(Reader.ReadSubExpr());
+ E->setRHS(Reader.ReadSubExpr());
E->setQuestionLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -570,13 +570,13 @@
VisitExpr(E);
E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
- E->setInitializer(Reader.ReadExpr());
+ E->setInitializer(Reader.ReadSubExpr());
E->setFileScope(Record[Idx++]);
}
void PCHStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
VisitExpr(E);
- E->setBase(Reader.ReadExpr());
+ E->setBase(Reader.ReadSubExpr());
E->setAccessor(Reader.GetIdentifierInfo(Record, Idx));
E->setAccessorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -586,8 +586,8 @@
unsigned NumInits = Record[Idx++];
E->reserveInits(*Reader.getContext(), NumInits);
for (unsigned I = 0; I != NumInits; ++I)
- E->updateInit(*Reader.getContext(), I, Reader.ReadExpr());
- E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadStmt()));
+ E->updateInit(*Reader.getContext(), I, Reader.ReadSubExpr());
+ E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
E->setLBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setInitializedFieldInUnion(
@@ -602,7 +602,7 @@
unsigned NumSubExprs = Record[Idx++];
assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
for (unsigned I = 0; I != NumSubExprs; ++I)
- E->setSubExpr(I, Reader.ReadExpr());
+ E->setSubExpr(I, Reader.ReadSubExpr());
E->setEqualOrColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setGNUSyntax(Record[Idx++]);
@@ -665,7 +665,7 @@
void PCHStmtReader::VisitVAArgExpr(VAArgExpr *E) {
VisitExpr(E);
- E->setSubExpr(Reader.ReadExpr());
+ E->setSubExpr(Reader.ReadSubExpr());
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -681,7 +681,7 @@
VisitExpr(E);
E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadStmt()));
+ E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
}
void PCHStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
@@ -694,9 +694,9 @@
void PCHStmtReader::VisitChooseExpr(ChooseExpr *E) {
VisitExpr(E);
- E->setCond(Reader.ReadExpr());
- E->setLHS(Reader.ReadExpr());
- E->setRHS(Reader.ReadExpr());
+ E->setCond(Reader.ReadSubExpr());
+ E->setLHS(Reader.ReadSubExpr());
+ E->setRHS(Reader.ReadSubExpr());
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -711,7 +711,7 @@
llvm::SmallVector<Expr *, 16> Exprs;
unsigned NumExprs = Record[Idx++];
while (NumExprs--)
- Exprs.push_back(Reader.ReadExpr());
+ Exprs.push_back(Reader.ReadSubExpr());
E->setExprs(*Reader.getContext(), Exprs.data(), Exprs.size());
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
@@ -729,7 +729,7 @@
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setByRef(Record[Idx++]);
E->setConstQualAdded(Record[Idx++]);
- E->setCopyConstructorExpr(Reader.ReadExpr());
+ E->setCopyConstructorExpr(Reader.ReadSubExpr());
}
//===----------------------------------------------------------------------===//
@@ -737,7 +737,7 @@
void PCHStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
VisitExpr(E);
- E->setString(cast<StringLiteral>(Reader.ReadStmt()));
+ E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -766,7 +766,7 @@
VisitExpr(E);
E->setDecl(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setBase(Reader.ReadExpr());
+ E->setBase(Reader.ReadSubExpr());
E->setIsArrow(Record[Idx++]);
E->setIsFreeIvar(Record[Idx++]);
}
@@ -775,7 +775,7 @@
VisitExpr(E);
E->setProperty(cast<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++])));
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setBase(Reader.ReadExpr());
+ E->setBase(Reader.ReadSubExpr());
}
void PCHStmtReader::VisitObjCImplicitSetterGetterRefExpr(
@@ -787,7 +787,7 @@
cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
E->setInterfaceDecl(
cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
- E->setBase(Reader.ReadExpr());
+ E->setBase(Reader.ReadSubExpr());
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -800,7 +800,7 @@
= static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
switch (Kind) {
case ObjCMessageExpr::Instance:
- E->setInstanceReceiver(Reader.ReadExpr());
+ E->setInstanceReceiver(Reader.ReadSubExpr());
break;
case ObjCMessageExpr::Class:
@@ -827,7 +827,7 @@
E->setRightLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- E->setArg(I, Reader.ReadExpr());
+ E->setArg(I, Reader.ReadSubExpr());
}
void PCHStmtReader::VisitObjCSuperExpr(ObjCSuperExpr *E) {
@@ -837,16 +837,16 @@
void PCHStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
VisitStmt(S);
- S->setElement(Reader.ReadStmt());
- S->setCollection(Reader.ReadExpr());
- S->setBody(Reader.ReadStmt());
+ S->setElement(Reader.ReadSubStmt());
+ S->setCollection(Reader.ReadSubExpr());
+ S->setBody(Reader.ReadSubStmt());
S->setForLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
void PCHStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
VisitStmt(S);
- S->setCatchBody(Reader.ReadStmt());
+ S->setCatchBody(Reader.ReadSubStmt());
S->setCatchParamDecl(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
S->setAtCatchLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
@@ -854,7 +854,7 @@
void PCHStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
VisitStmt(S);
- S->setFinallyBody(Reader.ReadStmt());
+ S->setFinallyBody(Reader.ReadSubStmt());
S->setAtFinallyLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -863,25 +863,25 @@
assert(Record[Idx] == S->getNumCatchStmts());
++Idx;
bool HasFinally = Record[Idx++];
- S->setTryBody(Reader.ReadStmt());
+ S->setTryBody(Reader.ReadSubStmt());
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
- S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadStmt()));
+ S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
if (HasFinally)
- S->setFinallyStmt(Reader.ReadStmt());
+ S->setFinallyStmt(Reader.ReadSubStmt());
S->setAtTryLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
void PCHStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
VisitStmt(S);
- S->setSynchExpr(Reader.ReadStmt());
- S->setSynchBody(Reader.ReadStmt());
+ S->setSynchExpr(Reader.ReadSubStmt());
+ S->setSynchBody(Reader.ReadSubStmt());
S->setAtSynchronizedLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
void PCHStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
VisitStmt(S);
- S->setThrowExpr(Reader.ReadStmt());
+ S->setThrowExpr(Reader.ReadSubStmt());
S->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
@@ -898,7 +898,7 @@
assert(Record[Idx] == E->getNumArgs() &&"Read wrong record during creation?");
++Idx; // NumArgs;
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- E->setArg(I, Reader.ReadExpr());
+ E->setArg(I, Reader.ReadSubExpr());
E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++])));
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setElidable(Record[Idx++]);
@@ -953,7 +953,7 @@
}
// typeid(42+2)
- E->setExprOperand(Reader.ReadExpr());
+ E->setExprOperand(Reader.ReadSubExpr());
}
void PCHStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
@@ -965,7 +965,7 @@
void PCHStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
VisitExpr(E);
E->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setSubExpr(Reader.ReadExpr());
+ E->setSubExpr(Reader.ReadSubExpr());
}
void PCHStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
@@ -973,13 +973,13 @@
E->setUsedLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
bool HasStoredExpr = Record[Idx++];
if (!HasStoredExpr) return;
- E->setExpr(Reader.ReadExpr());
+ E->setExpr(Reader.ReadSubExpr());
}
void PCHStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
VisitExpr(E);
E->setTemporary(Reader.ReadCXXTemporary(Record, Idx));
- E->setSubExpr(Reader.ReadExpr());
+ E->setSubExpr(Reader.ReadSubExpr());
}
void PCHStmtReader::VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E) {
@@ -1010,7 +1010,7 @@
// Install all the subexpressions.
for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
I != e; ++I)
- *I = Reader.ReadStmt();
+ *I = Reader.ReadSubStmt();
}
void PCHStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
@@ -1019,14 +1019,14 @@
E->setArrayForm(Record[Idx++]);
E->setOperatorDelete(
cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
- E->setArgument(Reader.ReadExpr());
+ E->setArgument(Reader.ReadSubExpr());
E->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
void PCHStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
VisitExpr(E);
- E->setBase(Reader.ReadExpr());
+ E->setBase(Reader.ReadSubExpr());
E->setArrow(Record[Idx++]);
E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx));
E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
@@ -1050,7 +1050,7 @@
for (unsigned i = 0; i != NumTemps; ++i)
E->setTemporary(i, Reader.ReadCXXTemporary(Record, Idx));
}
- E->setSubExpr(Reader.ReadExpr());
+ E->setSubExpr(Reader.ReadSubExpr());
}
void
@@ -1064,7 +1064,7 @@
ReadExplicitTemplateArgumentList(*E->getExplicitTemplateArgumentList(),
NumTemplateArgs);
- E->setBase(Reader.ReadExpr());
+ E->setBase(Reader.ReadSubExpr());
E->setBaseType(Reader.GetType(Record[Idx++]));
E->setArrow(Record[Idx++]);
E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx));
@@ -1099,7 +1099,7 @@
assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
++Idx; // NumArgs;
for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
- E->setArg(I, Reader.ReadExpr());
+ E->setArg(I, Reader.ReadSubExpr());
E->setTypeBeginLoc(Reader.ReadSourceLocation(Record, Idx));
E->setTypeAsWritten(Reader.GetType(Record[Idx++]));
E->setLParenLoc(Reader.ReadSourceLocation(Record, Idx));
@@ -1135,7 +1135,7 @@
VisitOverloadExpr(E);
E->setArrow(Record[Idx++]);
E->setHasUnresolvedUsing(Record[Idx++]);
- E->setBase(Reader.ReadExpr());
+ E->setBase(Reader.ReadSubExpr());
E->setBaseType(Reader.GetType(Record[Idx++]));
E->setOperatorLoc(Reader.ReadSourceLocation(Record, Idx));
}
@@ -1154,10 +1154,7 @@
// Read a statement from the current DeclCursor.
return ReadStmtFromStream(DeclsCursor);
case Read_Stmt:
- // Subexpressions are stored from last to first, so the next Stmt we need
- // will be at the back of the stack.
- assert(!StmtStack.empty() && "Read too many sub statements!");
- return StmtStack.pop_back_val();
+ return ReadSubStmt();
}
llvm_unreachable("ReadingKind not set ?");
@@ -1168,6 +1165,10 @@
return cast_or_null<Expr>(ReadStmt());
}
+Expr *PCHReader::ReadSubExpr() {
+ return cast_or_null<Expr>(ReadSubStmt());
+}
+
// Within the bitstream, expressions are stored in Reverse Polish
// Notation, with each of the subexpressions preceding the
// expression they are stored in. Subexpressions are stored from last to first.
More information about the cfe-commits
mailing list