<div dir="ltr">Hi Miklos,<br><br>This revision broke tests on one of builders:<br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/14332">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/14332</a><br><br>Please have a look at this?<br><br>Thanks<br><br>Galina<br><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 8, 2016 at 11:38 AM, Miklos Vajna via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: vmiklos<br>
Date: Wed Jun 8 13:38:23 2016<br>
New Revision: 272188<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=272188&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=272188&view=rev</a><br>
Log:<br>
clang-rename: implement renaming of classes inside dynamic_cast<br>
<br>
Refactor to do the same as what is done already for static_cast.<br>
<br>
Reviewers: klimek<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D21120" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21120</a><br>
<br>
Added:<br>
clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp<br>
Modified:<br>
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp<br>
<br>
Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=272188&r1=272187&r2=272188&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=272188&r1=272187&r2=272188&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)<br>
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Wed Jun 8 13:38:23 2016<br>
@@ -124,20 +124,11 @@ public:<br>
}<br>
<br>
bool VisitCXXStaticCastExpr(clang::CXXStaticCastExpr *Expr) {<br>
- clang::QualType Type = Expr->getType();<br>
- // See if this a cast of a pointer.<br>
- const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();<br>
- if (!Decl) {<br>
- // See if this is a cast of a reference.<br>
- Decl = Type->getAsCXXRecordDecl();<br>
- }<br>
-<br>
- if (Decl && getUSRForDecl(Decl) == USR) {<br>
- SourceLocation Location = Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();<br>
- LocationsFound.push_back(Location);<br>
- }<br>
+ return handleCXXNamedCastExpr(Expr);<br>
+ }<br>
<br>
- return true;<br>
+ bool VisitCXXDynamicCastExpr(clang::CXXDynamicCastExpr *Expr) {<br>
+ return handleCXXNamedCastExpr(Expr);<br>
}<br>
<br>
// Non-visitors:<br>
@@ -159,6 +150,23 @@ private:<br>
}<br>
}<br>
<br>
+ bool handleCXXNamedCastExpr(clang::CXXNamedCastExpr *Expr) {<br>
+ clang::QualType Type = Expr->getType();<br>
+ // See if this a cast of a pointer.<br>
+ const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();<br>
+ if (!Decl) {<br>
+ // See if this is a cast of a reference.<br>
+ Decl = Type->getAsCXXRecordDecl();<br>
+ }<br>
+<br>
+ if (Decl && getUSRForDecl(Decl) == USR) {<br>
+ SourceLocation Location = Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();<br>
+ LocationsFound.push_back(Location);<br>
+ }<br>
+<br>
+ return true;<br>
+ }<br>
+<br>
// All the locations of the USR were found.<br>
const std::string USR;<br>
// Old name that is renamed.<br>
<br>
Added: clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp?rev=272188&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp?rev=272188&view=auto</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp (added)<br>
+++ clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp Wed Jun 8 13:38:23 2016<br>
@@ -0,0 +1,25 @@<br>
+// RUN: cat %s > %t.cpp<br>
+// RUN: clang-rename -offset=186 -new-name=X %t.cpp -i --<br>
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s<br>
+class Base {<br>
+ virtual int getValue() const = 0;<br>
+};<br>
+<br>
+class Derived : public Base {<br>
+public:<br>
+ int getValue() const {<br>
+ return 0;<br>
+ }<br>
+};<br>
+<br>
+int main() {<br>
+ Derived D;<br>
+ const Base &Reference = D;<br>
+ const Base *Pointer = &D;<br>
+<br>
+ dynamic_cast<const Derived &>(Reference).getValue(); // CHECK: dynamic_cast<const X &><br>
+ dynamic_cast<const Derived *>(Pointer)->getValue(); // CHECK: dynamic_cast<const X *><br>
+}<br>
+<br>
+// Use grep -FUbo 'Derived' <file> to get the correct offset of foo when changing<br>
+// this file.<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>