diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /clang/lib/Tooling/Core/Lookup.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'clang/lib/Tooling/Core/Lookup.cpp')
-rw-r--r-- | clang/lib/Tooling/Core/Lookup.cpp | 11 |
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. |