diff options
author | Alexander Shaposhnikov <shal1t712@gmail.com> | 2016-09-17 17:08:47 +0000 |
---|---|---|
committer | Alexander Shaposhnikov <shal1t712@gmail.com> | 2016-09-17 17:08:47 +0000 |
commit | 4c80dcd9157dbc19004ba3592e703ba9375f0138 (patch) | |
tree | 868607d0c893fa1834628f883ff2a4872f3c7aad /clang-reorder-fields | |
parent | 97c950472bfdaf7f04e437a1634c29ce1d68a13b (diff) |
[clang-rename] Fix handling of unchanged files
Fix the output of clang-rename for the files without modifications.
Update the code in clang-reorder-fields/tool/ClangReorderFields.cpp
to avoid inconsistency.
Example:
a.h:
struct A {};
a.cpp:
#include "a.h"
int main() { return 0; }
Before the changes the output looks like this:
clang-rename -qualified-name=A -new-name=B a.cpp
<<<<<INVALID SOURCE LOCATION>>>>>
Test plan: make -j8 check-clang-tools
Differential revision: https://reviews.llvm.org/D24634
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@281826 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-reorder-fields')
-rw-r--r-- | clang-reorder-fields/tool/ClangReorderFields.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/clang-reorder-fields/tool/ClangReorderFields.cpp b/clang-reorder-fields/tool/ClangReorderFields.cpp index 3061876c..077e55e8 100644 --- a/clang-reorder-fields/tool/ClangReorderFields.cpp +++ b/clang-reorder-fields/tool/ClangReorderFields.cpp @@ -80,13 +80,8 @@ int main(int argc, const char **argv) { for (const auto &File : Files) { const auto *Entry = FileMgr.getFile(File); - const auto ID = Sources.translateFile(Entry); - // The method Rewriter::getRewriteBufferFor returns nullptr if - // the file has not been changed. - if (const auto *RB = Rewrite.getRewriteBufferFor(ID)) - RB->write(outs()); - else - outs() << Sources.getMemoryBufferForFile(Entry)->getBuffer(); + const auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User); + Rewrite.getEditBuffer(ID).write(outs()); } return ExitCode; |