]> granicus.if.org Git - clang/commitdiff
Don't rely on the use of non-POD types within unions.
authorDouglas Gregor <dgregor@apple.com>
Tue, 7 Jul 2015 06:20:46 +0000 (06:20 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 7 Jul 2015 06:20:46 +0000 (06:20 +0000)
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

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp

index 0aeb8ca4de5a464575276936bd2cbf533d95e297..25fd59996b2a5dfe5ffeaa391f1168173c149531 100644 (file)
@@ -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.
index 11a66c9c8cb2556fac1adb4b56789e3a372f961d..ebe27a98c4ca18875016bb7ae36cf651220f23a7 100644 (file)
@@ -1251,8 +1251,10 @@ SourceRange ObjCTypeParamDecl::getSourceRange() const {
 ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
                                      ArrayRef<ObjCTypeParamDecl *> 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());
 }