[clang] 8930032 - Don't dereference a dyn_cast<> result - use cast<> instead. NFCI.

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 8 05:08:00 PST 2020


Author: Simon Pilgrim
Date: 2020-11-08T13:06:07Z
New Revision: 8930032f53322405ca2d06cac78b9503542e5b62

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

LOG: Don't dereference a dyn_cast<> result - use cast<> instead. NFCI.

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.

Added: 
    

Modified: 
    clang/lib/CodeGen/CodeGenModule.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index ccf5d24bb9eb..d8b819cf5bee 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -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();
   }


        


More information about the cfe-commits mailing list