From: Douglas Gregor Date: Wed, 3 Jun 2009 18:26:16 +0000 (+0000) Subject: Document the PCH representation of statements and expressions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe3f223de8d670cdfdb1f362242c2b952e1c5f34;p=clang Document the PCH representation of statements and expressions git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72790 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/PCHInternals.html b/docs/PCHInternals.html index 6923f928a4..f1cfeb3673 100644 --- a/docs/PCHInternals.html +++ b/docs/PCHInternals.html @@ -103,8 +103,8 @@ below.

The metadata block contains several records that provide information about how the precompiled header was built. This metadata is primarily used to validate the use of a precompiled header. For -example, a precompiled header built for x86 (32-bit) cannot be used -when compiling for x86-64 (64-bit). The metadata block contains +example, a precompiled header built for a 32-bit x86 target cannot be used +when compiling for a 64-bit x86 target. The metadata block contains information about:

@@ -292,7 +292,32 @@ function.

in Clang's abstract syntax tree (ForStmt, CallExpr, etc.) has a corresponding record type in the precompiled header, which contains the serialized representation of -that statement or expression.

+that statement or expression. Each substatement or subexpression +within an expression is stored as a separate record (which keeps most +records to a fixed size). Within the precompiled header, the +subexpressions of an expression are stored prior to the expression +that owns those expression, using a form of Reverse +Polish Notation. For example, an expression 3 - 4 + 5 +would be represented as follows:

+ + + + + + + + +
IntegerLiteral(3)
IntegerLiteral(4)
BinaryOperator(-)
IntegerLiteral(5)
BinaryOperator(+)
STOP
+ +

When reading this representation, Clang evaluates each expression +record it encounters, builds the appropriate abstract synax tree node, +and then pushes that expression on to a stack. When a record contains N +subexpressions--BinaryOperator has two of them--those +expressions are popped from the top of the stack. The special STOP +code indicates that we have reached the end of a serialized expression +or statement; other expression or statement records may follow, but +they are part of a different expression.

Identifier Table Block