Removed PointerUnion3 and PointerUnion4 aliases in favor of the variadic template

This commit is contained in:
Dmitri Gribenko 2020-01-14 15:46:13 +01:00
parent 0877843dda
commit 2948ec5ca9
13 changed files with 28 additions and 38 deletions

View File

@ -1859,10 +1859,10 @@ private:
/// FunctionTemplateSpecializationInfo, which contains information about
/// the template being specialized and the template arguments involved in
/// that specialization.
llvm::PointerUnion4<FunctionTemplateDecl *,
MemberSpecializationInfo *,
FunctionTemplateSpecializationInfo *,
DependentFunctionTemplateSpecializationInfo *>
llvm::PointerUnion<FunctionTemplateDecl *,
MemberSpecializationInfo *,
FunctionTemplateSpecializationInfo *,
DependentFunctionTemplateSpecializationInfo *>
TemplateOrSpecialization;
/// Provides source/type location info for the declaration name embedded in

View File

@ -2125,8 +2125,8 @@ class CXXCtorInitializer final {
/// Either the base class name/delegating constructor type (stored as
/// a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field
/// (IndirectFieldDecl*) being initialized.
llvm::PointerUnion3<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *>
Initializee;
llvm::PointerUnion<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *>
Initializee;
/// The source location for the field name or, for a base initializer
/// pack expansion, the location of the ellipsis.

View File

@ -57,8 +57,8 @@ class VarTemplatePartialSpecializationDecl;
/// Stores a template parameter of any kind.
using TemplateParameter =
llvm::PointerUnion3<TemplateTypeParmDecl *, NonTypeTemplateParmDecl *,
TemplateTemplateParmDecl *>;
llvm::PointerUnion<TemplateTypeParmDecl *, NonTypeTemplateParmDecl *,
TemplateTemplateParmDecl *>;
NamedDecl *getAsNamedDecl(TemplateParameter P);
@ -309,7 +309,7 @@ class DefaultArgStorage {
static_assert(sizeof(Chain) == sizeof(void *) * 2,
"non-pointer argument type?");
llvm::PointerUnion3<ArgType, ParmDecl*, Chain*> ValueOrInherited;
llvm::PointerUnion<ArgType, ParmDecl*, Chain*> ValueOrInherited;
static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
const DefaultArgStorage &Storage = Parm->getDefaultArgStorage();

View File

@ -642,7 +642,7 @@ private:
/// the location of the 'super' keyword. When it's an interface,
/// this is that interface.
SourceLocation ReceiverLoc;
llvm::PointerUnion3<Stmt *, const Type *, ObjCInterfaceDecl *> Receiver;
llvm::PointerUnion<Stmt *, const Type *, ObjCInterfaceDecl *> Receiver;
public:
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,

View File

@ -190,8 +190,8 @@ public:
/// only be understood in the context of
class TemplateName {
using StorageType =
llvm::PointerUnion4<TemplateDecl *, UncommonTemplateNameStorage *,
QualifiedTemplateName *, DependentTemplateName *>;
llvm::PointerUnion<TemplateDecl *, UncommonTemplateNameStorage *,
QualifiedTemplateName *, DependentTemplateName *>;
StorageType Storage;

View File

@ -924,15 +924,15 @@ class ASTContext::ParentMap {
/// only storing a unique pointer to them.
using ParentMapPointers = llvm::DenseMap<
const void *,
llvm::PointerUnion4<const Decl *, const Stmt *,
ast_type_traits::DynTypedNode *, ParentVector *>>;
llvm::PointerUnion<const Decl *, const Stmt *,
ast_type_traits::DynTypedNode *, ParentVector *>>;
/// Parent map for nodes without pointer identity. We store a full
/// DynTypedNode for all keys.
using ParentMapOtherNodes = llvm::DenseMap<
ast_type_traits::DynTypedNode,
llvm::PointerUnion4<const Decl *, const Stmt *,
ast_type_traits::DynTypedNode *, ParentVector *>>;
llvm::PointerUnion<const Decl *, const Stmt *,
ast_type_traits::DynTypedNode *, ParentVector *>>;
ParentMapPointers PointerParents;
ParentMapOtherNodes OtherParents;

View File

@ -228,9 +228,9 @@ CXCursor MakeCursorOverloadedDeclRef(TemplateName Template,
CXTranslationUnit TU);
/// Internal storage for an overloaded declaration reference cursor;
typedef llvm::PointerUnion3<const OverloadExpr *, const Decl *,
OverloadedTemplateStorage *>
OverloadedDeclRefStorage;
typedef llvm::PointerUnion<const OverloadExpr *, const Decl *,
OverloadedTemplateStorage *>
OverloadedDeclRefStorage;
/// Unpack an overloaded declaration reference into an expression,
/// declaration, or template name along with the source location.

View File

@ -58,7 +58,7 @@ public:
/// the query also keeps the entity number in that list.
///
class Query {
PointerUnion3<const Value *, const Metadata *, const Type *> Entity;
PointerUnion<const Value *, const Metadata *, const Type *> Entity;
unsigned OperandNo;
public:

View File

@ -272,16 +272,6 @@ struct PointerLikeTypeTraits<PointerUnion<PTs...>> {
PointerUnion<PTs...>::Val)>::NumLowBitsAvailable;
};
/// A pointer union of three pointer types. See documentation for PointerUnion
/// for usage.
template <typename PT1, typename PT2, typename PT3>
using PointerUnion3 = PointerUnion<PT1, PT2, PT3>;
/// A pointer union of four pointer types. See documentation for PointerUnion
/// for usage.
template <typename PT1, typename PT2, typename PT3, typename PT4>
using PointerUnion4 = PointerUnion<PT1, PT2, PT3, PT4>;
// Teach DenseMap how to use PointerUnions as keys.
template <typename ...PTs> struct DenseMapInfo<PointerUnion<PTs...>> {
using Union = PointerUnion<PTs...>;

View File

@ -61,10 +61,10 @@ private:
/// into relatively small files (often smaller than 2^8 or 2^16 bytes),
/// we select the offset vector element type dynamically based on the
/// size of Buffer.
using VariableSizeOffsets = PointerUnion4<std::vector<uint8_t> *,
std::vector<uint16_t> *,
std::vector<uint32_t> *,
std::vector<uint64_t> *>;
using VariableSizeOffsets = PointerUnion<std::vector<uint8_t> *,
std::vector<uint16_t> *,
std::vector<uint32_t> *,
std::vector<uint64_t> *>;
/// Vector of offsets into Buffer at which there are line-endings
/// (lazily populated). Once populated, the '\n' that marks the end of

View File

@ -1811,7 +1811,7 @@ bool LowerTypeTestsModule::lower() {
// reference them. This is used to partition the set of type identifiers in
// the module into disjoint sets.
using GlobalClassesTy = EquivalenceClasses<
PointerUnion3<GlobalTypeMember *, Metadata *, ICallBranchFunnel *>>;
PointerUnion<GlobalTypeMember *, Metadata *, ICallBranchFunnel *>>;
GlobalClassesTy GlobalClasses;
// Verify the type metadata and build a few data structures to let us

View File

@ -43,7 +43,7 @@ class InputFile {
std::unique_ptr<NativeSession> PdbSession;
object::OwningBinary<object::Binary> CoffObject;
std::unique_ptr<MemoryBuffer> UnknownFile;
PointerUnion3<PDBFile *, object::COFFObjectFile *, MemoryBuffer *> PdbOrObj;
PointerUnion<PDBFile *, object::COFFObjectFile *, MemoryBuffer *> PdbOrObj;
using TypeCollectionPtr = std::unique_ptr<codeview::LazyRandomTypeCollection>;

View File

@ -13,8 +13,8 @@ using namespace llvm;
namespace {
typedef PointerUnion<int *, float *> PU;
typedef PointerUnion3<int *, float *, long long *> PU3;
typedef PointerUnion4<int *, float *, long long *, double *> PU4;
typedef PointerUnion<int *, float *, long long *> PU3;
typedef PointerUnion<int *, float *, long long *, double *> PU4;
struct PointerUnionTest : public testing::Test {
float f;