From: Douglas Gregor Date: Tue, 7 Jul 2015 06:20:46 +0000 (+0000) Subject: Don't rely on the use of non-POD types within unions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f1ba8ae2199185357c4ed6e2de5b0fc42713162a;p=clang Don't rely on the use of non-POD types within unions. They aren't universally supported and we're not getting any benefit from using them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241564 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 0aeb8ca4de..25fd59996b 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -610,7 +610,10 @@ public: class ObjCTypeParamList { union { /// Location of the left and right angle brackets. - SourceRange Brackets; + struct { + unsigned Begin; + unsigned End; + } Brackets; // Used only for alignment. ObjCTypeParamDecl *AlignmentHack; @@ -661,9 +664,15 @@ public: return *(end() - 1); } - SourceLocation getLAngleLoc() const { return Brackets.getBegin(); } - SourceLocation getRAngleLoc() const { return Brackets.getEnd(); } - SourceRange getSourceRange() const { return Brackets; } + SourceLocation getLAngleLoc() const { + return SourceLocation::getFromRawEncoding(Brackets.Begin); + } + SourceLocation getRAngleLoc() const { + return SourceLocation::getFromRawEncoding(Brackets.End); + } + SourceRange getSourceRange() const { + return SourceRange(getLAngleLoc(), getRAngleLoc()); + } /// Gather the default set of type arguments to be substituted for /// these type parameters when dealing with an unspecialized type. diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 11a66c9c8c..ebe27a98c4 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -1251,8 +1251,10 @@ SourceRange ObjCTypeParamDecl::getSourceRange() const { ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc, ArrayRef typeParams, SourceLocation rAngleLoc) - : Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size()) + : NumParams(typeParams.size()) { + Brackets.Begin = lAngleLoc.getRawEncoding(); + Brackets.End = rAngleLoc.getRawEncoding(); std::copy(typeParams.begin(), typeParams.end(), begin()); }