@@ -638,20 +638,54 @@ class BooleanLiteral extends Literal, @booleanliteral {
638
638
override string getAPrimaryQlClass ( ) { result = "BooleanLiteral" }
639
639
}
640
640
641
- /** An integer literal. For example, `23`. */
641
+ /**
642
+ * An integer literal. For example, `23`.
643
+ *
644
+ * An integer literal can never be negative except when:
645
+ * - It is written in binary, octal or hexadecimal notation
646
+ * - It is written in decimal notation, has the value `2147483648` and is preceded
647
+ * by a minus; in this case the value of the IntegerLiteral is -2147483648 and
648
+ * the preceding minus will *not* be modeled as `MinusExpr`.
649
+ *
650
+ * In all other cases the preceding minus, if any, will be modeled as a separate
651
+ * `MinusExpr`.
652
+ *
653
+ * The last exception is necessary because `2147483648` on its own would not be
654
+ * a valid integer literal (and could also not be parsed as CodeQL `int`).
655
+ */
642
656
class IntegerLiteral extends Literal , @integerliteral {
643
657
/** Gets the int representation of this literal. */
644
658
int getIntValue ( ) { result = getValue ( ) .toInt ( ) }
645
659
646
660
override string getAPrimaryQlClass ( ) { result = "IntegerLiteral" }
647
661
}
648
662
649
- /** A long literal. For example, `23l`. */
663
+ /**
664
+ * A long literal. For example, `23L`.
665
+ *
666
+ * A long literal can never be negative except when:
667
+ * - It is written in binary, octal or hexadecimal notation
668
+ * - It is written in decimal notation, has the value `9223372036854775808` and
669
+ * is preceded by a minus; in this case the value of the LongLiteral is
670
+ * -9223372036854775808 and the preceding minus will *not* be modeled as
671
+ * `MinusExpr`.
672
+ *
673
+ * In all other cases the preceding minus, if any, will be modeled as a separate
674
+ * `MinusExpr`.
675
+ *
676
+ * The last exception is necessary because `9223372036854775808` on its own
677
+ * would not be a valid long literal.
678
+ */
650
679
class LongLiteral extends Literal , @longliteral {
651
680
override string getAPrimaryQlClass ( ) { result = "LongLiteral" }
652
681
}
653
682
654
- /** A floating point literal. For example, `4.2f`. */
683
+ /**
684
+ * A float literal. For example, `4.2f`.
685
+ *
686
+ * A float literal is never negative; a preceding minus, if any, will always
687
+ * be modeled as separate `MinusExpr`.
688
+ */
655
689
class FloatingPointLiteral extends Literal , @floatingpointliteral {
656
690
/**
657
691
* Gets the value of this literal as CodeQL 64-bit `float`. The value will
@@ -662,7 +696,12 @@ class FloatingPointLiteral extends Literal, @floatingpointliteral {
662
696
override string getAPrimaryQlClass ( ) { result = "FloatingPointLiteral" }
663
697
}
664
698
665
- /** A double literal. For example, `4.2`. */
699
+ /**
700
+ * A double literal. For example, `4.2`.
701
+ *
702
+ * A double literal is never negative; a preceding minus, if any, will always
703
+ * be modeled as separate `MinusExpr`.
704
+ */
666
705
class DoubleLiteral extends Literal , @doubleliteral {
667
706
/**
668
707
* Gets the value of this literal as CodeQL 64-bit `float`. The result will
0 commit comments