[libTooling] Transformer: refine `SourceLocation` specified as anchor of changes.
authorYitzhak Mandelbaum <yitzhakm@google.com>
Fri, 27 Sep 2019 15:26:04 +0000 (15:26 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Fri, 27 Sep 2019 15:26:04 +0000 (15:26 +0000)
commitdb24ef509ecb271a1b03c35c34889f539bc70a32
treeddb9f298bd71bfd6b80d136a4a477626caa8d552
parent59e26308e60a08a5a4534ba827744564c71d7aff
[libTooling] Transformer: refine `SourceLocation` specified as anchor of changes.

Summary: Every change triggered by a rewrite rule is anchored at a particular
location in the source code.  This patch refines how that location is chosen and
defines it as an explicit function so it can be shared by other Transformer
implementations.

This patch was inspired by a bug found by a clang tidy, wherein two changes were
anchored at the same location (the expansion loc of the macro) resulting in the
discarding of the second change.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 373093
clang/include/clang/Tooling/Refactoring/Transformer.h
clang/lib/Tooling/Refactoring/Transformer.cpp
clang/unittests/Tooling/TransformerTest.cpp