[PATCH] D155195: [include-cleaner] Avoid a caching issue when running --edit mode on multiple files.
This revision was automatically updated to reflect the committed changes. Closed by commit rGbe861b64d941: [include-cleaner] Avoid a caching issue when running --edit mode on multiple… (authored by hokein). Changed prior to commit: https://reviews.llvm.org/D155195?vs=539988=541449#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155195/new/ https://reviews.llvm.org/D155195 Files: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp === --- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -19,6 +19,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Regex.h" #include "llvm/Support/Signals.h" #include "llvm/Support/raw_ostream.h" @@ -270,12 +271,24 @@ } } } + + clang::tooling::ClangTool Tool(OptionsParser->getCompilations(), + OptionsParser->getSourcePathList()); + std::vector> Buffers; + for (const auto : OptionsParser->getSourcePathList()) { +auto Content = llvm::MemoryBuffer::getFile(File); +if (!Content) { + llvm::errs() << "Error: can't read file '" << File + << "': " << Content.getError().message() << "\n"; + return 1; +} +Buffers.push_back(std::move(Content.get())); +Tool.mapVirtualFile(File, Buffers.back()->getBuffer()); + } + auto HeaderFilter = headerFilter(); if (!HeaderFilter) return 1; // error already reported. ActionFactory Factory(HeaderFilter); - return clang::tooling::ClangTool(OptionsParser->getCompilations(), - OptionsParser->getSourcePathList()) - .run() || - Errors != 0; + return Tool.run() || Errors != 0; } Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp === --- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -19,6 +19,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Regex.h" #include "llvm/Support/Signals.h" #include "llvm/Support/raw_ostream.h" @@ -270,12 +271,24 @@ } } } + + clang::tooling::ClangTool Tool(OptionsParser->getCompilations(), + OptionsParser->getSourcePathList()); + std::vector> Buffers; + for (const auto : OptionsParser->getSourcePathList()) { +auto Content = llvm::MemoryBuffer::getFile(File); +if (!Content) { + llvm::errs() << "Error: can't read file '" << File + << "': " << Content.getError().message() << "\n"; + return 1; +} +Buffers.push_back(std::move(Content.get())); +Tool.mapVirtualFile(File, Buffers.back()->getBuffer()); + } + auto HeaderFilter = headerFilter(); if (!HeaderFilter) return 1; // error already reported. ActionFactory Factory(HeaderFilter); - return clang::tooling::ClangTool(OptionsParser->getCompilations(), - OptionsParser->getSourcePathList()) - .run() || - Errors != 0; + return Tool.run() || Errors != 0; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D155195: [include-cleaner] Avoid a caching issue when running --edit mode on multiple files.
kadircet accepted this revision. kadircet added a comment. This revision is now accepted and ready to land. thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155195/new/ https://reviews.llvm.org/D155195 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D155195: [include-cleaner] Avoid a caching issue when running --edit mode on multiple files.
hokein created this revision. hokein added a reviewer: kadircet. Herald added a project: All. hokein requested review of this revision. Herald added a project: clang-tools-extra. Snapshot all analysing files before running the tool, this makes sure that we analyse all files statelessly and avoid the FileManager caching issue when running `-edit` on multiple files. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D155195 Files: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp === --- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -19,6 +19,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Regex.h" #include "llvm/Support/Signals.h" #include "llvm/Support/raw_ostream.h" @@ -270,10 +271,22 @@ } } } + + clang::tooling::ClangTool Tool(OptionsParser->getCompilations(), + OptionsParser->getSourcePathList()); + std::vector> Buffers; + for (const auto : OptionsParser->getSourcePathList()) { +auto Content = llvm::MemoryBuffer::getFile(File); +if (!Content) { + llvm::errs() << "Error: can't read file '" << File + << "': " << Content.getError().message() << "\n"; + return 1; +} +Buffers.push_back(std::move(Content.get())); +Tool.mapVirtualFile(File, Buffers.back()->getBuffer()); + } + auto HeaderFilter = headerFilter(); ActionFactory Factory(HeaderFilter); - return clang::tooling::ClangTool(OptionsParser->getCompilations(), - OptionsParser->getSourcePathList()) - .run() || - Errors != 0; + return Tool.run() || Errors != 0; } Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp === --- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -19,6 +19,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Regex.h" #include "llvm/Support/Signals.h" #include "llvm/Support/raw_ostream.h" @@ -270,10 +271,22 @@ } } } + + clang::tooling::ClangTool Tool(OptionsParser->getCompilations(), + OptionsParser->getSourcePathList()); + std::vector> Buffers; + for (const auto : OptionsParser->getSourcePathList()) { +auto Content = llvm::MemoryBuffer::getFile(File); +if (!Content) { + llvm::errs() << "Error: can't read file '" << File + << "': " << Content.getError().message() << "\n"; + return 1; +} +Buffers.push_back(std::move(Content.get())); +Tool.mapVirtualFile(File, Buffers.back()->getBuffer()); + } + auto HeaderFilter = headerFilter(); ActionFactory Factory(HeaderFilter); - return clang::tooling::ClangTool(OptionsParser->getCompilations(), - OptionsParser->getSourcePathList()) - .run() || - Errors != 0; + return Tool.run() || Errors != 0; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits