================
@@ -17575,7 +17576,21 @@ static bool ConvertAPValueToString(const APValue &V,
QualType T,
break;
}
}
- V.getInt().toString(Str);
+
+ llvm::APSInt vInt = V.getInt();
+ if (llvm::APSInt::compareValues(
+ vInt, llvm::APSInt::getUnsigned(
+ std::numeric_limits<uint64_t>::max())) >= 0 ||
+ vInt < std::numeric_limits<int64_t>::min()) {
+ // The value of cutSize is not special, it is just a number of
+ // characters that gives us enough info without losing readability
+ const int cutSize = 20;
+ vInt.toString(Str, 16);
+ Str.erase(Str.begin() + cutSize, Str.end() - cutSize);
----------------
erichkeane wrote:
This here doesn't really seem right. We're just erasing blindly in the middle,
despite not knowing that we have enough room. I think what we REALLY want is
to decide to keep the first N characters, and the last N characters (and still
do the ...).
Additionally, I think instead of doing the whole to-string mechanism here (and
since we're doing it in hex it is easy to do so), we could just do a
numeric-trim of hte front/back instead and join them afterwards.
THAT SAID: I'm not sold on doing this as a hex-print, I think we can keep it
decimal. We could have a new function in `APInt` that does a `print only the
first N and last N, with dots between` kind of thing. If we have that, we
don't actually have to do any branching here, because choosing a reasonable
number there plus decent algorithm for it (basically, normal RHS processing
until we reach 'N' digits, then figure out how many orders of magnitude to
divide by using 'log' to figure out how to get the remaining 'N').
https://github.com/llvm/llvm-project/pull/145053
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits