[Lldb-commits] [clang] [lldb] [lldb] Re-use clang's keyword enable/disable mechanism in CPlusPlusNameParser.cpp (PR #164284)
Daniel Sanders via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 20 11:23:14 PDT 2025
================
@@ -46,6 +46,59 @@ class LangOptions;
class MultiKeywordSelector;
class SourceLocation;
+// This is an inline namespace to allow both clang and lldb to use them without
+// namespace prefixes (via `using namespace` in lldb's case).
+inline namespace TokenKeyEnumerators {
----------------
dsandersllvm wrote:
I don't mind splitting it but that PR won't make sense without the context of this PR
The reason we need the `inline namespace` is because of this code:
```
#define KEYWORD(NAME, FLAGS) \
AddResult = getKeywordStatus(LangOpts, FLAGS); \
...
#include "clang/Basic/TokenKinds.def"
```
I can't reference `FLAGS` as `clang::FLAGS` because some of the `KEYWORD()` declaration's in TokenKinds.def are the `|` of multiple values such as `BOOLSUPPORT|KEYC23` and I'd need the namespace to appear on each identifier. `enum class` is ruled out for the same reason, and `enum class` combined with `using enum ...` requires C++20 and therefore can't be used.
`inline namespace` allows lldb to import them with `using namespace ...` for use as bare names without changing how clang uses them
https://github.com/llvm/llvm-project/pull/164284
More information about the lldb-commits
mailing list