Skip to content

Commit 03adf39

Browse files
author
MUSTAPHA BARKI
authored
Merge branch 'main' into Uncontrolled-data-used-in-path-expression
2 parents 8993144 + 3960ff6 commit 03adf39

File tree

327 files changed

+9891
-4878
lines changed

Some content is hidden

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

327 files changed

+9891
-4878
lines changed

clang-tools-extra/clang-include-fixer/IncludeFixer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bool IncludeFixerActionFactory::runInvocation(
9696
// diagnostics here.
9797
Compiler.createDiagnostics(new clang::IgnoringDiagConsumer,
9898
/*ShouldOwnClient=*/true);
99-
Compiler.createSourceManager(*Files);
99+
Compiler.createSourceManager();
100100

101101
// We abort on fatal errors so don't let a large number of errors become
102102
// fatal. A missing #include can cause thousands of errors.

clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,12 @@ TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) {
649649
Clang->createVirtualFileSystem(VFS);
650650
Clang->createDiagnostics();
651651

652-
auto *FM = Clang->createFileManager();
652+
Clang->createFileManager();
653+
FileManager &FM = Clang->getFileManager();
653654
ASSERT_TRUE(Clang->ExecuteAction(*Inputs.MakeAction()));
654655
EXPECT_THAT(
655-
PI.getExporters(llvm::cantFail(FM->getFileRef("foo.h")), *FM),
656-
testing::ElementsAre(llvm::cantFail(FM->getFileRef("exporter.h"))));
656+
PI.getExporters(llvm::cantFail(FM.getFileRef("foo.h")), FM),
657+
testing::ElementsAre(llvm::cantFail(FM.getFileRef("exporter.h"))));
657658
}
658659

