IR: Properly return nullptr when getAggregateElement is out-of-bounds
[oota-llvm.git] / include / llvm / IR / Constants.h
index 785f48c90d3ad5fa47dcf3c6a4fa57b0955b7ce2..5f09fe1fb62c6da7f623683757a19c8b10a41bda 100644 (file)
@@ -325,6 +325,9 @@ public:
   /// index.
   Constant *getElementValue(unsigned Idx) const;
 
+  /// \brief Return the number of elements in the array, vector, or struct.
+  unsigned getNumElements() const;
+
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   ///
   static bool classof(const Value *V) {
@@ -1196,6 +1199,9 @@ public:
   /// index.
   UndefValue *getElementValue(unsigned Idx) const;
 
+  /// \brief Return the number of elements in the array, vector, or struct.
+  unsigned getNumElements() const;
+
   void destroyConstant() override;
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast: