[PATCH] D158288: [LangRef] Document integer hexadecimal constants

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 08:41:12 PDT 2023


luke created this revision.
luke added reviewers: spatel, arsenm, vitalybuka, nikic.
Herald added subscribers: asb, pmatos, StephenFan, jdoerfert.
Herald added a project: All.
luke requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

It's possible to write an integer constant in hexadecimal, but you need to
prefix it with u or s. I couldn't find this mentioned anywhere in the LangRef,
so this adds a small note about it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158288

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -4093,9 +4093,12 @@
     The two strings '``true``' and '``false``' are both valid constants
     of the ``i1`` type.
 **Integer constants**
-    Standard integers (such as '4') are constants of the
-    :ref:`integer <t_integer>` type. Negative numbers may be used with
-    integer types.
+    Standard integers (such as '4') are constants of the :ref:`integer
+    <t_integer>` type. They can be either decimal or
+    hexadecimal. Decimal integers can be prefixed with - to represent
+    negative integers, whilst hexadecimal integers must be prefixed
+    with either u or s to indicate whether they are unsigned or signed
+    respectively, e.g u0x1234.
 **Floating-point constants**
     Floating-point constants use standard decimal notation (e.g.
     123.421), exponential notation (e.g. 1.23421e+2), or a more precise


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158288.551529.patch
Type: text/x-patch
Size: 982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230818/a8a6f670/attachment.bin>


More information about the llvm-commits mailing list