================
@@ -2462,6 +2467,35 @@ StmtResult Parser::ParseBreakStatement() {
return ParseBreakOrContinueStatement(/*IsContinue=*/false);
}
+StmtResult Parser::ParseContractAssertStatement() {
+ assert(Tok.is(tok::kw_contract_assert) && "expected contract_assert");
+ if (!getLangOpts().Contracts)
+ Diag(Tok, diag::err_contracts_disabled);
+ SourceLocation ContractAssertLoc = ConsumeToken();
+
+ ParsedAttributes Attrs(AttrFactory);
+ MaybeParseCXX11Attributes(Attrs);
+
+ BalancedDelimiterTracker T(*this, tok::l_paren);
+ if (T.expectAndConsume(diag::err_expected_lparen_after, "contract_assert")) {
+ SkipUntil(tok::semi, StopBeforeMatch);
+ return Actions.ActOnNullStmt(ContractAssertLoc,
+ /*HasLeadingEmptyMacro=*/false);
+ }
+
+ EnterExpressionEvaluationContext Evaluated(
+ Actions, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
+ ExprResult Predicate = ParseConditionalExpression();
+ if (Predicate.isInvalid())
+ T.skipToEnd();
+ else
+ T.consumeClose();
+
+ // TODO: Now we don't build AST node for contracts.
+ return Actions.ActOnNullStmt(ContractAssertLoc,
----------------
ChuanqiXu9 wrote:
Got your point. But as this is a patch series and I plan to add the AST part
soon. I feel the current style is not bad.
https://github.com/llvm/llvm-project/pull/221139
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits