Krzysztof Parzyszek 4dcc159485
[utils][TableGen] Implement clause aliases as alternative spellings (#141765)
Use the spellings in the generated clause parser. The functions
`get<lang>ClauseKind` and `get<lang>ClauseName` are not yet updated.

The definitions of both clauses and directives now take a list of
"Spelling"s instead of a single string. For example
```
def ACCC_Copyin : Clause<[Spelling<"copyin">,
                          Spelling<"present_or_copyin">,
                          Spelling<"pcopyin">]> { ... }
```

A "Spelling" is a versioned string, defaulting to "all versions".

For background information see

https://discourse.llvm.org/t/rfc-alternative-spellings-of-openmp-directives/85507
2025-06-05 12:35:30 -05:00

43 lines
1.2 KiB
TableGen

// RUN: not llvm-tblgen -gen-directive-decl -I %p/../../include %s 2>&1 | FileCheck -match-full-lines %s
// RUN: not llvm-tblgen -gen-directive-impl -I %p/../../include %s 2>&1 | FileCheck -match-full-lines %s
include "llvm/Frontend/Directive/DirectiveBase.td"
def TestDirectiveLanguage : DirectiveLanguage {
let name = "TdlError";
}
def TDLC_ClauseA : Clause<[Spelling<"clausea">]> {
let isDefault = 1;
}
def TDLC_ClauseB : Clause<[Spelling<"clauseb">]> {
}
def TDLC_ClauseC : Clause<[Spelling<"clausec">]> {
}
def TDLC_ClauseD : Clause<[Spelling<"claused">]> {
}
def TDL_DirA : Directive<[Spelling<"dira">]> {
let allowedClauses = [
VersionedClause<TDLC_ClauseA>,
VersionedClause<TDLC_ClauseB>,
VersionedClause<TDLC_ClauseD>
];
let allowedOnceClauses = [
VersionedClause<TDLC_ClauseA>,
VersionedClause<TDLC_ClauseC>
];
let requiredClauses = [
VersionedClause<TDLC_ClauseC>,
VersionedClause<TDLC_ClauseD>
];
let isDefault = 1;
}
// CHECK: error: Clause TDLC_ClauseA already defined on directive TDL_DirA
// CHECK: error: Clause TDLC_ClauseD already defined on directive TDL_DirA
// CHECK: error: One or more clauses are defined multiple times on directive TDL_DirA