Skip to content

Commit c6fb62c

Browse files
committed
merge main into amd-staging
2 parents 61f5792 + f36f65b commit c6fb62c

File tree

75 files changed

+1794
-452
lines changed

Some content is hidden

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

75 files changed

+1794
-452
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
@@ -814,6 +814,7 @@ Bug Fixes to C++ Support
814814
- Fix instantiation of default-initialized variable template specialization. (#GH140632) (#GH140622)
815815
- Clang modules now allow a module and its user to differ on TrivialAutoVarInit*
816816
- Fixed an access checking bug when initializing non-aggregates in default arguments (#GH62444), (#GH83608)
817+
- Fixed a pack substitution bug in deducing class template partial specializations. (#GH53609)
817818

818819
Bug Fixes to AST Handling
819820
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/StaticAnalyzer/Core/Checker.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,22 @@ class Bind {
221221
}
222222
};
223223

224+
class BlockEntrance {
225+
template <typename CHECKER>
226+
static void _checkBlockEntrance(void *Checker,
227+
const clang::BlockEntrance &Entrance,
228+
CheckerContext &C) {
229+
((const CHECKER *)Checker)->checkBlockEntrance(Entrance, C);
230+
}
231+
232+
public:
233+
template <typename CHECKER>
234+
static void _register(CHECKER *checker, CheckerManager &mgr) {
235+
mgr._registerForBlockEntrance(CheckerManager::CheckBlockEntranceFunc(
236+
checker, _checkBlockEntrance<CHECKER>));
237+
}
238+
};
239+
224240
class EndAnalysis {
225241
template <typename CHECKER>
226242
static void _checkEndAnalysis(void *checker, ExplodedGraph &G,
@@ -536,6 +552,8 @@ class CheckerBase : public CheckerFrontend, public CheckerBackend {
536552
template <typename... CHECKs>
537553
class Checker : public CheckerBase, public CHECKs... {
538554
public:
555+
using BlockEntrance = clang::BlockEntrance;
556+
539557
template <typename CHECKER>
540558
static void _register(CHECKER *Chk, CheckerManager &Mgr) {
541559
(CHECKs::_register(Chk, Mgr), ...);
@@ -565,6 +583,8 @@ class Checker : public CheckerBase, public CHECKs... {
565583
template <typename... CHECKs>
566584
class CheckerFamily : public CheckerBackend, public CHECKs... {
567585
public:
586+
using BlockEntrance = clang::BlockEntrance;
587+
568588
template <typename CHECKER>
569589
static void _register(CHECKER *Chk, CheckerManager &Mgr) {
570590
(CHECKs::_register(Chk, Mgr), ...);

clang/include/clang/StaticAnalyzer/Core/CheckerManager.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,12 @@ class CheckerManager {
344344
const Stmt *S, ExprEngine &Eng,
345345
const ProgramPoint &PP);
346346

347+
/// Run checkers after taking a control flow edge.
348+
void runCheckersForBlockEntrance(ExplodedNodeSet &Dst,
349+
const ExplodedNodeSet &Src,
350+
const BlockEntrance &Entrance,
351+
ExprEngine &Eng) const;
352+
347353
/// Run checkers for end of analysis.
348354
void runCheckersForEndAnalysis(ExplodedGraph &G, BugReporter &BR,
349355
ExprEngine &Eng);
@@ -496,6 +502,9 @@ class CheckerManager {
496502
using CheckBindFunc =
497503
CheckerFn<void(SVal location, SVal val, const Stmt *S, CheckerContext &)>;
498504

505+
using CheckBlockEntranceFunc =
506+
CheckerFn<void(const BlockEntrance &, CheckerContext &)>;
507+
499508
using CheckEndAnalysisFunc =
500509
CheckerFn<void (ExplodedGraph &, BugReporter &, ExprEngine &)>;
501510

@@ -557,6 +566,8 @@ class CheckerManager {
557566

558567
void _registerForBind(CheckBindFunc checkfn);
559568

569+
void _registerForBlockEntrance(CheckBlockEntranceFunc checkfn);
570+
560571
void _registerForEndAnalysis(CheckEndAnalysisFunc checkfn);
561572

562573
void _registerForBeginFunction(CheckBeginFunctionFunc checkfn);
@@ -663,6 +674,8 @@ class CheckerManager {
663674

664675
std::vector<CheckBindFunc> BindCheckers;
665676

677+
std::vector<CheckBlockEntranceFunc> BlockEntranceCheckers;
678+
666679
std::vector<CheckEndAnalysisFunc> EndAnalysisCheckers;
667680

668681
std::vector<CheckBeginFunctionFunc> BeginFunctionCheckers;

clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ class ExprEngine {
321321
NodeBuilderWithSinks &nodeBuilder,
322322
ExplodedNode *Pred);
323323

324+
void runCheckersForBlockEntrance(const NodeBuilderContext &BldCtx,
325+
const BlockEntrance &Entrance,
326+
ExplodedNode *Pred, ExplodedNodeSet &Dst);
327+
324328
/// ProcessBranch - Called by CoreEngine. Used to generate successor nodes by
325329
/// processing the 'effects' of a branch condition. If the branch condition
326330
/// is a loop condition, IterationsCompletedInLoop is the number of completed

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,33 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
596596
if (HasSMEB16B16)
597597
Builder.defineMacro("__ARM_FEATURE_SME_B16B16", "1");
598598

599+
if (HasFP8)
600+
Builder.defineMacro("__ARM_FEATURE_FP8", "1");
601+
602+
if (HasFP8FMA)
603+
Builder.defineMacro("__ARM_FEATURE_FP8FMA", "1");
604+
605+
if (HasFP8DOT2)
606+
Builder.defineMacro("__ARM_FEATURE_FP8DOT2", "1");
607+
608+
if (HasFP8DOT4)
609+
Builder.defineMacro("__ARM_FEATURE_FP8DOT4", "1");
610+
611+
if (HasSSVE_FP8DOT2)
612+
Builder.defineMacro("__ARM_FEATURE_SSVE_FP8DOT2", "1");
613+
614+
if (HasSSVE_FP8DOT4)
615+
Builder.defineMacro("__ARM_FEATURE_SSVE_FP8DOT4", "1");
616+
617+
if (HasSSVE_FP8FMA)
618+
Builder.defineMacro("__ARM_FEATURE_SSVE_FP8FMA", "1");
619+
620+
if (HasSME_F8F32)
621+
Builder.defineMacro("__ARM_FEATURE_SME_F8F32", "1");
622+
623+
if (HasSME_F8F16)
624+
Builder.defineMacro("__ARM_FEATURE_SME_F8F16", "1");
625+
599626
if (HasCRC)
600627
Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
601628

@@ -885,6 +912,15 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
885912
.Cases("ls64", "ls64_v", "ls64_accdata", HasLS64)
886913
.Case("wfxt", HasWFxT)
887914
.Case("rcpc3", HasRCPC3)
915+
.Case("fp8", HasFP8)
916+
.Case("fp8fma", HasFP8FMA)
917+
.Case("fp8dot2", HasFP8DOT2)
918+
.Case("fp8dot4", HasFP8DOT4)
919+
.Case("ssve-fp8dot2", HasSSVE_FP8DOT2)
920+
.Case("ssve-fp8dot4", HasSSVE_FP8DOT4)
921+
.Case("ssve-fp8fma", HasSSVE_FP8FMA)
922+
.Case("sme-f8f32", HasSME_F8F32)
923+
.Case("sme-f8f16", HasSME_F8F16)
888924
.Default(false);
889925
}
890926

@@ -1046,6 +1082,25 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
10461082
HasSVEB16B16 = true;
10471083
HasSMEB16B16 = true;
10481084
}
1085+
1086+
if (Feature == "+fp8")
1087+
HasFP8 = true;
1088+
if (Feature == "+fp8fma")
1089+
HasFP8FMA = true;
1090+
if (Feature == "+fp8dot2")
1091+
HasFP8DOT2 = true;
1092+
if (Feature == "+fp8dot4")
1093+
HasFP8DOT4 = true;
1094+
if (Feature == "+ssve-fp8dot2")
1095+
HasSSVE_FP8DOT2 = true;
1096+
if (Feature == "+ssve-fp8dot4")
1097+
HasSSVE_FP8DOT4 = true;
1098+
if (Feature == "+ssve-fp8fma")
1099+
HasSSVE_FP8FMA = true;
1100+
if (Feature == "+sme-f8f32")
1101+
HasSME_F8F32 = true;
1102+
if (Feature == "+sme-f8f16")
1103+
HasSME_F8F16 = true;
10491104
if (Feature == "+sb")
10501105
HasSB = true;
10511106
if (Feature == "+predres")

clang/lib/Basic/Targets/AArch64.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
106106
bool HasSMEF16F16 = false;
107107
bool HasSMEB16B16 = false;
108108
bool HasSME2p1 = false;
109+
bool HasFP8 = false;
110+
bool HasFP8FMA = false;
111+
bool HasFP8DOT2 = false;
112+
bool HasFP8DOT4 = false;
113+
bool HasSSVE_FP8DOT2 = false;
114+
bool HasSSVE_FP8DOT4 = false;
115+
bool HasSSVE_FP8FMA = false;
116+
bool HasSME_F8F32 = false;
117+
bool HasSME_F8F16 = false;
109118
bool HasSB = false;
110119
bool HasPredRes = false;
111120
bool HasSSBS = false;

0 commit comments

Comments
 (0)