RenameMethod.cpp compilation errors

The following example:

http://llvm.org/svn/llvm-project/cfe/branches/tooling/examples/rename-method/RenameMethod.cpp

doesn’t compile with the current clang source. Hacking it based on samples in tools/clang/unittests/ASTMatchers/ASTMatchersTest.cpp

— orig/RenameMethod.cpp 2012-07-02 15:22:34.000000000 -0400
+++ RenameMethod.cpp 2013-04-25 15:50:48.000000000 -0400
@@ -122,22 +122,22 @@ int main(int argc, const char **argv) {
CallRenamer CallCallback(&Tool.getReplacements());
Finder.addMatcher(
// Match calls…

  • call(
  • memberCallExpr(
    // Where the callee is a method called “Get”…
  • callee(method(hasName(“Get”))),
  • callee(methodDecl(hasName(“Get”))),
    // … and the class on which the method is called is derived
    // from ElementsBase …
  • thisPointerType(record(
  • thisPointerType(recordDecl(
    isDerivedFrom(“ElementsBase”))),
    // … and bind the member expression to the ID “member”, under which
    // it can later be found in the callback.
  • callee(id(“member”, memberExpression()))),
  • callee(id(“member”, memberExpr()))),
    &CallCallback);

DeclRenamer DeclCallback(&Tool.getReplacements());
Finder.addMatcher(
// Match declarations…

  • id(“method”, method(hasName(“Get”),
  • id(“method”, methodDecl(hasName(“Get”),
    ofClass(isDerivedFrom(“ElementsBase”)))),
    &DeclCallback);

appears to be enough to make it compile.

The following example:

http://llvm.org/svn/llvm-project/cfe/branches/tooling/examples/rename-method/RenameMethod.cpp

doesn't compile with the current clang source. Hacking it based on
samples in tools/clang/unittests/ASTMatchers/ASTMatchersTest.cpp

--- orig/RenameMethod.cpp 2012-07-02 15:22:34.000000000 -0400
+++ RenameMethod.cpp 2013-04-25 15:50:48.000000000 -0400
@@ -122,22 +122,22 @@ int main(int argc, const char **argv) {
   CallRenamer CallCallback(&Tool.getReplacements());
   Finder.addMatcher(
     // Match calls...
- call(
+ memberCallExpr(
       // Where the callee is a method called "Get"...
- callee(method(hasName("Get"))),
+ callee(methodDecl(hasName("Get"))),
       // ... and the class on which the method is called is derived
       // from ElementsBase ...
- thisPointerType(record(
+ thisPointerType(recordDecl(
         isDerivedFrom("ElementsBase"))),
       // ... and bind the member expression to the ID "member", under
which
       // it can later be found in the callback.
- callee(id("member", memberExpression()))),
+ callee(id("member", memberExpr()))),
     &CallCallback);

   DeclRenamer DeclCallback(&Tool.getReplacements());
   Finder.addMatcher(
     // Match declarations...
- id("method", method(hasName("Get"),
+ id("method", methodDecl(hasName("Get"),
                         ofClass(isDerivedFrom("ElementsBase")))),
     &DeclCallback);

appears to be enough to make it compile.

The tooling/ branch is currently unsupported. We're planning to start a
better rename tool into the extra/tools repo in the upcoming months...

Cheers,
/Manuel