]> granicus.if.org Git - llvm/commitdiff
VirtualFileSystem - replace dyn_cast<>+assert with cast<> calls. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 1 Oct 2019 11:25:29 +0000 (11:25 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 1 Oct 2019 11:25:29 +0000 (11:25 +0000)
Silences a number of clang static analyzer null dereference warnings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373325 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/VirtualFileSystem.cpp

index f4b77fc3145e6aeb21b30def35c904c63d4479a1..5aa420cfc721eece26d2fbbc26a27b6b63a22ad8 100644 (file)
@@ -1223,7 +1223,7 @@ class llvm::vfs::RedirectingFileSystemParser {
     }
 
     auto *DE =
-        dyn_cast<RedirectingFileSystem::RedirectingDirectoryEntry>(ParentEntry);
+        cast<RedirectingFileSystem::RedirectingDirectoryEntry>(ParentEntry);
     DE->addContent(std::move(E));
     return DE->getLastContent();
   }
@@ -1234,9 +1234,7 @@ class llvm::vfs::RedirectingFileSystemParser {
     StringRef Name = SrcE->getName();
     switch (SrcE->getKind()) {
     case RedirectingFileSystem::EK_Directory: {
-      auto *DE =
-          dyn_cast<RedirectingFileSystem::RedirectingDirectoryEntry>(SrcE);
-      assert(DE && "Must be a directory");
+      auto *DE = cast<RedirectingFileSystem::RedirectingDirectoryEntry>(SrcE);
       // Empty directories could be present in the YAML as a way to
       // describe a file for a current directory after some of its subdir
       // is parsed. This only leads to redundant walks, ignore it.
@@ -1248,11 +1246,10 @@ class llvm::vfs::RedirectingFileSystemParser {
       break;
     }
     case RedirectingFileSystem::EK_File: {
-      auto *FE = dyn_cast<RedirectingFileSystem::RedirectingFileEntry>(SrcE);
-      assert(FE && "Must be a file");
       assert(NewParentE && "Parent entry must exist");
-      auto *DE = dyn_cast<RedirectingFileSystem::RedirectingDirectoryEntry>(
-          NewParentE);
+      auto *FE = cast<RedirectingFileSystem::RedirectingFileEntry>(SrcE);
+      auto *DE =
+          cast<RedirectingFileSystem::RedirectingDirectoryEntry>(NewParentE);
       DE->addContent(
           std::make_unique<RedirectingFileSystem::RedirectingFileEntry>(
               Name, FE->getExternalContentsPath(), FE->getUseName()));