Skip to content

Commit 7789e64

Browse files
committed
Merge branch 'main' into users/meinersbur/mlir_tile
2 parents bcc5cd5 + 2512611 commit 7789e64

File tree

132 files changed

+3201
-3288
lines changed

Some content is hidden

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

132 files changed

+3201
-3288
lines changed

clang/docs/InternalsManual.rst

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,67 +2859,6 @@ This library is called by the :ref:`Parser library <Parser>` during parsing to
28592859
do semantic analysis of the input. For valid programs, Sema builds an AST for
28602860
parsed constructs.
28612861

2862-
2863-
Concept Satisfaction Checking and Subsumption
2864-
---------------------------------------------
2865-
2866-
As per the C++ standard, constraints are `normalized <https://eel.is/c++draft/temp.constr.normal>`_
2867-
and the normal form is used both for subsumption, and constraint checking.
2868-
Both depend on a parameter mapping that substitutes lazily. In particular,
2869-
we should not substitute in unused arguments.
2870-
2871-
Clang follows the order of operations prescribed by the standard.
2872-
2873-
Normalization happens prior to satisfaction and subsumption
2874-
and is handled by ``NormalizedConstraint``.
2875-
2876-
Clang preserves in the normalized form intermediate concept-ids
2877-
(``ConceptIdConstraint``) This is used for diagnostics only and no substitution
2878-
happens in a ConceptIdConstraint if its expression is satisfied.
2879-
2880-
The normal form of the associated constraints of a declaration is cached in
2881-
Sema::NormalizationCache such that it is only computed once.
2882-
2883-
A ``NormalizedConstraint`` is a recursive data structure, where each node
2884-
contains a parameter mapping, represented by the indexes of all parameter
2885-
being used.
2886-
2887-
Checking satisfaction is done by ``ConstraintSatisfactionChecker``, recursively
2888-
walking ``NormalizedConstraint``. At each level, we substitute the outermost
2889-
level of the template arguments referenced in the parameter mapping of a
2890-
normalized expression (``MultiLevelTemplateArgumentList``).
2891-
2892-
For the following example,
2893-
2894-
.. code-block:: c++
2895-
2896-
template <typename T>
2897-
concept A = __is_same(T, int);
2898-
2899-
template <typename U>
2900-
concept B = A<U> && __is_same(U, int);
2901-
2902-
The normal form of B is
2903-
2904-
.. code-block:: c++
2905-
2906-
__is_same(T, int) /*T->U, innermost level*/
2907-
&& __is_same(U, int) {U->U} /*T->U, outermost level*/
2908-
2909-
After substitution in the mapping, we substitute in the constraint expression
2910-
using that copy of the ``MultiLevelTemplateArgumentList``, and then evaluate it.
2911-
2912-
Because this is expensive, it is cached in
2913-
``UnsubstitutedConstraintSatisfactionCache``.
2914-
2915-
Any error during satisfaction is recorded in ``ConstraintSatisfaction``.
2916-
for nested requirements, ``ConstraintSatisfaction`` is stored (including
2917-
diagnostics) in the AST, which is something we might want to improve.
2918-
2919-
When an atomic constraint is not satified, we try to substitute into any
2920-
enclosing concept-id using the same mechanism described above, for
2921-
diagnostics purpose, and inject that in the ``ConstraintSatisfaction``.
2922-
29232862
.. _CodeGen:
29242863

29252864
The CodeGen Library

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ C++23 Feature Support
160160
C++20 Feature Support
161161
^^^^^^^^^^^^^^^^^^^^^
162162

