私は、clang 8.0.1 でリフレクション ツールに取り組んでいます。そして今、すべての名前を完全修飾して Expr を出力する必要があります。
FullyQualifiedName ビットを true に設定して、組み込みの prettyPrint 関数を既に試しました。しかし、それでも間違った結果が得られます。
このコードの場合:
namespace math {
struct Transform {
float val;
[[custom_attr(&Transform::public_val)]]
void foo();
};
}
それは私に与えます
&Transform::public_val
それ以外の
&math::Transform::public_val
そして、
static_cast<float (*)(const Transform&)>(Transform::static_overload)
custom_attr の値として、それは私に与えます
static_cast<float (*)(const math::Transform &)>(Transform::static_overload)
(のみTransform::static_over
)
印刷用の私のコードは次のとおりです。
std::string get_string(const Expr *expr, const ASTContext &Context) {
PrintingPolicy print_policy(Context.getLangOpts());
print_policy.FullyQualifiedName = 1;
print_policy.SuppressScope = 0;
print_policy.SuppressUnwrittenScope = 0;
std::string expr_string;
llvm::raw_string_ostream stream(expr_string);
expr->printPretty(stream, nullptr, print_policy);
stream.flush();
return expr_string;
}