r177133 - Silence anonymous type in anonymous union warnings.

Eric Christopher echristo at gmail.com
Thu Mar 14 17:32:53 PDT 2013


Author: echristo
Date: Thu Mar 14 19:32:52 2013
New Revision: 177133

URL: http://llvm.org/viewvc/llvm-project?rev=177133&view=rev
Log:
Silence anonymous type in anonymous union warnings.

Modified:
    cfe/trunk/include/clang/AST/DeclTemplate.h
    cfe/trunk/include/clang/AST/DeclarationName.h
    cfe/trunk/include/clang/AST/DependentDiagnostic.h
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/include/clang/AST/TemplateBase.h
    cfe/trunk/include/clang/AST/TemplateName.h
    cfe/trunk/include/clang/Sema/DeclSpec.h
    cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
    cfe/trunk/include/clang/Sema/Initialization.h

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=177133&r1=177132&r2=177133&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu Mar 14 19:32:52 2013
@@ -458,18 +458,19 @@ public:
 ///   };
 /// \endcode
 class DependentFunctionTemplateSpecializationInfo {
+  struct CA {
+    /// The number of potential template candidates.
+    unsigned NumTemplates;
+
+    /// The number of template arguments.
+    unsigned NumArgs;
+  };
+
   union {
     // Force sizeof to be a multiple of sizeof(void*) so that the
     // trailing data is aligned.
     void *Aligner;
-
-    struct {
-      /// The number of potential template candidates.
-      unsigned NumTemplates;
-
-      /// The number of template arguments.
-      unsigned NumArgs;
-    } d;
+    struct CA d;
   };
 
   /// The locations of the left and right angle brackets.

Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=177133&r1=177132&r2=177133&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Thu Mar 14 19:32:52 2013
@@ -382,32 +382,35 @@ public:
 /// for a declaration name. Needs a DeclarationName in order
 /// to be interpreted correctly.
 struct DeclarationNameLoc {
-  union {
-    // The source location for identifier stored elsewhere.
-    // struct {} Identifier;
+  // The source location for identifier stored elsewhere.
+  // struct {} Identifier;
 
-    // Type info for constructors, destructors and conversion functions.
-    // Locations (if any) for the tilde (destructor) or operator keyword
-    // (conversion) are stored elsewhere.
-    struct {
-      TypeSourceInfo* TInfo;
-    } NamedType;
+  // Type info for constructors, destructors and conversion functions.
+  // Locations (if any) for the tilde (destructor) or operator keyword
+  // (conversion) are stored elsewhere.
+  struct NT {
+    TypeSourceInfo* TInfo;
+  };
 
-    // The location (if any) of the operator keyword is stored elsewhere.
-    struct {
-      unsigned BeginOpNameLoc;
-      unsigned EndOpNameLoc;
-    } CXXOperatorName;
+  // The location (if any) of the operator keyword is stored elsewhere.
+  struct CXXOpName {
+    unsigned BeginOpNameLoc;
+    unsigned EndOpNameLoc;
+  };
 
-    // The location (if any) of the operator keyword is stored elsewhere.
-    struct {
-      unsigned OpNameLoc;
-    } CXXLiteralOperatorName;
+  // The location (if any) of the operator keyword is stored elsewhere.
+  struct CXXLitOpName {
+    unsigned OpNameLoc;
+  };
 
-    // struct {} CXXUsingDirective;
-    // struct {} ObjCZeroArgSelector;
-    // struct {} ObjCOneArgSelector;
-    // struct {} ObjCMultiArgSelector;
+  // struct {} CXXUsingDirective;
+  // struct {} ObjCZeroArgSelector;
+  // struct {} ObjCOneArgSelector;
+  // struct {} ObjCMultiArgSelector;
+  union {
+    struct NT NamedType;
+    struct CXXOpName CXXOperatorName;
+    struct CXXLitOpName CXXLiteralOperatorName;
   };
 
   DeclarationNameLoc(DeclarationName Name);

Modified: cfe/trunk/include/clang/AST/DependentDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DependentDiagnostic.h?rev=177133&r1=177132&r2=177133&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DependentDiagnostic.h (original)
+++ cfe/trunk/include/clang/AST/DependentDiagnostic.h Thu Mar 14 19:32:52 2013
@@ -108,16 +108,14 @@ private:
 
   PartialDiagnostic Diag;
 
-  union {
-    struct {
-      unsigned Loc;
-      unsigned Access : 2;
-      unsigned IsMember : 1;
-      NamedDecl *TargetDecl;
-      CXXRecordDecl *NamingClass;
-      void *BaseObjectType;
-    } AccessData;
-  };
+  struct {
+    unsigned Loc;
+    unsigned Access : 2;
+    unsigned IsMember : 1;
+    NamedDecl *TargetDecl;
+    CXXRecordDecl *NamingClass;
+    void *BaseObjectType;
+  } AccessData;
 };
 
 /// 

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=177133&r1=177132&r2=177133&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Mar 14 19:32:52 2013
@@ -60,18 +60,21 @@ struct SubobjectAdjustment {
     MemberPointerAdjustment
   } Kind;
 
-   union {
-    struct {
-      const CastExpr *BasePath;
-      const CXXRecordDecl *DerivedClass;
-    } DerivedToBase;
 
-    FieldDecl *Field;
+  struct DTB {
+    const CastExpr *BasePath;
+    const CXXRecordDecl *DerivedClass;
+  };
 
-    struct {
-      const MemberPointerType *MPT;
-      Expr *RHS;
-    } Ptr;
+  struct P {
+    const MemberPointerType *MPT;
+    Expr *RHS;
+  };
+
+  union {
+    struct DTB DerivedToBase;
+    FieldDecl *Field;
+    struct P Ptr;
   };
 
   SubobjectAdjustment(const CastExpr *BasePath,

Modified: cfe/trunk/include/clang/AST/TemplateBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateBase.h?rev=177133&r1=177132&r2=177133&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TemplateBase.h (original)
+++ cfe/trunk/include/clang/AST/TemplateBase.h Thu Mar 14 19:32:52 2013
@@ -72,32 +72,36 @@ private:
   /// \brief The kind of template argument we're storing.
   unsigned Kind;
 
+  struct DA {
+    ValueDecl *D;
+    bool ForRefParam;
+  };
+  struct I {
+    // We store a decomposed APSInt with the data allocated by ASTContext if
+    // BitWidth > 64. The memory may be shared between multiple
+    // TemplateArgument instances.
+    union {
+      uint64_t VAL;          ///< Used to store the <= 64 bits integer value.
+      const uint64_t *pVal;  ///< Used to store the >64 bits integer value.
+    };
+    unsigned BitWidth : 31;
+    unsigned IsUnsigned : 1;
+    void *Type;
+  };
+  struct A {
+    const TemplateArgument *Args;
+    unsigned NumArgs;
+  };
+  struct TA {
+    void *Name;
+    unsigned NumExpansions;
+  };
   union {
+    struct DA DeclArg;
+    struct I Integer;
+    struct A Args;
+    struct TA TemplateArg;
     uintptr_t TypeOrValue;
-    struct {
-      ValueDecl *D;
-      bool ForRefParam;
-    } DeclArg;
-    struct {
-      // We store a decomposed APSInt with the data allocated by ASTContext if
-      // BitWidth > 64. The memory may be shared between multiple
-      // TemplateArgument instances.
-      union {
-        uint64_t VAL;          ///< Used to store the <= 64 bits integer value.
-        const uint64_t *pVal;  ///< Used to store the >64 bits integer value.
-      };
-      unsigned BitWidth : 31;
-      unsigned IsUnsigned : 1;
-      void *Type;
-    } Integer;
-    struct {
-      const TemplateArgument *Args;
-      unsigned NumArgs;
-    } Args;
-    struct {
-      void *Name;
-      unsigned NumExpansions;
-    } TemplateArg;
   };
 
   TemplateArgument(TemplateName, bool) LLVM_DELETED_FUNCTION;
@@ -341,17 +345,20 @@ public:
 /// Location information for a TemplateArgument.
 struct TemplateArgumentLocInfo {
 private:
+
+  struct T {
+    // FIXME: We'd like to just use the qualifier in the TemplateName,
+    // but template arguments get canonicalized too quickly.
+    NestedNameSpecifier *Qualifier;
+    void *QualifierLocData;
+    unsigned TemplateNameLoc;
+    unsigned EllipsisLoc;
+  };
+
   union {
+    struct T Template;
     Expr *Expression;
     TypeSourceInfo *Declarator;
-    struct {
-      // FIXME: We'd like to just use the qualifier in the TemplateName,
-      // but template arguments get canonicalized too quickly.
-      NestedNameSpecifier *Qualifier;
-      void *QualifierLocData;
-      unsigned TemplateNameLoc;
-      unsigned EllipsisLoc;
-    } Template;
   };
 
 public:

Modified: cfe/trunk/include/clang/AST/TemplateName.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateName.h?rev=177133&r1=177132&r2=177133&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TemplateName.h (original)
+++ cfe/trunk/include/clang/AST/TemplateName.h Thu Mar 14 19:32:52 2013
@@ -46,16 +46,17 @@ protected:
     SubstTemplateTemplateParmPack
   };
 
-  union {
-    struct {
-      /// \brief A Kind.
-      unsigned Kind : 2;
-      
-      /// \brief The number of stored templates or template arguments,
-      /// depending on which subclass we have.
-      unsigned Size : 30;
-    } Bits;
+  struct BitsTag {
+    /// \brief A Kind.
+    unsigned Kind : 2;
     
+    /// \brief The number of stored templates or template arguments,
+    /// depending on which subclass we have.
+    unsigned Size : 30;
+  };
+
+  union {
+    struct BitsTag Bits;
     void *PointerAlignment;
   };
   

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=177133&r1=177132&r2=177133&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Thu Mar 14 19:32:52 2013
@@ -821,6 +821,20 @@ public:
     IK_ImplicitSelfParam
   } Kind;
 
+  struct OFI {
+    /// \brief The kind of overloaded operator.
+    OverloadedOperatorKind Operator;
+
+    /// \brief The source locations of the individual tokens that name
+    /// the operator, e.g., the "new", "[", and "]" tokens in 
+    /// operator new []. 
+    ///
+    /// Different operators have different numbers of tokens in their name,
+    /// up to three. Any remaining source locations in this array will be
+    /// set to an invalid value for operators with fewer than three tokens.
+    unsigned SymbolLocations[3];
+  };
+
   /// \brief Anonymous union that holds extra data associated with the
   /// parsed unqualified-id.
   union {
@@ -830,19 +844,7 @@ public:
     
     /// \brief When Kind == IK_OperatorFunctionId, the overloaded operator
     /// that we parsed.
-    struct {
-      /// \brief The kind of overloaded operator.
-      OverloadedOperatorKind Operator;
-      
-      /// \brief The source locations of the individual tokens that name
-      /// the operator, e.g., the "new", "[", and "]" tokens in 
-      /// operator new []. 
-      ///
-      /// Different operators have different numbers of tokens in their name,
-      /// up to three. Any remaining source locations in this array will be
-      /// set to an invalid value for operators with fewer than three tokens.
-      unsigned SymbolLocations[3];
-    } OperatorFunctionId;
+    struct OFI OperatorFunctionId;
     
     /// \brief When Kind == IK_ConversionFunctionId, the type that the 
     /// conversion function names.

Modified: cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DelayedDiagnostic.h?rev=177133&r1=177132&r2=177133&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DelayedDiagnostic.h (original)
+++ cfe/trunk/include/clang/Sema/DelayedDiagnostic.h Thu Mar 14 19:32:52 2013
@@ -199,21 +199,25 @@ public:
   }
   
 private:
-  union {
-    /// Deprecation.
-    struct {
-      const NamedDecl *Decl;
-      const ObjCInterfaceDecl *UnknownObjCClass;
-      const ObjCPropertyDecl  *ObjCProperty;
-      const char *Message;
-      size_t MessageLen;
-    } DeprecationData;
 
-    struct {
-      unsigned Diagnostic;
-      unsigned Argument;
-      void *OperandType;
-    } ForbiddenTypeData;
+  struct DD {
+    const NamedDecl *Decl;
+    const ObjCInterfaceDecl *UnknownObjCClass;
+    const ObjCPropertyDecl  *ObjCProperty;
+    const char *Message;
+    size_t MessageLen;
+  };
+
+  struct FTD {
+    unsigned Diagnostic;
+    unsigned Argument;
+    void *OperandType;
+  };
+
+  union {
+    /// Deprecation
+    struct DD DeprecationData;
+    struct FTD ForbiddenTypeData;
 
     /// Access control.
     char AccessData[sizeof(AccessedEntity)];

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=177133&r1=177132&r2=177133&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Thu Mar 14 19:32:52 2013
@@ -88,7 +88,27 @@ private:
 
   /// \brief The type of the object or reference being initialized.
   QualType Type;
-  
+
+  struct LN {
+    /// \brief When Kind == EK_Result, EK_Exception, EK_New, the
+    /// location of the 'return', 'throw', or 'new' keyword,
+    /// respectively. When Kind == EK_Temporary, the location where
+    /// the temporary is being created.
+    unsigned Location;
+
+    /// \brief Whether the entity being initialized may end up using the
+    /// named return value optimization (NRVO).
+    bool NRVO;
+  };
+
+  struct C {
+    /// \brief The variable being captured by an EK_LambdaCapture.
+    VarDecl *Var;
+
+    /// \brief The source location at which the capture occurs.
+    unsigned Location;
+  };
+
   union {
     /// \brief When Kind == EK_Variable, or EK_Member, the VarDecl or
     /// FieldDecl, respectively.
@@ -101,18 +121,8 @@ private:
     /// \brief When Kind == EK_Temporary, the type source information for
     /// the temporary.
     TypeSourceInfo *TypeInfo;
-    
-    struct {
-      /// \brief When Kind == EK_Result, EK_Exception, EK_New, the
-      /// location of the 'return', 'throw', or 'new' keyword,
-      /// respectively. When Kind == EK_Temporary, the location where
-      /// the temporary is being created.
-      unsigned Location;
-      
-      /// \brief Whether the entity being initialized may end up using the
-      /// named return value optimization (NRVO).
-      bool NRVO;
-    } LocAndNRVO;
+
+    struct LN LocAndNRVO;
     
     /// \brief When Kind == EK_Base, the base specifier that provides the 
     /// base class. The lower bit specifies whether the base is an inherited
@@ -123,14 +133,8 @@ private:
     /// EK_ComplexElement, the index of the array or vector element being
     /// initialized. 
     unsigned Index;
-    
-    struct {
-      /// \brief The variable being captured by an EK_LambdaCapture.
-      VarDecl *Var;
-      
-      /// \brief The source location at which the capture occurs.
-      unsigned Location;
-    } Capture;
+
+    struct C Capture;
   };
 
   InitializedEntity() { }
@@ -639,7 +643,13 @@ public:
     
     // \brief The type that results from this initialization.
     QualType Type;
-    
+
+    struct F {
+      bool HadMultipleCandidates;
+      FunctionDecl *Function;
+      DeclAccessPair FoundDecl;
+    };
+
     union {
       /// \brief When Kind == SK_ResolvedOverloadedFunction or Kind ==
       /// SK_UserConversion, the function that the expression should be 
@@ -651,11 +661,7 @@ public:
       /// selected from an overloaded set having size greater than 1.
       /// For conversion decls, the naming class is the source type.
       /// For construct decls, the naming class is the target type.
-      struct {
-        bool HadMultipleCandidates;
-        FunctionDecl *Function;
-        DeclAccessPair FoundDecl;
-      } Function;
+      struct F Function;
 
       /// \brief When Kind = SK_ConversionSequence, the implicit conversion
       /// sequence.





More information about the cfe-commits mailing list