Skip to content

Commit aeda622

Browse files
[NFC] Rename ExtInfo::Uncommon to ExtInfo::ClangTypeInfo.
The previous name was poorly chosen (by me). Time to fix that.
1 parent b2f8fa8 commit aeda622

File tree

4 files changed

+50
-52
lines changed

4 files changed

+50
-52
lines changed

include/swift/AST/Types.h

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
342342
/// Extra information which affects how the function is called, like
343343
/// regparm and the calling convention.
344344
ExtInfoBits : NumAFTExtInfoBits,
345-
HasUncommonInfo : 1,
345+
HasClangTypeInfo : 1,
346346
: NumPadBits,
347347
NumParams : 16
348348
);
@@ -365,7 +365,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
365365

366366
SWIFT_INLINE_BITFIELD(SILFunctionType, TypeBase, NumSILExtInfoBits+1+3+1+2+1+1,
367367
ExtInfoBits : NumSILExtInfoBits,
368-
HasUncommonInfo : 1,
368+
HasClangTypeInfo : 1,
369369
CalleeConvention : 3,
370370
HasErrorResult : 1,
371371
CoroutineKind : 2,
@@ -2987,7 +2987,7 @@ class AnyFunctionType : public TypeBase {
29872987
unsigned Bits; // Naturally sized for speed.
29882988

29892989
public:
2990-
class Uncommon {
2990+
class ClangTypeInfo {
29912991
friend ExtInfo;
29922992
friend class AnyFunctionType;
29932993
friend class FunctionType;
@@ -2996,27 +2996,26 @@ class AnyFunctionType : public TypeBase {
29962996
// 2. The actual type being stored is [ignoring sugar] either a
29972997
// clang::PointerType, a clang::BlockPointerType, or a
29982998
// clang::ReferenceType which points to a clang::FunctionType.
2999-
const clang::Type *ClangFunctionType;
2999+
const clang::Type *type;
30003000

3001-
bool empty() const { return !ClangFunctionType; }
3002-
Uncommon(const clang::Type *type) : ClangFunctionType(type) {}
3001+
bool empty() const { return !type; }
3002+
ClangTypeInfo(const clang::Type *type) : type(type) {}
30033003

30043004
public:
30053005
/// Use the ClangModuleLoader to print the Clang type as a string.
3006-
void printClangFunctionType(ClangModuleLoader *cml,
3007-
llvm::raw_ostream &os);
3006+
void printType(ClangModuleLoader *cml, llvm::raw_ostream &os) const;
30083007
};
30093008

30103009
private:
3011-
Uncommon Other;
3010+
ClangTypeInfo Other;
30123011

30133012
static void assertIsFunctionType(const clang::Type *);
30143013

3015-
ExtInfo(unsigned Bits, Uncommon Other) : Bits(Bits), Other(Other) {
3014+
ExtInfo(unsigned Bits, ClangTypeInfo Other) : Bits(Bits), Other(Other) {
30163015
// [TODO: Clang-type-plumbing] Assert that the pointer is non-null.
30173016
auto Rep = Representation(Bits & RepresentationMask);
3018-
if ((Rep == Representation::CFunctionPointer) && Other.ClangFunctionType)
3019-
assertIsFunctionType(Other.ClangFunctionType);
3017+
if ((Rep == Representation::CFunctionPointer) && Other.type)
3018+
assertIsFunctionType(Other.type);
30203019
}
30213020

30223021
friend AnyFunctionType;
@@ -3045,7 +3044,7 @@ class AnyFunctionType : public TypeBase {
30453044
| (Throws ? ThrowsMask : 0)
30463045
| (((unsigned)DiffKind << DifferentiabilityMaskOffset)
30473046
& DifferentiabilityMask),
3048-
Uncommon(type)) {
3047+
ClangTypeInfo(type)) {
30493048
}
30503049

30513050
bool isNoEscape() const { return Bits & NoEscapeMask; }
@@ -3065,9 +3064,9 @@ class AnyFunctionType : public TypeBase {
30653064
return Representation(rawRep);
30663065
}
30673066

3068-
/// Return the underlying Uncommon value if it is not the default value.
3069-
Optional<Uncommon> getUncommonInfo() const {
3070-
return Other.empty() ? Optional<Uncommon>() : Other;
3067+
/// Get the underlying ClangTypeInfo value if it is not the default value.
3068+
Optional<ClangTypeInfo> getClangTypeInfo() const {
3069+
return Other.empty() ? Optional<ClangTypeInfo>() : Other;
30713070
}
30723071

30733072
bool hasSelfParam() const {
@@ -3124,7 +3123,7 @@ class AnyFunctionType : public TypeBase {
31243123
}
31253124
LLVM_NODISCARD
31263125
ExtInfo withClangFunctionType(const clang::Type *type) const {
3127-
return ExtInfo(Bits, Uncommon(type));
3126+
return ExtInfo(Bits, ClangTypeInfo(type));
31283127
}
31293128
LLVM_NODISCARD
31303129
ExtInfo
@@ -3136,7 +3135,7 @@ class AnyFunctionType : public TypeBase {
31363135
}
31373136

31383137
std::pair<unsigned, const void *> getFuncAttrKey() const {
3139-
return std::make_pair(Bits, Other.ClangFunctionType);
3138+
return std::make_pair(Bits, Other.type);
31403139
}
31413140

31423141
/// Put a SIL representation in the ExtInfo.
@@ -3166,13 +3165,13 @@ class AnyFunctionType : public TypeBase {
31663165
/// Create an AnyFunctionType.
31673166
///
31683167
/// Subclasses are responsible for storing and retrieving the
3169-
/// ExtInfo::Uncommon value if one is present.
3168+
/// ExtInfo::ClangTypeInfo value if one is present.
31703169
AnyFunctionType(TypeKind Kind, const ASTContext *CanTypeContext,
31713170
Type Output, RecursiveTypeProperties properties,
31723171
unsigned NumParams, ExtInfo Info)
31733172
: TypeBase(Kind, CanTypeContext, properties), Output(Output) {
31743173
Bits.AnyFunctionType.ExtInfoBits = Info.Bits;
3175-
Bits.AnyFunctionType.HasUncommonInfo = Info.getUncommonInfo().hasValue();
3174+
Bits.AnyFunctionType.HasClangTypeInfo = Info.getClangTypeInfo().hasValue();
31763175
Bits.AnyFunctionType.NumParams = NumParams;
31773176
assert(Bits.AnyFunctionType.NumParams == NumParams && "Params dropped!");
31783177
// The use of both assert() and static_assert() is intentional.
@@ -3216,7 +3215,7 @@ class AnyFunctionType : public TypeBase {
32163215
GenericSignature getOptGenericSignature() const;
32173216

32183217
bool hasClangFunctionType() const {
3219-
return Bits.AnyFunctionType.HasUncommonInfo;
3218+
return Bits.AnyFunctionType.HasClangTypeInfo;
32203219
}
32213220

32223221
const clang::Type *getClangFunctionType() const;
@@ -3435,15 +3434,15 @@ inline AnyFunctionType::CanYield AnyFunctionType::Yield::getCanonical() const {
34353434
class FunctionType final : public AnyFunctionType,
34363435
public llvm::FoldingSetNode,
34373436
private llvm::TrailingObjects<FunctionType, AnyFunctionType::Param,
3438-
AnyFunctionType::ExtInfo::Uncommon> {
3437+
AnyFunctionType::ExtInfo::ClangTypeInfo> {
34393438
friend TrailingObjects;
34403439

34413440

34423441
size_t numTrailingObjects(OverloadToken<AnyFunctionType::Param>) const {
34433442
return getNumParams();
34443443
}
34453444

3446-
size_t numTrailingObjects(OverloadToken<ExtInfo::Uncommon>) const {
3445+
size_t numTrailingObjects(OverloadToken<ExtInfo::ClangTypeInfo>) const {
34473446
return hasClangFunctionType() ? 1 : 0;
34483447
}
34493448

@@ -3460,7 +3459,7 @@ class FunctionType final : public AnyFunctionType,
34603459
const clang::Type *getClangFunctionType() const {
34613460
if (!hasClangFunctionType())
34623461
return nullptr;
3463-
auto *type = getTrailingObjects<ExtInfo::Uncommon>()->ClangFunctionType;
3462+
auto *type = getTrailingObjects<ExtInfo::ClangTypeInfo>()->type;
34643463
assert(type && "If the pointer was null, we shouldn't have stored it.");
34653464
return type;
34663465
}
@@ -4218,7 +4217,7 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
42184217

42194218
unsigned Bits; // Naturally sized for speed.
42204219

4221-
class Uncommon {
4220+
class ClangTypeInfo {
42224221
friend ExtInfo;
42234222
friend class SILFunctionType;
42244223

@@ -4228,22 +4227,21 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
42284227
const clang::FunctionType *ClangFunctionType;
42294228

42304229
bool empty() const { return !ClangFunctionType; }
4231-
Uncommon(const clang::FunctionType *type) : ClangFunctionType(type) {}
4230+
ClangTypeInfo(const clang::FunctionType *type) : ClangFunctionType(type) {}
42324231

42334232
public:
4234-
/// Analog of AnyFunctionType::ExtInfo::Uncommon::printClangFunctionType.
4235-
void printClangFunctionType(ClangModuleLoader *cml,
4236-
llvm::raw_ostream &os) const;
4233+
/// Analog of AnyFunctionType::ExtInfo::ClangTypeInfo::printType.
4234+
void printType(ClangModuleLoader *cml, llvm::raw_ostream &os) const;
42374235
};
42384236

4239-
Uncommon Other;
4237+
ClangTypeInfo Other;
42404238

4241-
ExtInfo(unsigned Bits, Uncommon Other) : Bits(Bits), Other(Other) {}
4239+
ExtInfo(unsigned Bits, ClangTypeInfo Other) : Bits(Bits), Other(Other) {}
42424240

42434241
friend class SILFunctionType;
42444242
public:
42454243
// Constructor with all defaults.
4246-
ExtInfo() : Bits(0), Other(Uncommon(nullptr)) { }
4244+
ExtInfo() : Bits(0), Other(ClangTypeInfo(nullptr)) { }
42474245

42484246
// Constructor for polymorphic type.
42494247
ExtInfo(Representation rep, bool isPseudogeneric, bool isNoEscape,
@@ -4254,7 +4252,7 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
42544252
| (isNoEscape ? NoEscapeMask : 0)
42554253
| (((unsigned)diffKind << DifferentiabilityMaskOffset)
42564254
& DifferentiabilityMask),
4257-
Uncommon(type)) {
4255+
ClangTypeInfo(type)) {
42584256
}
42594257

42604258
static ExtInfo getThin() {
@@ -4287,9 +4285,9 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
42874285
return getSILFunctionLanguage(getRepresentation());
42884286
}
42894287

4290-
/// Return the underlying Uncommon value if it is not the default value.
4291-
Optional<Uncommon> getUncommonInfo() const {
4292-
return Other.empty() ? Optional<Uncommon>() : Other;
4288+
/// Get the underlying ClangTypeInfo value if it is not the default value.
4289+
Optional<ClangTypeInfo> getClangTypeInfo() const {
4290+
return Other.empty() ? Optional<ClangTypeInfo>() : Other;
42934291
}
42944292

42954293
bool hasSelfParam() const {

lib/AST/ASTContext.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,17 +3082,17 @@ FunctionType *FunctionType::get(ArrayRef<AnyFunctionType::Param> params,
30823082
return funcTy;
30833083
}
30843084

3085-
Optional<ExtInfo::Uncommon> uncommon = info.getUncommonInfo();
3085+
Optional<ExtInfo::ClangTypeInfo> clangTypeInfo = info.getClangTypeInfo();
30863086

30873087
size_t allocSize =
3088-
totalSizeToAlloc<AnyFunctionType::Param, ExtInfo::Uncommon>(
3089-
params.size(), uncommon.hasValue() ? 1 : 0);
3088+
totalSizeToAlloc<AnyFunctionType::Param, ExtInfo::ClangTypeInfo>(
3089+
params.size(), clangTypeInfo.hasValue() ? 1 : 0);
30903090
void *mem = ctx.Allocate(allocSize, alignof(FunctionType), arena);
30913091

30923092
bool isCanonical = isFunctionTypeCanonical(params, result);
3093-
if (uncommon.hasValue()) {
3093+
if (clangTypeInfo.hasValue()) {
30943094
if (ctx.LangOpts.UseClangFunctionTypes)
3095-
isCanonical &= uncommon->ClangFunctionType->isCanonicalUnqualified();
3095+
isCanonical &= clangTypeInfo->type->isCanonicalUnqualified();
30963096
else
30973097
isCanonical = false;
30983098
}
@@ -3113,9 +3113,9 @@ FunctionType::FunctionType(ArrayRef<AnyFunctionType::Param> params,
31133113
output, properties, params.size(), info) {
31143114
std::uninitialized_copy(params.begin(), params.end(),
31153115
getTrailingObjects<AnyFunctionType::Param>());
3116-
Optional<ExtInfo::Uncommon> uncommon = info.getUncommonInfo();
3117-
if (uncommon.hasValue())
3118-
*getTrailingObjects<ExtInfo::Uncommon>() = uncommon.getValue();
3116+
auto clangTypeInfo = info.getClangTypeInfo();
3117+
if (clangTypeInfo.hasValue())
3118+
*getTrailingObjects<ExtInfo::ClangTypeInfo>() = clangTypeInfo.getValue();
31193119
}
31203120

31213121
void GenericFunctionType::Profile(llvm::FoldingSetNodeID &ID,
@@ -3208,7 +3208,7 @@ ArrayRef<Requirement> GenericFunctionType::getRequirements() const {
32083208
return Signature->getRequirements();
32093209
}
32103210

3211-
void SILFunctionType::ExtInfo::Uncommon::printClangFunctionType(
3211+
void SILFunctionType::ExtInfo::ClangTypeInfo::printType(
32123212
ClangModuleLoader *cml, llvm::raw_ostream &os) const {
32133213
cml->printClangType(ClangFunctionType, os);
32143214
}
@@ -3272,7 +3272,7 @@ SILFunctionType::SILFunctionType(
32723272

32733273
Bits.SILFunctionType.HasErrorResult = errorResult.hasValue();
32743274
Bits.SILFunctionType.ExtInfoBits = ext.Bits;
3275-
Bits.SILFunctionType.HasUncommonInfo = false;
3275+
Bits.SILFunctionType.HasClangTypeInfo = false;
32763276
Bits.SILFunctionType.HasPatternSubs = (bool) patternSubs;
32773277
Bits.SILFunctionType.HasInvocationSubs = (bool) invocationSubs;
32783278
// The use of both assert() and static_assert() below is intentional.

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3598,7 +3598,7 @@ void printCType(ASTContext &Ctx, ASTPrinter &Printer, ExtInfo &info) {
35983598
auto *cml = Ctx.getClangModuleLoader();
35993599
SmallString<64> buf;
36003600
llvm::raw_svector_ostream os(buf);
3601-
info.getUncommonInfo().getValue().printClangFunctionType(cml, os);
3601+
info.getClangTypeInfo().getValue().printType(cml, os);
36023602
Printer << ", cType: " << QuotedString(os.str());
36033603
}
36043604

@@ -4020,7 +4020,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
40204020
case SILFunctionType::Representation::CFunctionPointer:
40214021
Printer << "c";
40224022
// [TODO: Clang-type-plumbing] Remove the second check.
4023-
if (printNameOnly || !info.getUncommonInfo().hasValue())
4023+
if (printNameOnly || !info.getClangTypeInfo().hasValue())
40244024
break;
40254025
printCType(Ctx, Printer, info);
40264026
break;
@@ -4086,7 +4086,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
40864086
case SILFunctionType::Representation::CFunctionPointer:
40874087
Printer << "c";
40884088
// [TODO: Clang-type-plumbing] Remove the second check.
4089-
if (printNameOnly || !info.getUncommonInfo().hasValue())
4089+
if (printNameOnly || !info.getClangTypeInfo().hasValue())
40904090
break;
40914091
printCType(Ctx, Printer, info);
40924092
break;

lib/AST/Type.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3369,9 +3369,9 @@ Type ProtocolCompositionType::get(const ASTContext &C,
33693369
return build(C, CanTypes, HasExplicitAnyObject);
33703370
}
33713371

3372-
void AnyFunctionType::ExtInfo::Uncommon::printClangFunctionType(
3373-
ClangModuleLoader *cml, llvm::raw_ostream &os) {
3374-
cml->printClangType(ClangFunctionType, os);
3372+
void AnyFunctionType::ExtInfo::ClangTypeInfo::printType(
3373+
ClangModuleLoader *cml, llvm::raw_ostream &os) const {
3374+
cml->printClangType(type, os);
33753375
}
33763376

33773377
void

0 commit comments

Comments
 (0)