[PATCH] D62621: [LibTooling] Add insert/remove convenience functions for creating `ASTEdit`s.

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 4 00:39:31 PDT 2019


ilya-biryukov added a comment.

Are there any corner cases with handling whitespace that we might want to handle or document them if we don't handle them?
E.g. if the range ends up being a name of an expanded macro , it's probably very easy to glue the macro name with whatever you're inserting.

  #define FOO 1+2;
  #define BAR 2+3;
  
  [[FOO]] // [[ ]] marks the selected range

would `insertBefore([[FOO]], "BAR")` end up being `BARFOO` or `BAR FOO`?



================
Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:202
+
+/// Inserts \p Replacement after \p S, automatically calculating the end
+/// location of \p S.
----------------
Could you elaborate on what `calculating the end location of \p S` means?
Is the fact that the end location is calculated specific to this function, rather than `RangeSelector` in general?

The comment is very different from `insertBefore`, suggesting the function behaves differently in practice.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62621





More information about the cfe-commits mailing list