[llvm] 770fd38 - [LangRef] Document string literals in LLVM's format (#82529)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 05:35:27 PST 2024


Author: Ian Hickson
Date: 2024-02-22T14:35:23+01:00
New Revision: 770fd3856660fea6cbaa78d9cb1f03cc92611783

URL: https://github.com/llvm/llvm-project/commit/770fd3856660fea6cbaa78d9cb1f03cc92611783
DIFF: https://github.com/llvm/llvm-project/commit/770fd3856660fea6cbaa78d9cb1f03cc92611783.diff

LOG: [LangRef] Document string literals in LLVM's format (#82529)

Added: 
    

Modified: 
    llvm/docs/LangRef.rst

Removed: 
    


################################################################################
diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index fd2e3aacd0169c..8f4495e25d0fa2 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -61,10 +61,13 @@ run by the parser after parsing input assembly and by the optimizer
 before it outputs bitcode. The violations pointed out by the verifier
 pass indicate bugs in transformation passes or input to the parser.
 
+Syntax
+======
+
 .. _identifiers:
 
 Identifiers
-===========
+-----------
 
 LLVM identifiers come in two basic types: global and local. Global
 identifiers (functions, global variables) begin with the ``'@'``
@@ -140,6 +143,34 @@ It also shows a convention that we follow in this document. When
 demonstrating instructions, we will follow an instruction with a comment
 that defines the type and name of value produced.
 
+.. _strings:
+
+String constants
+----------------
+
+Strings in LLVM programs are delimited by ``"`` characters. Within a
+string, all bytes are treated literally with the exception of ``\``
+characters, which start escapes, and the first ``"`` character, which
+ends the string.
+
+There are two kinds of escapes.
+
+* ``\\`` represents a single ``\`` character.
+
+* ``\`` followed by two hexadecimal characters (0-9, a-f, or A-F)
+  represents the byte with the given value (e.g. \x00 represents a
+  null byte).
+
+To represent a ``"`` character, use ``\22``. (``\"`` will end the string
+with a trailing ``\``.)
+
+Newlines do not terminate string constants; strings can span multiple
+lines.
+
+The interpretation of string constants (e.g. their character encoding)
+depends on context.
+
+
 High Level Structure
 ====================
 


        


More information about the llvm-commits mailing list