summaryrefslogtreecommitdiff
path: root/clang/lib/Tooling/Core/Lookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Tooling/Core/Lookup.cpp')
-rw-r--r--clang/lib/Tooling/Core/Lookup.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Tooling/Core/Lookup.cpp b/clang/lib/Tooling/Core/Lookup.cpp
index 735a5df5ed21e..712724a268fb2 100644
--- a/clang/lib/Tooling/Core/Lookup.cpp
+++ b/clang/lib/Tooling/Core/Lookup.cpp
@@ -11,10 +11,12 @@
//===----------------------------------------------------------------------===//
#include "clang/Tooling/Core/Lookup.h"
+#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclarationName.h"
#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/SmallVector.h"
using namespace clang;
using namespace clang::tooling;
@@ -129,7 +131,7 @@ static std::string disambiguateSpellingInScope(StringRef Spelling,
assert(QName.startswith("::"));
assert(QName.endswith(Spelling));
if (Spelling.startswith("::"))
- return Spelling;
+ return std::string(Spelling);
auto UnspelledSpecifier = QName.drop_back(Spelling.size());
llvm::SmallVector<llvm::StringRef, 2> UnspelledScopes;
@@ -168,7 +170,7 @@ static std::string disambiguateSpellingInScope(StringRef Spelling,
};
// Add more qualifiers until the spelling is not ambiguous.
- std::string Disambiguated = Spelling;
+ std::string Disambiguated = std::string(Spelling);
while (IsAmbiguousSpelling(Disambiguated)) {
if (UnspelledScopes.empty()) {
Disambiguated = "::" + Disambiguated;
@@ -206,8 +208,9 @@ std::string tooling::replaceNestedName(const NestedNameSpecifier *Use,
!usingFromDifferentCanonicalNamespace(FromDecl->getDeclContext(),
UseContext)) {
auto Pos = ReplacementString.rfind("::");
- return Pos != StringRef::npos ? ReplacementString.substr(Pos + 2)
- : ReplacementString;
+ return std::string(Pos != StringRef::npos
+ ? ReplacementString.substr(Pos + 2)
+ : ReplacementString);
}
// We did not match this because of a using statement, so we will need to
// figure out how good a namespace match we have with our destination type.