Skip to content

Commit 43c0d1c

Browse files
authored
merge main into amd-staging (#657)
2 parents c23228a + b44c3f1 commit 43c0d1c

File tree

121 files changed

+6757
-6341
lines changed

Some content is hidden

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

121 files changed

+6757
-6341
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ Bug Fixes to C++ Support
800800
- Diagnose unresolved overload sets in non-dependent compound requirements. (#GH51246) (#GH97753)
801801
- Fix a crash when extracting unavailable member type from alias in template deduction. (#GH165560)
802802
- Fix incorrect diagnostics for lambdas with init-captures inside braced initializers. (#GH163498)
803+
- Fixed spurious diagnoses of certain nested lambda expressions. (#GH149121) (#GH156579)
803804

804805
Bug Fixes to AST Handling
805806
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,9 @@ static bool RoundTrip(ParseFn Parse, GenerateFn Generate,
856856
// Compares two lists of arguments.
857857
auto Equal = [](const ArrayRef<const char *> A,
858858
const ArrayRef<const char *> B) {
859-
return std::equal(A.begin(), A.end(), B.begin(), B.end(),
860-
[](const char *AElem, const char *BElem) {
861-
return StringRef(AElem) == StringRef(BElem);
862-
});
859+
return llvm::equal(A, B, [](const char *AElem, const char *BElem) {
860+
return StringRef(AElem) == StringRef(BElem);
861+
});
863862
};
864863

865864
// If we generated different arguments from what we assume are two

clang/lib/Lex/Preprocessor.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,10 +1458,8 @@ void Preprocessor::removeCommentHandler(CommentHandler *Handler) {
14581458

14591459
bool Preprocessor::HandleComment(Token &result, SourceRange Comment) {
14601460
bool AnyPendingTokens = false;
1461-
for (std::vector<CommentHandler *>::iterator H = CommentHandlers.begin(),
1462-
HEnd = CommentHandlers.end();
1463-
H != HEnd; ++H) {
1464-
if ((*H)->HandleComment(*this, Comment))
1461+
for (CommentHandler *H : CommentHandlers) {
1462+
if (H->HandleComment(*this, Comment))
14651463
AnyPendingTokens = true;
14661464
}
14671465
if (!AnyPendingTokens || getCommentRetentionState())

clang/lib/Sema/TreeTransform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15628,6 +15628,8 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
1562815628
DC = DC->getParent();
1562915629
if ((getSema().isUnevaluatedContext() ||
1563015630
getSema().isConstantEvaluatedContext()) &&
15631+
!(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
15632+
cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
1563115633
(DC->isFileContext() || !DC->getParent()->isDependentContext()))
1563215634
DependencyKind = CXXRecordDecl::LDK_NeverDependent;
1563315635

clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,12 @@ bool CallAndMessageChecker::PreVisitProcessArg(
322322
else {
323323
os << " (e.g., via the field chain: '";
324324
bool first = true;
325-
for (SmallVectorImpl<const FieldDecl *>::iterator
326-
DI = F.FieldChain.begin(), DE = F.FieldChain.end(); DI!=DE;++DI){
325+
for (const FieldDecl *FD : F.FieldChain) {
327326
if (first)
328327
first = false;
329328
else
330329
os << '.';
331-
os << **DI;
330+
os << *FD;
332331
}
333332
os << "')";
334333
}

clang/test/SemaCXX/cxx2a-consteval.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,27 @@ namespace GH139160{
13191319
B result = (B){10, get_value(make_struct())}; // expected-error {{initializer element is not a compile-time constant}}
13201320
// expected-error@-1 {{call to consteval function 'GH139160::get_value' is not a constant expression}}
13211321
// expected-note@-2 {{non-constexpr function 'make_struct' cannot be used in a constant expression}}
1322-
};
1322+
} // namespace GH139160
1323+
1324+
namespace GH118187 {
1325+
1326+
template <typename T> int t() {
1327+
return []<typename U>() consteval {
1328+
return [](U v) { return v; }(123);
1329+
}.template operator()<int>();
1330+
}
13231331

1332+
int v = t<int>();
1333+
} // namespace GH118187
13241334

1335+
namespace GH156579 {
1336+
template <class>
1337+
auto f{[] (auto...) {
1338+
if constexpr ([] (auto) { return true; }(0))
1339+
return 0;
1340+
}};
1341+
1342+
void g() {
1343+
f<int>();
1344+
}
1345+
} // namespace GH156579

clang/utils/TableGen/NeonEmitter.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,13 +2233,10 @@ NeonEmitter::areRangeChecksCompatible(const ArrayRef<ImmCheck> ChecksA,
22332233
// the same. The element types may differ as they will be resolved
22342234
// per-intrinsic as overloaded types by SemaArm.cpp, though the vector sizes
22352235
// are not and so must be the same.
2236-
bool compat =
2237-
std::equal(ChecksA.begin(), ChecksA.end(), ChecksB.begin(), ChecksB.end(),
2238-
[](const auto &A, const auto &B) {
2239-
return A.getImmArgIdx() == B.getImmArgIdx() &&
2240-
A.getKind() == B.getKind() &&
2241-
A.getVecSizeInBits() == B.getVecSizeInBits();
2242-
});
2236+
bool compat = llvm::equal(ChecksA, ChecksB, [](const auto &A, const auto &B) {
2237+
return A.getImmArgIdx() == B.getImmArgIdx() && A.getKind() == B.getKind() &&
2238+
A.getVecSizeInBits() == B.getVecSizeInBits();
2239+
});
22432240

22442241
return compat;
22452242
}

flang/include/flang/Parser/openmp-utils.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ const OpenMPConstruct *GetOmp(const ExecutionPartConstruct &x);
126126
const OpenMPLoopConstruct *GetOmpLoop(const ExecutionPartConstruct &x);
127127
const DoConstruct *GetDoConstruct(const ExecutionPartConstruct &x);
128128

129+
// Is the template argument "Statement<T>" for some T?
130+
template <typename T> struct IsStatement {
131+
static constexpr bool value{false};
132+
};
133+
template <typename T> struct IsStatement<Statement<T>> {
134+
static constexpr bool value{true};
135+
};
136+
137+
std::optional<Label> GetStatementLabel(const ExecutionPartConstruct &x);
138+
std::optional<Label> GetFinalLabel(const OpenMPConstruct &x);
139+
129140
const OmpObjectList *GetOmpObjectList(const OmpClause &clause);
130141

131142
template <typename T>

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ template <typename ExecParser> struct AsBlockParser {
7171
if (auto &&exec{attempt(epc_).Parse(state)}) {
7272
Block body;
7373
body.push_back(std::move(*exec));
74-
return body;
74+
return std::move(body); // std::move for GCC 7.5.0
7575
}
7676
return std::nullopt;
7777
}
@@ -1731,30 +1731,6 @@ struct NonBlockDoConstructParser {
17311731
}
17321732
return std::nullopt;
17331733
}
1734-
1735-
private:
1736-
// Is the template argument "Statement<T>" for some T?
1737-
template <typename T> struct IsStatement {
1738-
static constexpr bool value{false};
1739-
};
1740-
template <typename T> struct IsStatement<Statement<T>> {
1741-
static constexpr bool value{true};
1742-
};
1743-
1744-
// Get the Label from a Statement<...> contained in an ExecutionPartConstruct,
1745-
// or std::nullopt, if there is no Statement<...> contained in there.
1746-
template <typename T>
1747-
static std::optional<Label> GetStatementLabel(const T &stmt) {
1748-
if constexpr (IsStatement<T>::value) {
1749-
return stmt.label;
1750-
} else if constexpr (WrapperTrait<T>) {
1751-
return GetStatementLabel(stmt.v);
1752-
} else if constexpr (UnionTrait<T>) {
1753-
return common::visit(
1754-
[&](auto &&s) { return GetStatementLabel(s); }, stmt.u);
1755-
}
1756-
return std::nullopt;
1757-
}
17581734
};
17591735

17601736
struct LoopNestParser {

flang/lib/Parser/openmp-utils.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "flang/Common/indirection.h"
1616
#include "flang/Common/template.h"
1717
#include "flang/Common/visit.h"
18+
#include "flang/Parser/tools.h"
1819

1920
#include <tuple>
2021
#include <type_traits>
@@ -58,6 +59,63 @@ const DoConstruct *GetDoConstruct(const ExecutionPartConstruct &x) {
5859
return nullptr;
5960
}
6061

62+
// Get the Label from a Statement<...> contained in an ExecutionPartConstruct,
63+
// or std::nullopt, if there is no Statement<...> contained in there.
64+
template <typename T>
65+
static std::optional<Label> GetStatementLabelHelper(const T &stmt) {
66+
if constexpr (IsStatement<T>::value) {
67+
return stmt.label;
68+
} else if constexpr (WrapperTrait<T>) {
69+
return GetStatementLabelHelper(stmt.v);
70+
} else if constexpr (UnionTrait<T>) {
71+
return common::visit(
72+
[&](auto &&s) { return GetStatementLabelHelper(s); }, stmt.u);
73+
}
74+
return std::nullopt;
75+
}
76+
77+
std::optional<Label> GetStatementLabel(const ExecutionPartConstruct &x) {
78+
return GetStatementLabelHelper(x);
79+
}
80+
81+
static std::optional<Label> GetFinalLabel(const Block &x) {
82+
if (!x.empty()) {
83+
const ExecutionPartConstruct &last{x.back()};
84+
if (auto *omp{Unwrap<OpenMPConstruct>(last)}) {
85+
return GetFinalLabel(*omp);
86+
} else if (auto *doLoop{Unwrap<DoConstruct>(last)}) {
87+
return GetFinalLabel(std::get<Block>(doLoop->t));
88+
} else {
89+
return GetStatementLabel(x.back());
90+
}
91+
} else {
92+
return std::nullopt;
93+
}
94+
}
95+
96+
std::optional<Label> GetFinalLabel(const OpenMPConstruct &x) {
97+
return common::visit(
98+
[](auto &&s) -> std::optional<Label> {
99+
using TypeS = llvm::remove_cvref_t<decltype(s)>;
100+
if constexpr (std::is_same_v<TypeS, OpenMPSectionsConstruct>) {
101+
auto &list{std::get<std::list<OpenMPConstruct>>(s.t)};
102+
if (!list.empty()) {
103+
return GetFinalLabel(list.back());
104+
} else {
105+
return std::nullopt;
106+
}
107+
} else if constexpr ( //
108+
std::is_same_v<TypeS, OpenMPLoopConstruct> ||
109+
std::is_same_v<TypeS, OpenMPSectionConstruct> ||
110+
std::is_base_of_v<OmpBlockConstruct, TypeS>) {
111+
return GetFinalLabel(std::get<Block>(s.t));
112+
} else {
113+
return std::nullopt;
114+
}
115+
},
116+
x.u);
117+
}
118+
61119
const OmpObjectList *GetOmpObjectList(const OmpClause &clause) {
62120
// Clauses with OmpObjectList as its data member
63121
using MemberObjectListClauses = std::tuple<OmpClause::Copyin,

0 commit comments

Comments
 (0)