[llvm-branch-commits] [clang] 8278922 - Frontend: Migrate to FileEntryRef in VerifyDiagnosticConsumer.cpp, NFC

Duncan P. N. Exon Smith via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 9 11:55:55 PST 2020


Author: Duncan P. N. Exon Smith
Date: 2020-12-09T11:51:43-08:00
New Revision: 82789228c65317ceea3fdcc08c573c5ca780021e

URL: https://github.com/llvm/llvm-project/commit/82789228c65317ceea3fdcc08c573c5ca780021e
DIFF: https://github.com/llvm/llvm-project/commit/82789228c65317ceea3fdcc08c573c5ca780021e.diff

LOG: Frontend: Migrate to FileEntryRef in VerifyDiagnosticConsumer.cpp, NFC

Add a `FileEntryRef` overload of `SourceManager::translateFile`, and
migrate `ParseDirective` in VerifyDiagnosticConsumer.cpp to use it and
the corresponding overload of `createFileID`.

No functionality change here.

Differential Revision: https://reviews.llvm.org/D92699

Added: 
    

Modified: 
    clang/include/clang/Basic/SourceManager.h
    clang/lib/Frontend/VerifyDiagnosticConsumer.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index 459bd088f0d7..05edc98f9ec8 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -1582,6 +1582,9 @@ class SourceManager : public RefCountedBase<SourceManager> {
   /// If the source file is included multiple times, the FileID will be the
   /// first inclusion.
   FileID translateFile(const FileEntry *SourceFile) const;
+  FileID translateFile(FileEntryRef SourceFile) const {
+    return translateFile(&SourceFile.getFileEntry());
+  }
 
   /// Get the source location in \p FID for the given line:col.
   /// Returns null location if \p FID is not a file SLocEntry.

diff  --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index a10a3dd8a446..0503ae46a15f 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -554,10 +554,9 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
             continue;
           }
 
-          const FileEntry *FE = &File->getFileEntry();
-          FileID FID = SM.translateFile(FE);
+          FileID FID = SM.translateFile(*File);
           if (FID.isInvalid())
-            FID = SM.createFileID(FE, Pos, SrcMgr::C_User);
+            FID = SM.createFileID(*File, Pos, SrcMgr::C_User);
 
           if (PH.Next(Line) && Line > 0)
             ExpectedLoc = SM.translateLineCol(FID, Line, 1);


        


More information about the llvm-branch-commits mailing list