aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseOpenMP.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2021-01-31 00:37:56 -0600
committerJohannes Doerfert <johannes@jdoerfert.de>2021-03-11 23:31:21 -0600
commitad9e98b8efa0138559eb640023695dab54967a8d (patch)
tree459c3ecc15fa809ec4c57e10b0ff593d74386621 /clang/lib/Parse/ParseOpenMP.cpp
parentcd1bd6e5870044f3e35da3f713782563e0014c5d (diff)
downloadllvm-ad9e98b8efa0138559eb640023695dab54967a8d.zip
llvm-ad9e98b8efa0138559eb640023695dab54967a8d.tar.gz
llvm-ad9e98b8efa0138559eb640023695dab54967a8d.tar.bz2
[OpenMP] Do not propagate match extensions to nested contexts
If we have nested declare variant context, it doesn't make sense to inherit the match extension from the parent. Instead, just skip it. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D95764
Diffstat (limited to 'clang/lib/Parse/ParseOpenMP.cpp')
-rw-r--r--clang/lib/Parse/ParseOpenMP.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 3de01be..dd98e89 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -21,6 +21,7 @@
#include "clang/Parse/RAIIObjectsForParser.h"
#include "clang/Sema/Scope.h"
#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/UniqueVector.h"
#include "llvm/Frontend/OpenMP/OMPContext.h"
@@ -1463,7 +1464,29 @@ bool Parser::parseOMPDeclareVariantMatchClause(SourceLocation Loc,
// TODO: Keep some source location in the TI to provide better diagnostics.
// TODO: Perform some kind of equivalence check on the condition and score
// expressions.
- for (const OMPTraitSet &ParentSet : ParentTI->Sets) {
+ auto StripImplementation = [](const OMPTraitSet &TSet) -> OMPTraitSet {
+ if (TSet.Kind != llvm::omp::TraitSet::implementation)
+ return TSet;
+ OMPTraitSet Set = TSet;
+ for (OMPTraitSelector &Selector : Set.Selectors) {
+ if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
+ continue;
+ // Do not propagate match extensions to nested contexts.
+ llvm::erase_if(Selector.Properties, [](const OMPTraitProperty &Property) {
+ return (
+ Property.Kind ==
+ llvm::omp::TraitProperty::implementation_extension_match_any ||
+ Property.Kind ==
+ llvm::omp::TraitProperty::implementation_extension_match_all ||
+ Property.Kind ==
+ llvm::omp::TraitProperty::implementation_extension_match_none);
+ });
+ return Set;
+ }
+ return Set;
+ };
+ for (const OMPTraitSet &PSet : ParentTI->Sets) {
+ const OMPTraitSet ParentSet = StripImplementation(PSet);
bool MergedSet = false;
for (OMPTraitSet &Set : TI.Sets) {
if (Set.Kind != ParentSet.Kind)