[LibTooling] Add retrieval of extended AST-node source to FixIt library
authorYitzhak Mandelbaum <yitzhakm@google.com>
Wed, 13 Mar 2019 19:48:51 +0000 (19:48 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Wed, 13 Mar 2019 19:48:51 +0000 (19:48 +0000)
commit60a4163f6d442e2c312bb88f5c219f0ac58daf0f
tree74ec039ab35b6ac0842288c561377042cf28f721
parent0253620f891086458e1acc51d691d324e1a50388
[LibTooling] Add retrieval of extended AST-node source to FixIt library

Summary:
Introduces variants of `getText` and `getSourceRange` that extract the source text of an AST node potentially with a trailing token.

Some of the new functions manipulate `CharSourceRange`s, rather than `SourceRange`s, because they document and dynamically enforce their type.  So, this revision also updates the corresponding existing FixIt functions to manipulate `CharSourceRange`s.  This change is not strictly necessary, but seems like the correct choice, to keep the API self-consistent.

This revision is the first in a series intended to improve the abstractions available to users for writing source-to-source transformations.  A full discussion of the end goal can be found on the cfe-dev list with subject "[RFC] Easier source-to-source transformations with clang tooling".

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: kimgr, riccibruno, JonasToth, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58556

llvm-svn: 356095
clang/include/clang/Tooling/FixIt.h
clang/lib/Tooling/FixIt.cpp
clang/unittests/Tooling/FixItTest.cpp