[clang] [OpenACC] Implement Sema work for OpenACC Clauses (PR #87821)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 5 13:15:54 PDT 2024


================
@@ -3594,11 +3595,26 @@ class Parser : public CodeCompletionHandler {
     OpenACCDirectiveKind DirKind;
     SourceLocation StartLoc;
     SourceLocation EndLoc;
-    // TODO OpenACC: Add Clause list here once we have a type for that.
+    SmallVector<OpenACCClause *> Clauses;
     // TODO OpenACC: As we implement support for the Atomic, Routine, Cache, and
     // Wait constructs, we likely want to put that information in here as well.
   };
 
+  /// Represents the 'error' state of parsing an OpenACC Clause, and stores
+  /// whether we can continue parsing, or should give up on the directive.
+  enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
+
+  /// A type to represent the state of parsing an OpenACC Clause. Situations
+  /// that result in an OpenACCClause pointer are a success and can continue
+  /// parsing, however some other situations can also continue.
+  /// FIXME: This is better represented as a std::expected when we get C++23.
----------------
erichkeane wrote:

I DID, but llvm::Expected doesn't support arbitrary 'error' types, just `llvm::Error`.  My attempt using that ended up being pretty awkward thanks to it.

Additionally, this ends up being a little better 'space' wise, since we know we only have 2 values (and thus can use a `PointerIntPair`) with what IMO looks like a nicer interface.

https://github.com/llvm/llvm-project/pull/87821


More information about the cfe-commits mailing list