[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 26 02:33:55 PDT 2019


ilya-biryukov added inline comments.


================
Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:89
+  /// relevant name, not including qualifiers.
+  Name,
+};
----------------
ymandel wrote:
> ilya-biryukov wrote:
> > Same here, what happens to the template arguments and multi-token names, e.g.
> > `operator +` or `foo<int, int>`?
> Good point. This seems difficult to get right, since NamedDecl does not carry sufficient loc data.  However, I've updated the code to explicitly fail in such cases, so at least we won't have bad rewrites.
> 
> BTW, any idea whether constructor initializers can ever be multi token?
> BTW, any idea whether constructor initializers can ever be multi token?

Two cases come to mind:
1. arbitrary names when initializing base classes,  something like `::ns::X<int>(10)`
2. template packs with ellipsis (although ellipsis shouldn't be normally part that we replace, I guess): `Base(10)...`

Full example:
```
namespace ns {
  struct X {
    X(int);
  };
}


template <class ...Bases>
struct Y : ns::X, Bases... {
  Y() : ns::X(10), Bases(10)... {
  }
};

struct Z {
  Z(int);
};
struct W {
  W(int);
};

Y<Z, W> y;
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59376/new/

https://reviews.llvm.org/D59376





More information about the cfe-commits mailing list