Skip to content

Commit

Permalink
Merged main:d8db2733c87ef2ee54c322cbee76711147a94948 into amd-gfx:967…
Browse files Browse the repository at this point in the history
…ab3262a05

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)
  • Loading branch information
SC llvm team authored and SC llvm team committed Jan 2, 2024
2 parents 967ab32 + d8db273 commit 6b757b3
Show file tree
Hide file tree
Showing 179 changed files with 9,200 additions and 1,958 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

# Tensor Dialect in MLIR.
/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp @hanhanW @nicolasvasilache
/mlir/lib/Dialect/Tensor/Transforms/FoldIntoPackAndUnpackPatterns.cpp @hanhanW @nicolasvasilache
/mlir/lib/Dialect/Tensor/Transforms/* @hanhanW @nicolasvasilache

# Transform Dialect in MLIR.
/mlir/include/mlir/Dialect/Transform/* @ftynse @nicolasvasilache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace clang {
namespace ento {
namespace categories {
extern const char *const AppleAPIMisuse;
extern const char *const CoreFoundationObjectiveC;
extern const char *const LogicError;
extern const char *const MemoryRefCount;
Expand Down
14 changes: 5 additions & 9 deletions clang/include/clang/StaticAnalyzer/Core/Checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ class PostCall {

class Location {
template <typename CHECKER>
static void _checkLocation(void *checker,
const SVal &location, bool isLoad, const Stmt *S,
CheckerContext &C) {
static void _checkLocation(void *checker, SVal location, bool isLoad,
const Stmt *S, CheckerContext &C) {
((const CHECKER *)checker)->checkLocation(location, isLoad, S, C);
}

Expand All @@ -209,8 +208,7 @@ class Location {

class Bind {
template <typename CHECKER>
static void _checkBind(void *checker,
const SVal &location, const SVal &val, const Stmt *S,
static void _checkBind(void *checker, SVal location, SVal val, const Stmt *S,
CheckerContext &C) {
((const CHECKER *)checker)->checkBind(location, val, S, C);
}
Expand Down Expand Up @@ -456,10 +454,8 @@ namespace eval {

class Assume {
template <typename CHECKER>
static ProgramStateRef _evalAssume(void *checker,
ProgramStateRef state,
const SVal &cond,
bool assumption) {
static ProgramStateRef _evalAssume(void *checker, ProgramStateRef state,
SVal cond, bool assumption) {
return ((const CHECKER *)checker)->evalAssume(state, cond, assumption);
}

Expand Down
11 changes: 4 additions & 7 deletions clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,11 @@ class CheckerManager {
using CheckCallFunc =
CheckerFn<void (const CallEvent &, CheckerContext &)>;

using CheckLocationFunc =
CheckerFn<void (const SVal &location, bool isLoad, const Stmt *S,
CheckerContext &)>;
using CheckLocationFunc = CheckerFn<void(SVal location, bool isLoad,
const Stmt *S, CheckerContext &)>;

using CheckBindFunc =
CheckerFn<void (const SVal &location, const SVal &val, const Stmt *S,
CheckerContext &)>;
CheckerFn<void(SVal location, SVal val, const Stmt *S, CheckerContext &)>;

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

using EvalAssumeFunc =
CheckerFn<ProgramStateRef (ProgramStateRef, const SVal &cond,
bool assumption)>;
CheckerFn<ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)>;

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

Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Driver/ToolChains/Solaris.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,12 @@ static StringRef getSolarisLibSuffix(const llvm::Triple &Triple) {
switch (Triple.getArch()) {
case llvm::Triple::x86:
case llvm::Triple::sparc:
default:
break;
case llvm::Triple::x86_64:
return "/amd64";
case llvm::Triple::sparcv9:
return "/sparcv9";
default:
llvm_unreachable("Unsupported architecture");
}
return "";
}
Expand Down
7 changes: 2 additions & 5 deletions clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using namespace ento;
namespace {
class ArrayBoundChecker :
public Checker<check::Location> {
mutable std::unique_ptr<BugType> BT;
const BugType BT{this, "Out-of-bound array access"};

public:
void checkLocation(SVal l, bool isLoad, const Stmt* S,
Expand Down Expand Up @@ -65,16 +65,13 @@ void ArrayBoundChecker::checkLocation(SVal l, bool isLoad, const Stmt* LoadS,
if (!N)
return;

if (!BT)
BT.reset(new BugType(this, "Out-of-bound array access"));

// FIXME: It would be nice to eventually make this diagnostic more clear,
// e.g., by referencing the original declaration or by saying *why* this
// reference is outside the range.

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

report->addRange(LoadS->getSourceRange());
C.emitReport(std::move(report));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace {
class APIMisuse : public BugType {
public:
APIMisuse(const CheckerBase *checker, const char *name)
: BugType(checker, name, "API Misuse (Apple)") {}
: BugType(checker, name, categories::AppleAPIMisuse) {}
};
} // end anonymous namespace

Expand Down
57 changes: 25 additions & 32 deletions clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,31 @@ using namespace clang;
using namespace ento;

namespace {

class BlockInCriticalSectionChecker : public Checker<check::PostCall> {

mutable IdentifierInfo *IILockGuard, *IIUniqueLock;

CallDescription LockFn, UnlockFn, SleepFn, GetcFn, FgetsFn, ReadFn, RecvFn,
PthreadLockFn, PthreadTryLockFn, PthreadUnlockFn,
MtxLock, MtxTimedLock, MtxTryLock, MtxUnlock;

StringRef ClassLockGuard, ClassUniqueLock;

mutable bool IdentifierInfoInitialized;

std::unique_ptr<BugType> BlockInCritSectionBugType;
mutable IdentifierInfo *IILockGuard = nullptr;
mutable IdentifierInfo *IIUniqueLock = nullptr;
mutable bool IdentifierInfoInitialized = false;

const CallDescription LockFn{{"lock"}};
const CallDescription UnlockFn{{"unlock"}};
const CallDescription SleepFn{{"sleep"}};
const CallDescription GetcFn{{"getc"}};
const CallDescription FgetsFn{{"fgets"}};
const CallDescription ReadFn{{"read"}};
const CallDescription RecvFn{{"recv"}};
const CallDescription PthreadLockFn{{"pthread_mutex_lock"}};
const CallDescription PthreadTryLockFn{{"pthread_mutex_trylock"}};
const CallDescription PthreadUnlockFn{{"pthread_mutex_unlock"}};
const CallDescription MtxLock{{"mtx_lock"}};
const CallDescription MtxTimedLock{{"mtx_timedlock"}};
const CallDescription MtxTryLock{{"mtx_trylock"}};
const CallDescription MtxUnlock{{"mtx_unlock"}};

const llvm::StringLiteral ClassLockGuard{"lock_guard"};
const llvm::StringLiteral ClassUniqueLock{"unique_lock"};

const BugType BlockInCritSectionBugType{
this, "Call to blocking function in critical section", "Blocking Error"};

void initIdentifierInfo(ASTContext &Ctx) const;

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

public:
BlockInCriticalSectionChecker();

bool isBlockingFunction(const CallEvent &Call) const;
bool isLockFunction(const CallEvent &Call) const;
bool isUnlockFunction(const CallEvent &Call) const;
Expand All @@ -63,22 +72,6 @@ class BlockInCriticalSectionChecker : public Checker<check::PostCall> {

REGISTER_TRAIT_WITH_PROGRAMSTATE(MutexCounter, unsigned)

BlockInCriticalSectionChecker::BlockInCriticalSectionChecker()
: IILockGuard(nullptr), IIUniqueLock(nullptr), LockFn({"lock"}),
UnlockFn({"unlock"}), SleepFn({"sleep"}), GetcFn({"getc"}),
FgetsFn({"fgets"}), ReadFn({"read"}), RecvFn({"recv"}),
PthreadLockFn({"pthread_mutex_lock"}),
PthreadTryLockFn({"pthread_mutex_trylock"}),
PthreadUnlockFn({"pthread_mutex_unlock"}), MtxLock({"mtx_lock"}),
MtxTimedLock({"mtx_timedlock"}), MtxTryLock({"mtx_trylock"}),
MtxUnlock({"mtx_unlock"}), ClassLockGuard("lock_guard"),
ClassUniqueLock("unique_lock"), IdentifierInfoInitialized(false) {
// Initialize the bug type.
BlockInCritSectionBugType.reset(
new BugType(this, "Call to blocking function in critical section",
"Blocking Error"));
}

void BlockInCriticalSectionChecker::initIdentifierInfo(ASTContext &Ctx) const {
if (!IdentifierInfoInitialized) {
/* In case of checking C code, or when the corresponding headers are not
Expand Down Expand Up @@ -151,7 +144,7 @@ void BlockInCriticalSectionChecker::reportBlockInCritSection(
llvm::raw_string_ostream os(msg);
os << "Call to blocking function '" << Call.getCalleeIdentifier()->getName()
<< "' inside of critical section";
auto R = std::make_unique<PathSensitiveBugReport>(*BlockInCritSectionBugType,
auto R = std::make_unique<PathSensitiveBugReport>(BlockInCritSectionBugType,
os.str(), ErrNode);
R->addRange(Call.getSourceRange());
R->markInteresting(BlockDescSym);
Expand Down
7 changes: 2 additions & 5 deletions clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace ento;

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

Expand All @@ -36,12 +36,9 @@ namespace {
void BoolAssignmentChecker::emitReport(ProgramStateRef state, CheckerContext &C,
bool IsTainted) const {
if (ExplodedNode *N = C.generateNonFatalErrorNode(state)) {
if (!BT)
BT.reset(new BugType(this, "Assignment of a non-Boolean value"));

StringRef Msg = IsTainted ? "Might assign a tainted non-Boolean value"
: "Assignment of a non-Boolean value";
C.emitReport(std::make_unique<PathSensitiveBugReport>(*BT, Msg, N));
C.emitReport(std::make_unique<PathSensitiveBugReport>(BT, Msg, N));
}
}

Expand Down
24 changes: 7 additions & 17 deletions clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
Expand Down Expand Up @@ -65,7 +66,8 @@ class CXXDeleteChecker : public Checker<check::PreStmt<CXXDeleteExpr>> {
};

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

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

class CXXArrayDeleteChecker : public CXXDeleteChecker {
mutable std::unique_ptr<BugType> BT;
const BugType BT{this,
"Deleting an array of polymorphic objects is undefined"};

void
checkTypedDeleteExpr(const CXXDeleteExpr *DE, CheckerContext &C,
Expand Down Expand Up @@ -123,17 +126,10 @@ void DeleteWithNonVirtualDtorChecker::checkTypedDeleteExpr(
if (!DerivedClass->isDerivedFrom(BaseClass))
return;

if (!BT)
BT.reset(new BugType(this,
"Destruction of a polymorphic object with no "
"virtual destructor",
"Logic error"));

ExplodedNode *N = C.generateNonFatalErrorNode();
if (!N)
return;
auto R =
std::make_unique<PathSensitiveBugReport>(*BT, BT->getDescription(), N);
auto R = std::make_unique<PathSensitiveBugReport>(BT, BT.getDescription(), N);

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

if (!BT)
BT.reset(new BugType(this,
"Deleting an array of polymorphic objects "
"is undefined",
"Logic error"));

ExplodedNode *N = C.generateNonFatalErrorNode();
if (!N)
return;
Expand All @@ -182,7 +172,7 @@ void CXXArrayDeleteChecker::checkTypedDeleteExpr(
<< SourceType.getAsString(C.getASTContext().getPrintingPolicy())
<< "' is undefined";

auto R = std::make_unique<PathSensitiveBugReport>(*BT, OS.str(), N);
auto R = std::make_unique<PathSensitiveBugReport>(BT, OS.str(), N);

// Mark region of problematic base class for later use in the BugVisitor.
R->markInteresting(BaseClassRegion);
Expand Down
9 changes: 4 additions & 5 deletions clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ class CallAndMessageChecker
if (!BT)
BT.reset(new BugType(OriginalName, desc));
}
bool uninitRefOrPointer(CheckerContext &C, const SVal &V,
SourceRange ArgRange, const Expr *ArgEx,
std::unique_ptr<BugType> &BT,
bool uninitRefOrPointer(CheckerContext &C, SVal V, SourceRange ArgRange,
const Expr *ArgEx, std::unique_ptr<BugType> &BT,
const ParmVarDecl *ParamDecl, const char *BD,
int ArgumentNumber) const;
};
Expand Down Expand Up @@ -185,7 +184,7 @@ static void describeUninitializedArgumentInCall(const CallEvent &Call,
}

bool CallAndMessageChecker::uninitRefOrPointer(
CheckerContext &C, const SVal &V, SourceRange ArgRange, const Expr *ArgEx,
CheckerContext &C, SVal V, SourceRange ArgRange, const Expr *ArgEx,
std::unique_ptr<BugType> &BT, const ParmVarDecl *ParamDecl, const char *BD,
int ArgumentNumber) const {

Expand Down Expand Up @@ -263,7 +262,7 @@ class FindUninitializedField {
if (Find(FR))
return true;
} else {
const SVal &V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
SVal V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
if (V.isUndef())
return true;
}
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace ento;

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

public:
void checkPreStmt(const CastExpr *CE, CheckerContext &C) const;
Expand Down Expand Up @@ -131,12 +131,10 @@ void CastSizeChecker::checkPreStmt(const CastExpr *CE,CheckerContext &C) const {
return;

if (ExplodedNode *errorNode = C.generateErrorNode()) {
if (!BT)
BT.reset(new BugType(this, "Cast region with wrong size."));
constexpr llvm::StringLiteral Msg =
"Cast a region whose size is not a multiple of the destination type "
"size.";
auto R = std::make_unique<PathSensitiveBugReport>(*BT, Msg, errorNode);
auto R = std::make_unique<PathSensitiveBugReport>(BT, Msg, errorNode);
R->addRange(CE->getSourceRange());
C.emitReport(std::move(R));
}
Expand Down
Loading

0 comments on commit 6b757b3

Please sign in to comment.