From: Simon Pilgrim Date: Tue, 1 Oct 2019 11:25:29 +0000 (+0000) Subject: VirtualFileSystem - replace dyn_cast<>+assert with cast<> calls. NFCI. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f29d67d31978d40debc7148311fdf72703df128c;p=llvm VirtualFileSystem - replace dyn_cast<>+assert with cast<> calls. NFCI. 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 --- diff --git a/lib/Support/VirtualFileSystem.cpp b/lib/Support/VirtualFileSystem.cpp index f4b77fc3145..5aa420cfc72 100644 --- a/lib/Support/VirtualFileSystem.cpp +++ b/lib/Support/VirtualFileSystem.cpp @@ -1223,7 +1223,7 @@ class llvm::vfs::RedirectingFileSystemParser { } auto *DE = - dyn_cast(ParentEntry); + cast(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(SrcE); - assert(DE && "Must be a directory"); + auto *DE = cast(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(SrcE); - assert(FE && "Must be a file"); assert(NewParentE && "Parent entry must exist"); - auto *DE = dyn_cast( - NewParentE); + auto *FE = cast(SrcE); + auto *DE = + cast(NewParentE); DE->addContent( std::make_unique( Name, FE->getExternalContentsPath(), FE->getUseName()));