63 #include "llvm/ADT/APFloat.h" 64 #include "llvm/ADT/APInt.h" 65 #include "llvm/ADT/APSInt.h" 66 #include "llvm/ADT/ArrayRef.h" 67 #include "llvm/ADT/DenseMap.h" 68 #include "llvm/ADT/FoldingSet.h" 69 #include "llvm/ADT/None.h" 70 #include "llvm/ADT/Optional.h" 71 #include "llvm/ADT/STLExtras.h" 72 #include "llvm/ADT/SmallBitVector.h" 73 #include "llvm/ADT/SmallPtrSet.h" 74 #include "llvm/ADT/SmallString.h" 75 #include "llvm/ADT/SmallVector.h" 76 #include "llvm/ADT/StringRef.h" 77 #include "llvm/ADT/StringSwitch.h" 78 #include "llvm/ADT/Triple.h" 79 #include "llvm/Support/AtomicOrdering.h" 80 #include "llvm/Support/Casting.h" 81 #include "llvm/Support/Compiler.h" 82 #include "llvm/Support/ConvertUTF.h" 83 #include "llvm/Support/ErrorHandling.h" 84 #include "llvm/Support/Format.h" 85 #include "llvm/Support/Locale.h" 86 #include "llvm/Support/MathExtras.h" 87 #include "llvm/Support/SaveAndRestore.h" 88 #include "llvm/Support/raw_ostream.h" 99 using namespace clang;
100 using namespace sema;
103 unsigned ByteNo)
const {
112 if (argCount == desiredArgCount)
return false;
114 if (argCount < desiredArgCount)
115 return S.
Diag(call->
getEndLoc(), diag::err_typecheck_call_too_few_args)
116 << 0 << desiredArgCount << argCount
123 return S.
Diag(
range.getBegin(), diag::err_typecheck_call_too_many_args)
124 << 0 << desiredArgCount << argCount
146 if (!Literal || !Literal->
isAscii()) {
159 S.
Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args_at_least)
167 auto *Literal = dyn_cast<
StringLiteral>(Arg->IgnoreParenCasts());
168 if (!Literal || !Literal->isWide()) {
169 S.
Diag(Arg->getBeginLoc(), diag::err_msvc_annotation_wide_str)
170 << Arg->getSourceRange();
186 if (ResultType.isNull())
189 TheCall->
setArg(0, Arg.get());
209 for (
unsigned I = 0; I < 2; ++I) {
213 S.
Diag(Arg.
get()->getBeginLoc(), diag::err_overflow_builtin_must_be_int)
214 << Ty << Arg.
get()->getSourceRange();
222 TheCall->
setArg(I, Arg.get());
232 if (!(PtrTy && PtrTy->getPointeeType()->isIntegerType() &&
233 !PtrTy->getPointeeType().isConstQualified())) {
234 S.
Diag(Arg.
get()->getBeginLoc(),
235 diag::err_overflow_builtin_must_be_ptr_int)
236 << Ty << Arg.
get()->getSourceRange();
244 TheCall->
setArg(2, Arg.get());
259 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_not_call)
264 auto CE = cast<CallExpr>(Call);
265 if (CE->getCallee()->getType()->isBlockPointerType()) {
266 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_block_call)
271 const Decl *TargetDecl = CE->getCalleeDecl();
272 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
273 if (FD->getBuiltinID()) {
274 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_builtin_call)
279 if (isa<CXXPseudoDestructorExpr>(CE->getCallee()->IgnoreParens())) {
280 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_pdtor_call)
288 if (!ChainResult.
get()->getType()->isPointerType()) {
289 S.
Diag(BuiltinLoc, diag::err_second_argument_to_cwsc_not_pointer)
295 QualType ArgTys[2] = { ReturnTy, ChainResult.
get()->getType() };
303 BuiltinCall->
setType(CE->getType());
307 BuiltinCall->
setArg(1, ChainResult.
get());
315 void Sema::checkFortifiedBuiltinMemoryFunction(
FunctionDecl *FD,
322 isConstantEvaluated())
330 bool IsChkVariant =
false;
331 unsigned SizeIndex, ObjectIndex;
335 case Builtin::BI__builtin___memcpy_chk:
336 case Builtin::BI__builtin___memmove_chk:
337 case Builtin::BI__builtin___memset_chk:
338 case Builtin::BI__builtin___strlcat_chk:
339 case Builtin::BI__builtin___strlcpy_chk:
340 case Builtin::BI__builtin___strncat_chk:
341 case Builtin::BI__builtin___strncpy_chk:
342 case Builtin::BI__builtin___stpncpy_chk:
343 case Builtin::BI__builtin___memccpy_chk: {
344 DiagID = diag::warn_builtin_chk_overflow;
351 case Builtin::BI__builtin___snprintf_chk:
352 case Builtin::BI__builtin___vsnprintf_chk: {
353 DiagID = diag::warn_builtin_chk_overflow;
360 case Builtin::BIstrncat:
361 case Builtin::BI__builtin_strncat:
362 case Builtin::BIstrncpy:
363 case Builtin::BI__builtin_strncpy:
364 case Builtin::BIstpncpy:
365 case Builtin::BI__builtin_stpncpy: {
371 DiagID = diag::warn_fortify_source_size_mismatch;
377 case Builtin::BImemcpy:
378 case Builtin::BI__builtin_memcpy:
379 case Builtin::BImemmove:
380 case Builtin::BI__builtin_memmove:
381 case Builtin::BImemset:
382 case Builtin::BI__builtin_memset: {
383 DiagID = diag::warn_fortify_source_overflow;
388 case Builtin::BIsnprintf:
389 case Builtin::BI__builtin_snprintf:
390 case Builtin::BIvsnprintf:
391 case Builtin::BI__builtin_vsnprintf: {
392 DiagID = diag::warn_fortify_source_size_mismatch;
399 llvm::APSInt ObjectSize;
415 if (
const auto *POS =
417 BOSType = POS->getType();
424 const TargetInfo &TI = getASTContext().getTargetInfo();
426 ObjectSize = llvm::APSInt::getUnsigned(Result).extOrTrunc(SizeTypeWidth);
431 Expr *UsedSizeArg = TheCall->
getArg(SizeIndex);
434 llvm::APSInt UsedSize = Result.
Val.
getInt();
436 if (UsedSize.ule(ObjectSize))
439 StringRef FunctionName = getASTContext().BuiltinInfo.getName(BuiltinID);
443 FunctionName = FunctionName.drop_front(std::strlen(
"__builtin___"));
444 FunctionName = FunctionName.drop_back(std::strlen(
"_chk"));
445 }
else if (FunctionName.startswith(
"__builtin_")) {
446 FunctionName = FunctionName.drop_front(std::strlen(
"__builtin_"));
449 DiagRuntimeBehavior(TheCall->
getBeginLoc(), TheCall,
451 << FunctionName << ObjectSize.toString(10)
452 << UsedSize.toString(10));
467 if (!S || !(S->
getFlags() & NeededScopeFlags)) {
470 << DRE->getDecl()->getIdentifier();
486 ArrayRef<QualType> Params =
488 unsigned ArgCounter = 0;
489 bool IllegalParams =
false;
492 for (ArrayRef<QualType>::iterator I = Params.begin(), E = Params.end();
493 I != E; ++I, ++ArgCounter) {
494 if (!(*I)->isPointerType() || !(*I)->getPointeeType()->isVoidType() ||
495 (*I)->getPointeeType().getQualifiers().getAddressSpace() !=
501 if (isa<BlockExpr>(BlockArg)) {
502 BlockDecl *BD = cast<BlockExpr>(BlockArg)->getBlockDecl();
504 }
else if (isa<DeclRefExpr>(BlockArg)) {
505 ErrorLoc = cast<DeclRefExpr>(BlockArg)->getBeginLoc();
508 diag::err_opencl_enqueue_kernel_blocks_non_local_void_args);
509 IllegalParams =
true;
513 return IllegalParams;
535 S.
Diag(NDRangeArg->
getBeginLoc(), diag::err_opencl_builtin_expected_type)
542 S.
Diag(BlockArg->
getBeginLoc(), diag::err_opencl_builtin_expected_type)
558 S.
Diag(BlockArg->
getBeginLoc(), diag::err_opencl_builtin_expected_type)
570 unsigned Start,
unsigned End) {
571 bool IllegalParams =
false;
572 for (
unsigned I = Start; I <=
End; ++I)
575 return IllegalParams;
582 unsigned NumNonVarArgs) {
585 unsigned NumBlockParams =
587 unsigned TotalNumArgs = TheCall->
getNumArgs();
591 if (TotalNumArgs != NumBlockParams + NumNonVarArgs) {
593 diag::err_opencl_enqueue_kernel_local_size_args);
644 diag::err_opencl_builtin_expected_type)
652 diag::err_opencl_builtin_expected_type)
653 << TheCall->
getDirectCallee() <<
"'kernel_enqueue_flags_t' (i.e. uint)";
660 diag::err_opencl_builtin_expected_type)
679 diag::err_opencl_enqueue_kernel_blocks_no_args);
703 diag::err_opencl_builtin_expected_type)
716 diag::err_opencl_builtin_expected_type)
728 diag::err_opencl_builtin_expected_type)
742 diag::err_opencl_enqueue_kernel_incorrect_args);
748 return D->
getAttr<OpenCLAccessAttr>();
760 OpenCLAccessAttr *AccessQual =
767 case Builtin::BIread_pipe:
768 case Builtin::BIreserve_read_pipe:
769 case Builtin::BIcommit_read_pipe:
770 case Builtin::BIwork_group_reserve_read_pipe:
771 case Builtin::BIsub_group_reserve_read_pipe:
772 case Builtin::BIwork_group_commit_read_pipe:
773 case Builtin::BIsub_group_commit_read_pipe:
774 if (!(!AccessQual || AccessQual->isReadOnly())) {
776 diag::err_opencl_builtin_pipe_invalid_access_modifier)
781 case Builtin::BIwrite_pipe:
782 case Builtin::BIreserve_write_pipe:
783 case Builtin::BIcommit_write_pipe:
784 case Builtin::BIwork_group_reserve_write_pipe:
785 case Builtin::BIsub_group_reserve_write_pipe:
786 case Builtin::BIwork_group_commit_write_pipe:
787 case Builtin::BIsub_group_commit_write_pipe:
788 if (!(AccessQual && AccessQual->isWriteOnly())) {
790 diag::err_opencl_builtin_pipe_invalid_access_modifier)
960 if (!RT->isPointerType() || RT->getPointeeType()
962 S.
Diag(Call->
getBeginLoc(), diag::err_opencl_builtin_to_addr_invalid_arg)
969 diag::warn_opencl_generic_address_space_arg)
974 RT = RT->getPointeeType();
975 auto Qual = RT.getQualifiers();
977 case Builtin::BIto_global:
980 case Builtin::BIto_local:
983 case Builtin::BIto_private:
987 llvm_unreachable(
"Invalid builtin function");
990 RT.getUnqualifiedType(), Qual)));
1025 if (DiagSelect.hasValue()) {
1038 diag::err_incomplete_type))
1042 "Unhandled non-object pointer case");
1059 ArrayRef<llvm::Triple::ArchType> SupportedArchs) {
1060 llvm::Triple::ArchType CurArch =
1062 if (llvm::is_contained(SupportedArchs, CurArch))
1070 Sema::CheckBuiltinFunctionCall(
FunctionDecl *FDecl,
unsigned BuiltinID,
1075 unsigned ICEArguments = 0;
1082 for (
unsigned ArgNo = 0; ICEArguments != 0; ++ArgNo) {
1084 if ((ICEArguments & (1 << ArgNo)) == 0)
continue;
1086 llvm::APSInt Result;
1087 if (SemaBuiltinConstantArg(TheCall, ArgNo, Result))
1089 ICEArguments &= ~(1 << ArgNo);
1092 switch (BuiltinID) {
1093 case Builtin::BI__builtin___CFStringMakeConstantString:
1095 "Wrong # arguments to builtin CFStringMakeConstantString");
1096 if (CheckObjCString(TheCall->
getArg(0)))
1099 case Builtin::BI__builtin_ms_va_start:
1100 case Builtin::BI__builtin_stdarg_start:
1101 case Builtin::BI__builtin_va_start:
1102 if (SemaBuiltinVAStart(BuiltinID, TheCall))
1105 case Builtin::BI__va_start: {
1107 case llvm::Triple::aarch64:
1108 case llvm::Triple::arm:
1109 case llvm::Triple::thumb:
1110 if (SemaBuiltinVAStartARMMicrosoft(TheCall))
1114 if (SemaBuiltinVAStart(BuiltinID, TheCall))
1122 case Builtin::BI_interlockedbittestandset_acq:
1123 case Builtin::BI_interlockedbittestandset_rel:
1124 case Builtin::BI_interlockedbittestandset_nf:
1125 case Builtin::BI_interlockedbittestandreset_acq:
1126 case Builtin::BI_interlockedbittestandreset_rel:
1127 case Builtin::BI_interlockedbittestandreset_nf:
1129 *
this, BuiltinID, TheCall,
1130 {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
1135 case Builtin::BI_bittest64:
1136 case Builtin::BI_bittestandcomplement64:
1137 case Builtin::BI_bittestandreset64:
1138 case Builtin::BI_bittestandset64:
1139 case Builtin::BI_interlockedbittestandreset64:
1140 case Builtin::BI_interlockedbittestandset64:
1142 {llvm::Triple::x86_64, llvm::Triple::arm,
1143 llvm::Triple::thumb, llvm::Triple::aarch64}))
1147 case Builtin::BI__builtin_isgreater:
1148 case Builtin::BI__builtin_isgreaterequal:
1149 case Builtin::BI__builtin_isless:
1150 case Builtin::BI__builtin_islessequal:
1151 case Builtin::BI__builtin_islessgreater:
1152 case Builtin::BI__builtin_isunordered:
1153 if (SemaBuiltinUnorderedCompare(TheCall))
1156 case Builtin::BI__builtin_fpclassify:
1157 if (SemaBuiltinFPClassification(TheCall, 6))
1160 case Builtin::BI__builtin_isfinite:
1161 case Builtin::BI__builtin_isinf:
1162 case Builtin::BI__builtin_isinf_sign:
1163 case Builtin::BI__builtin_isnan:
1164 case Builtin::BI__builtin_isnormal:
1165 case Builtin::BI__builtin_signbit:
1166 case Builtin::BI__builtin_signbitf:
1167 case Builtin::BI__builtin_signbitl:
1168 if (SemaBuiltinFPClassification(TheCall, 1))
1171 case Builtin::BI__builtin_shufflevector:
1172 return SemaBuiltinShuffleVector(TheCall);
1175 case Builtin::BI__builtin_prefetch:
1176 if (SemaBuiltinPrefetch(TheCall))
1179 case Builtin::BI__builtin_alloca_with_align:
1180 if (SemaBuiltinAllocaWithAlign(TheCall))
1183 case Builtin::BI__assume:
1184 case Builtin::BI__builtin_assume:
1185 if (SemaBuiltinAssume(TheCall))
1188 case Builtin::BI__builtin_assume_aligned:
1189 if (SemaBuiltinAssumeAligned(TheCall))
1192 case Builtin::BI__builtin_dynamic_object_size:
1193 case Builtin::BI__builtin_object_size:
1194 if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 3))
1197 case Builtin::BI__builtin_longjmp:
1198 if (SemaBuiltinLongjmp(TheCall))
1201 case Builtin::BI__builtin_setjmp:
1202 if (SemaBuiltinSetjmp(TheCall))
1205 case Builtin::BI_setjmp:
1206 case Builtin::BI_setjmpex:
1210 case Builtin::BI__builtin_classify_type:
1214 case Builtin::BI__builtin_constant_p: {
1222 case Builtin::BI__builtin_launder:
1224 case Builtin::BI__sync_fetch_and_add:
1225 case Builtin::BI__sync_fetch_and_add_1:
1226 case Builtin::BI__sync_fetch_and_add_2:
1227 case Builtin::BI__sync_fetch_and_add_4:
1228 case Builtin::BI__sync_fetch_and_add_8:
1229 case Builtin::BI__sync_fetch_and_add_16:
1230 case Builtin::BI__sync_fetch_and_sub:
1231 case Builtin::BI__sync_fetch_and_sub_1:
1232 case Builtin::BI__sync_fetch_and_sub_2:
1233 case Builtin::BI__sync_fetch_and_sub_4:
1234 case Builtin::BI__sync_fetch_and_sub_8:
1235 case Builtin::BI__sync_fetch_and_sub_16:
1236 case Builtin::BI__sync_fetch_and_or:
1237 case Builtin::BI__sync_fetch_and_or_1:
1238 case Builtin::BI__sync_fetch_and_or_2:
1239 case Builtin::BI__sync_fetch_and_or_4:
1240 case Builtin::BI__sync_fetch_and_or_8:
1241 case Builtin::BI__sync_fetch_and_or_16:
1242 case Builtin::BI__sync_fetch_and_and:
1243 case Builtin::BI__sync_fetch_and_and_1:
1244 case Builtin::BI__sync_fetch_and_and_2:
1245 case Builtin::BI__sync_fetch_and_and_4:
1246 case Builtin::BI__sync_fetch_and_and_8:
1247 case Builtin::BI__sync_fetch_and_and_16:
1248 case Builtin::BI__sync_fetch_and_xor:
1249 case Builtin::BI__sync_fetch_and_xor_1:
1250 case Builtin::BI__sync_fetch_and_xor_2:
1251 case Builtin::BI__sync_fetch_and_xor_4:
1252 case Builtin::BI__sync_fetch_and_xor_8:
1253 case Builtin::BI__sync_fetch_and_xor_16:
1254 case Builtin::BI__sync_fetch_and_nand:
1255 case Builtin::BI__sync_fetch_and_nand_1:
1256 case Builtin::BI__sync_fetch_and_nand_2:
1257 case Builtin::BI__sync_fetch_and_nand_4:
1258 case Builtin::BI__sync_fetch_and_nand_8:
1259 case Builtin::BI__sync_fetch_and_nand_16:
1260 case Builtin::BI__sync_add_and_fetch:
1261 case Builtin::BI__sync_add_and_fetch_1:
1262 case Builtin::BI__sync_add_and_fetch_2:
1263 case Builtin::BI__sync_add_and_fetch_4:
1264 case Builtin::BI__sync_add_and_fetch_8:
1265 case Builtin::BI__sync_add_and_fetch_16:
1266 case Builtin::BI__sync_sub_and_fetch:
1267 case Builtin::BI__sync_sub_and_fetch_1:
1268 case Builtin::BI__sync_sub_and_fetch_2:
1269 case Builtin::BI__sync_sub_and_fetch_4:
1270 case Builtin::BI__sync_sub_and_fetch_8:
1271 case Builtin::BI__sync_sub_and_fetch_16:
1272 case Builtin::BI__sync_and_and_fetch:
1273 case Builtin::BI__sync_and_and_fetch_1:
1274 case Builtin::BI__sync_and_and_fetch_2:
1275 case Builtin::BI__sync_and_and_fetch_4:
1276 case Builtin::BI__sync_and_and_fetch_8:
1277 case Builtin::BI__sync_and_and_fetch_16:
1278 case Builtin::BI__sync_or_and_fetch:
1279 case Builtin::BI__sync_or_and_fetch_1:
1280 case Builtin::BI__sync_or_and_fetch_2:
1281 case Builtin::BI__sync_or_and_fetch_4:
1282 case Builtin::BI__sync_or_and_fetch_8:
1283 case Builtin::BI__sync_or_and_fetch_16:
1284 case Builtin::BI__sync_xor_and_fetch:
1285 case Builtin::BI__sync_xor_and_fetch_1:
1286 case Builtin::BI__sync_xor_and_fetch_2:
1287 case Builtin::BI__sync_xor_and_fetch_4:
1288 case Builtin::BI__sync_xor_and_fetch_8:
1289 case Builtin::BI__sync_xor_and_fetch_16:
1290 case Builtin::BI__sync_nand_and_fetch:
1291 case Builtin::BI__sync_nand_and_fetch_1:
1292 case Builtin::BI__sync_nand_and_fetch_2:
1293 case Builtin::BI__sync_nand_and_fetch_4:
1294 case Builtin::BI__sync_nand_and_fetch_8:
1295 case Builtin::BI__sync_nand_and_fetch_16:
1296 case Builtin::BI__sync_val_compare_and_swap:
1297 case Builtin::BI__sync_val_compare_and_swap_1:
1298 case Builtin::BI__sync_val_compare_and_swap_2:
1299 case Builtin::BI__sync_val_compare_and_swap_4:
1300 case Builtin::BI__sync_val_compare_and_swap_8:
1301 case Builtin::BI__sync_val_compare_and_swap_16:
1302 case Builtin::BI__sync_bool_compare_and_swap:
1303 case Builtin::BI__sync_bool_compare_and_swap_1:
1304 case Builtin::BI__sync_bool_compare_and_swap_2:
1305 case Builtin::BI__sync_bool_compare_and_swap_4:
1306 case Builtin::BI__sync_bool_compare_and_swap_8:
1307 case Builtin::BI__sync_bool_compare_and_swap_16:
1308 case Builtin::BI__sync_lock_test_and_set:
1309 case Builtin::BI__sync_lock_test_and_set_1:
1310 case Builtin::BI__sync_lock_test_and_set_2:
1311 case Builtin::BI__sync_lock_test_and_set_4:
1312 case Builtin::BI__sync_lock_test_and_set_8:
1313 case Builtin::BI__sync_lock_test_and_set_16:
1314 case Builtin::BI__sync_lock_release:
1315 case Builtin::BI__sync_lock_release_1:
1316 case Builtin::BI__sync_lock_release_2:
1317 case Builtin::BI__sync_lock_release_4:
1318 case Builtin::BI__sync_lock_release_8:
1319 case Builtin::BI__sync_lock_release_16:
1320 case Builtin::BI__sync_swap:
1321 case Builtin::BI__sync_swap_1:
1322 case Builtin::BI__sync_swap_2:
1323 case Builtin::BI__sync_swap_4:
1324 case Builtin::BI__sync_swap_8:
1325 case Builtin::BI__sync_swap_16:
1326 return SemaBuiltinAtomicOverloaded(TheCallResult);
1327 case Builtin::BI__sync_synchronize:
1331 case Builtin::BI__builtin_nontemporal_load:
1332 case Builtin::BI__builtin_nontemporal_store:
1333 return SemaBuiltinNontemporalOverloaded(TheCallResult);
1334 #define BUILTIN(ID, TYPE, ATTRS) 1335 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ 1336 case Builtin::BI##ID: \ 1337 return SemaAtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID); 1338 #include "clang/Basic/Builtins.def" 1339 case Builtin::BI__annotation:
1343 case Builtin::BI__builtin_annotation:
1347 case Builtin::BI__builtin_addressof:
1351 case Builtin::BI__builtin_add_overflow:
1352 case Builtin::BI__builtin_sub_overflow:
1353 case Builtin::BI__builtin_mul_overflow:
1357 case Builtin::BI__builtin_operator_new:
1358 case Builtin::BI__builtin_operator_delete: {
1359 bool IsDelete = BuiltinID == Builtin::BI__builtin_operator_delete;
1361 SemaBuiltinOperatorNewDeleteOverloaded(TheCallResult, IsDelete);
1363 CorrectDelayedTyposInExpr(TheCallResult.
get());
1366 case Builtin::BI__builtin_dump_struct: {
1376 << PtrArgType <<
"structure pointer" << 1 << 0 << 3 << 1 << PtrArgType
1377 <<
"structure pointer";
1385 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1386 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3 << 2
1387 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1391 const auto *FuncType =
1395 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1396 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3 << 2
1397 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1401 if (
const auto *FT = dyn_cast<FunctionProtoType>(FuncType)) {
1402 if (!FT->getNumParams()) {
1403 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1404 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1405 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1409 if (!FT->isVariadic() || FT->getReturnType() != Context.
IntTy ||
1412 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1413 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1414 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1422 case Builtin::BI__builtin_preserve_access_index:
1426 case Builtin::BI__builtin_call_with_static_chain:
1430 case Builtin::BI__exception_code:
1431 case Builtin::BI_exception_code:
1433 diag::err_seh___except_block))
1436 case Builtin::BI__exception_info:
1437 case Builtin::BI_exception_info:
1439 diag::err_seh___except_filter))
1442 case Builtin::BI__GetExceptionInfo:
1446 if (CheckCXXThrowOperand(
1455 case Builtin::BIread_pipe:
1456 case Builtin::BIwrite_pipe:
1462 case Builtin::BIreserve_read_pipe:
1463 case Builtin::BIreserve_write_pipe:
1464 case Builtin::BIwork_group_reserve_read_pipe:
1465 case Builtin::BIwork_group_reserve_write_pipe:
1469 case Builtin::BIsub_group_reserve_read_pipe:
1470 case Builtin::BIsub_group_reserve_write_pipe:
1475 case Builtin::BIcommit_read_pipe:
1476 case Builtin::BIcommit_write_pipe:
1477 case Builtin::BIwork_group_commit_read_pipe:
1478 case Builtin::BIwork_group_commit_write_pipe:
1482 case Builtin::BIsub_group_commit_read_pipe:
1483 case Builtin::BIsub_group_commit_write_pipe:
1488 case Builtin::BIget_pipe_num_packets:
1489 case Builtin::BIget_pipe_max_packets:
1493 case Builtin::BIto_global:
1494 case Builtin::BIto_local:
1495 case Builtin::BIto_private:
1500 case Builtin::BIenqueue_kernel:
1504 case Builtin::BIget_kernel_work_group_size:
1505 case Builtin::BIget_kernel_preferred_work_group_size_multiple:
1509 case Builtin::BIget_kernel_max_sub_group_size_for_ndrange:
1510 case Builtin::BIget_kernel_sub_group_count_for_ndrange:
1514 case Builtin::BI__builtin_os_log_format:
1515 case Builtin::BI__builtin_os_log_format_buffer_size:
1516 if (SemaBuiltinOSLogFormat(TheCall))
1525 case llvm::Triple::arm:
1526 case llvm::Triple::armeb:
1527 case llvm::Triple::thumb:
1528 case llvm::Triple::thumbeb:
1529 if (CheckARMBuiltinFunctionCall(BuiltinID, TheCall))
1532 case llvm::Triple::aarch64:
1533 case llvm::Triple::aarch64_be:
1534 if (CheckAArch64BuiltinFunctionCall(BuiltinID, TheCall))
1537 case llvm::Triple::hexagon:
1538 if (CheckHexagonBuiltinFunctionCall(BuiltinID, TheCall))
1541 case llvm::Triple::mips:
1542 case llvm::Triple::mipsel:
1543 case llvm::Triple::mips64:
1544 case llvm::Triple::mips64el:
1545 if (CheckMipsBuiltinFunctionCall(BuiltinID, TheCall))
1548 case llvm::Triple::systemz:
1549 if (CheckSystemZBuiltinFunctionCall(BuiltinID, TheCall))
1552 case llvm::Triple::x86:
1553 case llvm::Triple::x86_64:
1554 if (CheckX86BuiltinFunctionCall(BuiltinID, TheCall))
1557 case llvm::Triple::ppc:
1558 case llvm::Triple::ppc64:
1559 case llvm::Triple::ppc64le:
1560 if (CheckPPCBuiltinFunctionCall(BuiltinID, TheCall))
1568 return TheCallResult;
1572 static unsigned RFT(
unsigned t,
bool shift =
false,
bool ForceQuad =
false) {
1574 int IsQuad = ForceQuad ?
true : Type.
isQuad();
1578 return shift ? 7 : (8 << IsQuad) - 1;
1581 return shift ? 15 : (4 << IsQuad) - 1;
1583 return shift ? 31 : (2 << IsQuad) - 1;
1586 return shift ? 63 : (1 << IsQuad) - 1;
1588 return shift ? 127 : (1 << IsQuad) - 1;
1590 assert(!shift &&
"cannot shift float types!");
1591 return (4 << IsQuad) - 1;
1593 assert(!shift &&
"cannot shift float types!");
1594 return (2 << IsQuad) - 1;
1596 assert(!shift &&
"cannot shift float types!");
1597 return (1 << IsQuad) - 1;
1599 llvm_unreachable(
"Invalid NeonTypeFlag!");
1606 bool IsPolyUnsigned,
bool IsInt64Long) {
1638 llvm_unreachable(
"Invalid NeonTypeFlag!");
1641 bool Sema::CheckNeonBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
1642 llvm::APSInt Result;
1646 bool HasConstPtr =
false;
1647 switch (BuiltinID) {
1648 #define GET_NEON_OVERLOAD_CHECK 1649 #include "clang/Basic/arm_neon.inc" 1650 #include "clang/Basic/arm_fp16.inc" 1651 #undef GET_NEON_OVERLOAD_CHECK 1658 if (SemaBuiltinConstantArg(TheCall, ImmArg, Result))
1661 TV = Result.getLimitedValue(64);
1662 if ((TV > 63) || (mask & (1ULL << TV)) == 0)
1667 if (PtrArgNum >= 0) {
1671 Arg = ICE->getSubExpr();
1672 ExprResult RHS = DefaultFunctionArrayLvalueConversion(Arg);
1676 bool IsPolyUnsigned = Arch == llvm::Triple::aarch64 ||
1677 Arch == llvm::Triple::aarch64_be;
1685 AssignConvertType ConvTy;
1686 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
1689 if (DiagnoseAssignmentResult(ConvTy, Arg->
getBeginLoc(), LHSTy, RHSTy,
1690 RHS.
get(), AA_Assigning))
1696 unsigned i = 0, l = 0, u = 0;
1697 switch (BuiltinID) {
1700 #define GET_NEON_IMMEDIATE_CHECK 1701 #include "clang/Basic/arm_neon.inc" 1702 #include "clang/Basic/arm_fp16.inc" 1703 #undef GET_NEON_IMMEDIATE_CHECK 1706 return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
1709 bool Sema::CheckARMBuiltinExclusiveCall(
unsigned BuiltinID,
CallExpr *TheCall,
1710 unsigned MaxWidth) {
1711 assert((BuiltinID == ARM::BI__builtin_arm_ldrex ||
1712 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1713 BuiltinID == ARM::BI__builtin_arm_strex ||
1714 BuiltinID == ARM::BI__builtin_arm_stlex ||
1715 BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1716 BuiltinID == AArch64::BI__builtin_arm_ldaex ||
1717 BuiltinID == AArch64::BI__builtin_arm_strex ||
1718 BuiltinID == AArch64::BI__builtin_arm_stlex) &&
1719 "unexpected ARM builtin");
1720 bool IsLdrex = BuiltinID == ARM::BI__builtin_arm_ldrex ||
1721 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1722 BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1723 BuiltinID == AArch64::BI__builtin_arm_ldaex;
1735 Expr *PointerArg = TheCall->
getArg(IsLdrex ? 0 : 1);
1736 ExprResult PointerArgRes = DefaultFunctionArrayLvalueConversion(PointerArg);
1739 PointerArg = PointerArgRes.
get();
1759 CastNeeded = CK_BitCast;
1760 Diag(DRE->
getBeginLoc(), diag::ext_typecheck_convert_discards_qualifiers)
1767 PointerArgRes = ImpCastExprToType(PointerArg, AddrType, CastNeeded);
1770 PointerArg = PointerArgRes.
get();
1772 TheCall->
setArg(IsLdrex ? 0 : 1, PointerArg);
1777 Diag(DRE->
getBeginLoc(), diag::err_atomic_builtin_must_be_pointer_intfltptr)
1784 assert(MaxWidth == 64 &&
"Diagnostic unexpectedly inaccurate");
1785 Diag(DRE->
getBeginLoc(), diag::err_atomic_exclusive_builtin_pointer_size)
1812 Context, ValType,
false);
1813 ValArg = PerformCopyInitialization(Entity,
SourceLocation(), ValArg);
1824 bool Sema::CheckARMBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
1825 if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
1826 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1827 BuiltinID == ARM::BI__builtin_arm_strex ||
1828 BuiltinID == ARM::BI__builtin_arm_stlex) {
1829 return CheckARMBuiltinExclusiveCall(BuiltinID, TheCall, 64);
1832 if (BuiltinID == ARM::BI__builtin_arm_prefetch) {
1833 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
1834 SemaBuiltinConstantArgRange(TheCall, 2, 0, 1);
1837 if (BuiltinID == ARM::BI__builtin_arm_rsr64 ||
1838 BuiltinID == ARM::BI__builtin_arm_wsr64)
1839 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 3,
false);
1841 if (BuiltinID == ARM::BI__builtin_arm_rsr ||
1842 BuiltinID == ARM::BI__builtin_arm_rsrp ||
1843 BuiltinID == ARM::BI__builtin_arm_wsr ||
1844 BuiltinID == ARM::BI__builtin_arm_wsrp)
1845 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1847 if (CheckNeonBuiltinFunctionCall(BuiltinID, TheCall))
1853 switch (BuiltinID) {
1854 default:
return false;
1855 case ARM::BI__builtin_arm_ssat:
1856 return SemaBuiltinConstantArgRange(TheCall, 1, 1, 32);
1857 case ARM::BI__builtin_arm_usat:
1858 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 31);
1859 case ARM::BI__builtin_arm_ssat16:
1860 return SemaBuiltinConstantArgRange(TheCall, 1, 1, 16);
1861 case ARM::BI__builtin_arm_usat16:
1862 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
1863 case ARM::BI__builtin_arm_vcvtr_f:
1864 case ARM::BI__builtin_arm_vcvtr_d:
1865 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
1866 case ARM::BI__builtin_arm_dmb:
1867 case ARM::BI__builtin_arm_dsb:
1868 case ARM::BI__builtin_arm_isb:
1869 case ARM::BI__builtin_arm_dbg:
1870 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 15);
1874 bool Sema::CheckAArch64BuiltinFunctionCall(
unsigned BuiltinID,
1876 if (BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1877 BuiltinID == AArch64::BI__builtin_arm_ldaex ||
1878 BuiltinID == AArch64::BI__builtin_arm_strex ||
1879 BuiltinID == AArch64::BI__builtin_arm_stlex) {
1880 return CheckARMBuiltinExclusiveCall(BuiltinID, TheCall, 128);
1883 if (BuiltinID == AArch64::BI__builtin_arm_prefetch) {
1884 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
1885 SemaBuiltinConstantArgRange(TheCall, 2, 0, 2) ||
1886 SemaBuiltinConstantArgRange(TheCall, 3, 0, 1) ||
1887 SemaBuiltinConstantArgRange(TheCall, 4, 0, 1);
1890 if (BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
1891 BuiltinID == AArch64::BI__builtin_arm_wsr64)
1892 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1895 if (BuiltinID == AArch64::BI__builtin_arm_irg ||
1896 BuiltinID == AArch64::BI__builtin_arm_addg ||
1897 BuiltinID == AArch64::BI__builtin_arm_gmi ||
1898 BuiltinID == AArch64::BI__builtin_arm_ldg ||
1899 BuiltinID == AArch64::BI__builtin_arm_stg ||
1900 BuiltinID == AArch64::BI__builtin_arm_subp) {
1901 return SemaBuiltinARMMemoryTaggingCall(BuiltinID, TheCall);
1904 if (BuiltinID == AArch64::BI__builtin_arm_rsr ||
1905 BuiltinID == AArch64::BI__builtin_arm_rsrp ||
1906 BuiltinID == AArch64::BI__builtin_arm_wsr ||
1907 BuiltinID == AArch64::BI__builtin_arm_wsrp)
1908 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1913 if (BuiltinID == AArch64::BI_ReadStatusReg ||
1914 BuiltinID == AArch64::BI_WriteStatusReg)
1915 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 0x7fff);
1917 if (BuiltinID == AArch64::BI__getReg)
1918 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31);
1920 if (CheckNeonBuiltinFunctionCall(BuiltinID, TheCall))
1925 unsigned i = 0, l = 0, u = 0;
1926 switch (BuiltinID) {
1927 default:
return false;
1928 case AArch64::BI__builtin_arm_dmb:
1929 case AArch64::BI__builtin_arm_dsb:
1930 case AArch64::BI__builtin_arm_isb: l = 0; u = 15;
break;
1933 return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
1936 bool Sema::CheckHexagonBuiltinCpu(
unsigned BuiltinID,
CallExpr *TheCall) {
1937 struct BuiltinAndString {
1942 static BuiltinAndString ValidCPU[] = {
1943 { Hexagon::BI__builtin_HEXAGON_A6_vcmpbeq_notany,
"v65,v66" },
1944 { Hexagon::BI__builtin_HEXAGON_A6_vminub_RdP,
"v62,v65,v66" },
1945 { Hexagon::BI__builtin_HEXAGON_F2_dfadd,
"v66" },
1946 { Hexagon::BI__builtin_HEXAGON_F2_dfsub,
"v66" },
1947 { Hexagon::BI__builtin_HEXAGON_M2_mnaci,
"v66" },
1948 { Hexagon::BI__builtin_HEXAGON_M6_vabsdiffb,
"v62,v65,v66" },
1949 { Hexagon::BI__builtin_HEXAGON_M6_vabsdiffub,
"v62,v65,v66" },
1950 { Hexagon::BI__builtin_HEXAGON_S2_mask,
"v66" },
1951 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc,
"v60,v62,v65,v66" },
1952 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and,
"v60,v62,v65,v66" },
1953 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac,
"v60,v62,v65,v66" },
1954 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or,
"v60,v62,v65,v66" },
1955 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p,
"v60,v62,v65,v66" },
1956 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc,
"v60,v62,v65,v66" },
1957 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc,
"v60,v62,v65,v66" },
1958 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and,
"v60,v62,v65,v66" },
1959 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac,
"v60,v62,v65,v66" },
1960 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or,
"v60,v62,v65,v66" },
1961 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r,
"v60,v62,v65,v66" },
1962 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc,
"v60,v62,v65,v66" },
1963 { Hexagon::BI__builtin_HEXAGON_S6_vsplatrbp,
"v62,v65,v66" },
1964 { Hexagon::BI__builtin_HEXAGON_S6_vtrunehb_ppp,
"v62,v65,v66" },
1965 { Hexagon::BI__builtin_HEXAGON_S6_vtrunohb_ppp,
"v62,v65,v66" },
1968 static BuiltinAndString ValidHVX[] = {
1969 { Hexagon::BI__builtin_HEXAGON_V6_hi,
"v60,v62,v65,v66" },
1970 { Hexagon::BI__builtin_HEXAGON_V6_hi_128B,
"v60,v62,v65,v66" },
1971 { Hexagon::BI__builtin_HEXAGON_V6_lo,
"v60,v62,v65,v66" },
1972 { Hexagon::BI__builtin_HEXAGON_V6_lo_128B,
"v60,v62,v65,v66" },
1973 { Hexagon::BI__builtin_HEXAGON_V6_extractw,
"v60,v62,v65,v66" },
1974 { Hexagon::BI__builtin_HEXAGON_V6_extractw_128B,
"v60,v62,v65,v66" },
1975 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatb,
"v62,v65,v66" },
1976 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatb_128B,
"v62,v65,v66" },
1977 { Hexagon::BI__builtin_HEXAGON_V6_lvsplath,
"v62,v65,v66" },
1978 { Hexagon::BI__builtin_HEXAGON_V6_lvsplath_128B,
"v62,v65,v66" },
1979 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatw,
"v60,v62,v65,v66" },
1980 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatw_128B,
"v60,v62,v65,v66" },
1981 { Hexagon::BI__builtin_HEXAGON_V6_pred_and,
"v60,v62,v65,v66" },
1982 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_128B,
"v60,v62,v65,v66" },
1983 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_n,
"v60,v62,v65,v66" },
1984 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_n_128B,
"v60,v62,v65,v66" },
1985 { Hexagon::BI__builtin_HEXAGON_V6_pred_not,
"v60,v62,v65,v66" },
1986 { Hexagon::BI__builtin_HEXAGON_V6_pred_not_128B,
"v60,v62,v65,v66" },
1987 { Hexagon::BI__builtin_HEXAGON_V6_pred_or,
"v60,v62,v65,v66" },
1988 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_128B,
"v60,v62,v65,v66" },
1989 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_n,
"v60,v62,v65,v66" },
1990 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_n_128B,
"v60,v62,v65,v66" },
1991 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2,
"v60,v62,v65,v66" },
1992 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2_128B,
"v60,v62,v65,v66" },
1993 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2v2,
"v62,v65,v66" },
1994 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2v2_128B,
"v62,v65,v66" },
1995 { Hexagon::BI__builtin_HEXAGON_V6_pred_xor,
"v60,v62,v65,v66" },
1996 { Hexagon::BI__builtin_HEXAGON_V6_pred_xor_128B,
"v60,v62,v65,v66" },
1997 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqh,
"v62,v65,v66" },
1998 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqh_128B,
"v62,v65,v66" },
1999 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqw,
"v62,v65,v66" },
2000 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqw_128B,
"v62,v65,v66" },
2001 { Hexagon::BI__builtin_HEXAGON_V6_vabsb,
"v65,v66" },
2002 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_128B,
"v65,v66" },
2003 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_sat,
"v65,v66" },
2004 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_sat_128B,
"v65,v66" },
2005 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffh,
"v60,v62,v65,v66" },
2006 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffh_128B,
"v60,v62,v65,v66" },
2007 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffub,
"v60,v62,v65,v66" },
2008 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffub_128B,
"v60,v62,v65,v66" },
2009 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffuh,
"v60,v62,v65,v66" },
2010 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffuh_128B,
"v60,v62,v65,v66" },
2011 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffw,
"v60,v62,v65,v66" },
2012 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffw_128B,
"v60,v62,v65,v66" },
2013 { Hexagon::BI__builtin_HEXAGON_V6_vabsh,
"v60,v62,v65,v66" },
2014 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_128B,
"v60,v62,v65,v66" },
2015 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_sat,
"v60,v62,v65,v66" },
2016 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_sat_128B,
"v60,v62,v65,v66" },
2017 { Hexagon::BI__builtin_HEXAGON_V6_vabsw,
"v60,v62,v65,v66" },
2018 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_128B,
"v60,v62,v65,v66" },
2019 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_sat,
"v60,v62,v65,v66" },
2020 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_sat_128B,
"v60,v62,v65,v66" },
2021 { Hexagon::BI__builtin_HEXAGON_V6_vaddb,
"v60,v62,v65,v66" },
2022 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_128B,
"v60,v62,v65,v66" },
2023 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_dv,
"v60,v62,v65,v66" },
2024 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_dv_128B,
"v60,v62,v65,v66" },
2025 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat,
"v62,v65,v66" },
2026 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_128B,
"v62,v65,v66" },
2027 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_dv,
"v62,v65,v66" },
2028 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_dv_128B,
"v62,v65,v66" },
2029 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarry,
"v62,v65,v66" },
2030 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarry_128B,
"v62,v65,v66" },
2031 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarrysat,
"v66" },
2032 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarrysat_128B,
"v66" },
2033 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbh,
"v62,v65,v66" },
2034 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbh_128B,
"v62,v65,v66" },
2035 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbw,
"v62,v65,v66" },
2036 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbw_128B,
"v62,v65,v66" },
2037 { Hexagon::BI__builtin_HEXAGON_V6_vaddh,
"v60,v62,v65,v66" },
2038 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_128B,
"v60,v62,v65,v66" },
2039 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_dv,
"v60,v62,v65,v66" },
2040 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_dv_128B,
"v60,v62,v65,v66" },
2041 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat,
"v60,v62,v65,v66" },
2042 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_128B,
"v60,v62,v65,v66" },
2043 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_dv,
"v60,v62,v65,v66" },
2044 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_dv_128B,
"v60,v62,v65,v66" },
2045 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw,
"v60,v62,v65,v66" },
2046 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_128B,
"v60,v62,v65,v66" },
2047 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_acc,
"v62,v65,v66" },
2048 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_acc_128B,
"v62,v65,v66" },
2049 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh,
"v60,v62,v65,v66" },
2050 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_128B,
"v60,v62,v65,v66" },
2051 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_acc,
"v62,v65,v66" },
2052 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_acc_128B,
"v62,v65,v66" },
2053 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat,
"v60,v62,v65,v66" },
2054 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_128B,
"v60,v62,v65,v66" },
2055 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_dv,
"v60,v62,v65,v66" },
2056 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_dv_128B,
"v60,v62,v65,v66" },
2057 { Hexagon::BI__builtin_HEXAGON_V6_vaddububb_sat,
"v62,v65,v66" },
2058 { Hexagon::BI__builtin_HEXAGON_V6_vaddububb_sat_128B,
"v62,v65,v66" },
2059 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat,
"v60,v62,v65,v66" },
2060 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_128B,
"v60,v62,v65,v66" },
2061 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_dv,
"v60,v62,v65,v66" },
2062 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_dv_128B,
"v60,v62,v65,v66" },
2063 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw,
"v60,v62,v65,v66" },
2064 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_128B,
"v60,v62,v65,v66" },
2065 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_acc,
"v62,v65,v66" },
2066 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_acc_128B,
"v62,v65,v66" },
2067 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat,
"v62,v65,v66" },
2068 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_128B,
"v62,v65,v66" },
2069 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_dv,
"v62,v65,v66" },
2070 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_dv_128B,
"v62,v65,v66" },
2071 { Hexagon::BI__builtin_HEXAGON_V6_vaddw,
"v60,v62,v65,v66" },
2072 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_128B,
"v60,v62,v65,v66" },
2073 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_dv,
"v60,v62,v65,v66" },
2074 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_dv_128B,
"v60,v62,v65,v66" },
2075 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat,
"v60,v62,v65,v66" },
2076 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_128B,
"v60,v62,v65,v66" },
2077 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_dv,
"v60,v62,v65,v66" },
2078 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_dv_128B,
"v60,v62,v65,v66" },
2079 { Hexagon::BI__builtin_HEXAGON_V6_valignb,
"v60,v62,v65,v66" },
2080 { Hexagon::BI__builtin_HEXAGON_V6_valignb_128B,
"v60,v62,v65,v66" },
2081 { Hexagon::BI__builtin_HEXAGON_V6_valignbi,
"v60,v62,v65,v66" },
2082 { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B,
"v60,v62,v65,v66" },
2083 { Hexagon::BI__builtin_HEXAGON_V6_vand,
"v60,v62,v65,v66" },
2084 { Hexagon::BI__builtin_HEXAGON_V6_vand_128B,
"v60,v62,v65,v66" },
2085 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt,
"v62,v65,v66" },
2086 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_128B,
"v62,v65,v66" },
2087 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_acc,
"v62,v65,v66" },
2088 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_acc_128B,
"v62,v65,v66" },
2089 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt,
"v60,v62,v65,v66" },
2090 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_128B,
"v60,v62,v65,v66" },
2091 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_acc,
"v60,v62,v65,v66" },
2092 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_acc_128B,
"v60,v62,v65,v66" },
2093 { Hexagon::BI__builtin_HEXAGON_V6_vandvnqv,
"v62,v65,v66" },
2094 { Hexagon::BI__builtin_HEXAGON_V6_vandvnqv_128B,
"v62,v65,v66" },
2095 { Hexagon::BI__builtin_HEXAGON_V6_vandvqv,
"v62,v65,v66" },
2096 { Hexagon::BI__builtin_HEXAGON_V6_vandvqv_128B,
"v62,v65,v66" },
2097 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt,
"v60,v62,v65,v66" },
2098 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_128B,
"v60,v62,v65,v66" },
2099 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_acc,
"v60,v62,v65,v66" },
2100 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_acc_128B,
"v60,v62,v65,v66" },
2101 { Hexagon::BI__builtin_HEXAGON_V6_vaslh,
"v60,v62,v65,v66" },
2102 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_128B,
"v60,v62,v65,v66" },
2103 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_acc,
"v65,v66" },
2104 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_acc_128B,
"v65,v66" },
2105 { Hexagon::BI__builtin_HEXAGON_V6_vaslhv,
"v60,v62,v65,v66" },
2106 { Hexagon::BI__builtin_HEXAGON_V6_vaslhv_128B,
"v60,v62,v65,v66" },
2107 { Hexagon::BI__builtin_HEXAGON_V6_vaslw,
"v60,v62,v65,v66" },
2108 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_128B,
"v60,v62,v65,v66" },
2109 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_acc,
"v60,v62,v65,v66" },
2110 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_acc_128B,
"v60,v62,v65,v66" },
2111 { Hexagon::BI__builtin_HEXAGON_V6_vaslwv,
"v60,v62,v65,v66" },
2112 { Hexagon::BI__builtin_HEXAGON_V6_vaslwv_128B,
"v60,v62,v65,v66" },
2113 { Hexagon::BI__builtin_HEXAGON_V6_vasrh,
"v60,v62,v65,v66" },
2114 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_128B,
"v60,v62,v65,v66" },
2115 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_acc,
"v65,v66" },
2116 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_acc_128B,
"v65,v66" },
2117 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbrndsat,
"v60,v62,v65,v66" },
2118 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbrndsat_128B,
"v60,v62,v65,v66" },
2119 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbsat,
"v62,v65,v66" },
2120 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbsat_128B,
"v62,v65,v66" },
2121 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubrndsat,
"v60,v62,v65,v66" },
2122 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubrndsat_128B,
"v60,v62,v65,v66" },
2123 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubsat,
"v60,v62,v65,v66" },
2124 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubsat_128B,
"v60,v62,v65,v66" },
2125 { Hexagon::BI__builtin_HEXAGON_V6_vasrhv,
"v60,v62,v65,v66" },
2126 { Hexagon::BI__builtin_HEXAGON_V6_vasrhv_128B,
"v60,v62,v65,v66" },
2127 { Hexagon::BI__builtin_HEXAGON_V6_vasr_into,
"v66" },
2128 { Hexagon::BI__builtin_HEXAGON_V6_vasr_into_128B,
"v66" },
2129 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubrndsat,
"v65,v66" },
2130 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubrndsat_128B,
"v65,v66" },
2131 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubsat,
"v65,v66" },
2132 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubsat_128B,
"v65,v66" },
2133 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhrndsat,
"v62,v65,v66" },
2134 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhrndsat_128B,
"v62,v65,v66" },
2135 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhsat,
"v65,v66" },
2136 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhsat_128B,
"v65,v66" },
2137 { Hexagon::BI__builtin_HEXAGON_V6_vasrw,
"v60,v62,v65,v66" },
2138 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_128B,
"v60,v62,v65,v66" },
2139 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_acc,
"v60,v62,v65,v66" },
2140 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_acc_128B,
"v60,v62,v65,v66" },
2141 { Hexagon::BI__builtin_HEXAGON_V6_vasrwh,
"v60,v62,v65,v66" },
2142 { Hexagon::BI__builtin_HEXAGON_V6_vasrwh_128B,
"v60,v62,v65,v66" },
2143 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhrndsat,
"v60,v62,v65,v66" },
2144 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhrndsat_128B,
"v60,v62,v65,v66" },
2145 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhsat,
"v60,v62,v65,v66" },
2146 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhsat_128B,
"v60,v62,v65,v66" },
2147 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhrndsat,
"v62,v65,v66" },
2148 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhrndsat_128B,
"v62,v65,v66" },
2149 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhsat,
"v60,v62,v65,v66" },
2150 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhsat_128B,
"v60,v62,v65,v66" },
2151 { Hexagon::BI__builtin_HEXAGON_V6_vasrwv,
"v60,v62,v65,v66" },
2152 { Hexagon::BI__builtin_HEXAGON_V6_vasrwv_128B,
"v60,v62,v65,v66" },
2153 { Hexagon::BI__builtin_HEXAGON_V6_vassign,
"v60,v62,v65,v66" },
2154 { Hexagon::BI__builtin_HEXAGON_V6_vassign_128B,
"v60,v62,v65,v66" },
2155 { Hexagon::BI__builtin_HEXAGON_V6_vassignp,
"v60,v62,v65,v66" },
2156 { Hexagon::BI__builtin_HEXAGON_V6_vassignp_128B,
"v60,v62,v65,v66" },
2157 { Hexagon::BI__builtin_HEXAGON_V6_vavgb,
"v65,v66" },
2158 { Hexagon::BI__builtin_HEXAGON_V6_vavgb_128B,
"v65,v66" },
2159 { Hexagon::BI__builtin_HEXAGON_V6_vavgbrnd,
"v65,v66" },
2160 { Hexagon::BI__builtin_HEXAGON_V6_vavgbrnd_128B,
"v65,v66" },
2161 { Hexagon::BI__builtin_HEXAGON_V6_vavgh,
"v60,v62,v65,v66" },
2162 { Hexagon::BI__builtin_HEXAGON_V6_vavgh_128B,
"v60,v62,v65,v66" },
2163 { Hexagon::BI__builtin_HEXAGON_V6_vavghrnd,
"v60,v62,v65,v66" },
2164 { Hexagon::BI__builtin_HEXAGON_V6_vavghrnd_128B,
"v60,v62,v65,v66" },
2165 { Hexagon::BI__builtin_HEXAGON_V6_vavgub,
"v60,v62,v65,v66" },
2166 { Hexagon::BI__builtin_HEXAGON_V6_vavgub_128B,
"v60,v62,v65,v66" },
2167 { Hexagon::BI__builtin_HEXAGON_V6_vavgubrnd,
"v60,v62,v65,v66" },
2168 { Hexagon::BI__builtin_HEXAGON_V6_vavgubrnd_128B,
"v60,v62,v65,v66" },
2169 { Hexagon::BI__builtin_HEXAGON_V6_vavguh,
"v60,v62,v65,v66" },
2170 { Hexagon::BI__builtin_HEXAGON_V6_vavguh_128B,
"v60,v62,v65,v66" },
2171 { Hexagon::BI__builtin_HEXAGON_V6_vavguhrnd,
"v60,v62,v65,v66" },
2172 { Hexagon::BI__builtin_HEXAGON_V6_vavguhrnd_128B,
"v60,v62,v65,v66" },
2173 { Hexagon::BI__builtin_HEXAGON_V6_vavguw,
"v65,v66" },
2174 { Hexagon::BI__builtin_HEXAGON_V6_vavguw_128B,
"v65,v66" },
2175 { Hexagon::BI__builtin_HEXAGON_V6_vavguwrnd,
"v65,v66" },
2176 { Hexagon::BI__builtin_HEXAGON_V6_vavguwrnd_128B,
"v65,v66" },
2177 { Hexagon::BI__builtin_HEXAGON_V6_vavgw,
"v60,v62,v65,v66" },
2178 { Hexagon::BI__builtin_HEXAGON_V6_vavgw_128B,
"v60,v62,v65,v66" },
2179 { Hexagon::BI__builtin_HEXAGON_V6_vavgwrnd,
"v60,v62,v65,v66" },
2180 { Hexagon::BI__builtin_HEXAGON_V6_vavgwrnd_128B,
"v60,v62,v65,v66" },
2181 { Hexagon::BI__builtin_HEXAGON_V6_vcl0h,
"v60,v62,v65,v66" },
2182 { Hexagon::BI__builtin_HEXAGON_V6_vcl0h_128B,
"v60,v62,v65,v66" },
2183 { Hexagon::BI__builtin_HEXAGON_V6_vcl0w,
"v60,v62,v65,v66" },
2184 { Hexagon::BI__builtin_HEXAGON_V6_vcl0w_128B,
"v60,v62,v65,v66" },
2185 { Hexagon::BI__builtin_HEXAGON_V6_vcombine,
"v60,v62,v65,v66" },
2186 { Hexagon::BI__builtin_HEXAGON_V6_vcombine_128B,
"v60,v62,v65,v66" },
2187 { Hexagon::BI__builtin_HEXAGON_V6_vd0,
"v60,v62,v65,v66" },
2188 { Hexagon::BI__builtin_HEXAGON_V6_vd0_128B,
"v60,v62,v65,v66" },
2189 { Hexagon::BI__builtin_HEXAGON_V6_vdd0,
"v65,v66" },
2190 { Hexagon::BI__builtin_HEXAGON_V6_vdd0_128B,
"v65,v66" },
2191 { Hexagon::BI__builtin_HEXAGON_V6_vdealb,
"v60,v62,v65,v66" },
2192 { Hexagon::BI__builtin_HEXAGON_V6_vdealb_128B,
"v60,v62,v65,v66" },
2193 { Hexagon::BI__builtin_HEXAGON_V6_vdealb4w,
"v60,v62,v65,v66" },
2194 { Hexagon::BI__builtin_HEXAGON_V6_vdealb4w_128B,
"v60,v62,v65,v66" },
2195 { Hexagon::BI__builtin_HEXAGON_V6_vdealh,
"v60,v62,v65,v66" },
2196 { Hexagon::BI__builtin_HEXAGON_V6_vdealh_128B,
"v60,v62,v65,v66" },
2197 { Hexagon::BI__builtin_HEXAGON_V6_vdealvdd,
"v60,v62,v65,v66" },
2198 { Hexagon::BI__builtin_HEXAGON_V6_vdealvdd_128B,
"v60,v62,v65,v66" },
2199 { Hexagon::BI__builtin_HEXAGON_V6_vdelta,
"v60,v62,v65,v66" },
2200 { Hexagon::BI__builtin_HEXAGON_V6_vdelta_128B,
"v60,v62,v65,v66" },
2201 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus,
"v60,v62,v65,v66" },
2202 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_128B,
"v60,v62,v65,v66" },
2203 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_acc,
"v60,v62,v65,v66" },
2204 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_acc_128B,
"v60,v62,v65,v66" },
2205 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv,
"v60,v62,v65,v66" },
2206 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_128B,
"v60,v62,v65,v66" },
2207 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_acc,
"v60,v62,v65,v66" },
2208 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_acc_128B,
"v60,v62,v65,v66" },
2209 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb,
"v60,v62,v65,v66" },
2210 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_128B,
"v60,v62,v65,v66" },
2211 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_acc,
"v60,v62,v65,v66" },
2212 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_acc_128B,
"v60,v62,v65,v66" },
2213 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv,
"v60,v62,v65,v66" },
2214 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_128B,
"v60,v62,v65,v66" },
2215 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_acc,
"v60,v62,v65,v66" },
2216 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_acc_128B,
"v60,v62,v65,v66" },
2217 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat,
"v60,v62,v65,v66" },
2218 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_128B,
"v60,v62,v65,v66" },
2219 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_acc,
"v60,v62,v65,v66" },
2220 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_acc_128B,
"v60,v62,v65,v66" },
2221 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat,
"v60,v62,v65,v66" },
2222 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_128B,
"v60,v62,v65,v66" },
2223 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_acc,
"v60,v62,v65,v66" },
2224 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_acc_128B,
"v60,v62,v65,v66" },
2225 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat,
"v60,v62,v65,v66" },
2226 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_128B,
"v60,v62,v65,v66" },
2227 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_acc,
"v60,v62,v65,v66" },
2228 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_acc_128B,
"v60,v62,v65,v66" },
2229 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat,
"v60,v62,v65,v66" },
2230 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_128B,
"v60,v62,v65,v66" },
2231 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_acc,
"v60,v62,v65,v66" },
2232 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_acc_128B,
"v60,v62,v65,v66" },
2233 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat,
"v60,v62,v65,v66" },
2234 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_128B,
"v60,v62,v65,v66" },
2235 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_acc,
"v60,v62,v65,v66" },
2236 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_acc_128B,
"v60,v62,v65,v66" },
2237 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh,
"v60,v62,v65,v66" },
2238 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_128B,
"v60,v62,v65,v66" },
2239 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_acc,
"v60,v62,v65,v66" },
2240 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_acc_128B,
"v60,v62,v65,v66" },
2241 { Hexagon::BI__builtin_HEXAGON_V6_veqb,
"v60,v62,v65,v66" },
2242 { Hexagon::BI__builtin_HEXAGON_V6_veqb_128B,
"v60,v62,v65,v66" },
2243 { Hexagon::BI__builtin_HEXAGON_V6_veqb_and,
"v60,v62,v65,v66" },
2244 { Hexagon::BI__builtin_HEXAGON_V6_veqb_and_128B,
"v60,v62,v65,v66" },
2245 { Hexagon::BI__builtin_HEXAGON_V6_veqb_or,
"v60,v62,v65,v66" },
2246 { Hexagon::BI__builtin_HEXAGON_V6_veqb_or_128B,
"v60,v62,v65,v66" },
2247 { Hexagon::BI__builtin_HEXAGON_V6_veqb_xor,
"v60,v62,v65,v66" },
2248 { Hexagon::BI__builtin_HEXAGON_V6_veqb_xor_128B,
"v60,v62,v65,v66" },
2249 { Hexagon::BI__builtin_HEXAGON_V6_veqh,
"v60,v62,v65,v66" },
2250 { Hexagon::BI__builtin_HEXAGON_V6_veqh_128B,
"v60,v62,v65,v66" },
2251 { Hexagon::BI__builtin_HEXAGON_V6_veqh_and,
"v60,v62,v65,v66" },
2252 { Hexagon::BI__builtin_HEXAGON_V6_veqh_and_128B,
"v60,v62,v65,v66" },
2253 { Hexagon::BI__builtin_HEXAGON_V6_veqh_or,
"v60,v62,v65,v66" },
2254 { Hexagon::BI__builtin_HEXAGON_V6_veqh_or_128B,
"v60,v62,v65,v66" },
2255 { Hexagon::BI__builtin_HEXAGON_V6_veqh_xor,
"v60,v62,v65,v66" },
2256 { Hexagon::BI__builtin_HEXAGON_V6_veqh_xor_128B,
"v60,v62,v65,v66" },
2257 { Hexagon::BI__builtin_HEXAGON_V6_veqw,
"v60,v62,v65,v66" },
2258 { Hexagon::BI__builtin_HEXAGON_V6_veqw_128B,
"v60,v62,v65,v66" },
2259 { Hexagon::BI__builtin_HEXAGON_V6_veqw_and,
"v60,v62,v65,v66" },
2260 { Hexagon::BI__builtin_HEXAGON_V6_veqw_and_128B,
"v60,v62,v65,v66" },
2261 { Hexagon::BI__builtin_HEXAGON_V6_veqw_or,
"v60,v62,v65,v66" },
2262 { Hexagon::BI__builtin_HEXAGON_V6_veqw_or_128B,
"v60,v62,v65,v66" },
2263 { Hexagon::BI__builtin_HEXAGON_V6_veqw_xor,
"v60,v62,v65,v66" },
2264 { Hexagon::BI__builtin_HEXAGON_V6_veqw_xor_128B,
"v60,v62,v65,v66" },
2265 { Hexagon::BI__builtin_HEXAGON_V6_vgtb,
"v60,v62,v65,v66" },
2266 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_128B,
"v60,v62,v65,v66" },
2267 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_and,
"v60,v62,v65,v66" },
2268 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_and_128B,
"v60,v62,v65,v66" },
2269 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_or,
"v60,v62,v65,v66" },
2270 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_or_128B,
"v60,v62,v65,v66" },
2271 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_xor,
"v60,v62,v65,v66" },
2272 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_xor_128B,
"v60,v62,v65,v66" },
2273 { Hexagon::BI__builtin_HEXAGON_V6_vgth,
"v60,v62,v65,v66" },
2274 { Hexagon::BI__builtin_HEXAGON_V6_vgth_128B,
"v60,v62,v65,v66" },
2275 { Hexagon::BI__builtin_HEXAGON_V6_vgth_and,
"v60,v62,v65,v66" },
2276 { Hexagon::BI__builtin_HEXAGON_V6_vgth_and_128B,
"v60,v62,v65,v66" },
2277 { Hexagon::BI__builtin_HEXAGON_V6_vgth_or,
"v60,v62,v65,v66" },
2278 { Hexagon::BI__builtin_HEXAGON_V6_vgth_or_128B,
"v60,v62,v65,v66" },
2279 { Hexagon::BI__builtin_HEXAGON_V6_vgth_xor,
"v60,v62,v65,v66" },
2280 { Hexagon::BI__builtin_HEXAGON_V6_vgth_xor_128B,
"v60,v62,v65,v66" },
2281 { Hexagon::BI__builtin_HEXAGON_V6_vgtub,
"v60,v62,v65,v66" },
2282 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_128B,
"v60,v62,v65,v66" },
2283 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_and,
"v60,v62,v65,v66" },
2284 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_and_128B,
"v60,v62,v65,v66" },
2285 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_or,
"v60,v62,v65,v66" },
2286 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_or_128B,
"v60,v62,v65,v66" },
2287 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_xor,
"v60,v62,v65,v66" },
2288 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_xor_128B,
"v60,v62,v65,v66" },
2289 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh,
"v60,v62,v65,v66" },
2290 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_128B,
"v60,v62,v65,v66" },
2291 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_and,
"v60,v62,v65,v66" },
2292 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_and_128B,
"v60,v62,v65,v66" },
2293 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_or,
"v60,v62,v65,v66" },
2294 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_or_128B,
"v60,v62,v65,v66" },
2295 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_xor,
"v60,v62,v65,v66" },
2296 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_xor_128B,
"v60,v62,v65,v66" },
2297 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw,
"v60,v62,v65,v66" },
2298 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_128B,
"v60,v62,v65,v66" },
2299 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_and,
"v60,v62,v65,v66" },
2300 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_and_128B,
"v60,v62,v65,v66" },
2301 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_or,
"v60,v62,v65,v66" },
2302 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_or_128B,
"v60,v62,v65,v66" },
2303 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_xor,
"v60,v62,v65,v66" },
2304 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_xor_128B,
"v60,v62,v65,v66" },
2305 { Hexagon::BI__builtin_HEXAGON_V6_vgtw,
"v60,v62,v65,v66" },
2306 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_128B,
"v60,v62,v65,v66" },
2307 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_and,
"v60,v62,v65,v66" },
2308 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_and_128B,
"v60,v62,v65,v66" },
2309 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_or,
"v60,v62,v65,v66" },
2310 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_or_128B,
"v60,v62,v65,v66" },
2311 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_xor,
"v60,v62,v65,v66" },
2312 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_xor_128B,
"v60,v62,v65,v66" },
2313 { Hexagon::BI__builtin_HEXAGON_V6_vinsertwr,
"v60,v62,v65,v66" },
2314 { Hexagon::BI__builtin_HEXAGON_V6_vinsertwr_128B,
"v60,v62,v65,v66" },
2315 { Hexagon::BI__builtin_HEXAGON_V6_vlalignb,
"v60,v62,v65,v66" },
2316 { Hexagon::BI__builtin_HEXAGON_V6_vlalignb_128B,
"v60,v62,v65,v66" },
2317 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi,
"v60,v62,v65,v66" },
2318 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B,
"v60,v62,v65,v66" },
2319 { Hexagon::BI__builtin_HEXAGON_V6_vlsrb,
"v62,v65,v66" },
2320 { Hexagon::BI__builtin_HEXAGON_V6_vlsrb_128B,
"v62,v65,v66" },
2321 { Hexagon::BI__builtin_HEXAGON_V6_vlsrh,
"v60,v62,v65,v66" },
2322 { Hexagon::BI__builtin_HEXAGON_V6_vlsrh_128B,
"v60,v62,v65,v66" },
2323 { Hexagon::BI__builtin_HEXAGON_V6_vlsrhv,
"v60,v62,v65,v66" },
2324 { Hexagon::BI__builtin_HEXAGON_V6_vlsrhv_128B,
"v60,v62,v65,v66" },
2325 { Hexagon::BI__builtin_HEXAGON_V6_vlsrw,
"v60,v62,v65,v66" },
2326 { Hexagon::BI__builtin_HEXAGON_V6_vlsrw_128B,
"v60,v62,v65,v66" },
2327 { Hexagon::BI__builtin_HEXAGON_V6_vlsrwv,
"v60,v62,v65,v66" },
2328 { Hexagon::BI__builtin_HEXAGON_V6_vlsrwv_128B,
"v60,v62,v65,v66" },
2329 { Hexagon::BI__builtin_HEXAGON_V6_vlut4,
"v65,v66" },
2330 { Hexagon::BI__builtin_HEXAGON_V6_vlut4_128B,
"v65,v66" },
2331 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb,
"v60,v62,v65,v66" },
2332 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_128B,
"v60,v62,v65,v66" },
2333 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi,
"v62,v65,v66" },
2334 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi_128B,
"v62,v65,v66" },
2335 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_nm,
"v62,v65,v66" },
2336 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_nm_128B,
"v62,v65,v66" },
2337 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracc,
"v60,v62,v65,v66" },
2338 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracc_128B,
"v60,v62,v65,v66" },
2339 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci,
"v62,v65,v66" },
2340 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci_128B,
"v62,v65,v66" },
2341 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh,
"v60,v62,v65,v66" },
2342 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_128B,
"v60,v62,v65,v66" },
2343 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi,
"v62,v65,v66" },
2344 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi_128B,
"v62,v65,v66" },
2345 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_nm,
"v62,v65,v66" },
2346 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_nm_128B,
"v62,v65,v66" },
2347 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracc,
"v60,v62,v65,v66" },
2348 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracc_128B,
"v60,v62,v65,v66" },
2349 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci,
"v62,v65,v66" },
2350 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci_128B,
"v62,v65,v66" },
2351 { Hexagon::BI__builtin_HEXAGON_V6_vmaxb,
"v62,v65,v66" },
2352 { Hexagon::BI__builtin_HEXAGON_V6_vmaxb_128B,
"v62,v65,v66" },
2353 { Hexagon::BI__builtin_HEXAGON_V6_vmaxh,
"v60,v62,v65,v66" },
2354 { Hexagon::BI__builtin_HEXAGON_V6_vmaxh_128B,
"v60,v62,v65,v66" },
2355 { Hexagon::BI__builtin_HEXAGON_V6_vmaxub,
"v60,v62,v65,v66" },
2356 { Hexagon::BI__builtin_HEXAGON_V6_vmaxub_128B,
"v60,v62,v65,v66" },
2357 { Hexagon::BI__builtin_HEXAGON_V6_vmaxuh,
"v60,v62,v65,v66" },
2358 { Hexagon::BI__builtin_HEXAGON_V6_vmaxuh_128B,
"v60,v62,v65,v66" },
2359 { Hexagon::BI__builtin_HEXAGON_V6_vmaxw,
"v60,v62,v65,v66" },
2360 { Hexagon::BI__builtin_HEXAGON_V6_vmaxw_128B,
"v60,v62,v65,v66" },
2361 { Hexagon::BI__builtin_HEXAGON_V6_vminb,
"v62,v65,v66" },
2362 { Hexagon::BI__builtin_HEXAGON_V6_vminb_128B,
"v62,v65,v66" },
2363 { Hexagon::BI__builtin_HEXAGON_V6_vminh,
"v60,v62,v65,v66" },
2364 { Hexagon::BI__builtin_HEXAGON_V6_vminh_128B,
"v60,v62,v65,v66" },
2365 { Hexagon::BI__builtin_HEXAGON_V6_vminub,
"v60,v62,v65,v66" },
2366 { Hexagon::BI__builtin_HEXAGON_V6_vminub_128B,
"v60,v62,v65,v66" },
2367 { Hexagon::BI__builtin_HEXAGON_V6_vminuh,
"v60,v62,v65,v66" },
2368 { Hexagon::BI__builtin_HEXAGON_V6_vminuh_128B,
"v60,v62,v65,v66" },
2369 { Hexagon::BI__builtin_HEXAGON_V6_vminw,
"v60,v62,v65,v66" },
2370 { Hexagon::BI__builtin_HEXAGON_V6_vminw_128B,
"v60,v62,v65,v66" },
2371 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus,
"v60,v62,v65,v66" },
2372 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_128B,
"v60,v62,v65,v66" },
2373 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_acc,
"v60,v62,v65,v66" },
2374 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_acc_128B,
"v60,v62,v65,v66" },
2375 { Hexagon::BI__builtin_HEXAGON_V6_vmpabusv,
"v60,v62,v65,v66" },
2376 { Hexagon::BI__builtin_HEXAGON_V6_vmpabusv_128B,
"v60,v62,v65,v66" },
2377 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu,
"v65,v66" },
2378 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_128B,
"v65,v66" },
2379 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_acc,
"v65,v66" },
2380 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_acc_128B,
"v65,v66" },
2381 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuuv,
"v60,v62,v65,v66" },
2382 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuuv_128B,
"v60,v62,v65,v66" },
2383 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb,
"v60,v62,v65,v66" },
2384 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_128B,
"v60,v62,v65,v66" },
2385 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_acc,
"v60,v62,v65,v66" },
2386 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_acc_128B,
"v60,v62,v65,v66" },
2387 { Hexagon::BI__builtin_HEXAGON_V6_vmpahhsat,
"v65,v66" },
2388 { Hexagon::BI__builtin_HEXAGON_V6_vmpahhsat_128B,
"v65,v66" },
2389 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb,
"v62,v65,v66" },
2390 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_128B,
"v62,v65,v66" },
2391 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_acc,
"v62,v65,v66" },
2392 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_acc_128B,
"v62,v65,v66" },
2393 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhuhsat,
"v65,v66" },
2394 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhuhsat_128B,
"v65,v66" },
2395 { Hexagon::BI__builtin_HEXAGON_V6_vmpsuhuhsat,
"v65,v66" },
2396 { Hexagon::BI__builtin_HEXAGON_V6_vmpsuhuhsat_128B,
"v65,v66" },
2397 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus,
"v60,v62,v65,v66" },
2398 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_128B,
"v60,v62,v65,v66" },
2399 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_acc,
"v60,v62,v65,v66" },
2400 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_acc_128B,
"v60,v62,v65,v66" },
2401 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv,
"v60,v62,v65,v66" },
2402 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_128B,
"v60,v62,v65,v66" },
2403 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_acc,
"v60,v62,v65,v66" },
2404 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_acc_128B,
"v60,v62,v65,v66" },
2405 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv,
"v60,v62,v65,v66" },
2406 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_128B,
"v60,v62,v65,v66" },
2407 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_acc,
"v60,v62,v65,v66" },
2408 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_acc_128B,
"v60,v62,v65,v66" },
2409 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh,
"v60,v62,v65,v66" },
2410 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_128B,
"v60,v62,v65,v66" },
2411 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_64,
"v62,v65,v66" },
2412 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_64_128B,
"v62,v65,v66" },
2413 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh,
"v60,v62,v65,v66" },
2414 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_128B,
"v60,v62,v65,v66" },
2415 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_acc,
"v65,v66" },
2416 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_acc_128B,
"v65,v66" },
2417 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsat_acc,
"v60,v62,v65,v66" },
2418 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsat_acc_128B,
"v60,v62,v65,v66" },
2419 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsrs,
"v60,v62,v65,v66" },
2420 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsrs_128B,
"v60,v62,v65,v66" },
2421 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhss,
"v60,v62,v65,v66" },
2422 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhss_128B,
"v60,v62,v65,v66" },
2423 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus,
"v60,v62,v65,v66" },
2424 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_128B,
"v60,v62,v65,v66" },
2425 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_acc,
"v60,v62,v65,v66" },
2426 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_acc_128B,
"v60,v62,v65,v66" },
2427 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv,
"v60,v62,v65,v66" },
2428 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_128B,
"v60,v62,v65,v66" },
2429 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_acc,
"v60,v62,v65,v66" },
2430 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_acc_128B,
"v60,v62,v65,v66" },
2431 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhvsrs,
"v60,v62,v65,v66" },
2432 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhvsrs_128B,
"v60,v62,v65,v66" },
2433 { Hexagon::BI__builtin_HEXAGON_V6_vmpyieoh,
"v60,v62,v65,v66" },
2434 { Hexagon::BI__builtin_HEXAGON_V6_vmpyieoh_128B,
"v60,v62,v65,v66" },
2435 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewh_acc,
"v60,v62,v65,v66" },
2436 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewh_acc_128B,
"v60,v62,v65,v66" },
2437 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh,
"v60,v62,v65,v66" },
2438 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_128B,
"v60,v62,v65,v66" },
2439 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_acc,
"v60,v62,v65,v66" },
2440 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_acc_128B,
"v60,v62,v65,v66" },
2441 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih,
"v60,v62,v65,v66" },
2442 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_128B,
"v60,v62,v65,v66" },
2443 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_acc,
"v60,v62,v65,v66" },
2444 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_acc_128B,
"v60,v62,v65,v66" },
2445 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb,
"v60,v62,v65,v66" },
2446 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_128B,
"v60,v62,v65,v66" },
2447 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_acc,
"v60,v62,v65,v66" },
2448 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_acc_128B,
"v60,v62,v65,v66" },
2449 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiowh,
"v60,v62,v65,v66" },
2450 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiowh_128B,
"v60,v62,v65,v66" },
2451 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb,
"v60,v62,v65,v66" },
2452 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_128B,
"v60,v62,v65,v66" },
2453 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_acc,
"v60,v62,v65,v66" },
2454 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_acc_128B,
"v60,v62,v65,v66" },
2455 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh,
"v60,v62,v65,v66" },
2456 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_128B,
"v60,v62,v65,v66" },
2457 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_acc,
"v60,v62,v65,v66" },
2458 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_acc_128B,
"v60,v62,v65,v66" },
2459 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub,
"v62,v65,v66" },
2460 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_128B,
"v62,v65,v66" },
2461 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_acc,
"v62,v65,v66" },
2462 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_acc_128B,
"v62,v65,v66" },
2463 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh,
"v60,v62,v65,v66" },
2464 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_128B,
"v60,v62,v65,v66" },
2465 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_64_acc,
"v62,v65,v66" },
2466 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_64_acc_128B,
"v62,v65,v66" },
2467 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd,
"v60,v62,v65,v66" },
2468 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_128B,
"v60,v62,v65,v66" },
2469 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_sacc,
"v60,v62,v65,v66" },
2470 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_sacc_128B,
"v60,v62,v65,v66" },
2471 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_sacc,
"v60,v62,v65,v66" },
2472 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_sacc_128B,
"v60,v62,v65,v66" },
2473 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub,
"v60,v62,v65,v66" },
2474 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_128B,
"v60,v62,v65,v66" },
2475 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_acc,
"v60,v62,v65,v66" },
2476 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_acc_128B,
"v60,v62,v65,v66" },
2477 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv,
"v60,v62,v65,v66" },
2478 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_128B,
"v60,v62,v65,v66" },
2479 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_acc,
"v60,v62,v65,v66" },
2480 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_acc_128B,
"v60,v62,v65,v66" },
2481 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh,
"v60,v62,v65,v66" },
2482 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_128B,
"v60,v62,v65,v66" },
2483 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_acc,
"v60,v62,v65,v66" },
2484 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_acc_128B,
"v60,v62,v65,v66" },
2485 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe,
"v65,v66" },
2486 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_128B,
"v65,v66" },
2487 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_acc,
"v65,v66" },
2488 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_acc_128B,
"v65,v66" },
2489 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv,
"v60,v62,v65,v66" },
2490 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_128B,
"v60,v62,v65,v66" },
2491 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_acc,
"v60,v62,v65,v66" },
2492 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_acc_128B,
"v60,v62,v65,v66" },
2493 { Hexagon::BI__builtin_HEXAGON_V6_vmux,
"v60,v62,v65,v66" },
2494 { Hexagon::BI__builtin_HEXAGON_V6_vmux_128B,
"v60,v62,v65,v66" },
2495 { Hexagon::BI__builtin_HEXAGON_V6_vnavgb,
"v65,v66" },
2496 { Hexagon::BI__builtin_HEXAGON_V6_vnavgb_128B,
"v65,v66" },
2497 { Hexagon::BI__builtin_HEXAGON_V6_vnavgh,
"v60,v62,v65,v66" },
2498 { Hexagon::BI__builtin_HEXAGON_V6_vnavgh_128B,
"v60,v62,v65,v66" },
2499 { Hexagon::BI__builtin_HEXAGON_V6_vnavgub,
"v60,v62,v65,v66" },
2500 { Hexagon::BI__builtin_HEXAGON_V6_vnavgub_128B,
"v60,v62,v65,v66" },
2501 { Hexagon::BI__builtin_HEXAGON_V6_vnavgw,
"v60,v62,v65,v66" },
2502 { Hexagon::BI__builtin_HEXAGON_V6_vnavgw_128B,
"v60,v62,v65,v66" },
2503 { Hexagon::BI__builtin_HEXAGON_V6_vnormamth,
"v60,v62,v65,v66" },
2504 { Hexagon::BI__builtin_HEXAGON_V6_vnormamth_128B,
"v60,v62,v65,v66" },
2505 { Hexagon::BI__builtin_HEXAGON_V6_vnormamtw,
"v60,v62,v65,v66" },
2506 { Hexagon::BI__builtin_HEXAGON_V6_vnormamtw_128B,
"v60,v62,v65,v66" },
2507 { Hexagon::BI__builtin_HEXAGON_V6_vnot,
"v60,v62,v65,v66" },
2508 { Hexagon::BI__builtin_HEXAGON_V6_vnot_128B,
"v60,v62,v65,v66" },
2509 { Hexagon::BI__builtin_HEXAGON_V6_vor,
"v60,v62,v65,v66" },
2510 { Hexagon::BI__builtin_HEXAGON_V6_vor_128B,
"v60,v62,v65,v66" },
2511 { Hexagon::BI__builtin_HEXAGON_V6_vpackeb,
"v60,v62,v65,v66" },
2512 { Hexagon::BI__builtin_HEXAGON_V6_vpackeb_128B,
"v60,v62,v65,v66" },
2513 { Hexagon::BI__builtin_HEXAGON_V6_vpackeh,
"v60,v62,v65,v66" },
2514 { Hexagon::BI__builtin_HEXAGON_V6_vpackeh_128B,
"v60,v62,v65,v66" },
2515 { Hexagon::BI__builtin_HEXAGON_V6_vpackhb_sat,
"v60,v62,v65,v66" },
2516 { Hexagon::BI__builtin_HEXAGON_V6_vpackhb_sat_128B,
"v60,v62,v65,v66" },
2517 { Hexagon::BI__builtin_HEXAGON_V6_vpackhub_sat,
"v60,v62,v65,v66" },
2518 { Hexagon::BI__builtin_HEXAGON_V6_vpackhub_sat_128B,
"v60,v62,v65,v66" },
2519 { Hexagon::BI__builtin_HEXAGON_V6_vpackob,
"v60,v62,v65,v66" },
2520 { Hexagon::BI__builtin_HEXAGON_V6_vpackob_128B,
"v60,v62,v65,v66" },
2521 { Hexagon::BI__builtin_HEXAGON_V6_vpackoh,
"v60,v62,v65,v66" },
2522 { Hexagon::BI__builtin_HEXAGON_V6_vpackoh_128B,
"v60,v62,v65,v66" },
2523 { Hexagon::BI__builtin_HEXAGON_V6_vpackwh_sat,
"v60,v62,v65,v66" },
2524 { Hexagon::BI__builtin_HEXAGON_V6_vpackwh_sat_128B,
"v60,v62,v65,v66" },
2525 { Hexagon::BI__builtin_HEXAGON_V6_vpackwuh_sat,
"v60,v62,v65,v66" },
2526 { Hexagon::BI__builtin_HEXAGON_V6_vpackwuh_sat_128B,
"v60,v62,v65,v66" },
2527 { Hexagon::BI__builtin_HEXAGON_V6_vpopcounth,
"v60,v62,v65,v66" },
2528 { Hexagon::BI__builtin_HEXAGON_V6_vpopcounth_128B,
"v60,v62,v65,v66" },
2529 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqb,
"v65,v66" },
2530 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqb_128B,
"v65,v66" },
2531 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqh,
"v65,v66" },
2532 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqh_128B,
"v65,v66" },
2533 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqw,
"v65,v66" },
2534 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqw_128B,
"v65,v66" },
2535 { Hexagon::BI__builtin_HEXAGON_V6_vrdelta,
"v60,v62,v65,v66" },
2536 { Hexagon::BI__builtin_HEXAGON_V6_vrdelta_128B,
"v60,v62,v65,v66" },
2537 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt,
"v65" },
2538 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_128B,
"v65" },
2539 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_acc,
"v65" },
2540 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_acc_128B,
"v65" },
2541 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus,
"v60,v62,v65,v66" },
2542 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_128B,
"v60,v62,v65,v66" },
2543 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_acc,
"v60,v62,v65,v66" },
2544 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_acc_128B,
"v60,v62,v65,v66" },
2545 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi,
"v60,v62,v65,v66" },
2546 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B,
"v60,v62,v65,v66" },
2547 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc,
"v60,v62,v65,v66" },
2548 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B,
"v60,v62,v65,v66" },
2549 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv,
"v60,v62,v65,v66" },
2550 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_128B,
"v60,v62,v65,v66" },
2551 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_acc,
"v60,v62,v65,v66" },
2552 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_acc_128B,
"v60,v62,v65,v66" },
2553 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv,
"v60,v62,v65,v66" },
2554 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_128B,
"v60,v62,v65,v66" },
2555 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_acc,
"v60,v62,v65,v66" },
2556 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_acc_128B,
"v60,v62,v65,v66" },
2557 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub,
"v60,v62,v65,v66" },
2558 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_128B,
"v60,v62,v65,v66" },
2559 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_acc,
"v60,v62,v65,v66" },
2560 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_acc_128B,
"v60,v62,v65,v66" },
2561 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi,
"v60,v62,v65,v66" },
2562 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B,
"v60,v62,v65,v66" },
2563 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc,
"v60,v62,v65,v66" },
2564 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B,
"v60,v62,v65,v66" },
2565 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt,
"v65" },
2566 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_128B,
"v65" },
2567 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_acc,
"v65" },
2568 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,
"v65" },
2569 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv,
"v60,v62,v65,v66" },
2570 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_128B,
"v60,v62,v65,v66" },
2571 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_acc,
"v60,v62,v65,v66" },
2572 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_acc_128B,
"v60,v62,v65,v66" },
2573 { Hexagon::BI__builtin_HEXAGON_V6_vror,
"v60,v62,v65,v66" },
2574 { Hexagon::BI__builtin_HEXAGON_V6_vror_128B,
"v60,v62,v65,v66" },
2575 { Hexagon::BI__builtin_HEXAGON_V6_vrotr,
"v66" },
2576 { Hexagon::BI__builtin_HEXAGON_V6_vrotr_128B,
"v66" },
2577 { Hexagon::BI__builtin_HEXAGON_V6_vroundhb,
"v60,v62,v65,v66" },
2578 { Hexagon::BI__builtin_HEXAGON_V6_vroundhb_128B,
"v60,v62,v65,v66" },
2579 { Hexagon::BI__builtin_HEXAGON_V6_vroundhub,
"v60,v62,v65,v66" },
2580 { Hexagon::BI__builtin_HEXAGON_V6_vroundhub_128B,
"v60,v62,v65,v66" },
2581 { Hexagon::BI__builtin_HEXAGON_V6_vrounduhub,
"v62,v65,v66" },
2582 { Hexagon::BI__builtin_HEXAGON_V6_vrounduhub_128B,
"v62,v65,v66" },
2583 { Hexagon::BI__builtin_HEXAGON_V6_vrounduwuh,
"v62,v65,v66" },
2584 { Hexagon::BI__builtin_HEXAGON_V6_vrounduwuh_128B,
"v62,v65,v66" },
2585 { Hexagon::BI__builtin_HEXAGON_V6_vroundwh,
"v60,v62,v65,v66" },
2586 { Hexagon::BI__builtin_HEXAGON_V6_vroundwh_128B,
"v60,v62,v65,v66" },
2587 { Hexagon::BI__builtin_HEXAGON_V6_vroundwuh,
"v60,v62,v65,v66" },
2588 { Hexagon::BI__builtin_HEXAGON_V6_vroundwuh_128B,
"v60,v62,v65,v66" },
2589 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi,
"v60,v62,v65,v66" },
2590 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B,
"v60,v62,v65,v66" },
2591 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc,
"v60,v62,v65,v66" },
2592 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B,
"v60,v62,v65,v66" },
2593 { Hexagon::BI__builtin_HEXAGON_V6_vsatdw,
"v66" },
2594 { Hexagon::BI__builtin_HEXAGON_V6_vsatdw_128B,
"v66" },
2595 { Hexagon::BI__builtin_HEXAGON_V6_vsathub,
"v60,v62,v65,v66" },
2596 { Hexagon::BI__builtin_HEXAGON_V6_vsathub_128B,
"v60,v62,v65,v66" },
2597 { Hexagon::BI__builtin_HEXAGON_V6_vsatuwuh,
"v62,v65,v66" },
2598 { Hexagon::BI__builtin_HEXAGON_V6_vsatuwuh_128B,
"v62,v65,v66" },
2599 { Hexagon::BI__builtin_HEXAGON_V6_vsatwh,
"v60,v62,v65,v66" },
2600 { Hexagon::BI__builtin_HEXAGON_V6_vsatwh_128B,
"v60,v62,v65,v66" },
2601 { Hexagon::BI__builtin_HEXAGON_V6_vsb,
"v60,v62,v65,v66" },
2602 { Hexagon::BI__builtin_HEXAGON_V6_vsb_128B,
"v60,v62,v65,v66" },
2603 { Hexagon::BI__builtin_HEXAGON_V6_vsh,
"v60,v62,v65,v66" },
2604 { Hexagon::BI__builtin_HEXAGON_V6_vsh_128B,
"v60,v62,v65,v66" },
2605 { Hexagon::BI__builtin_HEXAGON_V6_vshufeh,
"v60,v62,v65,v66" },
2606 { Hexagon::BI__builtin_HEXAGON_V6_vshufeh_128B,
"v60,v62,v65,v66" },
2607 { Hexagon::BI__builtin_HEXAGON_V6_vshuffb,
"v60,v62,v65,v66" },
2608 { Hexagon::BI__builtin_HEXAGON_V6_vshuffb_128B,
"v60,v62,v65,v66" },
2609 { Hexagon::BI__builtin_HEXAGON_V6_vshuffeb,
"v60,v62,v65,v66" },
2610 { Hexagon::BI__builtin_HEXAGON_V6_vshuffeb_128B,
"v60,v62,v65,v66" },
2611 { Hexagon::BI__builtin_HEXAGON_V6_vshuffh,
"v60,v62,v65,v66" },
2612 { Hexagon::BI__builtin_HEXAGON_V6_vshuffh_128B,
"v60,v62,v65,v66" },
2613 { Hexagon::BI__builtin_HEXAGON_V6_vshuffob,
"v60,v62,v65,v66" },
2614 { Hexagon::BI__builtin_HEXAGON_V6_vshuffob_128B,
"v60,v62,v65,v66" },
2615 { Hexagon::BI__builtin_HEXAGON_V6_vshuffvdd,
"v60,v62,v65,v66" },
2616 { Hexagon::BI__builtin_HEXAGON_V6_vshuffvdd_128B,
"v60,v62,v65,v66" },
2617 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeb,
"v60,v62,v65,v66" },
2618 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeb_128B,
"v60,v62,v65,v66" },
2619 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeh,
"v60,v62,v65,v66" },
2620 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeh_128B,
"v60,v62,v65,v66" },
2621 { Hexagon::BI__builtin_HEXAGON_V6_vshufoh,
"v60,v62,v65,v66" },
2622 { Hexagon::BI__builtin_HEXAGON_V6_vshufoh_128B,
"v60,v62,v65,v66" },
2623 { Hexagon::BI__builtin_HEXAGON_V6_vsubb,
"v60,v62,v65,v66" },
2624 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_128B,
"v60,v62,v65,v66" },
2625 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_dv,
"v60,v62,v65,v66" },
2626 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_dv_128B,
"v60,v62,v65,v66" },
2627 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat,
"v62,v65,v66" },
2628 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_128B,
"v62,v65,v66" },
2629 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_dv,
"v62,v65,v66" },
2630 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_dv_128B,
"v62,v65,v66" },
2631 { Hexagon::BI__builtin_HEXAGON_V6_vsubcarry,
"v62,v65,v66" },
2632 { Hexagon::BI__builtin_HEXAGON_V6_vsubcarry_128B,
"v62,v65,v66" },
2633 { Hexagon::BI__builtin_HEXAGON_V6_vsubh,
"v60,v62,v65,v66" },
2634 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_128B,
"v60,v62,v65,v66" },
2635 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_dv,
"v60,v62,v65,v66" },
2636 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_dv_128B,
"v60,v62,v65,v66" },
2637 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat,
"v60,v62,v65,v66" },
2638 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_128B,
"v60,v62,v65,v66" },
2639 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_dv,
"v60,v62,v65,v66" },
2640 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_dv_128B,
"v60,v62,v65,v66" },
2641 { Hexagon::BI__builtin_HEXAGON_V6_vsubhw,
"v60,v62,v65,v66" },
2642 { Hexagon::BI__builtin_HEXAGON_V6_vsubhw_128B,
"v60,v62,v65,v66" },
2643 { Hexagon::BI__builtin_HEXAGON_V6_vsububh,
"v60,v62,v65,v66" },
2644 { Hexagon::BI__builtin_HEXAGON_V6_vsububh_128B,
"v60,v62,v65,v66" },
2645 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat,
"v60,v62,v65,v66" },
2646 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_128B,
"v60,v62,v65,v66" },
2647 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_dv,
"v60,v62,v65,v66" },
2648 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_dv_128B,
"v60,v62,v65,v66" },
2649 { Hexagon::BI__builtin_HEXAGON_V6_vsubububb_sat,
"v62,v65,v66" },
2650 { Hexagon::BI__builtin_HEXAGON_V6_vsubububb_sat_128B,
"v62,v65,v66" },
2651 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat,
"v60,v62,v65,v66" },
2652 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_128B,
"v60,v62,v65,v66" },
2653 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_dv,
"v60,v62,v65,v66" },
2654 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_dv_128B,
"v60,v62,v65,v66" },
2655 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhw,
"v60,v62,v65,v66" },
2656 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhw_128B,
"v60,v62,v65,v66" },
2657 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat,
"v62,v65,v66" },
2658 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_128B,
"v62,v65,v66" },
2659 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_dv,
"v62,v65,v66" },
2660 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_dv_128B,
"v62,v65,v66" },
2661 { Hexagon::BI__builtin_HEXAGON_V6_vsubw,
"v60,v62,v65,v66" },
2662 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_128B,
"v60,v62,v65,v66" },
2663 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_dv,
"v60,v62,v65,v66" },
2664 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_dv_128B,
"v60,v62,v65,v66" },
2665 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat,
"v60,v62,v65,v66" },
2666 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_128B,
"v60,v62,v65,v66" },
2667 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_dv,
"v60,v62,v65,v66" },
2668 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_dv_128B,
"v60,v62,v65,v66" },
2669 { Hexagon::BI__builtin_HEXAGON_V6_vswap,
"v60,v62,v65,v66" },
2670 { Hexagon::BI__builtin_HEXAGON_V6_vswap_128B,
"v60,v62,v65,v66" },
2671 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb,
"v60,v62,v65,v66" },
2672 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_128B,
"v60,v62,v65,v66" },
2673 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_acc,
"v60,v62,v65,v66" },
2674 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_acc_128B,
"v60,v62,v65,v66" },
2675 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus,
"v60,v62,v65,v66" },
2676 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_128B,
"v60,v62,v65,v66" },
2677 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_acc,
"v60,v62,v65,v66" },
2678 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_acc_128B,
"v60,v62,v65,v66" },
2679 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb,
"v60,v62,v65,v66" },
2680 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_128B,
"v60,v62,v65,v66" },
2681 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_acc,
"v60,v62,v65,v66" },
2682 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_acc_128B,
"v60,v62,v65,v66" },
2683 { Hexagon::BI__builtin_HEXAGON_V6_vunpackb,
"v60,v62,v65,v66" },
2684 { Hexagon::BI__builtin_HEXAGON_V6_vunpackb_128B,
"v60,v62,v65,v66" },
2685 { Hexagon::BI__builtin_HEXAGON_V6_vunpackh,
"v60,v62,v65,v66" },
2686 { Hexagon::BI__builtin_HEXAGON_V6_vunpackh_128B,
"v60,v62,v65,v66" },
2687 { Hexagon::BI__builtin_HEXAGON_V6_vunpackob,
"v60,v62,v65,v66" },
2688 { Hexagon::BI__builtin_HEXAGON_V6_vunpackob_128B,
"v60,v62,v65,v66" },
2689 { Hexagon::BI__builtin_HEXAGON_V6_vunpackoh,
"v60,v62,v65,v66" },
2690 { Hexagon::BI__builtin_HEXAGON_V6_vunpackoh_128B,
"v60,v62,v65,v66" },
2691 { Hexagon::BI__builtin_HEXAGON_V6_vunpackub,
"v60,v62,v65,v66" },
2692 { Hexagon::BI__builtin_HEXAGON_V6_vunpackub_128B,
"v60,v62,v65,v66" },
2693 { Hexagon::BI__builtin_HEXAGON_V6_vunpackuh,
"v60,v62,v65,v66" },
2694 { Hexagon::BI__builtin_HEXAGON_V6_vunpackuh_128B,
"v60,v62,v65,v66" },
2695 { Hexagon::BI__builtin_HEXAGON_V6_vxor,
"v60,v62,v65,v66" },
2696 { Hexagon::BI__builtin_HEXAGON_V6_vxor_128B,
"v60,v62,v65,v66" },
2697 { Hexagon::BI__builtin_HEXAGON_V6_vzb,
"v60,v62,v65,v66" },
2698 { Hexagon::BI__builtin_HEXAGON_V6_vzb_128B,
"v60,v62,v65,v66" },
2699 { Hexagon::BI__builtin_HEXAGON_V6_vzh,
"v60,v62,v65,v66" },
2700 { Hexagon::BI__builtin_HEXAGON_V6_vzh_128B,
"v60,v62,v65,v66" },
2704 auto SortCmp = [](
const BuiltinAndString &LHS,
const BuiltinAndString &RHS) {
2705 return LHS.BuiltinID < RHS.BuiltinID;
2707 static const bool SortOnce =
2708 (llvm::sort(ValidCPU, SortCmp),
2709 llvm::sort(ValidHVX, SortCmp),
true);
2711 auto LowerBoundCmp = [](
const BuiltinAndString &BI,
unsigned BuiltinID) {
2712 return BI.BuiltinID < BuiltinID;
2717 const BuiltinAndString *FC =
2718 llvm::lower_bound(ValidCPU, BuiltinID, LowerBoundCmp);
2719 if (FC != std::end(ValidCPU) && FC->BuiltinID == BuiltinID) {
2721 StringRef CPU = Opts.
CPU;
2723 assert(CPU.startswith(
"hexagon") &&
"Unexpected CPU name");
2724 CPU.consume_front(
"hexagon");
2726 StringRef(FC->Str).split(CPUs,
',');
2727 if (llvm::none_of(CPUs, [CPU](StringRef S) {
return S == CPU; }))
2729 diag::err_hexagon_builtin_unsupported_cpu);
2733 const BuiltinAndString *FH =
2734 llvm::lower_bound(ValidHVX, BuiltinID, LowerBoundCmp);
2735 if (FH != std::end(ValidHVX) && FH->BuiltinID == BuiltinID) {
2738 diag::err_hexagon_builtin_requires_hvx);
2741 StringRef(FH->Str).split(HVXs,
',');
2742 bool IsValid = llvm::any_of(HVXs,
2743 [&TI] (StringRef
V) {
2744 std::string F =
"hvx" + V.str();
2749 diag::err_hexagon_builtin_unsupported_hvx);
2755 bool Sema::CheckHexagonBuiltinArgument(
unsigned BuiltinID,
CallExpr *TheCall) {
2768 { Hexagon::BI__builtin_circ_ldd, {{ 3,
true, 4, 3 }} },
2769 { Hexagon::BI__builtin_circ_ldw, {{ 3,
true, 4, 2 }} },
2770 { Hexagon::BI__builtin_circ_ldh, {{ 3,
true, 4, 1 }} },
2771 { Hexagon::BI__builtin_circ_lduh, {{ 3,
true, 4, 0 }} },
2772 { Hexagon::BI__builtin_circ_ldb, {{ 3,
true, 4, 0 }} },
2773 { Hexagon::BI__builtin_circ_ldub, {{ 3,
true, 4, 0 }} },
2774 { Hexagon::BI__builtin_circ_std, {{ 3,
true, 4, 3 }} },
2775 { Hexagon::BI__builtin_circ_stw, {{ 3,
true, 4, 2 }} },
2776 { Hexagon::BI__builtin_circ_sth, {{ 3,
true, 4, 1 }} },
2777 { Hexagon::BI__builtin_circ_sthhi, {{ 3,
true, 4, 1 }} },
2778 { Hexagon::BI__builtin_circ_stb, {{ 3,
true, 4, 0 }} },
2780 { Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{ 1,
true, 4, 0 }} },
2781 { Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{ 1,
true, 4, 0 }} },
2782 { Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{ 1,
true, 4, 1 }} },
2783 { Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{ 1,
true, 4, 1 }} },
2784 { Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{ 1,
true, 4, 2 }} },
2785 { Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{ 1,
true, 4, 3 }} },
2786 { Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{ 1,
true, 4, 0 }} },
2787 { Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{ 1,
true, 4, 1 }} },
2788 { Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{ 1,
true, 4, 1 }} },
2789 { Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{ 1,
true, 4, 2 }} },
2790 { Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{ 1,
true, 4, 3 }} },
2792 { Hexagon::BI__builtin_HEXAGON_A2_combineii, {{ 1,
true, 8, 0 }} },
2793 { Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{ 1,
false, 16, 0 }} },
2794 { Hexagon::BI__builtin_HEXAGON_A2_tfril, {{ 1,
false, 16, 0 }} },
2795 { Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{ 0,
true, 8, 0 }} },
2796 { Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{ 1,
false, 5, 0 }} },
2797 { Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{ 1,
false, 8, 0 }} },
2798 { Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{ 1,
true, 8, 0 }} },
2799 { Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{ 1,
false, 5, 0 }} },
2800 { Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{ 1,
false, 5, 0 }} },
2801 { Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{ 1,
false, 5, 0 }} },
2802 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{ 1,
false, 8, 0 }} },
2803 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{ 1,
true, 8, 0 }} },
2804 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{ 1,
false, 7, 0 }} },
2805 { Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{ 1,
true, 8, 0 }} },
2806 { Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{ 1,
true, 8, 0 }} },
2807 { Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{ 1,
false, 7, 0 }} },
2808 { Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{ 1,
true, 8, 0 }} },
2809 { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{ 1,
true, 8, 0 }} },
2810 { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{ 1,
false, 7, 0 }} },
2811 { Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{ 1,
false, 6, 0 }} },
2812 { Hexagon::BI__builtin_HEXAGON_C2_muxii, {{ 2,
true, 8, 0 }} },
2813 { Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{ 1,
false, 6, 0 }} },
2814 { Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{ 1,
false, 5, 0 }} },
2815 { Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{ 0,
false, 10, 0 }} },
2816 { Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{ 0,
false, 10, 0 }} },
2817 { Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{ 1,
false, 5, 0 }} },
2818 { Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{ 0,
false, 10, 0 }} },
2819 { Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{ 0,
false, 10, 0 }} },
2820 { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{ 2,
false, 6, 0 }} },
2821 { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{ 1,
false, 6, 2 }} },
2822 { Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{ 2,
false, 3, 0 }} },
2823 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{ 2,
false, 6, 0 }} },
2824 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{ 2,
false, 6, 0 }} },
2825 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{ 1,
false, 6, 0 }} },
2826 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{ 2,
false, 6, 0 }} },
2827 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{ 2,
false, 6, 0 }} },
2828 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{ 2,
false, 6, 0 }} },
2829 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{ 2,
false, 5, 0 }} },
2830 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{ 2,
false, 5, 0 }} },
2831 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{ 1,
false, 5, 0 }} },
2832 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{ 2,
false, 5, 0 }} },
2833 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{ 2,
false, 5, 0 }} },
2834 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{ 1,
false, 5, 0 }} },
2835 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{ 2,
false, 5, 0 }} },
2836 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{ 1,
false, 4, 0 }} },
2837 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{ 1,
false, 5, 0 }} },
2838 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{ 2,
false, 6, 0 }} },
2839 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{ 2,
false, 6, 0 }} },
2840 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{ 1,
false, 6, 0 }} },
2841 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{ 2,
false, 6, 0 }} },
2842 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{ 2,
false, 6, 0 }} },
2843 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax,
2844 {{ 1,
false, 6, 0 }} },
2845 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{ 1,
false, 6, 0 }} },
2846 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{ 2,
false, 5, 0 }} },
2847 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{ 2,
false, 5, 0 }} },
2848 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{ 1,
false, 5, 0 }} },
2849 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{ 2,
false, 5, 0 }} },
2850 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{ 2,
false, 5, 0 }} },
2851 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax,
2852 {{ 1,
false, 5, 0 }} },
2853 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{ 1,
false, 5, 0 }} },
2854 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{ 1,
false, 5, 0 }} },
2855 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{ 1,
false, 4, 0 }} },
2856 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{ 1,
false, 5, 0 }} },
2857 { Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{ 1,
false, 5, 0 }} },
2858 { Hexagon::BI__builtin_HEXAGON_S2_extractu, {{ 1,
false, 5, 0 },
2859 { 2,
false, 5, 0 }} },
2860 { Hexagon::BI__builtin_HEXAGON_S2_extractup, {{ 1,
false, 6, 0 },
2861 { 2,
false, 6, 0 }} },
2862 { Hexagon::BI__builtin_HEXAGON_S2_insert, {{ 2,
false, 5, 0 },
2863 { 3,
false, 5, 0 }} },
2864 { Hexagon::BI__builtin_HEXAGON_S2_insertp, {{ 2,
false, 6, 0 },
2865 { 3,
false, 6, 0 }} },
2866 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{ 2,
false, 6, 0 }} },
2867 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{ 2,
false, 6, 0 }} },
2868 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{ 1,
false, 6, 0 }} },
2869 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{ 2,
false, 6, 0 }} },
2870 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{ 2,
false, 6, 0 }} },
2871 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{ 2,
false, 6, 0 }} },
2872 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{ 2,
false, 5, 0 }} },
2873 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{ 2,
false, 5, 0 }} },
2874 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{ 1,
false, 5, 0 }} },
2875 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{ 2,
false, 5, 0 }} },
2876 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{ 2,
false, 5, 0 }} },
2877 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{ 2,
false, 5, 0 }} },
2878 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{ 1,
false, 4, 0 }} },
2879 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{ 1,
false, 5, 0 }} },
2880 { Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{ 1,
false, 5, 0 }} },
2881 { Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax,
2882 {{ 2,
false, 4, 0 },
2883 { 3,
false, 5, 0 }} },
2884 { Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax,
2885 {{ 2,
false, 4, 0 },
2886 { 3,
false, 5, 0 }} },
2887 { Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax,
2888 {{ 2,
false, 4, 0 },
2889 { 3,
false, 5, 0 }} },
2890 { Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax,
2891 {{ 2,
false, 4, 0 },
2892 { 3,
false, 5, 0 }} },
2893 { Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{ 1,
false, 5, 0 }} },
2894 { Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{ 1,
false, 5, 0 }} },
2895 { Hexagon::BI__builtin_HEXAGON_S2_valignib, {{ 2,
false, 3, 0 }} },
2896 { Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{ 2,
false, 3, 0 }} },
2897 { Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{ 2,
false, 5, 0 }} },
2898 { Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{ 2,
false, 5, 0 }} },
2899 { Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{ 2,
false, 5, 0 }} },
2900 { Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{ 2,
false, 5, 0 }} },
2901 { Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{ 1,
true , 6, 0 }} },
2902 { Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{ 1,
true, 6, 0 }} },
2903 { Hexagon::BI__builtin_HEXAGON_S4_extract, {{ 1,
false, 5, 0 },
2904 { 2,
false, 5, 0 }} },
2905 { Hexagon::BI__builtin_HEXAGON_S4_extractp, {{ 1,
false, 6, 0 },
2906 { 2,
false, 6, 0 }} },
2907 { Hexagon::BI__builtin_HEXAGON_S4_lsli, {{ 0,
true, 6, 0 }} },
2908 { Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{ 1,
false, 5, 0 }} },
2909 { Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{ 2,
false, 5, 0 }} },
2910 { Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{ 2,
false, 5, 0 }} },
2911 { Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{ 2,
false, 5, 0 }} },
2912 { Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{ 2,
false, 5, 0 }} },
2913 { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{ 3,
false, 2, 0 }} },
2914 { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{ 2,
false, 2, 0 }} },
2915 { Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax,
2916 {{ 1,
false, 4, 0 }} },
2917 { Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{ 1,
false, 4, 0 }} },
2918 { Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax,
2919 {{ 1,
false, 4, 0 }} },
2920 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{ 1,
false, 6, 0 }} },
2921 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{ 2,
false, 6, 0 }} },
2922 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{ 2,
false, 6, 0 }} },
2923 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{ 2,
false, 6, 0 }} },
2924 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{ 2,
false, 6, 0 }} },
2925 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{ 2,
false, 6, 0 }} },
2926 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{ 1,
false, 5, 0 }} },
2927 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{ 2,
false, 5, 0 }} },
2928 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{ 2,
false, 5, 0 }} },
2929 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{ 2,
false, 5, 0 }} },
2930 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{ 2,
false, 5, 0 }} },
2931 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{ 2,
false, 5, 0 }} },
2932 { Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{ 2,
false, 3, 0 }} },
2933 { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{ 2,
false, 3, 0 }} },
2934 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{ 2,
false, 3, 0 }} },
2935 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{ 2,
false, 3, 0 }} },
2936 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{ 2,
false, 1, 0 }} },
2937 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{ 2,
false, 1, 0 }} },
2938 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{ 3,
false, 1, 0 }} },
2939 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B,
2940 {{ 3,
false, 1, 0 }} },
2941 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{ 2,
false, 1, 0 }} },
2942 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{ 2,
false, 1, 0 }} },
2943 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{ 3,
false, 1, 0 }} },
2944 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B,
2945 {{ 3,
false, 1, 0 }} },
2946 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{ 2,
false, 1, 0 }} },
2947 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{ 2,
false, 1, 0 }} },
2948 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{ 3,
false, 1, 0 }} },
2949 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B,
2950 {{ 3,
false, 1, 0 }} },
2955 static const bool SortOnce =
2958 return LHS.BuiltinID < RHS.BuiltinID;
2964 Infos, [=](
const BuiltinInfo &BI) {
return BI.BuiltinID < BuiltinID; });
2965 if (F == std::end(Infos) || F->BuiltinID != BuiltinID)
2970 for (
const ArgInfo &A : F->Infos) {
2972 if (A.BitWidth == 0)
2975 int32_t Min = A.IsSigned ? -(1 << (A.BitWidth - 1)) : 0;
2976 int32_t Max = (1 << (A.IsSigned ? A.BitWidth - 1 : A.BitWidth)) - 1;
2978 Error |= SemaBuiltinConstantArgRange(TheCall, A.OpNum, Min, Max);
2980 unsigned M = 1 << A.Align;
2983 Error |= SemaBuiltinConstantArgRange(TheCall, A.OpNum, Min, Max) |
2984 SemaBuiltinConstantArgMultiple(TheCall, A.OpNum, M);
2990 bool Sema::CheckHexagonBuiltinFunctionCall(
unsigned BuiltinID,
2992 return CheckHexagonBuiltinCpu(BuiltinID, TheCall) ||
2993 CheckHexagonBuiltinArgument(BuiltinID, TheCall);
3006 bool Sema::CheckMipsBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
3007 unsigned i = 0, l = 0, u = 0, m = 0;
3008 switch (BuiltinID) {
3009 default:
return false;
3010 case Mips::BI__builtin_mips_wrdsp: i = 1; l = 0; u = 63;
break;
3011 case Mips::BI__builtin_mips_rddsp: i = 0; l = 0; u = 63;
break;
3012 case Mips::BI__builtin_mips_append: i = 2; l = 0; u = 31;
break;
3013 case Mips::BI__builtin_mips_balign: i = 2; l = 0; u = 3;
break;
3014 case Mips::BI__builtin_mips_precr_sra_ph_w: i = 2; l = 0; u = 31;
break;
3015 case Mips::BI__builtin_mips_precr_sra_r_ph_w: i = 2; l = 0; u = 31;
break;
3016 case Mips::BI__builtin_mips_prepend: i = 2; l = 0; u = 31;
break;
3020 case Mips::BI__builtin_msa_bclri_b:
3021 case Mips::BI__builtin_msa_bnegi_b:
3022 case Mips::BI__builtin_msa_bseti_b:
3023 case Mips::BI__builtin_msa_sat_s_b:
3024 case Mips::BI__builtin_msa_sat_u_b:
3025 case Mips::BI__builtin_msa_slli_b:
3026 case Mips::BI__builtin_msa_srai_b:
3027 case Mips::BI__builtin_msa_srari_b:
3028 case Mips::BI__builtin_msa_srli_b:
3029 case Mips::BI__builtin_msa_srlri_b: i = 1; l = 0; u = 7;
break;
3030 case Mips::BI__builtin_msa_binsli_b:
3031 case Mips::BI__builtin_msa_binsri_b: i = 2; l = 0; u = 7;
break;
3033 case Mips::BI__builtin_msa_bclri_h:
3034 case Mips::BI__builtin_msa_bnegi_h:
3035 case Mips::BI__builtin_msa_bseti_h:
3036 case Mips::BI__builtin_msa_sat_s_h:
3037 case Mips::BI__builtin_msa_sat_u_h:
3038 case Mips::BI__builtin_msa_slli_h:
3039 case Mips::BI__builtin_msa_srai_h:
3040 case Mips::BI__builtin_msa_srari_h:
3041 case Mips::BI__builtin_msa_srli_h:
3042 case Mips::BI__builtin_msa_srlri_h: i = 1; l = 0; u = 15;
break;
3043 case Mips::BI__builtin_msa_binsli_h:
3044 case Mips::BI__builtin_msa_binsri_h: i = 2; l = 0; u = 15;
break;
3048 case Mips::BI__builtin_msa_cfcmsa:
3049 case Mips::BI__builtin_msa_ctcmsa: i = 0; l = 0; u = 31;
break;
3050 case Mips::BI__builtin_msa_clei_u_b:
3051 case Mips::BI__builtin_msa_clei_u_h:
3052 case Mips::BI__builtin_msa_clei_u_w:
3053 case Mips::BI__builtin_msa_clei_u_d:
3054 case Mips::BI__builtin_msa_clti_u_b:
3055 case Mips::BI__builtin_msa_clti_u_h:
3056 case Mips::BI__builtin_msa_clti_u_w:
3057 case Mips::BI__builtin_msa_clti_u_d:
3058 case Mips::BI__builtin_msa_maxi_u_b:
3059 case Mips::BI__builtin_msa_maxi_u_h:
3060 case Mips::BI__builtin_msa_maxi_u_w:
3061 case Mips::BI__builtin_msa_maxi_u_d:
3062 case Mips::BI__builtin_msa_mini_u_b:
3063 case Mips::BI__builtin_msa_mini_u_h:
3064 case Mips::BI__builtin_msa_mini_u_w:
3065 case Mips::BI__builtin_msa_mini_u_d:
3066 case Mips::BI__builtin_msa_addvi_b:
3067 case Mips::BI__builtin_msa_addvi_h:
3068 case Mips::BI__builtin_msa_addvi_w:
3069 case Mips::BI__builtin_msa_addvi_d:
3070 case Mips::BI__builtin_msa_bclri_w:
3071 case Mips::BI__builtin_msa_bnegi_w:
3072 case Mips::BI__builtin_msa_bseti_w:
3073 case Mips::BI__builtin_msa_sat_s_w:
3074 case Mips::BI__builtin_msa_sat_u_w:
3075 case Mips::BI__builtin_msa_slli_w:
3076 case Mips::BI__builtin_msa_srai_w:
3077 case Mips::BI__builtin_msa_srari_w:
3078 case Mips::BI__builtin_msa_srli_w:
3079 case Mips::BI__builtin_msa_srlri_w:
3080 case Mips::BI__builtin_msa_subvi_b:
3081 case Mips::BI__builtin_msa_subvi_h:
3082 case Mips::BI__builtin_msa_subvi_w:
3083 case Mips::BI__builtin_msa_subvi_d: i = 1; l = 0; u = 31;
break;
3084 case Mips::BI__builtin_msa_binsli_w:
3085 case Mips::BI__builtin_msa_binsri_w: i = 2; l = 0; u = 31;
break;
3087 case Mips::BI__builtin_msa_bclri_d:
3088 case Mips::BI__builtin_msa_bnegi_d:
3089 case Mips::BI__builtin_msa_bseti_d:
3090 case Mips::BI__builtin_msa_sat_s_d:
3091 case Mips::BI__builtin_msa_sat_u_d:
3092 case Mips::BI__builtin_msa_slli_d:
3093 case Mips::BI__builtin_msa_srai_d:
3094 case Mips::BI__builtin_msa_srari_d:
3095 case Mips::BI__builtin_msa_srli_d:
3096 case Mips::BI__builtin_msa_srlri_d: i = 1; l = 0; u = 63;
break;
3097 case Mips::BI__builtin_msa_binsli_d:
3098 case Mips::BI__builtin_msa_binsri_d: i = 2; l = 0; u = 63;
break;
3100 case Mips::BI__builtin_msa_ceqi_b:
3101 case Mips::BI__builtin_msa_ceqi_h:
3102 case Mips::BI__builtin_msa_ceqi_w:
3103 case Mips::BI__builtin_msa_ceqi_d:
3104 case Mips::BI__builtin_msa_clti_s_b:
3105 case Mips::BI__builtin_msa_clti_s_h:
3106 case Mips::BI__builtin_msa_clti_s_w:
3107 case Mips::BI__builtin_msa_clti_s_d:
3108 case Mips::BI__builtin_msa_clei_s_b:
3109 case Mips::BI__builtin_msa_clei_s_h:
3110 case Mips::BI__builtin_msa_clei_s_w:
3111 case Mips::BI__builtin_msa_clei_s_d:
3112 case Mips::BI__builtin_msa_maxi_s_b:
3113 case Mips::BI__builtin_msa_maxi_s_h:
3114 case Mips::BI__builtin_msa_maxi_s_w:
3115 case Mips::BI__builtin_msa_maxi_s_d:
3116 case Mips::BI__builtin_msa_mini_s_b:
3117 case Mips::BI__builtin_msa_mini_s_h:
3118 case Mips::BI__builtin_msa_mini_s_w:
3119 case Mips::BI__builtin_msa_mini_s_d: i = 1; l = -16; u = 15;
break;
3121 case Mips::BI__builtin_msa_andi_b:
3122 case Mips::BI__builtin_msa_nori_b:
3123 case Mips::BI__builtin_msa_ori_b:
3124 case Mips::BI__builtin_msa_shf_b:
3125 case Mips::BI__builtin_msa_shf_h:
3126 case Mips::BI__builtin_msa_shf_w:
3127 case Mips::BI__builtin_msa_xori_b: i = 1; l = 0; u = 255;
break;
3128 case Mips::BI__builtin_msa_bseli_b:
3129 case Mips::BI__builtin_msa_bmnzi_b:
3130 case Mips::BI__builtin_msa_bmzi_b: i = 2; l = 0; u = 255;
break;
3133 case Mips::BI__builtin_msa_copy_s_b:
3134 case Mips::BI__builtin_msa_copy_u_b:
3135 case Mips::BI__builtin_msa_insve_b:
3136 case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15;
break;
3137 case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15;
break;
3139 case Mips::BI__builtin_msa_copy_s_h:
3140 case Mips::BI__builtin_msa_copy_u_h:
3141 case Mips::BI__builtin_msa_insve_h:
3142 case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7;
break;
3143 case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7;
break;
3145 case Mips::BI__builtin_msa_copy_s_w:
3146 case Mips::BI__builtin_msa_copy_u_w:
3147 case Mips::BI__builtin_msa_insve_w:
3148 case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3;
break;
3149 case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3;
break;
3151 case Mips::BI__builtin_msa_copy_s_d:
3152 case Mips::BI__builtin_msa_copy_u_d:
3153 case Mips::BI__builtin_msa_insve_d:
3154 case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1;
break;
3155 case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1;
break;
3158 case Mips::BI__builtin_msa_ldi_b: i = 0; l = -128; u = 255;
break;
3159 case Mips::BI__builtin_msa_ldi_h:
3160 case Mips::BI__builtin_msa_ldi_w:
3161 case Mips::BI__builtin_msa_ldi_d: i = 0; l = -512; u = 511;
break;
3162 case Mips::BI__builtin_msa_ld_b: i = 1; l = -512; u = 511; m = 1;
break;
3163 case Mips::BI__builtin_msa_ld_h: i = 1; l = -1024; u = 1022; m = 2;
break;
3164 case Mips::BI__builtin_msa_ld_w: i = 1; l = -2048; u = 2044; m = 4;
break;
3165 case Mips::BI__builtin_msa_ld_d: i = 1; l = -4096; u = 4088; m = 8;
break;
3166 case Mips::BI__builtin_msa_st_b: i = 2; l = -512; u = 511; m = 1;
break;
3167 case Mips::BI__builtin_msa_st_h: i = 2; l = -1024; u = 1022; m = 2;
break;
3168 case Mips::BI__builtin_msa_st_w: i = 2; l = -2048; u = 2044; m = 4;
break;
3169 case Mips::BI__builtin_msa_st_d: i = 2; l = -4096; u = 4088; m = 8;
break;
3173 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3175 return SemaBuiltinConstantArgRange(TheCall, i, l, u) ||
3176 SemaBuiltinConstantArgMultiple(TheCall, i, m);
3179 bool Sema::CheckPPCBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
3180 unsigned i = 0, l = 0, u = 0;
3181 bool Is64BitBltin = BuiltinID == PPC::BI__builtin_divde ||
3182 BuiltinID == PPC::BI__builtin_divdeu ||
3183 BuiltinID == PPC::BI__builtin_bpermd;
3187 .getIntPtrType()) == 64;
3188 bool IsBltinExtDiv = BuiltinID == PPC::BI__builtin_divwe ||
3189 BuiltinID == PPC::BI__builtin_divweu ||
3190 BuiltinID == PPC::BI__builtin_divde ||
3191 BuiltinID == PPC::BI__builtin_divdeu;
3193 if (Is64BitBltin && !IsTarget64Bit)
3194 return Diag(TheCall->
getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
3198 (BuiltinID == PPC::BI__builtin_bpermd &&
3200 return Diag(TheCall->
getBeginLoc(), diag::err_ppc_builtin_only_on_pwr7)
3203 auto SemaVSXCheck = [&](
CallExpr *TheCall) ->
bool {
3205 return Diag(TheCall->
getBeginLoc(), diag::err_ppc_builtin_only_on_pwr7)
3210 switch (BuiltinID) {
3211 default:
return false;
3212 case PPC::BI__builtin_altivec_crypto_vshasigmaw:
3213 case PPC::BI__builtin_altivec_crypto_vshasigmad:
3214 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
3215 SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
3216 case PPC::BI__builtin_tbegin:
3217 case PPC::BI__builtin_tend: i = 0; l = 0; u = 1;
break;
3218 case PPC::BI__builtin_tsr: i = 0; l = 0; u = 7;
break;
3219 case PPC::BI__builtin_tabortwc:
3220 case PPC::BI__builtin_tabortdc: i = 0; l = 0; u = 31;
break;
3221 case PPC::BI__builtin_tabortwci:
3222 case PPC::BI__builtin_tabortdci:
3223 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
3224 SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
3225 case PPC::BI__builtin_vsx_xxpermdi:
3226 case PPC::BI__builtin_vsx_xxsldwi:
3227 return SemaBuiltinVSX(TheCall);
3228 case PPC::BI__builtin_unpack_vector_int128:
3229 return SemaVSXCheck(TheCall) ||
3230 SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
3231 case PPC::BI__builtin_pack_vector_int128:
3232 return SemaVSXCheck(TheCall);
3234 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3237 bool Sema::CheckSystemZBuiltinFunctionCall(
unsigned BuiltinID,
3239 if (BuiltinID == SystemZ::BI__builtin_tabort) {
3241 llvm::APSInt AbortCode(32);
3243 AbortCode.getSExtValue() >= 0 && AbortCode.getSExtValue() < 256)
3244 return Diag(Arg->
getBeginLoc(), diag::err_systemz_invalid_tabort_code)
3250 unsigned i = 0, l = 0, u = 0;
3251 switch (BuiltinID) {
3252 default:
return false;
3253 case SystemZ::BI__builtin_s390_lcbb: i = 1; l = 0; u = 15;
break;
3254 case SystemZ::BI__builtin_s390_verimb:
3255 case SystemZ::BI__builtin_s390_verimh:
3256 case SystemZ::BI__builtin_s390_verimf:
3257 case SystemZ::BI__builtin_s390_verimg: i = 3; l = 0; u = 255;
break;
3258 case SystemZ::BI__builtin_s390_vfaeb:
3259 case SystemZ::BI__builtin_s390_vfaeh:
3260 case SystemZ::BI__builtin_s390_vfaef:
3261 case SystemZ::BI__builtin_s390_vfaebs:
3262 case SystemZ::BI__builtin_s390_vfaehs:
3263 case SystemZ::BI__builtin_s390_vfaefs:
3264 case SystemZ::BI__builtin_s390_vfaezb:
3265 case SystemZ::BI__builtin_s390_vfaezh:
3266 case SystemZ::BI__builtin_s390_vfaezf:
3267 case SystemZ::BI__builtin_s390_vfaezbs:
3268 case SystemZ::BI__builtin_s390_vfaezhs:
3269 case SystemZ::BI__builtin_s390_vfaezfs: i = 2; l = 0; u = 15;
break;
3270 case SystemZ::BI__builtin_s390_vfisb:
3271 case SystemZ::BI__builtin_s390_vfidb:
3272 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15) ||
3273 SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
3274 case SystemZ::BI__builtin_s390_vftcisb:
3275 case SystemZ::BI__builtin_s390_vftcidb: i = 1; l = 0; u = 4095;
break;
3276 case SystemZ::BI__builtin_s390_vlbb: i = 1; l = 0; u = 15;
break;
3277 case SystemZ::BI__builtin_s390_vpdi: i = 2; l = 0; u = 15;
break;
3278 case SystemZ::BI__builtin_s390_vsldb: i = 2; l = 0; u = 15;
break;
3279 case SystemZ::BI__builtin_s390_vstrcb:
3280 case SystemZ::BI__builtin_s390_vstrch:
3281 case SystemZ::BI__builtin_s390_vstrcf:
3282 case SystemZ::BI__builtin_s390_vstrczb:
3283 case SystemZ::BI__builtin_s390_vstrczh:
3284 case SystemZ::BI__builtin_s390_vstrczf:
3285 case SystemZ::BI__builtin_s390_vstrcbs:
3286 case SystemZ::BI__builtin_s390_vstrchs:
3287 case SystemZ::BI__builtin_s390_vstrcfs:
3288 case SystemZ::BI__builtin_s390_vstrczbs:
3289 case SystemZ::BI__builtin_s390_vstrczhs:
3290 case SystemZ::BI__builtin_s390_vstrczfs: i = 3; l = 0; u = 15;
break;
3291 case SystemZ::BI__builtin_s390_vmslg: i = 3; l = 0; u = 15;
break;
3292 case SystemZ::BI__builtin_s390_vfminsb:
3293 case SystemZ::BI__builtin_s390_vfmaxsb:
3294 case SystemZ::BI__builtin_s390_vfmindb:
3295 case SystemZ::BI__builtin_s390_vfmaxdb: i = 2; l = 0; u = 15;
break;
3296 case SystemZ::BI__builtin_s390_vsld: i = 2; l = 0; u = 7;
break;
3297 case SystemZ::BI__builtin_s390_vsrd: i = 2; l = 0; u = 7;
break;
3299 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3310 return S.
Diag(TheCall->
getBeginLoc(), diag::err_expr_not_string_literal)
3330 return S.
Diag(TheCall->
getBeginLoc(), diag::err_expr_not_string_literal)
3343 bool Sema::CheckX86BuiltinRoundingOrSAE(
unsigned BuiltinID,
CallExpr *TheCall) {
3347 unsigned ArgNum = 0;
3348 switch (BuiltinID) {
3351 case X86::BI__builtin_ia32_vcvttsd2si32:
3352 case X86::BI__builtin_ia32_vcvttsd2si64:
3353 case X86::BI__builtin_ia32_vcvttsd2usi32:
3354 case X86::BI__builtin_ia32_vcvttsd2usi64:
3355 case X86::BI__builtin_ia32_vcvttss2si32:
3356 case X86::BI__builtin_ia32_vcvttss2si64:
3357 case X86::BI__builtin_ia32_vcvttss2usi32:
3358 case X86::BI__builtin_ia32_vcvttss2usi64:
3361 case X86::BI__builtin_ia32_maxpd512:
3362 case X86::BI__builtin_ia32_maxps512:
3363 case X86::BI__builtin_ia32_minpd512:
3364 case X86::BI__builtin_ia32_minps512:
3367 case X86::BI__builtin_ia32_cvtps2pd512_mask:
3368 case X86::BI__builtin_ia32_cvttpd2dq512_mask:
3369 case X86::BI__builtin_ia32_cvttpd2qq512_mask:
3370 case X86::BI__builtin_ia32_cvttpd2udq512_mask:
3371 case X86::BI__builtin_ia32_cvttpd2uqq512_mask:
3372 case X86::BI__builtin_ia32_cvttps2dq512_mask:
3373 case X86::BI__builtin_ia32_cvttps2qq512_mask:
3374 case X86::BI__builtin_ia32_cvttps2udq512_mask:
3375 case X86::BI__builtin_ia32_cvttps2uqq512_mask:
3376 case X86::BI__builtin_ia32_exp2pd_mask:
3377 case X86::BI__builtin_ia32_exp2ps_mask:
3378 case X86::BI__builtin_ia32_getexppd512_mask:
3379 case X86::BI__builtin_ia32_getexpps512_mask:
3380 case X86::BI__builtin_ia32_rcp28pd_mask:
3381 case X86::BI__builtin_ia32_rcp28ps_mask:
3382 case X86::BI__builtin_ia32_rsqrt28pd_mask:
3383 case X86::BI__builtin_ia32_rsqrt28ps_mask:
3384 case X86::BI__builtin_ia32_vcomisd:
3385 case X86::BI__builtin_ia32_vcomiss:
3386 case X86::BI__builtin_ia32_vcvtph2ps512_mask:
3389 case X86::BI__builtin_ia32_cmppd512_mask:
3390 case X86::BI__builtin_ia32_cmpps512_mask:
3391 case X86::BI__builtin_ia32_cmpsd_mask:
3392 case X86::BI__builtin_ia32_cmpss_mask:
3393 case X86::BI__builtin_ia32_cvtss2sd_round_mask:
3394 case X86::BI__builtin_ia32_getexpsd128_round_mask:
3395 case X86::BI__builtin_ia32_getexpss128_round_mask:
3396 case X86::BI__builtin_ia32_getmantpd512_mask:
3397 case X86::BI__builtin_ia32_getmantps512_mask:
3398 case X86::BI__builtin_ia32_maxsd_round_mask:
3399 case X86::BI__builtin_ia32_maxss_round_mask:
3400 case X86::BI__builtin_ia32_minsd_round_mask:
3401 case X86::BI__builtin_ia32_minss_round_mask:
3402 case X86::BI__builtin_ia32_rcp28sd_round_mask:
3403 case X86::BI__builtin_ia32_rcp28ss_round_mask:
3404 case X86::BI__builtin_ia32_reducepd512_mask:
3405 case X86::BI__builtin_ia32_reduceps512_mask:
3406 case X86::BI__builtin_ia32_rndscalepd_mask:
3407 case X86::BI__builtin_ia32_rndscaleps_mask:
3408 case X86::BI__builtin_ia32_rsqrt28sd_round_mask:
3409 case X86::BI__builtin_ia32_rsqrt28ss_round_mask:
3412 case X86::BI__builtin_ia32_fixupimmpd512_mask:
3413 case X86::BI__builtin_ia32_fixupimmpd512_maskz:
3414 case X86::BI__builtin_ia32_fixupimmps512_mask:
3415 case X86::BI__builtin_ia32_fixupimmps512_maskz:
3416 case X86::BI__builtin_ia32_fixupimmsd_mask:
3417 case X86::BI__builtin_ia32_fixupimmsd_maskz:
3418 case X86::BI__builtin_ia32_fixupimmss_mask:
3419 case X86::BI__builtin_ia32_fixupimmss_maskz:
3420 case X86::BI__builtin_ia32_getmantsd_round_mask:
3421 case X86::BI__builtin_ia32_getmantss_round_mask:
3422 case X86::BI__builtin_ia32_rangepd512_mask:
3423 case X86::BI__builtin_ia32_rangeps512_mask:
3424 case X86::BI__builtin_ia32_rangesd128_round_mask:
3425 case X86::BI__builtin_ia32_rangess128_round_mask:
3426 case X86::BI__builtin_ia32_reducesd_mask:
3427 case X86::BI__builtin_ia32_reducess_mask:
3428 case X86::BI__builtin_ia32_rndscalesd_round_mask:
3429 case X86::BI__builtin_ia32_rndscaless_round_mask:
3432 case X86::BI__builtin_ia32_vcvtsd2si64:
3433 case X86::BI__builtin_ia32_vcvtsd2si32:
3434 case X86::BI__builtin_ia32_vcvtsd2usi32:
3435 case X86::BI__builtin_ia32_vcvtsd2usi64:
3436 case X86::BI__builtin_ia32_vcvtss2si32:
3437 case X86::BI__builtin_ia32_vcvtss2si64:
3438 case X86::BI__builtin_ia32_vcvtss2usi32:
3439 case X86::BI__builtin_ia32_vcvtss2usi64:
3440 case X86::BI__builtin_ia32_sqrtpd512:
3441 case X86::BI__builtin_ia32_sqrtps512:
3445 case X86::BI__builtin_ia32_addpd512:
3446 case X86::BI__builtin_ia32_addps512:
3447 case X86::BI__builtin_ia32_divpd512:
3448 case X86::BI__builtin_ia32_divps512:
3449 case X86::BI__builtin_ia32_mulpd512:
3450 case X86::BI__builtin_ia32_mulps512:
3451 case X86::BI__builtin_ia32_subpd512:
3452 case X86::BI__builtin_ia32_subps512:
3453 case X86::BI__builtin_ia32_cvtsi2sd64:
3454 case X86::BI__builtin_ia32_cvtsi2ss32:
3455 case X86::BI__builtin_ia32_cvtsi2ss64:
3456 case X86::BI__builtin_ia32_cvtusi2sd64:
3457 case X86::BI__builtin_ia32_cvtusi2ss32:
3458 case X86::BI__builtin_ia32_cvtusi2ss64:
3462 case X86::BI__builtin_ia32_cvtdq2ps512_mask:
3463 case X86::BI__builtin_ia32_cvtudq2ps512_mask:
3464 case X86::BI__builtin_ia32_cvtpd2ps512_mask:
3465 case X86::BI__builtin_ia32_cvtpd2dq512_mask:
3466 case X86::BI__builtin_ia32_cvtpd2qq512_mask:
3467 case X86::BI__builtin_ia32_cvtpd2udq512_mask:
3468 case X86::BI__builtin_ia32_cvtpd2uqq512_mask:
3469 case X86::BI__builtin_ia32_cvtps2dq512_mask:
3470 case X86::BI__builtin_ia32_cvtps2qq512_mask:
3471 case X86::BI__builtin_ia32_cvtps2udq512_mask:
3472 case X86::BI__builtin_ia32_cvtps2uqq512_mask:
3473 case X86::BI__builtin_ia32_cvtqq2pd512_mask:
3474 case X86::BI__builtin_ia32_cvtqq2ps512_mask:
3475 case X86::BI__builtin_ia32_cvtuqq2pd512_mask:
3476 case X86::BI__builtin_ia32_cvtuqq2ps512_mask:
3480 case X86::BI__builtin_ia32_addss_round_mask:
3481 case X86::BI__builtin_ia32_addsd_round_mask:
3482 case X86::BI__builtin_ia32_divss_round_mask:
3483 case X86::BI__builtin_ia32_divsd_round_mask:
3484 case X86::BI__builtin_ia32_mulss_round_mask:
3485 case X86::BI__builtin_ia32_mulsd_round_mask:
3486 case X86::BI__builtin_ia32_subss_round_mask:
3487 case X86::BI__builtin_ia32_subsd_round_mask:
3488 case X86::BI__builtin_ia32_scalefpd512_mask:
3489 case X86::BI__builtin_ia32_scalefps512_mask:
3490 case X86::BI__builtin_ia32_scalefsd_round_mask:
3491 case X86::BI__builtin_ia32_scalefss_round_mask:
3492 case X86::BI__builtin_ia32_cvtsd2ss_round_mask:
3493 case X86::BI__builtin_ia32_sqrtsd_round_mask:
3494 case X86::BI__builtin_ia32_sqrtss_round_mask:
3495 case X86::BI__builtin_ia32_vfmaddsd3_mask:
3496 case X86::BI__builtin_ia32_vfmaddsd3_maskz:
3497 case X86::BI__builtin_ia32_vfmaddsd3_mask3:
3498 case X86::BI__builtin_ia32_vfmaddss3_mask:
3499 case X86::BI__builtin_ia32_vfmaddss3_maskz:
3500 case X86::BI__builtin_ia32_vfmaddss3_mask3:
3501 case X86::BI__builtin_ia32_vfmaddpd512_mask:
3502 case X86::BI__builtin_ia32_vfmaddpd512_maskz:
3503 case X86::BI__builtin_ia32_vfmaddpd512_mask3:
3504 case X86::BI__builtin_ia32_vfmsubpd512_mask3:
3505 case X86::BI__builtin_ia32_vfmaddps512_mask:
3506 case X86::BI__builtin_ia32_vfmaddps512_maskz:
3507 case X86::BI__builtin_ia32_vfmaddps512_mask3:
3508 case X86::BI__builtin_ia32_vfmsubps512_mask3:
3509 case X86::BI__builtin_ia32_vfmaddsubpd512_mask:
3510 case X86::BI__builtin_ia32_vfmaddsubpd512_maskz:
3511 case X86::BI__builtin_ia32_vfmaddsubpd512_mask3:
3512 case X86::BI__builtin_ia32_vfmsubaddpd512_mask3:
3513 case X86::BI__builtin_ia32_vfmaddsubps512_mask:
3514 case X86::BI__builtin_ia32_vfmaddsubps512_maskz:
3515 case X86::BI__builtin_ia32_vfmaddsubps512_mask3:
3516 case X86::BI__builtin_ia32_vfmsubaddps512_mask3:
3522 llvm::APSInt Result;
3530 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
3538 (HasRC && Result.getZExtValue() >= 8 && Result.getZExtValue() <= 11))
3541 return Diag(TheCall->
getBeginLoc(), diag::err_x86_builtin_invalid_rounding)
3546 bool Sema::CheckX86BuiltinGatherScatterScale(
unsigned BuiltinID,
3548 unsigned ArgNum = 0;
3549 switch (BuiltinID) {
3552 case X86::BI__builtin_ia32_gatherpfdpd:
3553 case X86::BI__builtin_ia32_gatherpfdps:
3554 case X86::BI__builtin_ia32_gatherpfqpd:
3555 case X86::BI__builtin_ia32_gatherpfqps:
3556 case X86::BI__builtin_ia32_scatterpfdpd:
3557 case X86::BI__builtin_ia32_scatterpfdps:
3558 case X86::BI__builtin_ia32_scatterpfqpd:
3559 case X86::BI__builtin_ia32_scatterpfqps:
3562 case X86::BI__builtin_ia32_gatherd_pd:
3563 case X86::BI__builtin_ia32_gatherd_pd256:
3564 case X86::BI__builtin_ia32_gatherq_pd:
3565 case X86::BI__builtin_ia32_gatherq_pd256:
3566 case X86::BI__builtin_ia32_gatherd_ps:
3567 case X86::BI__builtin_ia32_gatherd_ps256:
3568 case X86::BI__builtin_ia32_gatherq_ps:
3569 case X86::BI__builtin_ia32_gatherq_ps256:
3570 case X86::BI__builtin_ia32_gatherd_q:
3571 case X86::BI__builtin_ia32_gatherd_q256:
3572 case X86::BI__builtin_ia32_gatherq_q:
3573 case X86::BI__builtin_ia32_gatherq_q256:
3574 case X86::BI__builtin_ia32_gatherd_d:
3575 case X86::BI__builtin_ia32_gatherd_d256:
3576 case X86::BI__builtin_ia32_gatherq_d:
3577 case X86::BI__builtin_ia32_gatherq_d256:
3578 case X86::BI__builtin_ia32_gather3div2df:
3579 case X86::BI__builtin_ia32_gather3div2di:
3580 case X86::BI__builtin_ia32_gather3div4df:
3581 case X86::BI__builtin_ia32_gather3div4di:
3582 case X86::BI__builtin_ia32_gather3div4sf:
3583 case X86::BI__builtin_ia32_gather3div4si:
3584 case X86::BI__builtin_ia32_gather3div8sf:
3585 case X86::BI__builtin_ia32_gather3div8si:
3586 case X86::BI__builtin_ia32_gather3siv2df:
3587 case X86::BI__builtin_ia32_gather3siv2di:
3588 case X86::BI__builtin_ia32_gather3siv4df:
3589 case X86::BI__builtin_ia32_gather3siv4di:
3590 case X86::BI__builtin_ia32_gather3siv4sf:
3591 case X86::BI__builtin_ia32_gather3siv4si:
3592 case X86::BI__builtin_ia32_gather3siv8sf:
3593 case X86::BI__builtin_ia32_gather3siv8si:
3594 case X86::BI__builtin_ia32_gathersiv8df:
3595 case X86::BI__builtin_ia32_gathersiv16sf:
3596 case X86::BI__builtin_ia32_gatherdiv8df:
3597 case X86::BI__builtin_ia32_gatherdiv16sf:
3598 case X86::BI__builtin_ia32_gathersiv8di:
3599 case X86::BI__builtin_ia32_gathersiv16si:
3600 case X86::BI__builtin_ia32_gatherdiv8di:
3601 case X86::BI__builtin_ia32_gatherdiv16si:
3602 case X86::BI__builtin_ia32_scatterdiv2df:
3603 case X86::BI__builtin_ia32_scatterdiv2di:
3604 case X86::BI__builtin_ia32_scatterdiv4df:
3605 case X86::BI__builtin_ia32_scatterdiv4di:
3606 case X86::BI__builtin_ia32_scatterdiv4sf:
3607 case X86::BI__builtin_ia32_scatterdiv4si:
3608 case X86::BI__builtin_ia32_scatterdiv8sf:
3609 case X86::BI__builtin_ia32_scatterdiv8si:
3610 case X86::BI__builtin_ia32_scattersiv2df:
3611 case X86::BI__builtin_ia32_scattersiv2di:
3612 case X86::BI__builtin_ia32_scattersiv4df:
3613 case X86::BI__builtin_ia32_scattersiv4di:
3614 case X86::BI__builtin_ia32_scattersiv4sf:
3615 case X86::BI__builtin_ia32_scattersiv4si:
3616 case X86::BI__builtin_ia32_scattersiv8sf:
3617 case X86::BI__builtin_ia32_scattersiv8si:
3618 case X86::BI__builtin_ia32_scattersiv8df:
3619 case X86::BI__builtin_ia32_scattersiv16sf:
3620 case X86::BI__builtin_ia32_scatterdiv8df:
3621 case X86::BI__builtin_ia32_scatterdiv16sf:
3622 case X86::BI__builtin_ia32_scattersiv8di:
3623 case X86::BI__builtin_ia32_scattersiv16si:
3624 case X86::BI__builtin_ia32_scatterdiv8di:
3625 case X86::BI__builtin_ia32_scatterdiv16si:
3630 llvm::APSInt Result;
3638 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
3641 if (Result == 1 || Result == 2 || Result == 4 || Result == 8)
3644 return Diag(TheCall->
getBeginLoc(), diag::err_x86_builtin_invalid_scale)
3650 switch (BuiltinID) {
3651 case X86::BI__builtin_ia32_readeflags_u32:
3652 case X86::BI__builtin_ia32_writeeflags_u32:
3659 bool Sema::CheckX86BuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
3660 if (BuiltinID == X86::BI__builtin_cpu_supports)
3663 if (BuiltinID == X86::BI__builtin_cpu_is)
3670 diag::err_32_bit_builtin_64_bit_tgt);
3673 if (CheckX86BuiltinRoundingOrSAE(BuiltinID, TheCall))
3677 if (CheckX86BuiltinGatherScatterScale(BuiltinID, TheCall))
3682 int i = 0, l = 0, u = 0;
3683 switch (BuiltinID) {
3686 case X86::BI__builtin_ia32_vec_ext_v2si:
3687 case X86::BI__builtin_ia32_vec_ext_v2di:
3688 case X86::BI__builtin_ia32_vextractf128_pd256:
3689 case X86::BI__builtin_ia32_vextractf128_ps256:
3690 case X86::BI__builtin_ia32_vextractf128_si256:
3691 case X86::BI__builtin_ia32_extract128i256:
3692 case X86::BI__builtin_ia32_extractf64x4_mask:
3693 case X86::BI__builtin_ia32_extracti64x4_mask:
3694 case X86::BI__builtin_ia32_extractf32x8_mask:
3695 case X86::BI__builtin_ia32_extracti32x8_mask:
3696 case X86::BI__builtin_ia32_extractf64x2_256_mask:
3697 case X86::BI__builtin_ia32_extracti64x2_256_mask:
3698 case X86::BI__builtin_ia32_extractf32x4_256_mask:
3699 case X86::BI__builtin_ia32_extracti32x4_256_mask:
3700 i = 1; l = 0; u = 1;
3702 case X86::BI__builtin_ia32_vec_set_v2di:
3703 case X86::BI__builtin_ia32_vinsertf128_pd256:
3704 case X86::BI__builtin_ia32_vinsertf128_ps256:
3705 case X86::BI__builtin_ia32_vinsertf128_si256:
3706 case X86::BI__builtin_ia32_insert128i256:
3707 case X86::BI__builtin_ia32_insertf32x8:
3708 case X86::BI__builtin_ia32_inserti32x8:
3709 case X86::BI__builtin_ia32_insertf64x4:
3710 case X86::BI__builtin_ia32_inserti64x4:
3711 case X86::BI__builtin_ia32_insertf64x2_256:
3712 case X86::BI__builtin_ia32_inserti64x2_256:
3713 case X86::BI__builtin_ia32_insertf32x4_256:
3714 case X86::BI__builtin_ia32_inserti32x4_256:
3715 i = 2; l = 0; u = 1;
3717 case X86::BI__builtin_ia32_vpermilpd:
3718 case X86::BI__builtin_ia32_vec_ext_v4hi:
3719 case X86::BI__builtin_ia32_vec_ext_v4si:
3720 case X86::BI__builtin_ia32_vec_ext_v4sf:
3721 case X86::BI__builtin_ia32_vec_ext_v4di:
3722 case X86::BI__builtin_ia32_extractf32x4_mask:
3723 case X86::BI__builtin_ia32_extracti32x4_mask:
3724 case X86::BI__builtin_ia32_extractf64x2_512_mask:
3725 case X86::BI__builtin_ia32_extracti64x2_512_mask:
3726 i = 1; l = 0; u = 3;
3728 case X86::BI_mm_prefetch:
3729 case X86::BI__builtin_ia32_vec_ext_v8hi:
3730 case X86::BI__builtin_ia32_vec_ext_v8si:
3731 i = 1; l = 0; u = 7;
3733 case X86::BI__builtin_ia32_sha1rnds4:
3734 case X86::BI__builtin_ia32_blendpd:
3735 case X86::BI__builtin_ia32_shufpd:
3736 case X86::BI__builtin_ia32_vec_set_v4hi:
3737 case X86::BI__builtin_ia32_vec_set_v4si:
3738 case X86::BI__builtin_ia32_vec_set_v4di:
3739 case X86::BI__builtin_ia32_shuf_f32x4_256:
3740 case X86::BI__builtin_ia32_shuf_f64x2_256:
3741 case X86::BI__builtin_ia32_shuf_i32x4_256:
3742 case X86::BI__builtin_ia32_shuf_i64x2_256:
3743 case X86::BI__builtin_ia32_insertf64x2_512:
3744 case X86::BI__builtin_ia32_inserti64x2_512:
3745 case X86::BI__builtin_ia32_insertf32x4:
3746 case X86::BI__builtin_ia32_inserti32x4:
3747 i = 2; l = 0; u = 3;
3749 case X86::BI__builtin_ia32_vpermil2pd:
3750 case X86::BI__builtin_ia32_vpermil2pd256:
3751 case X86::BI__builtin_ia32_vpermil2ps:
3752 case X86::BI__builtin_ia32_vpermil2ps256:
3753 i = 3; l = 0; u = 3;
3755 case X86::BI__builtin_ia32_cmpb128_mask:
3756 case X86::BI__builtin_ia32_cmpw128_mask:
3757 case X86::BI__builtin_ia32_cmpd128_mask:
3758 case X86::BI__builtin_ia32_cmpq128_mask:
3759 case X86::BI__builtin_ia32_cmpb256_mask:
3760 case X86::BI__builtin_ia32_cmpw256_mask:
3761 case X86::BI__builtin_ia32_cmpd256_mask:
3762 case X86::BI__builtin_ia32_cmpq256_mask:
3763 case X86::BI__builtin_ia32_cmpb512_mask:
3764 case X86::BI__builtin_ia32_cmpw512_mask:
3765 case X86::BI__builtin_ia32_cmpd512_mask:
3766 case X86::BI__builtin_ia32_cmpq512_mask:
3767 case X86::BI__builtin_ia32_ucmpb128_mask:
3768 case X86::BI__builtin_ia32_ucmpw128_mask:
3769 case X86::BI__builtin_ia32_ucmpd128_mask:
3770 case X86::BI__builtin_ia32_ucmpq128_mask:
3771 case X86::BI__builtin_ia32_ucmpb256_mask:
3772 case X86::BI__builtin_ia32_ucmpw256_mask:
3773 case X86::BI__builtin_ia32_ucmpd256_mask:
3774 case X86::BI__builtin_ia32_ucmpq256_mask:
3775 case X86::BI__builtin_ia32_ucmpb512_mask:
3776 case X86::BI__builtin_ia32_ucmpw512_mask:
3777 case X86::BI__builtin_ia32_ucmpd512_mask:
3778 case X86::BI__builtin_ia32_ucmpq512_mask:
3779 case X86::BI__builtin_ia32_vpcomub:
3780 case X86::BI__builtin_ia32_vpcomuw:
3781 case X86::BI__builtin_ia32_vpcomud:
3782 case X86::BI__builtin_ia32_vpcomuq:
3783 case X86::BI__builtin_ia32_vpcomb:
3784 case X86::BI__builtin_ia32_vpcomw:
3785 case X86::BI__builtin_ia32_vpcomd:
3786 case X86::BI__builtin_ia32_vpcomq:
3787 case X86::BI__builtin_ia32_vec_set_v8hi:
3788 case X86::BI__builtin_ia32_vec_set_v8si:
3789 i = 2; l = 0; u = 7;
3791 case X86::BI__builtin_ia32_vpermilpd256:
3792 case X86::BI__builtin_ia32_roundps:
3793 case X86::BI__builtin_ia32_roundpd:
3794 case X86::BI__builtin_ia32_roundps256:
3795 case X86::BI__builtin_ia32_roundpd256:
3796 case X86::BI__builtin_ia32_getmantpd128_mask:
3797 case X86::BI__builtin_ia32_getmantpd256_mask:
3798 case X86::BI__builtin_ia32_getmantps128_mask:
3799 case X86::BI__builtin_ia32_getmantps256_mask:
3800 case X86::BI__builtin_ia32_getmantpd512_mask:
3801 case X86::BI__builtin_ia32_getmantps512_mask:
3802 case X86::BI__builtin_ia32_vec_ext_v16qi:
3803 case X86::BI__builtin_ia32_vec_ext_v16hi:
3804 i = 1; l = 0; u = 15;
3806 case X86::BI__builtin_ia32_pblendd128:
3807 case X86::BI__builtin_ia32_blendps:
3808 case X86::BI__builtin_ia32_blendpd256:
3809 case X86::BI__builtin_ia32_shufpd256:
3810 case X86::BI__builtin_ia32_roundss:
3811 case X86::BI__builtin_ia32_roundsd:
3812 case X86::BI__builtin_ia32_rangepd128_mask:
3813 case X86::BI__builtin_ia32_rangepd256_mask:
3814 case X86::BI__builtin_ia32_rangepd512_mask:
3815 case X86::BI__builtin_ia32_rangeps128_mask:
3816 case X86::BI__builtin_ia32_rangeps256_mask:
3817 case X86::BI__builtin_ia32_rangeps512_mask:
3818 case X86::BI__builtin_ia32_getmantsd_round_mask:
3819 case X86::BI__builtin_ia32_getmantss_round_mask:
3820 case X86::BI__builtin_ia32_vec_set_v16qi:
3821 case X86::BI__builtin_ia32_vec_set_v16hi:
3822 i = 2; l = 0; u = 15;
3824 case X86::BI__builtin_ia32_vec_ext_v32qi:
3825 i = 1; l = 0; u = 31;
3827 case X86::BI__builtin_ia32_cmpps:
3828 case X86::BI__builtin_ia32_cmpss:
3829 case X86::BI__builtin_ia32_cmppd:
3830 case X86::BI__builtin_ia32_cmpsd:
3831 case X86::BI__builtin_ia32_cmpps256:
3832 case X86::BI__builtin_ia32_cmppd256:
3833 case X86::BI__builtin_ia32_cmpps128_mask:
3834 case X86::BI__builtin_ia32_cmppd128_mask:
3835 case X86::BI__builtin_ia32_cmpps256_mask:
3836 case X86::BI__builtin_ia32_cmppd256_mask:
3837 case X86::BI__builtin_ia32_cmpps512_mask:
3838 case X86::BI__builtin_ia32_cmppd512_mask:
3839 case X86::BI__builtin_ia32_cmpsd_mask:
3840 case X86::BI__builtin_ia32_cmpss_mask:
3841 case X86::BI__builtin_ia32_vec_set_v32qi:
3842 i = 2; l = 0; u = 31;
3844 case X86::BI__builtin_ia32_permdf256:
3845 case X86::BI__builtin_ia32_permdi256:
3846 case X86::BI__builtin_ia32_permdf512:
3847 case X86::BI__builtin_ia32_permdi512:
3848 case X86::BI__builtin_ia32_vpermilps:
3849 case X86::BI__builtin_ia32_vpermilps256:
3850 case X86::BI__builtin_ia32_vpermilpd512:
3851 case X86::BI__builtin_ia32_vpermilps512:
3852 case X86::BI__builtin_ia32_pshufd:
3853 case X86::BI__builtin_ia32_pshufd256:
3854 case X86::BI__builtin_ia32_pshufd512:
3855 case X86::BI__builtin_ia32_pshufhw:
3856 case X86::BI__builtin_ia32_pshufhw256:
3857 case X86::BI__builtin_ia32_pshufhw512:
3858 case X86::BI__builtin_ia32_pshuflw:
3859 case X86::BI__builtin_ia32_pshuflw256:
3860 case X86::BI__builtin_ia32_pshuflw512:
3861 case X86::BI__builtin_ia32_vcvtps2ph:
3862 case X86::BI__builtin_ia32_vcvtps2ph_mask:
3863 case X86::BI__builtin_ia32_vcvtps2ph256:
3864 case X86::BI__builtin_ia32_vcvtps2ph256_mask:
3865 case X86::BI__builtin_ia32_vcvtps2ph512_mask:
3866 case X86::BI__builtin_ia32_rndscaleps_128_mask:
3867 case X86::BI__builtin_ia32_rndscalepd_128_mask:
3868 case X86::BI__builtin_ia32_rndscaleps_256_mask:
3869 case X86::BI__builtin_ia32_rndscalepd_256_mask:
3870 case X86::BI__builtin_ia32_rndscaleps_mask:
3871 case X86::BI__builtin_ia32_rndscalepd_mask:
3872 case X86::BI__builtin_ia32_reducepd128_mask:
3873 case X86::BI__builtin_ia32_reducepd256_mask:
3874 case X86::BI__builtin_ia32_reducepd512_mask:
3875 case X86::BI__builtin_ia32_reduceps128_mask:
3876 case X86::BI__builtin_ia32_reduceps256_mask:
3877 case X86::BI__builtin_ia32_reduceps512_mask:
3878 case X86::BI__builtin_ia32_prold512:
3879 case X86::BI__builtin_ia32_prolq512:
3880 case X86::BI__builtin_ia32_prold128:
3881 case X86::BI__builtin_ia32_prold256:
3882 case X86::BI__builtin_ia32_prolq128:
3883 case X86::BI__builtin_ia32_prolq256:
3884 case X86::BI__builtin_ia32_prord512:
3885 case X86::BI__builtin_ia32_prorq512:
3886 case X86::BI__builtin_ia32_prord128:
3887 case X86::BI__builtin_ia32_prord256:
3888 case X86::BI__builtin_ia32_prorq128:
3889 case X86::BI__builtin_ia32_prorq256:
3890 case X86::BI__builtin_ia32_fpclasspd128_mask:
3891 case X86::BI__builtin_ia32_fpclasspd256_mask:
3892 case X86::BI__builtin_ia32_fpclassps128_mask:
3893 case X86::BI__builtin_ia32_fpclassps256_mask:
3894 case X86::BI__builtin_ia32_fpclassps512_mask:
3895 case X86::BI__builtin_ia32_fpclasspd512_mask:
3896 case X86::BI__builtin_ia32_fpclasssd_mask:
3897 case X86::BI__builtin_ia32_fpclassss_mask:
3898 case X86::BI__builtin_ia32_pslldqi128_byteshift:
3899 case X86::BI__builtin_ia32_pslldqi256_byteshift:
3900 case X86::BI__builtin_ia32_pslldqi512_byteshift:
3901 case X86::BI__builtin_ia32_psrldqi128_byteshift:
3902 case X86::BI__builtin_ia32_psrldqi256_byteshift:
3903 case X86::BI__builtin_ia32_psrldqi512_byteshift:
3904 case X86::BI__builtin_ia32_kshiftliqi:
3905 case X86::BI__builtin_ia32_kshiftlihi:
3906 case X86::BI__builtin_ia32_kshiftlisi:
3907 case X86::BI__builtin_ia32_kshiftlidi:
3908 case X86::BI__builtin_ia32_kshiftriqi:
3909 case X86::BI__builtin_ia32_kshiftrihi:
3910 case X86::BI__builtin_ia32_kshiftrisi:
3911 case X86::BI__builtin_ia32_kshiftridi:
3912 i = 1; l = 0; u = 255;
3914 case X86::BI__builtin_ia32_vperm2f128_pd256:
3915 case X86::BI__builtin_ia32_vperm2f128_ps256:
3916 case X86::BI__builtin_ia32_vperm2f128_si256:
3917 case X86::BI__builtin_ia32_permti256:
3918 case X86::BI__builtin_ia32_pblendw128:
3919 case X86::BI__builtin_ia32_pblendw256:
3920 case X86::BI__builtin_ia32_blendps256:
3921 case X86::BI__builtin_ia32_pblendd256:
3922 case X86::BI__builtin_ia32_palignr128:
3923 case X86::BI__builtin_ia32_palignr256:
3924 case X86::BI__builtin_ia32_palignr512:
3925 case X86::BI__builtin_ia32_alignq512:
3926 case X86::BI__builtin_ia32_alignd512:
3927 case X86::BI__builtin_ia32_alignd128:
3928 case X86::BI__builtin_ia32_alignd256:
3929 case X86::BI__builtin_ia32_alignq128:
3930 case X86::BI__builtin_ia32_alignq256:
3931 case X86::BI__builtin_ia32_vcomisd:
3932 case X86::BI__builtin_ia32_vcomiss:
3933 case X86::BI__builtin_ia32_shuf_f32x4:
3934 case X86::BI__builtin_ia32_shuf_f64x2:
3935 case X86::BI__builtin_ia32_shuf_i32x4:
3936 case X86::BI__builtin_ia32_shuf_i64x2:
3937 case X86::BI__builtin_ia32_shufpd512:
3938 case X86::BI__builtin_ia32_shufps:
3939 case X86::BI__builtin_ia32_shufps256:
3940 case X86::BI__builtin_ia32_shufps512:
3941 case X86::BI__builtin_ia32_dbpsadbw128:
3942 case X86::BI__builtin_ia32_dbpsadbw256:
3943 case X86::BI__builtin_ia32_dbpsadbw512:
3944 case X86::BI__builtin_ia32_vpshldd128:
3945 case X86::BI__builtin_ia32_vpshldd256:
3946 case X86::BI__builtin_ia32_vpshldd512:
3947 case X86::BI__builtin_ia32_vpshldq128:
3948 case X86::BI__builtin_ia32_vpshldq256:
3949 case X86::BI__builtin_ia32_vpshldq512:
3950 case X86::BI__builtin_ia32_vpshldw128:
3951 case X86::BI__builtin_ia32_vpshldw256:
3952 case X86::BI__builtin_ia32_vpshldw512:
3953 case X86::BI__builtin_ia32_vpshrdd128:
3954 case X86::BI__builtin_ia32_vpshrdd256:
3955 case X86::BI__builtin_ia32_vpshrdd512:
3956 case X86::BI__builtin_ia32_vpshrdq128:
3957 case X86::BI__builtin_ia32_vpshrdq256:
3958 case X86::BI__builtin_ia32_vpshrdq512:
3959 case X86::BI__builtin_ia32_vpshrdw128:
3960 case X86::BI__builtin_ia32_vpshrdw256:
3961 case X86::BI__builtin_ia32_vpshrdw512:
3962 i = 2; l = 0; u = 255;
3964 case X86::BI__builtin_ia32_fixupimmpd512_mask:
3965 case X86::BI__builtin_ia32_fixupimmpd512_maskz:
3966 case X86::BI__builtin_ia32_fixupimmps512_mask:
3967 case X86::BI__builtin_ia32_fixupimmps512_maskz:
3968 case X86::BI__builtin_ia32_fixupimmsd_mask:
3969 case X86::BI__builtin_ia32_fixupimmsd_maskz:
3970 case X86::BI__builtin_ia32_fixupimmss_mask:
3971 case X86::BI__builtin_ia32_fixupimmss_maskz:
3972 case X86::BI__builtin_ia32_fixupimmpd128_mask:
3973 case X86::BI__builtin_ia32_fixupimmpd128_maskz:
3974 case X86::BI__builtin_ia32_fixupimmpd256_mask:
3975 case X86::BI__builtin_ia32_fixupimmpd256_maskz:
3976 case X86::BI__builtin_ia32_fixupimmps128_mask:
3977 case X86::BI__builtin_ia32_fixupimmps128_maskz:
3978 case X86::BI__builtin_ia32_fixupimmps256_mask:
3979 case X86::BI__builtin_ia32_fixupimmps256_maskz:
3980 case X86::BI__builtin_ia32_pternlogd512_mask:
3981 case X86::BI__builtin_ia32_pternlogd512_maskz:
3982 case X86::BI__builtin_ia32_pternlogq512_mask:
3983 case X86::BI__builtin_ia32_pternlogq512_maskz:
3984 case X86::BI__builtin_ia32_pternlogd128_mask:
3985 case X86::BI__builtin_ia32_pternlogd128_maskz:
3986 case X86::BI__builtin_ia32_pternlogd256_mask:
3987 case X86::BI__builtin_ia32_pternlogd256_maskz:
3988 case X86::BI__builtin_ia32_pternlogq128_mask:
3989 case X86::BI__builtin_ia32_pternlogq128_maskz:
3990 case X86::BI__builtin_ia32_pternlogq256_mask:
3991 case X86::BI__builtin_ia32_pternlogq256_maskz:
3992 i = 3; l = 0; u = 255;
3994 case X86::BI__builtin_ia32_gatherpfdpd:
3995 case X86::BI__builtin_ia32_gatherpfdps:
3996 case X86::BI__builtin_ia32_gatherpfqpd:
3997 case X86::BI__builtin_ia32_gatherpfqps:
3998 case X86::BI__builtin_ia32_scatterpfdpd:
3999 case X86::BI__builtin_ia32_scatterpfdps:
4000 case X86::BI__builtin_ia32_scatterpfqpd:
4001 case X86::BI__builtin_ia32_scatterpfqps:
4002 i = 4; l = 2; u = 3;
4004 case X86::BI__builtin_ia32_reducesd_mask:
4005 case X86::BI__builtin_ia32_reducess_mask:
4006 case X86::BI__builtin_ia32_rndscalesd_round_mask:
4007 case X86::BI__builtin_ia32_rndscaless_round_mask:
4008 i = 4; l = 0; u = 255;
4016 return SemaBuiltinConstantArgRange(TheCall, i, l, u,
false);
4023 bool Sema::getFormatStringInfo(
const FormatAttr *Format,
bool IsCXXMember,
4024 FormatStringInfo *FSI) {
4025 FSI->HasVAListArg = Format->getFirstArg() == 0;
4026 FSI->FormatIdx = Format->getFormatIdx() - 1;
4027 FSI->FirstDataArg = FSI->HasVAListArg ? 0 : Format->getFirstArg() - 1;
4033 if(FSI->FormatIdx == 0)
4036 if (FSI->FirstDataArg != 0)
4037 --FSI->FirstDataArg;
4047 if (
auto nullability
4056 if (UT->getDecl()->hasAttr<TransparentUnionAttr>())
4058 dyn_cast<CompoundLiteralExpr>(Expr))
4060 dyn_cast<InitListExpr>(CLE->getInitializer()))
4061 Expr = ILE->getInit(0);
4071 const Expr *ArgExpr,
4075 S.
PDiag(diag::warn_null_arg)
4080 FormatStringInfo FSI;
4081 if ((GetFormatStringType(Format) == FST_NSString) &&
4082 getFormatStringInfo(Format,
false, &FSI)) {
4083 Idx = FSI.FormatIdx;
4097 bool Format =
false;
4110 if (!Format || NumArgs <= Idx)
4112 const Expr *FormatExpr = Args[Idx];
4113 if (
const CStyleCastExpr *CSCE = dyn_cast<CStyleCastExpr>(FormatExpr))
4114 FormatExpr = CSCE->getSubExpr();
4124 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
4142 ArrayRef<const Expr *> Args,
4144 assert((FDecl || Proto) &&
"Need a function declaration or prototype");
4150 llvm::SmallBitVector NonNullArgs;
4156 for (
const auto *Arg : Args)
4163 unsigned IdxAST = Idx.getASTIndex();
4164 if (IdxAST >= Args.size())
4166 if (NonNullArgs.empty())
4167 NonNullArgs.resize(Args.size());
4168 NonNullArgs.set(IdxAST);
4173 if (FDecl && (isa<FunctionDecl>(FDecl) || isa<ObjCMethodDecl>(FDecl))) {
4176 ArrayRef<ParmVarDecl*> parms;
4177 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(FDecl))
4180 parms = cast<ObjCMethodDecl>(FDecl)->parameters();
4182 unsigned ParamIndex = 0;
4183 for (ArrayRef<ParmVarDecl*>::iterator I = parms.begin(), E = parms.end();
4184 I != E; ++I, ++ParamIndex) {
4186 if (PVD->
hasAttr<NonNullAttr>() ||
4188 if (NonNullArgs.empty())
4189 NonNullArgs.resize(Args.size());
4191 NonNullArgs.set(ParamIndex);
4198 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(FDecl)) {
4217 if (NonNullArgs.empty())
4218 NonNullArgs.resize(Args.size());
4220 NonNullArgs.set(Index);
4229 for (
unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
4230 ArgIndex != ArgIndexEnd; ++ArgIndex) {
4231 if (NonNullArgs[ArgIndex])
4240 const Expr *ThisArg, ArrayRef<const Expr *> Args,
4244 if (CurContext->isDependentContext())
4248 llvm::SmallBitVector CheckedVarArgs;
4252 CheckedVarArgs.resize(Args.size());
4254 CheckFormatArguments(I, Args, IsMemberFunction, CallType, Loc, Range,
4261 auto *FD = dyn_cast_or_null<FunctionDecl>(FDecl);
4262 if (CallType != VariadicDoesNotApply &&
4265 : FDecl && isa<FunctionDecl>(FDecl)
4266 ? cast<FunctionDecl>(FDecl)->getNumParams()
4267 : FDecl && isa<ObjCMethodDecl>(FDecl)
4268 ? cast<ObjCMethodDecl>(FDecl)->param_size()
4271 for (
unsigned ArgIdx = NumParams; ArgIdx < Args.size(); ++ArgIdx) {
4273 if (
const Expr *Arg = Args[ArgIdx]) {
4274 if (CheckedVarArgs.empty() || !CheckedVarArgs[ArgIdx])
4275 checkVariadicArgument(Arg, CallType);
4280 if (FDecl || Proto) {
4285 for (
const auto *I : FDecl->
specific_attrs<ArgumentWithTypeTagAttr>())
4286 CheckArgumentWithTypeTag(I, Args, Loc);
4291 diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc);
4297 ArrayRef<const Expr *> Args,
4300 VariadicCallType CallType =
4301 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
4302 checkCall(FDecl, Proto,
nullptr, Args,
true,
4310 bool IsMemberOperatorCall = isa<CXXOperatorCallExpr>(TheCall) &&
4311 isa<CXXMethodDecl>(FDecl);
4312 bool IsMemberFunction = isa<CXXMemberCallExpr>(TheCall) ||
4313 IsMemberOperatorCall;
4314 VariadicCallType CallType = getVariadicCallType(FDecl, Proto,
4319 Expr *ImplicitThis =
nullptr;
4320 if (IsMemberOperatorCall) {
4324 ImplicitThis = Args[0];
4327 }
else if (IsMemberFunction)
4329 cast<CXXMemberCallExpr>(TheCall)->getImplicitObjectArgument();
4331 checkCall(FDecl, Proto, ImplicitThis, llvm::makeArrayRef(Args, NumArgs),
4341 CheckAbsoluteValueFunction(TheCall, FDecl);
4342 CheckMaxUnsignedZero(TheCall, FDecl);
4344 if (getLangOpts().ObjC)
4352 if (CMId == Builtin::BIstrlcpy || CMId == Builtin::BIstrlcat)
4353 CheckStrlcpycatArguments(TheCall, FnInfo);
4354 else if (CMId == Builtin::BIstrncat)
4355 CheckStrncatArguments(TheCall, FnInfo);
4357 CheckMemaccessArguments(TheCall, CMId, FnInfo);
4363 ArrayRef<const Expr *> Args) {
4364 VariadicCallType CallType =
4365 Method->
isVariadic() ? VariadicMethod : VariadicDoesNotApply;
4367 checkCall(Method,
nullptr,
nullptr, Args,
4377 if (
const auto *
V = dyn_cast<VarDecl>(NDecl))
4378 Ty =
V->getType().getNonReferenceType();
4379 else if (
const auto *F = dyn_cast<FieldDecl>(NDecl))
4380 Ty = F->getType().getNonReferenceType();
4388 VariadicCallType CallType;
4390 CallType = VariadicDoesNotApply;
4392 CallType = VariadicBlock;
4394 CallType = VariadicFunction;
4397 checkCall(NDecl, Proto,
nullptr,
4408 VariadicCallType CallType = getVariadicCallType(
nullptr, Proto,
4410 checkCall(
nullptr, Proto,
nullptr,
4419 if (!llvm::isValidAtomicOrderingCABI(Ordering))
4422 auto OrderingCABI = (llvm::AtomicOrderingCABI)Ordering;
4424 case AtomicExpr::AO__c11_atomic_init:
4425 case AtomicExpr::AO__opencl_atomic_init:
4426 llvm_unreachable(
"There is no ordering argument for an init");
4428 case AtomicExpr::AO__c11_atomic_load:
4429 case AtomicExpr::AO__opencl_atomic_load:
4430 case AtomicExpr::AO__atomic_load_n:
4431 case AtomicExpr::AO__atomic_load:
4432 return OrderingCABI != llvm::AtomicOrderingCABI::release &&
4433 OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
4435 case AtomicExpr::AO__c11_atomic_store:
4436 case AtomicExpr::AO__opencl_atomic_store:
4437 case AtomicExpr::AO__atomic_store:
4438 case AtomicExpr::AO__atomic_store_n:
4439 return OrderingCABI != llvm::AtomicOrderingCABI::consume &&
4440 OrderingCABI != llvm::AtomicOrderingCABI::acquire &&
4441 OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
4450 CallExpr *TheCall = cast<CallExpr>(TheCallResult.
get());
4485 const unsigned NumForm = GNUCmpXchg + 1;
4486 const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 3, 4, 5, 6 };
4487 const unsigned NumVals[] = { 1, 0, 1, 1, 1, 1, 2, 2, 3 };
4495 static_assert(
sizeof(NumArgs)/
sizeof(NumArgs[0]) == NumForm
4496 &&
sizeof(NumVals)/
sizeof(NumVals[0]) == NumForm,
4497 "need to update code for modified forms");
4498 static_assert(AtomicExpr::AO__c11_atomic_init == 0 &&
4499 AtomicExpr::AO__c11_atomic_fetch_xor + 1 ==
4500 AtomicExpr::AO__atomic_load,
4501 "need to update code for modified C11 atomics");
4502 bool IsOpenCL = Op >= AtomicExpr::AO__opencl_atomic_init &&
4503 Op <= AtomicExpr::AO__opencl_atomic_fetch_max;
4504 bool IsC11 = (Op >= AtomicExpr::AO__c11_atomic_init &&
4505 Op <= AtomicExpr::AO__c11_atomic_fetch_xor) ||
4507 bool IsN = Op == AtomicExpr::AO__atomic_load_n ||
4508 Op == AtomicExpr::AO__atomic_store_n ||
4509 Op == AtomicExpr::AO__atomic_exchange_n ||
4510 Op == AtomicExpr::AO__atomic_compare_exchange_n;
4511 bool IsAddSub =
false;
4512 bool IsMinMax =
false;
4515 case AtomicExpr::AO__c11_atomic_init:
4516 case AtomicExpr::AO__opencl_atomic_init:
4520 case AtomicExpr::AO__c11_atomic_load:
4521 case AtomicExpr::AO__opencl_atomic_load:
4522 case AtomicExpr::AO__atomic_load_n:
4526 case AtomicExpr::AO__atomic_load:
4530 case AtomicExpr::AO__c11_atomic_store:
4531 case AtomicExpr::AO__opencl_atomic_store:
4532 case AtomicExpr::AO__atomic_store:
4533 case AtomicExpr::AO__atomic_store_n:
4537 case AtomicExpr::AO__c11_atomic_fetch_add:
4538 case AtomicExpr::AO__c11_atomic_fetch_sub:
4539 case AtomicExpr::AO__opencl_atomic_fetch_add:
4540 case AtomicExpr::AO__opencl_atomic_fetch_sub:
4541 case AtomicExpr::AO__opencl_atomic_fetch_min:
4542 case AtomicExpr::AO__opencl_atomic_fetch_max:
4543 case AtomicExpr::AO__atomic_fetch_add:
4544 case AtomicExpr::AO__atomic_fetch_sub:
4545 case AtomicExpr::AO__atomic_add_fetch:
4546 case AtomicExpr::AO__atomic_sub_fetch:
4549 case AtomicExpr::AO__c11_atomic_fetch_and:
4550 case AtomicExpr::AO__c11_atomic_fetch_or:
4551 case AtomicExpr::AO__c11_atomic_fetch_xor:
4552 case AtomicExpr::AO__opencl_atomic_fetch_and:
4553 case AtomicExpr::AO__opencl_atomic_fetch_or:
4554 case AtomicExpr::AO__opencl_atomic_fetch_xor:
4555 case AtomicExpr::AO__atomic_fetch_and:
4556 case AtomicExpr::AO__atomic_fetch_or:
4557 case AtomicExpr::AO__atomic_fetch_xor:
4558 case AtomicExpr::AO__atomic_fetch_nand:
4559 case AtomicExpr::AO__atomic_and_fetch:
4560 case AtomicExpr::AO__atomic_or_fetch:
4561 case AtomicExpr::AO__atomic_xor_fetch:
4562 case AtomicExpr::AO__atomic_nand_fetch:
4566 case AtomicExpr::AO__atomic_fetch_min:
4567 case AtomicExpr::AO__atomic_fetch_max:
4572 case AtomicExpr::AO__c11_atomic_exchange:
4573 case AtomicExpr::AO__opencl_atomic_exchange:
4574 case AtomicExpr::AO__atomic_exchange_n:
4578 case AtomicExpr::AO__atomic_exchange:
4582 case AtomicExpr::AO__c11_atomic_compare_exchange_strong:
4583 case AtomicExpr::AO__c11_atomic_compare_exchange_weak:
4584 case AtomicExpr::AO__opencl_atomic_compare_exchange_strong:
4585 case AtomicExpr::AO__opencl_atomic_compare_exchange_weak:
4589 case AtomicExpr::AO__atomic_compare_exchange:
4590 case AtomicExpr::AO__atomic_compare_exchange_n:
4595 unsigned AdjustedNumArgs = NumArgs[Form];
4596 if (IsOpenCL && Op != AtomicExpr::AO__opencl_atomic_init)
4599 if (TheCall->
getNumArgs() < AdjustedNumArgs) {
4600 Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
4601 << 0 << AdjustedNumArgs << TheCall->
getNumArgs()
4604 }
else if (TheCall->
getNumArgs() > AdjustedNumArgs) {
4606 diag::err_typecheck_call_too_many_args)
4607 << 0 << AdjustedNumArgs << TheCall->
getNumArgs()
4614 ExprResult ConvertedPtr = DefaultFunctionArrayLvalueConversion(Ptr);
4618 Ptr = ConvertedPtr.
get();
4621 Diag(DRE->getBeginLoc(), diag::err_atomic_builtin_must_be_pointer)
4631 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_atomic)
4637 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_non_const_atomic)
4643 }
else if (Form != Load && Form != LoadCopy) {
4645 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_non_const_pointer)
4652 if (Form == Arithmetic) {
4656 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_atomic_int_or_ptr)
4662 if (!BT || (BT->
getKind() != BuiltinType::Int &&
4663 BT->
getKind() != BuiltinType::UInt)) {
4664 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_int32_or_ptr);
4669 Diag(DRE->getBeginLoc(), diag::err_atomic_op_bitwise_needs_atomic_int)
4675 diag::err_incomplete_type)) {
4681 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_atomic_int_or_ptr)
4690 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_trivial_copy)
4706 Diag(DRE->getBeginLoc(), diag::err_arc_atomic_ownership)
4718 if (Form == Copy || Form == LoadCopy || Form == GNUXchg ||
4720 ResultType = Context.
VoidTy;
4721 else if (Form == C11CmpXchg || Form == GNUCmpXchg)
4722 ResultType = Context.
BoolTy;
4727 bool IsPassedByAddress =
false;
4728 if (!IsC11 && !IsN) {
4730 IsPassedByAddress =
true;
4740 if (
i < NumVals[Form] + 1) {
4753 assert(Form != Load);
4754 if (Form == Init || (Form == Arithmetic && ValType->
isIntegerType()))
4756 else if (Form == Copy || Form == Xchg) {
4757 if (IsPassedByAddress)
4761 }
else if (Form == Arithmetic)
4771 AS = PtrTy->getPointeeType().getAddressSpace();
4780 if (IsPassedByAddress)
4805 SubExprs.push_back(Ptr);
4809 SubExprs.push_back(TheCall->
getArg(1));
4812 SubExprs.push_back(TheCall->
getArg(1));
4818 SubExprs.push_back(TheCall->
getArg(2));
4819 SubExprs.push_back(TheCall->
getArg(1));
4823 SubExprs.push_back(TheCall->
getArg(3));
4824 SubExprs.push_back(TheCall->
getArg(1));
4825 SubExprs.push_back(TheCall->
getArg(2));
4828 SubExprs.push_back(TheCall->
getArg(3));
4829 SubExprs.push_back(TheCall->
getArg(1));
4830 SubExprs.push_back(TheCall->
getArg(4));
4831 SubExprs.push_back(TheCall->
getArg(2));
4834 SubExprs.push_back(TheCall->
getArg(4));
4835 SubExprs.push_back(TheCall->
getArg(1));
4836 SubExprs.push_back(TheCall->
getArg(5));
4837 SubExprs.push_back(TheCall->
getArg(2));
4838 SubExprs.push_back(TheCall->
getArg(3));
4842 if (SubExprs.size() >= 2 && Form != Init) {
4843 llvm::APSInt Result(32);
4844 if (SubExprs[1]->isIntegerConstantExpr(Result, Context) &&
4846 Diag(SubExprs[1]->getBeginLoc(),
4847 diag::warn_atomic_op_has_invalid_memory_order)
4848 << SubExprs[1]->getSourceRange();
4853 llvm::APSInt Result(32);
4854 if (
Scope->isIntegerConstantExpr(Result, Context) &&
4855 !ScopeModel->isValid(Result.getZExtValue())) {
4856 Diag(
Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_synch_scope)
4857 <<
Scope->getSourceRange();
4859 SubExprs.push_back(
Scope);
4866 if ((Op == AtomicExpr::AO__c11_atomic_load ||
4867 Op == AtomicExpr::AO__c11_atomic_store ||
4868 Op == AtomicExpr::AO__opencl_atomic_load ||
4869 Op == AtomicExpr::AO__opencl_atomic_store ) &&
4872 << ((Op == AtomicExpr::AO__c11_atomic_load ||
4873 Op == AtomicExpr::AO__opencl_atomic_load)
4889 assert(Fn &&
"builtin call without direct callee!");
4912 Sema::SemaBuiltinAtomicOverloaded(
ExprResult TheCallResult) {
4920 Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args_at_least)
4931 ExprResult FirstArgResult = DefaultFunctionArrayLvalueConversion(FirstArg);
4934 FirstArg = FirstArgResult.
get();
4935 TheCall->
setArg(0, FirstArg);
4947 Diag(DRE->
getBeginLoc(), diag::err_atomic_builtin_must_be_pointer_intptr)
4982 #define BUILTIN_ROW(x) \ 4983 { Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \ 4984 Builtin::BI##x##_8, Builtin::BI##x##_16 } 4986 static const unsigned BuiltinIndices[][5] = {
5012 case 1: SizeIndex = 0;
break;
5013 case 2: SizeIndex = 1;
break;
5014 case 4: SizeIndex = 2;
break;
5015 case 8: SizeIndex = 3;
break;
5016 case 16: SizeIndex = 4;
break;
5027 unsigned BuiltinID = FDecl->getBuiltinID();
5028 unsigned BuiltinIndex, NumFixed = 1;
5029 bool WarnAboutSemanticsChange =
false;
5030 switch (BuiltinID) {
5031 default: llvm_unreachable(
"Unknown overloaded atomic builtin!");
5032 case Builtin::BI__sync_fetch_and_add:
5033 case Builtin::BI__sync_fetch_and_add_1:
5034 case Builtin::BI__sync_fetch_and_add_2:
5035 case Builtin::BI__sync_fetch_and_add_4:
5036 case Builtin::BI__sync_fetch_and_add_8:
5037 case Builtin::BI__sync_fetch_and_add_16:
5041 case Builtin::BI__sync_fetch_and_sub:
5042 case Builtin::BI__sync_fetch_and_sub_1:
5043 case Builtin::BI__sync_fetch_and_sub_2:
5044 case Builtin::BI__sync_fetch_and_sub_4:
5045 case Builtin::BI__sync_fetch_and_sub_8:
5046 case Builtin::BI__sync_fetch_and_sub_16:
5050 case Builtin::BI__sync_fetch_and_or:
5051 case Builtin::BI__sync_fetch_and_or_1:
5052 case Builtin::BI__sync_fetch_and_or_2:
5053 case Builtin::BI__sync_fetch_and_or_4:
5054 case Builtin::BI__sync_fetch_and_or_8:
5055 case Builtin::BI__sync_fetch_and_or_16:
5059 case Builtin::BI__sync_fetch_and_and:
5060 case Builtin::BI__sync_fetch_and_and_1:
5061 case Builtin::BI__sync_fetch_and_and_2:
5062 case Builtin::BI__sync_fetch_and_and_4:
5063 case Builtin::BI__sync_fetch_and_and_8:
5064 case Builtin::BI__sync_fetch_and_and_16:
5068 case Builtin::BI__sync_fetch_and_xor:
5069 case Builtin::BI__sync_fetch_and_xor_1:
5070 case Builtin::BI__sync_fetch_and_xor_2:
5071 case Builtin::BI__sync_fetch_and_xor_4:
5072 case Builtin::BI__sync_fetch_and_xor_8:
5073 case Builtin::BI__sync_fetch_and_xor_16:
5077 case Builtin::BI__sync_fetch_and_nand:
5078 case Builtin::BI__sync_fetch_and_nand_1:
5079 case Builtin::BI__sync_fetch_and_nand_2:
5080 case Builtin::BI__sync_fetch_and_nand_4:
5081 case Builtin::BI__sync_fetch_and_nand_8:
5082 case Builtin::BI__sync_fetch_and_nand_16:
5084 WarnAboutSemanticsChange =
true;
5087 case Builtin::BI__sync_add_and_fetch:
5088 case Builtin::BI__sync_add_and_fetch_1:
5089 case Builtin::BI__sync_add_and_fetch_2:
5090 case Builtin::BI__sync_add_and_fetch_4:
5091 case Builtin::BI__sync_add_and_fetch_8:
5092 case Builtin::BI__sync_add_and_fetch_16:
5096 case Builtin::BI__sync_sub_and_fetch:
5097 case Builtin::BI__sync_sub_and_fetch_1:
5098 case Builtin::BI__sync_sub_and_fetch_2:
5099 case Builtin::BI__sync_sub_and_fetch_4:
5100 case Builtin::BI__sync_sub_and_fetch_8:
5101 case Builtin::BI__sync_sub_and_fetch_16:
5105 case Builtin::BI__sync_and_and_fetch:
5106 case Builtin::BI__sync_and_and_fetch_1:
5107 case Builtin::BI__sync_and_and_fetch_2:
5108 case Builtin::BI__sync_and_and_fetch_4:
5109 case Builtin::BI__sync_and_and_fetch_8:
5110 case Builtin::BI__sync_and_and_fetch_16:
5114 case Builtin::BI__sync_or_and_fetch:
5115 case Builtin::BI__sync_or_and_fetch_1:
5116 case Builtin::BI__sync_or_and_fetch_2:
5117 case Builtin::BI__sync_or_and_fetch_4:
5118 case Builtin::BI__sync_or_and_fetch_8:
5119 case Builtin::BI__sync_or_and_fetch_16:
5123 case Builtin::BI__sync_xor_and_fetch:
5124 case Builtin::BI__sync_xor_and_fetch_1:
5125 case Builtin::BI__sync_xor_and_fetch_2:
5126 case Builtin::BI__sync_xor_and_fetch_4:
5127 case Builtin::BI__sync_xor_and_fetch_8:
5128 case Builtin::BI__sync_xor_and_fetch_16:
5132 case Builtin::BI__sync_nand_and_fetch:
5133 case Builtin::BI__sync_nand_and_fetch_1:
5134 case Builtin::BI__sync_nand_and_fetch_2:
5135 case Builtin::BI__sync_nand_and_fetch_4:
5136 case Builtin::BI__sync_nand_and_fetch_8:
5137 case Builtin::BI__sync_nand_and_fetch_16:
5139 WarnAboutSemanticsChange =
true;
5142 case Builtin::BI__sync_val_compare_and_swap:
5143 case Builtin::BI__sync_val_compare_and_swap_1:
5144 case Builtin::BI__sync_val_compare_and_swap_2:
5145 case Builtin::BI__sync_val_compare_and_swap_4:
5146 case Builtin::BI__sync_val_compare_and_swap_8:
5147 case Builtin::BI__sync_val_compare_and_swap_16:
5152 case Builtin::BI__sync_bool_compare_and_swap:
5153 case Builtin::BI__sync_bool_compare_and_swap_1:
5154 case Builtin::BI__sync_bool_compare_and_swap_2:
5155 case Builtin::BI__sync_bool_compare_and_swap_4:
5156 case Builtin::BI__sync_bool_compare_and_swap_8:
5157 case Builtin::BI__sync_bool_compare_and_swap_16:
5160 ResultType = Context.
BoolTy;
5163 case Builtin::BI__sync_lock_test_and_set:
5164 case Builtin::BI__sync_lock_test_and_set_1:
5165 case Builtin::BI__sync_lock_test_and_set_2:
5166 case Builtin::BI__sync_lock_test_and_set_4:
5167 case Builtin::BI__sync_lock_test_and_set_8:
5168 case Builtin::BI__sync_lock_test_and_set_16:
5172 case Builtin::BI__sync_lock_release:
5173 case Builtin::BI__sync_lock_release_1:
5174 case Builtin::BI__sync_lock_release_2:
5175 case Builtin::BI__sync_lock_release_4:
5176 case Builtin::BI__sync_lock_release_8:
5177 case Builtin::BI__sync_lock_release_16:
5180 ResultType = Context.
VoidTy;
5183 case Builtin::BI__sync_swap:
5184 case Builtin::BI__sync_swap_1:
5185 case Builtin::BI__sync_swap_2:
5186 case Builtin::BI__sync_swap_4:
5187 case Builtin::BI__sync_swap_8:
5188 case Builtin::BI__sync_swap_16:
5196 Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args_at_least)
5197 << 0 << 1 + NumFixed << TheCall->
getNumArgs()
5202 Diag(TheCall->
getEndLoc(), diag::warn_atomic_implicit_seq_cst)
5205 if (WarnAboutSemanticsChange) {
5206 Diag(TheCall->
getEndLoc(), diag::warn_sync_fetch_and_nand_semantics_change)
5212 unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
5215 if (NewBuiltinID == BuiltinID)
5216 NewBuiltinDecl = FDecl;
5221 LookupName(Res, TUScope,
true);
5222 assert(Res.getFoundDecl());
5223 NewBuiltinDecl = dyn_cast<
FunctionDecl>(Res.getFoundDecl());
5224 if (!NewBuiltinDecl)
5231 for (
unsigned i = 0;
i != NumFixed; ++
i) {
5261 ExprResult PromotedCall = ImpCastExprToType(NewDRE, CalleePtrTy,
5262 CK_BuiltinFnToFnPtr);
5270 return TheCallResult;
5285 assert((BuiltinID == Builtin::BI__builtin_nontemporal_store ||
5286 BuiltinID == Builtin::BI__builtin_nontemporal_load) &&
5287 "Unexpected nontemporal load/store builtin!");
5288 bool isStore = BuiltinID == Builtin::BI__builtin_nontemporal_store;
5289 unsigned numArgs = isStore ? 2 : 1;
5299 Expr *PointerArg = TheCall->
getArg(numArgs - 1);
5301 DefaultFunctionArrayLvalueConversion(PointerArg);
5305 PointerArg = PointerArgResult.
get();
5306 TheCall->
setArg(numArgs - 1, PointerArg);
5310 Diag(DRE->
getBeginLoc(), diag::err_nontemporal_builtin_must_be_pointer)
5323 diag::err_nontemporal_builtin_must_be_pointer_intfltptr_or_vector)
5330 return TheCallResult;
5335 Context, ValType,
false);
5336 ValArg = PerformCopyInitialization(Entity,
SourceLocation(), ValArg);
5342 return TheCallResult;
5349 bool Sema::CheckObjCString(
Expr *Arg) {
5353 if (!Literal || !Literal->
isAscii()) {
5354 Diag(Arg->
getBeginLoc(), diag::err_cfstring_literal_not_string_constant)
5360 StringRef String = Literal->
getString();
5361 unsigned NumBytes = String.size();
5363 const llvm::UTF8 *FromPtr = (
const llvm::UTF8 *)String.data();
5364 llvm::UTF16 *ToPtr = &ToBuf[0];
5366 llvm::ConversionResult Result =
5367 llvm::ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes, &ToPtr,
5368 ToPtr + NumBytes, llvm::strictConversion);
5370 if (Result != llvm::conversionOK)
5383 if (
auto *ObjcLiteral = dyn_cast<ObjCStringLiteral>(Arg)) {
5388 if (!Literal || (!Literal->isAscii() && !Literal->isUTF8())) {
5398 Result = PerformCopyInitialization(Entity,
SourceLocation(), Result);
5406 bool IsX64 = TT.getArch() == llvm::Triple::x86_64;
5407 bool IsAArch64 = TT.getArch() == llvm::Triple::aarch64;
5408 bool IsWindows = TT.isOSWindows();
5409 bool IsMSVAStart = BuiltinID == Builtin::BI__builtin_ms_va_start;
5410 if (IsX64 || IsAArch64) {
5418 diag::err_ms_va_start_used_in_sysv_function);
5427 diag::err_va_start_used_in_wrong_abi_function)
5442 bool IsVariadic =
false;
5443 ArrayRef<ParmVarDecl *> Params;
5445 if (
auto *Block = dyn_cast<BlockDecl>(Caller)) {
5446 IsVariadic = Block->isVariadic();
5447 Params = Block->parameters();
5448 }
else if (
auto *FD = dyn_cast<FunctionDecl>(Caller)) {
5451 }
else if (
auto *MD = dyn_cast<ObjCMethodDecl>(Caller)) {
5452 IsVariadic = MD->isVariadic();
5454 Params = MD->parameters();
5455 }
else if (isa<CapturedDecl>(Caller)) {
5471 *LastParam = Params.empty() ? nullptr : Params.back();
5479 bool Sema::SemaBuiltinVAStart(
unsigned BuiltinID,
CallExpr *TheCall) {
5487 diag::err_typecheck_call_too_many_args)
5491 (*(TheCall->
arg_end() - 1))->getEndLoc());
5497 diag::err_typecheck_call_too_few_args_at_least)
5512 bool SecondArgIsLastNamedArgument =
false;
5519 bool IsCRegister =
false;
5521 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Arg)) {
5522 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {
5523 SecondArgIsLastNamedArgument = PV == LastParam;
5525 Type = PV->getType();
5526 ParamLoc = PV->getLocation();
5528 PV->getStorageClass() ==
SC_Register && !getLangOpts().CPlusPlus;
5532 if (!SecondArgIsLastNamedArgument)
5534 diag::warn_second_arg_of_va_start_not_last_named_param);
5547 unsigned Reason = 0;
5549 else if (IsCRegister) Reason = 2;
5550 Diag(Arg->
getBeginLoc(), diag::warn_va_start_type_is_undefined) << Reason;
5551 Diag(ParamLoc, diag::note_parameter_type) << Type;
5558 bool Sema::SemaBuiltinVAStartARMMicrosoft(
CallExpr *Call) {
5566 diag::err_typecheck_call_too_few_args_at_least)
5590 << Arg1->
getType() << ConstCharPtrTy << 1
5593 << 2 << Arg1->
getType() << ConstCharPtrTy;
5598 << Arg2->
getType() << SizeTy << 1
5601 << 3 << Arg2->
getType() << SizeTy;
5608 bool Sema::SemaBuiltinUnorderedCompare(
CallExpr *TheCall) {
5610 return Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
5614 diag::err_typecheck_call_too_many_args)
5617 (*(TheCall->
arg_end() - 1))->getEndLoc());
5624 QualType Res = UsualArithmeticConversions(OrigArg0, OrigArg1,
false);
5625 if (OrigArg0.isInvalid() || OrigArg1.
isInvalid())
5631 TheCall->
setArg(0, OrigArg0.get());
5634 if (OrigArg0.get()->isTypeDependent() || OrigArg1.
get()->isTypeDependent())
5640 return Diag(OrigArg0.get()->getBeginLoc(),
5641 diag::err_typecheck_call_invalid_ordered_compare)
5642 << OrigArg0.get()->getType() << OrigArg1.
get()->getType()
5644 OrigArg1.
get()->getEndLoc());
5653 bool Sema::SemaBuiltinFPClassification(
CallExpr *TheCall,
unsigned NumArgs) {
5655 return Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
5659 diag::err_typecheck_call_too_many_args)
5662 (*(TheCall->
arg_end() - 1))->getEndLoc());
5666 if (OrigArg->isTypeDependent())
5670 if (!OrigArg->getType()->isRealFloatingType())
5671 return Diag(OrigArg->getBeginLoc(),
5672 diag::err_typecheck_call_invalid_unary_fp)
5673 << OrigArg->getType() << OrigArg->getSourceRange();
5679 if (Cast->getCastKind() == CK_FloatingCast) {
5680 Expr *CastArg = Cast->getSubExpr();
5683 (Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) ||
5684 Cast->getType()->isSpecificBuiltinType(BuiltinType::Float) ||
5685 Cast->getType()->isSpecificBuiltinType(BuiltinType::LongDouble)) &&
5686 "promotion from float to either float, double, or long double is " 5687 "the only expected cast here");
5688 Cast->setSubExpr(
nullptr);
5689 TheCall->
setArg(NumArgs-1, CastArg);
5704 bool Sema::SemaBuiltinVSX(
CallExpr *TheCall) {
5705 unsigned ExpectedNumArgs = 3;
5708 diag::err_typecheck_call_too_few_args_at_least)
5709 << 0 << ExpectedNumArgs << TheCall->
getNumArgs()
5714 diag::err_typecheck_call_too_many_args_at_most)
5715 << 0 << ExpectedNumArgs << TheCall->
getNumArgs()
5722 diag::err_vsx_builtin_nonconstant_argument)
5732 if ((!Arg1Ty->isVectorType() && !Arg1Ty->isDependentType()) ||
5734 return Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
5742 return Diag(BuiltinLoc, diag::err_vec_builtin_incompatible_vector)
5761 diag::err_typecheck_call_too_few_args_at_least)
5769 unsigned numElements = 0;
5784 unsigned numResElements = TheCall->
getNumArgs() - 2;
5793 diag::err_vec_builtin_incompatible_vector)
5799 diag::err_vec_builtin_incompatible_vector)
5803 }
else if (numElements != numResElements) {
5815 llvm::APSInt Result(32);
5818 diag::err_shufflevector_nonconstant_argument)
5822 if (Result.isSigned() && Result.isAllOnesValue())
5825 if (Result.getActiveBits() > 64 || Result.getZExtValue() >= numElements*2)
5827 diag::err_shufflevector_argument_too_large)
5833 for (
unsigned i = 0, e = TheCall->
getNumArgs();
i != e;
i++) {
5834 exprs.push_back(TheCall->
getArg(
i));
5854 diag::err_convertvector_non_vector)
5858 diag::err_convertvector_non_vector_type));
5863 if (SrcElts != DstElts)
5865 diag::err_convertvector_incompatible_vector)
5869 return new (Context)
5876 bool Sema::SemaBuiltinPrefetch(
CallExpr *TheCall) {
5881 diag::err_typecheck_call_too_many_args_at_most)
5886 for (
unsigned i = 1;
i != NumArgs; ++
i)
5887 if (SemaBuiltinConstantArgRange(TheCall,
i, 0,
i == 1 ? 1 : 3))
5896 bool Sema::SemaBuiltinAssume(
CallExpr *TheCall) {
5911 bool Sema::SemaBuiltinAllocaWithAlign(
CallExpr *TheCall) {
5917 if (
const auto *UE =
5926 if (!Result.isPowerOf2())
5927 return Diag(TheCall->
getBeginLoc(), diag::err_alignment_not_power_of_two)
5944 bool Sema::SemaBuiltinAssumeAligned(
CallExpr *TheCall) {
5949 diag::err_typecheck_call_too_many_args_at_most)
5957 llvm::APSInt Result;
5958 if (SemaBuiltinConstantArg(TheCall, 1, Result))
5961 if (!Result.isPowerOf2())
5962 return Diag(TheCall->
getBeginLoc(), diag::err_alignment_not_power_of_two)
5971 if (Arg.isInvalid())
return true;
5972 TheCall->
setArg(2, Arg.get());
5978 bool Sema::SemaBuiltinOSLogFormat(
CallExpr *TheCall) {
5979 unsigned BuiltinID =
5980 cast<FunctionDecl>(TheCall->
getCalleeDecl())->getBuiltinID();
5981 bool IsSizeCall = BuiltinID == Builtin::BI__builtin_os_log_format_buffer_size;
5984 unsigned NumRequiredArgs = IsSizeCall ? 1 : 2;
5985 if (NumArgs < NumRequiredArgs) {
5986 return Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
5987 << 0 << NumRequiredArgs << NumArgs
5990 if (NumArgs >= NumRequiredArgs + 0x100) {
5992 diag::err_typecheck_call_too_many_args_at_most)
5993 << 0 << (NumRequiredArgs + 0xff) << NumArgs
6004 if (Arg.isInvalid())
6006 TheCall->
setArg(i, Arg.get());
6011 unsigned FormatIdx =
i;
6021 unsigned FirstDataArg =
i;
6022 while (i < NumArgs) {
6023 ExprResult Arg = DefaultVariadicArgumentPromotion(
6024 TheCall->
getArg(i), VariadicFunction,
nullptr);
6029 return Diag(Arg.
get()->getEndLoc(), diag::err_os_log_argument_too_big)
6040 llvm::SmallBitVector CheckedVarArgs(NumArgs,
false);
6042 bool Success = CheckFormatArguments(
6043 Args,
false, FormatIdx, FirstDataArg, FST_OSLog,
6060 bool Sema::SemaBuiltinConstantArg(
CallExpr *TheCall,
int ArgNum,
6061 llvm::APSInt &Result) {
6069 return Diag(TheCall->
getBeginLoc(), diag::err_constant_integer_arg_type)
6077 bool Sema::SemaBuiltinConstantArgRange(
CallExpr *TheCall,
int ArgNum,
6078 int Low,
int High,
bool RangeIsError) {
6079 if (isConstantEvaluated())
6081 llvm::APSInt Result;
6089 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
6092 if (Result.getSExtValue() < Low || Result.getSExtValue() > High) {
6099 DiagRuntimeBehavior(TheCall->
getBeginLoc(), TheCall,
6100 PDiag(diag::warn_argument_invalid_range)
6101 << Result.toString(10) << Low << High
6110 bool Sema::SemaBuiltinConstantArgMultiple(
CallExpr *TheCall,
int ArgNum,
6112 llvm::APSInt Result;
6120 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
6123 if (Result.getSExtValue() % Num != 0)
6131 bool Sema::SemaBuiltinARMMemoryTaggingCall(
unsigned BuiltinID,
CallExpr *TheCall) {
6132 if (BuiltinID == AArch64::BI__builtin_arm_irg) {
6138 ExprResult FirstArg = DefaultFunctionArrayLvalueConversion(Arg0);
6141 QualType FirstArgType = FirstArg.
get()->getType();
6143 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
6147 ExprResult SecArg = DefaultLvalueConversion(Arg1);
6152 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_integer)
6156 TheCall->
setType(FirstArgType);
6160 if (BuiltinID == AArch64::BI__builtin_arm_addg) {
6165 ExprResult FirstArg = DefaultFunctionArrayLvalueConversion(Arg0);
6168 QualType FirstArgType = FirstArg.
get()->getType();
6170 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
6175 TheCall->
setType(FirstArgType);
6178 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
6181 if (BuiltinID == AArch64::BI__builtin_arm_gmi) {
6187 ExprResult FirstArg = DefaultFunctionArrayLvalueConversion(Arg0);
6190 QualType FirstArgType = FirstArg.
get()->getType();
6192 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
6197 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_integer)
6203 if (BuiltinID == AArch64::BI__builtin_arm_ldg ||
6204 BuiltinID == AArch64::BI__builtin_arm_stg) {
6208 ExprResult FirstArg = DefaultFunctionArrayLvalueConversion(Arg0);
6212 QualType FirstArgType = FirstArg.
get()->getType();
6214 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
6219 if (BuiltinID == AArch64::BI__builtin_arm_ldg)
6220 TheCall->
setType(FirstArgType);
6224 if (BuiltinID == AArch64::BI__builtin_arm_subp) {
6228 ExprResult ArgExprA = DefaultFunctionArrayLvalueConversion(ArgA);
6229 ExprResult ArgExprB = DefaultFunctionArrayLvalueConversion(ArgB);
6237 auto isNull = [&] (
Expr *E) ->
bool {
6243 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_null_or_pointer)
6247 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_null_or_pointer)
6258 return Diag(TheCall->
getBeginLoc(), diag::err_typecheck_sub_ptr_compatible)
6270 ArgExprA = ImpCastExprToType(ArgExprA.
get(), ArgTypeB, CK_NullToPointer);
6273 ArgExprB = ImpCastExprToType(ArgExprB.
get(), ArgTypeA, CK_NullToPointer);
6280 assert(
false &&
"Unhandled ARM MTE intrinsic");
6286 bool Sema::SemaBuiltinARMSpecialReg(
unsigned BuiltinID,
CallExpr *TheCall,
6287 int ArgNum,
unsigned ExpectedFieldNum,
6289 bool IsARMBuiltin = BuiltinID == ARM::BI__builtin_arm_rsr64 ||
6290 BuiltinID == ARM::BI__builtin_arm_wsr64 ||
6291 BuiltinID == ARM::BI__builtin_arm_rsr ||
6292 BuiltinID == ARM::BI__builtin_arm_rsrp ||
6293 BuiltinID == ARM::BI__builtin_arm_wsr ||
6294 BuiltinID == ARM::BI__builtin_arm_wsrp;
6295 bool IsAArch64Builtin = BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
6296 BuiltinID == AArch64::BI__builtin_arm_wsr64 ||
6297 BuiltinID == AArch64::BI__builtin_arm_rsr ||
6298 BuiltinID == AArch64::BI__builtin_arm_rsrp ||
6299 BuiltinID == AArch64::BI__builtin_arm_wsr ||
6300 BuiltinID == AArch64::BI__builtin_arm_wsrp;
6301 assert((IsARMBuiltin || IsAArch64Builtin) &&
"Unexpected ARM builtin.");
6310 return Diag(TheCall->
getBeginLoc(), diag::err_expr_not_string_literal)
6316 Reg.split(Fields,
":");
6318 if (Fields.size() != ExpectedFieldNum && !(AllowName && Fields.size() == 1))
6326 if (Fields.size() > 1) {
6327 bool FiveFields = Fields.size() == 5;
6329 bool ValidString =
true;
6331 ValidString &= Fields[0].startswith_lower(
"cp") ||
6332 Fields[0].startswith_lower(
"p");
6335 Fields[0].drop_front(Fields[0].startswith_lower(
"cp") ? 2 : 1);
6337 ValidString &= Fields[2].startswith_lower(
"c");
6339 Fields[2] = Fields[2].drop_front(1);
6342 ValidString &= Fields[3].startswith_lower(
"c");
6344 Fields[3] = Fields[3].drop_front(1);
6350 Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 15, 15, 7});
6352 Ranges.append({15, 7, 15});
6354 for (
unsigned i=0;
i<Fields.size(); ++
i) {
6356 ValidString &= !Fields[
i].getAsInteger(10, IntField);
6357 ValidString &= (IntField >= 0 && IntField <= Ranges[
i]);
6363 }
else if (IsAArch64Builtin && Fields.size() == 1) {
6373 std::string RegLower = Reg.lower();
6374 if (RegLower !=
"spsel" && RegLower !=
"daifset" && RegLower !=
"daifclr" &&
6375 RegLower !=
"pan" && RegLower !=
"uao")
6378 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
6387 bool Sema::SemaBuiltinLongjmp(
CallExpr *TheCall) {
6389 return Diag(TheCall->
getBeginLoc(), diag::err_builtin_longjmp_unsupported)
6393 llvm::APSInt Result;
6396 if (SemaBuiltinConstantArg(TheCall, 1, Result))
6400 return Diag(TheCall->
getBeginLoc(), diag::err_builtin_longjmp_invalid_val)
6408 bool Sema::SemaBuiltinSetjmp(
CallExpr *TheCall) {
6410 return Diag(TheCall->
getBeginLoc(), diag::err_builtin_setjmp_unsupported)
6417 class UncoveredArgHandler {
6418 enum { Unknown = -1, AllCovered = -2 };
6420 signed FirstUncoveredArg = Unknown;
6424 UncoveredArgHandler() =
default;
6426 bool hasUncoveredArg()
const {
6427 return (FirstUncoveredArg >= 0);
6430 unsigned getUncoveredArg()
const {
6431 assert(hasUncoveredArg() &&
"no uncovered argument");
6432 return FirstUncoveredArg;
6435 void setAllCovered() {
6438 DiagnosticExprs.clear();
6439 FirstUncoveredArg = AllCovered;
6442 void Update(
signed NewFirstUncoveredArg,
const Expr *StrExpr) {
6443 assert(NewFirstUncoveredArg >= 0 &&
"Outside range");
6446 if (FirstUncoveredArg == AllCovered)
6451 if (NewFirstUncoveredArg == FirstUncoveredArg)
6452 DiagnosticExprs.push_back(StrExpr);
6453 else if (NewFirstUncoveredArg > FirstUncoveredArg) {
6454 DiagnosticExprs.clear();
6455 DiagnosticExprs.push_back(StrExpr);
6456 FirstUncoveredArg = NewFirstUncoveredArg;
6460 void Diagnose(
Sema &S,
bool IsFunctionCall,
const Expr *ArgExpr);
6465 SLCT_UncheckedLiteral,
6473 bool AddendIsRight) {
6474 unsigned BitWidth = Offset.getBitWidth();
6475 unsigned AddendBitWidth = Addend.getBitWidth();
6477 if (Addend.isUnsigned()) {
6478 Addend = Addend.zext(++AddendBitWidth);
6479 Addend.setIsSigned(
true);
6482 if (AddendBitWidth > BitWidth) {
6483 Offset = Offset.sext(AddendBitWidth);
6484 BitWidth = AddendBitWidth;
6485 }
else if (BitWidth > AddendBitWidth) {
6486 Addend = Addend.sext(BitWidth);
6490 llvm::APSInt ResOffset =
Offset;
6491 if (BinOpKind == BO_Add)
6492 ResOffset = Offset.sadd_ov(Addend, Ov);
6494 assert(AddendIsRight && BinOpKind == BO_Sub &&
6495 "operator must be add or sub with addend on the right");
6496 ResOffset = Offset.ssub_ov(Addend, Ov);
6503 "index (intermediate) result too big");
6504 Offset = Offset.sext(2 * BitWidth);
6505 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
6517 class FormatStringLiteral {
6522 FormatStringLiteral(
const StringLiteral *fexpr, int64_t Offset = 0)
6523 : FExpr(fexpr),
Offset(Offset) {}
6525 StringRef getString()
const {
6526 return FExpr->
getString().drop_front(Offset);
6529 unsigned getByteLength()
const {
6540 bool isAscii()
const {
return FExpr->
isAscii(); }
6541 bool isWide()
const {
return FExpr->
isWide(); }
6542 bool isUTF8()
const {
return FExpr->
isUTF8(); }
6543 bool isUTF16()
const {
return FExpr->
isUTF16(); }
6544 bool isUTF32()
const {
return FExpr->
isUTF32(); }
6545 bool isPascal()
const {
return FExpr->
isPascal(); }
6550 unsigned *StartTokenByteOffset =
nullptr)
const {
6552 StartToken, StartTokenByteOffset);
6565 const Expr *OrigFormatExpr,
6566 ArrayRef<const Expr *> Args,
6567 bool HasVAListArg,
unsigned format_idx,
6568 unsigned firstDataArg,
6570 bool inFunctionCall,
6572 llvm::SmallBitVector &CheckedVarArgs,
6573 UncoveredArgHandler &UncoveredArg);
6581 bool HasVAListArg,
unsigned format_idx,
6584 llvm::SmallBitVector &CheckedVarArgs,
6585 UncoveredArgHandler &UncoveredArg,
6588 return SLCT_NotALiteral;
6590 assert(Offset.isSigned() &&
"invalid offset");
6593 return SLCT_NotALiteral;
6602 return SLCT_UncheckedLiteral;
6605 case Stmt::BinaryConditionalOperatorClass:
6606 case Stmt::ConditionalOperatorClass: {
6610 cast<AbstractConditionalOperator>(E);
6615 bool CheckLeft =
true, CheckRight =
true;
6632 Left = SLCT_UncheckedLiteral;
6635 HasVAListArg, format_idx, firstDataArg,
6636 Type, CallType, InFunctionCall,
6637 CheckedVarArgs, UncoveredArg,
Offset);
6638 if (Left == SLCT_NotALiteral || !CheckRight) {
6645 HasVAListArg, format_idx, firstDataArg,
6646 Type, CallType, InFunctionCall, CheckedVarArgs,
6649 return (CheckLeft && Left < Right) ? Left : Right;
6652 case Stmt::ImplicitCastExprClass:
6653 E = cast<ImplicitCastExpr>(E)->getSubExpr();
6656 case Stmt::OpaqueValueExprClass:
6657 if (
const Expr *src = cast<OpaqueValueExpr>(E)->getSourceExpr()) {
6661 return SLCT_NotALiteral;
6663 case Stmt::PredefinedExprClass:
6667 return SLCT_UncheckedLiteral;
6669 case Stmt::DeclRefExprClass: {
6675 bool isConstant =
false;
6679 isConstant = AT->getElementType().isConstant(S.
Context);
6682 PT->getPointeeType().isConstant(S.
Context);
6690 if (
const Expr *Init = VD->getAnyInitializer()) {
6692 if (
const InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
6693 if (InitList->isStringLiteralInit())
6694 Init = InitList->getInit(0)->IgnoreParenImpCasts();
6697 HasVAListArg, format_idx,
6698 firstDataArg, Type, CallType,
6699 false, CheckedVarArgs,
6700 UncoveredArg, Offset);
6719 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(VD)) {
6720 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(PV->getDeclContext())) {
6721 int PVIndex = PV->getFunctionScopeIndex() + 1;
6722 for (
const auto *PVFormat : ND->specific_attrs<FormatAttr>()) {
6725 if (MD->isInstance())
6729 if (PVIndex == PVFormat->getFormatIdx() &&
6731 return SLCT_UncheckedLiteral;
6738 return SLCT_NotALiteral;
6741 case Stmt::CallExprClass:
6742 case Stmt::CXXMemberCallExprClass: {
6743 const CallExpr *CE = cast<CallExpr>(E);
6745 bool IsFirst =
true;
6747 for (
const auto *FA : ND->specific_attrs<FormatArgAttr>()) {
6748 const Expr *Arg = CE->
getArg(FA->getFormatIdx().getASTIndex());
6750 S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
6751 CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
6753 CommonResult = Result;
6758 return CommonResult;
6760 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
6762 if (BuiltinID == Builtin::BI__builtin___CFStringMakeConstantString ||
6763 BuiltinID == Builtin::BI__builtin___NSStringMakeConstantString) {
6766 HasVAListArg, format_idx,
6767 firstDataArg, Type, CallType,
6768 InFunctionCall, CheckedVarArgs,
6769 UncoveredArg, Offset);
6774 return SLCT_NotALiteral;
6776 case Stmt::ObjCMessageExprClass: {
6777 const auto *ME = cast<ObjCMessageExpr>(E);
6778 if (
const auto *ND = ME->getMethodDecl()) {
6779 if (
const auto *FA = ND->getAttr<FormatArgAttr>()) {
6780 const Expr *Arg = ME->getArg(FA->getFormatIdx().getASTIndex());
6782 S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
6783 CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
6787 return SLCT_NotALiteral;
6789 case Stmt::ObjCStringLiteralClass:
6790 case Stmt::StringLiteralClass: {
6796 StrE = cast<StringLiteral>(E);
6799 if (Offset.isNegative() || Offset > StrE->
getLength()) {
6802 return SLCT_NotALiteral;
6804 FormatStringLiteral FStr(StrE, Offset.sextOrTrunc(64).getSExtValue());
6806 firstDataArg, Type, InFunctionCall, CallType,
6807 CheckedVarArgs, UncoveredArg);
6808 return SLCT_CheckedLiteral;
6811 return SLCT_NotALiteral;
6813 case Stmt::BinaryOperatorClass: {
6825 if (LIsInt != RIsInt) {
6829 if (BinOpKind == BO_Add) {
6842 return SLCT_NotALiteral;
6844 case Stmt::UnaryOperatorClass: {
6847 if (UnaOp->
getOpcode() == UO_AddrOf && ASE) {
6849 if (ASE->getRHS()->EvaluateAsInt(IndexResult, S.
Context,
6859 return SLCT_NotALiteral;
6863 return SLCT_NotALiteral;
6868 return llvm::StringSwitch<FormatStringType>(Format->getType()->getName())
6869 .Case(
"scanf", FST_Scanf)
6870 .Cases(
"printf",
"printf0", FST_Printf)
6871 .Cases(
"NSString",
"CFString", FST_NSString)
6872 .Case(
"strftime", FST_Strftime)
6873 .Case(
"strfmon", FST_Strfmon)
6874 .Cases(
"kprintf",
"cmn_err",
"vcmn_err",
"zcmn_err", FST_Kprintf)
6875 .Case(
"freebsd_kprintf", FST_FreeBSDKPrintf)
6876 .Case(
"os_trace", FST_OSLog)
6877 .Case(
"os_log", FST_OSLog)
6878 .Default(FST_Unknown);
6884 bool Sema::CheckFormatArguments(
const FormatAttr *Format,
6889 llvm::SmallBitVector &CheckedVarArgs) {
6890 FormatStringInfo FSI;
6891 if (getFormatStringInfo(Format, IsCXXMember, &FSI))
6892 return CheckFormatArguments(Args, FSI.HasVAListArg, FSI.FormatIdx,
6893 FSI.FirstDataArg, GetFormatStringType(Format),
6894 CallType, Loc, Range, CheckedVarArgs);
6899 bool HasVAListArg,
unsigned format_idx,
6903 llvm::SmallBitVector &CheckedVarArgs) {
6905 if (format_idx >= Args.size()) {
6906 Diag(Loc, diag::warn_missing_format_string) << Range;
6910 const Expr *OrigFormatExpr = Args[format_idx]->IgnoreParenCasts();
6924 UncoveredArgHandler UncoveredArg;
6927 format_idx, firstDataArg,
Type, CallType,
6928 true, CheckedVarArgs,
6930 llvm::APSInt(64,
false) = 0);
6933 if (UncoveredArg.hasUncoveredArg()) {
6934 unsigned ArgIdx = UncoveredArg.getUncoveredArg() + firstDataArg;
6935 assert(ArgIdx < Args.size() &&
"ArgIdx outside bounds");
6936 UncoveredArg.Diagnose(*
this,
true, Args[ArgIdx]);
6939 if (CT != SLCT_NotALiteral)
6941 return CT == SLCT_CheckedLiteral;
6945 if (
Type == FST_Strftime)
6953 if (
Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
6958 if (Args.size() == firstDataArg) {
6959 Diag(FormatLoc, diag::warn_format_nonliteral_noargs)
6965 case FST_FreeBSDKPrintf:
6967 Diag(FormatLoc, diag::note_format_security_fixit)
6971 Diag(FormatLoc, diag::note_format_security_fixit)
6976 Diag(FormatLoc, diag::warn_format_nonliteral)
6987 const FormatStringLiteral *FExpr;
6988 const Expr *OrigFormatExpr;
6990 const unsigned FirstDataArg;
6991 const unsigned NumDataArgs;
6993 const bool HasVAListArg;
6996 llvm::SmallBitVector CoveredArgs;
6997 bool usesPositionalArgs =
false;
6998 bool atFirstArg =
true;
6999 bool inFunctionCall;
7001 llvm::SmallBitVector &CheckedVarArgs;
7002 UncoveredArgHandler &UncoveredArg;
7005 CheckFormatHandler(
Sema &s,
const FormatStringLiteral *fexpr,
7006 const Expr *origFormatExpr,
7008 unsigned numDataArgs,
const char *beg,
bool hasVAListArg,
7011 llvm::SmallBitVector &CheckedVarArgs,
7012 UncoveredArgHandler &UncoveredArg)
7013 : S(s), FExpr(fexpr), OrigFormatExpr(origFormatExpr), FSType(type),
7014 FirstDataArg(firstDataArg), NumDataArgs(numDataArgs), Beg(beg),
7015 HasVAListArg(hasVAListArg), Args(Args), FormatIdx(formatIdx),
7016 inFunctionCall(inFunctionCall), CallType(callType),
7017 CheckedVarArgs(CheckedVarArgs), UncoveredArg(UncoveredArg) {
7018 CoveredArgs.resize(numDataArgs);
7019 CoveredArgs.reset();
7022 void DoneProcessing();
7024 void HandleIncompleteSpecifier(
const char *startSpecifier,
7025 unsigned specifierLen)
override;
7027 void HandleInvalidLengthModifier(
7030 const char *startSpecifier,
unsigned specifierLen,
7033 void HandleNonStandardLengthModifier(
7035 const char *startSpecifier,
unsigned specifierLen);
7037 void HandleNonStandardConversionSpecifier(
7039 const char *startSpecifier,
unsigned specifierLen);
7041 void HandlePosition(
const char *startPos,
unsigned posLen)
override;
7043 void HandleInvalidPosition(
const char *startSpecifier,
7044 unsigned specifierLen,
7047 void HandleZeroPosition(
const char *startPos,
unsigned posLen)
override;
7049 void HandleNullChar(
const char *nullCharacter)
override;
7051 template <
typename Range>
7053 EmitFormatDiagnostic(
Sema &S,
bool inFunctionCall,
const Expr *ArgumentExpr,
7055 bool IsStringLocation, Range StringRange,
7059 bool HandleInvalidConversionSpecifier(
unsigned argIndex,
SourceLocation Loc,
7060 const char *startSpec,
7061 unsigned specifierLen,
7062 const char *csStart,
unsigned csLen);
7065 const char *startSpec,
7066 unsigned specifierLen);
7070 unsigned specifierLen);
7073 const Expr *getDataArg(
unsigned i)
const;
7077 const char *startSpecifier,
unsigned specifierLen,
7080 template <
typename Range>
7082 bool IsStringLocation, Range StringRange,
7088 SourceRange CheckFormatHandler::getFormatStringRange() {
7093 getSpecifierRange(
const char *startSpecifier,
unsigned specifierLen) {
7103 SourceLocation CheckFormatHandler::getLocationOfByte(
const char *x) {
7108 void CheckFormatHandler::HandleIncompleteSpecifier(
const char *startSpecifier,
7109 unsigned specifierLen){
7110 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_incomplete_specifier),
7111 getLocationOfByte(startSpecifier),
7113 getSpecifierRange(startSpecifier, specifierLen));
7116 void CheckFormatHandler::HandleInvalidLengthModifier(
7119 const char *startSpecifier,
unsigned specifierLen,
unsigned DiagID) {
7120 using namespace analyze_format_string;
7123 CharSourceRange LMRange = getSpecifierRange(LM.getStart(), LM.getLength());
7128 EmitFormatDiagnostic(S.
PDiag(DiagID) << LM.toString() << CS.
toString(),
7129 getLocationOfByte(LM.getStart()),
7131 getSpecifierRange(startSpecifier, specifierLen));
7133 S.
Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
7134 << FixedLM->toString()
7139 if (DiagID == diag::warn_format_nonsensical_length)
7142 EmitFormatDiagnostic(S.
PDiag(DiagID) << LM.toString() << CS.
toString(),
7143 getLocationOfByte(LM.getStart()),
7145 getSpecifierRange(startSpecifier, specifierLen),
7150 void CheckFormatHandler::HandleNonStandardLengthModifier(
7152 const char *startSpecifier,
unsigned specifierLen) {
7153 using namespace analyze_format_string;
7156 CharSourceRange LMRange = getSpecifierRange(LM.getStart(), LM.getLength());
7161 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
7162 << LM.toString() << 0,
7163 getLocationOfByte(LM.getStart()),
7165 getSpecifierRange(startSpecifier, specifierLen));
7167 S.
Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
7168 << FixedLM->toString()
7172 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
7173 << LM.toString() << 0,
7174 getLocationOfByte(LM.getStart()),
7176 getSpecifierRange(startSpecifier, specifierLen));
7180 void CheckFormatHandler::HandleNonStandardConversionSpecifier(
7182 const char *startSpecifier,
unsigned specifierLen) {
7183 using namespace analyze_format_string;
7188 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
7192 getSpecifierRange(startSpecifier, specifierLen));
7195 S.
Diag(getLocationOfByte(CS.
getStart()), diag::note_format_fix_specifier)
7196 << FixedCS->toString()
7199 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
7203 getSpecifierRange(startSpecifier, specifierLen));
7207 void CheckFormatHandler::HandlePosition(
const char *startPos,
7209 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard_positional_arg),
7210 getLocationOfByte(startPos),
7212 getSpecifierRange(startPos, posLen));
7216 CheckFormatHandler::HandleInvalidPosition(
const char *startPos,
unsigned posLen,
7218 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_positional_specifier)
7220 getLocationOfByte(startPos),
true,
7221 getSpecifierRange(startPos, posLen));
7224 void CheckFormatHandler::HandleZeroPosition(
const char *startPos,
7226 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_zero_positional_specifier),
7227 getLocationOfByte(startPos),
7229 getSpecifierRange(startPos, posLen));
7232 void CheckFormatHandler::HandleNullChar(
const char *nullCharacter) {
7233 if (!isa<ObjCStringLiteral>(OrigFormatExpr)) {
7235 EmitFormatDiagnostic(
7236 S.
PDiag(diag::warn_printf_format_string_contains_null_char),
7237 getLocationOfByte(nullCharacter),
true,
7238 getFormatStringRange());
7244 const Expr *CheckFormatHandler::getDataArg(
unsigned i)
const {
7245 return Args[FirstDataArg +
i];
7248 void CheckFormatHandler::DoneProcessing() {
7251 if (!HasVAListArg) {
7254 signed notCoveredArg = CoveredArgs.find_first();
7255 if (notCoveredArg >= 0) {
7256 assert((
unsigned)notCoveredArg < NumDataArgs);
7257 UncoveredArg.Update(notCoveredArg, OrigFormatExpr);
7259 UncoveredArg.setAllCovered();
7264 void UncoveredArgHandler::Diagnose(
Sema &S,
bool IsFunctionCall,
7265 const Expr *ArgExpr) {
7266 assert(hasUncoveredArg() && DiagnosticExprs.size() > 0 &&
7278 for (
auto E : DiagnosticExprs)
7281 CheckFormatHandler::EmitFormatDiagnostic(
7282 S, IsFunctionCall, DiagnosticExprs[0],
7288 CheckFormatHandler::HandleInvalidConversionSpecifier(
unsigned argIndex,
7290 const char *startSpec,
7291 unsigned specifierLen,
7292 const char *csStart,
7294 bool keepGoing =
true;
7295 if (argIndex < NumDataArgs) {
7298 CoveredArgs.set(argIndex);
7314 std::string CodePointStr;
7315 if (!llvm::sys::locale::isPrint(*csStart)) {
7316 llvm::UTF32 CodePoint;
7317 const llvm::UTF8 **B =
reinterpret_cast<const llvm::UTF8 **
>(&csStart);
7318 const llvm::UTF8 *E =
7319 reinterpret_cast<const llvm::UTF8 *
>(csStart + csLen);
7320 llvm::ConversionResult Result =
7321 llvm::convertUTF8Sequence(B, E, &CodePoint, llvm::strictConversion);
7323 if (Result != llvm::conversionOK) {
7324 unsigned char FirstChar = *csStart;
7325 CodePoint = (llvm::UTF32)FirstChar;
7328 llvm::raw_string_ostream OS(CodePointStr);
7329 if (CodePoint < 256)
7330 OS <<
"\\x" << llvm::format(
"%02x", CodePoint);
7331 else if (CodePoint <= 0xFFFF)
7332 OS <<
"\\u" << llvm::format(
"%04x", CodePoint);
7334 OS <<
"\\U" << llvm::format(
"%08x", CodePoint);
7336 Specifier = CodePointStr;
7339 EmitFormatDiagnostic(
7341 true, getSpecifierRange(startSpec, specifierLen));
7347 CheckFormatHandler::HandlePositionalNonpositionalArgs(
SourceLocation Loc,
7348 const char *startSpec,
7349 unsigned specifierLen) {
7350 EmitFormatDiagnostic(
7351 S.
PDiag(diag::warn_format_mix_positional_nonpositional_args),
7352 Loc,
true, getSpecifierRange(startSpec, specifierLen));
7356 CheckFormatHandler::CheckNumArgs(
7359 const char *startSpecifier,
unsigned specifierLen,
unsigned argIndex) {
7361 if (argIndex >= NumDataArgs) {
7363 ? (S.
PDiag(diag::warn_printf_positional_arg_exceeds_data_args)
7364 << (argIndex+1) << NumDataArgs)
7365 : S.
PDiag(diag::warn_printf_insufficient_data_args);
7366 EmitFormatDiagnostic(
7367 PDiag, getLocationOfByte(CS.
getStart()),
true,
7368 getSpecifierRange(startSpecifier, specifierLen));
7372 UncoveredArg.setAllCovered();
7378 template<
typename Range>
7381 bool IsStringLocation,
7384 EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag,
7385 Loc, IsStringLocation, StringRange, FixIt);
7415 template <
typename Range>
7416 void CheckFormatHandler::EmitFormatDiagnostic(
7417 Sema &S,
bool InFunctionCall,
const Expr *ArgumentExpr,
7420 if (InFunctionCall) {
7425 S.
Diag(IsStringLocation ? ArgumentExpr->
getExprLoc() : Loc, PDiag)
7429 S.
Diag(IsStringLocation ? Loc : StringRange.getBegin(),
7430 diag::note_format_string_defined);
7432 Note << StringRange;
7441 class CheckPrintfHandler :
public CheckFormatHandler {
7443 CheckPrintfHandler(
Sema &s,
const FormatStringLiteral *fexpr,
7444 const Expr *origFormatExpr,
7446 unsigned numDataArgs,
bool isObjC,
const char *beg,
7448 unsigned formatIdx,
bool inFunctionCall,
7450 llvm::SmallBitVector &CheckedVarArgs,
7451 UncoveredArgHandler &UncoveredArg)
7452 : CheckFormatHandler(s, fexpr, origFormatExpr, type, firstDataArg,
7453 numDataArgs, beg, hasVAListArg, Args, formatIdx,
7454 inFunctionCall, CallType, CheckedVarArgs,
7460 bool allowsObjCArg()
const {
7465 bool HandleInvalidPrintfConversionSpecifier(
7467 const char *startSpecifier,
7468 unsigned specifierLen)
override;
7470 void handleInvalidMaskType(StringRef MaskType)
override;
7473 const char *startSpecifier,
7474 unsigned specifierLen)
override;
7476 const char *StartSpecifier,
7477 unsigned SpecifierLen,
7481 const char *startSpecifier,
unsigned specifierLen);
7485 const char *startSpecifier,
unsigned specifierLen);
7488 const char *startSpecifier,
unsigned specifierLen);
7492 const char *startSpecifier,
unsigned specifierLen);
7496 void HandleEmptyObjCModifierFlag(
const char *startFlag,
7497 unsigned flagLen)
override;
7499 void HandleInvalidObjCModifierFlag(
const char *startFlag,
7500 unsigned flagLen)
override;
7502 void HandleObjCFlagsWithNonObjCConversion(
const char *flagsStart,
7503 const char *flagsEnd,
7504 const char *conversionPosition)
7510 bool CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier(
7512 const char *startSpecifier,
7513 unsigned specifierLen) {
7517 return HandleInvalidConversionSpecifier(FS.
getArgIndex(),
7519 startSpecifier, specifierLen,
7523 void CheckPrintfHandler::handleInvalidMaskType(StringRef MaskType) {
7524 S.
Diag(getLocationOfByte(MaskType.data()), diag::err_invalid_mask_type_size);
7527 bool CheckPrintfHandler::HandleAmount(
7529 unsigned k,
const char *startSpecifier,
7530 unsigned specifierLen) {
7532 if (!HasVAListArg) {
7534 if (argIndex >= NumDataArgs) {
7535 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_asterisk_missing_arg)
7539 getSpecifierRange(startSpecifier, specifierLen));
7549 CoveredArgs.set(argIndex);
7550 const Expr *Arg = getDataArg(argIndex);
7560 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_asterisk_wrong_type)
7565 getSpecifierRange(startSpecifier, specifierLen));
7575 void CheckPrintfHandler::HandleInvalidAmount(
7579 const char *startSpecifier,
7580 unsigned specifierLen) {
7590 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_nonsensical_optional_amount)
7594 getSpecifierRange(startSpecifier, specifierLen),
7600 const char *startSpecifier,
7601 unsigned specifierLen) {
7605 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_nonsensical_flag)
7609 getSpecifierRange(startSpecifier, specifierLen),
7614 void CheckPrintfHandler::HandleIgnoredFlag(
7618 const char *startSpecifier,
7619 unsigned specifierLen) {
7621 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_ignored_flag)
7625 getSpecifierRange(startSpecifier, specifierLen),
7627 getSpecifierRange(ignoredFlag.
getPosition(), 1)));
7630 void CheckPrintfHandler::HandleEmptyObjCModifierFlag(
const char *startFlag,
7633 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_empty_objc_flag),
7634 getLocationOfByte(startFlag),
7636 getSpecifierRange(startFlag, flagLen));
7639 void CheckPrintfHandler::HandleInvalidObjCModifierFlag(
const char *startFlag,
7642 auto Range = getSpecifierRange(startFlag, flagLen);
7643 StringRef flag(startFlag, flagLen);
7644 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_invalid_objc_flag) << flag,
7645 getLocationOfByte(startFlag),
7650 void CheckPrintfHandler::HandleObjCFlagsWithNonObjCConversion(
7651 const char *flagsStart,
const char *flagsEnd,
const char *conversionPosition) {
7653 auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1);
7654 auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion;
7655 EmitFormatDiagnostic(S.
PDiag(diag) << StringRef(conversionPosition, 1),
7656 getLocationOfByte(conversionPosition),
7664 template<
typename MemberKind>
7665 static llvm::SmallPtrSet<MemberKind*, 1>
7668 llvm::SmallPtrSet<MemberKind*, 1> Results;
7685 if (MemberKind *FK = dyn_cast<MemberKind>(decl))
7696 using MethodSet = llvm::SmallPtrSet<CXXMethodDecl *, 1>;
7699 CXXRecordMembersNamed<CXXMethodDecl>(
"c_str", *
this, E->
getType());
7700 for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
7702 if ((*MI)->getMinRequiredArguments() == 0)
7710 bool CheckPrintfHandler::checkForCStrMembers(
7712 using MethodSet = llvm::SmallPtrSet<CXXMethodDecl *, 1>;
7715 CXXRecordMembersNamed<CXXMethodDecl>(
"c_str", S, E->
getType());
7717 for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
7736 const char *startSpecifier,
7737 unsigned specifierLen) {
7738 using namespace analyze_format_string;
7739 using namespace analyze_printf;
7749 HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
7750 startSpecifier, specifierLen);
7758 startSpecifier, specifierLen)) {
7763 startSpecifier, specifierLen)) {
7767 if (!CS.consumesDataArgument()) {
7775 if (argIndex < NumDataArgs) {
7779 CoveredArgs.set(argIndex);
7783 if (CS.getKind() == ConversionSpecifier::FreeBSDbArg ||
7784 CS.getKind() == ConversionSpecifier::FreeBSDDArg) {
7786 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex + 1))
7790 CoveredArgs.set(argIndex + 1);
7793 const Expr *Ex = getDataArg(argIndex);
7795 (CS.getKind() == ConversionSpecifier::FreeBSDbArg) ?
7798 EmitFormatDiagnostic(
7799 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
7803 getSpecifierRange(startSpecifier, specifierLen));
7806 Ex = getDataArg(argIndex + 1);
7809 EmitFormatDiagnostic(
7810 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
7812 <<
false << Ex->getSourceRange(),
7813 Ex->getBeginLoc(),
false,
7814 getSpecifierRange(startSpecifier, specifierLen));
7821 if (!allowsObjCArg() && CS.isObjCArg()) {
7822 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
7827 if (FSType !=
Sema::FST_OSLog && CS.getKind() == ConversionSpecifier::PArg) {
7828 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
7833 if (FSType ==
Sema::FST_OSLog && CS.getKind() == ConversionSpecifier::nArg) {
7834 EmitFormatDiagnostic(S.
PDiag(diag::warn_os_log_format_narg),
7835 getLocationOfByte(CS.getStart()),
7837 getSpecifierRange(startSpecifier, specifierLen));
7844 (CS.getKind() == ConversionSpecifier::PArg ||
7845 CS.getKind() == ConversionSpecifier::sArg ||
7846 CS.getKind() == ConversionSpecifier::ObjCObjArg)) {
7847 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
7854 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_annotation)
7858 getSpecifierRange(startSpecifier, specifierLen));
7861 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_annotation)
7865 getSpecifierRange(startSpecifier, specifierLen));
7872 startSpecifier, specifierLen);
7878 startSpecifier, specifierLen);
7882 if (CS.getKind() == ConversionSpecifier::PArg &&
7884 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_P_no_precision),
7885 getLocationOfByte(startSpecifier),
7887 getSpecifierRange(startSpecifier, specifierLen));
7896 HandleFlag(FS, FS.
hasPlusPrefix(), startSpecifier, specifierLen);
7898 HandleFlag(FS, FS.
hasSpacePrefix(), startSpecifier, specifierLen);
7907 startSpecifier, specifierLen);
7910 startSpecifier, specifierLen);
7915 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
7916 diag::warn_format_nonsensical_length);
7918 HandleNonStandardLengthModifier(FS, startSpecifier, specifierLen);
7920 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
7921 diag::warn_format_non_standard_conversion_spec);
7924 HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
7930 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex))
7933 const Expr *Arg = getDataArg(argIndex);
7937 return checkFormatExpr(FS, startSpecifier, specifierLen, Arg);
7949 case Stmt::ArraySubscriptExprClass:
7950 case Stmt::CallExprClass:
7951 case Stmt::CharacterLiteralClass:
7952 case Stmt::CXXBoolLiteralExprClass:
7953 case Stmt::DeclRefExprClass:
7954 case Stmt::FloatingLiteralClass:
7955 case Stmt::IntegerLiteralClass:
7956 case Stmt::MemberExprClass:
7957 case Stmt::ObjCArrayLiteralClass:
7958 case Stmt::ObjCBoolLiteralExprClass:
7959 case Stmt::ObjCBoxedExprClass:
7960 case Stmt::ObjCDictionaryLiteralClass:
7961 case Stmt::ObjCEncodeExprClass:
7962 case Stmt::ObjCIvarRefExprClass:
7963 case Stmt::ObjCMessageExprClass:
7964 case Stmt::ObjCPropertyRefExprClass:
7965 case Stmt::ObjCStringLiteralClass:
7966 case Stmt::ObjCSubscriptRefExprClass:
7967 case Stmt::ParenExprClass:
7968 case Stmt::StringLiteralClass:
7969 case Stmt::UnaryOperatorClass:
7976 static std::pair<QualType, StringRef>
7983 StringRef Name = UserTy->getDecl()->getName();
7984 QualType CastTy = llvm::StringSwitch<QualType>(Name)
7988 .Case(
"SInt32", Context.
IntTy)
7993 return std::make_pair(CastTy, Name);
7995 TyTy = UserTy->desugar();
7999 if (
const ParenExpr *PE = dyn_cast<ParenExpr>(E))
8001 PE->getSubExpr()->getType(),
8010 StringRef TrueName, FalseName;
8012 std::tie(TrueTy, TrueName) =
8014 CO->getTrueExpr()->getType(),
8016 std::tie(FalseTy, FalseName) =
8018 CO->getFalseExpr()->getType(),
8019 CO->getFalseExpr());
8021 if (TrueTy == FalseTy)
8022 return std::make_pair(TrueTy, TrueName);
8023 else if (TrueTy.
isNull())
8024 return std::make_pair(FalseTy, FalseName);
8025 else if (FalseTy.
isNull())
8026 return std::make_pair(TrueTy, TrueName);
8029 return std::make_pair(
QualType(), StringRef());
8048 From = VecTy->getElementType();
8050 To = VecTy->getElementType();
8058 const char *StartSpecifier,
8059 unsigned SpecifierLen,
8061 using namespace analyze_format_string;
8062 using namespace analyze_printf;
8071 while (
const TypeOfExprType *TET = dyn_cast<TypeOfExprType>(ExprTy)) {
8072 ExprTy = TET->getUnderlyingExpr()->getType();
8076 AT.matchesType(S.
Context, ExprTy);
8088 E = ICE->getSubExpr();
8097 if (AT.matchesType(S.
Context, ExprTy))
8111 bool IsEnum =
false;
8113 ExprTy = EnumTy->getDecl()->getIntegerType();
8121 if (isObjCContext() &&
8132 const llvm::APInt &
V = IL->getValue();
8142 if (TD->getUnderlyingType() == IntendedTy)
8150 bool ShouldNotPrintDirectly =
false; StringRef CastTyName;
8157 if ((CastTyName ==
"NSInteger" || CastTyName ==
"NSUInteger") &&
8158 (AT.isSizeT() || AT.isPtrdiffT()) &&
8159 AT.matchesType(S.
Context, CastTy))
8161 IntendedTy = CastTy;
8162 ShouldNotPrintDirectly =
true;
8167 PrintfSpecifier fixedFS = FS;
8174 llvm::raw_svector_ostream os(buf);
8175 fixedFS.toString(os);
8177 CharSourceRange SpecRange = getSpecifierRange(StartSpecifier, SpecifierLen);
8179 if (IntendedTy == ExprTy && !ShouldNotPrintDirectly) {
8182 ? diag::warn_format_conversion_argument_type_mismatch_pedantic
8183 : diag::warn_format_conversion_argument_type_mismatch;
8186 EmitFormatDiagnostic(S.
PDiag(Diag)
8187 << AT.getRepresentativeTypeName(S.
Context)
8201 llvm::raw_svector_ostream CastFix(CastBuf);
8207 if (!AT.matchesType(S.
Context, IntendedTy) || ShouldNotPrintDirectly)
8212 SourceRange CastRange(CCast->getLParenLoc(), CCast->getRParenLoc());
8230 if (ShouldNotPrintDirectly) {
8235 if (
const TypedefType *TypedefTy = dyn_cast<TypedefType>(ExprTy))
8236 Name = TypedefTy->getDecl()->getName();
8239 unsigned Diag = Pedantic
8240 ? diag::warn_format_argument_needs_cast_pedantic
8241 : diag::warn_format_argument_needs_cast;
8242 EmitFormatDiagnostic(S.
PDiag(Diag) << Name << IntendedTy << IsEnum
8250 EmitFormatDiagnostic(
8251 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
8252 << AT.getRepresentativeTypeName(S.
Context) << ExprTy << IsEnum
8268 ? diag::warn_format_conversion_argument_type_mismatch_pedantic
8269 : diag::warn_format_conversion_argument_type_mismatch;
8271 EmitFormatDiagnostic(
8272 S.
PDiag(Diag) << AT.getRepresentativeTypeName(S.
Context) << ExprTy
8279 EmitFormatDiagnostic(S.
PDiag(diag::warn_non_pod_vararg_with_format_string)
8282 << AT.getRepresentativeTypeName(S.
Context) << CSR
8285 checkForCStrMembers(AT, E);
8290 EmitFormatDiagnostic(
8291 S.
PDiag(diag::err_cannot_pass_objc_interface_to_vararg_format)
8292 << S.
getLangOpts().CPlusPlus11 << ExprTy << CallType
8293 << AT.getRepresentativeTypeName(S.
Context) << CSR
8300 << isa<InitListExpr>(E) << ExprTy << CallType
8305 assert(FirstDataArg + FS.
getArgIndex() < CheckedVarArgs.size() &&
8306 "format string specifier index out of range");
8307 CheckedVarArgs[FirstDataArg + FS.
getArgIndex()] =
true;
8317 class CheckScanfHandler :
public CheckFormatHandler {
8319 CheckScanfHandler(
Sema &s,
const FormatStringLiteral *fexpr,
8321 unsigned firstDataArg,
unsigned numDataArgs,
8322 const char *beg,
bool hasVAListArg,
8323 ArrayRef<const Expr *> Args,
unsigned formatIdx,
8325 llvm::SmallBitVector &CheckedVarArgs,
8326 UncoveredArgHandler &UncoveredArg)
8327 : CheckFormatHandler(s, fexpr, origFormatExpr, type, firstDataArg,
8328 numDataArgs, beg, hasVAListArg, Args, formatIdx,
8329 inFunctionCall, CallType, CheckedVarArgs,
8333 const char *startSpecifier,
8334 unsigned specifierLen)
override;
8336 bool HandleInvalidScanfConversionSpecifier(
8338 const char *startSpecifier,
8339 unsigned specifierLen)
override;
8341 void HandleIncompleteScanList(
const char *start,
const char *end)
override;
8346 void CheckScanfHandler::HandleIncompleteScanList(
const char *start,
8348 EmitFormatDiagnostic(S.
PDiag(diag::warn_scanf_scanlist_incomplete),
8349 getLocationOfByte(end),
true,
8350 getSpecifierRange(start, end - start));
8353 bool CheckScanfHandler::HandleInvalidScanfConversionSpecifier(
8355 const char *startSpecifier,
8356 unsigned specifierLen) {
8360 return HandleInvalidConversionSpecifier(FS.
getArgIndex(),
8362 startSpecifier, specifierLen,
8366 bool CheckScanfHandler::HandleScanfSpecifier(
8368 const char *startSpecifier,
8369 unsigned specifierLen) {
8370 using namespace analyze_scanf;
8371 using namespace analyze_format_string;
8383 HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
8384 startSpecifier, specifierLen);
8391 if (Amt.getHowSpecified() == OptionalAmount::Constant) {
8392 if (Amt.getConstantAmount() == 0) {
8394 Amt.getConstantLength());
8395 EmitFormatDiagnostic(S.
PDiag(diag::warn_scanf_nonzero_width),
8396 getLocationOfByte(Amt.getStart()),
8410 if (argIndex < NumDataArgs) {
8414 CoveredArgs.set(argIndex);
8420 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
8421 diag::warn_format_nonsensical_length);
8423 HandleNonStandardLengthModifier(FS, startSpecifier, specifierLen);
8425 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
8426 diag::warn_format_non_standard_conversion_spec);
8429 HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
8435 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex))
8439 const Expr *Ex = getDataArg(argIndex);
8455 ScanfSpecifier fixedFS = FS;
8460 Pedantic ? diag::warn_format_conversion_argument_type_mismatch_pedantic
8461 : diag::warn_format_conversion_argument_type_mismatch;
8466 llvm::raw_svector_ostream os(buf);
8467 fixedFS.toString(os);
8469 EmitFormatDiagnostic(
8474 getSpecifierRange(startSpecifier, specifierLen),
8476 getSpecifierRange(startSpecifier, specifierLen), os.str()));
8478 EmitFormatDiagnostic(S.
PDiag(Diag)
8483 getSpecifierRange(startSpecifier, specifierLen));
8490 const Expr *OrigFormatExpr,
8491 ArrayRef<const Expr *> Args,
8492 bool HasVAListArg,
unsigned format_idx,
8493 unsigned firstDataArg,
8495 bool inFunctionCall,
8497 llvm::SmallBitVector &CheckedVarArgs,
8498 UncoveredArgHandler &UncoveredArg) {
8500 if (!FExpr->isAscii() && !FExpr->isUTF8()) {
8501 CheckFormatHandler::EmitFormatDiagnostic(
8502 S, inFunctionCall, Args[format_idx],
8503 S.
PDiag(diag::warn_format_string_is_wide_literal), FExpr->getBeginLoc(),
8509 StringRef StrRef = FExpr->getString();
8510 const char *Str = StrRef.data();
8514 assert(T &&
"String literal not of constant array type!");
8515 size_t TypeSize = T->
getSize().getZExtValue();
8516 size_t StrLen =
std::min(
std::max(TypeSize,
size_t(1)) - 1, StrRef.size());
8517 const unsigned numDataArgs = Args.size() - firstDataArg;
8521 if (TypeSize <= StrRef.size() &&
8522 StrRef.substr(0, TypeSize).find(
'\0') == StringRef::npos) {
8523 CheckFormatHandler::EmitFormatDiagnostic(
8524 S, inFunctionCall, Args[format_idx],
8525 S.
PDiag(diag::warn_printf_format_string_not_null_terminated),
8526 FExpr->getBeginLoc(),
8532 if (StrLen == 0 && numDataArgs > 0) {
8533 CheckFormatHandler::EmitFormatDiagnostic(
8534 S, inFunctionCall, Args[format_idx],
8535 S.
PDiag(diag::warn_empty_format_string), FExpr->getBeginLoc(),
8543 CheckPrintfHandler H(
8544 S, FExpr, OrigFormatExpr, Type, firstDataArg, numDataArgs,
8546 HasVAListArg, Args, format_idx, inFunctionCall, CallType,
8547 CheckedVarArgs, UncoveredArg);
8555 CheckScanfHandler H(S, FExpr, OrigFormatExpr, Type, firstDataArg,
8556 numDataArgs, Str, HasVAListArg, Args, format_idx,
8557 inFunctionCall, CallType, CheckedVarArgs, UncoveredArg);
8569 const char *Str = StrRef.data();
8572 assert(T &&
"String literal not of constant array type!");
8573 size_t TypeSize = T->
getSize().getZExtValue();
8574 size_t StrLen =
std::min(
std::max(TypeSize,
size_t(1)) - 1, StrRef.size());
8585 switch (AbsFunction) {
8589 case Builtin::BI__builtin_abs:
8590 return Builtin::BI__builtin_labs;
8591 case Builtin::BI__builtin_labs:
8592 return Builtin::BI__builtin_llabs;
8593 case Builtin::BI__builtin_llabs:
8596 case Builtin::BI__builtin_fabsf:
8597 return Builtin::BI__builtin_fabs;
8598 case Builtin::BI__builtin_fabs:
8599 return Builtin::BI__builtin_fabsl;
8600 case Builtin::BI__builtin_fabsl:
8603 case Builtin::BI__builtin_cabsf:
8604 return Builtin::BI__builtin_cabs;
8605 case Builtin::BI__builtin_cabs:
8606 return Builtin::BI__builtin_cabsl;
8607 case Builtin::BI__builtin_cabsl:
8610 case Builtin::BIabs:
8611 return Builtin::BIlabs;
8612 case Builtin::BIlabs:
8613 return Builtin::BIllabs;
8614 case Builtin::BIllabs:
8617 case Builtin::BIfabsf:
8618 return Builtin::BIfabs;
8619 case Builtin::BIfabs:
8620 return Builtin::BIfabsl;
8621 case Builtin::BIfabsl:
8624 case Builtin::BIcabsf:
8625 return Builtin::BIcabs;
8626 case Builtin::BIcabs:
8627 return Builtin::BIcabsl;
8628 case Builtin::BIcabsl:
8657 unsigned AbsFunctionKind) {
8658 unsigned BestKind = 0;
8660 for (
unsigned Kind = AbsFunctionKind;
Kind != 0;
8666 else if (Context.
hasSameType(ParamType, ArgType)) {
8689 llvm_unreachable(
"Type not integer, floating, or complex");
8696 switch (ValueKind) {
8701 case Builtin::BI__builtin_fabsf:
8702 case Builtin::BI__builtin_fabs:
8703 case Builtin::BI__builtin_fabsl:
8704 case Builtin::BI__builtin_cabsf:
8705 case Builtin::BI__builtin_cabs:
8706 case Builtin::BI__builtin_cabsl:
8707 return Builtin::BI__builtin_abs;
8708 case Builtin::BIfabsf:
8709 case Builtin::BIfabs:
8710 case Builtin::BIfabsl:
8711 case Builtin::BIcabsf:
8712 case Builtin::BIcabs:
8713 case Builtin::BIcabsl:
8714 return Builtin::BIabs;
8720 case Builtin::BI__builtin_abs:
8721 case Builtin::BI__builtin_labs:
8722 case Builtin::BI__builtin_llabs:
8723 case Builtin::BI__builtin_cabsf:
8724 case Builtin::BI__builtin_cabs:
8725 case Builtin::BI__builtin_cabsl:
8726 return Builtin::BI__builtin_fabsf;
8727 case Builtin::BIabs:
8728 case Builtin::BIlabs:
8729 case Builtin::BIllabs:
8730 case Builtin::BIcabsf:
8731 case Builtin::BIcabs:
8732 case Builtin::BIcabsl:
8733 return Builtin::BIfabsf;
8739 case Builtin::BI__builtin_abs:
8740 case Builtin::BI__builtin_labs:
8741 case Builtin::BI__builtin_llabs:
8742 case Builtin::BI__builtin_fabsf:
8743 case Builtin::BI__builtin_fabs:
8744 case Builtin::BI__builtin_fabsl:
8745 return Builtin::BI__builtin_cabsf;
8746 case Builtin::BIabs:
8747 case Builtin::BIlabs:
8748 case Builtin::BIllabs:
8749 case Builtin::BIfabsf:
8750 case Builtin::BIfabs:
8751 case Builtin::BIfabsl:
8752 return Builtin::BIcabsf;
8755 llvm_unreachable(
"Unable to convert function");
8766 case Builtin::BI__builtin_abs:
8767 case Builtin::BI__builtin_fabs:
8768 case Builtin::BI__builtin_fabsf:
8769 case Builtin::BI__builtin_fabsl:
8770 case Builtin::BI__builtin_labs:
8771 case Builtin::BI__builtin_llabs:
8772 case Builtin::BI__builtin_cabs:
8773 case Builtin::BI__builtin_cabsf:
8774 case Builtin::BI__builtin_cabsl:
8775 case Builtin::BIabs:
8776 case Builtin::BIlabs:
8777 case Builtin::BIllabs:
8778 case Builtin::BIfabs:
8779 case Builtin::BIfabsf:
8780 case Builtin::BIfabsl:
8781 case Builtin::BIcabs:
8782 case Builtin::BIcabsf:
8783 case Builtin::BIcabsl:
8786 llvm_unreachable(
"Unknown Builtin type");
8792 unsigned AbsKind,
QualType ArgType) {
8793 bool EmitHeaderHint =
true;
8794 const char *HeaderName =
nullptr;
8795 const char *FunctionName =
nullptr;
8797 FunctionName =
"std::abs";
8799 HeaderName =
"cstdlib";
8801 HeaderName =
"cmath";
8803 llvm_unreachable(
"Invalid Type");
8812 for (
const auto *I : R) {
8815 FDecl = dyn_cast<
FunctionDecl>(UsingD->getTargetDecl());
8832 EmitHeaderHint =
false;
8844 R.suppressDiagnostics();
8847 if (R.isSingleResult()) {
8850 EmitHeaderHint =
false;
8854 }
else if (!R.empty()) {
8860 S.
Diag(Loc, diag::note_replace_abs_function)
8866 if (!EmitHeaderHint)
8869 S.
Diag(Loc, diag::note_include_header_or_declare) << HeaderName
8873 template <std::
size_t StrLen>
8875 const char (&Str)[StrLen]) {
8887 void Sema::CheckAbsoluteValueFunction(
const CallExpr *Call,
8894 if (AbsKind == 0 && !IsStdAbs)
8903 const char *FunctionName =
8905 Diag(Call->
getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType;
8915 unsigned DiagType = 0;
8921 Diag(Call->
getExprLoc(), diag::warn_pointer_abs) << DiagType << ArgType;
8935 if (ArgValueKind == ParamValueKind) {
8941 << FDecl << ArgType << ParamType;
8943 if (NewAbsKind == 0)
8956 if (NewAbsKind == 0)
8960 << FDecl << ParamValueKind << ArgValueKind;
8967 void Sema::CheckMaxUnsignedZero(
const CallExpr *Call,
8969 if (!Call || !FDecl)
return;
8972 if (inTemplateInstantiation())
return;
8979 if (!ArgList)
return;
8980 if (ArgList->size() != 1)
return;
8983 const auto& TA = ArgList->
get(0);
8989 auto IsLiteralZeroArg = [](
const Expr* E) ->
bool {
8991 if (!MTE)
return false;
8992 const auto *Num = dyn_cast<
IntegerLiteral>(MTE->GetTemporaryExpr());
8993 if (!Num)
return false;
8994 if (Num->getValue() != 0)
return false;
9000 const bool IsFirstArgZero = IsLiteralZeroArg(FirstArg);
9001 const bool IsSecondArgZero = IsLiteralZeroArg(SecondArg);
9004 if (IsFirstArgZero == IsSecondArgZero)
return;
9009 SourceRange ZeroRange = IsFirstArgZero ? FirstRange : SecondRange;
9016 if (IsFirstArgZero) {
9049 << SizeRange << FnName;
9050 S.
Diag(FnLoc, diag::note_memsize_comparison_paren)
9055 S.
Diag(SizeRange.
getBegin(), diag::note_memsize_comparison_cast_silence)
9066 bool &IsContained) {
9069 IsContained =
false;
9082 for (
auto *FD : RD->
fields()) {
9095 if (
const auto *Unary = dyn_cast<UnaryExprOrTypeTraitExpr>(E))
9105 if (!SizeOf->isArgumentType())
9113 return SizeOf->getTypeOfArgument();
9119 struct SearchNonTrivialToInitializeField
9124 SearchNonTrivialToInitializeField(
const Expr *E,
Sema &S) : E(E), S(S) {}
9128 if (
const auto *AT = asDerived().getContext().getAsArrayType(FT)) {
9129 asDerived().visitArray(PDIK, AT, SL);
9133 Super::visitWithKind(PDIK, FT, SL);
9148 visit(getContext().getBaseElementType(AT), SL);
9153 SearchNonTrivialToInitializeField(E, S).visitStruct(RT,
SourceLocation());
9162 struct SearchNonTrivialToCopyField
9166 SearchNonTrivialToCopyField(
const Expr *E,
Sema &S) : E(E), S(S) {}
9170 if (
const auto *AT = asDerived().getContext().getAsArrayType(FT)) {
9171 asDerived().visitArray(PCK, AT, SL);
9175 Super::visitWithKind(PCK, FT, SL);
9190 visit(getContext().getBaseElementType(AT), SL);
9198 SearchNonTrivialToCopyField(E, S).visitStruct(RT,
SourceLocation());
9213 if (
const auto *BO = dyn_cast<BinaryOperator>(SizeofExpr)) {
9214 if (BO->getOpcode() != BO_Mul && BO->getOpcode() != BO_Add)
9247 if (BId != Builtin::BImemset && BId != Builtin::BIbzero)
9250 const Expr *SizeArg =
9253 auto isLiteralZero = [](
const Expr *E) {
9254 return isa<IntegerLiteral>(E) && cast<IntegerLiteral>(E)->getValue() == 0;
9260 if (isLiteralZero(SizeArg) &&
9267 if (BId == Builtin::BIbzero ||
9270 S.
Diag(DiagLoc, diag::warn_suspicious_bzero_size);
9271 S.
Diag(DiagLoc, diag::note_suspicious_bzero_size_silence);
9273 S.
Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 0;
9274 S.
Diag(DiagLoc, diag::note_suspicious_sizeof_memset_silence) << 0;
9282 if (BId == Builtin::BImemset &&
9286 S.
Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 1;
9287 S.
Diag(DiagLoc, diag::note_suspicious_sizeof_memset_silence) << 1;
9299 void Sema::CheckMemaccessArguments(
const CallExpr *Call,
9306 unsigned ExpectedNumArgs =
9307 (BId == Builtin::BIstrndup || BId == Builtin::BIbzero ? 2 : 3);
9311 unsigned LastArg = (BId == Builtin::BImemset || BId == Builtin::BIbzero ||
9312 BId == Builtin::BIstrndup ? 1 : 2);
9314 (BId == Builtin::BIbzero || BId == Builtin::BIstrndup ? 1 : 2);
9327 llvm::FoldingSetNodeID SizeOfArgID;
9336 for (
unsigned ArgIdx = 0; ArgIdx != LastArg; ++ArgIdx) {
9355 !Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess,
9359 if (SizeOfArgID == llvm::FoldingSetNodeID())
9360 SizeOfArg->
Profile(SizeOfArgID, Context,
true);
9361 llvm::FoldingSetNodeID DestID;
9362 Dest->
Profile(DestID, Context,
true);
9363 if (DestID == SizeOfArgID) {
9366 unsigned ActionIdx = 0;
9367 StringRef ReadableName = FnName->
getName();
9369 if (
const UnaryOperator *UnaryOp = dyn_cast<UnaryOperator>(Dest))
9370 if (UnaryOp->getOpcode() == UO_AddrOf)
9393 DiagRuntimeBehavior(SL, SizeOfArg,
9394 PDiag(diag::warn_sizeof_pointer_expr_memaccess)
9400 DiagRuntimeBehavior(SL, SizeOfArg,
9401 PDiag(diag::warn_sizeof_pointer_expr_memaccess_note)
9415 DiagRuntimeBehavior(LenExpr->
getExprLoc(), Dest,
9416 PDiag(diag::warn_sizeof_pointer_type_memaccess)
9417 << FnName << SizeOfArgTy << ArgIdx
9435 unsigned OperationType = 0;
9436 const bool IsCmp = BId == Builtin::BImemcmp || BId == Builtin::BIbcmp;
9439 if (ArgIdx != 0 || IsCmp) {
9440 if (BId == Builtin::BImemcpy)
9442 else if(BId == Builtin::BImemmove)
9448 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9449 PDiag(diag::warn_dyn_class_memaccess)
9450 << (IsCmp ? ArgIdx + 2 : ArgIdx) << FnName
9451 << IsContained << ContainedRD << OperationType
9454 BId != Builtin::BImemset)
9455 DiagRuntimeBehavior(
9457 PDiag(diag::warn_arc_object_memaccess)
9458 << ArgIdx << FnName << PointeeTy
9461 if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
9462 RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize()) {
9463 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9464 PDiag(diag::warn_cstruct_memaccess)
9465 << ArgIdx << FnName << PointeeTy << 0);
9466 SearchNonTrivialToInitializeField::diag(PointeeTy, Dest, *
this);
9467 }
else if ((BId == Builtin::BImemcpy || BId == Builtin::BImemmove) &&
9468 RT->getDecl()->isNonTrivialToPrimitiveCopy()) {
9469 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9470 PDiag(diag::warn_cstruct_memaccess)
9471 << ArgIdx << FnName << PointeeTy << 1);
9472 SearchNonTrivialToCopyField::diag(PointeeTy, Dest, *
this);
9479 DiagRuntimeBehavior(
9481 PDiag(diag::note_bad_memaccess_silence)
9501 if (isa<IntegerLiteral>(RHS))
9503 else if (isa<IntegerLiteral>(LHS))
9517 if (CAT->getSize().getSExtValue() <= 1)
9527 void Sema::CheckStrlcpycatArguments(
const CallExpr *Call,
9532 if ((NumArgs != 3) && (NumArgs != 4))
9537 const Expr *CompareWithSrc =
nullptr;
9545 CompareWithSrc = Ex;
9548 if (
const CallExpr *SizeCall = dyn_cast<CallExpr>(SizeArg)) {
9549 if (SizeCall->getBuiltinCallee() == Builtin::BIstrlen &&
9550 SizeCall->getNumArgs() == 1)
9555 if (!CompareWithSrc)
9567 if (!CompareWithSrcDRE ||
9571 const Expr *OriginalSizeArg = Call->
getArg(2);
9572 Diag(CompareWithSrcDRE->
getBeginLoc(), diag::warn_strlcpycat_wrong_size)
9584 llvm::raw_svector_ostream OS(sizeString);
9586 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9589 Diag(OriginalSizeArg->
getBeginLoc(), diag::note_strlcpycat_wrong_size)
9596 if (
const DeclRefExpr *D1 = dyn_cast_or_null<DeclRefExpr>(E1))
9597 if (
const DeclRefExpr *D2 = dyn_cast_or_null<DeclRefExpr>(E2))
9598 return D1->getDecl() == D2->getDecl();
9603 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
9607 return CE->getArg(0)->IgnoreParenCasts();
9615 void Sema::CheckStrncatArguments(
const CallExpr *CE,
9630 unsigned PatternType = 0;
9638 }
else if (
const BinaryOperator *BE = dyn_cast<BinaryOperator>(LenArg)) {
9639 if (BE->getOpcode() == BO_Sub) {
9652 if (PatternType == 0)
9671 if (!isKnownSizeArray) {
9672 if (PatternType == 1)
9673 Diag(SL, diag::warn_strncat_wrong_size) << SR;
9675 Diag(SL, diag::warn_strncat_src_size) << SR;
9679 if (PatternType == 1)
9680 Diag(SL, diag::warn_strncat_large_size) << SR;
9682 Diag(SL, diag::warn_strncat_src_size) << SR;
9685 llvm::raw_svector_ostream OS(sizeString);
9687 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9690 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9693 Diag(SL, diag::note_strncat_wrong_size)
9698 Sema::CheckReturnValExpr(
Expr *RetValExp,
QualType lhsType,
9704 if (((Attrs && hasSpecificAttr<ReturnsNonNullAttr>(*Attrs)) ||
9707 Diag(ReturnLoc, diag::warn_null_ret)
9717 if (Op == OO_New || Op == OO_Array_New) {
9722 Diag(ReturnLoc, diag::warn_operator_new_returns_null)
9723 << FD << getLangOpts().CPlusPlus11;
9739 if (
DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(LeftExprSansParen))
9740 if (
DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(RightExprSansParen))
9741 if (DRL->getDecl() == DRR->getDecl())
9749 if (
FloatingLiteral* FLL = dyn_cast<FloatingLiteral>(LeftExprSansParen)) {
9753 if (
FloatingLiteral* FLR = dyn_cast<FloatingLiteral>(RightExprSansParen))
9758 if (
CallExpr* CL = dyn_cast<CallExpr>(LeftExprSansParen))
9759 if (CL->getBuiltinCallee())
9762 if (
CallExpr* CR = dyn_cast<CallExpr>(RightExprSansParen))
9763 if (CR->getBuiltinCallee())
9767 Diag(Loc, diag::warn_floatingpoint_eq)
9785 IntRange(
unsigned Width,
bool NonNegative)
9786 : Width(Width), NonNegative(NonNegative) {}
9789 static IntRange forBoolType() {
9790 return IntRange(1,
true);
9795 return forValueOfCanonicalType(C,
9800 static IntRange forValueOfCanonicalType(
ASTContext &C,
const Type *T) {
9803 if (
const VectorType *VT = dyn_cast<VectorType>(T))
9804 T = VT->getElementType().getTypePtr();
9805 if (
const ComplexType *CT = dyn_cast<ComplexType>(T))
9806 T = CT->getElementType().getTypePtr();
9807 if (
const AtomicType *AT = dyn_cast<AtomicType>(T))
9808 T = AT->getValueType().getTypePtr();
9812 if (
const EnumType *ET = dyn_cast<EnumType>(T))
9813 T = ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
9814 }
else if (
const EnumType *ET = dyn_cast<EnumType>(T)) {
9821 !ET->isSignedIntegerOrEnumerationType());
9827 if (NumNegative == 0)
9828 return IntRange(NumPositive,
true);
9830 return IntRange(
std::max(NumPositive + 1, NumNegative),
9845 static IntRange forTargetOfCanonicalType(
ASTContext &C,
const Type *T) {
9848 if (
const VectorType *VT = dyn_cast<VectorType>(T))
9849 T = VT->getElementType().getTypePtr();
9850 if (
const ComplexType *CT = dyn_cast<ComplexType>(T))
9851 T = CT->getElementType().getTypePtr();
9852 if (
const AtomicType *AT = dyn_cast<AtomicType>(T))
9853 T = AT->getValueType().getTypePtr();
9854 if (
const EnumType *ET = dyn_cast<EnumType>(T))
9864 static IntRange join(IntRange L, IntRange R) {
9865 return IntRange(
std::max(L.Width, R.Width),
9866 L.NonNegative && R.NonNegative);
9870 static IntRange meet(IntRange L, IntRange R) {
9871 return IntRange(
std::min(L.Width, R.Width),
9872 L.NonNegative || R.NonNegative);
9879 unsigned MaxWidth) {
9880 if (value.isSigned() && value.isNegative())
9881 return IntRange(value.getMinSignedBits(),
false);
9883 if (value.getBitWidth() > MaxWidth)
9884 value = value.trunc(MaxWidth);
9888 return IntRange(value.getActiveBits(),
true);
9892 unsigned MaxWidth) {
9900 R = IntRange::join(R, El);
9908 return IntRange::join(R, I);
9923 Ty = AtomicRHS->getValueType();
9932 bool InConstantContext) {
9943 if (
const auto *CE = dyn_cast<ImplicitCastExpr>(E)) {
9944 if (CE->getCastKind() == CK_NoOp || CE->getCastKind() == CK_LValueToRValue)
9945 return GetExprRange(C, CE->getSubExpr(), MaxWidth, InConstantContext);
9947 IntRange OutputTypeRange = IntRange::forValueOfType(C,
GetExprType(CE));
9949 bool isIntegerCast = CE->getCastKind() == CK_IntegralCast ||
9950 CE->getCastKind() == CK_BooleanToSignedIntegral;
9954 return OutputTypeRange;
9957 std::min(MaxWidth, OutputTypeRange.Width),
9961 if (SubRange.Width >= OutputTypeRange.Width)
9962 return OutputTypeRange;
9966 return IntRange(SubRange.Width,
9967 SubRange.NonNegative || OutputTypeRange.NonNegative);
9970 if (
const auto *CO = dyn_cast<ConditionalOperator>(E)) {
9973 if (CO->getCond()->EvaluateAsBooleanCondition(CondResult, C))
9975 CondResult ? CO->getTrueExpr() : CO->getFalseExpr(),
9976 MaxWidth, InConstantContext);
9980 GetExprRange(C, CO->getTrueExpr(), MaxWidth, InConstantContext);
9982 GetExprRange(C, CO->getFalseExpr(), MaxWidth, InConstantContext);
9983 return IntRange::join(L, R);
9986 if (
const auto *BO = dyn_cast<BinaryOperator>(E)) {
9987 switch (BO->getOpcode()) {
9989 llvm_unreachable(
"builtin <=> should have class type");
10000 return IntRange::forBoolType();
10012 return IntRange::forValueOfType(C,
GetExprType(E));
10018 return GetExprRange(C, BO->getRHS(), MaxWidth, InConstantContext);
10023 return IntRange::forValueOfType(C,
GetExprType(E));
10028 return IntRange::meet(
10029 GetExprRange(C, BO->getLHS(), MaxWidth, InConstantContext),
10030 GetExprRange(C, BO->getRHS(), MaxWidth, InConstantContext));
10037 = dyn_cast<IntegerLiteral>(BO->getLHS()->IgnoreParenCasts())) {
10038 if (I->getValue() == 1) {
10039 IntRange R = IntRange::forValueOfType(C,
GetExprType(E));
10040 return IntRange(R.Width,
true);
10046 return IntRange::forValueOfType(C,
GetExprType(E));
10050 case BO_ShrAssign: {
10051 IntRange L =
GetExprRange(C, BO->getLHS(), MaxWidth, InConstantContext);
10055 llvm::APSInt shift;
10056 if (BO->getRHS()->isIntegerConstantExpr(shift, C) &&
10057 shift.isNonNegative()) {
10058 unsigned zext = shift.getZExtValue();
10059 if (zext >= L.Width)
10060 L.Width = (L.NonNegative ? 0 : 1);
10070 return GetExprRange(C, BO->getRHS(), MaxWidth, InConstantContext);
10074 if (BO->getLHS()->getType()->isPointerType())
10075 return IntRange::forValueOfType(C,
GetExprType(E));
10083 IntRange L =
GetExprRange(C, BO->getLHS(), opWidth, InConstantContext);
10086 llvm::APSInt divisor;
10087 if (BO->getRHS()->isIntegerConstantExpr(divisor, C)) {
10088 unsigned log2 = divisor.logBase2();
10089 if (log2 >= L.Width)
10090 L.Width = (L.NonNegative ? 0 : 1);
10092 L.Width =
std::min(L.Width - log2, MaxWidth);
10097 IntRange R =
GetExprRange(C, BO->getRHS(), opWidth, InConstantContext);
10098 return IntRange(L.Width, L.NonNegative && R.NonNegative);
10106 IntRange L =
GetExprRange(C, BO->getLHS(), opWidth, InConstantContext);
10107 IntRange R =
GetExprRange(C, BO->getRHS(), opWidth, InConstantContext);
10109 IntRange meet = IntRange::meet(L, R);
10110 meet.Width =
std::min(meet.Width, MaxWidth);
10124 IntRange L =
GetExprRange(C, BO->getLHS(), MaxWidth, InConstantContext);
10125 IntRange R =
GetExprRange(C, BO->getRHS(), MaxWidth, InConstantContext);
10126 return IntRange::join(L, R);
10129 if (
const auto *UO = dyn_cast<UnaryOperator>(E)) {
10130 switch (UO->getOpcode()) {
10133 return IntRange::forBoolType();
10138 return IntRange::forValueOfType(C,
GetExprType(E));
10141 return GetExprRange(C, UO->getSubExpr(), MaxWidth, InConstantContext);
10145 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
10146 return GetExprRange(C, OVE->getSourceExpr(), MaxWidth, InConstantContext);
10149 return IntRange(BitField->getBitWidthValue(C),
10150 BitField->getType()->isUnsignedIntegerOrEnumerationType());
10152 return IntRange::forValueOfType(C,
GetExprType(E));
10156 bool InConstantContext) {
10164 const llvm::fltSemantics &Src,
10165 const llvm::fltSemantics &Tgt) {
10166 llvm::APFloat truncated = value;
10169 truncated.convert(Src, llvm::APFloat::rmNearestTiesToEven, &ignored);
10170 truncated.convert(Tgt, llvm::APFloat::rmNearestTiesToEven, &ignored);
10172 return truncated.bitwiseIsEqual(value);
10181 const llvm::fltSemantics &Src,
10182 const llvm::fltSemantics &Tgt) {
10204 if (isa<EnumConstantDecl>(DR->getDecl()))
10214 return MacroName !=
"YES" && MacroName !=
"NO" &&
10215 MacroName !=
"true" && MacroName !=
"false";
10238 struct PromotedRange {
10240 llvm::APSInt PromotedMin;
10242 llvm::APSInt PromotedMax;
10244 PromotedRange(IntRange R,
unsigned BitWidth,
bool Unsigned) {
10246 PromotedMin = PromotedMax = llvm::APSInt(BitWidth, Unsigned);
10247 else if (R.Width >= BitWidth && !Unsigned) {
10251 PromotedMin = llvm::APSInt::getMinValue(BitWidth, Unsigned);
10252 PromotedMax = llvm::APSInt::getMaxValue(BitWidth, Unsigned);
10254 PromotedMin = llvm::APSInt::getMinValue(R.Width, R.NonNegative)
10255 .extOrTrunc(BitWidth);
10256 PromotedMin.setIsUnsigned(Unsigned);
10258 PromotedMax = llvm::APSInt::getMaxValue(R.Width, R.NonNegative)
10259 .extOrTrunc(BitWidth);
10260 PromotedMax.setIsUnsigned(Unsigned);
10265 bool isContiguous()
const {
return PromotedMin <= PromotedMax; }
10268 enum ComparisonResult {
10275 InRangeFlag = 0x40,
10278 Min = LE | InRangeFlag,
10279 InRange = InRangeFlag,
10280 Max = GE | InRangeFlag,
10283 OnlyValue = LE | GE | EQ | InRangeFlag,
10287 ComparisonResult
compare(
const llvm::APSInt &
Value)
const {
10288 assert(Value.getBitWidth() == PromotedMin.getBitWidth() &&
10289 Value.isUnsigned() == PromotedMin.isUnsigned());
10290 if (!isContiguous()) {
10291 assert(Value.isUnsigned() &&
"discontiguous range for signed compare");
10292 if (Value.isMinValue())
return Min;
10293 if (Value.isMaxValue())
return Max;
10294 if (Value >= PromotedMin)
return InRange;
10295 if (Value <= PromotedMax)
return InRange;
10299 switch (llvm::APSInt::compareValues(Value, PromotedMin)) {
10300 case -1:
return Less;
10301 case 0:
return PromotedMin == PromotedMax ? OnlyValue : Min;
10303 switch (llvm::APSInt::compareValues(Value, PromotedMax)) {
10304 case -1:
return InRange;
10305 case 0:
return Max;
10310 llvm_unreachable(
"impossible compare result");
10315 if (Op == BO_Cmp) {
10316 ComparisonResult LTFlag =
LT, GTFlag = GT;
10317 if (ConstantOnRHS) std::swap(LTFlag, GTFlag);
10319 if (R & EQ)
return StringRef(
"'std::strong_ordering::equal'");
10320 if (R & LTFlag)
return StringRef(
"'std::strong_ordering::less'");
10321 if (R & GTFlag)
return StringRef(
"'std::strong_ordering::greater'");
10325 ComparisonResult TrueFlag, FalseFlag;
10329 }
else if (Op == BO_NE) {
10333 if ((Op == BO_LT || Op == BO_GE) ^ ConstantOnRHS) {
10340 if (Op == BO_GE || Op == BO_LE)
10341 std::swap(TrueFlag, FalseFlag);
10344 return StringRef(
"true");
10346 return StringRef(
"false");
10355 if (ICE->getCastKind() != CK_IntegralCast &&
10356 ICE->getCastKind() != CK_NoOp)
10358 E = ICE->getSubExpr();
10367 enum ConstantValueKind {
10372 if (
auto *BL = dyn_cast<CXXBoolLiteralExpr>(Constant))
10373 return BL->getValue() ? ConstantValueKind::LiteralTrue
10374 : ConstantValueKind::LiteralFalse;
10375 return ConstantValueKind::Miscellaneous;
10380 const llvm::APSInt &
Value,
10381 bool RhsConstant) {
10385 Expr *OriginalOther = Other;
10405 OtherT = AT->getValueType();
10406 IntRange OtherRange = IntRange::forValueOfType(S.
Context, OtherT);
10410 bool IsObjCSignedCharBool = S.
getLangOpts().ObjC &&
10411 S.
NSAPIObj->isObjCBOOLType(OtherT) &&
10416 bool OtherIsBooleanDespiteType =
10418 if (OtherIsBooleanDespiteType || IsObjCSignedCharBool)
10419 OtherRange = IntRange::forBoolType();
10423 PromotedRange OtherPromotedRange(OtherRange, Value.getBitWidth(),
10424 Value.isUnsigned());
10425 auto Cmp = OtherPromotedRange.compare(Value);
10426 auto Result = PromotedRange::constantValue(E->
getOpcode(), Cmp, RhsConstant);
10436 bool InRange = Cmp & PromotedRange::InRangeFlag;
10443 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Constant))
10444 ED = dyn_cast<EnumConstantDecl>(DR->getDecl());
10448 llvm::raw_svector_ostream OS(PrettySourceValue);
10450 OS <<
'\'' << *ED <<
"' (" << Value <<
")";
10451 }
else if (
auto *BL = dyn_cast<ObjCBoolLiteralExpr>(
10453 OS << (BL->getValue() ?
"YES" :
"NO");
10458 if (IsObjCSignedCharBool) {
10460 S.
PDiag(diag::warn_tautological_compare_objc_bool)
10461 << OS.str() << *Result);
10472 S.
PDiag(!InRange ? diag::warn_out_of_range_compare
10473 : diag::warn_tautological_bool_compare)
10475 << OtherIsBooleanDespiteType << *Result
10480 ? diag::warn_unsigned_enum_always_true_comparison
10481 : diag::warn_unsigned_always_true_comparison)
10482 : diag::warn_tautological_constant_compare;
10485 << RhsConstant << OtherT << E->
getOpcodeStr() << OS.str() << *Result
10519 llvm::APSInt RHSValue;
10520 llvm::APSInt LHSValue;
10526 if (IsRHSIntegralLiteral && IsLHSIntegralLiteral)
10530 if (IsRHSIntegralLiteral ^ IsLHSIntegralLiteral) {
10532 const bool RhsConstant = IsRHSIntegralLiteral;
10533 Expr *Const = RhsConstant ? RHS : LHS;
10534 Expr *Other = RhsConstant ? LHS : RHS;
10535 const llvm::APSInt &
Value = RhsConstant ? RHSValue : LHSValue;
10558 if (
const auto *TET = dyn_cast<TypeOfExprType>(LHS->
getType()))
10560 if (
const auto *TET = dyn_cast<TypeOfExprType>(RHS->
getType()))
10566 Expr *signedOperand, *unsignedOperand;
10569 "unsigned comparison between two signed integer expressions?");
10570 signedOperand = LHS;
10571 unsignedOperand = RHS;
10573 signedOperand = RHS;
10574 unsignedOperand = LHS;
10580 IntRange signedRange =
10589 if (signedRange.NonNegative)
10598 IntRange unsignedRange =
10603 assert(unsignedRange.NonNegative &&
"unsigned range includes negative?");
10605 if (unsignedRange.Width < comparisonWidth)
10610 S.
PDiag(diag::warn_mixed_sign_comparison)
10638 S.
Diag(InitLoc, diag::warn_no_underlying_type_specified_for_enum_bitfield)
10676 unsigned DiagID = 0;
10677 if (SignedEnum && !SignedBitfield) {
10678 DiagID = diag::warn_unsigned_bitfield_assigned_signed_enum;
10679 }
else if (SignedBitfield && !SignedEnum &&
10681 DiagID = diag::warn_signed_bitfield_enum_conversion;
10685 S.
Diag(InitLoc, DiagID) << Bitfield << ED;
10690 << SignedEnum << TypeRange;
10701 if (BitsNeeded > FieldWidth) {
10703 S.
Diag(InitLoc, diag::warn_bitfield_too_small_for_enum)
10715 unsigned OriginalWidth = Value.getBitWidth();
10717 if (!Value.isSigned() || Value.isNegative())
10718 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(OriginalInit))
10719 if (UO->getOpcode() == UO_Minus || UO->getOpcode() == UO_Not)
10720 OriginalWidth = Value.getMinSignedBits();
10722 if (OriginalWidth <= FieldWidth)
10726 llvm::APSInt TruncatedValue = Value.trunc(FieldWidth);
10730 TruncatedValue = TruncatedValue.extend(OriginalWidth);
10731 if (llvm::APSInt::isSameValue(Value, TruncatedValue))
10736 if (FieldWidth == 1 && Value == 1)
10739 std::string PrettyValue = Value.toString(10);
10740 std::string PrettyTrunc = TruncatedValue.toString(10);
10742 S.
Diag(InitLoc, diag::warn_impcast_bitfield_precision_constant)
10743 << PrettyValue << PrettyTrunc << OriginalInit->
getType()
10776 bool pruneControlFlow =
false) {
10777 if (pruneControlFlow) {
10791 unsigned diag,
bool pruneControlFlow =
false) {
10804 if (UOp->getOpcode() == UO_Minus || UOp->getOpcode() == UO_Plus)
10807 const bool IsLiteral =
10808 isa<FloatingLiteral>(E) || isa<FloatingLiteral>(InnerE);
10810 llvm::APFloat
Value(0.0);
10815 diag::warn_impcast_float_integer, PruneWarnings);
10818 bool isExact =
false;
10822 llvm::APFloat::opStatus Result = Value.convertToInteger(
10823 IntegerValue, llvm::APFloat::rmTowardZero, &isExact);
10825 if (Result == llvm::APFloat::opOK && isExact) {
10826 if (IsLiteral)
return;
10827 return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer,
10833 if (!IsBool && Result == llvm::APFloat::opInvalidOp)
10836 IsLiteral ? diag::warn_impcast_literal_float_to_integer_out_of_range
10837 : diag::warn_impcast_float_to_integer_out_of_range,
10840 unsigned DiagID = 0;
10843 DiagID = diag::warn_impcast_literal_float_to_integer;
10844 }
else if (IntegerValue == 0) {
10845 if (Value.isZero()) {
10847 diag::warn_impcast_float_integer, PruneWarnings);
10850 DiagID = diag::warn_impcast_float_to_integer_zero;
10852 if (IntegerValue.isUnsigned()) {
10853 if (!IntegerValue.isMaxValue()) {
10855 diag::warn_impcast_float_integer, PruneWarnings);
10858 if (!IntegerValue.isMaxSignedValue() &&
10859 !IntegerValue.isMinSignedValue()) {
10861 diag::warn_impcast_float_integer, PruneWarnings);
10865 DiagID = diag::warn_impcast_float_to_integer;
10874 unsigned precision = llvm::APFloat::semanticsPrecision(Value.getSemantics());
10875 precision = (precision * 59 + 195) / 196;
10876 Value.toString(PrettySourceValue, precision);
10880 PrettyTargetValue = Value.isZero() ?
"false" :
"true";
10882 IntegerValue.toString(PrettyTargetValue);
10884 if (PruneWarnings) {
10888 << PrettySourceValue << PrettyTargetValue
10900 assert(isa<CompoundAssignOperator>(E) &&
10901 "Must be compound assignment operation");
10911 const auto *RBT = cast<CompoundAssignOperator>(E)
10912 ->getComputationResultType()
10919 if (ResultBT->isInteger())
10921 E->
getExprLoc(), diag::warn_impcast_float_integer);
10923 if (!ResultBT->isFloatingPoint())
10932 diag::warn_impcast_float_result_precision);
10937 if (!Range.Width)
return "0";
10939 llvm::APSInt ValueInRange =
Value;
10940 ValueInRange.setIsSigned(!Range.NonNegative);
10941 ValueInRange = ValueInRange.trunc(Range.Width);
10942 return ValueInRange.toString(10);
10946 if (!isa<ImplicitCastExpr>(Ex))
10951 const Type *Source =
10958 const Type *BoolCandidateType = ToBool ? Target : Source;
10960 return (BoolCandidateType->isSpecificBuiltinType(BuiltinType::Bool) &&
10967 for (
unsigned i = 0;
i < NumArgs; ++
i) {
10972 bool IsSwapped = ((
i > 0) &&
10974 IsSwapped |= ((
i < (NumArgs - 1)) &&
10980 diag::warn_impcast_floating_point_to_bool);
10987 if (S.
Diags.
isIgnored(diag::warn_impcast_null_pointer_to_integer,
10992 if (isa<CallExpr>(E))
11018 if (MacroName ==
"NULL")
11026 S.
Diag(Loc, diag::warn_impcast_null_pointer_to_integer)
11044 unsigned ElementKind) {
11046 if (
auto ICE = dyn_cast<ImplicitCastExpr>(Element)) {
11047 if (ICE->getCastKind() == CK_BitCast &&
11049 Element = ICE->getSubExpr();
11059 S.
Diag(Element->
getBeginLoc(), diag::warn_objc_collection_literal_element)
11060 << ElementType << ElementKind << TargetElementType
11064 if (
auto ArrayLiteral = dyn_cast<ObjCArrayLiteral>(Element))
11066 else if (
auto DictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(Element))
11078 if (!TargetObjCPtr)
11081 if (TargetObjCPtr->isUnspecialized() ||
11082 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
11087 if (TypeArgs.size() != 1)
11090 QualType TargetElementType = TypeArgs[0];
11091 for (
unsigned I = 0, N = ArrayLiteral->
getNumElements(); I != N; ++I) {
11107 if (!TargetObjCPtr)
11110 if (TargetObjCPtr->isUnspecialized() ||
11111 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
11116 if (TypeArgs.size() != 2)
11119 QualType TargetKeyType = TypeArgs[0];
11120 QualType TargetObjectType = TypeArgs[1];
11121 for (
unsigned I = 0, N = DictionaryLiteral->
getNumElements(); I != N; ++I) {
11136 const char FirstLiteralCharacter =
11138 if (FirstLiteralCharacter ==
'0')
11145 const char FirstContextCharacter =
11147 if (FirstContextCharacter ==
'{')
11161 bool *ICContext =
nullptr) {
11166 if (Source == Target)
return;
11182 if (isa<StringLiteral>(E))
11187 diag::warn_impcast_string_literal_to_bool);
11188 if (isa<ObjCStringLiteral>(E) || isa<ObjCArrayLiteral>(E) ||
11189 isa<ObjCDictionaryLiteral>(E) || isa<ObjCBoxedExpr>(E)) {
11193 diag::warn_impcast_objective_c_literal_to_bool);
11210 auto Builder = S.
Diag(CC, diag::warn_impcast_constant_int_to_objc_bool)
11213 bool NeedsParens = isa<AbstractConditionalOperator>(Ignored) ||
11214 isa<BinaryOperator>(Ignored) ||
11215 isa<CXXOperatorCallExpr>(Ignored);
11227 if (
auto *ArrayLiteral = dyn_cast<ObjCArrayLiteral>(E))
11229 else if (
auto *DictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(E))
11233 if (isa<VectorType>(Source)) {
11234 if (!isa<VectorType>(Target)) {
11237 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_vector_scalar);
11245 Source = cast<VectorType>(Source)->getElementType().getTypePtr();
11246 Target = cast<VectorType>(Target)->getElementType().getTypePtr();
11248 if (
auto VecTy = dyn_cast<VectorType>(Target))
11249 Target = VecTy->getElementType().getTypePtr();
11252 if (isa<ComplexType>(Source)) {
11253 if (!isa<ComplexType>(Target)) {
11259 ? diag::err_impcast_complex_scalar
11260 : diag::warn_impcast_complex_scalar);
11263 Source = cast<ComplexType>(Source)->getElementType().getTypePtr();
11264 Target = cast<ComplexType>(Target)->getElementType().getTypePtr();
11273 if (TargetBT && TargetBT->isFloatingPoint()) {
11296 else if (Order < 0) {
11306 if (TargetBT && TargetBT->isInteger()) {
11325 CallExpr *CEx = cast<CallExpr>(E);
11329 if (isa<ImplicitCastExpr>(LastA) &&
11333 diag::warn_impcast_floating_point_to_bool);
11349 if (Value > MaxVal || Value < MinVal) {
11351 S.
PDiag(diag::warn_impcast_fixed_point_range)
11372 S.
PDiag(diag::warn_impcast_fixed_point_range)
11393 S.
PDiag(diag::warn_impcast_fixed_point_range)
11394 << Value.toString(10) << T
11416 IntRange TargetRange = IntRange::forTargetOfCanonicalType(S.
Context, Target);
11418 if (SourceRange.Width > TargetRange.Width) {
11424 llvm::APSInt
Value(32);
11430 std::string PrettySourceValue = Value.toString(10);
11435 S.
PDiag(diag::warn_impcast_integer_precision_constant)
11436 << PrettySourceValue << PrettyTargetValue << E->
getType() << T
11446 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_64_32,
11448 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_precision);
11451 if (TargetRange.Width > SourceRange.Width) {
11452 if (
auto *UO = dyn_cast<UnaryOperator>(E))
11453 if (UO->getOpcode() == UO_Minus)
11457 diag::warn_impcast_high_order_zero_bits);
11460 diag::warn_impcast_nonnegative_result);
11464 if (TargetRange.Width == SourceRange.Width && !TargetRange.NonNegative &&
11475 std::string PrettySourceValue = Value.toString(10);
11480 S.
PDiag(diag::warn_impcast_integer_precision_constant)
11481 << PrettySourceValue << PrettyTargetValue << E->
getType() << T
11490 if ((TargetRange.NonNegative && !SourceRange.NonNegative) ||
11491 (!TargetRange.NonNegative && SourceRange.NonNegative &&
11492 SourceRange.Width == TargetRange.Width)) {
11496 unsigned DiagID = diag::warn_impcast_integer_sign;
11504 DiagID = diag::warn_impcast_integer_sign_conditional;
11518 EnumDecl *Enum = cast<EnumDecl>(ECD->getDeclContext());
11526 if (SourceEnum->getDecl()->hasNameForLinkage() &&
11527 TargetEnum->getDecl()->hasNameForLinkage() &&
11528 SourceEnum != TargetEnum) {
11533 diag::warn_impcast_different_enum_types);
11544 if (isa<ConditionalOperator>(E))
11556 bool Suspicious =
false;
11562 if (!Suspicious)
return;
11565 if (!S.
Diags.
isIgnored(diag::warn_impcast_integer_sign_conditional, CC))
11570 if (E->
getType() == T)
return;
11572 Suspicious =
false;
11574 E->
getType(), CC, &Suspicious);
11577 E->
getType(), CC, &Suspicious);
11603 if (isa<ConditionalOperator>(E)) {
11610 if (
CallExpr *Call = dyn_cast<CallExpr>(E))
11625 for (
auto *SE : POE->semantics())
11626 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(SE))
11631 if (
auto *CE = dyn_cast<ExplicitCastExpr>(E)) {
11640 if (BO->isComparisonOp())
11644 if (BO->getOpcode() == BO_Assign)
11647 if (BO->isAssignmentOp())
11655 if (isa<StmtExpr>(E))
return;
11658 if (isa<UnaryExprOrTypeTraitExpr>(E))
return;
11663 bool IsLogicalAndOperator = BO && BO->
getOpcode() == BO_LAnd;
11665 Expr *ChildExpr = dyn_cast_or_null<Expr>(SubStmt);
11669 if (IsLogicalAndOperator &&
11679 if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
11683 if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
11688 if (U->getOpcode() == UO_LNot) {
11690 }
else if (U->getOpcode() != UO_AddrOf) {
11691 if (U->getSubExpr()->getType()->isAtomicType())
11692 S.
Diag(U->getSubExpr()->getBeginLoc(),
11693 diag::warn_atomic_implicit_seq_cst);
11704 diag::err_opencl_enqueue_kernel_invalid_local_size_type);
11721 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11722 if (!DRE->getDecl()->getType()->isReferenceType())
11724 }
else if (
const MemberExpr *M = dyn_cast<MemberExpr>(E)) {
11725 if (!M->getMemberDecl()->getType()->isReferenceType())
11727 }
else if (
const CallExpr *Call = dyn_cast<CallExpr>(E)) {
11739 SemaRef.
Diag(FD->
getLocation(), diag::note_reference_is_return_value) << FD;
11784 if (isa<CXXThisExpr>(E)) {
11785 unsigned DiagID = IsCompare ? diag::warn_this_null_compare
11786 : diag::warn_this_bool_conversion;
11791 bool IsAddressOf =
false;
11794 if (UO->getOpcode() != UO_AddrOf)
11796 IsAddressOf =
true;
11797 E = UO->getSubExpr();
11801 unsigned DiagID = IsCompare
11802 ? diag::warn_address_of_reference_null_compare
11803 : diag::warn_address_of_reference_bool_conversion;
11811 auto ComplainAboutNonnullParamOrCall = [&](
const Attr *NonnullAttr) {
11812 bool IsParam = isa<NonNullAttr>(NonnullAttr);
11814 llvm::raw_string_ostream S(Str);
11816 unsigned DiagID = IsCompare ? diag::warn_nonnull_expr_compare
11817 : diag::warn_cast_nonnull_to_bool;
11820 Diag(NonnullAttr->getLocation(), diag::note_declared_nonnull) << IsParam;
11826 if (
const Attr *A = Callee->getAttr<ReturnsNonNullAttr>()) {
11827 ComplainAboutNonnullParamOrCall(A);
11837 }
else if (
MemberExpr *M = dyn_cast<MemberExpr>(E)) {
11838 D = M->getMemberDecl();
11846 if (
const auto* PV = dyn_cast<ParmVarDecl>(D)) {
11847 if (getCurFunction() &&
11848 !getCurFunction()->ModifiedNonNullParams.count(PV)) {
11849 if (
const Attr *A = PV->getAttr<NonNullAttr>()) {
11850 ComplainAboutNonnullParamOrCall(A);
11854 if (
const auto *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
11858 auto ParamIter = llvm::find(FD->
parameters(), PV);
11864 ComplainAboutNonnullParamOrCall(
NonNull);
11869 if (ArgNo.getASTIndex() == ParamNo) {
11870 ComplainAboutNonnullParamOrCall(
NonNull);
11884 if (IsAddressOf && IsFunction) {
11889 if (!IsAddressOf && !IsFunction && !IsArray)
11894 llvm::raw_string_ostream S(Str);
11897 unsigned DiagID = IsCompare ? diag::warn_null_pointer_compare
11898 : diag::warn_impcast_pointer_to_bool;
11905 DiagType = AddressOf;
11906 else if (IsFunction)
11907 DiagType = FunctionPointer;
11909 DiagType = ArrayPointer;
11911 llvm_unreachable(
"Could not determine diagnostic.");
11913 << Range << IsEqual;
11925 tryExprAsCall(*E, ReturnType, NonTemplateOverloads);
11926 if (ReturnType.isNull())
11933 if (!ReturnType->isPointerType()) {
11936 if (!ReturnType->isIntegerType())
11945 if (!ReturnType->isSpecificBuiltinType(BuiltinType::Bool))
11961 if (isUnevaluatedContext())
11971 CheckArrayAccess(E);
11985 void Sema::CheckForIntOverflow (
Expr *E) {
11990 Expr *OriginalE = Exprs.pop_back_val();
11993 if (isa<BinaryOperator>(E)) {
11998 if (
auto InitList = dyn_cast<InitListExpr>(OriginalE))
11999 Exprs.append(InitList->inits().begin(), InitList->inits().end());
12000 else if (isa<ObjCBoxedExpr>(OriginalE))
12002 else if (
auto Call = dyn_cast<CallExpr>(E))
12004 else if (
auto Message = dyn_cast<ObjCMessageExpr>(E))
12005 Exprs.append(Message->arg_begin(), Message->arg_end());
12006 }
while (!Exprs.empty());
12021 class SequenceTree {
12025 unsigned Merged : 1;
12033 friend class SequenceTree;
12037 explicit Seq(
unsigned N) : Index(N) {}
12040 Seq() : Index(0) {}
12043 SequenceTree() { Values.push_back(
Value(0)); }
12044 Seq root()
const {
return Seq(0); }
12049 Seq allocate(Seq
Parent) {
12050 Values.push_back(
Value(Parent.Index));
12051 return Seq(Values.size() - 1);
12055 void merge(Seq S) {
12056 Values[S.Index].Merged =
true;
12062 bool isUnsequenced(Seq Cur, Seq Old) {
12063 unsigned C = representative(Cur.Index);
12064 unsigned Target = representative(Old.Index);
12065 while (C >= Target) {
12068 C = Values[
C].Parent;
12075 unsigned representative(
unsigned K) {
12076 if (Values[K].Merged)
12078 return Values[K].Parent = representative(Values[K].Parent);
12098 UK_ModAsSideEffect,
12100 UK_Count = UK_ModAsSideEffect + 1
12105 SequenceTree::Seq Seq;
12107 Usage() : Use(
nullptr), Seq() {}
12111 Usage Uses[UK_Count];
12116 UsageInfo() : Uses(), Diagnosed(
false) {}
12118 using UsageInfoMap = llvm::SmallDenseMap<Object, UsageInfo, 16>;
12126 UsageInfoMap UsageMap;
12129 SequenceTree::Seq Region;
12144 struct SequencedSubexpression {
12145 SequencedSubexpression(SequenceChecker &Self)
12146 : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) {
12147 Self.ModAsSideEffect = &ModAsSideEffect;
12150 ~SequencedSubexpression() {
12151 for (
auto &M : llvm::reverse(ModAsSideEffect)) {
12152 UsageInfo &U = Self.UsageMap[M.first];
12153 auto &SideEffectUsage = U.Uses[UK_ModAsSideEffect];
12154 Self.addUsage(U, M.first, SideEffectUsage.Use, UK_ModAsValue);
12155 SideEffectUsage = M.second;
12157 Self.ModAsSideEffect = OldModAsSideEffect;
12160 SequenceChecker &Self;
12169 class EvaluationTracker {
12171 EvaluationTracker(SequenceChecker &Self)
12172 : Self(Self), Prev(Self.EvalTracker) {
12173 Self.EvalTracker =
this;
12176 ~EvaluationTracker() {
12177 Self.EvalTracker = Prev;
12179 Prev->EvalOK &= EvalOK;
12182 bool evaluate(
const Expr *E,
bool &Result) {
12186 Result, Self.SemaRef.Context, Self.SemaRef.isConstantEvaluated());
12191 SequenceChecker &Self;
12192 EvaluationTracker *Prev;
12193 bool EvalOK =
true;
12194 } *EvalTracker =
nullptr;
12198 Object getObject(
Expr *E,
bool Mod)
const {
12201 if (Mod && (UO->getOpcode() == UO_PreInc || UO->getOpcode() == UO_PreDec))
12202 return getObject(UO->getSubExpr(), Mod);
12204 if (BO->getOpcode() == BO_Comma)
12205 return getObject(BO->getRHS(), Mod);
12206 if (Mod && BO->isAssignmentOp())
12207 return getObject(BO->getLHS(), Mod);
12208 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
12210 if (isa<CXXThisExpr>(ME->getBase()->IgnoreParenCasts()))
12211 return ME->getMemberDecl();
12212 }
else if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
12214 return DRE->getDecl();
12219 void addUsage(UsageInfo &UI, Object O,
Expr *Ref, UsageKind UK) {
12220 Usage &U = UI.Uses[UK];
12221 if (!U.Use || !Tree.isUnsequenced(Region, U.Seq)) {
12222 if (UK == UK_ModAsSideEffect && ModAsSideEffect)
12223 ModAsSideEffect->push_back(std::make_pair(O, U));
12230 void checkUsage(Object O, UsageInfo &UI,
Expr *Ref, UsageKind OtherKind,
12235 const Usage &U = UI.Uses[OtherKind];
12236 if (!U.Use || !Tree.isUnsequenced(Region, U.Seq))
12240 Expr *ModOrUse = Ref;
12241 if (OtherKind == UK_Use)
12242 std::swap(Mod, ModOrUse);
12246 SemaRef.
PDiag(IsModMod ? diag::warn_unsequenced_mod_mod
12247 : diag::warn_unsequenced_mod_use)
12249 UI.Diagnosed =
true;
12252 void notePreUse(Object O,
Expr *Use) {
12253 UsageInfo &U = UsageMap[O];
12255 checkUsage(O, U, Use, UK_ModAsValue,
false);
12258 void notePostUse(Object O,
Expr *Use) {
12259 UsageInfo &U = UsageMap[O];
12260 checkUsage(O, U, Use, UK_ModAsSideEffect,
false);
12261 addUsage(U, O, Use, UK_Use);
12264 void notePreMod(Object O,
Expr *Mod) {
12265 UsageInfo &U = UsageMap[O];
12267 checkUsage(O, U, Mod, UK_ModAsValue,
true);
12268 checkUsage(O, U, Mod, UK_Use,
false);
12271 void notePostMod(Object O,
Expr *Use, UsageKind UK) {
12272 UsageInfo &U = UsageMap[O];
12273 checkUsage(O, U, Use, UK_ModAsSideEffect,
true);
12274 addUsage(U, O, Use, UK);
12279 :
Base(S.
Context), SemaRef(S), Region(Tree.root()), WorkList(WorkList) {
12283 void VisitStmt(
Stmt *S) {
12287 void VisitExpr(
Expr *E) {
12289 Base::VisitStmt(E);
12293 Object O = Object();
12304 void VisitSequencedExpressions(
Expr *SequencedBefore,
Expr *SequencedAfter) {
12305 SequenceTree::Seq BeforeRegion = Tree.allocate(Region);
12306 SequenceTree::Seq AfterRegion = Tree.allocate(Region);
12307 SequenceTree::Seq OldRegion = Region;
12310 SequencedSubexpression SeqBefore(*
this);
12311 Region = BeforeRegion;
12312 Visit(SequencedBefore);
12315 Region = AfterRegion;
12316 Visit(SequencedAfter);
12318 Region = OldRegion;
12320 Tree.merge(BeforeRegion);
12321 Tree.merge(AfterRegion);
12329 VisitSequencedExpressions(ASE->
getLHS(), ASE->
getRHS());
12331 Base::VisitStmt(ASE);
12339 VisitSequencedExpressions(BO->
getLHS(), BO->
getRHS());
12346 Object O = getObject(BO->
getLHS(),
true);
12348 return VisitExpr(BO);
12358 if (isa<CompoundAssignOperator>(BO))
12363 if (isa<CompoundAssignOperator>(BO))
12364 notePostUse(O, BO);
12372 notePostMod(O, BO, SemaRef.
getLangOpts().CPlusPlus ? UK_ModAsValue
12373 : UK_ModAsSideEffect);
12377 VisitBinAssign(CAO);
12380 void VisitUnaryPreInc(
UnaryOperator *UO) { VisitUnaryPreIncDec(UO); }
12381 void VisitUnaryPreDec(
UnaryOperator *UO) { VisitUnaryPreIncDec(UO); }
12383 Object O = getObject(UO->
getSubExpr(),
true);
12385 return VisitExpr(UO);
12391 notePostMod(O, UO, SemaRef.
getLangOpts().CPlusPlus ? UK_ModAsValue
12392 : UK_ModAsSideEffect);
12395 void VisitUnaryPostInc(
UnaryOperator *UO) { VisitUnaryPostIncDec(UO); }
12396 void VisitUnaryPostDec(
UnaryOperator *UO) { VisitUnaryPostIncDec(UO); }
12398 Object O = getObject(UO->
getSubExpr(),
true);
12400 return VisitExpr(UO);
12404 notePostMod(O, UO, UK_ModAsSideEffect);
12413 EvaluationTracker Eval(*
this);
12415 SequencedSubexpression Sequenced(*
this);
12420 if (Eval.evaluate(BO->
getLHS(), Result)) {
12430 WorkList.push_back(BO->
getRHS());
12434 EvaluationTracker Eval(*
this);
12436 SequencedSubexpression Sequenced(*
this);
12441 if (Eval.evaluate(BO->
getLHS(), Result)) {
12445 WorkList.push_back(BO->
getRHS());
12452 EvaluationTracker Eval(*
this);
12454 SequencedSubexpression Sequenced(*
this);
12459 if (Eval.evaluate(CO->
getCond(), Result))
12467 void VisitCallExpr(
CallExpr *CE) {
12474 SequencedSubexpression Sequenced(*
this);
12475 Base::VisitCallExpr(CE);
12482 SequencedSubexpression Sequenced(*
this);
12485 return VisitExpr(CCE);
12489 SequenceTree::Seq
Parent = Region;
12493 Region = Tree.allocate(Parent);
12494 Elts.push_back(Region);
12500 for (
unsigned I = 0; I < Elts.size(); ++I)
12501 Tree.merge(Elts[I]);
12506 return VisitExpr(ILE);
12510 SequenceTree::Seq
Parent = Region;
12511 for (
unsigned I = 0; I < ILE->
getNumInits(); ++I) {
12514 Region = Tree.allocate(Parent);
12515 Elts.push_back(Region);
12521 for (
unsigned I = 0; I < Elts.size(); ++I)
12522 Tree.merge(Elts[I]);
12528 void Sema::CheckUnsequencedOperations(
Expr *E) {
12530 WorkList.push_back(E);
12531 while (!WorkList.empty()) {
12532 Expr *Item = WorkList.pop_back_val();
12533 SequenceChecker(*
this, Item, WorkList);
12538 bool IsConstexpr) {
12540 isConstantEvaluatedOverride, IsConstexpr || isa<ConstantExpr>(E));
12541 CheckImplicitConversions(E, CheckLoc);
12543 CheckUnsequencedOperations(E);
12545 CheckForIntOverflow(E);
12546 DiagnoseMisalignedMembers();
12559 if (
const auto *PointerTy = dyn_cast<PointerType>(PType)) {
12563 if (
const auto *ReferenceTy = dyn_cast<ReferenceType>(PType)) {
12567 if (
const auto *ParenTy = dyn_cast<ParenType>(PType)) {
12581 S.
Diag(Loc, diag::err_array_star_in_function_definition);
12590 bool CheckParameterNames) {
12591 bool HasInvalidParm =
false;
12598 if (!Param->isInvalidDecl() &&
12599 RequireCompleteType(Param->getLocation(), Param->getType(),
12600 diag::err_typecheck_decl_incomplete_type)) {
12601 Param->setInvalidDecl();
12602 HasInvalidParm =
true;
12607 if (CheckParameterNames &&
12608 Param->getIdentifier() ==
nullptr &&
12609 !Param->isImplicit() &&
12610 !getLangOpts().CPlusPlus)
12611 Diag(Param->getLocation(), diag::err_parameter_name_omitted);
12618 QualType PType = Param->getOriginalType();
12626 if (!Param->isInvalidDecl()) {
12627 if (
CXXRecordDecl *ClassDecl = Param->getType()->getAsCXXRecordDecl()) {
12628 if (!ClassDecl->isInvalidDecl() &&
12629 !ClassDecl->hasIrrelevantDestructor() &&
12630 !ClassDecl->isDependentContext() &&
12631 ClassDecl->isParamDestroyedInCallee()) {
12633 MarkFunctionReferenced(Param->getLocation(), Destructor);
12634 DiagnoseUseOfDecl(Destructor, Param->
getLocation());
12643 if (
const auto *
Attr = Param->getAttr<PassObjectSizeAttr>())
12644 if (!Param->getType().isConstQualified())
12645 Diag(Param->getLocation(), diag::err_attribute_pointers_only)
12649 if (LangOpts.CPlusPlus && !Param->isInvalidDecl()) {
12654 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC->
getParent()))
12655 CheckShadowInheritedFields(Param->getLocation(), Param->getDeclName(),
12661 return HasInvalidParm;
12668 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
12671 if (
const auto *ME = dyn_cast<MemberExpr>(E))
12682 if (getDiagnostics().isIgnored(diag::warn_cast_align, TRange.
getBegin()))
12691 if (!DestPtr)
return;
12697 if (DestAlign.
isOne())
return;
12701 if (!SrcPtr)
return;
12712 if (
auto *CE = dyn_cast<CastExpr>(Op)) {
12713 if (CE->getCastKind() == CK_ArrayToPointerDecay)
12714 SrcAlign =
getDeclAlign(CE->getSubExpr(), SrcAlign, Context);
12715 }
else if (
auto *UO = dyn_cast<UnaryOperator>(Op)) {
12716 if (UO->getOpcode() == UO_AddrOf)
12717 SrcAlign =
getDeclAlign(UO->getSubExpr(), SrcAlign, Context);
12720 if (SrcAlign >= DestAlign)
return;
12725 << static_cast<unsigned>(DestAlign.
getQuantity())
12736 if (Size != 1 || !ND)
return false;
12739 if (!FD)
return false;
12762 if (!RD)
return false;
12763 if (RD->
isUnion())
return false;
12764 if (
const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
12765 if (!CRD->isStandardLayout())
return false;
12769 const Decl *D = FD;
12771 if (isa<FieldDecl>(D))
12776 void Sema::CheckArrayAccess(
const Expr *BaseExpr,
const Expr *IndexExpr,
12778 bool AllowOnePastEnd,
bool IndexNegated) {
12780 if (isConstantEvaluated())
12787 const Type *EffectiveType =
12804 llvm::APSInt index = Result.
Val.
getInt();
12809 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr))
12810 ND = DRE->getDecl();
12811 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr))
12812 ND = ME->getMemberDecl();
12814 if (index.isUnsigned() || !index.isNegative()) {
12824 llvm::APInt size = ArrayTy->
getSize();
12825 if (!size.isStrictlyPositive())
12828 if (BaseType != EffectiveType) {
12830 uint64_t ptrarith_typesize = Context.
getTypeSize(EffectiveType);
12831 uint64_t array_typesize = Context.
getTypeSize(BaseType);
12833 if (!ptrarith_typesize) ptrarith_typesize = 1;
12834 if (ptrarith_typesize != array_typesize) {
12836 uint64_t ratio = array_typesize / ptrarith_typesize;
12839 if (ptrarith_typesize * ratio == array_typesize)
12840 size *= llvm::APInt(size.getBitWidth(), ratio);
12844 if (size.getBitWidth() > index.getBitWidth())
12845 index = index.zext(size.getBitWidth());
12846 else if (size.getBitWidth() < index.getBitWidth())
12847 size = size.zext(index.getBitWidth());
12853 if (AllowOnePastEnd ? index.ule(size) : index.ult(size))
12868 if (SourceMgr.isInSystemHeader(RBracketLoc)) {
12870 SourceMgr.getSpellingLoc(IndexExpr->
getBeginLoc());
12871 if (SourceMgr.isWrittenInSameFile(RBracketLoc, IndexLoc))
12876 unsigned DiagID = diag::warn_ptr_arith_exceeds_bounds;
12878 DiagID = diag::warn_array_index_exceeds_bounds;
12880 DiagRuntimeBehavior(BaseExpr->
getBeginLoc(), BaseExpr,
12881 PDiag(DiagID) << index.toString(10,
true)
12882 << size.toString(10,
true)
12883 << (unsigned)size.getLimitedValue(~0U)
12886 unsigned DiagID = diag::warn_array_index_precedes_bounds;
12888 DiagID = diag::warn_ptr_arith_precedes_bounds;
12889 if (index.isNegative()) index = -index;
12892 DiagRuntimeBehavior(BaseExpr->
getBeginLoc(), BaseExpr,
12893 PDiag(DiagID) << index.toString(10,
true)
12900 dyn_cast<ArraySubscriptExpr>(BaseExpr))
12902 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr))
12903 ND = DRE->getDecl();
12904 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr))
12905 ND = ME->getMemberDecl();
12910 PDiag(diag::note_array_index_out_of_bounds)
12914 void Sema::CheckArrayAccess(
const Expr *
expr) {
12915 int AllowOnePastEnd = 0;
12919 case Stmt::ArraySubscriptExprClass: {
12922 AllowOnePastEnd > 0);
12926 case Stmt::MemberExprClass: {
12927 expr = cast<MemberExpr>(
expr)->getBase();
12930 case Stmt::OMPArraySectionExprClass: {
12934 nullptr, AllowOnePastEnd > 0);
12937 case Stmt::UnaryOperatorClass: {
12953 case Stmt::ConditionalOperatorClass: {
12956 CheckArrayAccess(lhs);
12958 CheckArrayAccess(rhs);
12961 case Stmt::CXXOperatorCallExprClass: {
12962 const auto *OCE = cast<CXXOperatorCallExpr>(
expr);
12963 for (
const auto *Arg : OCE->arguments())
12964 CheckArrayAccess(Arg);
12977 struct RetainCycleOwner {
12981 bool Indirect =
false;
12983 RetainCycleOwner() =
default;
12985 void setLocsFrom(
Expr *e) {
13002 owner.Variable = var;
13004 owner.setLocsFrom(ref);
13012 switch (
cast->getCastKind()) {
13014 case CK_LValueBitCast:
13015 case CK_LValueToRValue:
13016 case CK_ARCReclaimReturnedObject:
13017 e =
cast->getSubExpr();
13034 if (ref->isFreeIvar()) owner.setLocsFrom(ref);
13035 owner.Indirect =
true;
13039 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(e)) {
13041 if (!var)
return false;
13046 if (
member->isArrow())
return false;
13058 if (!pre)
return false;
13061 if (!property->isRetaining() &&
13062 !(
property->getPropertyIvarDecl() &&
13063 property->getPropertyIvarDecl()->getType()
13067 owner.Indirect =
true;
13070 if (!owner.Variable)
13076 e =
const_cast<Expr*
>(cast<OpaqueValueExpr>(pre->
getBase())
13077 ->getSourceExpr());
13092 Expr *Capturer =
nullptr;
13093 bool VarWillBeReased =
false;
13097 Context(Context), Variable(variable) {}
13100 if (ref->
getDecl() == Variable && !Capturer)
13105 if (Capturer)
return;
13111 void VisitBlockExpr(
BlockExpr *block) {
13118 if (Capturer)
return;
13124 if (!Variable || VarWillBeReased || BinOp->
getOpcode() != BO_Assign)
13127 if (
const DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(LHS)) {
13128 if (DRE->getDecl() != Variable)
13132 llvm::APSInt
Value;
13134 (RHS && RHS->isIntegerConstantExpr(Value, Context) && Value == 0);
13145 assert(owner.Variable && owner.Loc.isValid());
13153 e = ME->getInstanceReceiver();
13156 e = e->IgnoreParenCasts();
13158 }
else if (
CallExpr *CE = dyn_cast<CallExpr>(e)) {
13163 if (FnI && FnI->
isStr(
"_Block_copy")) {
13174 FindCaptureVisitor visitor(S.
Context, owner.Variable);
13176 return visitor.VarWillBeReased ? nullptr : visitor.Capturer;
13180 RetainCycleOwner &owner) {
13182 assert(owner.Variable && owner.Loc.isValid());
13186 S.
Diag(owner.Loc, diag::note_arc_retain_cycle_owner)
13187 << owner.Indirect << owner.Range;
13196 while (!str.empty() && str.front() ==
'_') str = str.substr(1);
13197 if (str.startswith(
"set"))
13198 str = str.substr(3);
13199 else if (str.startswith(
"add")) {
13201 if (sel.
getNumArgs() == 1 && str.startswith(
"addOperationWithBlock"))
13203 str = str.substr(3);
13208 if (str.empty())
return true;
13214 bool IsMutableArray = S.
NSAPIObj->isSubclassOfNSClass(
13217 if (!IsMutableArray) {
13224 S.
NSAPIObj->getNSArrayMethodKind(Sel);
13249 bool IsMutableDictionary = S.
NSAPIObj->isSubclassOfNSClass(
13252 if (!IsMutableDictionary) {
13259 S.
NSAPIObj->getNSDictionaryMethodKind(Sel);
13280 bool IsMutableSet = S.
NSAPIObj->isSubclassOfNSClass(
13284 bool IsMutableOrderedSet = S.
NSAPIObj->isSubclassOfNSClass(
13287 if (!IsMutableSet && !IsMutableOrderedSet) {
13326 int ArgIndex = *ArgOpt;
13334 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
13335 if (ArgRE->isObjCSelfExpr()) {
13337 diag::warn_objc_circular_container)
13338 << ArgRE->getDecl() << StringRef(
"'super'");
13348 if (
DeclRefExpr *ReceiverRE = dyn_cast<DeclRefExpr>(Receiver)) {
13349 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
13350 if (ReceiverRE->getDecl() == ArgRE->getDecl()) {
13353 diag::warn_objc_circular_container)
13355 if (!ArgRE->isObjCSelfExpr()) {
13357 diag::note_objc_circular_container_declared_here)
13362 }
else if (
ObjCIvarRefExpr *IvarRE = dyn_cast<ObjCIvarRefExpr>(Receiver)) {
13364 if (IvarRE->getDecl() == IvarArgRE->getDecl()) {
13367 diag::warn_objc_circular_container)
13370 diag::note_objc_circular_container_declared_here)
13385 RetainCycleOwner owner;
13391 owner.Variable = getCurMethodDecl()->getSelfDecl();
13401 if (MD && MD->
parameters()[
i]->hasAttr<NoEscapeAttr>())
13410 RetainCycleOwner owner;
13419 RetainCycleOwner Owner;
13433 Expr *RHS,
bool isProperty) {
13445 S.
Diag(Loc, diag::warn_arc_literal_assign)
13447 << (isProperty ? 0 : 1)
13455 Expr *RHS,
bool isProperty) {
13458 if (
cast->getCastKind() == CK_ARCConsumeObject) {
13459 S.
Diag(Loc, diag::warn_arc_retained_assign)
13461 << (isProperty ? 0 : 1)
13465 RHS =
cast->getSubExpr();
13507 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
13508 getCurFunction()->markSafeWeakUse(LHS);
13511 if (checkUnsafeAssigns(Loc, LHSType, RHS))
13531 if (!(AsWrittenAttr & ObjCPropertyDecl::OBJC_PR_assign) &&
13536 if (
cast->getCastKind() == CK_ARCConsumeObject) {
13537 Diag(Loc, diag::warn_arc_retained_property_assign)
13541 RHS =
cast->getSubExpr();
13565 bool StmtLineInvalid;
13568 if (StmtLineInvalid)
13571 bool BodyLineInvalid;
13574 if (BodyLineInvalid)
13578 if (StmtLine != BodyLine)
13589 if (CurrentInstantiationScope)
13602 Diag(NBody->
getSemiLoc(), diag::note_empty_body_on_separate_line);
13606 const Stmt *PossibleBody) {
13607 assert(!CurrentInstantiationScope);
13612 if (
const ForStmt *FS = dyn_cast<ForStmt>(S)) {
13613 StmtLoc = FS->getRParenLoc();
13614 Body = FS->getBody();
13615 DiagID = diag::warn_empty_for_body;
13616 }
else if (
const WhileStmt *WS = dyn_cast<WhileStmt>(S)) {
13617 StmtLoc = WS->getCond()->getSourceRange().getEnd();
13618 Body = WS->getBody();
13619 DiagID = diag::warn_empty_while_body;
13629 if (Diags.isIgnored(DiagID, NBody->
getSemiLoc()))
13647 bool ProbableTypo = isa<CompoundStmt>(PossibleBody);
13648 if (!ProbableTypo) {
13649 bool BodyColInvalid;
13650 unsigned BodyCol = SourceMgr.getPresumedColumnNumber(
13652 if (BodyColInvalid)
13655 bool StmtColInvalid;
13657 SourceMgr.getPresumedColumnNumber(S->
getBeginLoc(), &StmtColInvalid);
13658 if (StmtColInvalid)
13661 if (BodyCol > StmtCol)
13662 ProbableTypo =
true;
13665 if (ProbableTypo) {
13667 Diag(NBody->
getSemiLoc(), diag::note_empty_body_on_separate_line);
13676 if (Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess, OpLoc))
13679 if (inTemplateInstantiation())
13696 RHSExpr = CE->
getArg(0);
13702 if (LHSDeclRef && RHSDeclRef) {
13703 if (!LHSDeclRef->
getDecl() || !RHSDeclRef->getDecl())
13709 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
13719 const Expr *LHSBase = LHSExpr;
13720 const Expr *RHSBase = RHSExpr;
13723 if (!LHSME || !RHSME)
13726 while (LHSME && RHSME) {
13732 RHSBase = RHSME->getBase();
13739 if (LHSDeclRef && RHSDeclRef) {
13740 if (!LHSDeclRef->getDecl() || !RHSDeclRef->getDecl())
13742 if (LHSDeclRef->getDecl()->getCanonicalDecl() !=
13743 RHSDeclRef->getDecl()->getCanonicalDecl())
13746 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
13752 if (isa<CXXThisExpr>(LHSBase) && isa<CXXThisExpr>(RHSBase))
13753 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
13785 if (Bits1 != Bits2)
13797 if (
const CXXRecordDecl *D1CXX = dyn_cast<CXXRecordDecl>(RD1)) {
13802 if (D1CXX->getNumBases() != D2CXX->
getNumBases())
13807 Base1 = D1CXX->bases_begin(),
13808 BaseEnd1 = D1CXX->bases_end(),
13811 ++Base1, ++Base2) {
13815 }
else if (
const CXXRecordDecl *D2CXX = dyn_cast<CXXRecordDecl>(RD2)) {
13817 if (D2CXX->getNumBases() > 0)
13826 for ( ; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) {
13830 if (Field1 != Field1End || Field2 != Field2End)
13840 llvm::SmallPtrSet<FieldDecl *, 8> UnmatchedFields;
13841 for (
auto *Field2 : RD2->
fields())
13842 UnmatchedFields.insert(Field2);
13844 for (
auto *Field1 : RD1->
fields()) {
13845 llvm::SmallPtrSet<FieldDecl *, 8>::iterator
13846 I = UnmatchedFields.begin(),
13847 E = UnmatchedFields.end();
13849 for ( ; I != E; ++I) {
13851 bool Result = UnmatchedFields.erase(*I);
13861 return UnmatchedFields.empty();
13895 if (TC1 == Type::Enum) {
13897 cast<EnumType>(T1)->getDecl(),
13898 cast<EnumType>(T2)->getDecl());
13899 }
else if (TC1 == Type::Record) {
13904 cast<RecordType>(T1)->getDecl(),
13905 cast<RecordType>(T2)->getDecl());
13925 const ValueDecl **VD, uint64_t *MagicValue,
13926 bool isConstantEvaluated) {
13934 case Stmt::UnaryOperatorClass: {
13943 case Stmt::DeclRefExprClass: {
13944 const DeclRefExpr *DRE = cast<DeclRefExpr>(TypeExpr);
13949 case Stmt::IntegerLiteralClass: {
13951 llvm::APInt MagicValueAPInt = IL->
getValue();
13952 if (MagicValueAPInt.getActiveBits() <= 64) {
13953 *MagicValue = MagicValueAPInt.getZExtValue();
13959 case Stmt::BinaryConditionalOperatorClass:
13960 case Stmt::ConditionalOperatorClass: {
13962 cast<AbstractConditionalOperator>(TypeExpr);
13965 isConstantEvaluated)) {
13975 case Stmt::BinaryOperatorClass: {
13978 TypeExpr = BO->
getRHS();
14008 const llvm::DenseMap<Sema::TypeTagMagicValue, Sema::TypeTagData>
14011 bool isConstantEvaluated) {
14012 FoundWrongKind =
false;
14017 uint64_t MagicValue;
14019 if (!
FindTypeTagExpr(TypeExpr, Ctx, &VD, &MagicValue, isConstantEvaluated))
14023 if (TypeTagForDatatypeAttr *I = VD->
getAttr<TypeTagForDatatypeAttr>()) {
14024 if (I->getArgumentKind() != ArgumentKind) {
14025 FoundWrongKind =
true;
14028 TypeInfo.
Type = I->getMatchingCType();
14041 MagicValues->find(std::make_pair(ArgumentKind, MagicValue));
14042 if (I == MagicValues->end())
14045 TypeInfo = I->second;
14051 bool LayoutCompatible,
14053 if (!TypeTagForDatatypeMagicValues)
14054 TypeTagForDatatypeMagicValues.reset(
14055 new llvm::DenseMap<TypeTagMagicValue, TypeTagData>);
14058 (*TypeTagForDatatypeMagicValues)[Magic] =
14074 return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) ||
14075 (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) ||
14076 (T1Kind == BuiltinType::Char_U && T2Kind == BuiltinType::UChar) ||
14077 (T1Kind == BuiltinType::Char_S && T2Kind == BuiltinType::SChar);
14080 void Sema::CheckArgumentWithTypeTag(
const ArgumentWithTypeTagAttr *
Attr,
14081 const ArrayRef<const Expr *> ExprArgs,
14084 bool IsPointerAttr = Attr->getIsPointer();
14087 unsigned TypeTagIdxAST = Attr->getTypeTagIdx().getASTIndex();
14088 if (TypeTagIdxAST >= ExprArgs.size()) {
14089 Diag(CallSiteLoc, diag::err_tag_index_out_of_range)
14090 << 0 << Attr->getTypeTagIdx().getSourceIndex();
14093 const Expr *TypeTagExpr = ExprArgs[TypeTagIdxAST];
14094 bool FoundWrongKind;
14097 TypeTagForDatatypeMagicValues.get(), FoundWrongKind,
14098 TypeInfo, isConstantEvaluated())) {
14099 if (FoundWrongKind)
14101 diag::warn_type_tag_for_datatype_wrong_kind)
14107 unsigned ArgumentIdxAST = Attr->getArgumentIdx().getASTIndex();
14108 if (ArgumentIdxAST >= ExprArgs.size()) {
14109 Diag(CallSiteLoc, diag::err_tag_index_out_of_range)
14110 << 1 << Attr->getArgumentIdx().getSourceIndex();
14113 const Expr *ArgumentExpr = ExprArgs[ArgumentIdxAST];
14114 if (IsPointerAttr) {
14116 if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(ArgumentExpr))
14117 if (ICE->getType()->isVoidPointerType() &&
14118 ICE->getCastKind() == CK_BitCast)
14119 ArgumentExpr = ICE->getSubExpr();
14127 if (TypeInfo.MustBeNull) {
14132 diag::warn_type_safety_null_pointer_required)
14140 QualType RequiredType = TypeInfo.Type;
14144 bool mismatch =
false;
14145 if (!TypeInfo.LayoutCompatible) {
14146 mismatch = !Context.
hasSameType(ArgumentType, RequiredType);
14167 Diag(ArgumentExpr->
getExprLoc(), diag::warn_type_safety_type_mismatch)
14168 << ArgumentType << ArgumentKind
14169 << TypeInfo.LayoutCompatible << RequiredType
14176 MisalignedMembers.emplace_back(E, RD, MD, Alignment);
14180 for (MisalignedMember &m : MisalignedMembers) {
14186 Diag(m.E->getBeginLoc(), diag::warn_taking_address_of_packed_member)
14189 MisalignedMembers.clear();
14196 if (isa<UnaryOperator>(E) &&
14197 cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf) {
14198 auto *Op = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
14199 if (isa<MemberExpr>(Op)) {
14200 auto MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
14201 if (MA != MisalignedMembers.end() &&
14206 MisalignedMembers.erase(MA);
14227 bool AnyIsPacked =
false;
14229 QualType BaseType = ME->getBase()->getType();
14243 AnyIsPacked || (RD->
hasAttr<PackedAttr>() || MD->
hasAttr<PackedAttr>());
14244 ReverseMemberChain.push_back(FD);
14247 ME = dyn_cast<
MemberExpr>(ME->getBase()->IgnoreParens());
14249 assert(TopME &&
"We did not compute a topmost MemberExpr!");
14256 const auto *DRE = dyn_cast<
DeclRefExpr>(TopBase);
14260 if (!DRE && !isa<CXXThisExpr>(TopBase))
14267 if (ExpectedAlignment.
isOne())
14272 for (
auto I = ReverseMemberChain.rbegin(); I != ReverseMemberChain.rend();
14279 ReverseMemberChain.back()->getParent()->getTypeForDecl());
14283 if (DRE && !TopME->
isArrow()) {
14286 CompleteObjectAlignment =
14291 if (Offset % ExpectedAlignment != 0 ||
14294 CompleteObjectAlignment < ExpectedAlignment) {
14305 for (
FieldDecl *FDI : ReverseMemberChain) {
14306 if (FDI->hasAttr<PackedAttr>() ||
14307 FDI->getParent()->hasAttr<PackedAttr>()) {
14315 assert(FD &&
"We did not find a packed FieldDecl!");
14316 Action(E, FD->
getParent(), FD, Alignment);
14320 void Sema::CheckAddressOfPackedMember(
Expr *rhs) {
14321 using namespace std::placeholders;
14323 RefersToMemberWithReducedAlignment(
14324 rhs, std::bind(&Sema::AddPotentialMisalignedMembers, std::ref(*
this), _1,
ArgType getArgType(ASTContext &Ctx, bool IsObjCLiteral) const
Returns the builtin type that a data argument paired with this format specifier should have...
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
The receiver is the instance of the superclass object.
static void diagnoseArrayStarInParamType(Sema &S, QualType PType, SourceLocation Loc)
static FormatStringType GetFormatStringType(const FormatAttr *Format)
bool isFloatingPoint() const
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
const BlockDecl * getBlockDecl() const
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
SourceLocation getBeginLoc() const LLVM_READONLY
TargetOptions & getTargetOpts() const
Retrieve the target options.
bool isCallToStdMove() const
static std::pair< QualType, StringRef > shouldNotPrintDirectly(const ASTContext &Context, QualType IntendedTy, const Expr *E)
IntType getInt64Type() const
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name...
static APFixedPoint getFromIntValue(const llvm::APSInt &Value, const FixedPointSemantics &DstFXSema, bool *Overflow=nullptr)
Create an APFixedPoint with a value equal to that of the provided integer, and in the same semantics ...
const OptionalFlag & hasAlternativeForm() const
QualType withConst() const
Retrieves a version of this type with const applied.
Represents a function declaration or definition.
static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E)
Analyze the given compound assignment for the possible losing of floating-point precision.
NamespaceDecl * getStdNamespace() const
const char * getSpelling() const
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
Expr ** getArgs()
Retrieve the call arguments.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
The receiver is an object instance.
unsigned getMemoryFunctionKind() const
Identify a memory copying or setting function.
static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E, Expr *Constant, Expr *Other, const llvm::APSInt &Value, bool RhsConstant)
SourceLocation getRParenLoc() const
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Smart pointer class that efficiently represents Objective-C method names.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getElementType() const
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
static llvm::SmallPtrSet< MemberKind *, 1 > CXXRecordMembersNamed(StringRef Name, Sema &S, QualType Ty)
A (possibly-)qualified type.
bool isBlockPointerType() const
StringKind getKind() const
bool isMemberPointerType() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
static bool CheckForReference(Sema &SemaRef, const Expr *E, const PartialDiagnostic &PD)
static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall)
OpenCL C v2.0, s6.13.17 - Enqueue kernel function contains four different overload formats specified ...
const ScanfConversionSpecifier & getConversionSpecifier() const
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getExprLoc() const
bool hasValidThousandsGroupingPrefix() const
Selector getSelector() const
static bool SemaOpenCLBuiltinNDRangeAndBlock(Sema &S, CallExpr *TheCall)
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2)
Check if two types are layout-compatible in C++11 sense.
Defines enumerations for the type traits support.
bool isSuperReceiver() const
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
const Expr * getInit(unsigned Init) const
bool containsNonAsciiOrNull() const
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
Stmt - This represents one statement.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
static Optional< int > GetNSMutableArrayArgumentIndex(Sema &S, ObjCMessageExpr *Message)
Expr * getBitWidth() const
bool consumesDataArgument() const
FunctionType - C99 6.7.5.3 - Function Declarators.
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken=nullptr, unsigned *StartTokenByteOffset=nullptr) const
getLocationOfByte - Return a source location that points to the specified byte of this string literal...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
An instance of this object exists for each enum constant that is defined.
bool isRealFloatingType() const
Floating point categories.
C Language Family Type Representation.
Defines the SourceManager interface.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
static const Builtin::Info BuiltinInfo[]
void addConst()
Add the const type qualifier to this QualType.
bool isRecordType() const
static void AnalyzeAssignment(Sema &S, BinaryOperator *E)
Analyze the given simple or compound assignment for warning-worthy operations.
static ExprResult SemaBuiltinLaunder(Sema &S, CallExpr *TheCall)
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
bool hasLeadingEmptyMacro() const
bool isVariadic() const
Whether this function prototype is variadic.
SourceLocation getBeginLoc() const LLVM_READONLY
static bool referToTheSameDecl(const Expr *E1, const Expr *E2)
Check if two expressions refer to the same declaration.
ParenExpr - This represents a parethesized expression, e.g.
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
Expr * getFalseExpr() const
Strictly evaluate the expression.
Expr * getLowerBound()
Get lower bound of array section.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CanQualType getNSUIntegerType() const
NSDictionaryMethodKind
Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some c...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
Wrapper for source info for typedefs.
static AbsoluteValueKind getAbsoluteValueKind(QualType T)
QualType withConst() const
static void AnalyzeComparison(Sema &S, BinaryOperator *E)
Implements -Wsign-compare.
const TargetInfo & getTargetInfo() const
const NestedNameSpecifier * Specifier
A container of type source information.
static bool checkOpenCLPipeArg(Sema &S, CallExpr *Call)
Returns true if pipe element type is different from the pointer.
bool EvaluateAsFixedPoint(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsFloat - Return true if this is a constant which we can fold and convert to a fixed point va...
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
static bool checkArgCount(Sema &S, CallExpr *call, unsigned desiredArgCount)
Checks that a call expression's argument count is the desired number.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
QualType getElementType() const
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static unsigned changeAbsFunction(unsigned AbsKind, AbsoluteValueKind ValueKind)
bool usesPositionalArg() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
SourceLocation getImmediateMacroCallerLoc(SourceLocation Loc) const
Gets the location of the immediate macro caller, one level up the stack toward the initial macro type...
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
QualType getReturnType() const
ScopeFlags
ScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sort...
DiagnosticsEngine & Diags
CompoundLiteralExpr - [C99 6.5.2.5].
unsigned getNumParams() const
bool isEnumeralType() const
APFixedPoint getFixedPointMax(QualType Ty) const
Options for controlling the target.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const AstTypeMatcher< PointerType > pointerType
Matches pointer types, but does not match Objective-C object pointer types.
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
APFloat & getComplexFloatReal()
const T * getAs() const
Member-template getAs<specific type>'.
Extra information about a function prototype.
const OptionalFlag & hasThousandsGrouping() const
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
ObjCMethodDecl - Represents an instance or class method declaration.
bool isInvalidDecl() const
Like System, but searched after the system directories.
bool isAddrLabelDiff() const
Represents a parameter to a function.
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
ObjCInterfaceDecl * NSDictionaryDecl
The declaration of the Objective-C NSDictionary class.
static bool CheckMemorySizeofForComparison(Sema &S, const Expr *E, IdentifierInfo *FnName, SourceLocation FnLoc, SourceLocation RParenLoc)
Takes the expression passed to the size_t parameter of functions such as memcmp, strncat, etc and warns if it's a comparison.
static bool CheckBuiltinTargetSupport(Sema &S, unsigned BuiltinID, CallExpr *TheCall, ArrayRef< llvm::Triple::ArchType > SupportedArchs)
Parse and apply any fixits to the source.
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
bool isVariableArrayType() const
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc, Qualifiers::ObjCLifetime LT, Expr *RHS, bool isProperty)
ObjCPropertyDecl * getExplicitProperty() const
static bool requiresParensToAddCast(const Expr *E)
ArgType getArgType(ASTContext &Ctx) const
static bool checkOpenCLEnqueueVariadicArgs(Sema &S, CallExpr *TheCall, Expr *BlockArg, unsigned NumNonVarArgs)
OpenCL v2.0, s6.13.17.1 - Check that sizes are provided for all 'local void*' parameter of passed blo...
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
Represents a struct/union/class.
static bool checkVAStartIsInVariadicFunction(Sema &S, Expr *Fn, ParmVarDecl **LastParam=nullptr)
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
bool isComplete() const
Returns true if this can be considered a complete type.
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
Expr * getFalseExpr() const
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
SourceLocation getBegin() const
bool isNothrow(bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
QualType getPointeeType() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
ArrayRef< QualType > getParamTypes() const
Used for GCC's __alignof.
field_range fields() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a member of a struct/union/class.
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
static bool isValidOrderingForOp(int64_t Ordering, AtomicExpr::AtomicOp Op)
static int classifyConstantValue(Expr *Constant)
bool isReferenceType() const
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
The iterator over UnresolvedSets.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
IntType getSizeType() const
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
__DEVICE__ int max(int __a, int __b)
bool hasValidLeftJustified() const
std::unique_ptr< AtomicScopeModel > getScopeModel() const
Get atomic scope model.
CanQualType OCLReserveIDTy
SourceLocation getBeginLoc() const LLVM_READONLY
static bool isLayoutCompatibleUnion(ASTContext &C, RecordDecl *RD1, RecordDecl *RD2)
Check if two standard-layout unions are layout-compatible.
SourceLocation getQuestionLoc() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
unsigned getCharByteWidth() const
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody)
Warn if a for/while loop statement S, which is followed by PossibleBody, has a suspicious null statem...
bool isConstantEvaluated()
static Optional< int > GetNSSetArgumentIndex(Sema &S, ObjCMessageExpr *Message)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
ArrayRef< ParmVarDecl * > parameters() const
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
bool isUnarySelector() const
bool hasValidPlusPrefix() const
Describes an C or C++ initializer list.
static bool checkOpenCLEnqueueLocalSizeArgs(Sema &S, CallExpr *TheCall, unsigned Start, unsigned End)
static bool isArithmeticArgumentPromotion(Sema &S, const ImplicitCastExpr *ICE)
Return true if ICE is an implicit argument promotion of an arithmetic type.
bool isBitField() const
Determines whether this field is a bitfield.
ForStmt - This represents a 'for (init;cond;inc)' stmt.
unsigned getLength() const
static bool isEqualityOp(Opcode Opc)
Represents the results of name lookup.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
CharUnits - This is an opaque type for sizes expressed in character units.
APValue Val
Val - This is the value the expression can be folded to.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS)
Check for comparisons of floating point operands using != and ==.
bool hasValidPrecision() const
bool isOne() const
isOne - Test whether the quantity equals one.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
static bool isNonNullType(ASTContext &ctx, QualType type)
Determine whether the given type has a non-null nullability annotation.
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
PropertyAttributeKind getPropertyAttributes() const
Represents a typeof (or typeof) expression (a GCC extension).
const clang::PrintingPolicy & getPrintingPolicy() const
A builtin binary operation expression such as "x + y" or "x <= y".
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
bool isComplexFloat() const
QualType getExceptionObjectType(QualType T) const
unsigned getSpellingLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
bool isComplexInt() const
Defines the Diagnostic-related interfaces.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
ObjCStringLiteral, used for Objective-C string literals i.e.
Values of this type can never be null.
Scope - A scope is a transient data structure that is used while parsing the program.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
StringKind
StringLiteral is followed by several trailing objects.
field_iterator field_begin() const
unsigned getBitWidthValue(const ASTContext &Ctx) const
NSSetMethodKind
Enumerates the NSMutableSet/NSOrderedSet methods used to apply some checks.
static QualType GetExprType(const Expr *E)
bool isMacroBodyExpansion(SourceLocation Loc) const
Tests whether the given source location represents the expansion of a macro body. ...
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
base_class_iterator bases_begin()
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
const LangOptions & getLangOpts() const
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
bool isScalarType() const
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
An ordinary object is located at an address in memory.
static const CXXRecordDecl * getContainedDynamicClass(QualType T, bool &IsContained)
Determine whether the given type is or contains a dynamic class type (e.g., whether it has a vtable)...
static bool SemaOpenCLBuiltinKernelWorkGroupSize(Sema &S, CallExpr *TheCall)
OpenCL C v2.0, s6.13.17.6 - Check the argument to the get_kernel_work_group_size and get_kernel_prefe...
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
Member name lookup, which finds the names of class/struct/union members.
SourceLocation getTypeSpecStartLoc() const
Expression is a GNU-style __null constant.
static void diagnoseRetainCycle(Sema &S, Expr *capturer, RetainCycleOwner &owner)
static void AnalyzeImpConvsInComparison(Sema &S, BinaryOperator *E)
Analyze the operands of the given comparison.
PrimitiveDefaultInitializeKind
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
APSInt & getComplexIntReal()
CanQualType UnsignedCharTy
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
static bool SemaBuiltinMSVCAnnotation(Sema &S, CallExpr *TheCall)
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
const OptionalFlag & hasLeadingZeros() const
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const
This object can be modified without requiring retains or releases.
param_iterator param_begin()
bool tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx, unsigned Type) const
If the current Expr is a pointer, this will try to statically determine the number of bytes available...
APValue & getVectorElt(unsigned I)
The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a s...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
unsigned getFlags() const
getFlags - Return the flags for this scope.
Provides definitions for the various language-specific address spaces.
Decl * getNextDeclInContext()
OpenMP 4.0 [2.4, Array Sections].
const OptionalFlag & hasPlusPrefix() const
ConditionalOperator - The ?: ternary operator.
Sema - This implements semantic analysis and AST building for C.
StringRef getString() const
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
bool isDynamicClass() const
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
CastKind
CastKind - The kind of operation required for a conversion.
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
static bool checkOpenCLPipePacketType(Sema &S, CallExpr *Call, unsigned Idx)
Returns true if pipe element type is different from the pointer.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
const char * getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
SourceLocation getLocation() const
bool isEnabled(llvm::StringRef Ext) const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
TypeSourceInfo * getTypeSourceInfo() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
Scope * getCurScope() const
Retrieve the parser's current scope.
static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, SourceLocation CContext)
Diagnose an implicit cast from a floating point value to an integer value.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Exposes information about the current target.
NSArrayMethodKind
Enumerates the NSArray/NSMutableArray methods used to generate literals and to apply some checks...
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting...
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
Defines the clang::LangOptions interface.
const OptionalFlag & isLeftJustified() const
Allow any unmodeled side effect.
Represents a character-granular source range.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isVariadic() const
Whether this function is variadic.
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
void EvaluateForOverflow(const ASTContext &Ctx) const
static void CheckImplicitArgumentConversions(Sema &S, CallExpr *TheCall, SourceLocation CC)
virtual bool hasSjLjLowering() const
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm...
const T * castAs() const
Member-template castAs<specific type>.
bool isObjCRetainableType() const
ObjCStringFormatFamily getObjCFStringFormattingFamily() const
static bool checkOpenCLBlockArgs(Sema &S, Expr *BlockArg)
OpenCL C v2.0, s6.13.17.2 - Checks that the block parameters are all local void*, which is a requirem...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
unsigned getNumInits() const
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
This scope corresponds to an SEH except.
Defines an enumeration for C++ overloaded operators.
bool isNullPtrType() const
bool hasValidLeadingZeros() const
field_iterator field_end() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
bool isAnyComplexType() const
void setObjectKind(ExprObjectKind Cat)
setObjectKind - Set the object kind produced by this expression.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void removeLocalVolatile()
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isFunctionOrMethod() const
CharSourceRange getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
Expr * getElement(unsigned Index)
getElement - Return the Element at the specified index.
static void CheckNonNullArguments(Sema &S, const NamedDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< const Expr *> Args, SourceLocation CallSiteLoc)
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
virtual bool validateCpuSupports(StringRef Name) const
static bool SemaBuiltinPipePackets(Sema &S, CallExpr *Call)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
An expression that sends a message to the given Objective-C object or class.
SourceLocation getRBracketLoc() const
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
static void CheckFormatString(Sema &S, const FormatStringLiteral *FExpr, const Expr *OrigFormatExpr, ArrayRef< const Expr *> Args, bool HasVAListArg, unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type, bool inFunctionCall, Sema::VariadicCallType CallType, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg)
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a GCC generic vector type.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
static OpenCLAccessAttr * getOpenCLArgAccess(const Decl *D)
Returns OpenCL access qual.
ArraySizeModifier getSizeModifier() const
unsigned getNumArgs() const
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool capturesVariable(const VarDecl *var) const
Expr * getTrueExpr() const
APSInt & getComplexIntImag()
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
unsigned getPresumedLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T, SourceLocation CContext, unsigned diag, bool pruneControlFlow=false)
Diagnose an implicit cast; purely a helper for CheckImplicitConversion.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
QualType withoutLocalFastQualifiers() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
ImplicitParamDecl * getSelfDecl() const
static bool IsTailPaddedMemberArray(Sema &S, const llvm::APInt &Size, const NamedDecl *ND)
Check whether this array fits the idiom of a size-one tail padded array member of a struct...
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
static StringRef getIdentifier(const Token &Tok)
static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, bool IsPolyUnsigned, bool IsInt64Long)
getNeonEltType - Return the QualType corresponding to the elements of the vector type specified by th...
CanQualType getNSIntegerType() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static const Expr * getStrlenExprArg(const Expr *E)
static bool SemaBuiltinCpuSupports(Sema &S, CallExpr *TheCall)
SemaBuiltinCpuSupports - Handle __builtin_cpu_supports(char *).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static bool isConstantSizeArrayWithMoreThanOneElement(QualType Ty, ASTContext &Context)
SourceLocation getEndLoc() const LLVM_READONLY
static CharSourceRange getCharRange(SourceRange R)
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isVoidPointerType() const
std::string CPU
If given, the name of the target CPU to generate code for.
RecordDecl * getDecl() const
void toString(llvm::SmallVectorImpl< char > &Str) const
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn)
Check that the user is calling the appropriate va_start builtin for the target and calling convention...
static bool SemaBuiltinCommitRWPipe(Sema &S, CallExpr *Call)
EltType getEltType() const
Defines the clang::OpenCLOptions class.
static bool IsStdFunction(const FunctionDecl *FDecl, const char(&Str)[StrLen])
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
There is no lifetime qualification on this type.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Enumerates target-specific builtins in their own namespaces within namespace clang.
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
bool isImplicitProperty() const
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
void DiagnoseMisalignedMembers()
Diagnoses the current set of gathered accesses.
static bool isLayoutCompatibleStruct(ASTContext &C, RecordDecl *RD1, RecordDecl *RD2)
Check if two standard-layout structs are layout-compatible.
void RefersToMemberWithReducedAlignment(Expr *E, llvm::function_ref< void(Expr *, RecordDecl *, FieldDecl *, CharUnits)> Action)
This function calls Action when it determines that E designates a misaligned member due to the packed...
ASTContext & getASTContext() const
static bool considerVariable(VarDecl *var, Expr *ref, RetainCycleOwner &owner)
Consider whether capturing the given variable can possibly lead to a retain cycle.
static void checkObjCCollectionLiteralElement(Sema &S, QualType TargetElementType, Expr *Element, unsigned ElementKind)
Check a single element within a collection literal against the target element type.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
SourceLocation getEndLoc() const LLVM_READONLY
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static void CheckConditionalOperator(Sema &S, ConditionalOperator *E, SourceLocation CC, QualType T)
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl *> Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
static const Expr * getSizeOfExprArg(const Expr *E)
If E is a sizeof expression, returns its argument expression, otherwise returns NULL.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
SourceLocation getOperatorLoc() const
static bool doesExprLikelyComputeSize(const Expr *SizeofExpr)
Detect if SizeofExpr is likely to calculate the sizeof an object.
LangAS getAddressSpace() const
Return the address space of this type.
Expression is not a Null pointer constant.
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Expr * getSubExpr() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle...
bool hasValidSpacePrefix() const
static const Expr * ignoreLiteralAdditions(const Expr *Ex, ASTContext &Ctx)
CastKind getCastKind() const
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
static bool IsImplicitBoolFloatConversion(Sema &S, Expr *Ex, bool ToBool)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall)
SemaBuiltinShuffleVector - Handle __builtin_shufflevector.
static bool CheckNonNullExpr(Sema &S, const Expr *Expr)
Checks if a the given expression evaluates to null.
SourceLocation getSuperLoc() const
Retrieve the location of the 'super' keyword for a class or instance message to 'super', otherwise an invalid source location.
const ParmVarDecl * getParamDecl(unsigned i) const
static void checkObjCArrayLiteral(Sema &S, QualType TargetType, ObjCArrayLiteral *ArrayLiteral)
Check an Objective-C array literal being converted to the given target type.
static void DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, const NamedDecl *FDecl, Expr **Args, unsigned NumArgs)
Diagnose use of s directive in an NSString which is being passed as formatting string to formatting m...
static void CheckConditionalOperand(Sema &S, Expr *E, QualType T, SourceLocation CC, bool &ICContext)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
Check conversion of given expression to boolean.
SourceLocation getEndLoc() const LLVM_READONLY
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Look up any declaration with any name.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
static std::string PrettyPrintInRange(const llvm::APSInt &Value, IntRange Range)
static bool isBlockPointer(Expr *Arg)
bool FormatStringHasSArg(const StringLiteral *FExpr)
Represents one property declaration in an Objective-C interface.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool isFunctionProtoType() const
void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, uint64_t MagicValue, QualType Type, bool LayoutCompatible, bool MustBeNull)
Register a magic integral constant to be used as a type tag.
TypeClass getTypeClass() const
Used for C's _Alignof and C++'s alignof.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static bool isLogicalOp(Opcode Opc)
bool hasCStrMethod(const Expr *E)
Check to see if a given expression could have '.c_str()' called on it.
const ObjCMethodDecl * getMethodDecl() const
static bool IsEnumConstOrFromMacro(Sema &S, Expr *E)
DeclarationNameInfo getNameInfo() const
bool isVectorType() const
virtual bool validateCpuIs(StringRef Name) const
Assigning into this object requires a lifetime extension.
FixedPointSemantics getFixedPointSemantics(QualType Ty) const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static bool SemaBuiltinRWPipe(Sema &S, CallExpr *Call)
static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call)
Diagnose cases like 'memset(buf, sizeof(buf), 0)', which should have the last two arguments transpose...
We are currently in the filter expression of an SEH except block.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
LLVM_READONLY bool isLowercase(unsigned char c)
Return true if this character is a lowercase ASCII letter: [a-z].
static StringRef getImmediateMacroName(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
static StringRef getImmediateMacroNameForDiagnostics(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
const PrintfConversionSpecifier & getConversionSpecifier() const
CompoundAssignOperator - For compound assignments (e.g.
static bool isObjCSignedCharBool(Sema &S, QualType Ty)
Defines various enumerations that describe declaration and type specifiers.
StringRef getName() const
Return the actual identifier string.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
CanQualType UnsignedShortTy
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Canon=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
Base class for declarations which introduce a typedef-name.
QualType withVolatile() const
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
NullStmt - This is the null statement ";": C99 6.8.3p3.
Dataflow Directional Tag Classes.
bool isUnsaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
std::string getAsString() const
getAsString - Retrieve the human-readable string for this name.
bool isValid() const
Return true if this is a valid SourceLocation object.
static const UnaryExprOrTypeTraitExpr * getAsSizeOfExpr(const Expr *E)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getLocation() const
EvalResult is a struct with detailed info about an evaluated expression.
PropertyAttributeKind getPropertyAttributesAsWritten() const
static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx)
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments for this type.
APFixedPoint getFixedPointMin(QualType Ty) const
bool isSEHExceptScope() const
Determine whether this scope is a SEH '__except' block.
static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, SourceLocation InitLoc)
Analyzes an attempt to assign the given value to a bitfield.
static bool isX86_32Builtin(unsigned BuiltinID)
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
CanQualType UnsignedLongLongTy
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static QualType getAbsoluteValueArgumentType(ASTContext &Context, unsigned AbsType)
SourceLocation getSemiLoc() const
The name of a declaration.
StmtClass getStmtClass() const
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isBooleanType() const
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
U cast(CodeGen::Address addr)
static bool isSetterLikeSelector(Selector sel)
Check for a keyword selector that starts with the word 'add' or 'set'.
A set of unresolved declarations.
Expression is a C++11 nullptr.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
const OptionalFlag & isPrivate() const
Flags to identify the types for overloaded Neon builtins.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange)
CheckCastAlign - Implements -Wcast-align, which warns when a pointer cast increases the alignment req...
static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner)
static bool IsSameCharType(QualType T1, QualType T2)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
SemaConvertVectorExpr - Handle __builtin_convertvector.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
param_iterator param_end()
static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall)
llvm::APInt getValue() const
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
bool hasValidAlternativeForm() const
unsigned getByteLength() const
unsigned getIntWidth(QualType T) const
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point...
static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID, CallExpr *Call)
static unsigned getBestAbsFunction(ASTContext &Context, QualType ArgType, unsigned AbsFunctionKind)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
bool isMacroArgExpansion(SourceLocation Loc, SourceLocation *StartLoc=nullptr) const
Tests whether the given source location represents a macro argument's expansion into the function-lik...
Iterator for iterating over Stmt * arrays that contain only T *.
static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call)
bool hasValidFieldWidth() const
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
QualType getCanonicalTypeInternal() const
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
bool isReserveIDT() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
static bool checkOpenCLEnqueueIntType(Sema &S, Expr *E, const QualType &IntType)
Diagnose integer type and any valid implicit conversion to it.
CanQualType UnsignedLongTy
static bool SemaBuiltinReserveRWPipe(Sema &S, CallExpr *Call)
bool hasNonTrivialObjCLifetime() const
const llvm::APInt & getSize() const
uint64_t getCharWidth() const
Return the size of the character type, in bits.
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
bool isAtomicType() const
static bool isKnownToHaveUnsignedValue(Expr *E)
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
bool isFunctionType() const
static unsigned RFT(unsigned t, bool shift=false, bool ForceQuad=false)
TypeSourceInfo * getTypeSourceInfo() const
static void checkObjCDictionaryLiteral(Sema &S, QualType TargetType, ObjCDictionaryLiteral *DictionaryLiteral)
Check an Objective-C dictionary literal being converted to the given target type. ...
ExtVectorType - Extended vector type.
const OptionalAmount & getPrecision() const
static bool isAdditiveOp(Opcode Opc)
static bool IsSameFloatAfterCast(const llvm::APFloat &value, const llvm::fltSemantics &Src, const llvm::fltSemantics &Tgt)
Checks whether the given value, which currently has the given source semantics, has the same value wh...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const
Compare the rank of two floating point types as above, but compare equal if both types have the same ...
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
The template argument is a type.
static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend, BinaryOperatorKind BinOpKind, bool AddendIsRight)
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
const OptionalFlag & isPublic() const
ObjCInterfaceDecl * NSArrayDecl
The declaration of the Objective-C NSArray class.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
const Expr * getBase() const
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, unsigned AbsKind, QualType ArgType)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
static bool isSameWidthConstantConversion(Sema &S, Expr *E, QualType T, SourceLocation CC)
Represents a base class of a C++ class.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
bool isObjectType() const
Determine whether this type is an object type.
static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex)
checkBuiltinArgument - Given a call to a builtin function, perform normal type-checking on the given ...
ObjCIvarRefExpr - A reference to an ObjC instance variable.
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
const OptionalFlag & hasSpacePrefix() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, SourceLocation CC, bool *ICContext=nullptr)
uint64_t getFieldOffset(const ValueDecl *FD) const
Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Reading or writing from this object requires a barrier call.
static void DiagnoseNullConversion(Sema &S, Expr *E, QualType T, SourceLocation CC)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
Expression is a Null pointer constant built from a literal zero.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
static StringLiteralCheckType checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef< const Expr *> Args, bool HasVAListArg, unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type, Sema::VariadicCallType CallType, bool InFunctionCall, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset)
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
static bool SemaBuiltinSEHScopeCheck(Sema &SemaRef, CallExpr *TheCall, Scope::ScopeFlags NeededScopeFlags, unsigned DiagID)
void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, unsigned DiagID)
Emit DiagID if statement located on StmtLoc has a suspicious null statement as a Body, and it is located on the same line.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static bool HasEnumType(Expr *E)
Defines the clang::SourceLocation class and associated facilities.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Provides definitions for the atomic synchronization scopes.
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, unsigned ByteNo) const
bool hasUnaligned() const
APFloat & getComplexFloatImag()
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
Expr * getTrueExpr() const
static void CheckNonNullArgument(Sema &S, const Expr *ArgExpr, SourceLocation CallSiteLoc)
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
bool consumesDataArgument() const
ObjCIvarDecl - Represents an ObjC instance variable.
static bool isArgumentExpandedFromMacro(SourceManager &SM, SourceLocation CallLoc, SourceLocation ArgLoc)
Check if the ArgLoc originated from a macro passed to the call at CallLoc.
WhileStmt - This represents a 'while' stmt.
static bool SemaBuiltinCpuIs(Sema &S, CallExpr *TheCall)
SemaBuiltinCpuIs - Handle __builtin_cpu_is(char *).
ASTImporterLookupTable & LT
Builtin::Context & BuiltinInfo
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static void AnalyzeImplicitConversions(Sema &S, Expr *E, SourceLocation CC)
AnalyzeImplicitConversions - Find and report any interesting implicit conversions in the given expres...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
static QualType getSizeOfArgType(const Expr *E)
If E is a sizeof expression, returns its argument type.
SourceManager & getSourceManager() const
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
__DEVICE__ int min(int __a, int __b)
static bool SemaBuiltinPreserveAI(Sema &S, CallExpr *TheCall)
Check the number of arguments, and set the result type to the argument type.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
static bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx, const ValueDecl **VD, uint64_t *MagicValue, bool isConstantEvaluated)
Given a type tag expression find the type tag itself.
static Decl::Kind getKind(const Decl *D)
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
Warn if a value is moved to itself.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
static bool GetMatchingCType(const IdentifierInfo *ArgumentKind, const Expr *TypeExpr, const ASTContext &Ctx, const llvm::DenseMap< Sema::TypeTagMagicValue, Sema::TypeTagData > *MagicValues, bool &FoundWrongKind, Sema::TypeTagData &TypeInfo, bool isConstantEvaluated)
Retrieve the C type corresponding to type tag TypeExpr.
A reference to a declared variable, function, enum, etc.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
static unsigned getAbsoluteValueFunctionKind(const FunctionDecl *FDecl)
static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall)
Check that the argument to __builtin_addressof is a glvalue, and set the result type to the correspon...
bool isPointerType() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
SourceManager & SourceMgr
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
llvm::APSInt convertToInt(unsigned DstWidth, bool DstSign, bool *Overflow=nullptr) const
Return the integral part of this fixed point number, rounded towards zero.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
checkUnsafeExprAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained expressi...
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS)
checkUnsafeAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained type...
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static bool IsInAnyMacroBody(const SourceManager &SM, SourceLocation Loc)
bool isFloatingType() const
const Expr * getBase() const
A trivial tuple used to represent a source range.
SourceLocation getBeginLoc() const LLVM_READONLY
This represents a decl that may have a name.
static unsigned getLargerAbsoluteValueFunction(unsigned AbsFunction)
void DiagnoseAlwaysNonNullPointer(Expr *E, Expr::NullPointerConstantKind NullType, bool IsEqual, SourceRange Range)
Diagnose pointers that are always non-null.
static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, Expr *RHS, bool isProperty)
bool isConstant(const ASTContext &Ctx) const
static IntRange GetValueRange(ASTContext &C, llvm::APSInt &value, unsigned MaxWidth)
static bool SemaBuiltinAnnotation(Sema &S, CallExpr *TheCall)
Check that the first argument to __builtin_annotation is an integer and the second argument is a non-...
Describes an entity that is being initialized.
bool isFunctionPointerType() const
bool isInStdNamespace() const
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
static bool isComparisonOp(Opcode Opc)
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
static Expr * findCapturingExpr(Sema &S, Expr *e, RetainCycleOwner &owner)
Check whether the given argument is a block which captures a variable.
static Optional< int > GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message)
static bool SemaBuiltinCallWithStaticChain(Sema &S, CallExpr *BuiltinCall)
bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const
Represents the canonical version of C arrays with a specified constant size.
This class handles loading and caching of source files into memory.
bool isUnsignedInteger() const
bool isObjC(ID Id)
isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).
APFixedPoint & getFixedPoint()
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
Attr - This represents one attribute.
SourceLocation getLocation() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
QualType getType() const
Return the type wrapped by this type source info.
CanQualType OCLClkEventTy
static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, bool InConstantContext)
Pseudo-evaluate the given integer expression, estimating the range of values it might take...
ArrayRef< ParmVarDecl * > parameters() const
bool EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsFloat - Return true if this is a constant which we can fold and convert to a floating point...
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr, SourceLocation StmtLoc, const NullStmt *Body)
CanQualType UnsignedIntTy
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign, ASTContext &Context)
A helper function to get the alignment of a Decl referred to by DeclRefExpr or MemberExpr.
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
SourceLocation getTopMacroCallerLoc(SourceLocation Loc) const
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
unsigned getVectorLength() const