-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) #80309
Changes from 2 commits
9679519
665720f
2dba028
99d7e27
38e2027
796f5ef
1851f82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3600,8 +3600,11 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) { | |
|
||
ExprResult Sema::ActOnIntegerConstant(SourceLocation Loc, uint64_t Val) { | ||
unsigned IntSize = Context.getTargetInfo().getIntWidth(); | ||
return IntegerLiteral::Create(Context, llvm::APInt(IntSize, Val), | ||
Context.IntTy, Loc); | ||
// TODO: Avoid implicit trunc? | ||
return IntegerLiteral::Create( | ||
Context, | ||
llvm::APInt(IntSize, Val, /*isSigned=*/false, /*implicitTrunc=*/true), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like some of the callers are passing in -1... probably the signature needs to be reworked. Okay to leave it for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've changed this to set isSigned=true and updated the signature to use int64_t instead of uint64_t to clarify that a signed value is expected. |
||
Context.IntTy, Loc); | ||
} | ||
|
||
static Expr *BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
llvm::APInt(CHAR_BIT, (uint8_t)Data->BinaryData.back())
, maybe?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, though I used
(unsigned char)
to matchCHAR_BIT
more closely.