[clang] [clang][test] add TestLanguage.def to specify all tested language versions (PR #94243)

via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 26 12:00:47 PDT 2024


================
@@ -0,0 +1,47 @@
+
+//===-- TestLanguage.def - Language Versions for Testing --------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// The TESTLANGUAGE(-C/-CXX) macros have four parameters:
+// the language, the standard version, the corresponding compile-flag,
+// and an index of the language version for each language.
+// The standard version is used to compare a standard version numerically,
+// and the index is used to impose ordering for the language versions
+// with respect to each language.
+
+#ifndef TESTLANGUAGE
+#error "TESTLANGUAGE must be defined before including this file"
+#endif
+
+#ifndef TESTLANGUAGE_C
+#define TESTLANGUAGE_C TESTLANGUAGE
+#endif
+
+#ifndef TESTLANGUAGE_CXX
+#define TESTLANGUAGE_CXX TESTLANGUAGE
+#endif
----------------
Sirraide wrote:

```suggestion
#ifndef TESTLANGUAGE
#  define TESTLANGUAGE(...)
#endif

#ifndef TESTLANGUAGE_C
#  define TESTLANGUAGE_C(...) TESTLANGUAGE(__VA_ARGS__)
#endif

#ifndef TESTLANGUAGE_CXX
#  define TESTLANGUAGE_CXX(...) TESTLANGUAGE(__VA_ARGS__)
#endif
```

This would be more consistent with what we do elsewhere (e.g. `StmtNodes.inc`) and would make using this easier since you can now just define the one you care about instead of having to potentially define all three of them.

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


More information about the cfe-commits mailing list