From: Benjamin Kramer Date: Thu, 20 Oct 2016 13:52:26 +0000 (+0000) Subject: Clean up alignment hacks now that MSVC 2013 and GCC 4.7 are gone. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d0cbd7d8eb77b9df7f2e161fb70e877d944c29a;p=clang Clean up alignment hacks now that MSVC 2013 and GCC 4.7 are gone. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284729 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 562b49a366..a413f25464 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -56,7 +56,7 @@ namespace clang { /// Stmt - This represents one statement. /// -class LLVM_ALIGNAS(LLVM_PTR_SIZE) Stmt { +class alignas(void *) Stmt { public: enum StmtClass { NoStmtClass = 0, diff --git a/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h index b9c2c08943..bccb578792 100644 --- a/include/clang/AST/TemplateBase.h +++ b/include/clang/AST/TemplateBase.h @@ -607,7 +607,7 @@ public: /// as such, doesn't contain the array of TemplateArgumentLoc itself, /// but expects the containing object to also provide storage for /// that. -struct LLVM_ALIGNAS(LLVM_PTR_SIZE) ASTTemplateKWAndArgsInfo { +struct alignas(void *) ASTTemplateKWAndArgsInfo { /// \brief The source location of the left angle bracket ('<'). SourceLocation LAngleLoc; diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index df434ec778..8f5bd04f11 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -1417,15 +1417,12 @@ struct DeclaratorChunk { unsigned TypeQuals : 5; // CXXScopeSpec has a constructor, so it can't be a direct member. // So we need some pointer-aligned storage and a bit of trickery. - union { - void *Aligner; - char Mem[sizeof(CXXScopeSpec)]; - } ScopeMem; + alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)]; CXXScopeSpec &Scope() { - return *reinterpret_cast(ScopeMem.Mem); + return *reinterpret_cast(ScopeMem); } const CXXScopeSpec &Scope() const { - return *reinterpret_cast(ScopeMem.Mem); + return *reinterpret_cast(ScopeMem); } void destroy() { Scope().~CXXScopeSpec(); @@ -1580,7 +1577,7 @@ struct DeclaratorChunk { I.EndLoc = Loc; I.Mem.TypeQuals = TypeQuals; I.Mem.AttrList = nullptr; - new (I.Mem.ScopeMem.Mem) CXXScopeSpec(SS); + new (I.Mem.ScopeMem) CXXScopeSpec(SS); return I; } diff --git a/include/clang/Sema/TemplateDeduction.h b/include/clang/Sema/TemplateDeduction.h index ed1e768832..8a64b8bb96 100644 --- a/include/clang/Sema/TemplateDeduction.h +++ b/include/clang/Sema/TemplateDeduction.h @@ -199,10 +199,7 @@ struct DeductionFailureInfo { void *Data; /// \brief A diagnostic indicating why deduction failed. - union { - void *Align; - char Diagnostic[sizeof(PartialDiagnosticAt)]; - }; + alignas(PartialDiagnosticAt) char Diagnostic[sizeof(PartialDiagnosticAt)]; /// \brief Retrieve the diagnostic which caused this deduction failure, /// if any.