[AST] Attempt to fix buildbot warnings + appease MSVC; NFCI
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Tue, 10 Apr 2018 01:11:26 +0000 (01:11 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Tue, 10 Apr 2018 01:11:26 +0000 (01:11 +0000)
GCC 4.8.4 on a bot was warning about `ArgPassingKind` not fitting in
`ArgPassingRestrictions`, which appears to be incorrect, since
`ArgPassingKind` only has three potential values:

"warning: 'clang::RecordDecl::ArgPassingRestrictions' is too small to
hold all values of 'enum clang::RecordDecl::ArgPassingKind'"

Additionally, I remember hearing (though my knowledge may be outdated)
that MSVC won't merge adjacent bitfields if their types are different.

Try to fix both issues by turning these into `uint8_t`s.

llvm-svn: 329652

clang/include/clang/AST/Decl.h

index 8dcf707..b0af51a 100644 (file)
@@ -3599,10 +3599,13 @@ private:
   /// Indicates whether this struct is destroyed in the callee. This flag is
   /// meaningless when Microsoft ABI is used since parameters are always
   /// destroyed in the callee.
-  bool ParamDestroyedInCallee : 1;
+  ///
+  /// Please note that MSVC won't merge adjacent bitfields if they don't have
+  /// the same type.
+  uint8_t ParamDestroyedInCallee : 1;
 
   /// Represents the way this type is passed to a function.
-  ArgPassingKind ArgPassingRestrictions : 2;
+  uint8_t ArgPassingRestrictions : 2;
 
 protected:
   RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
@@ -3691,15 +3694,15 @@ public:
   /// it must have at least one trivial, non-deleted copy or move constructor.
   /// FIXME: This should be set as part of completeDefinition.
   bool canPassInRegisters() const {
-    return ArgPassingRestrictions == APK_CanPassInRegs;
+    return getArgPassingRestrictions() == APK_CanPassInRegs;
   }
 
   ArgPassingKind getArgPassingRestrictions() const {
-    return ArgPassingRestrictions;
+    return static_cast<ArgPassingKind>(ArgPassingRestrictions);
   }
 
   void setArgPassingRestrictions(ArgPassingKind Kind) {
-    ArgPassingRestrictions = Kind;
+    ArgPassingRestrictions = static_cast<uint8_t>(Kind);
   }
 
   bool isParamDestroyedInCallee() const {