return WhiteListFilenames.find(llvm::sys::path::filename(Path))
!= WhiteListFilenames.end();
}
- bool canModifyFile(const FileEntry *FE) {
+ bool canModifyFile(Optional<FileEntryRef> FE) {
if (!FE)
return false;
return canModifyFile(FE->getName());
bool canModifyFile(FileID FID) {
if (FID.isInvalid())
return false;
- return canModifyFile(PP.getSourceManager().getFileEntryForID(FID));
+ return canModifyFile(PP.getSourceManager().getFileEntryRefForID(FID));
}
bool canModify(const Decl *D) {
I = rewriter.buffer_begin(), E = rewriter.buffer_end(); I != E; ++I) {
FileID FID = I->first;
RewriteBuffer &buf = I->second;
- const FileEntry *file = Ctx.getSourceManager().getFileEntryForID(FID);
+ Optional<FileEntryRef> file = Ctx.getSourceManager().getFileEntryRefForID(FID);
assert(file);
SmallString<512> newText;
llvm::raw_svector_ostream vecOS(newText);
namespace {
struct EditEntry {
- const FileEntry *File = nullptr;
+ Optional<FileEntryRef> File;
unsigned Offset = 0;
unsigned RemoveLen = 0;
std::string Text;
StringRef Val = ValueString->getValue(ValueStorage);
if (Key == "file") {
- auto FE = FileMgr.getFile(Val);
- if (FE)
- Entry.File = *FE;
+ if (auto File = FileMgr.getOptionalFileRef(Val))
+ Entry.File = File;
else
Ignore = true;
} else if (Key == "offset") {
return true;
}
-static std::string applyEditsToTemp(const FileEntry *FE,
+static std::string applyEditsToTemp(FileEntryRef FE,
ArrayRef<EditEntry> Edits,
FileManager &FileMgr,
DiagnosticsEngine &Diag) {
SmallString<64> TempPath;
int FD;
- if (fs::createTemporaryFile(path::filename(FE->getName()),
- path::extension(FE->getName()).drop_front(), FD,
+ if (fs::createTemporaryFile(path::filename(FE.getName()),
+ path::extension(FE.getName()).drop_front(), FD,
TempPath)) {
reportDiag("Could not create file: " + TempPath.str(), Diag);
return std::string();
new DiagnosticsEngine(DiagID, new DiagnosticOptions,
DiagClient, /*ShouldOwnClient=*/false));
- typedef llvm::DenseMap<const FileEntry *, std::vector<EditEntry> >
+ typedef llvm::DenseMap<FileEntryRef, std::vector<EditEntry> >
FileEditEntriesTy;
FileEditEntriesTy FileEditEntries;
if (!Insert.second)
continue;
- FileEditEntries[Entry.File].push_back(Entry);
+ FileEditEntries[*Entry.File].push_back(Entry);
}
}
continue;
}
- remap.emplace_back(std::string(I->first->getName()), TempFile);
+ remap.emplace_back(std::string(I->first.getName()), TempFile);
}
return hasErrorOccurred;