Skip to content

Commit c7cfece

Browse files
authored
Merge branch 'main' into target_link_components
2 parents efe3cd4 + 4b4699a commit c7cfece

File tree

128 files changed

+1439
-688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1439
-688
lines changed

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,8 @@ genHTML(const EnumInfo &I, const ClangDocContext &CDCtx) {
692692
std::vector<std::unique_ptr<TagNode>> Out;
693693
std::string EnumType = I.Scoped ? "enum class " : "enum ";
694694
// Determine if enum members have comments attached
695-
bool HasComments = std::any_of(
696-
I.Members.begin(), I.Members.end(),
697-
[](const EnumValueInfo &M) { return !M.Description.empty(); });
695+
bool HasComments = llvm::any_of(
696+
I.Members, [](const EnumValueInfo &M) { return !M.Description.empty(); });
698697
std::unique_ptr<TagNode> Table =
699698
std::make_unique<TagNode>(HTMLTag::TAG_TABLE);
700699
std::unique_ptr<TagNode> THead =

clang/include/clang/AST/Expr.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5274,9 +5274,8 @@ class InitListExpr : public Expr {
52745274

52755275
/// Determine whether this initializer list contains a designated initializer.
52765276
bool hasDesignatedInit() const {
5277-
return std::any_of(begin(), end(), [](const Stmt *S) {
5278-
return isa<DesignatedInitExpr>(S);
5279-
});
5277+
return llvm::any_of(
5278+
*this, [](const Stmt *S) { return isa<DesignatedInitExpr>(S); });
52805279
}
52815280

52825281
/// If this initializes a union, specifies which field in the

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,29 @@ def err_user_defined_msg_constexpr : Error<
17621762
"%sub{subst_user_defined_msg}0 must be produced by a "
17631763
"constant expression">;
17641764

1765+
// Type traits explanations
1766+
def note_unsatisfied_trait : Note<"%0 is not %enum_select<TraitName>{"
1767+
"%TriviallyRelocatable{trivially relocatable}"
1768+
"}1">;
1769+
1770+
def note_unsatisfied_trait_reason
1771+
: Note<"because it "
1772+
"%enum_select<TraitNotSatisfiedReason>{"
1773+
"%Ref{is a reference type}|"
1774+
"%HasArcLifetime{has an ARC lifetime qualifier}|"
1775+
"%VLA{is a variably-modified type}|"
1776+
"%VBase{has a virtual base %1}|"
1777+
"%NRBase{has a non-trivially-relocatable base %1}|"
1778+
"%NRField{has a non-trivially-relocatable member %1 of type %2}|"
1779+
"%DeletedDtr{has a %select{deleted|user-provided}1 destructor}|"
1780+
"%UserProvidedCtr{has a user provided %select{copy|move}1 "
1781+
"constructor}|"
1782+
"%UserProvidedAssign{has a user provided %select{copy|move}1 "
1783+
"assignment operator}|"
1784+
"%UnionWithUserDeclaredSMF{is a union with a user-declared "
1785+
"%sub{select_special_member_kind}1}"
1786+
"}0">;
1787+
17651788
def warn_consteval_if_always_true : Warning<
17661789
"consteval if is always true in an %select{unevaluated|immediate}0 context">,
17671790
InGroup<DiagGroup<"redundant-consteval-if">>;

clang/include/clang/Sema/Sema.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5910,6 +5910,11 @@ class Sema final : public SemaBase {
59105910
/// with expression \E
59115911
void DiagnoseStaticAssertDetails(const Expr *E);
59125912

5913+
/// If E represents a built-in type trait, or a known standard type trait,
5914+
/// try to print more information about why the type type-trait failed.
5915+
/// This assumes we already evaluated the expression to a false boolean value.
5916+
void DiagnoseTypeTraitDetails(const Expr *E);
5917+
59135918
/// Handle a friend type declaration. This works in tandem with
59145919
/// ActOnTag.
59155920
///

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4927,7 +4927,8 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
49274927
const auto *MemberCall = cast<CXXMemberCallExpr>(E);
49284928
if (!this->visit(MemberCall->getImplicitObjectArgument()))
49294929
return false;
4930-
return this->emitCheckDestruction(E) && this->emitPopPtr(E);
4930+
return this->emitCheckDestruction(E) && this->emitEndLifetime(E) &&
4931+
this->emitPopPtr(E);
49314932
}
49324933
}
49334934

@@ -5016,7 +5017,7 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
50165017
return this->discard(Base);
50175018
if (!this->visit(Base))
50185019
return false;
5019-
return this->emitKill(E);
5020+
return this->emitEndLifetimePop(E);
50205021
} else if (!FuncDecl) {
50215022
const Expr *Callee = E->getCallee();
50225023
CalleeOffset =

clang/lib/AST/ByteCode/DynamicAllocator.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ Block *DynamicAllocator::allocate(const Descriptor *D, unsigned EvalID,
8686
ID->IsInitialized = false;
8787
ID->IsVolatile = false;
8888

89+
ID->LifeState =
90+
AllocForm == Form::Operator ? Lifetime::Ended : Lifetime::Started;
91+
;
92+
8993
B->IsDynamic = true;
9094

9195
if (auto It = AllocationSites.find(D->asExpr()); It != AllocationSites.end())

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,50 @@ bool CallPtr(InterpState &S, CodePtr OpPC, uint32_t ArgSize,
16991699
return Call(S, OpPC, F, VarArgSize);
17001700
}
17011701

1702+
bool StartLifetime(InterpState &S, CodePtr OpPC) {
1703+
const auto &Ptr = S.Stk.peek<Pointer>();
1704+
if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
1705+
return false;
1706+
1707+
Ptr.startLifetime();
1708+
return true;
1709+
}
1710+
1711+
// FIXME: It might be better to the recursing as part of the generated code for
1712+
// a destructor?
1713+
static void endLifetimeRecurse(const Pointer &Ptr) {
1714+
Ptr.endLifetime();
1715+
if (const Record *R = Ptr.getRecord()) {
1716+
for (const Record::Field &Fi : R->fields())
1717+
endLifetimeRecurse(Ptr.atField(Fi.Offset));
1718+
return;
1719+
}
1720+
1721+
if (const Descriptor *FieldDesc = Ptr.getFieldDesc();
1722+
FieldDesc->isCompositeArray()) {
1723+
for (unsigned I = 0; I != FieldDesc->getNumElems(); ++I)
1724+
endLifetimeRecurse(Ptr.atIndex(I).narrow());
1725+
}
1726+
}
1727+
1728+
/// Ends the lifetime of the peek'd pointer.
1729+
bool EndLifetime(InterpState &S, CodePtr OpPC) {
1730+
const auto &Ptr = S.Stk.peek<Pointer>();
1731+
if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
1732+
return false;
1733+
endLifetimeRecurse(Ptr);
1734+
return true;
1735+
}
1736+
1737+
/// Ends the lifetime of the pop'd pointer.
1738+
bool EndLifetimePop(InterpState &S, CodePtr OpPC) {
1739+
const auto &Ptr = S.Stk.pop<Pointer>();
1740+
if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
1741+
return false;
1742+
endLifetimeRecurse(Ptr);
1743+
return true;
1744+
}
1745+
17021746
bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E,
17031747
std::optional<uint64_t> ArraySize) {
17041748
const Pointer &Ptr = S.Stk.peek<Pointer>();
@@ -1711,8 +1755,16 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E,
17111755
return false;
17121756
if (!CheckDummy(S, OpPC, Ptr, AK_Construct))
17131757
return false;
1714-
if (!CheckLifetime(S, OpPC, Ptr, AK_Construct))
1715-
return false;
1758+
1759+
// CheckLifetime for this and all base pointers.
1760+
for (Pointer P = Ptr;;) {
1761+
if (!CheckLifetime(S, OpPC, P, AK_Construct)) {
1762+
return false;
1763+
}
1764+
if (P.isRoot())
1765+
break;
1766+
P = P.getBase();
1767+
}
17161768
if (!CheckExtern(S, OpPC, Ptr))
17171769
return false;
17181770
if (!CheckRange(S, OpPC, Ptr, AK_Construct))

clang/lib/AST/ByteCode/Interp.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,21 +1326,9 @@ bool GetLocal(InterpState &S, CodePtr OpPC, uint32_t I) {
13261326
return true;
13271327
}
13281328

1329-
static inline bool Kill(InterpState &S, CodePtr OpPC) {
1330-
const auto &Ptr = S.Stk.pop<Pointer>();
1331-
if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
1332-
return false;
1333-
Ptr.endLifetime();
1334-
return true;
1335-
}
1336-
1337-
static inline bool StartLifetime(InterpState &S, CodePtr OpPC) {
1338-
const auto &Ptr = S.Stk.peek<Pointer>();
1339-
if (!CheckDummy(S, OpPC, Ptr, AK_Destroy))
1340-
return false;
1341-
Ptr.startLifetime();
1342-
return true;
1343-
}
1329+
bool EndLifetime(InterpState &S, CodePtr OpPC);
1330+
bool EndLifetimePop(InterpState &S, CodePtr OpPC);
1331+
bool StartLifetime(InterpState &S, CodePtr OpPC);
13441332

13451333
/// 1) Pops the value from the stack.
13461334
/// 2) Writes the value to the local variable with the

clang/lib/AST/ByteCode/Opcodes.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ def GetLocal : AccessOpcode { let HasCustomEval = 1; }
395395
// [] -> [Pointer]
396396
def SetLocal : AccessOpcode { let HasCustomEval = 1; }
397397

398-
def Kill : Opcode;
398+
def EndLifetimePop : Opcode;
399+
def EndLifetime : Opcode;
399400
def StartLifetime : Opcode;
400401

401402
def CheckDecl : Opcode {

clang/lib/AST/Type.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,13 +3797,13 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> params,
37973797
ExtraBits.EffectsHaveConditions = true;
37983798
auto *DestConds = getTrailingObjects<EffectConditionExpr>();
37993799
llvm::uninitialized_copy(SrcConds, DestConds);
3800-
assert(std::any_of(SrcConds.begin(), SrcConds.end(),
3801-
[](const EffectConditionExpr &EC) {
3802-
if (const Expr *E = EC.getCondition())
3803-
return E->isTypeDependent() ||
3804-
E->isValueDependent();
3805-
return false;
3806-
}) &&
3800+
assert(llvm::any_of(SrcConds,
3801+
[](const EffectConditionExpr &EC) {
3802+
if (const Expr *E = EC.getCondition())
3803+
return E->isTypeDependent() ||
3804+
E->isValueDependent();
3805+
return false;
3806+
}) &&
38073807
"expected a dependent expression among the conditions");
38083808
addDependence(TypeDependence::DependentInstantiation);
38093809
}

0 commit comments

Comments
 (0)