r241564 - Don't rely on the use of non-POD types within unions.
Douglas Gregor
dgregor at apple.com
Mon Jul 6 23:20:46 PDT 2015
Author: dgregor
Date: Tue Jul 7 01:20:46 2015
New Revision: 241564
URL: http://llvm.org/viewvc/llvm-project?rev=241564&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=241564&r1=241563&r2=241564&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Jul 7 01:20:46 2015
@@ -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.
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=241564&r1=241563&r2=241564&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Tue Jul 7 01:20:46 2015
@@ -1251,8 +1251,10 @@ SourceRange ObjCTypeParamDecl::getSource
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());
}
More information about the cfe-commits
mailing list