summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2018-09-27 14:50:24 +0000
committerEric Liu <ioeric@google.com>2018-09-27 14:50:24 +0000
commitbb898704e99cc7ea0890da36c99cd63d98e2df53 (patch)
tree2bb1e5e64c8427288684728b7e09fb20caf0054c
parentfd9f426049715a7a6f33194318a1e965a31f73de (diff)
downloadbcm5719-llvm-bb898704e99cc7ea0890da36c99cd63d98e2df53.tar.gz
bcm5719-llvm-bb898704e99cc7ea0890da36c99cd63d98e2df53.zip
[Tooling] Get rid of uses of llvm::Twine::str which is slow. NFC
llvm-svn: 343224
-rw-r--r--clang/lib/Tooling/Inclusions/HeaderIncludes.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
index 99c0866a685..21a72aa8e1e 100644
--- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -10,6 +10,7 @@
#include "clang/Tooling/Inclusions/HeaderIncludes.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
+#include "llvm/Support/FormatVariadic.h"
namespace clang {
namespace tooling {
@@ -181,7 +182,7 @@ bool IncludeCategoryManager::isMainHeader(StringRef IncludeName) const {
llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
if (FileStem.startswith(HeaderStem) ||
FileStem.startswith_lower(HeaderStem)) {
- llvm::Regex MainIncludeRegex((HeaderStem + Style.IncludeIsMainRegex).str(),
+ llvm::Regex MainIncludeRegex(HeaderStem.str() + Style.IncludeIsMainRegex,
llvm::Regex::IgnoreCase);
if (MainIncludeRegex.match(FileStem))
return true;
@@ -275,8 +276,8 @@ HeaderIncludes::insert(llvm::StringRef IncludeName, bool IsAngled) const {
if ((IsAngled && StringRef(Inc.Name).startswith("<")) ||
(!IsAngled && StringRef(Inc.Name).startswith("\"")))
return llvm::None;
- std::string Quoted = IsAngled ? ("<" + IncludeName + ">").str()
- : ("\"" + IncludeName + "\"").str();
+ std::string Quoted =
+ llvm::formatv(IsAngled ? "<{0}>" : "\"{0}\"", IncludeName);
StringRef QuotedName = Quoted;
int Priority = Categories.getIncludePriority(
QuotedName, /*CheckMainHeader=*/FirstIncludeOffset < 0);
@@ -293,7 +294,7 @@ HeaderIncludes::insert(llvm::StringRef IncludeName, bool IsAngled) const {
}
}
assert(InsertOffset <= Code.size());
- std::string NewInclude = ("#include " + QuotedName + "\n").str();
+ std::string NewInclude = llvm::formatv("#include {0}\n", QuotedName);
// When inserting headers at end of the code, also append '\n' to the code
// if it does not end with '\n'.
// FIXME: when inserting multiple #includes at the end of code, only one
OpenPOWER on IntegriCloud