Skip to content

Commit de998c6

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/fixit-unknown-attributes
2 parents 72775d4 + 7809b14 commit de998c6

File tree

54 files changed

+2327
-725
lines changed

Some content is hidden

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

54 files changed

+2327
-725
lines changed

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_v2bf16, "V2sV2s*0V2s", "t", "at
257257
TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2bf16, "V2sV2s*1V2s", "t", "atomic-global-pk-add-bf16-inst")
258258
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2bf16, "V2sV2s*3V2s", "t", "atomic-ds-pk-add-16-insts")
259259
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2f16, "V2hV2h*3V2h", "t", "atomic-ds-pk-add-16-insts")
260-
TARGET_BUILTIN(__builtin_amdgcn_load_to_lds, "vv*v*3IUiIiIUi", "t", "vmem-to-lds-load-insts")
260+
TARGET_BUILTIN(__builtin_amdgcn_load_to_lds, "vv*v*3IUiIiIUi", "", "vmem-to-lds-load-insts")
261261
TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3IUiIiIUi", "t", "vmem-to-lds-load-insts")
262262

263263
//===----------------------------------------------------------------------===//

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -608,20 +608,6 @@ class EventDispatcher {
608608
}
609609
};
610610

611-
/// Tag that can use a checker name as a message provider
612-
/// (see SimpleProgramPointTag).
613-
/// FIXME: This is a cargo cult class which is copied into several checkers but
614-
/// does not provide anything useful.
615-
/// The only added functionality provided by this class (compared to
616-
/// SimpleProgramPointTag) is that it composes the tag description string from
617-
/// two arguments -- but tag descriptions only appear in debug output so there
618-
/// is no reason to bother with this.
619-
class CheckerProgramPointTag : public SimpleProgramPointTag {
620-
public:
621-
CheckerProgramPointTag(StringRef CheckerName, StringRef Msg);
622-
CheckerProgramPointTag(const CheckerBase *Checker, StringRef Msg);
623-
};
624-
625611
/// We dereferenced a location that may be null.
626612
struct ImplicitNullDerefEvent {
627613
SVal Location;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ class CheckerContext {
171171
/// tag is specified, a default tag, unique to the given checker,
172172
/// will be used. Tags are used to prevent states generated at
173173
/// different sites from caching out.
174+
/// NOTE: If the State is unchanged and the Tag is nullptr, this may return a
175+
/// node which is not tagged (instead of using the default tag corresponding
176+
/// to the active checker). This is arguably a bug and should be fixed.
174177
ExplodedNode *addTransition(ProgramStateRef State = nullptr,
175178
const ProgramPointTag *Tag = nullptr) {
176179
return addTransitionImpl(State ? State : getState(), false, nullptr, Tag);
@@ -183,6 +186,9 @@ class CheckerContext {
183186
/// @param Pred The transition will be generated from the specified Pred node
184187
/// to the newly generated node.
185188
/// @param Tag The tag to uniquely identify the creation site.
189+
/// NOTE: If the State is unchanged and the Tag is nullptr, this may return a
190+
/// node which is not tagged (instead of using the default tag corresponding
191+
/// to the active checker). This is arguably a bug and should be fixed.
186192
ExplodedNode *addTransition(ProgramStateRef State, ExplodedNode *Pred,
187193
const ProgramPointTag *Tag = nullptr) {
188194
return addTransitionImpl(State, false, Pred, Tag);

clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include "CIRGenFunction.h"
1616

17+
#include "clang/AST/ExprCXX.h"
18+
1719
#include "mlir/Dialect/Arith/IR/Arith.h"
1820
#include "mlir/Dialect/OpenACC/OpenACC.h"
1921
#include "llvm/ADT/TypeSwitch.h"
@@ -188,7 +190,7 @@ class OpenACCClauseCIREmitter final
188190
struct DataOperandInfo {
189191
mlir::Location beginLoc;
190192
mlir::Value varValue;
191-
llvm::StringRef name;
193+
std::string name;
192194
llvm::SmallVector<mlir::Value> bounds;
193195
};
194196

@@ -226,6 +228,10 @@ class OpenACCClauseCIREmitter final
226228
mlir::Location exprLoc = cgf.cgm.getLoc(curVarExpr->getBeginLoc());
227229
llvm::SmallVector<mlir::Value> bounds;
228230

231+
std::string exprString;
232+
llvm::raw_string_ostream os(exprString);
233+
e->printPretty(os, nullptr, cgf.getContext().getPrintingPolicy());
234+
229235
// Assemble the list of bounds.
230236
while (isa<ArraySectionExpr, ArraySubscriptExpr>(curVarExpr)) {
231237
mlir::Location boundLoc = cgf.cgm.getLoc(curVarExpr->getBeginLoc());
@@ -267,20 +273,16 @@ class OpenACCClauseCIREmitter final
267273
bounds.push_back(createBound(boundLoc, lowerBound, upperBound, extent));
268274
}
269275

270-
// TODO: OpenACC: if this is a member expr, emit the VarPtrPtr correctly.
271-
if (isa<MemberExpr>(curVarExpr)) {
272-
cgf.cgm.errorNYI(curVarExpr->getSourceRange(),
273-
"OpenACC Data clause member expr");
274-
return {exprLoc, {}, {}, std::move(bounds)};
275-
}
276+
if (const auto *memExpr = dyn_cast<MemberExpr>(curVarExpr))
277+
return {exprLoc, cgf.emitMemberExpr(memExpr).getPointer(), exprString,
278+
std::move(bounds)};
276279

277280
// Sema has made sure that only 4 types of things can get here, array
278281
// subscript, array section, member expr, or DRE to a var decl (or the
279282
// former 3 wrapping a var-decl), so we should be able to assume this is
280283
// right.
281284
const auto *dre = cast<DeclRefExpr>(curVarExpr);
282-
const auto *vd = cast<VarDecl>(dre->getFoundDecl()->getCanonicalDecl());
283-
return {exprLoc, cgf.emitDeclRefLValue(dre).getPointer(), vd->getName(),
285+
return {exprLoc, cgf.emitDeclRefLValue(dre).getPointer(), exprString,
284286
std::move(bounds)};
285287
}
286288

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6395,7 +6395,8 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
63956395
return nullptr;
63966396
Expr *Arg = ArgRes.get();
63976397
QualType ArgType = Arg->getType();
6398-
if (!ParamType->isPointerType() || ParamType.hasAddressSpace() ||
6398+
if (!ParamType->isPointerType() ||
6399+
ParamType->getPointeeType().hasAddressSpace() ||
63996400
!ArgType->isPointerType() ||
64006401
!ArgType->getPointeeType().hasAddressSpace() ||
64016402
isPtrSizeAddressSpace(ArgType->getPointeeType().getAddressSpace())) {
@@ -6404,9 +6405,6 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
64046405
}
64056406

64066407
QualType PointeeType = ParamType->getPointeeType();
6407-
if (PointeeType.hasAddressSpace())
6408-
continue;
6409-
64106408
NeedsNewDecl = true;
64116409
LangAS AS = ArgType->getPointeeType().getAddressSpace();
64126410

clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,6 @@ void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,
671671
ProgramStateRef state,
672672
const ObjCMethodCall &Msg) const {
673673
ASTContext &Ctx = C.getASTContext();
674-
static CheckerProgramPointTag Tag(this, "NilReceiver");
675674

676675
// Check the return type of the message expression. A message to nil will
677676
// return different values depending on the return type and the architecture.
@@ -682,7 +681,7 @@ void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,
682681
if (CanRetTy->isStructureOrClassType()) {
683682
// Structure returns are safe since the compiler zeroes them out.
684683
SVal V = C.getSValBuilder().makeZeroVal(RetTy);
685-
C.addTransition(state->BindExpr(Msg.getOriginExpr(), LCtx, V), &Tag);
684+
C.addTransition(state->BindExpr(Msg.getOriginExpr(), LCtx, V));
686685
return;
687686
}
688687

@@ -701,7 +700,7 @@ void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,
701700
Ctx.LongDoubleTy == CanRetTy ||
702701
Ctx.LongLongTy == CanRetTy ||
703702
Ctx.UnsignedLongLongTy == CanRetTy)))) {
704-
if (ExplodedNode *N = C.generateErrorNode(state, &Tag))
703+
if (ExplodedNode *N = C.generateErrorNode(state))
705704
emitNilReceiverBug(C, Msg, N);
706705
return;
707706
}
@@ -720,7 +719,7 @@ void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,
720719
// of this case unless we have *a lot* more knowledge.
721720
//
722721
SVal V = C.getSValBuilder().makeZeroVal(RetTy);
723-
C.addTransition(state->BindExpr(Msg.getOriginExpr(), LCtx, V), &Tag);
722+
C.addTransition(state->BindExpr(Msg.getOriginExpr(), LCtx, V));
724723
return;
725724
}
726725

clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,16 @@ void DynamicTypePropagation::checkPostStmt(const CastExpr *CE,
674674
if (TrackedType &&
675675
!ASTCtxt.canAssignObjCInterfaces(DestObjectPtrType, *TrackedType) &&
676676
!ASTCtxt.canAssignObjCInterfaces(*TrackedType, DestObjectPtrType)) {
677-
static CheckerProgramPointTag IllegalConv(this, "IllegalConversion");
678-
ExplodedNode *N = C.addTransition(State, AfterTypeProp, &IllegalConv);
679-
reportGenericsBug(*TrackedType, DestObjectPtrType, N, Sym, C);
677+
// This distinct program point tag is needed because `State` can be
678+
// identical to the state of the node `AfterTypeProp`, and in that case
679+
// `generateNonFatalErrorNode` would "cache out" and return nullptr
680+
// (instead of re-creating an already existing node).
681+
static SimpleProgramPointTag IllegalConv("DynamicTypePropagation",
682+
"IllegalConversion");
683+
ExplodedNode *N =
684+
C.generateNonFatalErrorNode(State, AfterTypeProp, &IllegalConv);
685+
if (N)
686+
reportGenericsBug(*TrackedType, DestObjectPtrType, N, Sym, C);
680687
return;
681688
}
682689

@@ -885,8 +892,7 @@ void DynamicTypePropagation::checkPreObjCMessage(const ObjCMethodCall &M,
885892
// Warn when argument is incompatible with the parameter.
886893
if (!ASTCtxt.canAssignObjCInterfaces(ParamObjectPtrType,
887894
ArgObjectPtrType)) {
888-
static CheckerProgramPointTag Tag(this, "ArgTypeMismatch");
889-
ExplodedNode *N = C.addTransition(State, &Tag);
895+
ExplodedNode *N = C.generateNonFatalErrorNode(State);
890896
reportGenericsBug(ArgObjectPtrType, ParamObjectPtrType, N, Sym, C, Arg);
891897
return;
892898
}

clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,7 @@ bool GenericTaintChecker::generateReportIfTainted(const Expr *E, StringRef Msg,
10431043

10441044
// Generate diagnostic.
10451045
assert(BT);
1046-
static CheckerProgramPointTag Tag(BT->getCheckerName(), Msg);
1047-
if (ExplodedNode *N = C.generateNonFatalErrorNode(C.getState(), &Tag)) {
1046+
if (ExplodedNode *N = C.generateNonFatalErrorNode(C.getState())) {
10481047
auto report = std::make_unique<PathSensitiveBugReport>(*BT, Msg, N);
10491048
report->addRange(E->getSourceRange());
10501049
for (auto TaintedSym : getTaintedSymbols(C.getState(), *TaintedSVal)) {

clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,7 @@ void NonLocalizedStringChecker::reportLocalizationError(
747747
if (isDebuggingContext(C))
748748
return;
749749

750-
static CheckerProgramPointTag Tag("NonLocalizedStringChecker",
751-
"UnlocalizedString");
752-
ExplodedNode *ErrNode = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
750+
ExplodedNode *ErrNode = C.generateNonFatalErrorNode();
753751

754752
if (!ErrNode)
755753
return;

clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ void MPIChecker::checkUnmatchedWaits(const CallEvent &PreCallEvent,
7373
return;
7474

7575
ProgramStateRef State = Ctx.getState();
76-
static CheckerProgramPointTag Tag("MPI-Checker", "UnmatchedWait");
7776
ExplodedNode *ErrorNode{nullptr};
7877

7978
// Check all request regions used by the wait function.
@@ -82,7 +81,7 @@ void MPIChecker::checkUnmatchedWaits(const CallEvent &PreCallEvent,
8281
State = State->set<RequestMap>(ReqRegion, Request::State::Wait);
8382
if (!Req) {
8483
if (!ErrorNode) {
85-
ErrorNode = Ctx.generateNonFatalErrorNode(State, &Tag);
84+
ErrorNode = Ctx.generateNonFatalErrorNode(State);
8685
State = ErrorNode->getState();
8786
}
8887
// A wait has no matching nonblocking call.
@@ -105,7 +104,6 @@ void MPIChecker::checkMissingWaits(SymbolReaper &SymReaper,
105104
if (Requests.isEmpty())
106105
return;
107106

108-
static CheckerProgramPointTag Tag("MPI-Checker", "MissingWait");
109107
ExplodedNode *ErrorNode{nullptr};
110108

111109
auto ReqMap = State->get<RequestMap>();
@@ -114,7 +112,7 @@ void MPIChecker::checkMissingWaits(SymbolReaper &SymReaper,
114112
if (Req.second.CurrentState == Request::State::Nonblocking) {
115113

116114
if (!ErrorNode) {
117-
ErrorNode = Ctx.generateNonFatalErrorNode(State, &Tag);
115+
ErrorNode = Ctx.generateNonFatalErrorNode(State);
118116
State = ErrorNode->getState();
119117
}
120118
BReporter.reportMissingWait(Req.second, Req.first, ErrorNode,

0 commit comments

Comments
 (0)