Skip to content

Commit 66ff7c6

Browse files
committed
[Clang][P1061] Remove unrelated code changes; Address style issues
1 parent 116aff1 commit 66ff7c6

File tree

7 files changed

+19
-54
lines changed

7 files changed

+19
-54
lines changed

clang/lib/AST/DeclCXX.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,11 +3425,10 @@ VarDecl *BindingDecl::getHoldingVar() const {
34253425
return VD;
34263426
}
34273427

3428-
34293428
void DecompositionDecl::VisitHoldingVars(
34303429
llvm::function_ref<void(VarDecl *)> F) const {
3431-
VisitBindings([&](BindingDecl* BD) {
3432-
if (VarDecl* VD = BD->getHoldingVar())
3430+
VisitBindings([&](BindingDecl *BD) {
3431+
if (VarDecl *VD = BD->getHoldingVar())
34333432
F(VD);
34343433
});
34353434
}

clang/lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7369,8 +7369,8 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) {
73697369
ConsumeToken();
73707370

73717371
if (Tok.is(tok::ellipsis) && !PrevEllipsisLoc.isValid()) {
7372-
DiagnoseMisplacedEllipsis(Tok.getLocation(), Loc,
7373-
EllipsisLoc.isValid(), true);
7372+
DiagnoseMisplacedEllipsis(Tok.getLocation(), Loc, EllipsisLoc.isValid(),
7373+
true);
73747374
EllipsisLoc = Tok.getLocation();
73757375
ConsumeToken();
73767376
}

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -959,14 +959,15 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D,
959959
return New;
960960
}
961961

962-
namespace {
963962
// CheckBindingsCount
964963
// - Checks the arity of the structured bindings
965964
// - Creates the resolved pack expr if there is
966965
// one
967-
bool CheckBindingsCount(Sema &S, DecompositionDecl *DD, QualType DecompType,
968-
ArrayRef<BindingDecl *> Bindings,
969-
unsigned MemberCount) {
966+
967+
static bool CheckBindingsCount(Sema &S, DecompositionDecl *DD,
968+
QualType DecompType,
969+
ArrayRef<BindingDecl *> Bindings,
970+
unsigned MemberCount) {
970971
auto BindingWithPackItr =
971972
std::find_if(Bindings.begin(), Bindings.end(),
972973
[](BindingDecl *D) -> bool { return D->isParameterPack(); });
@@ -1058,7 +1059,6 @@ struct BindingInitWalker {
10581059
++BindingItr;
10591060
}
10601061
};
1061-
} // namespace
10621062

10631063
static bool checkSimpleDecomposition(
10641064
Sema &S, ArrayRef<BindingDecl *> Bindings, ValueDecl *Src,
@@ -1619,35 +1619,6 @@ static bool checkMemberDecomposition(Sema &S, ArrayRef<BindingDecl*> Bindings,
16191619
return false;
16201620
}
16211621

1622-
unsigned Sema::GetDecompositionElementCount(QualType DecompType) {
1623-
assert(!DecompType->isDependentType() && "expecting non-dependent type");
1624-
SourceLocation Loc = SourceLocation(); // FIXME
1625-
DecompType = DecompType.getNonReferenceType();
1626-
if (auto *CAT = Context.getAsConstantArrayType(DecompType))
1627-
return CAT->getSize().getLimitedValue(UINT_MAX);
1628-
if (auto *VT = DecompType->getAs<VectorType>())
1629-
return VT->getNumElements();
1630-
if (auto *CT = DecompType->getAs<ComplexType>())
1631-
return 2;
1632-
llvm::APSInt TupleSize(32);
1633-
if (IsTupleLike TL = isTupleLike(*this, Loc, DecompType, TupleSize);
1634-
TL == IsTupleLike::TupleLike)
1635-
return (unsigned)TupleSize.getLimitedValue(UINT_MAX);
1636-
1637-
if (CXXRecordDecl *RD = DecompType->getAsCXXRecordDecl();
1638-
RD && !RD->isUnion()) {
1639-
CXXCastPath BasePath;
1640-
DeclAccessPair BasePair =
1641-
findDecomposableBaseClass(*this, Loc, RD, BasePath);
1642-
RD = cast_or_null<CXXRecordDecl>(BasePair.getDecl());
1643-
if (RD)
1644-
return llvm::count_if(
1645-
RD->fields(), [](FieldDecl *FD) { return !FD->isUnnamedBitField(); });
1646-
}
1647-
1648-
llvm_unreachable("unknown type for decomposition");
1649-
}
1650-
16511622
void Sema::CheckCompleteDecompositionDeclaration(DecompositionDecl *DD) {
16521623
QualType DecompType = DD->getType();
16531624

clang/lib/Sema/SemaLambda.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,6 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
15261526
// - a member of a templated entity,
15271527
// - an enumerator for an enumeration that is a templated entity, or
15281528
// - the closure type of a lambda-expression ([expr.prim.lambda.closure])
1529-
// - an entity defined with an implicit template region
15301529
// appearing in the declaration of a templated entity. [Note 6: A local
15311530
// class, a local or block variable, or a friend function defined in a
15321531
// templated entity is a templated entity. — end note]

clang/lib/Sema/SemaStmt.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr &MTA) {
755755
return true;
756756
};
757757

758-
const auto *CallerDecl = getCurFunctionDecl();
758+
const auto *CallerDecl = dyn_cast<FunctionDecl>(CurContext);
759759

760760
// Find caller function signature.
761761
if (!CallerDecl) {
@@ -1010,7 +1010,8 @@ StmtResult Sema::ActOnIfStmt(SourceLocation IfLoc,
10101010
bool Immediate = ExprEvalContexts.back().Context ==
10111011
ExpressionEvaluationContext::ImmediateFunctionContext;
10121012
if (CurContext->isFunctionOrMethod()) {
1013-
const auto *FD = getCurFunctionDecl();
1013+
const auto *FD =
1014+
dyn_cast<FunctionDecl>(Decl::castFromDeclContext(CurContext));
10141015
if (FD && FD->isImmediateFunction())
10151016
Immediate = true;
10161017
}
@@ -3918,7 +3919,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
39183919
// deduction.
39193920
if (getLangOpts().CPlusPlus14) {
39203921
if (AutoType *AT = FnRetType->getContainedAutoType()) {
3921-
FunctionDecl *FD = getCurFunctionDecl();
3922+
FunctionDecl *FD = cast<FunctionDecl>(CurContext);
39223923
// If we've already decided this function is invalid, e.g. because
39233924
// we saw a `return` whose expression had an error, don't keep
39243925
// trying to deduce its return type.

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,10 +928,9 @@ static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef,
928928

929929
void Sema::translateTemplateArguments(const ASTTemplateArgsPtr &TemplateArgsIn,
930930
TemplateArgumentListInfo &TemplateArgs) {
931-
for (unsigned I = 0, Last = TemplateArgsIn.size(); I != Last; ++I) {
931+
for (unsigned I = 0, Last = TemplateArgsIn.size(); I != Last; ++I)
932932
TemplateArgs.addArgument(
933933
translateTemplateArgument(*this, TemplateArgsIn[I]));
934-
}
935934
}
936935

937936
static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S,

clang/lib/Sema/SemaTemplateVariadic.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "clang/Sema/Sema.h"
2020
#include "clang/Sema/SemaInternal.h"
2121
#include "clang/Sema/Template.h"
22-
#include "llvm/ADT/ScopeExit.h"
2322
#include "llvm/Support/SaveAndRestore.h"
2423
#include <optional>
2524

@@ -70,6 +69,7 @@ class CollectUnexpandedParameterPacksVisitor
7069
if (T->getDepth() < DepthLimit)
7170
Unexpanded.push_back({T, Loc});
7271
}
72+
7373
void addUnexpanded(ResolvedUnexpandedPackExpr *E) {
7474
Unexpanded.push_back({E, E->getBeginLoc()});
7575
}
@@ -807,9 +807,8 @@ bool Sema::CheckParameterPacksForExpansion(
807807
CurrentInstantiationScope->findInstantiationOf(ND);
808808
if (Decl *B = Instantiation->dyn_cast<Decl *>()) {
809809
Expr *BindingExpr = cast<BindingDecl>(B)->getBinding();
810-
if (auto *RP = dyn_cast<ResolvedUnexpandedPackExpr>(BindingExpr)) {
810+
if (auto *RP = dyn_cast<ResolvedUnexpandedPackExpr>(BindingExpr))
811811
ResolvedPack = RP;
812-
}
813812
}
814813
if (!ResolvedPack) {
815814
ShouldExpand = false;
@@ -1218,9 +1217,8 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S,
12181217
MarkAnyDeclReferenced(OpLoc, ParameterPack, true);
12191218

12201219
std::optional<unsigned> Length;
1221-
if (auto *RP = ResolvedUnexpandedPackExpr::getFromDecl(ParameterPack)) {
1220+
if (auto *RP = ResolvedUnexpandedPackExpr::getFromDecl(ParameterPack))
12221221
Length = RP->getNumExprs();
1223-
}
12241222

12251223
return SizeOfPackExpr::Create(Context, OpLoc, ParameterPack, NameLoc,
12261224
RParenLoc, Length);
@@ -1494,10 +1492,8 @@ ExprResult Sema::ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
14941492
}
14951493
}
14961494

1497-
ExprResult Result = BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc,
1498-
RHS, RParenLoc, std::nullopt);
1499-
1500-
return Result;
1495+
return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
1496+
std::nullopt);
15011497
}
15021498

15031499
ExprResult Sema::BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,

0 commit comments

Comments
 (0)