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
This commit is contained in:
Simon Pilgrim
2019-10-01 11:25:29 +00:00
parent 1f05f58c4d
commit f29d67d319

View 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()));