29 bool parse(Option &O, StringRef, StringRef Arg, APInt &Val) {
31 return O.error(
"empty integer literal");
33 if (!all_of(Arg, [](
char c) {
return isDigit(c); })) {
34 return O.error(
"arg must be in base 10 (digits).");
38 APInt tmp(bits, Arg, 10);
39 unsigned active = tmp.getActiveBits();
43 Val = tmp.zextOrTrunc(active);
51 const Option &O,
const APInt &V,
const OptionValue<APInt> &Default,
size_t GlobalWidth
53 std::string Cur = llvm::toString(V, 10,
false);
55 std::string Def =
"<unspecified>";
56 if (Default.hasValue()) {
57 const APInt &D = Default.getValue();
58 Def = llvm::toString(D, 10,
false);
61 printOptionName(O, GlobalWidth);
62 llvm::outs() << Cur <<
" (default: " << Def <<
")\n";