Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IR][NFC] Assert that FunctionType::getParamType is in-bounds #68887

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

Flakebi
Copy link
Member

@Flakebi Flakebi commented Oct 12, 2023

Like for Function::getArg, assert that the fetched argument is in-range and not out-of-bounds.

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 12, 2023

@llvm/pr-subscribers-llvm-ir

Author: Sebastian Neubauer (Flakebi)

Changes

Like for Function::getArg, assert that the fetched argument is in-range and not out-of-bounds.


Full diff: https://github.com/llvm/llvm-project/pull/68887.diff

1 Files Affected:

  • (modified) llvm/include/llvm/IR/DerivedTypes.h (+4-1)
diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index 203a73067edc7b0..2a81f9b999ce8d6 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -132,7 +132,10 @@ class FunctionType : public Type {
   }
 
   /// Parameter type accessors.
-  Type *getParamType(unsigned i) const { return ContainedTys[i+1]; }
+  Type *getParamType(unsigned i) const {
+    assert(i < getNumParams() && "getParamType() out of range!");
+    return ContainedTys[i+1];
+  }
 
   /// Return the number of fixed parameters this function type requires.
   /// This does not consider varargs.

@github-actions
Copy link

github-actions bot commented Oct 12, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

Like for Function::getArg, assert that the fetched argument is in-range
and not out-of-bounds.
@Flakebi Flakebi merged commit 7603c77 into llvm:main Oct 12, 2023
2 of 3 checks passed
@Flakebi Flakebi deleted the get-param-type branch October 12, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants