#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Mutex.h"
}
Optional<StringRef> Redirects[] = {StringRef(InputFile),
- StringRef(OutputFile), llvm::None};
+ StringRef(OutputFile), ""};
StringRef Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining",
#ifdef _WIN32
// Pass --relative-address on Windows so that we don't
auto CurLine = Lines.begin();
int frame_no = 0;
for (int i = 0; i < Depth; i++) {
+ auto PrintLineHeader = [&]() {
+ OS << right_justify(formatv("#{0}", frame_no++).str(),
+ std::log10(Depth) + 2)
+ << ' ' << format_ptr(StackTrace[i]) << ' ';
+ };
if (!Modules[i]) {
- OS << '#' << frame_no++ << ' ' << format_ptr(StackTrace[i]) << '\n';
+ PrintLineHeader();
+ OS << '\n';
continue;
}
// Read pairs of lines (function name and file/line info) until we
StringRef FunctionName = *CurLine++;
if (FunctionName.empty())
break;
- OS << '#' << frame_no++ << ' ' << format_ptr(StackTrace[i]) << ' ';
+ PrintLineHeader();
if (!FunctionName.startswith("??"))
OS << FunctionName << ' ';
if (CurLine == Lines.end())