[llvm] r373464 - AsmPrinter - emitGlobalConstantFP - silence static analyzer null dereference warning. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 06:08:46 PDT 2019


Author: rksimon
Date: Wed Oct  2 06:08:46 2019
New Revision: 373464

URL: http://llvm.org/viewvc/llvm-project?rev=373464&view=rev
Log:
AsmPrinter - emitGlobalConstantFP - silence static analyzer null dereference warning. NFCI.

All the calls to emitGlobalConstantFP should provide a nonnull Type for the float.

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

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=373464&r1=373463&r2=373464&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Oct  2 06:08:46 2019
@@ -2476,6 +2476,7 @@ static void emitGlobalConstantStruct(con
 }
 
 static void emitGlobalConstantFP(APFloat APF, Type *ET, AsmPrinter &AP) {
+  assert(ET && "Unknown float type");
   APInt API = APF.bitcastToAPInt();
 
   // First print a comment with what we think the original floating-point value
@@ -2483,11 +2484,7 @@ static void emitGlobalConstantFP(APFloat
   if (AP.isVerbose()) {
     SmallString<8> StrVal;
     APF.toString(StrVal);
-
-    if (ET)
-      ET->print(AP.OutStreamer->GetCommentOS());
-    else
-      AP.OutStreamer->GetCommentOS() << "Printing <null> Type";
+    ET->print(AP.OutStreamer->GetCommentOS());
     AP.OutStreamer->GetCommentOS() << ' ' << StrVal << '\n';
   }
 




More information about the llvm-commits mailing list