|
29 | 29 | #include "llvm/Support/Endian.h" |
30 | 30 | #include "llvm/Support/ErrorHandling.h" |
31 | 31 | #include "llvm/Support/FileSystem.h" |
32 | | -#include "llvm/Support/FormatVariadic.h" |
33 | 32 | #include "llvm/Support/MathExtras.h" |
34 | 33 | #include "llvm/Support/MemoryBuffer.h" |
35 | 34 | #include "llvm/Support/Path.h" |
@@ -2228,28 +2227,6 @@ LLVM_DUMP_METHOD void SourceManager::dump() const { |
2228 | 2227 | } |
2229 | 2228 | } |
2230 | 2229 |
|
2231 | | -// 123 -> "123". |
2232 | | -// 1234 -> "1.23k". |
2233 | | -// 123456 -> "123.46k". |
2234 | | -// 1234567 -> "1.23M". |
2235 | | -// 1234567890 -> "1.23G". |
2236 | | -// 1234567890123 -> "1.23T". |
2237 | | -static std::string humanizeNumber(uint64_t Number) { |
2238 | | - static constexpr std::array<std::pair<uint64_t, char>, 4> Units = { |
2239 | | - {{1'000'000'000'000UL, 'T'}, |
2240 | | - {1'000'000'000UL, 'G'}, |
2241 | | - {1'000'000UL, 'M'}, |
2242 | | - {1'000UL, 'k'}}}; |
2243 | | - |
2244 | | - for (const auto &[UnitSize, UnitSign] : Units) { |
2245 | | - if (Number >= UnitSize) { |
2246 | | - return llvm::formatv("{0:F}{1}", Number / static_cast<double>(UnitSize), |
2247 | | - UnitSign); |
2248 | | - } |
2249 | | - } |
2250 | | - return std::to_string(Number); |
2251 | | -} |
2252 | | - |
2253 | 2230 | void SourceManager::noteSLocAddressSpaceUsage( |
2254 | 2231 | DiagnosticsEngine &Diag, std::optional<unsigned> MaxNotes) const { |
2255 | 2232 | struct Info { |
@@ -2319,27 +2296,23 @@ void SourceManager::noteSLocAddressSpaceUsage( |
2319 | 2296 | int UsagePercent = static_cast<int>(100.0 * double(LocalUsage + LoadedUsage) / |
2320 | 2297 | MaxLoadedOffset); |
2321 | 2298 | Diag.Report(SourceLocation(), diag::note_total_sloc_usage) |
2322 | | - << LocalUsage << humanizeNumber(LocalUsage) << LoadedUsage |
2323 | | - << humanizeNumber(LoadedUsage) << (LocalUsage + LoadedUsage) |
2324 | | - << humanizeNumber(LocalUsage + LoadedUsage) << UsagePercent; |
| 2299 | + << LocalUsage << LoadedUsage << (LocalUsage + LoadedUsage) |
| 2300 | + << UsagePercent; |
2325 | 2301 |
|
2326 | 2302 | // Produce notes on sloc address space usage for each file with a high usage. |
2327 | 2303 | uint64_t ReportedSize = 0; |
2328 | 2304 | for (auto &[Entry, FileInfo] : |
2329 | 2305 | llvm::make_range(SortedUsage.begin(), SortedEnd)) { |
2330 | 2306 | Diag.Report(FileInfo.Loc, diag::note_file_sloc_usage) |
2331 | 2307 | << FileInfo.Inclusions << FileInfo.DirectSize |
2332 | | - << humanizeNumber(FileInfo.DirectSize) |
2333 | | - << (FileInfo.TotalSize - FileInfo.DirectSize) |
2334 | | - << humanizeNumber(FileInfo.TotalSize - FileInfo.DirectSize); |
| 2308 | + << (FileInfo.TotalSize - FileInfo.DirectSize); |
2335 | 2309 | ReportedSize += FileInfo.TotalSize; |
2336 | 2310 | } |
2337 | 2311 |
|
2338 | 2312 | // Describe any remaining usage not reported in the per-file usage. |
2339 | 2313 | if (ReportedSize != CountedSize) { |
2340 | 2314 | Diag.Report(SourceLocation(), diag::note_file_misc_sloc_usage) |
2341 | | - << (SortedUsage.end() - SortedEnd) << CountedSize - ReportedSize |
2342 | | - << humanizeNumber(CountedSize - ReportedSize); |
| 2315 | + << (SortedUsage.end() - SortedEnd) << CountedSize - ReportedSize; |
2343 | 2316 | } |
2344 | 2317 | } |
2345 | 2318 |
|
|
0 commit comments