From cf86ce0a7a954dc939711da585ceb6321e1b666b Mon Sep 17 00:00:00 2001 From: Bruno Ricci Date: Tue, 25 Sep 2018 13:43:25 +0000 Subject: [AST] Squeeze some bits in LinkageComputer::QueryType Replace the pair std::pair where the unsigned represents an LVComputationKind by a PointerIntPair. This saves a pointer per entry in the map LinkageComputer::CachedLinkageInfo. Differential Revision: https://reviews.llvm.org/D52268 Reviewed by: rjmccall, george.burgess.iv, erichkeane llvm-svn: 342973 --- clang/lib/AST/Linkage.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'clang') diff --git a/clang/lib/AST/Linkage.h b/clang/lib/AST/Linkage.h index e6489c7ef2b..8ad748bcc4a 100644 --- a/clang/lib/AST/Linkage.h +++ b/clang/lib/AST/Linkage.h @@ -20,6 +20,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/PointerIntPair.h" namespace clang { /// Kinds of LV computation. The linkage side of the computation is @@ -36,6 +37,8 @@ struct LVComputationKind { /// in computing linkage. unsigned IgnoreAllVisibility : 1; + enum { NumLVComputationKindBits = 3 }; + explicit LVComputationKind(NamedDecl::ExplicitVisibilityKind EK) : ExplicitKind(EK), IgnoreExplicitVisibility(false), IgnoreAllVisibility(false) {} @@ -78,12 +81,14 @@ class LinkageComputer { // using C = Foo; // using D = Foo; // - // The unsigned represents an LVComputationKind. - using QueryType = std::pair; + // The integer represents an LVComputationKind. + using QueryType = + llvm::PointerIntPair; llvm::SmallDenseMap CachedLinkageInfo; static QueryType makeCacheKey(const NamedDecl *ND, LVComputationKind Kind) { - return std::make_pair(ND, Kind.toBits()); + return QueryType(ND, Kind.toBits()); } llvm::Optional lookup(const NamedDecl *ND, -- cgit v1.2.3