659660
TEST_F(PragmaIncludeTest, OutlivesFMAndSM) {

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 & 6 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

@@ -250,8 +246,6 @@ Non-comprehensive list of changes in this release
250246

251247
- ``__builtin_assume_dereferenceable`` now accepts non-constant size operands.
252248

253-
- Fixed a crash when the second argument to ``__builtin_assume_aligned`` was not constant (#GH161314)
254-
255249
New Compiler Flags
256250
------------------
257251
- New option ``-fno-sanitize-debug-trap-reasons`` added to disable emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanitize-trap=undefined``).
@@ -450,6 +444,7 @@ Bug Fixes to AST Handling
450444
legal representation. This is fixed because ElaboratedTypes don't exist anymore. (#GH43179) (#GH68670) (#GH92757)
451445
- Fix unrecognized html tag causing undesirable comment lexing (#GH152944)
452446
- Fix comment lexing of special command names (#GH152943)
447+
- Use `extern` as a hint to continue parsing when recovering from a malformed declaration.
453448

454449
Miscellaneous Bug Fixes
455450
^^^^^^^^^^^^^^^^^^^^^^^

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/AST/OpenACCClause.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -840,14 +840,13 @@ class OpenACCClauseWithVarList : public OpenACCClauseWithExprs {
840840
// alloca at the level of the base, and the init at the element level.
841841
struct OpenACCPrivateRecipe {
842842
VarDecl *AllocaDecl;
843-
Expr *InitExpr;
844843

845-
OpenACCPrivateRecipe(VarDecl *A, Expr *I) : AllocaDecl(A), InitExpr(I) {}
844+
OpenACCPrivateRecipe(VarDecl *A) : AllocaDecl(A) {}
846845

847846
bool isSet() const { return AllocaDecl; }
848847

849848
static OpenACCPrivateRecipe Empty() {
850-
return OpenACCPrivateRecipe(nullptr, nullptr);
849+
return OpenACCPrivateRecipe(/*AllocaDecl=*/nullptr);
851850
}
852851
};
853852

@@ -899,18 +898,17 @@ class OpenACCPrivateClause final
899898
// InitFromTemporary is the 'temp' declaration we put in to be 'copied from'.
900899
struct OpenACCFirstPrivateRecipe {
901900
VarDecl *AllocaDecl;
902-
Expr *InitExpr;
903901
VarDecl *InitFromTemporary;
904-
OpenACCFirstPrivateRecipe(VarDecl *A, Expr *I, VarDecl *T)
905-
: AllocaDecl(A), InitExpr(I), InitFromTemporary(T) {
906-
assert(!AllocaDecl || AllocaDecl->getInit() == nullptr);
902+
OpenACCFirstPrivateRecipe(VarDecl *A, VarDecl *T)
903+
: AllocaDecl(A), InitFromTemporary(T) {
907904
assert(!InitFromTemporary || InitFromTemporary->getInit() == nullptr);
908905
}
909906

910907
bool isSet() const { return AllocaDecl; }
911908

912909
static OpenACCFirstPrivateRecipe Empty() {
913-
return OpenACCFirstPrivateRecipe(nullptr, nullptr, nullptr);
910+
return OpenACCFirstPrivateRecipe(/*AllocaDecl=*/nullptr,
911+
/*InitFromTemporary=*/nullptr);
914912
}
915913
};
916914

@@ -1282,16 +1280,13 @@ class OpenACCCreateClause final
12821280
// 'main' declaration used for initializaiton, which is fixed.
12831281
struct OpenACCReductionRecipe {
12841282
VarDecl *AllocaDecl;
1285-
Expr *InitExpr;
12861283
// TODO: OpenACC: this should eventually have the operations here too.
12871284

1288-
OpenACCReductionRecipe(VarDecl *A, Expr *I) : AllocaDecl(A), InitExpr(I) {
1289-
assert(!AllocaDecl || AllocaDecl->getInit() == nullptr);
1290-
}
1285+
OpenACCReductionRecipe(VarDecl *A) : AllocaDecl(A) {}
12911286

12921287
bool isSet() const { return AllocaDecl; }
12931288
static OpenACCReductionRecipe Empty() {
1294-
return OpenACCReductionRecipe(nullptr, nullptr);
1289+
return OpenACCReductionRecipe(/*AllocaDecl=*/nullptr);
12951290
}
12961291
};
12971292

clang/include/clang/AST/TypeBase.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6702,15 +6702,21 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode {
67026702
LLVM_PREFERRED_TYPE(bool)
67036703
uint8_t RawBuffer : 1;
67046704

6705+
LLVM_PREFERRED_TYPE(bool)
6706+
uint8_t IsCounter : 1;
6707+
67056708
Attributes(llvm::dxil::ResourceClass ResourceClass, bool IsROV = false,
6706-
bool RawBuffer = false)
6707-
: ResourceClass(ResourceClass), IsROV(IsROV), RawBuffer(RawBuffer) {}
6709+
bool RawBuffer = false, bool IsCounter = false)
6710+
: ResourceClass(ResourceClass), IsROV(IsROV), RawBuffer(RawBuffer),
6711+
IsCounter(IsCounter) {}
67086712

6709-
Attributes() : Attributes(llvm::dxil::ResourceClass::UAV, false, false) {}
6713+
Attributes()
6714+
: Attributes(llvm::dxil::ResourceClass::UAV, false, false, false) {}
67106715

67116716
friend bool operator==(const Attributes &LHS, const Attributes &RHS) {
6712-
return std::tie(LHS.ResourceClass, LHS.IsROV, LHS.RawBuffer) ==
6713-
std::tie(RHS.ResourceClass, RHS.IsROV, RHS.RawBuffer);
6717+
return std::tie(LHS.ResourceClass, LHS.IsROV, LHS.RawBuffer,
6718+
LHS.IsCounter) == std::tie(RHS.ResourceClass, RHS.IsROV,
6719+
RHS.RawBuffer, RHS.IsCounter);
67146720
}
67156721
friend bool operator!=(const Attributes &LHS, const Attributes &RHS) {
67166722
return !(LHS == RHS);
@@ -6751,6 +6757,7 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode {
67516757
ID.AddInteger(static_cast<uint32_t>(Attrs.ResourceClass));
67526758
ID.AddBoolean(Attrs.IsROV);
67536759
ID.AddBoolean(Attrs.RawBuffer);
6760+
ID.AddBoolean(Attrs.IsCounter);
67546761
}
67556762

67566763
static bool classof(const Type *T) {

clang/include/clang/AST/TypeProperties.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,14 +662,17 @@ let Class = HLSLAttributedResourceType in {
662662
def : Property<"rawBuffer", Bool> {
663663
let Read = [{ node->getAttrs().RawBuffer }];
664664
}
665+
def : Property<"isCounter", Bool> {
666+
let Read = [{ node->getAttrs().IsCounter }];
667+
}
665668
def : Property<"wrappedTy", QualType> {
666669
let Read = [{ node->getWrappedType() }];
667670
}
668671
def : Property<"containedTy", QualType> {
669672
let Read = [{ node->getContainedType() }];
670673
}
671674
def : Creator<[{
672-
HLSLAttributedResourceType::Attributes attrs(static_cast<llvm::dxil::ResourceClass>(resClass), isROV, rawBuffer);
675+
HLSLAttributedResourceType::Attributes attrs(static_cast<llvm::dxil::ResourceClass>(resClass), isROV, rawBuffer, isCounter);
673676
return ctx.getHLSLAttributedResourceType(wrappedTy, containedTy, attrs);
674677
}]>;
675678
}

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

0 commit comments

Comments
 (0)