forked from qt-creator/qt-creator
Clang: Fix template renaming
Change-Id: I8040fe8dfc99d66e242ce2ff8589aa914838bfc9 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -59,17 +59,15 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool shouldVisitImplicitCode() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VisitNamedDecl(const clang::NamedDecl *declaration)
|
||||
{
|
||||
auto name = declaration->getNameAsString();
|
||||
|
||||
return setResultIfCursorIsInBetween(declaration, declaration->getLocation(),
|
||||
declaration->getNameAsString().length());
|
||||
bool notFound = setResultIfCursorIsInBetween(declaration,
|
||||
declaration->getLocation(),
|
||||
declaration->getNameAsString().length());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VisitDeclRefExpr(const clang::DeclRefExpr *expression)
|
||||
@@ -77,16 +75,18 @@ public:
|
||||
if (!iterateNestedNameSpecifierLocation(expression->getQualifierLoc()))
|
||||
return false;
|
||||
|
||||
const auto *Decl = expression->getFoundDecl();
|
||||
return setResultIfCursorIsInBetween(Decl, expression->getLocation(),
|
||||
Decl->getNameAsString().length());
|
||||
const auto *declaration = expression->getFoundDecl();
|
||||
return setResultIfCursorIsInBetween(declaration,
|
||||
expression->getLocation(),
|
||||
declaration->getNameAsString().length());
|
||||
}
|
||||
|
||||
bool VisitMemberExpr(const clang::MemberExpr *Expr)
|
||||
bool VisitMemberExpr(const clang::MemberExpr *expression)
|
||||
{
|
||||
const auto *Decl = Expr->getFoundDecl().getDecl();
|
||||
return setResultIfCursorIsInBetween(Decl, Expr->getMemberLoc(),
|
||||
Decl->getNameAsString().length());
|
||||
const auto *declaration = expression->getFoundDecl().getDecl();
|
||||
return setResultIfCursorIsInBetween(declaration,
|
||||
expression->getMemberLoc(),
|
||||
declaration->getNameAsString().length());
|
||||
}
|
||||
|
||||
std::vector<const clang::NamedDecl*> takeNamedDecl()
|
||||
@@ -156,7 +156,8 @@ private:
|
||||
|
||||
std::vector<const clang::NamedDecl*> namedDeclarations;
|
||||
const clang::SourceManager &sourceManager;
|
||||
const clang::SourceLocation cursorSourceLocation; // The location to find the NamedDecl.
|
||||
const clang::SourceLocation cursorSourceLocation;
|
||||
bool isTemplate = false;
|
||||
};
|
||||
|
||||
inline
|
||||
|
||||
@@ -49,10 +49,9 @@ namespace ClangBackEnd {
|
||||
class FindLocationsOfUSRsASTVisitor : public clang::RecursiveASTVisitor<FindLocationsOfUSRsASTVisitor>
|
||||
{
|
||||
public:
|
||||
explicit FindLocationsOfUSRsASTVisitor(std::vector<USRName> &unifiedSymbolResolutions)
|
||||
explicit FindLocationsOfUSRsASTVisitor(const std::vector<USRName> &unifiedSymbolResolutions)
|
||||
: unifiedSymbolResolutions(unifiedSymbolResolutions)
|
||||
{
|
||||
std::sort(unifiedSymbolResolutions.begin(), unifiedSymbolResolutions.end());
|
||||
}
|
||||
|
||||
bool VisitNamedDecl(const clang::NamedDecl *declaration) {
|
||||
@@ -108,15 +107,17 @@ private:
|
||||
|
||||
bool containsUSR(const USRName &unifiedSymbolResolution)
|
||||
{
|
||||
return std::binary_search(unifiedSymbolResolutions.cbegin(),
|
||||
unifiedSymbolResolutions.cend(),
|
||||
unifiedSymbolResolution);
|
||||
auto found = std::find(unifiedSymbolResolutions.cbegin(),
|
||||
unifiedSymbolResolutions.cend(),
|
||||
unifiedSymbolResolution);
|
||||
|
||||
return found != unifiedSymbolResolutions.cend();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// All the locations of the USR were found.
|
||||
std::vector<USRName> unifiedSymbolResolutions;
|
||||
const std::vector<USRName> unifiedSymbolResolutions;
|
||||
std::vector<clang::SourceLocation> foundLocations;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user