mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 13:14:55 +00:00
tbv2: fix thrift isset with ClangTypeParser
Some of the logic that makes Thrift isset work for TreeBuilder-v2 in DrgnParser (JIT OIL) wasn't ported to ClangTypeParser meaning it doesn't work in Ahead-of-Time (AoT) OIL. Add the template parameter name reconstruction for enum values to ClangTypeParser. Test plan: - Tested with Thrift isset enabled on an internal type. Doesn't build before, does build after.
This commit is contained in:
parent
40af807d8b
commit
d47fae19d0
@ -235,9 +235,29 @@ std::optional<TemplateParam> ClangTypeParser::enumerateTemplateParam(
|
||||
}
|
||||
case clang::TemplateArgument::Integral: {
|
||||
auto& ty = enumerateType(*p.getIntegralType());
|
||||
llvm::SmallString<32> val;
|
||||
p.getAsIntegral().toString(val);
|
||||
return TemplateParam{ty, std::string(val)};
|
||||
|
||||
std::string value;
|
||||
if (const auto* e = dynamic_cast<const Enum*>(&ty)) {
|
||||
const auto& eTy =
|
||||
llvm::cast<const clang::EnumType>(*p.getIntegralType());
|
||||
for (const auto* enumerator : eTy.getDecl()->enumerators()) {
|
||||
if (enumerator->getInitVal() == p.getAsIntegral()) {
|
||||
value = e->inputName();
|
||||
value += "::";
|
||||
value += enumerator->getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (value.empty()) {
|
||||
throw std::runtime_error("unable to find enum name for value");
|
||||
}
|
||||
} else {
|
||||
llvm::SmallString<32> val;
|
||||
p.getAsIntegral().toString(val);
|
||||
value = std::string{val};
|
||||
}
|
||||
|
||||
return TemplateParam{ty, value};
|
||||
}
|
||||
case clang::TemplateArgument::Template: {
|
||||
return enumerateTemplateTemplateParam(p.getAsTemplate());
|
||||
|
Loading…
Reference in New Issue
Block a user