Skip to content

Commit f1d3fca

Browse files
committed
Reduce the number of parameters wrapping them in a struct
1 parent 13c5494 commit f1d3fca

File tree

4 files changed

+142
-195
lines changed

4 files changed

+142
-195
lines changed

clang/include/clang-c/Index.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2164,7 +2164,7 @@ enum CXCursorKind {
21642164

21652165
/** OpenMP fuse directive
21662166
*/
2167-
CXCursor_OMPFuseDirective = 318,
2167+
CXCursor_OMPFuseDirective = 311,
21682168

21692169
/** OpenACC Compute Construct.
21702170
*/

clang/include/clang/Sema/SemaOpenMP.h

Lines changed: 34 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,6 @@ class SemaOpenMP : public SemaBase {
15021502
/// This categorization helps differentiate between original source loops
15031503
/// and the structures resulting from applying OpenMP loop transformations.
15041504
enum class OMPLoopCategory {
1505-
15061505
/// @var OMPLoopCategory::RegularLoop
15071506
/// Represents a standard canonical loop nest found in the
15081507
/// original source code or an intact loop after transformations
@@ -1513,12 +1512,34 @@ class SemaOpenMP : public SemaBase {
15131512
/// Represents the resulting loop structure when an OpenMP loop
15141513
// transformation, generates a single, top-level loop
15151514
TransformSingleLoop,
1515+
};
15161516

1517-
/// @var OMPLoopCategory::TransformLoopSequence
1518-
/// Represents the resulting loop structure when an OpenMP loop
1519-
/// transformation
1520-
/// generates a sequence of two or more canonical loop nests
1521-
TransformLoopSequence
1517+
/// Holds the result of the analysis of a (possibly canonical) loop.
1518+
struct LoopAnalysis {
1519+
/// Category of the analyzed loop.
1520+
OMPLoopCategory Category;
1521+
/// Loop analyses results.
1522+
OMPLoopBasedDirective::HelperExprs HelperExprs;
1523+
/// The for-statement of the loop.
1524+
Stmt *ForStmt;
1525+
/// Initialization statements before transformations.
1526+
SmallVector<Stmt *> OriginalInits;
1527+
/// Initialization statements required after transformation of this loop.
1528+
SmallVector<Stmt *> TransformsPreInits;
1529+
1530+
explicit LoopAnalysis(OMPLoopCategory Category) : Category(Category) {}
1531+
};
1532+
1533+
/// Holds the result of the analysis of a (possibly canonical) loop sequence.
1534+
struct LoopSequenceAnalysis {
1535+
/// Number of top level canonical loops.
1536+
unsigned LoopSeqSize = 0;
1537+
/// Number of canonical loops, including nested.
1538+
unsigned NumLoops = 0;
1539+
/// For each loop results of the analysis.
1540+
std::vector<LoopAnalysis> Loops;
1541+
/// Additional code required before entering the transformed loop sequence.
1542+
SmallVector<Stmt *> LoopSequencePreInits;
15221543
};
15231544

15241545
/// The main recursive process of `checkTransformableLoopSequence` that
@@ -1529,72 +1550,27 @@ class SemaOpenMP : public SemaBase {
15291550
/// Loop Sequences
15301551
///
15311552
/// \param LoopSeqStmt The AST of the original statement.
1532-
/// \param LoopSeqSize [out] Number of top level canonical loops.
1533-
/// \param NumLoops [out] Number of total canonical loops (nested too).
1534-
/// \param LoopHelpers [out] The multiple loop analyses results.
1535-
/// \param ForStmts [out] The multiple Stmt of each For loop.
1536-
/// \param OriginalInits [out] The raw original initialization statements
1537-
/// of each belonging to a loop of the loop sequence
1538-
/// \param TransformPreInits [out] The multiple collection of statements and
1539-
/// declarations that must have been executed/declared
1540-
/// before entering the loop (each belonging to a
1541-
/// particular loop transformation, nullptr otherwise)
1542-
/// \param LoopSequencePreInits [out] Additional general collection of loop
1543-
/// transformation related statements and declarations
1544-
/// not bounded to a particular loop that must be
1545-
/// executed before entering the loop transformation
1546-
/// \param LoopCategories [out] A sequence of OMPLoopCategory values,
1547-
/// one for each loop or loop transformation node
1548-
/// successfully analyzed.
1553+
/// \param SeqAnalysis [out] Result of the analysis of \p LoopSeqStmt
15491554
/// \param Context
15501555
/// \param Kind The loop transformation directive kind.
15511556
/// \return Whether the original statement is both syntactically and
15521557
/// semantically correct according to OpenMP 6.0 canonical loop
15531558
/// sequence definition.
1554-
bool analyzeLoopSequence(
1555-
Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
1556-
SmallVectorImpl<OMPLoopBasedDirective::HelperExprs> &LoopHelpers,
1557-
SmallVectorImpl<Stmt *> &ForStmts,
1558-
SmallVectorImpl<SmallVector<Stmt *>> &OriginalInits,
1559-
SmallVectorImpl<SmallVector<Stmt *>> &TransformsPreInits,
1560-
SmallVectorImpl<SmallVector<Stmt *>> &LoopSequencePreInits,
1561-
SmallVectorImpl<OMPLoopCategory> &LoopCategories, ASTContext &Context,
1562-
OpenMPDirectiveKind Kind);
1559+
bool analyzeLoopSequence(Stmt *LoopSeqStmt, LoopSequenceAnalysis &SeqAnalysis,
1560+
ASTContext &Context, OpenMPDirectiveKind Kind);
15631561

15641562
/// Validates and checks whether a loop sequence can be transformed according
15651563
/// to the given directive, providing necessary setup and initialization
15661564
/// (Driver function) before recursion using `analyzeLoopSequence`.
15671565
///
15681566
/// \param Kind The loop transformation directive kind.
15691567
/// \param AStmt The AST of the original statement
1570-
/// \param LoopSeqSize [out] Number of top level canonical loops.
1571-
/// \param NumLoops [out] Number of total canonical loops (nested too)
1572-
/// \param LoopHelpers [out] The multiple loop analyses results.
1573-
/// \param ForStmts [out] The multiple Stmt of each For loop.
1574-
/// \param OriginalInits [out] The raw original initialization statements
1575-
/// of each belonging to a loop of the loop sequence
1576-
/// \param TransformsPreInits [out] The multiple collection of statements and
1577-
/// declarations that must have been executed/declared
1578-
/// before entering the loop (each belonging to a
1579-
/// particular loop transformation, nullptr otherwise)
1580-
/// \param LoopSequencePreInits [out] Additional general collection of loop
1581-
/// transformation related statements and declarations
1582-
/// not bounded to a particular loop that must be
1583-
/// executed before entering the loop transformation
1584-
/// \param LoopCategories [out] A sequence of OMPLoopCategory values,
1585-
/// one for each loop or loop transformation node
1586-
/// successfully analyzed.
1568+
/// \param SeqAnalysis [out] Result of the analysis of \p LoopSeqStmt
15871569
/// \param Context
15881570
/// \return Whether there was an absence of errors or not
1589-
bool checkTransformableLoopSequence(
1590-
OpenMPDirectiveKind Kind, Stmt *AStmt, unsigned &LoopSeqSize,
1591-
unsigned &NumLoops,
1592-
SmallVectorImpl<OMPLoopBasedDirective::HelperExprs> &LoopHelpers,
1593-
SmallVectorImpl<Stmt *> &ForStmts,
1594-
SmallVectorImpl<SmallVector<Stmt *>> &OriginalInits,
1595-
SmallVectorImpl<SmallVector<Stmt *>> &TransformsPreInits,
1596-
SmallVectorImpl<SmallVector<Stmt *>> &LoopSequencePreInits,
1597-
SmallVectorImpl<OMPLoopCategory> &LoopCategories, ASTContext &Context);
1571+
bool checkTransformableLoopSequence(OpenMPDirectiveKind Kind, Stmt *AStmt,
1572+
LoopSequenceAnalysis &SeqAnalysis,
1573+
ASTContext &Context);
15981574

15991575
/// Helper to keep information about the current `omp begin/end declare
16001576
/// variant` nesting.

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3267,8 +3267,9 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
32673267
var, ConvertTypeForMem(VD->getType()), getContext().getDeclAlign(VD));
32683268

32693269
// No other cases for now.
3270-
} else
3270+
} else {
32713271
llvm_unreachable("DeclRefExpr for Decl not entered in LocalDeclMap?");
3272+
}
32723273

32733274
// Handle threadlocal function locals.
32743275
if (VD->getTLSKind() != VarDecl::TLS_None)

0 commit comments

Comments
 (0)