diff options
Diffstat (limited to 'clang-tools-extra/clang-rename/USRLocFinder.cpp')
| -rw-r--r-- | clang-tools-extra/clang-rename/USRLocFinder.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/clang-tools-extra/clang-rename/USRLocFinder.cpp b/clang-tools-extra/clang-rename/USRLocFinder.cpp index be110f15276..2a8804d3e63 100644 --- a/clang-tools-extra/clang-rename/USRLocFinder.cpp +++ b/clang-tools-extra/clang-rename/USRLocFinder.cpp @@ -124,20 +124,11 @@ public: } bool VisitCXXStaticCastExpr(clang::CXXStaticCastExpr *Expr) { - clang::QualType Type = Expr->getType(); - // See if this a cast of a pointer. - const RecordDecl* Decl = Type->getPointeeCXXRecordDecl(); - if (!Decl) { - // See if this is a cast of a reference. - Decl = Type->getAsCXXRecordDecl(); - } - - if (Decl && getUSRForDecl(Decl) == USR) { - SourceLocation Location = Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc(); - LocationsFound.push_back(Location); - } + return handleCXXNamedCastExpr(Expr); + } - return true; + bool VisitCXXDynamicCastExpr(clang::CXXDynamicCastExpr *Expr) { + return handleCXXNamedCastExpr(Expr); } // Non-visitors: @@ -159,6 +150,23 @@ private: } } + bool handleCXXNamedCastExpr(clang::CXXNamedCastExpr *Expr) { + clang::QualType Type = Expr->getType(); + // See if this a cast of a pointer. + const RecordDecl* Decl = Type->getPointeeCXXRecordDecl(); + if (!Decl) { + // See if this is a cast of a reference. + Decl = Type->getAsCXXRecordDecl(); + } + + if (Decl && getUSRForDecl(Decl) == USR) { + SourceLocation Location = Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc(); + LocationsFound.push_back(Location); + } + + return true; + } + // All the locations of the USR were found. const std::string USR; // Old name that is renamed. |

