[llvm] r372757 - [COFF] Silence static analyzer null dereference warning. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 06:57:38 PDT 2019


Author: rksimon
Date: Tue Sep 24 06:57:38 2019
New Revision: 372757

URL: http://llvm.org/viewvc/llvm-project?rev=372757&view=rev
Log:
[COFF] Silence static analyzer null dereference warning. NFCI.

Assert that the COFFSymbolRef is correct.

Modified:
    llvm/trunk/include/llvm/Object/COFF.h

Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=372757&r1=372756&r2=372757&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Tue Sep 24 06:57:38 2019
@@ -314,7 +314,10 @@ public:
     return CS16 ? CS16->Name.Offset : CS32->Name.Offset;
   }
 
-  uint32_t getValue() const { return CS16 ? CS16->Value : CS32->Value; }
+  uint32_t getValue() const {
+    assert(isSet() && "COFFSymbolRef points to nothing!");
+    return CS16 ? CS16->Value : CS32->Value;
+  }
 
   int32_t getSectionNumber() const {
     assert(isSet() && "COFFSymbolRef points to nothing!");




More information about the llvm-commits mailing list