Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions interpreter/cling/lib/Utils/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ namespace utils {
ASTContext &mutableCtx( const_cast<ASTContext&>(Ctx) );
arg = TemplateArgument::CreatePackCopy(mutableCtx, desArgs);
}
} else if (arg.getKind() == TemplateArgument::Integral) {

const llvm::APSInt &Val = arg.getAsIntegral();
QualType T = arg.getIntegralType();

// Handle cases where the value is too large to fit into the underlying type
// i.e. where the unsignedness matters.
if (T->isBuiltinType()) {
if (Val.isUnsigned() && Val.getBitWidth() == 64 && Val.countLeadingOnes()) {
const_cast<clang::PrintingPolicy &>(Ctx.getPrintingPolicy()).AlwaysIncludeTypeForTemplateArgument = true;
}
}
}
return changed;
}
Expand Down
8 changes: 1 addition & 7 deletions interpreter/llvm-project/clang/lib/AST/TemplateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,8 @@ static void printIntegral(const TemplateArgument &TemplArg, raw_ostream &Out,
} else
Out << "(" << T->getCanonicalTypeInternal().getAsString(Policy) << ")"
<< Val;
} else {
} else
Out << Val;
// Handle cases where the value is too large to fit into the underlying type
// i.e. where the unsignedness matters.
if (T->isBuiltinType())
if (Val.isUnsigned() && Val.getBitWidth() == 64 && Val.countLeadingOnes())
Out << "ull";
}
}

static unsigned getArrayDepth(QualType type) {
Expand Down
Loading