[PATCH] D69903: [Basic] Introduce PODSourceLocation, NFCI

Mikhail Maltsev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 20 09:13:55 PDT 2020


miyuki added a comment.

In D69903#2340020 <https://reviews.llvm.org/D69903#2340020>, @dexonsmith wrote:

> An alternative would be to update the unions to an `AlignedCharArrayUnion` and use `SourceLocation` directly. WDYT?

So, say, in `DeclarationNameLoc`, I would add `AlignedCharArrayUnion` as follows:

  union {
    llvm::AlignedCharArrayUnion<struct NT, struct CXXOpName, struct CXXLitOpName> UninitStorage;
    struct NT NamedType;
    struct CXXOpName CXXOperatorName;
    struct CXXLitOpName CXXLiteralOperatorName;
  };

And change the constructor of `DeclarationNameLoc` to default-construct `UninitStorage`, i.e.:

  DeclarationNameLoc() : UninitStorage() {
    memset(UninitStorage.buffer, 0, sizeof(UninitStorage.buffer));
  }

After that, I can use `SourceLocation` in `DeclarationNameLoc` directly.

Do I understand your idea correctly?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69903/new/

https://reviews.llvm.org/D69903



More information about the cfe-commits mailing list