[all-commits] [llvm/llvm-project] 61cdaf: [ADT] Remove APInt/APSInt toString() std::string v...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Fri Jun 11 05:20:25 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 61cdaf66fe22be2b5942ddee4f46a998b4f3ee29
      https://github.com/llvm/llvm-project/commit/61cdaf66fe22be2b5942ddee4f46a998b4f3ee29
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
    M clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
    M clang-tools-extra/clangd/DumpAST.cpp
    M clang-tools-extra/clangd/Hover.cpp
    M clang/include/clang/ASTMatchers/ASTMatchers.h
    M clang/lib/AST/ASTDiagnostic.cpp
    M clang/lib/AST/ASTStructuralEquivalence.cpp
    M clang/lib/AST/ExprConstant.cpp
    M clang/lib/AST/StmtPrinter.cpp
    M clang/lib/AST/TemplateBase.cpp
    M clang/lib/AST/TextNodeDumper.cpp
    M clang/lib/Analysis/ThreadSafetyCommon.cpp
    M clang/lib/CodeGen/CGBuiltin.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/lib/Frontend/InitPreprocessor.cpp
    M clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
    M clang/lib/Lex/PPExpressions.cpp
    M clang/lib/Sema/SemaCast.cpp
    M clang/lib/Sema/SemaChecking.cpp
    M clang/lib/Sema/SemaConcept.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaExprCXX.cpp
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Sema/SemaOpenMP.cpp
    M clang/lib/Sema/SemaStmt.cpp
    M clang/lib/Sema/SemaStmtAsm.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
    M clang/unittests/StaticAnalyzer/RangeSetTest.cpp
    M clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp
    M clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCommon.h
    M llvm/include/llvm/ADT/APInt.h
    M llvm/include/llvm/ADT/APSInt.h
    M llvm/include/llvm/ADT/StringExtras.h
    M llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
    M llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    M llvm/lib/Support/APInt.cpp
    M llvm/lib/Target/X86/X86MCInstLower.cpp
    M llvm/lib/Transforms/IPO/OpenMPOpt.cpp
    M llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
    M llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
    M llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
    M llvm/unittests/ADT/APIntTest.cpp
    M llvm/unittests/ADT/StringExtrasTest.cpp

  Log Message:
  -----------
  [ADT] Remove APInt/APSInt toString() std::string variants

<string> 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 <string> 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




More information about the All-commits mailing list