This revision was automatically updated to reflect the committed changes. Closed by commit rL373440: [clang-rename] Better renaming the typedef decl. (authored by hokein, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D68322?vs=222765&id=222783#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D68322/new/ https://reviews.llvm.org/D68322 Files: cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h cfe/trunk/test/clang-rename/Typedef.cpp Index: cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h =================================================================== --- cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h +++ cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h @@ -98,7 +98,17 @@ TypeBeginLoc, TypeEndLoc)) return false; } - return visit(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc, TypeEndLoc); + if (const Type *TP = Loc.getTypePtr()) { + if (TP->getTypeClass() == clang::Type::Record) + return visit(TP->getAsCXXRecordDecl(), TypeBeginLoc, TypeEndLoc); + } + return true; + } + + bool VisitTypedefTypeLoc(TypedefTypeLoc TL) { + const SourceLocation TypeEndLoc = + Lexer::getLocForEndOfToken(TL.getBeginLoc(), 0, SM, LangOpts); + return visit(TL.getTypedefNameDecl(), TL.getBeginLoc(), TypeEndLoc); } bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) { Index: cfe/trunk/test/clang-rename/Typedef.cpp =================================================================== --- cfe/trunk/test/clang-rename/Typedef.cpp +++ cfe/trunk/test/clang-rename/Typedef.cpp @@ -0,0 +1,8 @@ +namespace std { +class basic_string {}; +typedef basic_string string; +} // namespace std + +std::string foo(); // // CHECK: std::new_string foo(); + +// RUN: clang-rename -offset=93 -new-name=new_string %s -- | sed 's,//.*,,' | FileCheck %s
Index: cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h =================================================================== --- cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h +++ cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h @@ -98,7 +98,17 @@ TypeBeginLoc, TypeEndLoc)) return false; } - return visit(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc, TypeEndLoc); + if (const Type *TP = Loc.getTypePtr()) { + if (TP->getTypeClass() == clang::Type::Record) + return visit(TP->getAsCXXRecordDecl(), TypeBeginLoc, TypeEndLoc); + } + return true; + } + + bool VisitTypedefTypeLoc(TypedefTypeLoc TL) { + const SourceLocation TypeEndLoc = + Lexer::getLocForEndOfToken(TL.getBeginLoc(), 0, SM, LangOpts); + return visit(TL.getTypedefNameDecl(), TL.getBeginLoc(), TypeEndLoc); } bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) { Index: cfe/trunk/test/clang-rename/Typedef.cpp =================================================================== --- cfe/trunk/test/clang-rename/Typedef.cpp +++ cfe/trunk/test/clang-rename/Typedef.cpp @@ -0,0 +1,8 @@ +namespace std { +class basic_string {}; +typedef basic_string string; +} // namespace std + +std::string foo(); // // CHECK: std::new_string foo(); + +// RUN: clang-rename -offset=93 -new-name=new_string %s -- | sed 's,//.*,,' | FileCheck %s
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits