[PATCH] D23657: Remove some false positives when taking the address of packed members

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 30 14:43:55 PDT 2016


aaron.ballman added a comment.

Some minor nits; @rsmith may have more substantial comments.


================
Comment at: lib/Sema/SemaChecking.cpp:11039
@@ -11036,2 +11038,3 @@
     std::function<void(Expr *, RecordDecl *, ValueDecl *, CharUnits)> Action) {
+  // return;
   const auto *ME = dyn_cast<MemberExpr>(E);
----------------
Spurious comment.

================
Comment at: lib/Sema/SemaChecking.cpp:11049
@@ -11044,5 +11048,3 @@
     ValueDecl *MD = ME->getMemberDecl();
-    bool ByteAligned = Context.getTypeAlignInChars(MD->getType()).isOne();
-    if (ByteAligned) // Attribute packed does not have any effect.
-      break;
+    auto AlignField = Context.getTypeAlignInChars(MD->getType());
 
----------------
Please don't use auto here as the type is not spelled out in the initialization.

================
Comment at: lib/Sema/SemaChecking.cpp:11053
@@ +11052,3 @@
+    if (RD->hasAttr<PackedAttr>() || MD->hasAttr<PackedAttr>()) {
+      auto AlignRecord = Context.getTypeAlignInChars(BaseType);
+      if ((RequiredAlignment > AlignRecord) ||
----------------
Don't use auto here either.


https://reviews.llvm.org/D23657





More information about the cfe-commits mailing list