================
@@ -1680,40 +1710,92 @@ void OmpStructureChecker::Leave(const 
parser::OpenMPRequiresConstruct &) {
   dirContext_.pop_back();
 }
 
-void OmpStructureChecker::Enter(const parser::OpenMPDeclarativeAllocate &x) {
-  isPredefinedAllocator = true;
-  const auto &dir{std::get<parser::Verbatim>(x.t)};
-  const auto &objectList{std::get<parser::OmpObjectList>(x.t)};
-  PushContextAndClauseSets(dir.source, llvm::omp::Directive::OMPD_allocate);
-  SymbolSourceMap currSymbols;
-  GetSymbolsInObjectList(objectList, currSymbols);
-  for (auto &[symbol, source] : currSymbols) {
-    if (IsPointer(*symbol)) {
+void OmpStructureChecker::CheckAllocateDirective(parser::CharBlock source,
+    const parser::OmpObjectList &objects,
+    const parser::OmpClauseList &clauses) {
+  const Scope &thisScope{context_.FindScope(source)};
+  SymbolSourceMap symbols;
+  GetSymbolsInObjectList(objects, symbols);
+
+  auto hasPredefinedAllocator{[&](const parser::OmpClause *c) {
+    if (!c) {
+      return std::make_optional(false);
+    }
+    auto *allocator{std::get_if<parser::OmpClause::Allocator>(&c->u)};
----------------
tblah wrote:

What if the clause isn't Allocator. This will then be null. I think we need to 
return `std::make_optional(false)` instead of trying to dereference it on the 
following line.

I see that this won't get called if the allocator clause wasn't found, but in 
that case there's no point having the std::optional and checking for !c. I 
think only checking some possible future error conditions could trip somebody 
up later.

https://github.com/llvm/llvm-project/pull/164420
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to