/// IndirectGotoStmt - This represents an indirect goto.
///
class IndirectGotoStmt : public Stmt {
+ SourceLocation GotoLoc;
Stmt *Target;
- // FIXME: Add location information (e.g. SourceLocation objects).
- // When doing so, update the PCH serialization routines.
public:
- IndirectGotoStmt(Expr *target) : Stmt(IndirectGotoStmtClass),
- Target((Stmt*)target){}
+ IndirectGotoStmt(SourceLocation gotoLoc, Expr *target)
+ : Stmt(IndirectGotoStmtClass), GotoLoc(gotoLoc), Target((Stmt*)target) {}
/// \brief Build an empty indirect goto statement.
explicit IndirectGotoStmt(EmptyShell Empty)
: Stmt(IndirectGotoStmtClass, Empty) { }
+ void setGotoLoc(SourceLocation L) { GotoLoc = L; }
+ SourceLocation getGotoLoc() const { return GotoLoc; }
+
Expr *getTarget();
const Expr *getTarget() const;
void setTarget(Expr *E) { Target = reinterpret_cast<Stmt*>(E); }
- virtual SourceRange getSourceRange() const { return SourceRange(); }
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(GotoLoc, Target->getLocEnd());
+ }
static bool classof(const Stmt *T) {
return T->getStmtClass() == IndirectGotoStmtClass;
IndirectGotoStmt* IndirectGotoStmt::CreateImpl(Deserializer& D, ASTContext& C) {
Expr* Target = D.ReadOwnedPtr<Expr>(C);
- return new IndirectGotoStmt(Target);
+ return new IndirectGotoStmt(SourceLocation(), Target);
}
void InitListExpr::EmitImpl(Serializer& S) const {
void PCHStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
VisitStmt(S);
+ Writer.AddSourceLocation(S->getGotoLoc(), Record);
Writer.WriteSubStmt(S->getTarget());
Code = pch::STMT_INDIRECT_GOTO;
}
}
Action::OwningStmtResult
-Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
+Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc,
ExprArg DestExp) {
// Convert operand to void*
Expr* E = DestExp.takeAs<Expr>();
if (DiagnoseAssignmentResult(ConvTy, StarLoc, Context.VoidPtrTy, ETy,
E, "passing"))
return StmtError();
- return Owned(new (Context) IndirectGotoStmt(E));
+ return Owned(new (Context) IndirectGotoStmt(GotoLoc, E));
}
Action::OwningStmtResult