[PATCH] D38320: [clang] Fix serializers for `TypeTemplateParmDecl` + related types

Steve O'Brien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 6 09:35:24 PDT 2017


elsteveogrande added a comment.

Hi @bruno, @rsmith, does this approach look ok?

I couldn't easily figure out a better way to store inherited-default-info; doing it alongside the default value seemed the cleanest.

Note: I saw there are three ways to store these data inside the `DefaultArgStorage` struct, see here:
https://reviews.llvm.org/diffusion/L/browse/cfe/trunk/include/clang/AST/DeclTemplate.h;315074$272

There's (1) the default arg; (2) the reference to the `Decl` having the default arg (inherited by this `Decl`); and (3) a pointer to a `Chain` link, which is the case when modules are used.

The serializer already had (1) covered, and I'm adding (2) here.  Maybe the most proper fix is to handle (3) as well.  Although it seems no unit tests broke, so this is either ok as is, or there's no test for it :)

So: right now the serialization stream generated in `ASTWriterDecl.cpp` looks sort of like:

   [ . . . other fields]
  bool defaultArgFollows
  [Stmt defaultArgStmtRef (if above is true)]
  bool inheritedFromDeclFollows
  [Decl inheritedFromDecl (if above is true)]

This could be changed to:

   [ . . . other fields]
  bool isPartOfChain     <----- add this
  bool defaultArgFollows
  [Stmt defaultArgStmtRef (if above is true)]
  bool inheritedFromDeclFollows
  [Decl inheritedFromDecl (if above is true)]

so this can store the `DefaultArgStorage` with better fidelity.  Thoughts?

Thanks!  :)


Repository:
  rL LLVM

https://reviews.llvm.org/D38320





More information about the cfe-commits mailing list