Skip to content

Commit 5012767

Browse files
Merge branch 'main' into libcxx-lldb-bootstrapping-build-ci-fix
2 parents 75f0f14 + 909212f commit 5012767

File tree

273 files changed

+5165
-2305
lines changed

Some content is hidden

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

273 files changed

+5165
-2305
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
stage1:
3838
if: github.repository_owner == 'llvm'
3939
runs-on: libcxx-self-hosted-linux
40-
container: ghcr.io/llvm/libcxx-linux-builder:2b57ebb50b6d418e70382e655feaa619b558e254
40+
container: ghcr.io/llvm/libcxx-linux-builder:b060022103f551d8ca1dad84122ef73927c86512
4141
continue-on-error: false
4242
strategy:
4343
fail-fast: false

clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,41 @@ internal::Matcher<Decl> knownSmartptr() {
4949

5050
void registerMatchersForGetArrowStart(MatchFinder *Finder,
5151
MatchFinder::MatchCallback *Callback) {
52-
const auto QuacksLikeASmartptr = recordDecl(
53-
recordDecl().bind("duck_typing"),
54-
has(cxxMethodDecl(hasName("operator->"),
55-
returns(qualType(pointsTo(type().bind("op->Type")))))),
56-
has(cxxMethodDecl(hasName("operator*"), returns(qualType(references(
57-
type().bind("op*Type")))))));
52+
const auto MatchesOpArrow =
53+
allOf(hasName("operator->"),
54+
returns(qualType(pointsTo(type().bind("op->Type")))));
55+
const auto MatchesOpStar =
56+
allOf(hasName("operator*"),
57+
returns(qualType(references(type().bind("op*Type")))));
58+
const auto HasRelevantOps =
59+
allOf(anyOf(hasMethod(MatchesOpArrow),
60+
has(functionTemplateDecl(has(functionDecl(MatchesOpArrow))))),
61+
anyOf(hasMethod(MatchesOpStar),
62+
has(functionTemplateDecl(has(functionDecl(MatchesOpStar))))));
63+
64+
const auto QuacksLikeASmartptr =
65+
cxxRecordDecl(cxxRecordDecl().bind("duck_typing"), HasRelevantOps);
5866

5967
// Make sure we are not missing the known standard types.
60-
const auto Smartptr = anyOf(knownSmartptr(), QuacksLikeASmartptr);
68+
const auto SmartptrAny = anyOf(knownSmartptr(), QuacksLikeASmartptr);
69+
const auto SmartptrWithDeref =
70+
anyOf(cxxRecordDecl(knownSmartptr(), HasRelevantOps), QuacksLikeASmartptr);
6171

6272
// Catch 'ptr.get()->Foo()'
63-
Finder->addMatcher(memberExpr(expr().bind("memberExpr"), isArrow(),
64-
hasObjectExpression(callToGet(Smartptr))),
65-
Callback);
73+
Finder->addMatcher(
74+
memberExpr(expr().bind("memberExpr"), isArrow(),
75+
hasObjectExpression(callToGet(SmartptrWithDeref))),
76+
Callback);
6677

6778
// Catch '*ptr.get()' or '*ptr->get()'
6879
Finder->addMatcher(
69-
unaryOperator(hasOperatorName("*"), hasUnaryOperand(callToGet(Smartptr))),
80+
unaryOperator(hasOperatorName("*"),
81+
hasUnaryOperand(callToGet(SmartptrWithDeref))),
7082
Callback);
7183

7284
// Catch '!ptr.get()'
7385
const auto CallToGetAsBool = callToGet(
74-
recordDecl(Smartptr, has(cxxConversionDecl(returns(booleanType())))));
86+
recordDecl(SmartptrAny, has(cxxConversionDecl(returns(booleanType())))));
7587
Finder->addMatcher(
7688
unaryOperator(hasOperatorName("!"), hasUnaryOperand(CallToGetAsBool)),
7789
Callback);
@@ -84,7 +96,7 @@ void registerMatchersForGetArrowStart(MatchFinder *Finder,
8496
Callback);
8597

8698
Finder->addMatcher(cxxDependentScopeMemberExpr(hasObjectExpression(
87-
callExpr(has(callToGet(Smartptr))).bind("obj"))),
99+
callExpr(has(callToGet(SmartptrAny))))),
88100
Callback);
89101
}
90102

clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-msvc.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ struct unique_ptr {
1616
explicit operator bool() const noexcept;
1717
};
1818

