[llvm] 46f0e2c - [bugpoint] ReduceCrashingFunctions::TestFuncs - fix dereference of null point static analyzer warning

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 7 04:14:15 PDT 2022


Author: Simon Pilgrim
Date: 2022-04-07T12:14:08+01:00
New Revision: 46f0e2ceb4875f69ec76af6bc2e02aa359cccb64

URL: https://github.com/llvm/llvm-project/commit/46f0e2ceb4875f69ec76af6bc2e02aa359cccb64
DIFF: https://github.com/llvm/llvm-project/commit/46f0e2ceb4875f69ec76af6bc2e02aa359cccb64.diff

LOG: [bugpoint] ReduceCrashingFunctions::TestFuncs - fix dereference of null point static analyzer warning

Alias.getAliaseeObject() shouldn't be null, do use dyn_cast instead of dyn_cast_or_null

Also, remove redundant `else if (!F)` test - that is always true at the point in the if-else chain

Added: 
    

Modified: 
    llvm/tools/bugpoint/CrashDebugger.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index d127ea0945f27..9912f59f0ba61 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -270,7 +270,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function *> &Funcs) {
     // First, remove aliases to functions we're about to purge.
     for (GlobalAlias &Alias : M->aliases()) {
       GlobalObject *Root = Alias.getAliaseeObject();
-      Function *F = dyn_cast_or_null<Function>(Root);
+      auto *F = dyn_cast<Function>(Root);
       if (F) {
         if (Functions.count(F))
           // We're keeping this function.
@@ -278,7 +278,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function *> &Funcs) {
       } else if (Root->isNullValue()) {
         // This referenced a globalalias that we've already replaced,
         // so we still need to replace this alias.
-      } else if (!F) {
+      } else {
         // Not a function, therefore not something we mess with.
         continue;
       }


        


More information about the llvm-commits mailing list