Skip to content

Properly interpolate negative AP literals #11286

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

Merged
merged 1 commit into from
Aug 1, 2017

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Aug 1, 2017

Integer and Floating literals are aware of their negation but
do not store the sign in the text of the value. Retrieve the
sign bit and properly interpolate the text of the literal value
with it to distinguish negative and positive literals.

Includes a bit of cleanup in IRGen too.

Integer and Floating literals are aware of their negation but
do not store the sign in the text of the value.  Retrieve the
sign bit and properly interpolate the text of the literal value
with it to distinguish negative and positive literals.
@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 1, 2017

@swift-ci please smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 1, 2017

#11288 Will unblock the bots.

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 1, 2017

@swift-ci please smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 1, 2017

@swift-ci please test and merge

@swift-ci swift-ci merged commit 9328a43 into swiftlang:master Aug 1, 2017
@CodaFi CodaFi deleted the a-distinctly-negative-attitude branch August 1, 2017 21:15
@@ -893,7 +893,7 @@ class IntegerLiteralExpr : public NumberLiteralExpr {
{}

APInt getValue() const;
static APInt getValue(StringRef Text, unsigned BitWidth);
static APInt getValue(StringRef Text, unsigned BitWidth, bool Negative);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you 're going to store a sign you should use APSInt.


if (intExpr->isNegative())
intValue = -intValue;
intType->getBitWidth(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember offhand but I think you need an extra bit for the negative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants