Skip to content

Commit 2067e3f

Browse files
Endillllravenclaw
authored andcommitted
[clang][NFC] Move more things out of SemaChecking.cpp (llvm#96641)
This patch moves some functions out of `SemaChecking.cpp`. ObjC-, HLSL-, OpenCL-related functions are affected. This patch continues the effort of splitting `Sema` into parts. Additional context can be found in llvm#84184 and llvm#92682.
1 parent 466e122 commit 2067e3f

File tree

9 files changed

+1118
-1101
lines changed

9 files changed

+1118
-1101
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,8 +2114,6 @@ class Sema final : public SemaBase {
21142114

21152115
bool FormatStringHasSArg(const StringLiteral *FExpr);
21162116

2117-
static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx);
2118-
21192117
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
21202118
BinaryOperatorKind Opcode);
21212119

@@ -2228,8 +2226,6 @@ class Sema final : public SemaBase {
22282226
bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res);
22292227
bool BuiltinVectorToScalarMath(CallExpr *TheCall);
22302228

2231-
bool CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2232-
22332229
void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
22342230
const Expr *ThisArg, ArrayRef<const Expr *> Args,
22352231
bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
@@ -2259,6 +2255,14 @@ class Sema final : public SemaBase {
22592255

22602256
bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
22612257

2258+
void CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC,
2259+
bool *ICContext = nullptr,
2260+
bool IsListInit = false);
2261+
2262+
bool BuiltinElementwiseTernaryMath(CallExpr *TheCall,
2263+
bool CheckForFloatArgs = true);
2264+
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall);
2265+
22622266
private:
22632267
void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
22642268
const ArraySubscriptExpr *ASE = nullptr,
@@ -2306,9 +2310,6 @@ class Sema final : public SemaBase {
23062310
AtomicExpr::AtomicOp Op);
23072311

23082312
bool BuiltinElementwiseMath(CallExpr *TheCall);
2309-
bool BuiltinElementwiseTernaryMath(CallExpr *TheCall,
2310-
bool CheckForFloatArgs = true);
2311-
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall);
23122313
bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
23132314

23142315
bool BuiltinNonDeterministicValue(CallExpr *TheCall);

clang/include/clang/Sema/SemaHLSL.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class SemaHLSL : public SemaBase {
5858
void handleShaderAttr(Decl *D, const ParsedAttr &AL);
5959
void handleResourceBindingAttr(Decl *D, const ParsedAttr &AL);
6060
void handleParamModifierAttr(Decl *D, const ParsedAttr &AL);
61+
62+
bool CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
6163
};
6264

6365
} // namespace clang

clang/include/clang/Sema/SemaObjC.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,27 @@ class SemaObjC : public SemaBase {
158158

159159
IdentifierInfo *getNSErrorIdent();
160160

161+
bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx);
162+
163+
/// Diagnose use of %s directive in an NSString which is being passed
164+
/// as formatting string to formatting method.
165+
void DiagnoseCStringFormatDirectiveInCFAPI(const NamedDecl *FDecl,
166+
Expr **Args, unsigned NumArgs);
167+
168+
bool isSignedCharBool(QualType Ty);
169+
170+
void adornBoolConversionDiagWithTernaryFixit(
171+
Expr *SourceExpr, const Sema::SemaDiagnosticBuilder &Builder);
172+
173+
/// Check an Objective-C dictionary literal being converted to the given
174+
/// target type.
175+
void checkDictionaryLiteral(QualType TargetType,
176+
ObjCDictionaryLiteral *DictionaryLiteral);
177+
178+
/// Check an Objective-C array literal being converted to the given
179+
/// target type.
180+
void checkArrayLiteral(QualType TargetType, ObjCArrayLiteral *ArrayLiteral);
181+
161182
private:
162183
IdentifierInfo *Ident_NSError = nullptr;
163184

