summaryrefslogtreecommitdiff
path: root/lib/Tooling/Inclusions/HeaderIncludes.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
commit676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch)
tree02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /lib/Tooling/Inclusions/HeaderIncludes.cpp
parentc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff)
Diffstat (limited to 'lib/Tooling/Inclusions/HeaderIncludes.cpp')
-rw-r--r--lib/Tooling/Inclusions/HeaderIncludes.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Tooling/Inclusions/HeaderIncludes.cpp b/lib/Tooling/Inclusions/HeaderIncludes.cpp
index 99c0866a68555..c74ad0b9cd569 100644
--- a/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ b/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 {
@@ -23,8 +24,7 @@ LangOptions createLangOpts() {
LangOpts.LineComment = 1;
LangOpts.CXXOperatorNames = 1;
LangOpts.Bool = 1;
- LangOpts.ObjC1 = 1;
- LangOpts.ObjC2 = 1;
+ LangOpts.ObjC = 1;
LangOpts.MicrosoftExt = 1; // To get kw___try, kw___finally.
LangOpts.DeclSpecKeyword = 1; // To get __declspec.
LangOpts.WChar = 1; // To get wchar_t
@@ -181,7 +181,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 +275,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 +293,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