[clang] [SYCL] Basic diagnostics for the sycl_kernel_entry_point attribute. (PR #120327)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 17 15:03:13 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 9f231a85004fad080980e80ef881c81d1d5bb60e 6ed96d3bf22c5da5af995ea5ffe083baf91594bb --extensions h,cpp -- clang/test/SemaSYCL/sycl-kernel-entry-point-attr-appertainment.cpp clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-module.cpp clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-pch.cpp clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name.cpp clang/test/SemaSYCL/sycl-kernel-entry-point-attr-sfinae.cpp clang/include/clang/AST/ASTContext.h clang/include/clang/Sema/SemaSYCL.h clang/lib/AST/ASTContext.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaSYCL.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/test/ASTSYCL/ast-dump-sycl-kernel-entry-point.cpp clang/test/SemaSYCL/sycl-kernel-entry-point-attr-grammar.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index aea8bb112c..a68dcfe5c2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -52,8 +52,8 @@
#include "clang/Sema/SemaOpenMP.h"
#include "clang/Sema/SemaPPC.h"
#include "clang/Sema/SemaRISCV.h"
-#include "clang/Sema/SemaSwift.h"
#include "clang/Sema/SemaSYCL.h"
+#include "clang/Sema/SemaSwift.h"
#include "clang/Sema/SemaWasm.h"
#include "clang/Sema/Template.h"
#include "llvm/ADT/STLForwardCompat.h"
@@ -15994,15 +15994,15 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
if (FD->isDeleted()) {
Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(),
diag::err_sycl_entry_point_invalid)
- << /*deleted function*/2;
+ << /*deleted function*/ 2;
} else if (FD->isDefaulted()) {
Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(),
diag::err_sycl_entry_point_invalid)
- << /*defaulted function*/3;
+ << /*defaulted function*/ 3;
} else if (FSI->isCoroutine()) {
Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(),
diag::err_sycl_entry_point_invalid)
- << /*coroutine*/7;
+ << /*coroutine*/ 7;
}
}
diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp
index 04ab8c28e1..9e34b30892 100644
--- a/clang/lib/Sema/SemaSYCL.cpp
+++ b/clang/lib/Sema/SemaSYCL.cpp
@@ -235,8 +235,7 @@ static bool CheckSYCLKernelName(Sema &S, SourceLocation Loc,
S.Diag(Loc, diag::warn_sycl_kernel_name_not_a_class_type) << KernelName;
SourceLocation DeclTypeLoc = SourceLocationForType(KernelName);
if (DeclTypeLoc.isValid())
- S.Diag(DeclTypeLoc, diag::note_entity_declared_at)
- << KernelName;
+ S.Diag(DeclTypeLoc, diag::note_entity_declared_at) << KernelName;
return true;
}
@@ -248,8 +247,7 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
// and warn about any redundant ones.
const SYCLKernelEntryPointAttr *SKEPAttr = nullptr;
for (auto SAI = FD->specific_attr_begin<SYCLKernelEntryPointAttr>();
- SAI != FD->specific_attr_end<SYCLKernelEntryPointAttr>();
- ++SAI) {
+ SAI != FD->specific_attr_end<SYCLKernelEntryPointAttr>(); ++SAI) {
if (!SKEPAttr) {
SKEPAttr = *SAI;
continue;
@@ -284,8 +282,8 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
Diag(SKEPAttr->getLocation(),
diag::err_sycl_entry_point_invalid_redeclaration)
<< SKEPAttr->getKernelName() << PrevSKEPAttr->getKernelName();
- Diag(PrevSKEPAttr->getLocation(), diag::note_previous_decl)
- << PrevFD;;
+ Diag(PrevSKEPAttr->getLocation(), diag::note_previous_decl) << PrevFD;
+ ;
}
}
}
@@ -293,23 +291,23 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
if (auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
if (!MD->isStatic()) {
Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
- << /*non-static member function*/0;
+ << /*non-static member function*/ 0;
}
}
if (FD->isVariadic()) {
Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
- << /*variadic function*/1;
+ << /*variadic function*/ 1;
}
if (FD->isConsteval()) {
Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
- << /*consteval function*/5;
+ << /*consteval function*/ 5;
} else if (FD->isConstexpr()) {
Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
- << /*constexpr function*/4;
+ << /*constexpr function*/ 4;
}
if (FD->isNoReturn()) {
Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
- << /*noreturn function*/6;
+ << /*noreturn function*/ 6;
}
if (!FD->getReturnType()->isVoidType()) {
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index ac5dd7fd16..e65983f201 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1136,13 +1136,12 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
if (FD->hasAttr<SYCLKernelEntryPointAttr>()) {
const auto *SKEPAttr = FD->getAttr<SYCLKernelEntryPointAttr>();
ASTContext &C = Reader.getContext();
- const SYCLKernelInfo *SKI =
- C.findSYCLKernelInfo(SKEPAttr->getKernelName());
+ const SYCLKernelInfo *SKI = C.findSYCLKernelInfo(SKEPAttr->getKernelName());
if (SKI) {
if (!declaresSameEntity(FD, SKI->getKernelEntryPointDecl())) {
Reader.Diag(FD->getLocation(), diag::err_sycl_kernel_name_conflict);
Reader.Diag(SKI->getKernelEntryPointDecl()->getLocation(),
- diag::note_previous_declaration);
+ diag::note_previous_declaration);
}
} else {
C.registerSYCLEntryPointFunction(FD);
``````````
</details>
https://github.com/llvm/llvm-project/pull/120327
More information about the cfe-commits
mailing list