本文整理汇总了C++中Sema::getCurFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ Sema::getCurFunction方法的具体用法?C++ Sema::getCurFunction怎么用?C++ Sema::getCurFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sema
的用法示例。
在下文中一共展示了Sema::getCurFunction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: actOnCoroutineBodyStart
static bool actOnCoroutineBodyStart(Sema &S, Scope *SC, SourceLocation KWLoc,
StringRef Keyword) {
if (!checkCoroutineContext(S, KWLoc, Keyword))
return false;
auto *ScopeInfo = S.getCurFunction();
assert(ScopeInfo->CoroutinePromise);
// If we have existing coroutine statements then we have already built
// the initial and final suspend points.
if (!ScopeInfo->NeedsCoroutineSuspends)
return true;
ScopeInfo->setNeedsCoroutineSuspends(false);
auto *Fn = cast<FunctionDecl>(S.CurContext);
SourceLocation Loc = Fn->getLocation();
// Build the initial suspend point
auto buildSuspends = [&](StringRef Name) mutable -> StmtResult {
ExprResult Suspend =
buildPromiseCall(S, ScopeInfo->CoroutinePromise, Loc, Name, None);
if (Suspend.isInvalid())
return StmtError();
Suspend = buildOperatorCoawaitCall(S, SC, Loc, Suspend.get());
if (Suspend.isInvalid())
return StmtError();
Suspend = S.BuildResolvedCoawaitExpr(Loc, Suspend.get(),
/*IsImplicit*/ true);
Suspend = S.ActOnFinishFullExpr(Suspend.get());
if (Suspend.isInvalid()) {
S.Diag(Loc, diag::note_coroutine_promise_suspend_implicitly_required)
<< ((Name == "initial_suspend") ? 0 : 1);
S.Diag(KWLoc, diag::note_declared_coroutine_here) << Keyword;
return StmtError();
}
return cast<Stmt>(Suspend.get());
};
StmtResult InitSuspend = buildSuspends("initial_suspend");
if (InitSuspend.isInvalid())
return true;
StmtResult FinalSuspend = buildSuspends("final_suspend");
if (FinalSuspend.isInvalid())
return true;
ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
return true;
}