Skip to content

Commit 54ee055

Browse files
committed
Merge from 'main' to 'sycl-web' (9 commits)
CONFLICT (content): Merge conflict in clang/lib/Sema/SemaLambda.cpp
2 parents 2428a5e + a274219 commit 54ee055

File tree

84 files changed

+847
-607
lines changed

Some content is hidden

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

84 files changed

+847
-607
lines changed

clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,8 @@ bool ForLoopIndexUseVisitor::TraverseLambdaCapture(LambdaExpr *LE,
785785
const LambdaCapture *C,
786786
Expr *Init) {
787787
if (C->capturesVariable()) {
788-
const ValueDecl *VDecl = C->getCapturedVar();
789-
if (areSameVariable(IndexVar, VDecl)) {
788+
const VarDecl *VDecl = C->getCapturedVar();
789+
if (areSameVariable(IndexVar, cast<ValueDecl>(VDecl))) {
790790
// FIXME: if the index is captured, it will count as an usage and the
791791
// alias (if any) won't work, because it is only used in case of having
792792
// exactly one usage.

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ Bug Fixes
5757
- Improve compile-times with large dynamic array allocations with trivial
5858
constructors. This fixes
5959
`Issue 56774 <https://github.com/llvm/llvm-project/issues/56774>`_.
60+
- No longer assert/miscompile when trying to make a vectorized ``_BitInt`` type
61+
using the ``ext_vector_type`` attribute (the ``vector_size`` attribute was
62+
already properly diagnosing this case).
6063

6164
Improvements to Clang's diagnostics
6265
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -105,16 +108,6 @@ C++ Language Changes in Clang
105108
C++20 Feature Support
106109
^^^^^^^^^^^^^^^^^^^^^
107110

108-
- Support capturing structured bindings in lambdas
109-
(`P1091R3 <https://wg21.link/p1091r3>`_ and `P1381R1 <https://wg21.link/P1381R1>`).
110-
This fixes issues `GH52720 <https://github.com/llvm/llvm-project/issues/52720>`_,
111-
`GH54300 <https://github.com/llvm/llvm-project/issues/54300>`_,
112-
`GH54301 <https://github.com/llvm/llvm-project/issues/54301>`_,
113-
and `GH49430 <https://github.com/llvm/llvm-project/issues/49430>`_.
114-
115-
116-
117-
118111
C++2b Feature Support
119112
^^^^^^^^^^^^^^^^^^^^^
120113

clang/include/clang/AST/Decl.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -690,11 +690,6 @@ class ValueDecl : public NamedDecl {
690690
/// or declared with the weak or weak-ref attr.
691691
bool isWeak() const;
692692

693-
/// Whether this variable is the implicit variable for a lambda init-capture.
694-
/// Only VarDecl can be init captures, but both VarDecl and BindingDecl
695-
/// can be captured.
696-
bool isInitCapture() const;
697-
698693
// Implement isa/cast/dyncast/etc.
699694
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
700695
static bool classofKind(Kind K) { return K >= firstValue && K <= lastValue; }

clang/include/clang/AST/DeclCXX.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,8 @@ class CXXRecordDecl : public RecordDecl {
10571057
///
10581058
/// \note No entries will be added for init-captures, as they do not capture
10591059
/// variables.
1060-
void
1061-
getCaptureFields(llvm::DenseMap<const ValueDecl *, FieldDecl *> &Captures,
1062-
FieldDecl *&ThisCapture) const;
1060+
void getCaptureFields(llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures,
1061+
FieldDecl *&ThisCapture) const;
10631062

10641063
using capture_const_iterator = const LambdaCapture *;
10651064
using capture_const_range = llvm::iterator_range<capture_const_iterator>;

clang/include/clang/AST/LambdaCapture.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class LambdaCapture {
7171
/// capture that is a pack expansion, or an invalid source
7272
/// location to indicate that this is not a pack expansion.
7373
LambdaCapture(SourceLocation Loc, bool Implicit, LambdaCaptureKind Kind,
74-
ValueDecl *Var = nullptr,
74+
VarDecl *Var = nullptr,
7575
SourceLocation EllipsisLoc = SourceLocation());
7676

7777
/// Determine the kind of capture.
@@ -86,7 +86,7 @@ class LambdaCapture {
8686

8787
/// Determine whether this capture handles a variable.
8888
bool capturesVariable() const {
89-
return isa_and_nonnull<ValueDecl>(DeclAndBits.getPointer());
89+
return isa_and_nonnull<VarDecl>(DeclAndBits.getPointer());
9090
}
9191

9292
/// Determine whether this captures a variable length array bound
@@ -101,9 +101,9 @@ class LambdaCapture {
101101
///
102102
/// This operation is only valid if this capture is a variable capture
103103
/// (other than a capture of \c this).
104-
ValueDecl *getCapturedVar() const {
104+
VarDecl *getCapturedVar() const {
105105
assert(capturesVariable() && "No variable available for capture");
106-
return static_cast<ValueDecl *>(DeclAndBits.getPointer());
106+
return static_cast<VarDecl *>(DeclAndBits.getPointer());
107107
}
108108

109109
/// Determine whether this was an implicit capture (not

clang/include/clang/AST/Stmt.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class RecordDecl;
5959
class SourceManager;
6060
class StringLiteral;
6161
class Token;
62-
class ValueDecl;
6362
class VarDecl;
6463

6564
//===----------------------------------------------------------------------===//

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4722,7 +4722,7 @@ AST_MATCHER_P(LambdaExpr, hasAnyCapture, internal::Matcher<LambdaCapture>,
47224722
/// In the matcher
47234723
/// lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))),
47244724
/// capturesVar(hasName("x")) matches `x` and `x = 1`.
4725-
AST_MATCHER_P(LambdaCapture, capturesVar, internal::Matcher<ValueDecl>,
4725+
AST_MATCHER_P(LambdaCapture, capturesVar, internal::Matcher<VarDecl>,
47264726
InnerMatcher) {
47274727
auto *capturedVar = Node.getCapturedVar();
47284728
return capturedVar && InnerMatcher.matches(*capturedVar, Finder, Builder);

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9074,16 +9074,6 @@ def ext_ms_anonymous_record : ExtWarn<
90749074
def err_reference_to_local_in_enclosing_context : Error<
90759075
"reference to local %select{variable|binding}1 %0 declared in enclosing "
90769076
"%select{%3|block literal|lambda expression|context}2">;
9077-
def err_bitfield_capture_by_ref : Error<
9078-
"cannot capture a bit-field by reference">;
9079-
def err_capture_binding_openmp : Error<
9080-
"capturing a structured binding is not yet supported in OpenMP">;
9081-
def ext_capture_binding : ExtWarn<
9082-
"captured structured bindings are a C++20 extension">, InGroup<CXX20>;
9083-
def warn_cxx17_compat_capture_binding : Warning<
9084-
"captured structured bindings are incompatible with "
9085-
"C++ standards before C++20">,
9086-
InGroup<CXXPre20Compat>, DefaultIgnore;
90879077

90889078
def err_static_data_member_not_allowed_in_local_class : Error<
90899079
"static data member %0 not allowed in local %sub{select_tag_type_kind}2 %1">;

clang/include/clang/Sema/ScopeInfo.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ class Capture {
553553
const VariableArrayType *CapturedVLA;
554554

555555
/// Otherwise, the captured variable (if any).
556-
ValueDecl *CapturedVar;
556+
VarDecl *CapturedVar;
557557
};
558558

559559
/// The source location at which the first capture occurred.
@@ -589,13 +589,12 @@ class Capture {
589589
unsigned Invalid : 1;
590590

591591
public:
592-
Capture(ValueDecl *Var, bool Block, bool ByRef, bool IsNested,
592+
Capture(VarDecl *Var, bool Block, bool ByRef, bool IsNested,
593593
SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType,
594594
bool Invalid)
595595
: CapturedVar(Var), Loc(Loc), EllipsisLoc(EllipsisLoc),
596-
CaptureType(CaptureType), Kind(Block ? Cap_Block
597-
: ByRef ? Cap_ByRef
598-
: Cap_ByCopy),
596+
CaptureType(CaptureType),
597+
Kind(Block ? Cap_Block : ByRef ? Cap_ByRef : Cap_ByCopy),
599598
Nested(IsNested), CapturesThis(false), ODRUsed(false),
600599
NonODRUsed(false), Invalid(Invalid) {}
601600

@@ -640,7 +639,7 @@ class Capture {
640639
NonODRUsed = true;
641640
}
642641

643-
ValueDecl *getVariable() const {
642+
VarDecl *getVariable() const {
644643
assert(isVariableCapture());
645644
return CapturedVar;
646645
}
@@ -679,7 +678,7 @@ class CapturingScopeInfo : public FunctionScopeInfo {
679678
: FunctionScopeInfo(Diag), ImpCaptureStyle(Style) {}
680679

681680
/// CaptureMap - A map of captured variables to (index+1) into Captures.
682-
llvm::DenseMap<ValueDecl *, unsigned> CaptureMap;
681+
llvm::DenseMap<VarDecl*, unsigned> CaptureMap;
683682

684683
/// CXXThisCaptureIndex - The (index+1) of the capture of 'this';
685684
/// zero if 'this' is not captured.
@@ -696,7 +695,7 @@ class CapturingScopeInfo : public FunctionScopeInfo {
696695
/// or null if unknown.
697696
QualType ReturnType;
698697

699-
void addCapture(ValueDecl *Var, bool isBlock, bool isByref, bool isNested,
698+
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested,
700699
SourceLocation Loc, SourceLocation EllipsisLoc,
701700
QualType CaptureType, bool Invalid) {
702701
Captures.push_back(Capture(Var, isBlock, isByref, isNested, Loc,
@@ -723,21 +722,23 @@ class CapturingScopeInfo : public FunctionScopeInfo {
723722
}
724723

725724
/// Determine whether the given variable has been captured.
726-
bool isCaptured(ValueDecl *Var) const { return CaptureMap.count(Var); }
725+
bool isCaptured(VarDecl *Var) const {
726+
return CaptureMap.count(Var);
727+
}
727728

728729
/// Determine whether the given variable-array type has been captured.
729730
bool isVLATypeCaptured(const VariableArrayType *VAT) const;
730731

731732
/// Retrieve the capture of the given variable, if it has been
732733
/// captured already.
733-
Capture &getCapture(ValueDecl *Var) {
734+
Capture &getCapture(VarDecl *Var) {
734735
assert(isCaptured(Var) && "Variable has not been captured");
735736
return Captures[CaptureMap[Var] - 1];
736737
}
737738

738-
const Capture &getCapture(ValueDecl *Var) const {
739-
llvm::DenseMap<ValueDecl *, unsigned>::const_iterator Known =
740-
CaptureMap.find(Var);
739+
const Capture &getCapture(VarDecl *Var) const {
740+
llvm::DenseMap<VarDecl*, unsigned>::const_iterator Known
741+
= CaptureMap.find(Var);
741742
assert(Known != CaptureMap.end() && "Variable has not been captured");
742743
return Captures[Known->second - 1];
743744
}

clang/include/clang/Sema/Sema.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5586,23 +5586,23 @@ class Sema final {
55865586
///
55875587
/// \returns true if an error occurred (i.e., the variable cannot be
55885588
/// captured) and false if the capture succeeded.
5589-
bool tryCaptureVariable(ValueDecl *Var, SourceLocation Loc,
5590-
TryCaptureKind Kind, SourceLocation EllipsisLoc,
5591-
bool BuildAndDiagnose, QualType &CaptureType,
5589+
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind,
5590+
SourceLocation EllipsisLoc, bool BuildAndDiagnose,
5591+
QualType &CaptureType,
55925592
QualType &DeclRefType,
55935593
const unsigned *const FunctionScopeIndexToStopAt);
55945594

55955595
/// Try to capture the given variable.
5596-
bool tryCaptureVariable(ValueDecl *Var, SourceLocation Loc,
5596+
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc,
55975597
TryCaptureKind Kind = TryCapture_Implicit,
55985598
SourceLocation EllipsisLoc = SourceLocation());
55995599

56005600
/// Checks if the variable must be captured.
5601-
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc);
5601+
bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc);
56025602

56035603
/// Given a variable, determine the type that a reference to that
56045604
/// variable will have in the given scope.
5605-
QualType getCapturedDeclRefType(ValueDecl *Var, SourceLocation Loc);
5605+
QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc);
56065606

56075607
/// Mark all of the declarations referenced within a particular AST node as
56085608
/// referenced. Used when template instantiation instantiates a non-dependent

0 commit comments

Comments
 (0)