Lines Matching +full:llvm +full:- +full:builddir
1 //===-- ApplyReplacements.cpp - Apply and deduplicate replacements --------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 /// FIXME: Use Diagnostics for output instead of llvm::errs().
15 //===----------------------------------------------------------------------===//
16 #include "clang-apply-replacements/Tooling/ApplyReplacements.h"
25 #include "llvm/ADT/ArrayRef.h"
26 #include "llvm/ADT/STLExtras.h"
27 #include "llvm/ADT/StringRef.h"
28 #include "llvm/ADT/StringSet.h"
29 #include "llvm/Support/FileSystem.h"
30 #include "llvm/Support/MemoryBuffer.h"
31 #include "llvm/Support/Path.h"
32 #include "llvm/Support/raw_ostream.h"
36 using namespace llvm;
50 const llvm::StringRef Directory, TranslationUnits &TUs,
52 using namespace llvm::sys::fs;
53 using namespace llvm::sys::path;
59 if (filename(I->path())[0] == '.') {
65 if (!is_contained(AllowedExtensions, extension(I->path())))
68 TUFiles.push_back(I->path());
71 MemoryBuffer::getFile(I->path());
73 errs() << "Error reading " << I->path() << ": " << BufferError.message()
78 yaml::Input YIn(Out.get()->getBuffer(), nullptr, &eatDiagnostics);
96 const llvm::StringRef Directory, TUReplacements &TUs,
104 const llvm::StringRef Directory, TUDiagnostics &TUs,
122 static llvm::DenseMap<FileEntryRef, std::vector<tooling::Replacement>>
125 llvm::StringSet<> Warned;
126 llvm::DenseMap<FileEntryRef, std::vector<tooling::Replacement>>
132 llvm::DenseMap<const FileEntry *,
139 const std::optional<std::string> BuildDir) {
144 if (BuildDir)
145 llvm::sys::fs::make_absolute(*BuildDir, Path);
152 if (!Inserted && It->second != SourceTU)
176 // clang-apply-replacements run on differents machine.
178 llvm::sort(FileAndReplacements.second);
198 llvm::Error Err =
214 errs() << llvm::toString(std::move(Err)) << "\n";
220 R.getOffset() + R.getLength()) -
227 llvm::errs()
242 llvm::Expected<std::string>
249 llvm::ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer =
253 return tooling::applyAtomicChanges(File, Buffer.get()->getBuffer(), Changes,
261 std::error_code Error = llvm::sys::fs::remove(Filename);