[flang-commits] [flang] [flang][OpenMP] Implement OmpDirectiveName, use in OmpDirectiveSpecif… (PR #130121)

Mats Petersson via flang-commits flang-commits at lists.llvm.org
Thu Mar 6 08:26:11 PST 2025


================
@@ -253,6 +253,21 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Name &x) {
   return os << x.ToString();
 }
 
+OmpDirectiveName::OmpDirectiveName(const Verbatim &name) {
+  std::string_view nameView{name.source.begin(), name.source.size()};
+  std::string nameLower{ToLowerCaseLetters(nameView)};
+  // If the name was actually "unknown" then accept it, otherwise flag
----------------
Leporacanthicus wrote:

This reads a bit "akward", at first I thought it was in fact backwards.  Perhaps `If the name is not "unknown", look up the kind. Result should not be OMPD_unknown. Accept "unknown" if that is the name.`

Or, perhaps rearrange the code so it says `if (nameLower == "unknown") v = OMPD_unkown; else ...` . 

Feel free to fix in any other way that you see fit. 

Or, could we just do something like this:
```
   v = omp::getOpenMPDIrectiveKind(nameLower)
   assert(v != llvm::omp::Directive::OMPD_unknown || nameLower == "unknown" && "Unrecognized directive");
```



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


More information about the flang-commits mailing list