@@ -1865,70 +1865,44 @@ class OMPSeverityClause final : public OMPClause {
18651865// / \endcode
18661866// / In this example directive '#pragma omp error' has simple
18671867// / 'message' clause with user error message of "GNU compiler required.".
1868- class OMPMessageClause final : public OMPClause {
1868+ class OMPMessageClause final
1869+ : public OMPOneStmtClause<llvm::omp::OMPC_message, OMPClause>,
1870+ public OMPClauseWithPreInit {
18691871 friend class OMPClauseReader ;
18701872
1871- // / Location of '('
1872- SourceLocation LParenLoc;
1873-
1874- // Expression of the 'message' clause.
1875- Stmt *MessageString = nullptr ;
1876-
18771873 // / Set message string of the clause.
1878- void setMessageString (Expr *MS) { MessageString = MS; }
1879-
1880- // / Sets the location of '('.
1881- void setLParenLoc (SourceLocation Loc) { LParenLoc = Loc; }
1874+ void setMessageString (Expr *MS) { setStmt (MS); }
18821875
18831876public:
18841877 // / Build 'message' clause with message string argument
18851878 // /
18861879 // / \param MS Argument of the clause (message string).
1880+ // / \param HelperMS Helper statement for the construct.
1881+ // / \param CaptureRegion Innermost OpenMP region where expressions in this
1882+ // / clause must be captured.
18871883 // / \param StartLoc Starting location of the clause.
18881884 // / \param LParenLoc Location of '('.
18891885 // / \param EndLoc Ending location of the clause.
1890- OMPMessageClause (Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc,
1886+ OMPMessageClause (Expr *MS, Stmt *HelperMS, OpenMPDirectiveKind CaptureRegion,
1887+ SourceLocation StartLoc, SourceLocation LParenLoc,
18911888 SourceLocation EndLoc)
1892- : OMPClause(llvm::omp::OMPC_message, StartLoc, EndLoc),
1893- LParenLoc (LParenLoc), MessageString(MS) {}
1894-
1895- // / Build an empty clause.
1896- OMPMessageClause ()
1897- : OMPClause(llvm::omp::OMPC_message, SourceLocation(), SourceLocation()) {
1889+ : OMPOneStmtClause(MS, StartLoc, LParenLoc, EndLoc),
1890+ OMPClauseWithPreInit (this ) {
1891+ setPreInitStmt (HelperMS, CaptureRegion);
18981892 }
18991893
1900- // / Returns the locaiton of '(' .
1901- SourceLocation getLParenLoc () const { return LParenLoc; }
1894+ // / Build an empty clause .
1895+ OMPMessageClause () : OMPOneStmtClause(), OMPClauseWithPreInit( this ) { }
19021896
19031897 // / Returns message string of the clause.
1904- Expr *getMessageString () const { return cast_or_null <Expr>(MessageString ); }
1898+ Expr *getMessageString () const { return getStmtAs <Expr>(); }
19051899
19061900 // / Try to evaluate the message string at compile time.
19071901 std::optional<std::string> tryEvaluateString (ASTContext &Ctx) const {
19081902 if (Expr *MessageExpr = getMessageString ())
19091903 return MessageExpr->tryEvaluateString (Ctx);
19101904 return std::nullopt ;
19111905 }
1912-
1913- child_range children () {
1914- return child_range (&MessageString, &MessageString + 1 );
1915- }
1916-
1917- const_child_range children () const {
1918- return const_child_range (&MessageString, &MessageString + 1 );
1919- }
1920-
1921- child_range used_children () {
1922- return child_range (child_iterator (), child_iterator ());
1923- }
1924-
1925- const_child_range used_children () const {
1926- return const_child_range (const_child_iterator (), const_child_iterator ());
1927- }
1928-
1929- static bool classof (const OMPClause *T) {
1930- return T->getClauseKind () == llvm::omp::OMPC_message;
1931- }
19321906};
19331907
19341908// / This represents 'schedule' clause in the '#pragma omp ...' directive.
0 commit comments