diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-06-11 13:19:00 +0100 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-06-11 13:19:15 +0100 |
commit | 61cdaf66fe22be2b5942ddee4f46a998b4f3ee29 (patch) | |
tree | 00d463a996cfb65a001a6995c154f7071fe8617e /clang/lib/Sema/SemaInit.cpp | |
parent | 71a02ddda10583b7f51611e8aefcbecc47352683 (diff) | |
download | llvm-61cdaf66fe22be2b5942ddee4f46a998b4f3ee29.zip llvm-61cdaf66fe22be2b5942ddee4f46a998b4f3ee29.tar.gz llvm-61cdaf66fe22be2b5942ddee4f46a998b4f3ee29.tar.bz2 |
[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
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 26d681b..f916299 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2873,7 +2873,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, if (!VerifyOnly) SemaRef.Diag(IndexExpr->getBeginLoc(), diag::err_array_designator_too_large) - << DesignatedEndIndex.toString(10) << MaxElements.toString(10) + << toString(DesignatedEndIndex, 10) << toString(MaxElements, 10) << IndexExpr->getSourceRange(); ++Index; return true; @@ -3167,7 +3167,7 @@ CheckArrayDesignatorExpr(Sema &S, Expr *Index, llvm::APSInt &Value) { if (Value.isSigned() && Value.isNegative()) return S.Diag(Loc, diag::err_array_designator_negative) - << Value.toString(10) << Index->getSourceRange(); + << toString(Value, 10) << Index->getSourceRange(); Value.setIsUnsigned(true); return Result; @@ -3236,7 +3236,7 @@ ExprResult Sema::ActOnDesignatedInitializer(Designation &Desig, if (!StartDependent && !EndDependent && EndValue < StartValue) { Diag(D.getEllipsisLoc(), diag::err_array_designator_empty_range) - << StartValue.toString(10) << EndValue.toString(10) + << toString(StartValue, 10) << toString(EndValue, 10) << StartIndex->getSourceRange() << EndIndex->getSourceRange(); Invalid = true; } else { |