Skip to content

Commit 7603c77

Browse files
authored
[IR][NFC] Assert that FunctionType::getParamType is in-bounds (#68887)
Like for Function::getArg, assert that the fetched argument is in-range and not out-of-bounds.
1 parent 25da115 commit 7603c77

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/include/llvm/IR/DerivedTypes.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ class FunctionType : public Type {
132132
}
133133

134134
/// Parameter type accessors.
135-
Type *getParamType(unsigned i) const { return ContainedTys[i+1]; }
135+
Type *getParamType(unsigned i) const {
136+
assert(i < getNumParams() && "getParamType() out of range!");
137+
return ContainedTys[i + 1];
138+
}
136139

137140
/// Return the number of fixed parameters this function type requires.
138141
/// This does not consider varargs.

0 commit comments

Comments
 (0)