Skip to content

Commit 6b757b3

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:d8db2733c87ef2ee54c322cbee76711147a94948 into amd-gfx:967ab3262a05
Local branch amd-gfx 967ab32 Merged main:90c397fc56b7a04dd53cdad8103de1ead9686104 into amd-gfx:cf37bdb63d3c Remote branch main d8db273 [X86][MC] Support Enc/Dec for EGPR for promoted CRC32 (llvm#76434)
2 parents 967ab32 + d8db273 commit 6b757b3

File tree

179 files changed

+9200
-1958
lines changed

Some content is hidden

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

179 files changed

+9200
-1958
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
# Tensor Dialect in MLIR.
8989
/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp @hanhanW @nicolasvasilache
90-
/mlir/lib/Dialect/Tensor/Transforms/FoldIntoPackAndUnpackPatterns.cpp @hanhanW @nicolasvasilache
90+
/mlir/lib/Dialect/Tensor/Transforms/* @hanhanW @nicolasvasilache
9191

9292
# Transform Dialect in MLIR.
9393
/mlir/include/mlir/Dialect/Transform/* @ftynse @nicolasvasilache

clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace clang {
1414
namespace ento {
1515
namespace categories {
16+
extern const char *const AppleAPIMisuse;
1617
extern const char *const CoreFoundationObjectiveC;
1718
extern const char *const LogicError;
1819
extern const char *const MemoryRefCount;

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,8 @@ class PostCall {
193193

194194
class Location {
195195
template <typename CHECKER>
196-
static void _checkLocation(void *checker,
197-
const SVal &location, bool isLoad, const Stmt *S,
198-
CheckerContext &C) {
196+
static void _checkLocation(void *checker, SVal location, bool isLoad,
197+
const Stmt *S, CheckerContext &C) {
199198
((const CHECKER *)checker)->checkLocation(location, isLoad, S, C);
200199
}
201200

@@ -209,8 +208,7 @@ class Location {
209208

210209
class Bind {
211210
template <typename CHECKER>
212-
static void _checkBind(void *checker,
213-
const SVal &location, const SVal &val, const Stmt *S,
211+
static void _checkBind(void *checker, SVal location, SVal val, const Stmt *S,
214212
CheckerContext &C) {
215213
((const CHECKER *)checker)->checkBind(location, val, S, C);
216214
}
@@ -456,10 +454,8 @@ namespace eval {
456454

457455
class Assume {
458456
template <typename CHECKER>
459-
static ProgramStateRef _evalAssume(void *checker,
460-
ProgramStateRef state,
461-
const SVal &cond,
462-
bool assumption) {
457+
static ProgramStateRef _evalAssume(void *checker, ProgramStateRef state,
458+
SVal cond, bool assumption) {
463459
return ((const CHECKER *)checker)->evalAssume(state, cond, assumption);
464460
}
465461

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,11 @@ class CheckerManager {
488488
using CheckCallFunc =
489489
CheckerFn<void (const CallEvent &, CheckerContext &)>;
490490

491-
using CheckLocationFunc =
492-
CheckerFn<void (const SVal &location, bool isLoad, const Stmt *S,
493-
CheckerContext &)>;
491+
using CheckLocationFunc = CheckerFn<void(SVal location, bool isLoad,
492+
const Stmt *S, CheckerContext &)>;
494493

495494
using CheckBindFunc =
496-
CheckerFn<void (const SVal &location, const SVal &val, const Stmt *S,
497-
CheckerContext &)>;
495+
CheckerFn<void(SVal location, SVal val, const Stmt *S, CheckerContext &)>;
498496

499497
using CheckEndAnalysisFunc =
500498
CheckerFn<void (ExplodedGraph &, BugReporter &, ExprEngine &)>;
@@ -530,8 +528,7 @@ class CheckerManager {
530528
RegionAndSymbolInvalidationTraits *ITraits)>;
531529

532530
using EvalAssumeFunc =
533-
CheckerFn<ProgramStateRef (ProgramStateRef, const SVal &cond,
534-
bool assumption)>;
531+
CheckerFn<ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)>;
535532

536533
using EvalCallFunc = CheckerFn<bool (const CallEvent &, CheckerContext &)>;
537534

clang/lib/Driver/ToolChains/Solaris.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,12 @@ static StringRef getSolarisLibSuffix(const llvm::Triple &Triple) {
295295
switch (Triple.getArch()) {
296296
case llvm::Triple::x86:
297297
case llvm::Triple::sparc:
298+
default:
298299
break;
299300
case llvm::Triple::x86_64:
300301
return "/amd64";
301302
case llvm::Triple::sparcv9:
302303
return "/sparcv9";
303-
default:
304-
llvm_unreachable("Unsupported architecture");
305304
}
306305
return "";
307306
}

clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using namespace ento;
2525
namespace {
2626
class ArrayBoundChecker :
2727
public Checker<check::Location> {
28-
mutable std::unique_ptr<BugType> BT;
28+
const BugType BT{this, "Out-of-bound array access"};
2929

3030
public:
3131
void checkLocation(SVal l, bool isLoad, const Stmt* S,
@@ -65,16 +65,13 @@ void ArrayBoundChecker::checkLocation(SVal l, bool isLoad, const Stmt* LoadS,
6565
if (!N)
6666
return;
6767

68-
if (!BT)
69-
BT.reset(new BugType(this, "Out-of-bound array access"));
70-
7168
// FIXME: It would be nice to eventually make this diagnostic more clear,
7269
// e.g., by referencing the original declaration or by saying *why* this
7370
// reference is outside the range.
7471

7572
// Generate a report for this bug.
7673
auto report = std::make_unique<PathSensitiveBugReport>(
77-
*BT, "Access out-of-bound array element (buffer overflow)", N);
74+
BT, "Access out-of-bound array element (buffer overflow)", N);
7875

7976
report->addRange(LoadS->getSourceRange());
8077
C.emitReport(std::move(report));

clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace {
4444
class APIMisuse : public BugType {
4545
public:
4646
APIMisuse(const CheckerBase *checker, const char *name)
47-
: BugType(checker, name, "API Misuse (Apple)") {}
47+
: BugType(checker, name, categories::AppleAPIMisuse) {}
4848
};
4949
} // end anonymous namespace
5050

clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,31 @@ using namespace clang;
2525
using namespace ento;
2626

2727
namespace {
28-
2928
class BlockInCriticalSectionChecker : public Checker<check::PostCall> {
30-
31-
mutable IdentifierInfo *IILockGuard, *IIUniqueLock;
32-
33-
CallDescription LockFn, UnlockFn, SleepFn, GetcFn, FgetsFn, ReadFn, RecvFn,
34-
PthreadLockFn, PthreadTryLockFn, PthreadUnlockFn,
35-
MtxLock, MtxTimedLock, MtxTryLock, MtxUnlock;
36-
37-
StringRef ClassLockGuard, ClassUniqueLock;
38-
39-
mutable bool IdentifierInfoInitialized;
40-
41-
std::unique_ptr<BugType> BlockInCritSectionBugType;
29+
mutable IdentifierInfo *IILockGuard = nullptr;
30+
mutable IdentifierInfo *IIUniqueLock = nullptr;
31+
mutable bool IdentifierInfoInitialized = false;
32+
33+
const CallDescription LockFn{{"lock"}};
34+
const CallDescription UnlockFn{{"unlock"}};
35+
const CallDescription SleepFn{{"sleep"}};
36+
const CallDescription GetcFn{{"getc"}};
37+
const CallDescription FgetsFn{{"fgets"}};
38+
const CallDescription ReadFn{{"read"}};
39+
const CallDescription RecvFn{{"recv"}};
40+
const CallDescription PthreadLockFn{{"pthread_mutex_lock"}};
41+
const CallDescription PthreadTryLockFn{{"pthread_mutex_trylock"}};
42+
const CallDescription PthreadUnlockFn{{"pthread_mutex_unlock"}};
43+
const CallDescription MtxLock{{"mtx_lock"}};
44+
const CallDescription MtxTimedLock{{"mtx_timedlock"}};
45+
const CallDescription MtxTryLock{{"mtx_trylock"}};
46+
const CallDescription MtxUnlock{{"mtx_unlock"}};
47+
48+
const llvm::StringLiteral ClassLockGuard{"lock_guard"};
49+
const llvm::StringLiteral ClassUniqueLock{"unique_lock"};
50+
51+
const BugType BlockInCritSectionBugType{
52+
this, "Call to blocking function in critical section", "Blocking Error"};
4253

4354
void initIdentifierInfo(ASTContext &Ctx) const;
4455

@@ -47,8 +58,6 @@ class BlockInCriticalSectionChecker : public Checker<check::PostCall> {
4758
CheckerContext &C) const;
4859

4960
public:
50-
BlockInCriticalSectionChecker();
51-
5261
bool isBlockingFunction(const CallEvent &Call) const;
5362
bool isLockFunction(const CallEvent &Call) const;
5463
bool isUnlockFunction(const CallEvent &Call) const;
@@ -63,22 +72,6 @@ class BlockInCriticalSectionChecker : public Checker<check::PostCall> {
6372

6473
REGISTER_TRAIT_WITH_PROGRAMSTATE(MutexCounter, unsigned)
6574

66-
BlockInCriticalSectionChecker::BlockInCriticalSectionChecker()
67-
: IILockGuard(nullptr), IIUniqueLock(nullptr), LockFn({"lock"}),
68-
UnlockFn({"unlock"}), SleepFn({"sleep"}), GetcFn({"getc"}),
69-
FgetsFn({"fgets"}), ReadFn({"read"}), RecvFn({"recv"}),
70-
PthreadLockFn({"pthread_mutex_lock"}),
71-
PthreadTryLockFn({"pthread_mutex_trylock"}),
72-
PthreadUnlockFn({"pthread_mutex_unlock"}), MtxLock({"mtx_lock"}),
73-
MtxTimedLock({"mtx_timedlock"}), MtxTryLock({"mtx_trylock"}),
74-
MtxUnlock({"mtx_unlock"}), ClassLockGuard("lock_guard"),
75-
ClassUniqueLock("unique_lock"), IdentifierInfoInitialized(false) {
76-
// Initialize the bug type.
77-
BlockInCritSectionBugType.reset(
78-
new BugType(this, "Call to blocking function in critical section",
79-
"Blocking Error"));
80-
}
81-
8275
void BlockInCriticalSectionChecker::initIdentifierInfo(ASTContext &Ctx) const {
8376
if (!IdentifierInfoInitialized) {
8477
/* In case of checking C code, or when the corresponding headers are not
@@ -151,7 +144,7 @@ void BlockInCriticalSectionChecker::reportBlockInCritSection(
151144
llvm::raw_string_ostream os(msg);
152145
os << "Call to blocking function '" << Call.getCalleeIdentifier()->getName()
153146
<< "' inside of critical section";
154-
auto R = std::make_unique<PathSensitiveBugReport>(*BlockInCritSectionBugType,
147+
auto R = std::make_unique<PathSensitiveBugReport>(BlockInCritSectionBugType,
155148
os.str(), ErrNode);
156149
R->addRange(Call.getSourceRange());
157150
R->markInteresting(BlockDescSym);

clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace ento;
2424

2525
namespace {
2626
class BoolAssignmentChecker : public Checker< check::Bind > {
27-
mutable std::unique_ptr<BugType> BT;
27+
const BugType BT{this, "Assignment of a non-Boolean value"};
2828
void emitReport(ProgramStateRef state, CheckerContext &C,
2929
bool IsTainted = false) const;
3030

@@ -36,12 +36,9 @@ namespace {
3636
void BoolAssignmentChecker::emitReport(ProgramStateRef state, CheckerContext &C,
3737
bool IsTainted) const {
3838
if (ExplodedNode *N = C.generateNonFatalErrorNode(state)) {
39-
if (!BT)
40-
BT.reset(new BugType(this, "Assignment of a non-Boolean value"));
41-
4239
StringRef Msg = IsTainted ? "Might assign a tainted non-Boolean value"
4340
: "Assignment of a non-Boolean value";
44-
C.emitReport(std::make_unique<PathSensitiveBugReport>(*BT, Msg, N));
41+
C.emitReport(std::make_unique<PathSensitiveBugReport>(BT, Msg, N));
4542
}
4643
}
4744

clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
3232
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
3333
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
34+
#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
3435
#include "clang/StaticAnalyzer/Core/Checker.h"
3536
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
3637
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
@@ -65,7 +66,8 @@ class CXXDeleteChecker : public Checker<check::PreStmt<CXXDeleteExpr>> {
6566
};
6667

6768
class DeleteWithNonVirtualDtorChecker : public CXXDeleteChecker {
68-
mutable std::unique_ptr<BugType> BT;
69+
const BugType BT{
70+
this, "Destruction of a polymorphic object with no virtual destructor"};
6971

7072
void
7173
checkTypedDeleteExpr(const CXXDeleteExpr *DE, CheckerContext &C,
@@ -74,7 +76,8 @@ class DeleteWithNonVirtualDtorChecker : public CXXDeleteChecker {
7476
};
7577

7678
class CXXArrayDeleteChecker : public CXXDeleteChecker {
77-
mutable std::unique_ptr<BugType> BT;
79+
const BugType BT{this,
80+
"Deleting an array of polymorphic objects is undefined"};
7881

7982
void
8083
checkTypedDeleteExpr(const CXXDeleteExpr *DE, CheckerContext &C,
@@ -123,17 +126,10 @@ void DeleteWithNonVirtualDtorChecker::checkTypedDeleteExpr(
123126
if (!DerivedClass->isDerivedFrom(BaseClass))
124127
return;
125128

126-
if (!BT)
127-
BT.reset(new BugType(this,
128-
"Destruction of a polymorphic object with no "
129-
"virtual destructor",
130-
"Logic error"));
131-
132129
ExplodedNode *N = C.generateNonFatalErrorNode();
133130
if (!N)
134131
return;
135-
auto R =
136-
std::make_unique<PathSensitiveBugReport>(*BT, BT->getDescription(), N);
132+
auto R = std::make_unique<PathSensitiveBugReport>(BT, BT.getDescription(), N);
137133

138134
// Mark region of problematic base class for later use in the BugVisitor.
139135
R->markInteresting(BaseClassRegion);
@@ -160,12 +156,6 @@ void CXXArrayDeleteChecker::checkTypedDeleteExpr(
160156
if (!DerivedClass->isDerivedFrom(BaseClass))
161157
return;
162158

163-
if (!BT)
164-
BT.reset(new BugType(this,
165-
"Deleting an array of polymorphic objects "
166-
"is undefined",
167-
"Logic error"));
168-
169159
ExplodedNode *N = C.generateNonFatalErrorNode();
170160
if (!N)
171161
return;
@@ -182,7 +172,7 @@ void CXXArrayDeleteChecker::checkTypedDeleteExpr(
182172
<< SourceType.getAsString(C.getASTContext().getPrintingPolicy())
183173
<< "' is undefined";
184174

185-
auto R = std::make_unique<PathSensitiveBugReport>(*BT, OS.str(), N);
175+
auto R = std::make_unique<PathSensitiveBugReport>(BT, OS.str(), N);
186176

187177
// Mark region of problematic base class for later use in the BugVisitor.
188178
R->markInteresting(BaseClassRegion);

clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ class CallAndMessageChecker
125125
if (!BT)
126126
BT.reset(new BugType(OriginalName, desc));
127127
}
128-
bool uninitRefOrPointer(CheckerContext &C, const SVal &V,
129-
SourceRange ArgRange, const Expr *ArgEx,
130-
std::unique_ptr<BugType> &BT,
128+
bool uninitRefOrPointer(CheckerContext &C, SVal V, SourceRange ArgRange,
129+
const Expr *ArgEx, std::unique_ptr<BugType> &BT,
131130
const ParmVarDecl *ParamDecl, const char *BD,
132131
int ArgumentNumber) const;
133132
};
@@ -185,7 +184,7 @@ static void describeUninitializedArgumentInCall(const CallEvent &Call,
185184
}
186185

187186
bool CallAndMessageChecker::uninitRefOrPointer(
188-
CheckerContext &C, const SVal &V, SourceRange ArgRange, const Expr *ArgEx,
187+
CheckerContext &C, SVal V, SourceRange ArgRange, const Expr *ArgEx,
189188
std::unique_ptr<BugType> &BT, const ParmVarDecl *ParamDecl, const char *BD,
190189
int ArgumentNumber) const {
191190

@@ -263,7 +262,7 @@ class FindUninitializedField {
263262
if (Find(FR))
264263
return true;
265264
} else {
266-
const SVal &V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
265+
SVal V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
267266
if (V.isUndef())
268267
return true;
269268
}

clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace ento;
2424

2525
namespace {
2626
class CastSizeChecker : public Checker< check::PreStmt<CastExpr> > {
27-
mutable std::unique_ptr<BugType> BT;
27+
const BugType BT{this, "Cast region with wrong size."};
2828

2929
public:
3030
void checkPreStmt(const CastExpr *CE, CheckerContext &C) const;
@@ -131,12 +131,10 @@ void CastSizeChecker::checkPreStmt(const CastExpr *CE,CheckerContext &C) const {
131131
return;
132132

133133
if (ExplodedNode *errorNode = C.generateErrorNode()) {
134-
if (!BT)
135-
BT.reset(new BugType(this, "Cast region with wrong size."));
136134
constexpr llvm::StringLiteral Msg =
137135
"Cast a region whose size is not a multiple of the destination type "
138136
"size.";
139-
auto R = std::make_unique<PathSensitiveBugReport>(*BT, Msg, errorNode);
137+
auto R = std::make_unique<PathSensitiveBugReport>(BT, Msg, errorNode);
140138
R->addRange(CE->getSourceRange());
141139
C.emitReport(std::move(R));
142140
}

0 commit comments

Comments
 (0)