clang/include/clang/Sema/SemaOpenCL.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,78 @@ class SemaOpenCL : public SemaBase {
2828

2929
// Handles intel_reqd_sub_group_size.
3030
void handleSubGroupSize(Decl *D, const ParsedAttr &AL);
31+
32+
// Performs semantic analysis for the read/write_pipe call.
33+
// \param S Reference to the semantic analyzer.
34+
// \param Call A pointer to the builtin call.
35+
// \return True if a semantic error has been found, false otherwise.
36+
bool checkBuiltinRWPipe(CallExpr *Call);
37+
38+
// Performs a semantic analysis on the {work_group_/sub_group_
39+
// /_}reserve_{read/write}_pipe
40+
// \param S Reference to the semantic analyzer.
41+
// \param Call The call to the builtin function to be analyzed.
42+
// \return True if a semantic error was found, false otherwise.
43+
bool checkBuiltinReserveRWPipe(CallExpr *Call);
44+
45+
bool checkSubgroupExt(CallExpr *Call);
46+
47+
// Performs a semantic analysis on {work_group_/sub_group_
48+
// /_}commit_{read/write}_pipe
49+
// \param S Reference to the semantic analyzer.
50+
// \param Call The call to the builtin function to be analyzed.
51+
// \return True if a semantic error was found, false otherwise.
52+
bool checkBuiltinCommitRWPipe(CallExpr *Call);
53+
54+
// Performs a semantic analysis on the call to built-in Pipe
55+
// Query Functions.
56+
// \param S Reference to the semantic analyzer.
57+
// \param Call The call to the builtin function to be analyzed.
58+
// \return True if a semantic error was found, false otherwise.
59+
bool checkBuiltinPipePackets(CallExpr *Call);
60+
61+
// OpenCL v2.0 s6.13.9 - Address space qualifier functions.
62+
// Performs semantic analysis for the to_global/local/private call.
63+
// \param S Reference to the semantic analyzer.
64+
// \param BuiltinID ID of the builtin function.
65+
// \param Call A pointer to the builtin call.
66+
// \return True if a semantic error has been found, false otherwise.
67+
bool checkBuiltinToAddr(unsigned BuiltinID, CallExpr *Call);
68+
69+
/// OpenCL C v2.0, s6.13.17 - Enqueue kernel function contains four different
70+
/// overload formats specified in Table 6.13.17.1.
71+
/// int enqueue_kernel(queue_t queue,
72+
/// kernel_enqueue_flags_t flags,
73+
/// const ndrange_t ndrange,
74+
/// void (^block)(void))
75+
/// int enqueue_kernel(queue_t queue,
76+
/// kernel_enqueue_flags_t flags,
77+
/// const ndrange_t ndrange,
78+
/// uint num_events_in_wait_list,
79+
/// clk_event_t *event_wait_list,
80+
/// clk_event_t *event_ret,
81+
/// void (^block)(void))
82+
/// int enqueue_kernel(queue_t queue,
83+
/// kernel_enqueue_flags_t flags,
84+
/// const ndrange_t ndrange,
85+
/// void (^block)(local void*, ...),
86+
/// uint size0, ...)
87+
/// int enqueue_kernel(queue_t queue,
88+
/// kernel_enqueue_flags_t flags,
89+
/// const ndrange_t ndrange,
90+
/// uint num_events_in_wait_list,
91+
/// clk_event_t *event_wait_list,
92+
/// clk_event_t *event_ret,
93+
/// void (^block)(local void*, ...),
94+
/// uint size0, ...)
95+
bool checkBuiltinEnqueueKernel(CallExpr *TheCall);
96+
97+
/// OpenCL C v2.0, s6.13.17.6 - Check the argument to the
98+
/// get_kernel_work_group_size
99+
/// and get_kernel_preferred_work_group_size_multiple builtin functions.
100+
bool checkBuiltinKernelWorkGroupSize(CallExpr *TheCall);
101+
102+
bool checkBuiltinNDRangeAndBlock(CallExpr *TheCall);
31103
};
32104

33105
} // namespace clang

0 commit comments

Comments
 (0)