[llvm-branch-commits] [clang] a600432 - Frontend: Migrate to FileEntryRef in TextDiagnosticTest, NFC

Duncan P. N. Exon Smith via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 11 17:11:03 PST 2020


Author: Duncan P. N. Exon Smith
Date: 2020-12-11T17:06:28-08:00
New Revision: a60043219907b8f370263b7d3d4827b83388d8cf

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

LOG: Frontend: Migrate to FileEntryRef in TextDiagnosticTest, NFC

Migrate over to the `FileEntryRef` overloads of
`SourceManager::createFileID` and `overrideFileContents` (using
`getVirtualFileRef`) in `TextDiagnostic`'s `ShowLine` test.

No functionality change.

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

Added: 
    

Modified: 
    clang/unittests/Frontend/TextDiagnosticTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Frontend/TextDiagnosticTest.cpp b/clang/unittests/Frontend/TextDiagnosticTest.cpp
index 1e05104d9388..220cff6643d5 100644
--- a/clang/unittests/Frontend/TextDiagnosticTest.cpp
+++ b/clang/unittests/Frontend/TextDiagnosticTest.cpp
@@ -46,7 +46,7 @@ TEST(TextDiagnostic, ShowLine) {
   // Create a dummy file with some contents to produce a test SourceLocation.
   const llvm::StringRef file_path = "main.cpp";
   const llvm::StringRef main_file_contents = "some\nsource\ncode\n";
-  const clang::FileEntry &fe = *FileMgr.getVirtualFile(
+  const clang::FileEntryRef fe = FileMgr.getVirtualFileRef(
       file_path,
       /*Size=*/static_cast<off_t>(main_file_contents.size()),
       /*ModificationTime=*/0);
@@ -55,11 +55,11 @@ TEST(TextDiagnostic, ShowLine) {
   buffer.append(main_file_contents.begin(), main_file_contents.end());
   auto file_contents = std::make_unique<llvm::SmallVectorMemoryBuffer>(
       std::move(buffer), file_path);
-  SrcMgr.overrideFileContents(&fe, std::move(file_contents));
+  SrcMgr.overrideFileContents(fe, std::move(file_contents));
 
   // Create the actual file id and use it as the main file.
   clang::FileID fid =
-      SrcMgr.createFileID(&fe, SourceLocation(), clang::SrcMgr::C_User);
+      SrcMgr.createFileID(fe, SourceLocation(), clang::SrcMgr::C_User);
   SrcMgr.setMainFileID(fid);
 
   // Create the source location for the test diagnostic.


        


More information about the llvm-branch-commits mailing list