19+
template <typename T>
20+
struct unique_ptr<T[]> {
21+
template <typename T2 = T>
22+
T2* operator[](unsigned) const;
23+
T* get() const;
24+
explicit operator bool() const noexcept;
25+
};
26+
1927
template <typename T>
2028
struct shared_ptr {
2129
template <typename T2 = T>
@@ -26,6 +34,14 @@ struct shared_ptr {
2634
explicit operator bool() const noexcept;
2735
};
2836

37+
template <typename T>
38+
struct shared_ptr<T[]> {
39+
template <typename T2 = T>
40+
T2* operator[](unsigned) const;
41+
T* get() const;
42+
explicit operator bool() const noexcept;
43+
};
44+
2945
} // namespace std
3046

3147
struct Bar {
@@ -92,3 +108,31 @@ void Positive() {
92108
// CHECK-MESSAGES: if (NULL == x.get());
93109
// CHECK-FIXES: if (NULL == x);
94110
}
111+
112+
void test_smart_ptr_to_array() {
113+
std::unique_ptr<int[]> i;
114+
// The array specialization does not have operator*(), so make sure
115+
// we do not incorrectly suggest sizeof(*i) here.
116+
// FIXME: alternatively, we could suggest sizeof(i[0])
117+
auto sz = sizeof(*i.get());
118+
119+
std::shared_ptr<Bar[]> s;
120+
// The array specialization does not have operator->() either
121+
s.get()->Do();
122+
123+
bool b1 = !s.get();
124+
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: redundant get() call
125+
// CHECK-FIXES: bool b1 = !s;
126+
127+
if (s.get()) {}
128+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
129+
// CHECK-FIXES: if (s) {}
130+
131+
int x = s.get() ? 1 : 2;
132+
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant get() call
133+
// CHECK-FIXES: int x = s ? 1 : 2;
134+
135+
bool b2 = s.get() == nullptr;
136+
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant get() call
137+
// CHECK-FIXES: bool b2 = s == nullptr;
138+
}

clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ struct unique_ptr {
1212
explicit operator bool() const noexcept;
1313
};
1414

15+
template <typename T>
16+
struct unique_ptr<T[]> {
17+
T& operator[](unsigned) const;
18+
T* get() const;
19+
explicit operator bool() const noexcept;
20+
};
21+
1522
template <typename T>
1623
struct shared_ptr {
1724
T& operator*() const;
@@ -20,6 +27,13 @@ struct shared_ptr {
2027
explicit operator bool() const noexcept;
2128
};
2229

30+
template <typename T>
31+
struct shared_ptr<T[]> {
32+
T& operator[](unsigned) const;
33+
T* get() const;
34+
explicit operator bool() const noexcept;
35+
};
36+
2337
template <typename T>
2438
struct vector {
2539
vector();
@@ -283,3 +297,31 @@ void test_redundant_get_with_member() {
283297
// CHECK-FIXES: f(**i->get()->getValue());
284298
}
285299
}
300+
301+
void test_smart_ptr_to_array() {
302+
std::unique_ptr<int[]> i;
303+
// The array specialization does not have operator*(), so make sure
304+
// we do not incorrectly suggest sizeof(*i) here.
305+
// FIXME: alternatively, we could suggest sizeof(i[0])
306+
auto sz = sizeof(*i.get());
307+
308+
std::shared_ptr<Inner[]> s;
309+
// The array specialization does not have operator->() either
310+
s.get()->getValue();
311+
312+
bool b1 = !s.get();
313+
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: redundant get() call
314+
// CHECK-FIXES: bool b1 = !s;
315+
316+
if (s.get()) {}
317+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
318+
// CHECK-FIXES: if (s) {}
319+
320+
int x = s.get() ? 1 : 2;
321+
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant get() call
322+
// CHECK-FIXES: int x = s ? 1 : 2;
323+
324+
bool b2 = s.get() == nullptr;
325+
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant get() call
326+
// CHECK-FIXES: bool b2 = s == nullptr;
327+
}

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ Bug Fixes to C++ Support
798798
- Fix instantiation of default-initialized variable template specialization. (#GH140632) (#GH140622)
799799
- Clang modules now allow a module and its user to differ on TrivialAutoVarInit*
800800
- Fixed an access checking bug when initializing non-aggregates in default arguments (#GH62444), (#GH83608)
801+
- Fixed a pack substitution bug in deducing class template partial specializations. (#GH53609)
801802

802803
Bug Fixes to AST Handling
803804
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang-c/Index.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3034,7 +3034,8 @@ enum CXTypeKind {
30343034

30353035
/* HLSL Types */
30363036
CXType_HLSLResource = 179,
3037-
CXType_HLSLAttributedResource = 180
3037+
CXType_HLSLAttributedResource = 180,
3038+
CXType_HLSLInlineSpirv = 181
30383039
};
30393040

30403041
/**

clang/include/clang/AST/ASTContext.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
260260
DependentBitIntTypes;
261261
mutable llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
262262
llvm::FoldingSet<HLSLAttributedResourceType> HLSLAttributedResourceTypes;
263+
llvm::FoldingSet<HLSLInlineSpirvType> HLSLInlineSpirvTypes;
263264

264265
mutable llvm::FoldingSet<CountAttributedType> CountAttributedTypes;
265266

@@ -582,7 +583,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
582583
llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
583584
InstantiatedFromUsingEnumDecl;
584585

585-
/// Simlarly maps instantiated UsingShadowDecls to their origin.
586+
/// Similarly maps instantiated UsingShadowDecls to their origin.
586587
llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
587588
InstantiatedFromUsingShadowDecl;
588589

@@ -790,7 +791,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
790791
}
791792
return new (*this) DeclListNode(ND);
792793
}
793-
/// Deallcates a \c DeclListNode by returning it to the \c ListNodeFreeList
794+
/// Deallocates a \c DeclListNode by returning it to the \c ListNodeFreeList
794795
/// pool.
795796
void DeallocateDeclListNode(DeclListNode *N) {
796797
N->Rest = ListNodeFreeList;
@@ -1123,7 +1124,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
11231124

11241125
/// Clean up the merged definition list. Call this if you might have
11251126
/// added duplicates into the list.
1126-
void deduplicateMergedDefinitonsFor(NamedDecl *ND);
1127+
void deduplicateMergedDefinitionsFor(NamedDecl *ND);
11271128

11281129
/// Get the additional modules in which the definition \p Def has
11291130
/// been merged.
@@ -1808,6 +1809,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
18081809
QualType Wrapped, QualType Contained,
18091810
const HLSLAttributedResourceType::Attributes &Attrs);
18101811

1812+
QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size,
1813+
uint32_t Alignment,
1814+
ArrayRef<SpirvOperand> Operands);
1815+
18111816
QualType getSubstTemplateTypeParmType(QualType Replacement,
18121817
Decl *AssociatedDecl, unsigned Index,
18131818
UnsignedOrNone PackIndex,
@@ -2565,7 +2570,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
25652570
/// Return the ABI-specified natural alignment of a (complete) type \p T,
25662571
/// before alignment adjustments, in bits.
25672572
///
2568-
/// This alignment is curently used only by ARM and AArch64 when passing
2573+
/// This alignment is currently used only by ARM and AArch64 when passing
25692574
/// arguments of a composite type.
25702575
unsigned getTypeUnadjustedAlign(QualType T) const {
25712576
return getTypeUnadjustedAlign(T.getTypePtr());
@@ -2638,7 +2643,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
26382643
/// considered specifically for the query.
26392644
CharUnits getAlignOfGlobalVarInChars(QualType T, const VarDecl *VD) const;
26402645

2641-
/// Return the minimum alignement as specified by the target. If \p VD is
2646+
/// Return the minimum alignment as specified by the target. If \p VD is
26422647
/// non-null it may be used to identify external or weak variables.
26432648
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const;
26442649

clang/include/clang/AST/ASTImporterLookupTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DeclContext;
3434
// Example 2:
3535
// // The fwd decl to Foo is not found in the lookupPtr of the DC of the
3636
// // translation unit decl.
37-
// // Here we could find the node by doing a traverse throught the list of
37+
// // Here we could find the node by doing a traverse through the list of
3838
// // the Decls in the DC, but that would not scale.
3939
// struct A { struct Foo *p; };
4040
// This is a severe problem because the importer decides if it has to create a

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,24 @@ class ASTNodeTraverser
450450
if (!Contained.isNull())
451451
Visit(Contained);
452452
}
453+
void VisitHLSLInlineSpirvType(const HLSLInlineSpirvType *T) {
454+
for (auto &Operand : T->getOperands()) {
455+
using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
456+
457+
switch (Operand.getKind()) {
458+
case SpirvOperandKind::ConstantId:
459+
case SpirvOperandKind::Literal:
460+
break;
461+
462+
case SpirvOperandKind::TypeId:
463+
Visit(Operand.getResultType());
464+
break;
465+
466+
default:
467+
llvm_unreachable("Invalid SpirvOperand kind!");
468+
}
469+
}
470+
}
453471
void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *) {}
454472
void
455473
VisitSubstTemplateTypeParmPackType(const SubstTemplateTypeParmPackType *T) {

clang/include/clang/AST/AbstractBasicReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//==--- AbstractBasiceReader.h - Abstract basic value deserialization -----===//
1+
//==--- AbstractBasicReader.h - Abstract basic value deserialization -----===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

0 commit comments

Comments
 (0)