@@ -638,20 +638,54 @@ class BooleanLiteral extends Literal, @booleanliteral {
638638 override string getAPrimaryQlClass ( ) { result = "BooleanLiteral" }
639639}
640640
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+ */
642656class IntegerLiteral extends Literal , @integerliteral {
643657 /** Gets the int representation of this literal. */
644658 int getIntValue ( ) { result = getValue ( ) .toInt ( ) }
645659
646660 override string getAPrimaryQlClass ( ) { result = "IntegerLiteral" }
647661}
648662
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+ */
650679class LongLiteral extends Literal , @longliteral {
651680 override string getAPrimaryQlClass ( ) { result = "LongLiteral" }
652681}
653682
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+ */
655689class FloatingPointLiteral extends Literal , @floatingpointliteral {
656690 /**
657691 * Gets the value of this literal as CodeQL 64-bit `float`. The value will
@@ -662,7 +696,12 @@ class FloatingPointLiteral extends Literal, @floatingpointliteral {
662696 override string getAPrimaryQlClass ( ) { result = "FloatingPointLiteral" }
663697}
664698
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+ */
666705class DoubleLiteral extends Literal , @doubleliteral {
667706 /**
668707 * Gets the value of this literal as CodeQL 64-bit `float`. The result will
0 commit comments