[llvm] 65c6ae3 - [Utils] isLegalToPromote - Fix missing null check before writing to FailureReason.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 15 06:52:56 PDT 2020


Author: Simon Pilgrim
Date: 2020-09-15T14:49:04+01:00
New Revision: 65c6ae3b6aceb934a76c5b10b244edeed80e9cac

URL: https://github.com/llvm/llvm-project/commit/65c6ae3b6aceb934a76c5b10b244edeed80e9cac
DIFF: https://github.com/llvm/llvm-project/commit/65c6ae3b6aceb934a76c5b10b244edeed80e9cac.diff

LOG: [Utils] isLegalToPromote - Fix missing null check before writing to FailureReason.

The FailureReason input parameter maybe null, we check this in all other cases in the method but this one was missed somehow.

Fixes clang-tidy warning.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/CallPromotionUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
index 5a47c1fd0b6c..7141e4b1e879 100644
--- a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
+++ b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
@@ -430,10 +430,11 @@ bool llvm::isLegalToPromote(const CallBase &CB, Function *Callee,
     }
   }
   for (; I < NumArgs; I++) {
-    // Vararg functions can have more arguments than paramters.
+    // Vararg functions can have more arguments than parameters.
     assert(Callee->isVarArg());
     if (CB.paramHasAttr(I, Attribute::StructRet)) {
-      *FailureReason = "SRet arg to vararg function";
+      if (FailureReason)
+        *FailureReason = "SRet arg to vararg function";
       return false;
     }
   }


        


More information about the llvm-commits mailing list