diff options
-rw-r--r-- | clang-rename/tool/ClangRename.cpp | 2 | ||||
-rw-r--r-- | clang-reorder-fields/tool/ClangReorderFields.cpp | 9 | ||||
-rw-r--r-- | test/clang-rename/IncludeHeaderWithSymbol.cpp | 10 | ||||
-rw-r--r-- | test/clang-rename/Inputs/HeaderWithSymbol.h | 1 |
4 files changed, 14 insertions, 8 deletions
diff --git a/clang-rename/tool/ClangRename.cpp b/clang-rename/tool/ClangRename.cpp index 9cc29ff9..1f42f7f1 100644 --- a/clang-rename/tool/ClangRename.cpp +++ b/clang-rename/tool/ClangRename.cpp @@ -222,7 +222,7 @@ int main(int argc, const char **argv) { Tool.applyAllReplacements(Rewrite); for (const auto &File : Files) { const auto *Entry = FileMgr.getFile(File); - auto ID = Sources.translateFile(Entry); + const auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User); Rewrite.getEditBuffer(ID).write(outs()); } } 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; diff --git a/test/clang-rename/IncludeHeaderWithSymbol.cpp b/test/clang-rename/IncludeHeaderWithSymbol.cpp new file mode 100644 index 00000000..cb2baee5 --- /dev/null +++ b/test/clang-rename/IncludeHeaderWithSymbol.cpp @@ -0,0 +1,10 @@ +#include "Inputs/HeaderWithSymbol.h" + +int main() { + return 0; // CHECK: {{^ return 0;}} +} + +// Test 1. +// The file IncludeHeaderWithSymbol.cpp doesn't contain the symbol Foo +// and is expected to be written to stdout without modifications +// RUN: clang-rename -qualified-name=Foo -new-name=Bar %s -- | FileCheck %s diff --git a/test/clang-rename/Inputs/HeaderWithSymbol.h b/test/clang-rename/Inputs/HeaderWithSymbol.h new file mode 100644 index 00000000..1fe02e89 --- /dev/null +++ b/test/clang-rename/Inputs/HeaderWithSymbol.h @@ -0,0 +1 @@ +struct Foo {}; |