Skip to content

Commit 128ab1b

Browse files
committed
Address review comments #1
1 parent f631d7a commit 128ab1b

File tree

6 files changed

+13
-19
lines changed

6 files changed

+13
-19
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,6 @@ class LangOpt<string name, code customCode = [{}], bit silentlyIgnore = 0> {
412412
// The language option to test; ignored when custom code is supplied.
413413
string Name = name;
414414

415-
// If set to 1, the attribute is accepted but is silently ignored. This is
416-
// useful in multi-compilation situations like SYCL.
417-
bit SilentlyIgnore = silentlyIgnore;
418-
419415
// A custom predicate, written as an expression evaluated in a context with
420416
// "LangOpts" bound.
421417
code CustomCode = customCode;
@@ -426,7 +422,6 @@ def CUDA : LangOpt<"CUDA">;
426422
def HIP : LangOpt<"HIP">;
427423
def SYCLHost : LangOpt<"SYCLIsHost">;
428424
def SYCLDevice : LangOpt<"SYCLIsDevice">;
429-
def SilentlyIgnoreSYCLHost : LangOpt<"SYCLIsHost", "", 1>;
430425
def COnly : LangOpt<"", "!LangOpts.CPlusPlus">;
431426
def CPlusPlus : LangOpt<"CPlusPlus">;
432427
def OpenCL : LangOpt<"OpenCL">;
@@ -1556,9 +1551,9 @@ def GlobalStorageNonLocalVar : SubsetSubject<Var,
15561551
"global variables">;
15571552

15581553
def SYCLExternal : InheritableAttr {
1559-
let Spellings = [GNU<"sycl_external">];
1554+
let Spellings = [Clang<"sycl_external">];
15601555
let Subjects = SubjectList<[Function, GlobalStorageNonLocalVar]>;
1561-
let LangOpts = [SYCLDevice, SilentlyIgnoreSYCLHost];
1556+
let LangOpts = [SYCLDevice];
15621557
let Documentation = [SYCLExternalDocs];
15631558
}
15641559

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12747,9 +12747,8 @@ def err_sycl_special_type_num_init_method : Error<
1274712747
"method defined">;
1274812748

1274912749
//SYCL external attribute diagnostics
12750-
def err_sycl_attribute_internal_decl
12751-
: Error<"%0 attribute cannot be applied to a %select{function|variable}1"
12752-
" without external linkage">;
12750+
def err_sycl_attribute_invalid_linkage : Error<
12751+
"'sycl_external' can only be applied to functions with external linkage">;
1275312752

1275412753
// SYCL kernel entry point diagnostics
1275512754
def err_sycl_entry_point_invalid : Error<

clang/include/clang/Sema/SemaSYCL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class SemaSYCL : public SemaBase {
6262
ParsedType ParsedTy);
6363

6464
void handleKernelAttr(Decl *D, const ParsedAttr &AL);
65-
void handleSYCLExternalAttr(Decl *D, const ParsedAttr &AL);
65+
void handleExternalAttr(Decl *D, const ParsedAttr &AL);
6666
void handleKernelEntryPointAttr(Decl *D, const ParsedAttr &AL);
6767

6868
void CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD);

clang/lib/AST/ASTContext.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12909,7 +12909,8 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
1290912909
if (D->hasAttr<WeakRefAttr>())
1291012910
return false;
1291112911

12912-
if (LangOpts.SYCLIsDevice && !D->hasAttr<SYCLKernelEntryPointAttr>())
12912+
if (LangOpts.SYCLIsDevice &&
12913+
(!D->hasAttr<SYCLKernelEntryPointAttr>() || !D->hasAttr<SYCLExternalAttr>()))
1291312914
return false;
1291412915

1291512916
// Aliases and used decls are required.
@@ -12927,10 +12928,9 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
1292712928
if (LangOpts.SYCLIsDevice && FD->hasAttr<SYCLKernelEntryPointAttr>())
1292812929
return true;
1292912930

12930-
// FIXME: Functions declared with SYCL_EXTERNAL are required during
12931-
// device compilation.
12932-
// Functions definitions with sycl_external attribute are required during
12933-
// device compilation.
12931+
// Functions definitions with the sycl_external attribute are required
12932+
// during device compilation regardless of whether they are reachable from
12933+
// a SYCL kernel.
1293412934
if (LangOpts.SYCLIsDevice && FD->hasAttr<SYCLExternalAttr>())
1293512935
return true;
1293612936

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7114,7 +7114,7 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
71147114
S.SYCL().handleKernelAttr(D, AL);
71157115
break;
71167116
case ParsedAttr::AT_SYCLExternal:
7117-
S.SYCL().handleSYCLExternalAttr(D, AL);
7117+
S.SYCL().handleExternalAttr(D, AL);
71187118
break;
71197119
case ParsedAttr::AT_SYCLKernelEntryPoint:
71207120
S.SYCL().handleKernelEntryPointAttr(D, AL);

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ void SemaSYCL::handleKernelAttr(Decl *D, const ParsedAttr &AL) {
202202
handleSimpleAttribute<SYCLKernelAttr>(*this, D, AL);
203203
}
204204

205-
void SemaSYCL::handleSYCLExternalAttr(Decl *D, const ParsedAttr &AL) {
205+
void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) {
206206
auto *ND = cast<NamedDecl>(D);
207207
if (!ND->isExternallyVisible()) {
208-
Diag(AL.getLoc(), diag::err_sycl_attribute_internal_decl)
208+
Diag(AL.getLoc(), diag::err_sycl_attribute_invalid_linkage)
209209
<< AL << !isa<FunctionDecl>(ND);
210210
return;
211211
}

0 commit comments

Comments
 (0)