summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCoroutine.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-03-27 03:15:46 +0000
committerEric Fiselier <eric@efcs.ca>2018-03-27 03:15:46 +0000
commitd2e30d34b943470025ebcf0fe18f8925c2aac012 (patch)
tree37655517eb4396449d0aa13e0ae4e304f194851c /clang/lib/Sema/SemaCoroutine.cpp
parentbc0d3b4e0fe5081b54751c4561f388cb857d5a72 (diff)
downloadbcm5719-llvm-d2e30d34b943470025ebcf0fe18f8925c2aac012.tar.gz
bcm5719-llvm-d2e30d34b943470025ebcf0fe18f8925c2aac012.zip
[coroutines] Fix invalid source range in co_await call expressions.
Summary: Currently an invalid source range is generated for the member call expressions of `co_await`. The end location of the call expression is the `co_await` token loc, while the start is the location of the operand. This causes crashes when the source range is used to produce diagnostics. This patch fixes the issues by using the expression location instead of the token location when building the member calls. Reviewers: GorNishanov, rsmith, vsk, aaron.ballman Reviewed By: vsk Subscribers: cfe-commits, modocache Differential Revision: https://reviews.llvm.org/D44915 llvm-svn: 328606
Diffstat (limited to 'clang/lib/Sema/SemaCoroutine.cpp')
-rw-r--r--clang/lib/Sema/SemaCoroutine.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index e4cb4cf059f..95758baff4a 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -708,9 +708,14 @@ ExprResult Sema::BuildResolvedCoawaitExpr(SourceLocation Loc, Expr *E,
if (E->getValueKind() == VK_RValue)
E = CreateMaterializeTemporaryExpr(E->getType(), E, true);
+ // The location of the `co_await` token cannot be used when constructing
+ // the member call expressions since it's before the location of `Expr`, which
+ // is used as the start of the member call expression.
+ SourceLocation CallLoc = E->getExprLoc();
+
// Build the await_ready, await_suspend, await_resume calls.
ReadySuspendResumeResult RSS =
- buildCoawaitCalls(*this, Coroutine->CoroutinePromise, Loc, E);
+ buildCoawaitCalls(*this, Coroutine->CoroutinePromise, CallLoc, E);
if (RSS.IsInvalid)
return ExprError();
OpenPOWER on IntegriCloud