Don't dereference a dyn_cast<> result - use cast<> instead. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 8 Nov 2020 13:06:07 +0000 (13:06 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 8 Nov 2020 13:06:07 +0000 (13:06 +0000)
We were relying on the dyn_cast<> succeeding - better use cast<> and have it assert that its the correct type than dereference a null result.

clang/lib/CodeGen/CodeGenModule.cpp

index ccf5d24..d8b819c 100644 (file)
@@ -372,7 +372,7 @@ void CodeGenModule::checkAliases() {
   for (const GlobalDecl &GD : Aliases) {
     StringRef MangledName = getMangledName(GD);
     llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
-    auto *Alias = dyn_cast<llvm::GlobalIndirectSymbol>(Entry);
+    auto *Alias = cast<llvm::GlobalIndirectSymbol>(Entry);
     Alias->replaceAllUsesWith(llvm::UndefValue::get(Alias->getType()));
     Alias->eraseFromParent();
   }