[clang-tools-extra] r272188 - clang-rename: implement renaming of classes inside dynamic_cast

Galina Kistanova via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 9 10:15:27 PDT 2016


Hi Miklos,

This revision broke tests on one of builders:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/14332

Please have a look at this?

Thanks

Galina


On Wed, Jun 8, 2016 at 11:38 AM, Miklos Vajna via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: vmiklos
> Date: Wed Jun  8 13:38:23 2016
> New Revision: 272188
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272188&view=rev
> Log:
> clang-rename: implement renaming of classes inside dynamic_cast
>
> Refactor to do the same as what is done already for static_cast.
>
> Reviewers: klimek
>
> Differential Revision: http://reviews.llvm.org/D21120
>
> Added:
>     clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp
> Modified:
>     clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
>
> Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=272188&r1=272187&r2=272188&view=diff
>
> ==============================================================================
> --- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
> +++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Wed Jun  8
> 13:38:23 2016
> @@ -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.
>
> Added: clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp?rev=272188&view=auto
>
> ==============================================================================
> --- clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp (added)
> +++ clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp Wed Jun
> 8 13:38:23 2016
> @@ -0,0 +1,25 @@
> +// RUN: cat %s > %t.cpp
> +// RUN: clang-rename -offset=186 -new-name=X %t.cpp -i --
> +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
> +class Base {
> +  virtual int getValue() const = 0;
> +};
> +
> +class Derived : public Base {
> +public:
> +  int getValue() const {
> +    return 0;
> +  }
> +};
> +
> +int main() {
> +  Derived D;
> +  const Base &Reference = D;
> +  const Base *Pointer = &D;
> +
> +  dynamic_cast<const Derived &>(Reference).getValue(); // CHECK:
> dynamic_cast<const X &>
> +  dynamic_cast<const Derived *>(Pointer)->getValue();  // CHECK:
> dynamic_cast<const X *>
> +}
> +
> +// Use grep -FUbo 'Derived' <file> to get the correct offset of foo when
> changing
> +// this file.
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160609/2982d807/attachment.html>


More information about the cfe-commits mailing list