Skip to content

Commit 4da5ebd

Browse files
committed
Merge remote-tracking branch 'origin/main' into midhun7/big-archive-recognition
2 parents 7407769 + 0833493 commit 4da5ebd

File tree

75 files changed

+1004
-567
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

+1004
-567
lines changed

clang-tools-extra/docs/clang-tidy/checks/performance/noexcept-move-constructor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ marked with ``noexcept`` or marked with ``noexcept(expr)`` where ``expr``
99
evaluates to ``false`` (but is not a ``false`` literal itself).
1010

1111
Move constructors of all the types used with STL containers, for example,
12-
need to be declared ``noexcept``. Otherwise STL will choose copy constructors
12+
should be declared ``noexcept``. Otherwise STL may choose copy constructors
1313
instead. The same is valid for move assignment operations.

clang/include/clang/AST/StmtOpenMP.h

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -889,23 +889,24 @@ class OMPLoopBasedDirective : public OMPExecutableDirective {
889889

890890
/// Calls the specified callback function for all the loops in \p CurStmt,
891891
/// from the outermost to the innermost.
892-
static bool
893-
doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
894-
unsigned NumLoops,
895-
llvm::function_ref<bool(unsigned, Stmt *)> Callback,
896-
llvm::function_ref<void(OMPLoopTransformationDirective *)>
897-
OnTransformationCallback);
892+
static bool doForAllLoops(
893+
Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,
894+
llvm::function_ref<bool(unsigned, Stmt *)> Callback,
895+
llvm::function_ref<void(OMPCanonicalLoopNestTransformationDirective *)>
896+
OnTransformationCallback);
898897
static bool
899898
doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops,
900899
unsigned NumLoops,
901900
llvm::function_ref<bool(unsigned, const Stmt *)> Callback,
902-
llvm::function_ref<void(const OMPLoopTransformationDirective *)>
901+
llvm::function_ref<
902+
void(const OMPCanonicalLoopNestTransformationDirective *)>
903903
OnTransformationCallback) {
904904
auto &&NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) {
905905
return Callback(Cnt, CurStmt);
906906
};
907907
auto &&NewTransformCb =
908-
[OnTransformationCallback](OMPLoopTransformationDirective *A) {
908+
[OnTransformationCallback](
909+
OMPCanonicalLoopNestTransformationDirective *A) {
909910
OnTransformationCallback(A);
910911
};
911912
return doForAllLoops(const_cast<Stmt *>(CurStmt), TryImperfectlyNestedLoops,
@@ -918,7 +919,7 @@ class OMPLoopBasedDirective : public OMPExecutableDirective {
918919
doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
919920
unsigned NumLoops,
920921
llvm::function_ref<bool(unsigned, Stmt *)> Callback) {
921-
auto &&TransformCb = [](OMPLoopTransformationDirective *) {};
922+
auto &&TransformCb = [](OMPCanonicalLoopNestTransformationDirective *) {};
922923
return doForAllLoops(CurStmt, TryImperfectlyNestedLoops, NumLoops, Callback,
923924
TransformCb);
924925
}
@@ -955,19 +956,18 @@ class OMPLoopBasedDirective : public OMPExecutableDirective {
955956
}
956957
};
957958

958-
/// The base class for all loop transformation directives.
959-
class OMPLoopTransformationDirective : public OMPLoopBasedDirective {
959+
/// The base class for all transformation directives of canonical loop nests.
960+
class OMPCanonicalLoopNestTransformationDirective
961+
: public OMPLoopBasedDirective {
960962
friend class ASTStmtReader;
961963

962964
/// Number of loops generated by this loop transformation.
963965
unsigned NumGeneratedLoops = 0;
964966

965967
protected:
966-
explicit OMPLoopTransformationDirective(StmtClass SC,
967-
OpenMPDirectiveKind Kind,
968-
SourceLocation StartLoc,
969-
SourceLocation EndLoc,
970-
unsigned NumAssociatedLoops)
968+
explicit OMPCanonicalLoopNestTransformationDirective(
969+
StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc,
970+
SourceLocation EndLoc, unsigned NumAssociatedLoops)
971971
: OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, NumAssociatedLoops) {}
972972

973973
/// Set the number of loops generated by this loop transformation.
@@ -5545,7 +5545,8 @@ class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective {
55455545
};
55465546

55475547
/// This represents the '#pragma omp tile' loop transformation directive.
5548-
class OMPTileDirective final : public OMPLoopTransformationDirective {
5548+
class OMPTileDirective final
5549+
: public OMPCanonicalLoopNestTransformationDirective {
55495550
friend class ASTStmtReader;
55505551
friend class OMPExecutableDirective;
55515552

@@ -5557,9 +5558,9 @@ class OMPTileDirective final : public OMPLoopTransformationDirective {
55575558

55585559
explicit OMPTileDirective(SourceLocation StartLoc, SourceLocation EndLoc,
55595560
unsigned NumLoops)
5560-
: OMPLoopTransformationDirective(OMPTileDirectiveClass,
5561-
llvm::omp::OMPD_tile, StartLoc, EndLoc,
5562-
NumLoops) {
5561+
: OMPCanonicalLoopNestTransformationDirective(
5562+
OMPTileDirectiveClass, llvm::omp::OMPD_tile, StartLoc, EndLoc,
5563+
NumLoops) {
55635564
setNumGeneratedLoops(2 * NumLoops);
55645565
}
55655566

@@ -5622,7 +5623,8 @@ class OMPTileDirective final : public OMPLoopTransformationDirective {
56225623
};
56235624

56245625
/// This represents the '#pragma omp stripe' loop transformation directive.
5625-
class OMPStripeDirective final : public OMPLoopTransformationDirective {
5626+
class OMPStripeDirective final
5627+
: public OMPCanonicalLoopNestTransformationDirective {
56265628
friend class ASTStmtReader;
56275629
friend class OMPExecutableDirective;
56285630

@@ -5634,9 +5636,9 @@ class OMPStripeDirective final : public OMPLoopTransformationDirective {
56345636

56355637
explicit OMPStripeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
56365638
unsigned NumLoops)
5637-
: OMPLoopTransformationDirective(OMPStripeDirectiveClass,
5638-
llvm::omp::OMPD_stripe, StartLoc, EndLoc,
5639-
NumLoops) {
5639+
: OMPCanonicalLoopNestTransformationDirective(
5640+
OMPStripeDirectiveClass, llvm::omp::OMPD_stripe, StartLoc, EndLoc,
5641+
NumLoops) {
56405642
setNumGeneratedLoops(2 * NumLoops);
56415643
}
56425644

@@ -5702,7 +5704,8 @@ class OMPStripeDirective final : public OMPLoopTransformationDirective {
57025704
/// #pragma omp unroll
57035705
/// for (int i = 0; i < 64; ++i)
57045706
/// \endcode
5705-
class OMPUnrollDirective final : public OMPLoopTransformationDirective {
5707+
class OMPUnrollDirective final
5708+
: public OMPCanonicalLoopNestTransformationDirective {
57065709
friend class ASTStmtReader;
57075710
friend class OMPExecutableDirective;
57085711

@@ -5713,9 +5716,9 @@ class OMPUnrollDirective final : public OMPLoopTransformationDirective {
57135716
};
57145717

57155718
explicit OMPUnrollDirective(SourceLocation StartLoc, SourceLocation EndLoc)
5716-
: OMPLoopTransformationDirective(OMPUnrollDirectiveClass,
5717-
llvm::omp::OMPD_unroll, StartLoc, EndLoc,
5718-
1) {}
5719+
: OMPCanonicalLoopNestTransformationDirective(OMPUnrollDirectiveClass,
5720+
llvm::omp::OMPD_unroll,
5721+
StartLoc, EndLoc, 1) {}
57195722

57205723
/// Set the pre-init statements.
57215724
void setPreInits(Stmt *PreInits) {
@@ -5776,7 +5779,8 @@ class OMPUnrollDirective final : public OMPLoopTransformationDirective {
57765779
/// for (int i = 0; i < n; ++i)
57775780
/// ...
57785781
/// \endcode
5779-
class OMPReverseDirective final : public OMPLoopTransformationDirective {
5782+
class OMPReverseDirective final
5783+
: public OMPCanonicalLoopNestTransformationDirective {
57805784
friend class ASTStmtReader;
57815785
friend class OMPExecutableDirective;
57825786

@@ -5788,9 +5792,9 @@ class OMPReverseDirective final : public OMPLoopTransformationDirective {
57885792

57895793
explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc,
57905794
unsigned NumLoops)
5791-
: OMPLoopTransformationDirective(OMPReverseDirectiveClass,
5792-
llvm::omp::OMPD_reverse, StartLoc,
5793-
EndLoc, NumLoops) {
5795+
: OMPCanonicalLoopNestTransformationDirective(
5796+
OMPReverseDirectiveClass, llvm::omp::OMPD_reverse, StartLoc, EndLoc,
5797+
NumLoops) {
57945798
setNumGeneratedLoops(NumLoops);
57955799
}
57965800

@@ -5848,7 +5852,8 @@ class OMPReverseDirective final : public OMPLoopTransformationDirective {
58485852
/// for (int j = 0; j < n; ++j)
58495853
/// ..
58505854
/// \endcode
5851-
class OMPInterchangeDirective final : public OMPLoopTransformationDirective {
5855+
class OMPInterchangeDirective final
5856+
: public OMPCanonicalLoopNestTransformationDirective {
58525857
friend class ASTStmtReader;
58535858
friend class OMPExecutableDirective;
58545859

@@ -5860,9 +5865,9 @@ class OMPInterchangeDirective final : public OMPLoopTransformationDirective {
58605865

58615866
explicit OMPInterchangeDirective(SourceLocation StartLoc,
58625867
SourceLocation EndLoc, unsigned NumLoops)
5863-
: OMPLoopTransformationDirective(OMPInterchangeDirectiveClass,
5864-
llvm::omp::OMPD_interchange, StartLoc,
5865-
EndLoc, NumLoops) {
5868+
: OMPCanonicalLoopNestTransformationDirective(
5869+
OMPInterchangeDirectiveClass, llvm::omp::OMPD_interchange, StartLoc,
5870+
EndLoc, NumLoops) {
58665871
setNumGeneratedLoops(NumLoops);
58675872
}
58685873

clang/include/clang/Basic/OpenMPKinds.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,13 @@ bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind);
365365
/// functions
366366
bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);
367367

368+
/// Checks if the specified directive is a loop transformation directive that
369+
/// applies to a canonical loop nest.
370+
/// \param DKind Specified directive.
371+
/// \return True iff the directive is a loop transformation.
372+
bool isOpenMPCanonicalLoopNestTransformationDirective(
373+
OpenMPDirectiveKind DKind);
374+
368375
/// Checks if the specified directive is a loop transformation directive.
369376
/// \param DKind Specified directive.
370377
/// \return True iff the directive is a loop transformation.

clang/include/clang/Basic/StmtNodes.td

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,14 @@ def OMPLoopBasedDirective : StmtNode<OMPExecutableDirective, 1>;
230230
def OMPLoopDirective : StmtNode<OMPLoopBasedDirective, 1>;
231231
def OMPParallelDirective : StmtNode<OMPExecutableDirective>;
232232
def OMPSimdDirective : StmtNode<OMPLoopDirective>;
233-
def OMPLoopTransformationDirective : StmtNode<OMPLoopBasedDirective, 1>;
234-
def OMPTileDirective : StmtNode<OMPLoopTransformationDirective>;
235-
def OMPStripeDirective : StmtNode<OMPLoopTransformationDirective>;
236-
def OMPUnrollDirective : StmtNode<OMPLoopTransformationDirective>;
237-
def OMPReverseDirective : StmtNode<OMPLoopTransformationDirective>;
238-
def OMPInterchangeDirective : StmtNode<OMPLoopTransformationDirective>;
233+
def OMPCanonicalLoopNestTransformationDirective
234+
: StmtNode<OMPLoopBasedDirective, 1>;
235+
def OMPTileDirective : StmtNode<OMPCanonicalLoopNestTransformationDirective>;
236+
def OMPStripeDirective : StmtNode<OMPCanonicalLoopNestTransformationDirective>;
237+
def OMPUnrollDirective : StmtNode<OMPCanonicalLoopNestTransformationDirective>;
238+
def OMPReverseDirective : StmtNode<OMPCanonicalLoopNestTransformationDirective>;
239+
def OMPInterchangeDirective
240+
: StmtNode<OMPCanonicalLoopNestTransformationDirective>;
239241
def OMPForDirective : StmtNode<OMPLoopDirective>;
240242
def OMPForSimdDirective : StmtNode<OMPLoopDirective>;
241243
def OMPSectionsDirective : StmtNode<OMPExecutableDirective>;

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,7 +2912,8 @@ bool Compiler<Emitter>::VisitMaterializeTemporaryExpr(
29122912
OptPrimType SubExprT = classify(SubExpr);
29132913
bool IsStatic = E->getStorageDuration() == SD_Static;
29142914
if (IsStatic) {
2915-
std::optional<unsigned> GlobalIndex = P.createGlobal(E);
2915+
2916+
UnsignedOrNone GlobalIndex = P.createGlobal(E);
29162917
if (!GlobalIndex)
29172918
return false;
29182919

@@ -3001,7 +3002,7 @@ bool Compiler<Emitter>::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
30013002
if (T && !E->isLValue())
30023003
return this->delegate(Init);
30033004

3004-
std::optional<unsigned> GlobalIndex = P.createGlobal(E);
3005+
UnsignedOrNone GlobalIndex = P.createGlobal(E);
30053006
if (!GlobalIndex)
30063007
return false;
30073008

@@ -3345,7 +3346,7 @@ bool Compiler<Emitter>::VisitSourceLocExpr(const SourceLocExpr *E) {
33453346

33463347
auto *UGCD = cast<UnnamedGlobalConstantDecl>(BaseDecl);
33473348

3348-
std::optional<unsigned> GlobalIndex = P.getOrCreateGlobal(UGCD);
3349+
UnsignedOrNone GlobalIndex = P.getOrCreateGlobal(UGCD);
33493350
if (!GlobalIndex)
33503351
return false;
33513352

@@ -3868,7 +3869,7 @@ bool Compiler<Emitter>::VisitCXXUuidofExpr(const CXXUuidofExpr *E) {
38683869
if (!RD->isCompleteDefinition())
38693870
return this->emitDummyPtr(GuidDecl, E);
38703871

3871-
std::optional<unsigned> GlobalIndex = P.getOrCreateGlobal(GuidDecl);
3872+
UnsignedOrNone GlobalIndex = P.getOrCreateGlobal(GuidDecl);
38723873
if (!GlobalIndex)
38733874
return false;
38743875
if (!this->emitGetPtrGlobal(*GlobalIndex, E))
@@ -4860,7 +4861,7 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
48604861
DeclScope<Emitter> LocalScope(this, VD);
48614862

48624863
// We've already seen and initialized this global.
4863-
if (std::optional<unsigned> GlobalIndex = P.getGlobal(VD)) {
4864+
if (UnsignedOrNone GlobalIndex = P.getGlobal(VD)) {
48644865
if (P.getPtrGlobal(*GlobalIndex).isInitialized())
48654866
return checkDecl();
48664867

@@ -4869,7 +4870,7 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
48694870
return Init && checkDecl() && initGlobal(*GlobalIndex);
48704871
}
48714872

4872-
std::optional<unsigned> GlobalIndex = P.createGlobal(VD, Init);
4873+
UnsignedOrNone GlobalIndex = P.createGlobal(VD, Init);
48734874

48744875
if (!GlobalIndex)
48754876
return false;
@@ -6802,7 +6803,7 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
68026803
return F && this->emitGetFnPtr(F, E);
68036804
}
68046805
if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(D)) {
6805-
if (std::optional<unsigned> Index = P.getOrCreateGlobal(D)) {
6806+
if (UnsignedOrNone Index = P.getOrCreateGlobal(D)) {
68066807
if (!this->emitGetPtrGlobal(*Index, E))
68076808
return false;
68086809
if (OptPrimType T = classify(E->getType())) {

clang/lib/AST/ByteCode/EvalEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ bool EvalEmitter::emitDestroy(uint32_t I, const SourceInfo &Info) {
331331
/// This is what we do here.
332332
void EvalEmitter::updateGlobalTemporaries() {
333333
for (const auto &[E, Temp] : S.SeenGlobalTemporaries) {
334-
if (std::optional<unsigned> GlobalIndex = P.getGlobal(E)) {
334+
if (UnsignedOrNone GlobalIndex = P.getGlobal(E)) {
335335
const Pointer &Ptr = P.getPtrGlobal(*GlobalIndex);
336336
APValue *Cached = Temp->getOrCreateValue(true);
337337

clang/lib/AST/ByteCode/Program.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Pointer Program::getPtrGlobal(unsigned Idx) const {
111111
return Pointer(Globals[Idx]->block());
112112
}
113113

114-
std::optional<unsigned> Program::getGlobal(const ValueDecl *VD) {
114+
UnsignedOrNone Program::getGlobal(const ValueDecl *VD) {
115115
if (auto It = GlobalIndices.find(VD); It != GlobalIndices.end())
116116
return It->second;
117117

@@ -131,14 +131,14 @@ std::optional<unsigned> Program::getGlobal(const ValueDecl *VD) {
131131
return std::nullopt;
132132
}
133133

134-
std::optional<unsigned> Program::getGlobal(const Expr *E) {
134+
UnsignedOrNone Program::getGlobal(const Expr *E) {
135135
if (auto It = GlobalIndices.find(E); It != GlobalIndices.end())
136136
return It->second;
137137
return std::nullopt;
138138
}
139139

140-
std::optional<unsigned> Program::getOrCreateGlobal(const ValueDecl *VD,
141-
const Expr *Init) {
140+
UnsignedOrNone Program::getOrCreateGlobal(const ValueDecl *VD,
141+
const Expr *Init) {
142142
if (auto Idx = getGlobal(VD))
143143
return Idx;
144144

@@ -195,8 +195,7 @@ unsigned Program::getOrCreateDummy(const DeclTy &D) {
195195
return I;
196196
}
197197

198-
std::optional<unsigned> Program::createGlobal(const ValueDecl *VD,
199-
const Expr *Init) {
198+
UnsignedOrNone Program::createGlobal(const ValueDecl *VD, const Expr *Init) {
200199
bool IsStatic, IsExtern;
201200
bool IsWeak = VD->isWeak();
202201
if (const auto *Var = dyn_cast<VarDecl>(VD)) {
@@ -213,7 +212,7 @@ std::optional<unsigned> Program::createGlobal(const ValueDecl *VD,
213212

214213
// Register all previous declarations as well. For extern blocks, just replace
215214
// the index with the new variable.
216-
std::optional<unsigned> Idx =
215+
UnsignedOrNone Idx =
217216
createGlobal(VD, VD->getType(), IsStatic, IsExtern, IsWeak, Init);
218217
if (!Idx)
219218
return std::nullopt;
@@ -240,7 +239,7 @@ std::optional<unsigned> Program::createGlobal(const ValueDecl *VD,
240239
return *Idx;
241240
}
242241

243-
std::optional<unsigned> Program::createGlobal(const Expr *E) {
242+
UnsignedOrNone Program::createGlobal(const Expr *E) {
244243
if (auto Idx = getGlobal(E))
245244
return Idx;
246245
if (auto Idx = createGlobal(E, E->getType(), /*isStatic=*/true,
@@ -251,9 +250,9 @@ std::optional<unsigned> Program::createGlobal(const Expr *E) {
251250
return std::nullopt;
252251
}
253252

254-
std::optional<unsigned> Program::createGlobal(const DeclTy &D, QualType Ty,
255-
bool IsStatic, bool IsExtern,
256-
bool IsWeak, const Expr *Init) {
253+
UnsignedOrNone Program::createGlobal(const DeclTy &D, QualType Ty,
254+
bool IsStatic, bool IsExtern, bool IsWeak,
255+
const Expr *Init) {
257256
// Create a descriptor for the global.
258257
Descriptor *Desc;
259258
const bool IsConst = Ty.isConstQualified();

0 commit comments

Comments
 (0)