Skip to content

Commit 770fd38

Browse files
authored
[LangRef] Document string literals in LLVM's format (#82529)
1 parent afa8a2e commit 770fd38

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

llvm/docs/LangRef.rst

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ run by the parser after parsing input assembly and by the optimizer
6161
before it outputs bitcode. The violations pointed out by the verifier
6262
pass indicate bugs in transformation passes or input to the parser.
6363

64+
Syntax
65+
======
66+
6467
.. _identifiers:
6568

6669
Identifiers
67-
===========
70+
-----------
6871

6972
LLVM identifiers come in two basic types: global and local. Global
7073
identifiers (functions, global variables) begin with the ``'@'``
@@ -140,6 +143,34 @@ It also shows a convention that we follow in this document. When
140143
demonstrating instructions, we will follow an instruction with a comment
141144
that defines the type and name of value produced.
142145

146+
.. _strings:
147+
148+
String constants
149+
----------------
150+
151+
Strings in LLVM programs are delimited by ``"`` characters. Within a
152+
string, all bytes are treated literally with the exception of ``\``
153+
characters, which start escapes, and the first ``"`` character, which
154+
ends the string.
155+
156+
There are two kinds of escapes.
157+
158+
* ``\\`` represents a single ``\`` character.
159+
160+
* ``\`` followed by two hexadecimal characters (0-9, a-f, or A-F)
161+
represents the byte with the given value (e.g. \x00 represents a
162+
null byte).
163+
164+
To represent a ``"`` character, use ``\22``. (``\"`` will end the string
165+
with a trailing ``\``.)
166+
167+
Newlines do not terminate string constants; strings can span multiple
168+
lines.
169+
170+
The interpretation of string constants (e.g. their character encoding)
171+
depends on context.
172+
173+
143174
High Level Structure
144175
====================
145176

0 commit comments

Comments
 (0)