Radovan =?utf-8?q?Božić?= <[email protected]>,
Radovan =?utf-8?q?Božić?= <[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>
================
@@ -1174,18 +1174,28 @@ class FortifiedBufferChecker {
return NewIndex;
}
- std::optional<llvm::APSInt>
- ComputeExplicitObjectSizeArgument(unsigned Index) {
+ /// Evaluate the argument at Index as an integer constant while preserving
+ /// its signedness, or return std::nullopt if it cannot be evaluated.
+ std::optional<llvm::APSInt> EvaluateIntegerArgument(unsigned Index) {
std::optional<unsigned> IndexOptional = TranslateIndex(Index);
if (!IndexOptional)
return std::nullopt;
- unsigned NewIndex = *IndexOptional;
+
Expr::EvalResult Result;
- Expr *SizeArg = TheCall->getArg(NewIndex);
- if (!SizeArg->EvaluateAsInt(Result, S.getASTContext()))
+ Expr *Arg = TheCall->getArg(*IndexOptional);
----------------
nickdesaulniers wrote:
This looks like it's missing a bounds check against `TheCall->getNumArgs()` to
me.
If we add one here, can we remove the one in `ComputeSizeArgument`?
https://github.com/llvm/llvm-project/pull/204337
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits