Skip to content

Commit c29e127

Browse files
authored
merge main into amd-staging (#522)
2 parents d05e662 + 831cb18 commit c29e127

File tree

146 files changed

+3791
-2249
lines changed

Some content is hidden

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

146 files changed

+3791
-2249
lines changed

.github/actions/push-container/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ runs:
2424
latest_name=$(echo $image_name | sed 's/:[a-f0-9]\+$/:latest/g')
2525
podman tag $image_name $latest_name
2626
echo "Pushing $image_name ..."
27-
podman push $image_name
27+
podman push --compression-format=zstd $image_name
2828
echo "Pushing $latest_name ..."
29-
podman push $latest_name
29+
podman push --compression-format=zstd $latest_name
3030
}
3131
3232
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ class IfPreprocessorCallbacks final : public PPCallbacks {
9191
Check.diag(
9292
DirectiveLoc,
9393
"preprocessor condition can be written more concisely using '#%0'")
94-
<< FixItHint::CreateReplacement(DirectiveLoc, Replacements[Inverted])
94+
<< FixItHint::CreateReplacement(
95+
CharSourceRange::getCharRange(DirectiveLoc,
96+
ConditionRange.getBegin()),
97+
(Replacements[Inverted].str() + " "))
9598
<< FixItHint::CreateReplacement(ConditionRange, Macro)
9699
<< Replacements[Inverted];
97100
}

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,10 @@ Changes in existing checks
480480
<clang-tidy/checks/readability/uppercase-literal-suffix>` check to recognize
481481
literal suffixes added in C++23 and C23.
482482

483+
- Improved :doc:`readability-use-concise-preprocessor-directives
484+
<clang-tidy/checks/readability/use-concise-preprocessor-directives>` check to
485+
generate correct fix-its for forms without a space after the directive.
486+
483487
Removed checks
484488
^^^^^^^^^^^^^^
485489

clang-tools-extra/test/clang-tidy/checkers/readability/use-concise-preprocessor-directives.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
# elif (defined(BAR))
2929
#endif
3030

31+
// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives]
32+
// CHECK-FIXES: #ifdef FOO
33+
#if(defined(FOO))
34+
// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives]
35+
// CHECK-FIXES-23: #elifdef BAR
36+
#elif(defined(BAR))
37+
#endif
38+
3139
// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives]
3240
// CHECK-FIXES: #ifdef FOO
3341
#if (defined FOO)

clang/bindings/python/clang/cindex.py

Lines changed: 88 additions & 86 deletions
Large diffs are not rendered by default.

clang/include/clang/Analysis/Analyses/LifetimeSafety/Facts.h

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616

1717
#include "clang/Analysis/Analyses/LifetimeSafety/Loans.h"
1818
#include "clang/Analysis/Analyses/LifetimeSafety/Origins.h"
19+
#include "clang/Analysis/Analyses/LifetimeSafety/Utils.h"
1920
#include "clang/Analysis/AnalysisDeclContext.h"
2021
#include "clang/Analysis/CFG.h"
2122
#include "llvm/ADT/SmallVector.h"
2223
#include "llvm/Support/Debug.h"
2324
#include <cstdint>
2425

2526
namespace clang::lifetimes::internal {
27+
28+
using FactID = utils::ID<struct FactTag>;
29+
2630
/// An abstract base class for a single, atomic lifetime-relevant event.
2731
class Fact {
2832

@@ -48,6 +52,7 @@ class Fact {
4852

4953
private:
5054
Kind K;
55+
FactID ID;
5156

5257
protected:
5358
Fact(Kind K) : K(K) {}
@@ -56,6 +61,9 @@ class Fact {
5661
virtual ~Fact() = default;
5762
Kind getKind() const { return K; }
5863

64+
void setID(FactID ID) { this->ID = ID; }
65+
FactID getID() const { return ID; }
66+
5967
template <typename T> const T *getAs() const {
6068
if (T::classof(this))
6169
return static_cast<const T *>(this);
@@ -144,19 +152,18 @@ class ReturnOfOriginFact : public Fact {
144152

145153
class UseFact : public Fact {
146154
const Expr *UseExpr;
155+
OriginID OID;
147156
// True if this use is a write operation (e.g., left-hand side of assignment).
148157
// Write operations are exempted from use-after-free checks.
149158
bool IsWritten = false;
150159

151160
public:
152161
static bool classof(const Fact *F) { return F->getKind() == Kind::Use; }
153162

154-
UseFact(const Expr *UseExpr) : Fact(Kind::Use), UseExpr(UseExpr) {}
163+
UseFact(const Expr *UseExpr, OriginManager &OM)
164+
: Fact(Kind::Use), UseExpr(UseExpr), OID(OM.get(*UseExpr)) {}
155165

156-
OriginID getUsedOrigin(const OriginManager &OM) const {
157-
// TODO: Remove const cast and make OriginManager::get as const.
158-
return const_cast<OriginManager &>(OM).get(*UseExpr);
159-
}
166+
OriginID getUsedOrigin() const { return OID; }
160167
const Expr *getUseExpr() const { return UseExpr; }
161168
void markAsWritten() { IsWritten = true; }
162169
bool isWritten() const { return IsWritten; }
@@ -184,22 +191,26 @@ class TestPointFact : public Fact {
184191

185192
class FactManager {
186193
public:
194+
void init(const CFG &Cfg) {
195+
assert(BlockToFacts.empty() && "FactManager already initialized");
196+
BlockToFacts.resize(Cfg.getNumBlockIDs());
197+
}
198+
187199
llvm::ArrayRef<const Fact *> getFacts(const CFGBlock *B) const {
188-
auto It = BlockToFactsMap.find(B);
189-
if (It != BlockToFactsMap.end())
190-
return It->second;
191-
return {};
200+
return BlockToFacts[B->getBlockID()];
192201
}
193202

194203
void addBlockFacts(const CFGBlock *B, llvm::ArrayRef<Fact *> NewFacts) {
195204
if (!NewFacts.empty())
196-
BlockToFactsMap[B].assign(NewFacts.begin(), NewFacts.end());
205+
BlockToFacts[B->getBlockID()].assign(NewFacts.begin(), NewFacts.end());
197206
}
198207

199208
template <typename FactType, typename... Args>
200209
FactType *createFact(Args &&...args) {
201210
void *Mem = FactAllocator.Allocate<FactType>();
202-
return new (Mem) FactType(std::forward<Args>(args)...);
211+
FactType *Res = new (Mem) FactType(std::forward<Args>(args)...);
212+
Res->setID(NextFactID++);
213+
return Res;
203214
}
204215

205216
void dump(const CFG &Cfg, AnalysisDeclContext &AC) const;
@@ -215,16 +226,19 @@ class FactManager {
215226
/// \note This is intended for testing only.
216227
llvm::StringMap<ProgramPoint> getTestPoints() const;
217228

229+
unsigned getNumFacts() const { return NextFactID.Value; }
230+
218231
LoanManager &getLoanMgr() { return LoanMgr; }
219232
const LoanManager &getLoanMgr() const { return LoanMgr; }
220233
OriginManager &getOriginMgr() { return OriginMgr; }
221234
const OriginManager &getOriginMgr() const { return OriginMgr; }
222235

223236
private:
237+
FactID NextFactID{0};
224238
LoanManager LoanMgr;
225239
OriginManager OriginMgr;
226-
llvm::DenseMap<const clang::CFGBlock *, llvm::SmallVector<const Fact *>>
227-
BlockToFactsMap;
240+
/// Facts for each CFG block, indexed by block ID.
241+
llvm::SmallVector<llvm::SmallVector<const Fact *>> BlockToFacts;
228242
llvm::BumpPtrAllocator FactAllocator;
229243
};
230244
} // namespace clang::lifetimes::internal

clang/include/clang/Analysis/Analyses/LifetimeSafety/Origins.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class OriginManager {
7474

7575
OriginID getOrCreate(const ValueDecl &D);
7676

77+
unsigned getNumOrigins() const { return NextOriginID.Value; }
78+
7779
void dump(OriginID OID, llvm::raw_ostream &OS) const;
7880

7981
private:

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,31 +3167,31 @@ let Features = "avx512bw", Attributes = [NoThrow, Const, Constexpr] in {
31673167
def kordi : X86Builtin<"unsigned long long int(unsigned long long int, unsigned long long int)">;
31683168
}
31693169

3170-
let Features = "avx512dq", Attributes = [NoThrow, Const] in {
3170+
let Features = "avx512dq", Attributes = [NoThrow, Const, Constexpr] in {
31713171
def kortestcqi : X86Builtin<"int(unsigned char, unsigned char)">;
31723172
def kortestzqi : X86Builtin<"int(unsigned char, unsigned char)">;
31733173
}
31743174

3175-
let Features = "avx512f", Attributes = [NoThrow, Const] in {
3175+
let Features = "avx512f", Attributes = [NoThrow, Const, Constexpr] in {
31763176
def kortestchi : X86Builtin<"int(unsigned short, unsigned short)">;
31773177
def kortestzhi : X86Builtin<"int(unsigned short, unsigned short)">;
31783178
}
31793179

3180-
let Features = "avx512bw", Attributes = [NoThrow, Const] in {
3180+
let Features = "avx512bw", Attributes = [NoThrow, Const, Constexpr] in {
31813181
def kortestcsi : X86Builtin<"int(unsigned int, unsigned int)">;
31823182
def kortestzsi : X86Builtin<"int(unsigned int, unsigned int)">;
31833183
def kortestcdi : X86Builtin<"int(unsigned long long int, unsigned long long int)">;
31843184
def kortestzdi : X86Builtin<"int(unsigned long long int, unsigned long long int)">;
31853185
}
31863186

3187-
let Features = "avx512dq", Attributes = [NoThrow, Const] in {
3187+
let Features = "avx512dq", Attributes = [NoThrow, Const, Constexpr] in {
31883188
def ktestcqi : X86Builtin<"int(unsigned char, unsigned char)">;
31893189
def ktestzqi : X86Builtin<"int(unsigned char, unsigned char)">;
31903190
def ktestchi : X86Builtin<"int(unsigned short, unsigned short)">;
31913191
def ktestzhi : X86Builtin<"int(unsigned short, unsigned short)">;
31923192
}
31933193

3194-
let Features = "avx512bw", Attributes = [NoThrow, Const] in {
3194+
let Features = "avx512bw", Attributes = [NoThrow, Const, Constexpr] in {
31953195
def ktestcsi : X86Builtin<"int(unsigned int, unsigned int)">;
31963196
def ktestzsi : X86Builtin<"int(unsigned int, unsigned int)">;
31973197
def ktestcdi : X86Builtin<"int(unsigned long long int, unsigned long long int)">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8112,6 +8112,17 @@ def ext_gnu_ptr_func_arith : Extension<
81128112
"arithmetic on%select{ a|}0 pointer%select{|s}0 to%select{ the|}2 function "
81138113
"type%select{|s}2 %1%select{| and %3}2 is a GNU extension">,
81148114
InGroup<GNUPointerArith>;
8115+
def ext_gnu_counted_by_void_ptr
8116+
: Extension<
8117+
"'%select{counted_by|sized_by|counted_by_or_null|sized_by_or_null}0' "
8118+
"on a pointer to void is a GNU extension, treated as "
8119+
"'%select{sized_by|sized_by|sized_by_or_null|sized_by_or_null}0'">,
8120+
InGroup<GNUPointerArith>;
8121+
def note_gnu_counted_by_void_ptr_use_sized_by
8122+
: Note<"use "
8123+
"'%select{__sized_by|__sized_by|__sized_by_or_null|__sized_by_or_"
8124+
"null}0' "
8125+
"to suppress this warning">;
81158126
def err_readonly_message_assignment : Error<
81168127
"assigning to 'readonly' return result of an Objective-C message not allowed">;
81178128
def ext_c2y_increment_complex : Extension<

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,6 +3831,42 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
38313831
return Result;
38323832
});
38333833

3834+
case clang::X86::BI__builtin_ia32_ktestcqi:
3835+
case clang::X86::BI__builtin_ia32_ktestchi:
3836+
case clang::X86::BI__builtin_ia32_ktestcsi:
3837+
case clang::X86::BI__builtin_ia32_ktestcdi:
3838+
return interp__builtin_elementwise_int_binop(
3839+
S, OpPC, Call, [](const APSInt &A, const APSInt &B) {
3840+
return APInt(sizeof(unsigned char) * 8, (~A & B) == 0);
3841+
});
3842+
3843+
case clang::X86::BI__builtin_ia32_ktestzqi:
3844+
case clang::X86::BI__builtin_ia32_ktestzhi:
3845+
case clang::X86::BI__builtin_ia32_ktestzsi:
3846+
case clang::X86::BI__builtin_ia32_ktestzdi:
3847+
return interp__builtin_elementwise_int_binop(
3848+
S, OpPC, Call, [](const APSInt &A, const APSInt &B) {
3849+
return APInt(sizeof(unsigned char) * 8, (A & B) == 0);
3850+
});
3851+
3852+
case clang::X86::BI__builtin_ia32_kortestcqi:
3853+
case clang::X86::BI__builtin_ia32_kortestchi:
3854+
case clang::X86::BI__builtin_ia32_kortestcsi:
3855+
case clang::X86::BI__builtin_ia32_kortestcdi:
3856+
return interp__builtin_elementwise_int_binop(
3857+
S, OpPC, Call, [](const APSInt &A, const APSInt &B) {
3858+
return APInt(sizeof(unsigned char) * 8, ~(A | B) == 0);
3859+
});
3860+
3861+
case clang::X86::BI__builtin_ia32_kortestzqi:
3862+
case clang::X86::BI__builtin_ia32_kortestzhi:
3863+
case clang::X86::BI__builtin_ia32_kortestzsi:
3864+
case clang::X86::BI__builtin_ia32_kortestzdi:
3865+
return interp__builtin_elementwise_int_binop(
3866+
S, OpPC, Call, [](const APSInt &A, const APSInt &B) {
3867+
return APInt(sizeof(unsigned char) * 8, (A | B) == 0);
3868+
});
3869+
38343870
case clang::X86::BI__builtin_ia32_lzcnt_u16:
38353871
case clang::X86::BI__builtin_ia32_lzcnt_u32:
38363872
case clang::X86::BI__builtin_ia32_lzcnt_u64:

0 commit comments

Comments
 (0)