[clang][CodeGen] NFCI: Use FileEntryRef

This patch removes use of the deprecated `DirectoryEntry::getName()` from clangCodeGen by using `{File,Directory}EntryRef` instead.

Reviewed By: bnbarham

Differential Revision: https://reviews.llvm.org/D123768
This commit is contained in:
Jan Svoboda 2022-04-15 14:48:01 +02:00
parent f263dac446
commit 9d98f58959
2 changed files with 6 additions and 4 deletions

View file

@ -519,8 +519,9 @@ void CGDebugInfo::CreateCompileUnit() {
// a relative path, so we look into the actual file entry for the main
// file to determine the real absolute path for the file.
std::string MainFileDir;
if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
MainFileDir = std::string(MainFile->getDir()->getName());
if (Optional<FileEntryRef> MainFile =
SM.getFileEntryRefForID(SM.getMainFileID())) {
MainFileDir = std::string(MainFile->getDir().getName());
if (!llvm::sys::path::is_absolute(MainFileName)) {
llvm::SmallString<1024> MainFileDirSS(MainFileDir);
llvm::sys::path::append(MainFileDirSS, MainFileName);

View file

@ -3862,9 +3862,10 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
// The path to the source file where this module was declared
SourceManager &SM = CGM.getContext().getSourceManager();
const FileEntry *mainFile = SM.getFileEntryForID(SM.getMainFileID());
Optional<FileEntryRef> mainFile =
SM.getFileEntryRefForID(SM.getMainFileID());
std::string path =
(Twine(mainFile->getDir()->getName()) + "/" + mainFile->getName()).str();
(mainFile->getDir().getName() + "/" + mainFile->getName()).str();
module.add(MakeConstantString(path, ".objc_source_file_name"));
module.add(symtab);