30 "Should only be called during SYCL compilation");
32 SemaDiagnosticBuilder::Kind DiagKind = [
this, FD] {
34 return SemaDiagnosticBuilder::K_Nop;
36 return SemaDiagnosticBuilder::K_ImmediateWithCallStack;
37 return SemaDiagnosticBuilder::K_Deferred;
44 return CAT->isZeroSize();
49 llvm::DenseSet<QualType>
Visited,
52 "Should only be called during SYCL compilation");
55 bool NeedToEmitNotes =
true;
58 bool ErrorFound =
false;
65 if (NeedToEmitNotes) {
66 if (
auto *FD = dyn_cast<FieldDecl>(
D))
68 diag::note_illegal_field_declared_here)
69 << FD->getType()->isPointerType() << FD->getType();
80 StackForRecursion.push_back(DeclToCheck);
84 History.push_back(
nullptr);
87 const ValueDecl *Next = StackForRecursion.pop_back_val();
89 assert(!History.empty());
96 if (!
Visited.insert(NextTy).second)
99 auto EmitHistory = [&]() {
101 for (uint64_t Index = 1; Index < History.size(); ++Index) {
103 diag::note_within_field_of_type)
104 << History[Index]->getType();
108 if (Check(NextTy, Next)) {
111 NeedToEmitNotes =
false;
122 if (Check(NextTy, Next)) {
125 NeedToEmitNotes =
false;
130 if (
auto *NextFD = dyn_cast<FieldDecl>(Next))
131 History.push_back(NextFD);
134 StackForRecursion.push_back(
nullptr);
135 llvm::copy(RecDecl->fields(), std::back_inserter(StackForRecursion));
137 }
while (!StackForRecursion.empty());
165 const auto *FD = cast<FunctionDecl>(
D);
167 assert(FT &&
"Function template is expected");
171 if (TL->
size() < 2) {
172 Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_template_params);
177 for (
unsigned I = 0; I < 2; ++I) {
179 if (isa<NonTypeTemplateParmDecl>(TParam)) {
181 diag::warn_sycl_kernel_invalid_template_param_type);
188 Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_function_params);
199 handleSimpleAttribute<SYCLKernelAttr>(*
this,
D, AL);
llvm::DenseSet< const void * > Visited
static bool isZeroSizedArray(SemaSYCL &S, QualType Ty)
This file declares semantic analysis for SYCL constructs.
Allows QualTypes to be sorted and hence used in maps and sets.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
Represents a function declaration or definition.
Declaration of a template function.
This represents a decl that may have a name.
ParsedAttr - Represents a syntactic attribute.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static SYCLUniqueStableNameExpr * Create(const ASTContext &Ctx, SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ASTContext & getASTContext() const
const LangOptions & getLangOpts() const
SemaDiagnosticBuilder DiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device c...
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
void deepTypeCheckForDevice(SourceLocation UsedAt, llvm::DenseSet< QualType > Visited, ValueDecl *DeclToCheck)
void handleKernelAttr(Decl *D, const ParsedAttr &AL)
ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, ParsedType ParsedTy)
Sema - This implements semantic analysis and AST building for C.
ASTContext & getASTContext() const
DeclContext * getCurLexicalContext() const
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
Encodes a location in the source.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
A container of type source information.
bool isReferenceType() const
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isAnyPointerType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
The JSON file list parser is used to communicate input to InstallAPI.
QualType getFunctionOrMethodResultType(const Decl *D)
unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.