[llvm] r373449 - WinException::emitExceptHandlerTable - silence static analyzer dyn_cast<Function> null dereference warning. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 04:48:32 PDT 2019


Author: rksimon
Date: Wed Oct  2 04:48:32 2019
New Revision: 373449

URL: http://llvm.org/viewvc/llvm-project?rev=373449&view=rev
Log:
WinException::emitExceptHandlerTable - silence static analyzer dyn_cast<Function> null dereference warning. NFCI.

The static analyzer is warning about a potential null dereference, but we should be able to use cast<Function> directly and if not assert will fire for us.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp?rev=373449&r1=373448&r2=373449&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp Wed Oct  2 04:48:32 2019
@@ -982,8 +982,7 @@ void WinException::emitExceptHandlerTabl
   OS.EmitValueToAlignment(4);
   OS.EmitLabel(LSDALabel);
 
-  const Function *Per =
-      dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
+  const auto *Per = cast<Function>(F.getPersonalityFn()->stripPointerCasts());
   StringRef PerName = Per->getName();
   int BaseState = -1;
   if (PerName == "_except_handler4") {




More information about the llvm-commits mailing list