Skip to content

Commit c7db450

Browse files
committed
[clang][NFC] Refactor EvaluateBinaryTypeTrait to accept TypeSourceInfo
Some type traits issue diagnostics that would benefit from additional source location information.
1 parent 03ffb82 commit c7db450

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5566,8 +5566,8 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT,
55665566
}
55675567
}
55685568

5569-
static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT,
5570-
QualType RhsT, SourceLocation KeyLoc);
5569+
static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceInfo *Lhs,
5570+
const TypeSourceInfo *Rhs, SourceLocation KeyLoc);
55715571

55725572
static bool EvaluateBooleanTypeTrait(Sema &S, TypeTrait Kind,
55735573
SourceLocation KWLoc,
@@ -5583,8 +5583,8 @@ static bool EvaluateBooleanTypeTrait(Sema &S, TypeTrait Kind,
55835583
// Evaluate ReferenceBindsToTemporary and ReferenceConstructsFromTemporary
55845584
// alongside the IsConstructible traits to avoid duplication.
55855585
if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary && Kind != BTT_ReferenceConstructsFromTemporary)
5586-
return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
5587-
Args[1]->getType(), RParenLoc);
5586+
return EvaluateBinaryTypeTrait(S, Kind, Args[0],
5587+
Args[1], RParenLoc);
55885588

55895589
switch (Kind) {
55905590
case clang::BTT_ReferenceBindsToTemporary:
@@ -5679,8 +5679,8 @@ static bool EvaluateBooleanTypeTrait(Sema &S, TypeTrait Kind,
56795679
if (U->isReferenceType())
56805680
return false;
56815681

5682-
QualType TPtr = S.Context.getPointerType(S.BuiltinRemoveReference(T, UnaryTransformType::RemoveCVRef, {}));
5683-
QualType UPtr = S.Context.getPointerType(S.BuiltinRemoveReference(U, UnaryTransformType::RemoveCVRef, {}));
5682+
TypeSourceInfo *TPtr = S.Context.CreateTypeSourceInfo(S.Context.getPointerType(S.BuiltinRemoveReference(T, UnaryTransformType::RemoveCVRef, {})));
5683+
TypeSourceInfo *UPtr = S.Context.CreateTypeSourceInfo(S.Context.getPointerType(S.BuiltinRemoveReference(U, UnaryTransformType::RemoveCVRef, {})));
56845684
return EvaluateBinaryTypeTrait(S, TypeTrait::BTT_IsConvertibleTo, UPtr, TPtr, RParenLoc);
56855685
}
56865686

@@ -5814,8 +5814,11 @@ ExprResult Sema::ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
58145814
return BuildTypeTrait(Kind, KWLoc, ConvertedArgs, RParenLoc);
58155815
}
58165816

5817-
static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT,
5818-
QualType RhsT, SourceLocation KeyLoc) {
5817+
static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceInfo *Lhs,
5818+
const TypeSourceInfo *Rhs, SourceLocation KeyLoc) {
5819+
QualType LhsT = Lhs->getType();
5820+
QualType RhsT = Rhs->getType();
5821+
58195822
assert(!LhsT->isDependentType() && !RhsT->isDependentType() &&
58205823
"Cannot evaluate traits of dependent types");
58215824

0 commit comments

Comments
 (0)