This patch is the third part of the below RFC:
https://discourse.llvm.org/t/rfc-handle-execution-results-in-clang-repl/68493
- It implements Value::dump to enable pretty printing. For example:
clang-repl> int x = 42;
clang-repl> x
(int) 42
It also works for STL facilities:
clang-repl> #include <vector>
clang-repl> std::vector<int> v{1,2,3};
clang-repl> v
(std::vector<int> &) { 1, 2, 3 }
- Users can also provide their own pretty printers by writing an
overload of PrintValueRuntime(T*). For example:
clang-repl> struct S{};
clang-repl> std::string PrintValueRuntime(S* s) { return "My printer!"; }
clang-repl> S{}
clang-repl> (S) My printer!
Signed-off-by: Jun Zhang <jun@junz.org>
We should move this routine to its user in maybe ValuePrinter.cpp.