================ @@ -267,92 +267,156 @@ std::string Interpreter::ValueDataToString(const Value &V) const { return "{ error: unknown builtin type '" + std::to_string(BT->getKind()) + " '}"; case clang::BuiltinType::Bool: - SS << ((V.getBool()) ? "true" : "false"); - return Str; - case clang::BuiltinType::Char_S: - SS << '\'' << V.getChar_S() << '\''; - return Str; - case clang::BuiltinType::SChar: - SS << '\'' << V.getSChar() << '\''; - return Str; - case clang::BuiltinType::Char_U: - SS << '\'' << V.getChar_U() << '\''; - return Str; - case clang::BuiltinType::UChar: - SS << '\'' << V.getUChar() << '\''; + SS << ((B.as<bool>()) ? "true" : "false"); return Str; case clang::BuiltinType::Short: - SS << V.getShort(); + SS << B.as<short>(); ---------------- SahilPatidar wrote:
Since I’m not using our existing `Value`, I introduced a universal buffer for built-in types (including strings). ```cpp class BuiltinValueBuffer : public ValueBuffer { public: std::vector<uint8_t> raw; BuiltinValueBuffer(QualType _Ty) : ValueBuffer(K_Builtin) { Ty = _Ty; } template <typename T> T as() const { T v{}; // Ensure the buffer is large enough for the requested type. memcpy(&v, raw.data(), sizeof(T)); return v; } static bool classof(const ValueBuffer *B) { return B->isBuiltin(); } }; ``` I use `ValueBuffer` to read memory directly into a buffer sized for the type, and at print time we cast the raw data back to the correct type. If we use a `Value`-kind structure, we need to read memory, cast it, and set the value at read time. https://github.com/llvm/llvm-project/pull/156649 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits