[clang-tools-extra] r272816 - clang-rename: implement renaming of classes with a dtor

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 15 16:12:00 PDT 2016


Should be fixed in r272852

--Artem

On Wed, Jun 15, 2016 at 3:16 PM, Artem Belevich <tra at google.com> wrote:

> Miklos,
>
> TokenName produces unused variable warning in builds with asserts disabled.
> Could you add LLVM_ATTRIBUTE_UNUSED to it?
>
> Thanks,
> --Artem
>
>
> On Wed, Jun 15, 2016 at 11:35 AM, Miklos Vajna via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: vmiklos
>> Date: Wed Jun 15 13:35:41 2016
>> New Revision: 272816
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=272816&view=rev
>> Log:
>> clang-rename: implement renaming of classes with a dtor
>>
>> The declaration wasn't renamed. Also neither part of the declaration
>> wasn't renamed.
>>
>> Reviewers: klimek
>>
>> Differential Revision: http://reviews.llvm.org/D21364
>>
>> Added:
>>     clang-tools-extra/trunk/test/clang-rename/DtorDefTest.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=272816&r1=272815&r2=272816&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
>> +++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Wed Jun 15
>> 13:35:41 2016
>> @@ -87,6 +87,28 @@ public:
>>      return true;
>>    }
>>
>> +  bool VisitCXXDestructorDecl(clang::CXXDestructorDecl *DestructorDecl) {
>> +    if (getUSRForDecl(DestructorDecl->getParent()) == USR) {
>> +      // Handles "~Foo" from "Foo::~Foo".
>> +      SourceLocation Location = DestructorDecl->getLocation();
>> +      const ASTContext &Context = DestructorDecl->getASTContext();
>> +      StringRef TokenName = Lexer::getSourceText(
>> +          CharSourceRange::getTokenRange(Location),
>> Context.getSourceManager(),
>> +          Context.getLangOpts());
>> +      // 1 is the length of the "~" string that is not to be touched by
>> the
>> +      // rename.
>> +      assert(TokenName.startswith("~"));
>> +      LocationsFound.push_back(Location.getLocWithOffset(1));
>> +
>> +      if (DestructorDecl->isThisDeclarationADefinition()) {
>> +        // Handles "Foo" from "Foo::~Foo".
>> +        LocationsFound.push_back(DestructorDecl->getLocStart());
>> +      }
>> +    }
>> +
>> +    return true;
>> +  }
>> +
>>    // Expression visitors:
>>
>>    bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
>>
>> Added: clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp?rev=272816&view=auto
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp (added)
>> +++ clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp Wed Jun 15
>> 13:35:41 2016
>> @@ -0,0 +1,17 @@
>> +// RUN: cat %s > %t.cpp
>> +// RUN: clang-rename -offset=135 -new-name=Bar %t.cpp -i --
>> +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
>> +class Foo {
>> +public:
>> +  Foo();
>> +  ~Foo(); // CHECK: ~Bar();
>> +};
>> +
>> +Foo::Foo() {
>> +}
>> +
>> +Foo::~Foo() { // CHECK: Bar::~Bar()
>> +}
>> +
>> +// Use grep -FUbo 'Foo' <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
>>
>
>
>
> --
> --Artem Belevich
>



-- 
--Artem Belevich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160615/c4b99a40/attachment-0001.html>


More information about the cfe-commits mailing list