summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/AST/Stmt.h14
-rw-r--r--clang/lib/AST/StmtSerialization.cpp2
-rw-r--r--clang/lib/Frontend/PCHReader.cpp1
-rw-r--r--clang/lib/Frontend/PCHWriter.cpp1
-rw-r--r--clang/lib/Sema/SemaStmt.cpp4
5 files changed, 14 insertions, 8 deletions
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index f665cfd5826..3c1e04f47aa 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -850,22 +850,26 @@ public:
/// 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;
diff --git a/clang/lib/AST/StmtSerialization.cpp b/clang/lib/AST/StmtSerialization.cpp
index 0d920fa23e3..7a37a16550d 100644
--- a/clang/lib/AST/StmtSerialization.cpp
+++ b/clang/lib/AST/StmtSerialization.cpp
@@ -691,7 +691,7 @@ void IndirectGotoStmt::EmitImpl(Serializer& S) const {
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 {
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp
index 6c79b8a5a57..9af75aef2b4 100644
--- a/clang/lib/Frontend/PCHReader.cpp
+++ b/clang/lib/Frontend/PCHReader.cpp
@@ -415,6 +415,7 @@ unsigned PCHStmtReader::VisitGotoStmt(GotoStmt *S) {
unsigned PCHStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
VisitStmt(S);
+ S->setGotoLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setTarget(cast_or_null<Expr>(StmtStack.back()));
return 1;
}
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp
index 1efe70f270f..9f22f13134b 100644
--- a/clang/lib/Frontend/PCHWriter.cpp
+++ b/clang/lib/Frontend/PCHWriter.cpp
@@ -610,6 +610,7 @@ void PCHStmtWriter::VisitGotoStmt(GotoStmt *S) {
void PCHStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
VisitStmt(S);
+ Writer.AddSourceLocation(S->getGotoLoc(), Record);
Writer.WriteSubStmt(S->getTarget());
Code = pch::STMT_INDIRECT_GOTO;
}
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 6595b881220..4a5facb39cc 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -666,7 +666,7 @@ Sema::ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
}
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>();
@@ -676,7 +676,7 @@ Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
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
OpenPOWER on IntegriCloud