How to convert an APSInt to string in llvm-13?

until llvm-12 i could convert an APSInt to string just using toString() but now in llvm-13 I think I’m supposed to use a different version of toString(). I tried multiple times but nothing so far.

Could you help me to “convert” this line os << ‘[’ << i->From().toString(10) << ", " << i->To().toString(10) << ‘]’;?


We made this change in ⚙ D103888 [ADT] Remove APInt/APSInt toString() std::string variants which has examples of the refactor necessary.

You should be able to use the llvm::toString(const APSInt &I, unsigned Radix) helper found in StringExtras.h

But if you're always wanting Radix = 10, you might be able to just stream the APSInt directly:

os << '[' << i->From() << ", " << i->To() << ']';


Thanks Simon,
That’s solved the problem.