forked from OSchip/llvm-project
[clang][AST] Get rid of an alignment hack in DeclObjC.h [NFCI]
This code currently uses a union object to increase the alignment of the type ObjCTypeParamList. The original intent of this trick was to be able to use the expression `this + 1` to access the beginning of a tail-allocated array of `ObjCTypeParamDecl *` pointers. The code has since been refactored and uses `llvm::TrailingObjects` to manage the tail-allocated array. This template takes care of alignment, so the hack is no longer necessary. This patch removes the union so that the `SourceRange` class can be used directly instead of being re-implemented with raw representations of source locations. Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D94224
This commit is contained in:
parent
891b4873c1
commit
c1e08f0073
|
@ -656,20 +656,8 @@ public:
|
|||
/// \endcode
|
||||
class ObjCTypeParamList final
|
||||
: private llvm::TrailingObjects<ObjCTypeParamList, ObjCTypeParamDecl *> {
|
||||
/// 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.
|
||||
SourceRange Brackets;
|
||||
/// The number of parameters in the list, which are tail-allocated.
|
||||
unsigned NumParams;
|
||||
|
||||
|
@ -717,17 +705,9 @@ public:
|
|||
return *(end() - 1);
|
||||
}
|
||||
|
||||
SourceLocation getLAngleLoc() const {
|
||||
return SourceLocation::getFromRawEncoding(Brackets.Begin);
|
||||
}
|
||||
|
||||
SourceLocation getRAngleLoc() const {
|
||||
return SourceLocation::getFromRawEncoding(Brackets.End);
|
||||
}
|
||||
|
||||
SourceRange getSourceRange() const {
|
||||
return SourceRange(getLAngleLoc(), getRAngleLoc());
|
||||
}
|
||||
SourceLocation getLAngleLoc() const { return Brackets.getBegin(); }
|
||||
SourceLocation getRAngleLoc() const { return Brackets.getEnd(); }
|
||||
SourceRange getSourceRange() const { return Brackets; }
|
||||
|
||||
/// Gather the default set of type arguments to be substituted for
|
||||
/// these type parameters when dealing with an unspecialized type.
|
||||
|
|
|
@ -1461,9 +1461,7 @@ SourceRange ObjCTypeParamDecl::getSourceRange() const {
|
|||
ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
|
||||
ArrayRef<ObjCTypeParamDecl *> 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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue