[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 27 00:24:50 PDT 2021


rjmccall added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1984
+    auto checkTypeIsTypedef = [](auto &&checkTypeIsTypedef,
+                                 const auto Ty) -> bool {
+      bool isTypedef = false;
----------------
Hah.  The knot-tying here is really cute, but I think either just make it a static function somewhere in the file, or make it iterative instead of recursive.

...actually, I think it would be better to just make the computation in `getTypeInfo` preserve more information.  Make `TypeInfo` carry a three-valued enum instead of an `AlignIsRequired` flag:

```
enum class AlignRequirement {
  /// The alignment was not explicit in code.
  None,

  /// The alignment comes from an alignment attribute on a typedef.
  RequiredByTypedef,

  /// The alignment comes from an alignment attribute on a record type.
  RequiredByRecord,
};
```

You can add a method on `TypeInfo` to ask if the alignment is required for any reason and make all the existing clients use that instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107394



More information about the cfe-commits mailing list