[all-commits] [llvm/llvm-project] b6f03a: [NFC] Rename ClangASTEmitters.h -> ASTTableGen.h

John McCall via All-commits all-commits at lists.llvm.org
Fri Dec 13 21:24:23 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b6f03a5a6b57b7858098051e60c2ce2fd4058461
      https://github.com/llvm/llvm-project/commit/b6f03a5a6b57b7858098051e60c2ce2fd4058461
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    A clang/utils/TableGen/ASTTableGen.h
    R clang/utils/TableGen/ClangASTEmitters.h
    M clang/utils/TableGen/ClangASTNodesEmitter.cpp
    M clang/utils/TableGen/ClangAttrEmitter.cpp
    M clang/utils/TableGen/ClangTypeNodesEmitter.cpp
    M clang/utils/TableGen/TableGen.cpp

  Log Message:
  -----------
  [NFC] Rename ClangASTEmitters.h -> ASTTableGen.h


  Commit: a7950ffd12caa2fb7ed4704128011bceeacd35e9
      https://github.com/llvm/llvm-project/commit/a7950ffd12caa2fb7ed4704128011bceeacd35e9
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    M clang/utils/TableGen/ClangTypeNodesEmitter.cpp

  Log Message:
  -----------
  [NFC] Correct accidental use of tabs.


  Commit: 91dd67ef724c07f28d4cb52448539f12ad488f2a
      https://github.com/llvm/llvm-project/commit/91dd67ef724c07f28d4cb52448539f12ad488f2a
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    A clang/utils/TableGen/ASTTableGen.cpp
    M clang/utils/TableGen/ASTTableGen.h
    M clang/utils/TableGen/CMakeLists.txt
    M clang/utils/TableGen/ClangASTNodesEmitter.cpp
    M clang/utils/TableGen/ClangTypeNodesEmitter.cpp

  Log Message:
  -----------
  Introduce some types and functions to make it easier to work with
the tblgen AST node hierarchies.

Not totally NFC because both of the emitters now emit in a different
order.  The type-nodes emitter now visits nodes in hierarchy order,
which means we could use range checks in classof if we had any types
that would benefit from that; currently we do not.  The AST-nodes
emitter now uses a multimap keyed by the name of the record; previously
it was using `Record*`, which of couse isn't stable across processes
and may have led to non-reproducible builds in some circumstances.


  Commit: f39e1efaf5b0d4abb08bd042a3bae9a772836b5f
      https://github.com/llvm/llvm-project/commit/f39e1efaf5b0d4abb08bd042a3bae9a772836b5f
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    M clang/include/clang/AST/Type.h

  Log Message:
  -----------
  Add a function to get the ExceptionSpecInfo of a function type; NFC.


  Commit: 30066e522c94a193dbcae9bc4d4005f8a137bd4b
      https://github.com/llvm/llvm-project/commit/30066e522c94a193dbcae9bc4d4005f8a137bd4b
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    M clang/utils/TableGen/ASTTableGen.h

  Log Message:
  -----------
  Extract out WrappedRecord as a convenience base class; NFC.


  Commit: f6da0cf34a5a48bf8154067206980fff9b7a1975
      https://github.com/llvm/llvm-project/commit/f6da0cf34a5a48bf8154067206980fff9b7a1975
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    M clang/utils/TableGen/ASTTableGen.cpp
    M clang/utils/TableGen/ASTTableGen.h
    M clang/utils/TableGen/ClangTypeNodesEmitter.cpp

  Log Message:
  -----------
  Enable better node-hierarchy metaprogramming; NFC.


  Commit: 139006ceb641f038a2b19cac1174316e57004ed6
      https://github.com/llvm/llvm-project/commit/139006ceb641f038a2b19cac1174316e57004ed6
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    M clang/include/clang/Serialization/ASTBitCodes.h
    A clang/include/clang/Serialization/TypeBitCodes.def

  Log Message:
  -----------
  Extract the TypeClass <-> TypeCode map into a .def file; NFC.


  Commit: 3ce3d23facf146698c4ef6107d1b9425b3ff5764
      https://github.com/llvm/llvm-project/commit/3ce3d23facf146698c4ef6107d1b9425b3ff5764
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    M clang/include/clang/Serialization/ASTReader.h
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/lib/Serialization/ASTReaderStmt.cpp
    M clang/utils/TableGen/ClangAttrEmitter.cpp

  Log Message:
  -----------
  Standardize the reader methods in ASTReader; NFC.

There are three significant changes here:

- Most of the methods to read various embedded structures (`APInt`,
  `NestedNameSpecifier`, `DeclarationName`, etc.) have been moved
  from `ASTReader` to `ASTRecordReader`.  This cleans up quite a
  bit of code which was passing around `(F, Record, Idx)` arguments
  everywhere or doing explicit indexing, and it nicely parallels
  how it works on the writer side.  It also sets us up to then move
  most of these methods into the `BasicReader`s that I'm introducing
  as part of abstract serialization.

  As part of this, several of the top-level reader methods (e.g.
  `readTypeRecord`) have been converted to use `ASTRecordReader`
  internally, which is a nice readability improvement.

- I've standardized most of these method names on `readFoo` rather
  than `ReadFoo` (used in some of the helper structures) or `GetFoo`
  (used for some specific types for no apparent reason).

- I've changed a few of these methods to return their result instead
  of reading into an argument passed by reference.  This is partly
  for general consistency and partly because it will make the
  metaprogramming easier with abstract serialization.


  Commit: 6404bd236240639d4986d1ee634ded4bc81d8bd8
      https://github.com/llvm/llvm-project/commit/6404bd236240639d4986d1ee634ded4bc81d8bd8
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    M clang/include/clang/AST/CMakeLists.txt
    A clang/include/clang/AST/PropertiesBase.td
    M clang/include/clang/Basic/DeclNodes.td
    M clang/include/clang/Basic/StmtNodes.td
    M clang/include/clang/Basic/TypeNodes.td
    M clang/utils/TableGen/ASTTableGen.cpp
    M clang/utils/TableGen/ASTTableGen.h
    M clang/utils/TableGen/CMakeLists.txt
    A clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
    M clang/utils/TableGen/TableGen.cpp
    M clang/utils/TableGen/TableGenBackends.h

  Log Message:
  -----------
  Abstract serialization: TableGen "basic" reader/writer CRTP
classes that serialize basic values


  Commit: d505e57cc273750541ec8bbce2065b8b87c99ad6
      https://github.com/llvm/llvm-project/commit/d505e57cc273750541ec8bbce2065b8b87c99ad6
  Author: John McCall <rjmccall at apple.com>
  Date:   2019-12-14 (Sat, 14 Dec 2019)

  Changed paths:
    M clang/include/clang/AST/ASTContext.h
    A clang/include/clang/AST/AbstractBasicReader.h
    A clang/include/clang/AST/AbstractBasicWriter.h
    A clang/include/clang/AST/AbstractTypeReader.h
    A clang/include/clang/AST/AbstractTypeWriter.h
    M clang/include/clang/AST/CMakeLists.txt
    M clang/include/clang/AST/Type.h
    A clang/include/clang/AST/TypeProperties.td
    M clang/include/clang/Serialization/ASTReader.h
    M clang/include/clang/Serialization/ASTWriter.h
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTWriter.cpp
    M clang/utils/TableGen/TableGen.cpp

  Log Message:
  -----------
  Abstract serialization: TableGen the (de)serialization code for Types.

The basic technical design here is that we have three levels
of readers and writers:

- At the lowest level, there's a `Basic{Reader,Writer}` that knows
  how to emit the basic structures of the AST.  CRTP allows this to
  be metaprogrammed so that the client only needs to support a handful
  of primitive types (e.g. `uint64_t` and `IdentifierInfo*`) and more
  complicated "inline" structures such as `DeclarationName` can just
  be emitted in terms of those primitives.

  In Clang's binary-serialization code, these are
  `ASTRecord{Reader,Writer}`.  For now, a large number of basic
  structures are still emitted explicitly by code on those classes
  rather than by either TableGen or CRTP metaprogramming, but I
  expect to move more of these over.

- In the middle, there's a `Property{Reader,Writer}` which is
  responsible for processing the properties of a larger object.  The
  object-level reader/writer asks the property-level reader/writer to
  project out a particular property, yielding a basic reader/writer
  which will be used to read/write the property's value, like so:

  ```
    propertyWriter.find("count").writeUInt32(node->getCount());
  ```

  Clang's binary-serialization code ignores this level (it uses
  the basic reader/writer as the property reader/writer and has the
  projection methods just return `*this`) and simply relies on the
  roperties being read/written in a stable order.

- At the highest level, there's an object reader/writer (e.g.
  `Type{Reader,Writer}` which emits a logical object with properties.
  Think of this as writing something like a JSON dictionary literal.

I haven't introduced support for bitcode abbreviations yet --- it
turns out that there aren't any operative abbreviations for types
besides the QualType one --- but I do have some ideas of how they
should work.  At any rate, they'll be necessary in order to handle
statements.

I'm sorry for not disentangling the patches that added basic and type
reader/writers; I made some effort to, but I ran out of energy after
disentangling a number of other patches from the work.

Negligible impact on module size, time to build a set of about 20
fairly large modules, or time to read a few declarations out of them.


Compare: https://github.com/llvm/llvm-project/compare/5d34602da452...d505e57cc273


More information about the All-commits mailing list