From 61cdaf66fe22be2b5942ddee4f46a998b4f3ee29 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Fri, 11 Jun 2021 13:19:00 +0100 Subject: [ADT] Remove APInt/APSInt toString() std::string variants is currently the highest impact header in a clang+llvm build: https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html One of the most common places this is being included is the APInt.h header, which needs it for an old toString() implementation that returns std::string - an inefficient method compared to the SmallString versions that it actually wraps. This patch replaces these APInt/APSInt methods with a pair of llvm::toString() helpers inside StringExtras.h, adjusts users accordingly and removes the from APInt.h - I was hoping that more of these users could be converted to use the SmallString methods, but it appears that most end up creating a std::string anyhow. I avoided trying to use the raw_ostream << operators as well as I didn't want to lose having the integer radix explicit in the code. Differential Revision: https://reviews.llvm.org/D103888 --- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 24f8998..5490444 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -4581,7 +4581,7 @@ std::string CompilerInvocation::getModuleHash() const { if (!SanHash.empty()) code = hash_combine(code, SanHash.Mask); - return llvm::APInt(64, code).toString(36, /*Signed=*/false); + return toString(llvm::APInt(64, code), 36, /*Signed=*/false); } void CompilerInvocation::generateCC1CommandLine( -- cgit v1.1