163-
- Clang now normalizes constraints before checking whether they are satisfied, as mandated by the standard.
164-
As a result, Clang no longer incorrectly diagnoses substitution failures in template arguments only
165-
used in concept-ids, and produces better diagnostics for satisfaction failure. (#GH61811) (#GH135190)
166-
167163
C++17 Feature Support
168164
^^^^^^^^^^^^^^^^^^^^^
169165

@@ -450,6 +446,7 @@ Bug Fixes to AST Handling
450446
legal representation. This is fixed because ElaboratedTypes don't exist anymore. (#GH43179) (#GH68670) (#GH92757)
451447
- Fix unrecognized html tag causing undesirable comment lexing (#GH152944)
452448
- Fix comment lexing of special command names (#GH152943)
449+
- Use `extern` as a hint to continue parsing when recovering from a malformed declaration.
453450

454451
Miscellaneous Bug Fixes
455452
^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ASTConcept.h

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,10 @@ namespace clang {
2828

2929
class ConceptDecl;
3030
class TemplateDecl;
31-
class ConceptReference;
3231
class Expr;
3332
class NamedDecl;
3433
struct PrintingPolicy;
3534

36-
/// Unsatisfied constraint expressions if the template arguments could be
37-
/// substituted into them, or a diagnostic if substitution resulted in
38-
/// an invalid expression.
39-
///
40-
using ConstraintSubstitutionDiagnostic = std::pair<SourceLocation, StringRef>;
41-
using UnsatisfiedConstraintRecord =
42-
llvm::PointerUnion<const Expr *, const ConceptReference *,
43-
const ConstraintSubstitutionDiagnostic *>;
44-
4535
/// The result of a constraint satisfaction check, containing the necessary
4636
/// information to diagnose an unsatisfied constraint.
4737
class ConstraintSatisfaction : public llvm::FoldingSetNode {
@@ -58,13 +48,16 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode {
5848
ArrayRef<TemplateArgument> TemplateArgs)
5949
: ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs) {}
6050

51+
using SubstitutionDiagnostic = std::pair<SourceLocation, StringRef>;
52+
using Detail = llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>;
53+
6154
bool IsSatisfied = false;
6255
bool ContainsErrors = false;
6356

6457
/// \brief The substituted constraint expr, if the template arguments could be
6558
/// substituted into them, or a diagnostic if substitution resulted in an
6659
/// invalid expression.
67-
llvm::SmallVector<UnsatisfiedConstraintRecord, 4> Details;
60+
llvm::SmallVector<Detail, 4> Details;
6861

6962
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) {
7063
Profile(ID, C, ConstraintOwner, TemplateArgs);
@@ -76,12 +69,19 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode {
7669

7770
bool HasSubstitutionFailure() {
7871
for (const auto &Detail : Details)
79-
if (Detail.dyn_cast<const ConstraintSubstitutionDiagnostic *>())
72+
if (Detail.dyn_cast<SubstitutionDiagnostic *>())
8073
return true;
8174
return false;
8275
}
8376
};
8477

78+
/// Pairs of unsatisfied atomic constraint expressions along with the
79+
/// substituted constraint expr, if the template arguments could be
80+
/// substituted into them, or a diagnostic if substitution resulted in
81+
/// an invalid expression.
82+
using UnsatisfiedConstraintRecord =
83+
llvm::PointerUnion<Expr *, std::pair<SourceLocation, StringRef> *>;
84+
8585
/// \brief The result of a constraint satisfaction check, containing the
8686
/// necessary information to diagnose an unsatisfied constraint.
8787
///
@@ -101,10 +101,6 @@ struct ASTConstraintSatisfaction final :
101101
return getTrailingObjects() + NumRecords;
102102
}
103103

104-
ArrayRef<UnsatisfiedConstraintRecord> records() const {
105-
return {begin(), end()};
106-
}
107-
108104
ASTConstraintSatisfaction(const ASTContext &C,
109105
const ConstraintSatisfaction &Satisfaction);
110106
ASTConstraintSatisfaction(const ASTContext &C,
@@ -286,11 +282,6 @@ class TypeConstraint {
286282
}
287283
};
288284

289-
/// Insertion operator for diagnostics. This allows sending ConceptReferences's
290-
/// into a diagnostic with <<.
291-
const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
292-
const ConceptReference *C);
293-
294285
} // clang
295286

296287
#endif // LLVM_CLANG_AST_ASTCONCEPT_H

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,6 +3877,7 @@ typename clang::LazyGenerationalUpdatePtr<Owner, T, Update>::ValueType
38773877
return new (Ctx) LazyData(Source, Value);
38783878
return Value;
38793879
}
3880+
38803881
template <> struct llvm::DenseMapInfo<llvm::FoldingSetNodeID> {
38813882
static FoldingSetNodeID getEmptyKey() { return FoldingSetNodeID{}; }
38823883

clang/include/clang/Analysis/CFG.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,7 @@ class CFG {
12511251
bool MarkElidedCXXConstructors = false;
12521252
bool AddVirtualBaseBranches = false;
12531253
bool OmitImplicitValueInitializers = false;
1254+
bool AssumeReachableDefaultInSwitchStatements = false;
12541255

12551256
BuildOptions() = default;
12561257

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ struct MissingFeatures {
133133
// RecordType
134134
static bool skippedLayout() { return false; }
135135
static bool astRecordDeclAttr() { return false; }
136-
static bool recordZeroInit() { return false; }
137136
static bool recordZeroInitPadding() { return false; }
138137
static bool zeroSizeRecordMembers() { return false; }
139138

@@ -192,6 +191,7 @@ struct MissingFeatures {
192191
static bool builtinCheckKind() { return false; }
193192
static bool cgCapturedStmtInfo() { return false; }
194193
static bool cgFPOptionsRAII() { return false; }
194+
static bool checkBitfieldClipping() { return false; }
195195
static bool cirgenABIInfo() { return false; }
196196
static bool cleanupAfterErrorDiags() { return false; }
197197
static bool cleanupsToDeactivate() { return false; }

0 commit comments

Comments
 (0)