[clang] 5be0e83 - [clang] NFCI: Use `FileEntryRef` in `PPLexerChange`

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Wed May 31 16:04:53 PDT 2023


Author: Jan Svoboda
Date: 2023-05-31T16:04:45-07:00
New Revision: 5be0e83635a22da0a42aeeeca8d42193ff2f9db6

URL: https://github.com/llvm/llvm-project/commit/5be0e83635a22da0a42aeeeca8d42193ff2f9db6
DIFF: https://github.com/llvm/llvm-project/commit/5be0e83635a22da0a42aeeeca8d42193ff2f9db6.diff

LOG: [clang] NFCI: Use `FileEntryRef` in `PPLexerChange`

This removes some uses of the deprecated `FileEntry::getName()`.

Added: 
    

Modified: 
    clang/lib/Lex/PPLexerChange.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index e2dc532e6b70..ab005381adfa 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -223,18 +223,17 @@ void Preprocessor::EnterTokenStream(const Token *Toks, unsigned NumToks,
 /// Compute the relative path that names the given file relative to
 /// the given directory.
 static void computeRelativePath(FileManager &FM, const DirectoryEntry *Dir,
-                                const FileEntry *File,
-                                SmallString<128> &Result) {
+                                FileEntryRef File, SmallString<128> &Result) {
   Result.clear();
 
-  StringRef FilePath = File->getDir()->getName();
+  StringRef FilePath = File.getDir().getName();
   StringRef Path = FilePath;
   while (!Path.empty()) {
     if (auto CurDir = FM.getDirectory(Path)) {
       if (*CurDir == Dir) {
         Result = FilePath.substr(Path.size());
         llvm::sys::path::append(Result,
-                                llvm::sys::path::filename(File->getName()));
+                                llvm::sys::path::filename(File.getName()));
         return;
       }
     }
@@ -242,7 +241,7 @@ static void computeRelativePath(FileManager &FM, const DirectoryEntry *Dir,
     Path = llvm::sys::path::parent_path(Path);
   }
 
-  Result = File->getName();
+  Result = File.getName();
 }
 
 void Preprocessor::PropagateLineStartLeadingSpaceInfo(Token &Result) {
@@ -314,7 +313,7 @@ void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
              .Default(false))
       continue;
 
-    if (auto Header = getFileManager().getFile(Entry->path()))
+    if (auto Header = getFileManager().getOptionalFileRef(Entry->path()))
       if (!getSourceManager().hasFileInfo(*Header)) {
         if (!ModMap.isHeaderInUnavailableModule(*Header)) {
           // Find the relative path that would access this header.


        


More information about the cfe-commits mailing list