diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -656,20 +656,8 @@ /// \endcode class ObjCTypeParamList final : private llvm::TrailingObjects { - /// Stores the components of a SourceRange as a POD. - struct PODSourceRange { - unsigned Begin; - unsigned End; - }; - - union { - /// Location of the left and right angle brackets. - PODSourceRange Brackets; - - // Used only for alignment. - ObjCTypeParamDecl *AlignmentHack; - }; - + /// Location of the left and right angle brackets. + alignas(ObjCTypeParamDecl *) SourceRange Brackets; /// The number of parameters in the list, which are tail-allocated. unsigned NumParams; @@ -718,15 +706,15 @@ } SourceLocation getLAngleLoc() const { - return SourceLocation::getFromRawEncoding(Brackets.Begin); + return Brackets.getBegin(); } SourceLocation getRAngleLoc() const { - return SourceLocation::getFromRawEncoding(Brackets.End); + return Brackets.getEnd(); } SourceRange getSourceRange() const { - return SourceRange(getLAngleLoc(), getRAngleLoc()); + return Brackets; } /// Gather the default set of type arguments to be substituted for diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -1461,9 +1461,8 @@ ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc, ArrayRef typeParams, SourceLocation rAngleLoc) - : NumParams(typeParams.size()) { - Brackets.Begin = lAngleLoc.getRawEncoding(); - Brackets.End = rAngleLoc.getRawEncoding(); + : Brackets(lAngleLoc, rAngleLoc), + NumParams(typeParams.size()) { std::copy(typeParams.begin(), typeParams.end(), begin()); }