Skip to content

Commit

Permalink
Migrate to FileEntryRef and DirectoryEntryRef
Browse files Browse the repository at this point in the history
Fix the deprecation warning when compiling cling standalone
  • Loading branch information
devajithvs authored and jenkins committed Sep 12, 2024
1 parent 535417b commit 92e93ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions lib/Interpreter/ClangInternalState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,26 @@ namespace cling {
std::vector<std::string> ParsedOpen, Parsed, AST;
for (clang::SourceManager::fileinfo_iterator I = SM.fileinfo_begin(),
E = SM.fileinfo_end(); I != E; ++I) {
const clang::FileEntry *FE = I->first;
const clang::FileEntryRef FE = I->first;
// Our error recovery purges the cache of the FileEntry, but keeps
// the FileEntry's pointer so that if it was used by smb (like the
// SourceManager) it wouldn't be dangling. In that case we shouldn't
// print the FileName, because semantically it is not there.
if (!I->second)
continue;
std::string fileName(FE->getName());
std::string fileName(FE.getName());
if (!(fileName.compare(0, 5, "/usr/") == 0 &&
fileName.find("/bits/") != std::string::npos) &&
fileName.compare("-")) {
if (I->second->getBufferDataIfLoaded()) {
// There is content - a memory buffer or a file.
// We know it's a file because we started off the FileEntry.
if (FE->isOpen())

// FIXME: LLVM will completely migrate to FileEntryRef.
// We added `isOpen()` in our commit:
// `Accessor to "is file opened"; this is crucial info for us.`
// Move this logic to FileEntryRef or have a workaround.
if (FE.getFileEntry().isOpen())
ParsedOpen.emplace_back(std::move(fileName));
else
Parsed.emplace_back(std::move(fileName));
Expand Down
4 changes: 2 additions & 2 deletions lib/Interpreter/NullDerefProtectionTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ namespace cling {
if (FID.isInvalid())
return false;

auto FE = SM.getFileEntryForID(FID);
auto FE = SM.getFileEntryRefForID(FID);
if (!FE)
return false;

Expand All @@ -296,7 +296,7 @@ namespace cling {
if (IterAndInserted.second == false)
return IterAndInserted.first->second;

if (llvm::sys::fs::can_write(Dir->getName()))
if (llvm::sys::fs::can_write(Dir.getName()))
return true; // `true` is already emplaced above.

// Remember that this dir is not writable and should not be visited.
Expand Down

0 comments on commit 92e93ec

Please sign in to comment.