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