[interop] Pass template names and named constants as template arguments - #62
[interop] Pass template names and named constants as template arguments#62conrade-ctc wants to merge 2 commits into
Conversation
1e9aef5 to
5d9ceb7
Compare
is_integral rejects a leading minus, so the comma-split fallback in AppendTypesSlow reads a negative literal as a type name. Accept the sign. Co-developed-with-the-help-of: Claude Code (Opus 5, human in the loop)
A class or alias template name becomes a template-template argument. The argument carries the name and a null type. A constexpr variable or an enum constant goes through as its qualified name, so Sema builds an expression. true and false become bool values. The by-name paths need a CppInterOp that resolves the name. An older one reads the name as an integer literal and instantiates a garbage value. Probe for CppInterOp's SupportsNamedTemplateArguments export, and skip the test when it is absent. Co-developed-with-the-help-of: Claude Code (Fable 5, human in the loop)
5d9ceb7 to
155b722
Compare
| #else | ||
| static const bool Supported = [] { | ||
| // CppInterOp is dlopen'ed RTLD_LOCAL; its exports need its own handle. | ||
| void* handle = dlopen(cppinterop_paths().Library.c_str(), |
There was a problem hiding this comment.
This seems a weird way to check if a feature is there or not. Can’t we rely on the version hash, for example?
There was a problem hiding this comment.
The probe guards a window, not a permanent difference. cppjit pins CppInterOp by commit sha. The current pin (9802d619) predates #1074, so Cpp::GetNamed does not resolve a named constant yet. Without the guard, the by-name tests fail on the pinned build.
I looked at the version hash. Cpp::GetVersion() reads the VERSION file, which is the same before and after #1074. Cpp::GetBuildInfo() has no git sha, and a sha has no order, so a check cannot express "at least this commit".
So I think the pin is already the version check. My proposal: drop the probe and hold this PR until #1074 merges. Then I rebase, move the pin to a commit that carries #1074, and the by-name tests run unconditionally. This matches #63, which waited on #1101 the same way. The removal is ready locally.
Tell me if you prefer a different order.
A template argument can now name a template or a constant. A class or alias template name becomes a template-template argument. A constexpr variable or an enum constant becomes an expression, so Sema reads its value.
trueandfalsebecome bool values. The first commit fixes a separate bug:is_integralrejected a leading minus, so a negative literal became a type name.The by-name paths need CppInterOp compiler-research/CppInterOp#1074, which resolves the name. Before this merges, the CppInterOp pin moves to the commit that carries #1074 and the capability probe goes away. Do not merge this before #1074.