]> granicus.if.org Git - clang/commitdiff
Partially revert "Replace custom alignment enforcement with LLVM_ALIGNAS."
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 2 Apr 2015 12:43:31 +0000 (12:43 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 2 Apr 2015 12:43:31 +0000 (12:43 +0000)
MSVC 2013 can't even parse __declspec(align(sizeof(foo))). We'll have to
wait until MSVC 2015 for this.

This partially reverts commit r233911.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233912 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclGroup.h
include/clang/AST/DeclTemplate.h
include/clang/AST/Stmt.h
lib/AST/Decl.cpp

index 04718f4741bdbb7376b3f53e61003e11819531c1..bd3dbd8fa7876ac9a70e98962b2e3430cc5af92e 100644 (file)
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_AST_DECLGROUP_H
 #define LLVM_CLANG_AST_DECLGROUP_H
 
-#include "llvm/Support/Compiler.h"
 #include "llvm/Support/DataTypes.h"
 #include <cassert>
 
@@ -25,9 +24,13 @@ class Decl;
 class DeclGroup;
 class DeclGroupIterator;
 
-class LLVM_ALIGNAS(sizeof(void *)) DeclGroup {
+class DeclGroup {
   // FIXME: Include a TypeSpecifier object.
-  unsigned NumDecls;
+  union {
+    unsigned NumDecls;
+
+    Decl *Aligner;
+  };
 
 private:
   DeclGroup() : NumDecls(0) {}
index 60e0481944c1d06fccbb4c9e33fae211ad66a139..39b5208a6622112c6b1a772d8b91acb837d2efbc 100644 (file)
@@ -460,12 +460,21 @@ public:
 ///     friend void foo<>(T);
 ///   };
 /// \endcode
-class LLVM_ALIGNAS(sizeof(void *)) DependentFunctionTemplateSpecializationInfo {
-  /// The number of potential template candidates.
-  unsigned NumTemplates;
+class DependentFunctionTemplateSpecializationInfo {
+  struct CA {
+    /// The number of potential template candidates.
+    unsigned NumTemplates;
 
-  /// The number of template arguments.
-  unsigned NumArgs;
+    /// 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 CA d;
+  };
 
   /// The locations of the left and right angle brackets.
   SourceRange AngleLocs;
@@ -481,7 +490,9 @@ public:
 
   /// \brief Returns the number of function templates that this might
   /// be a specialization of.
-  unsigned getNumTemplates() const { return NumTemplates; }
+  unsigned getNumTemplates() const {
+    return d.NumTemplates;
+  }
 
   /// \brief Returns the i'th template candidate.
   FunctionTemplateDecl *getTemplate(unsigned I) const {
@@ -496,7 +507,9 @@ public:
   }
 
   /// \brief Returns the number of explicit template arguments that were given.
-  unsigned getNumTemplateArgs() const { return NumArgs; }
+  unsigned getNumTemplateArgs() const {
+    return d.NumArgs;
+  }
 
   /// \brief Returns the nth template argument.
   const TemplateArgumentLoc &getTemplateArg(unsigned I) const {
index 6739cb3fb00562fa6349e66da59bb2d7a0e37e0a..a55cba9d1a40c6879cdd0ced6376f27d274864b1 100644 (file)
@@ -101,7 +101,7 @@ namespace clang {
 
 /// Stmt - This represents one statement.
 ///
-class LLVM_ALIGNAS(sizeof(void *)) Stmt {
+class Stmt {
 public:
   enum StmtClass {
     NoStmtClass = 0,
@@ -287,6 +287,9 @@ protected:
   };
 
   union {
+    // FIXME: this is wasteful on 64-bit platforms.
+    void *Aligner;
+
     StmtBitfields StmtBits;
     CompoundStmtBitfields CompoundStmtBits;
     ExprBitfields ExprBits;
index b4410538f76e69f43bfe2a5a8792f13433f61315..3efd24f21f9e083225d9e2f7af1a418b88fa451d 100644 (file)
@@ -3103,11 +3103,13 @@ FunctionDecl::setDependentTemplateSpecialization(ASTContext &Context,
 DependentFunctionTemplateSpecializationInfo::
 DependentFunctionTemplateSpecializationInfo(const UnresolvedSetImpl &Ts,
                                       const TemplateArgumentListInfo &TArgs)
-  : NumTemplates(Ts.size()), NumArgs(TArgs.size()),
-    AngleLocs(TArgs.getLAngleLoc(), TArgs.getRAngleLoc()) {
+  : AngleLocs(TArgs.getLAngleLoc(), TArgs.getRAngleLoc()) {
   static_assert(sizeof(*this) % llvm::AlignOf<void *>::Alignment == 0,
                 "Trailing data is unaligned!");
 
+  d.NumTemplates = Ts.size();
+  d.NumArgs = TArgs.size();
+
   FunctionTemplateDecl **TsArray =
     const_cast<FunctionTemplateDecl**>(getTemplates());
   for (unsigned I = 0, E = Ts.size(); I != E; ++I)