Skip to content

Commit cef6177

Browse files
committed
Addressed the first round of code review comments from Erich Keane.
1 parent 51951a7 commit cef6177

File tree

8 files changed

+23
-32
lines changed

8 files changed

+23
-32
lines changed

clang/include/clang/AST/Decl.h

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4701,11 +4701,6 @@ class OutlinedFunctionDecl final
47014701
: public Decl,
47024702
public DeclContext,
47034703
private llvm::TrailingObjects<OutlinedFunctionDecl, ImplicitParamDecl *> {
4704-
protected:
4705-
size_t numTrailingObjects(OverloadToken<ImplicitParamDecl>) {
4706-
return NumParams;
4707-
}
4708-
47094704
private:
47104705
/// The number of parameters to the outlined function.
47114706
unsigned NumParams;
@@ -4750,21 +4745,14 @@ class OutlinedFunctionDecl final
47504745
getParams()[i] = P;
47514746
}
47524747

4753-
// ArrayRef interface to parameters.
4754-
ArrayRef<ImplicitParamDecl *> parameters() const {
4755-
return {getParams(), getNumParams()};
4748+
// Range interface to parameters.
4749+
using parameter_const_iterator = const ImplicitParamDecl * const *;
4750+
using parameter_const_range = llvm::iterator_range<parameter_const_iterator>;
4751+
parameter_const_range parameters() const {
4752+
return {param_begin(), param_end()};
47564753
}
4757-
MutableArrayRef<ImplicitParamDecl *> parameters() {
4758-
return {getParams(), getNumParams()};
4759-
}
4760-
4761-
using param_iterator = ImplicitParamDecl *const *;
4762-
using param_range = llvm::iterator_range<param_iterator>;
4763-
4764-
/// Retrieve an iterator pointing to the first parameter decl.
4765-
param_iterator param_begin() const { return getParams(); }
4766-
/// Retrieve an iterator one past the last parameter decl.
4767-
param_iterator param_end() const { return getParams() + NumParams; }
4754+
parameter_const_iterator param_begin() const { return getParams(); }
4755+
parameter_const_iterator param_end() const { return getParams() + NumParams; }
47684756

47694757
// Implement isa/cast/dyncast/etc.
47704758
static bool classof(const Decl *D) { return classofKind(D->getKind()); }

clang/include/clang/AST/StmtSYCL.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,18 @@ class SYCLKernelCallStmt : public Stmt {
4444

4545
public:
4646
/// Construct a SYCL kernel call statement.
47-
SYCLKernelCallStmt(Stmt *OS, OutlinedFunctionDecl *OFD)
48-
: Stmt(SYCLKernelCallStmtClass), OriginalStmt(OS), OFDecl(OFD) {}
47+
SYCLKernelCallStmt(CompoundStmt *CS, OutlinedFunctionDecl *OFD)
48+
: Stmt(SYCLKernelCallStmtClass), OriginalStmt(CS), OFDecl(OFD) {}
4949

5050
/// Construct an empty SYCL kernel call statement.
5151
SYCLKernelCallStmt(EmptyShell Empty) : Stmt(SYCLKernelCallStmtClass, Empty) {}
5252

5353
/// Retrieve the model statement.
54-
Stmt *getOriginalStmt() { return OriginalStmt; }
55-
const Stmt *getOriginalStmt() const { return OriginalStmt; }
56-
void setOriginalStmt(Stmt *S) { OriginalStmt = S; }
54+
CompoundStmt *getOriginalStmt() { return cast<CompoundStmt>(OriginalStmt); }
55+
const CompoundStmt *getOriginalStmt() const {
56+
return cast<CompoundStmt>(OriginalStmt);
57+
}
58+
void setOriginalStmt(CompoundStmt *CS) { OriginalStmt = CS; }
5759

5860
/// Retrieve the outlined function declaration.
5961
OutlinedFunctionDecl *getOutlinedFunctionDecl() { return OFDecl; }

clang/include/clang/Sema/SemaSYCL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class SemaSYCL : public SemaBase {
6565
void handleKernelEntryPointAttr(Decl *D, const ParsedAttr &AL);
6666

6767
void CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD);
68-
StmtResult BuildSYCLKernelCallStmt(FunctionDecl *FD, Stmt *Body);
68+
StmtResult BuildSYCLKernelCallStmt(FunctionDecl *FD, CompoundStmt *Body);
6969
};
7070

7171
} // namespace clang

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15986,7 +15986,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
1598615986
}
1598715987

1598815988
if (Body && !FD->isTemplated() && !SKEPAttr->isInvalidAttr()) {
15989-
StmtResult SR = SYCL().BuildSYCLKernelCallStmt(FD, Body);
15989+
StmtResult SR = SYCL().BuildSYCLKernelCallStmt(FD,
15990+
cast<CompoundStmt>(Body));
1599015991
if (SR.isInvalid())
1599115992
return nullptr;
1599215993
Body = SR.get();

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ class OutlinedFunctionDeclBodyInstantiator
412412

413413
} // unnamed namespace
414414

415-
StmtResult SemaSYCL::BuildSYCLKernelCallStmt(FunctionDecl *FD, Stmt *Body) {
415+
StmtResult SemaSYCL::BuildSYCLKernelCallStmt(FunctionDecl *FD,
416+
CompoundStmt *Body) {
416417
assert(!FD->isInvalidDecl());
417418
assert(!FD->isTemplated());
418419
assert(FD->hasPrototype());

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,10 +1799,9 @@ void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) {
17991799
void ASTDeclReader::VisitOutlinedFunctionDecl(OutlinedFunctionDecl *D) {
18001800
// NumParams is deserialized by OutlinedFunctionDecl::CreateDeserialized().
18011801
VisitDecl(D);
1802-
D->setNothrow(Record.readInt() != 0);
1803-
for (unsigned I = 0; I < D->NumParams; ++I) {
1802+
for (unsigned I = 0; I < D->NumParams; ++I)
18041803
D->setParam(I, readDeclAs<ImplicitParamDecl>());
1805-
}
1804+
D->setNothrow(Record.readInt() != 0);
18061805
D->setBody(cast_or_null<Stmt>(Record.readStmt()));
18071806
}
18081807

clang/lib/Serialization/ASTReaderStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
531531

532532
void ASTStmtReader::VisitSYCLKernelCallStmt(SYCLKernelCallStmt *S) {
533533
VisitStmt(S);
534-
S->setOriginalStmt(Record.readSubStmt());
534+
S->setOriginalStmt(cast<CompoundStmt>(Record.readSubStmt()));
535535
S->setOutlinedFunctionDecl(readDeclAs<OutlinedFunctionDecl>());
536536
}
537537

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,9 +1381,9 @@ void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) {
13811381
void ASTDeclWriter::VisitOutlinedFunctionDecl(OutlinedFunctionDecl *D) {
13821382
Record.push_back(D->getNumParams());
13831383
VisitDecl(D);
1384-
Record.push_back(D->isNothrow() ? 1 : 0);
13851384
for (unsigned I = 0; I < D->getNumParams(); ++I)
13861385
Record.AddDeclRef(D->getParam(I));
1386+
Record.push_back(D->isNothrow() ? 1 : 0);
13871387
Record.AddStmt(D->getBody());
13881388
Code = serialization::DECL_OUTLINEDFUNCTION;
13891389
}

0 commit comments

Comments
 (0)