llvm-project/clang/lib/AST
Johannes Doerfert 1228d42dda [OpenMP][Part 2] Use reusable OpenMP context/traits handling
This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.

All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.

The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).

The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.

The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.

The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the
future.

---

Test changes:

The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.

Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim

Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D71830
2020-02-14 16:37:42 -06:00
..
Interp Use std::foo_t rather than std::foo in clang. 2020-02-11 10:37:08 -08:00
APValue.cpp Silence static analyzer getAs<RecordType> null dereference warnings. NFCI. 2019-10-03 11:22:48 +00:00
ASTConcept.cpp [Concepts] Transform constraints of non-template functions to ConstantEvaluated 2020-01-25 23:00:24 +02:00
ASTConsumer.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ASTContext.cpp [OPENMP50]Full handling of atomic_default_mem_order in requires 2020-02-11 15:42:34 -05:00
ASTDiagnostic.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
ASTDumper.cpp When dumping the AST to JSON, dump the type information from a typeid expression with a type operand. 2019-05-27 14:34:31 +00:00
ASTImporter.cpp Use C++14-style return type deduction in clang. 2020-02-11 14:41:22 -08:00
ASTImporterLookupTable.cpp [ASTImporter] Fix unhandled cases in ASTImporterLookupTable 2019-06-11 13:35:25 +00:00
ASTStructuralEquivalence.cpp [Concepts] Placeholder constraints and abbreviated templates 2020-01-23 19:39:43 +02:00
ASTTypeTraits.cpp Remove clang::ast_type_traits namespace in favor of clang 2020-02-13 10:46:47 -08:00
AttrImpl.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
CXXABI.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CXXInheritance.cpp Fix wrong devirtualization when the final overrider in one base class 2020-01-31 17:06:48 -08:00
Comment.cpp Fix "pointer is null" static analyzer warning. NFCI. 2020-01-07 13:41:52 +00:00
CommentBriefParser.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CommentCommandTraits.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CommentLexer.cpp [AST] CommentLexer - Remove (optional) Invalid parameter from getSpelling. 2019-09-18 12:11:16 +00:00
CommentParser.cpp Adds a warning when an inline Doxygen comment has no argument 2019-08-05 08:05:16 +00:00
CommentSema.cpp [Wdocumentation] Implement \anchor 2019-12-21 14:52:21 +01:00
ComparisonCategories.cpp [c++20] P1959R0: Remove support for std::*_equality. 2019-12-16 17:49:45 -08:00
DataCollection.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Decl.cpp [clang] Fix linkage of nested lambdas. 2020-02-07 13:24:21 -05:00
DeclBase.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
DeclCXX.cpp Don't assume a reference refers to at least sizeof(T) bytes. 2020-01-31 19:08:17 -08:00
DeclFriend.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DeclGroup.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DeclObjC.cpp [objc_direct] Tigthen checks for direct methods 2019-12-20 10:57:36 -08:00
DeclOpenMP.cpp [OPENMP 5.0]Initial support for 'allocator' clause. 2019-03-12 18:52:33 +00:00
DeclPrinter.cpp [clang][DeclPrinter] Implement visitors for {TemplateType,NonTypeTemplate}Parms 2020-02-14 13:20:34 +01:00
DeclTemplate.cpp Add missing newlines at EOF; NFC 2020-02-12 15:57:25 +00:00
DeclarationName.cpp [AST] Let DeclarationNameInfo printing use PrintingPolicy, and fix const-correctness 2019-11-15 19:19:41 +01:00
Expr.cpp Fix type-dependency of bitfields in templates 2020-02-12 13:31:41 -08:00
ExprCXX.cpp [Concepts] Requires Expressions 2020-01-19 00:23:26 +02:00
ExprClassification.cpp [Concepts] Requires Expressions 2020-01-19 00:23:26 +02:00
ExprConcepts.cpp [Concept] Fix incorrect check for containsUnexpandedParameterPack in CSE 2020-01-30 20:45:44 +02:00
ExprConstant.cpp C++ DR2026: static storage duration variables are not zeroed before 2020-02-06 16:37:22 -08:00
ExprObjC.cpp [AST][NFC] Add const children() accessors to all AST nodes 2019-04-12 15:36:02 +00:00
ExternalASTMerger.cpp Modernize llvm::Error handling in ExternalASTMerger 2019-11-14 13:58:32 +01:00
ExternalASTSource.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
FormatString.cpp Revert "[Clang] Warn about 'z' printf modifier in old MSVC." 2020-01-28 09:27:54 -05:00
FormatStringParsing.h Add a missing header comment, NFC 2019-08-13 22:01:39 +00:00
InheritViz.cpp Silence static analyzer getAs<RecordType> null dereference warnings. NFCI. 2019-10-03 11:22:48 +00:00
ItaniumCXXABI.cpp [c++20] Fix some ambiguities in our mangling of lambdas with explicit 2019-09-05 01:23:47 +00:00
ItaniumMangle.cpp [Concepts] Requires Expressions 2020-01-19 00:23:26 +02:00
JSONNodeDumper.cpp [Wdocumentation] Implement \anchor 2019-12-21 14:52:21 +01:00
Linkage.h [AST] Split parent map traversal logic into ParentMapContext.h 2020-01-24 13:42:28 -08:00
Mangle.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
MicrosoftCXXABI.cpp Separate the MS inheritance model enum from the attribute, NFC 2019-11-22 16:06:30 -08:00
MicrosoftMangle.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
NSAPI.cpp Removed dead code from clang/AST/NSAPI.h 2019-08-29 06:30:12 +00:00
NestedNameSpecifier.cpp Don't call memcpy(p, 0, 0). 2020-02-13 00:51:12 -08:00
ODRHash.cpp [Concepts] Placeholder constraints and abbreviated templates 2020-01-23 19:39:43 +02:00
OSLog.cpp os_log: Allow specifying mask type in format string. 2018-11-06 07:05:14 +00:00
OpenMPClause.cpp [OpenMP][Part 2] Use reusable OpenMP context/traits handling 2020-02-14 16:37:42 -06:00
ParentMap.cpp [OPENMP]Fix PR42632: crash on the analysis of the OpenMP constructs. 2019-07-17 18:03:39 +00:00
ParentMapContext.cpp Remove clang::ast_type_traits namespace in favor of clang 2020-02-13 10:46:47 -08:00
PrintfFormatString.cpp [Sema][ObjC] Fix a -Wformat false positive with localizedStringForKey 2019-08-14 16:57:11 +00:00
QualTypeNames.cpp Fix crash in getFullyQualifiedName for inline namespace 2019-12-28 16:35:51 +03:00
RawCommentList.cpp [clang] Refactor doc comments to Decls attribution 2019-08-13 18:11:44 +00:00
RecordLayout.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RecordLayoutBuilder.cpp Move vtordisp mode from Attr class to LangOptions.h, NFC 2019-11-22 15:47:46 -08:00
ScanfFormatString.cpp Fix parameter name comments using clang-tidy. NFC. 2019-07-16 04:46:31 +00:00
SelectorLocationsKind.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Stmt.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
StmtCXX.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StmtIterator.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StmtObjC.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StmtOpenMP.cpp [OPENMP50]Add cancellation support in taskloop-based directives. 2020-02-13 12:03:43 -05:00
StmtPrinter.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
StmtProfile.cpp [OPENMP50]Add support for relaxed clause in atomic directive. 2020-02-11 11:54:46 -05:00
StmtViz.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TemplateBase.cpp [Concepts] Placeholder constraints and abbreviated templates 2020-01-23 19:39:43 +02:00
TemplateName.cpp [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whose 2019-05-09 03:31:27 +00:00
TextNodeDumper.cpp [Concepts] Placeholder constraints and abbreviated templates 2020-01-23 19:39:43 +02:00
Type.cpp [Concepts] Placeholder constraints and abbreviated templates 2020-01-23 19:39:43 +02:00
TypeLoc.cpp [Concepts] Placeholder constraints and abbreviated templates 2020-01-23 19:39:43 +02:00
TypePrinter.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
VTTBuilder.cpp Silence static analyzer getAs<RecordType> null dereference warnings. NFCI. 2019-10-03 11:22:48 +00:00
VTableBuilder.cpp List implicit operator== after implicit destructors in a vtable. 2020-01-21 15:54:40 -08:00