64 #include "llvm/ADT/APFloat.h" 65 #include "llvm/ADT/APInt.h" 66 #include "llvm/ADT/APSInt.h" 67 #include "llvm/ADT/ArrayRef.h" 68 #include "llvm/ADT/DenseMap.h" 69 #include "llvm/ADT/FoldingSet.h" 70 #include "llvm/ADT/None.h" 71 #include "llvm/ADT/Optional.h" 72 #include "llvm/ADT/STLExtras.h" 73 #include "llvm/ADT/SmallBitVector.h" 74 #include "llvm/ADT/SmallPtrSet.h" 75 #include "llvm/ADT/SmallString.h" 76 #include "llvm/ADT/SmallVector.h" 77 #include "llvm/ADT/StringRef.h" 78 #include "llvm/ADT/StringSwitch.h" 79 #include "llvm/ADT/Triple.h" 80 #include "llvm/Support/AtomicOrdering.h" 81 #include "llvm/Support/Casting.h" 82 #include "llvm/Support/Compiler.h" 83 #include "llvm/Support/ConvertUTF.h" 84 #include "llvm/Support/ErrorHandling.h" 85 #include "llvm/Support/Format.h" 86 #include "llvm/Support/Locale.h" 87 #include "llvm/Support/MathExtras.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());
199 for (
unsigned I = 0; I < 2; ++I) {
203 S.
Diag(Arg.
get()->getBeginLoc(), diag::err_overflow_builtin_must_be_int)
204 << Ty << Arg.
get()->getSourceRange();
212 TheCall->
setArg(I, Arg.get());
222 if (!(PtrTy && PtrTy->getPointeeType()->isIntegerType() &&
223 !PtrTy->getPointeeType().isConstQualified())) {
224 S.
Diag(Arg.
get()->getBeginLoc(),
225 diag::err_overflow_builtin_must_be_ptr_int)
226 << Ty << Arg.
get()->getSourceRange();
234 TheCall->
setArg(2, Arg.get());
240 CallExpr *TheCall,
unsigned SizeIdx,
242 StringRef LikelyMacroName) {
247 const Expr *SizeArg = TheCall->
getArg(SizeIdx);
248 const Expr *DstSizeArg = TheCall->
getArg(DstSizeIdx);
257 llvm::APSInt Size = SizeResult.
Val.
getInt();
258 llvm::APSInt DstSize = DstSizeResult.
Val.
getInt();
260 if (Size.ule(DstSize))
264 StringRef FunctionName = FDecl->
getName();
271 FunctionName = LikelyMacroName;
275 S.
Diag(SL, diag::warn_memcpy_chk_overflow)
276 << FunctionName << DstSize.toString(10)
277 << Size.toString(10);
290 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_not_call)
295 auto CE = cast<CallExpr>(Call);
296 if (CE->getCallee()->getType()->isBlockPointerType()) {
297 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_block_call)
302 const Decl *TargetDecl = CE->getCalleeDecl();
303 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
304 if (FD->getBuiltinID()) {
305 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_builtin_call)
310 if (isa<CXXPseudoDestructorExpr>(CE->getCallee()->IgnoreParens())) {
311 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_pdtor_call)
319 if (!ChainResult.
get()->getType()->isPointerType()) {
320 S.
Diag(BuiltinLoc, diag::err_second_argument_to_cwsc_not_pointer)
326 QualType ArgTys[2] = { ReturnTy, ChainResult.
get()->getType() };
334 BuiltinCall->
setType(CE->getType());
338 BuiltinCall->
setArg(1, ChainResult.
get());
355 if (!S || !(S->
getFlags() & NeededScopeFlags)) {
358 << DRE->getDecl()->getIdentifier();
374 ArrayRef<QualType> Params =
376 unsigned ArgCounter = 0;
377 bool IllegalParams =
false;
380 for (ArrayRef<QualType>::iterator I = Params.begin(), E = Params.end();
381 I != E; ++I, ++ArgCounter) {
382 if (!(*I)->isPointerType() || !(*I)->getPointeeType()->isVoidType() ||
383 (*I)->getPointeeType().getQualifiers().getAddressSpace() !=
389 if (isa<BlockExpr>(BlockArg)) {
390 BlockDecl *BD = cast<BlockExpr>(BlockArg)->getBlockDecl();
392 }
else if (isa<DeclRefExpr>(BlockArg)) {
393 ErrorLoc = cast<DeclRefExpr>(BlockArg)->getBeginLoc();
396 diag::err_opencl_enqueue_kernel_blocks_non_local_void_args);
397 IllegalParams =
true;
401 return IllegalParams;
423 S.
Diag(NDRangeArg->
getBeginLoc(), diag::err_opencl_builtin_expected_type)
430 S.
Diag(BlockArg->
getBeginLoc(), diag::err_opencl_builtin_expected_type)
446 S.
Diag(BlockArg->
getBeginLoc(), diag::err_opencl_builtin_expected_type)
458 unsigned Start,
unsigned End) {
459 bool IllegalParams =
false;
460 for (
unsigned I = Start; I <=
End; ++I)
463 return IllegalParams;
470 unsigned NumNonVarArgs) {
473 unsigned NumBlockParams =
475 unsigned TotalNumArgs = TheCall->
getNumArgs();
479 if (TotalNumArgs != NumBlockParams + NumNonVarArgs) {
481 diag::err_opencl_enqueue_kernel_local_size_args);
532 diag::err_opencl_builtin_expected_type)
540 diag::err_opencl_builtin_expected_type)
541 << TheCall->
getDirectCallee() <<
"'kernel_enqueue_flags_t' (i.e. uint)";
548 diag::err_opencl_builtin_expected_type)
567 diag::err_opencl_enqueue_kernel_blocks_no_args);
591 diag::err_opencl_builtin_expected_type)
604 diag::err_opencl_builtin_expected_type)
616 diag::err_opencl_builtin_expected_type)
630 diag::err_opencl_enqueue_kernel_incorrect_args);
636 return D->
getAttr<OpenCLAccessAttr>();
648 OpenCLAccessAttr *AccessQual =
655 case Builtin::BIread_pipe:
656 case Builtin::BIreserve_read_pipe:
657 case Builtin::BIcommit_read_pipe:
658 case Builtin::BIwork_group_reserve_read_pipe:
659 case Builtin::BIsub_group_reserve_read_pipe:
660 case Builtin::BIwork_group_commit_read_pipe:
661 case Builtin::BIsub_group_commit_read_pipe:
662 if (!(!AccessQual || AccessQual->isReadOnly())) {
664 diag::err_opencl_builtin_pipe_invalid_access_modifier)
669 case Builtin::BIwrite_pipe:
670 case Builtin::BIreserve_write_pipe:
671 case Builtin::BIcommit_write_pipe:
672 case Builtin::BIwork_group_reserve_write_pipe:
673 case Builtin::BIsub_group_reserve_write_pipe:
674 case Builtin::BIwork_group_commit_write_pipe:
675 case Builtin::BIsub_group_commit_write_pipe:
676 if (!(AccessQual && AccessQual->isWriteOnly())) {
678 diag::err_opencl_builtin_pipe_invalid_access_modifier)
848 if (!RT->isPointerType() || RT->getPointeeType()
850 S.
Diag(Call->
getBeginLoc(), diag::err_opencl_builtin_to_addr_invalid_arg)
857 diag::warn_opencl_generic_address_space_arg)
862 RT = RT->getPointeeType();
863 auto Qual = RT.getQualifiers();
865 case Builtin::BIto_global:
868 case Builtin::BIto_local:
871 case Builtin::BIto_private:
875 llvm_unreachable(
"Invalid builtin function");
878 RT.getUnqualifiedType(), Qual)));
913 if (DiagSelect.hasValue()) {
926 diag::err_incomplete_type))
930 "Unhandled non-object pointer case");
947 ArrayRef<llvm::Triple::ArchType> SupportedArchs) {
948 llvm::Triple::ArchType CurArch =
950 if (llvm::is_contained(SupportedArchs, CurArch))
958 Sema::CheckBuiltinFunctionCall(
FunctionDecl *FDecl,
unsigned BuiltinID,
963 unsigned ICEArguments = 0;
970 for (
unsigned ArgNo = 0; ICEArguments != 0; ++ArgNo) {
972 if ((ICEArguments & (1 << ArgNo)) == 0)
continue;
975 if (SemaBuiltinConstantArg(TheCall, ArgNo, Result))
977 ICEArguments &= ~(1 << ArgNo);
981 case Builtin::BI__builtin___CFStringMakeConstantString:
983 "Wrong # arguments to builtin CFStringMakeConstantString");
984 if (CheckObjCString(TheCall->
getArg(0)))
987 case Builtin::BI__builtin_ms_va_start:
988 case Builtin::BI__builtin_stdarg_start:
989 case Builtin::BI__builtin_va_start:
990 if (SemaBuiltinVAStart(BuiltinID, TheCall))
993 case Builtin::BI__va_start: {
995 case llvm::Triple::aarch64:
996 case llvm::Triple::arm:
997 case llvm::Triple::thumb:
998 if (SemaBuiltinVAStartARMMicrosoft(TheCall))
1002 if (SemaBuiltinVAStart(BuiltinID, TheCall))
1010 case Builtin::BI_interlockedbittestandset_acq:
1011 case Builtin::BI_interlockedbittestandset_rel:
1012 case Builtin::BI_interlockedbittestandset_nf:
1013 case Builtin::BI_interlockedbittestandreset_acq:
1014 case Builtin::BI_interlockedbittestandreset_rel:
1015 case Builtin::BI_interlockedbittestandreset_nf:
1017 *
this, BuiltinID, TheCall,
1018 {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
1023 case Builtin::BI_bittest64:
1024 case Builtin::BI_bittestandcomplement64:
1025 case Builtin::BI_bittestandreset64:
1026 case Builtin::BI_bittestandset64:
1027 case Builtin::BI_interlockedbittestandreset64:
1028 case Builtin::BI_interlockedbittestandset64:
1030 {llvm::Triple::x86_64, llvm::Triple::arm,
1031 llvm::Triple::thumb, llvm::Triple::aarch64}))
1035 case Builtin::BI__builtin_isgreater:
1036 case Builtin::BI__builtin_isgreaterequal:
1037 case Builtin::BI__builtin_isless:
1038 case Builtin::BI__builtin_islessequal:
1039 case Builtin::BI__builtin_islessgreater:
1040 case Builtin::BI__builtin_isunordered:
1041 if (SemaBuiltinUnorderedCompare(TheCall))
1044 case Builtin::BI__builtin_fpclassify:
1045 if (SemaBuiltinFPClassification(TheCall, 6))
1048 case Builtin::BI__builtin_isfinite:
1049 case Builtin::BI__builtin_isinf:
1050 case Builtin::BI__builtin_isinf_sign:
1051 case Builtin::BI__builtin_isnan:
1052 case Builtin::BI__builtin_isnormal:
1053 case Builtin::BI__builtin_signbit:
1054 case Builtin::BI__builtin_signbitf:
1055 case Builtin::BI__builtin_signbitl:
1056 if (SemaBuiltinFPClassification(TheCall, 1))
1059 case Builtin::BI__builtin_shufflevector:
1060 return SemaBuiltinShuffleVector(TheCall);
1063 case Builtin::BI__builtin_prefetch:
1064 if (SemaBuiltinPrefetch(TheCall))
1067 case Builtin::BI__builtin_alloca_with_align:
1068 if (SemaBuiltinAllocaWithAlign(TheCall))
1071 case Builtin::BI__assume:
1072 case Builtin::BI__builtin_assume:
1073 if (SemaBuiltinAssume(TheCall))
1076 case Builtin::BI__builtin_assume_aligned:
1077 if (SemaBuiltinAssumeAligned(TheCall))
1080 case Builtin::BI__builtin_object_size:
1081 if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 3))
1084 case Builtin::BI__builtin_longjmp:
1085 if (SemaBuiltinLongjmp(TheCall))
1088 case Builtin::BI__builtin_setjmp:
1089 if (SemaBuiltinSetjmp(TheCall))
1092 case Builtin::BI_setjmp:
1093 case Builtin::BI_setjmpex:
1097 case Builtin::BI__builtin_classify_type:
1101 case Builtin::BI__builtin_constant_p:
1105 case Builtin::BI__builtin_launder:
1107 case Builtin::BI__sync_fetch_and_add:
1108 case Builtin::BI__sync_fetch_and_add_1:
1109 case Builtin::BI__sync_fetch_and_add_2:
1110 case Builtin::BI__sync_fetch_and_add_4:
1111 case Builtin::BI__sync_fetch_and_add_8:
1112 case Builtin::BI__sync_fetch_and_add_16:
1113 case Builtin::BI__sync_fetch_and_sub:
1114 case Builtin::BI__sync_fetch_and_sub_1:
1115 case Builtin::BI__sync_fetch_and_sub_2:
1116 case Builtin::BI__sync_fetch_and_sub_4:
1117 case Builtin::BI__sync_fetch_and_sub_8:
1118 case Builtin::BI__sync_fetch_and_sub_16:
1119 case Builtin::BI__sync_fetch_and_or:
1120 case Builtin::BI__sync_fetch_and_or_1:
1121 case Builtin::BI__sync_fetch_and_or_2:
1122 case Builtin::BI__sync_fetch_and_or_4:
1123 case Builtin::BI__sync_fetch_and_or_8:
1124 case Builtin::BI__sync_fetch_and_or_16:
1125 case Builtin::BI__sync_fetch_and_and:
1126 case Builtin::BI__sync_fetch_and_and_1:
1127 case Builtin::BI__sync_fetch_and_and_2:
1128 case Builtin::BI__sync_fetch_and_and_4:
1129 case Builtin::BI__sync_fetch_and_and_8:
1130 case Builtin::BI__sync_fetch_and_and_16:
1131 case Builtin::BI__sync_fetch_and_xor:
1132 case Builtin::BI__sync_fetch_and_xor_1:
1133 case Builtin::BI__sync_fetch_and_xor_2:
1134 case Builtin::BI__sync_fetch_and_xor_4:
1135 case Builtin::BI__sync_fetch_and_xor_8:
1136 case Builtin::BI__sync_fetch_and_xor_16:
1137 case Builtin::BI__sync_fetch_and_nand:
1138 case Builtin::BI__sync_fetch_and_nand_1:
1139 case Builtin::BI__sync_fetch_and_nand_2:
1140 case Builtin::BI__sync_fetch_and_nand_4:
1141 case Builtin::BI__sync_fetch_and_nand_8:
1142 case Builtin::BI__sync_fetch_and_nand_16:
1143 case Builtin::BI__sync_add_and_fetch:
1144 case Builtin::BI__sync_add_and_fetch_1:
1145 case Builtin::BI__sync_add_and_fetch_2:
1146 case Builtin::BI__sync_add_and_fetch_4:
1147 case Builtin::BI__sync_add_and_fetch_8:
1148 case Builtin::BI__sync_add_and_fetch_16:
1149 case Builtin::BI__sync_sub_and_fetch:
1150 case Builtin::BI__sync_sub_and_fetch_1:
1151 case Builtin::BI__sync_sub_and_fetch_2:
1152 case Builtin::BI__sync_sub_and_fetch_4:
1153 case Builtin::BI__sync_sub_and_fetch_8:
1154 case Builtin::BI__sync_sub_and_fetch_16:
1155 case Builtin::BI__sync_and_and_fetch:
1156 case Builtin::BI__sync_and_and_fetch_1:
1157 case Builtin::BI__sync_and_and_fetch_2:
1158 case Builtin::BI__sync_and_and_fetch_4:
1159 case Builtin::BI__sync_and_and_fetch_8:
1160 case Builtin::BI__sync_and_and_fetch_16:
1161 case Builtin::BI__sync_or_and_fetch:
1162 case Builtin::BI__sync_or_and_fetch_1:
1163 case Builtin::BI__sync_or_and_fetch_2:
1164 case Builtin::BI__sync_or_and_fetch_4:
1165 case Builtin::BI__sync_or_and_fetch_8:
1166 case Builtin::BI__sync_or_and_fetch_16:
1167 case Builtin::BI__sync_xor_and_fetch:
1168 case Builtin::BI__sync_xor_and_fetch_1:
1169 case Builtin::BI__sync_xor_and_fetch_2:
1170 case Builtin::BI__sync_xor_and_fetch_4:
1171 case Builtin::BI__sync_xor_and_fetch_8:
1172 case Builtin::BI__sync_xor_and_fetch_16:
1173 case Builtin::BI__sync_nand_and_fetch:
1174 case Builtin::BI__sync_nand_and_fetch_1:
1175 case Builtin::BI__sync_nand_and_fetch_2:
1176 case Builtin::BI__sync_nand_and_fetch_4:
1177 case Builtin::BI__sync_nand_and_fetch_8:
1178 case Builtin::BI__sync_nand_and_fetch_16:
1179 case Builtin::BI__sync_val_compare_and_swap:
1180 case Builtin::BI__sync_val_compare_and_swap_1:
1181 case Builtin::BI__sync_val_compare_and_swap_2:
1182 case Builtin::BI__sync_val_compare_and_swap_4:
1183 case Builtin::BI__sync_val_compare_and_swap_8:
1184 case Builtin::BI__sync_val_compare_and_swap_16:
1185 case Builtin::BI__sync_bool_compare_and_swap:
1186 case Builtin::BI__sync_bool_compare_and_swap_1:
1187 case Builtin::BI__sync_bool_compare_and_swap_2:
1188 case Builtin::BI__sync_bool_compare_and_swap_4:
1189 case Builtin::BI__sync_bool_compare_and_swap_8:
1190 case Builtin::BI__sync_bool_compare_and_swap_16:
1191 case Builtin::BI__sync_lock_test_and_set:
1192 case Builtin::BI__sync_lock_test_and_set_1:
1193 case Builtin::BI__sync_lock_test_and_set_2:
1194 case Builtin::BI__sync_lock_test_and_set_4:
1195 case Builtin::BI__sync_lock_test_and_set_8:
1196 case Builtin::BI__sync_lock_test_and_set_16:
1197 case Builtin::BI__sync_lock_release:
1198 case Builtin::BI__sync_lock_release_1:
1199 case Builtin::BI__sync_lock_release_2:
1200 case Builtin::BI__sync_lock_release_4:
1201 case Builtin::BI__sync_lock_release_8:
1202 case Builtin::BI__sync_lock_release_16:
1203 case Builtin::BI__sync_swap:
1204 case Builtin::BI__sync_swap_1:
1205 case Builtin::BI__sync_swap_2:
1206 case Builtin::BI__sync_swap_4:
1207 case Builtin::BI__sync_swap_8:
1208 case Builtin::BI__sync_swap_16:
1209 return SemaBuiltinAtomicOverloaded(TheCallResult);
1210 case Builtin::BI__sync_synchronize:
1214 case Builtin::BI__builtin_nontemporal_load:
1215 case Builtin::BI__builtin_nontemporal_store:
1216 return SemaBuiltinNontemporalOverloaded(TheCallResult);
1217 #define BUILTIN(ID, TYPE, ATTRS) 1218 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ 1219 case Builtin::BI##ID: \ 1220 return SemaAtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID); 1221 #include "clang/Basic/Builtins.def" 1222 case Builtin::BI__annotation:
1226 case Builtin::BI__builtin_annotation:
1230 case Builtin::BI__builtin_addressof:
1234 case Builtin::BI__builtin_add_overflow:
1235 case Builtin::BI__builtin_sub_overflow:
1236 case Builtin::BI__builtin_mul_overflow:
1240 case Builtin::BI__builtin_operator_new:
1241 case Builtin::BI__builtin_operator_delete: {
1242 bool IsDelete = BuiltinID == Builtin::BI__builtin_operator_delete;
1244 SemaBuiltinOperatorNewDeleteOverloaded(TheCallResult, IsDelete);
1246 CorrectDelayedTyposInExpr(TheCallResult.
get());
1249 case Builtin::BI__builtin_dump_struct: {
1259 << PtrArgType <<
"structure pointer" << 1 << 0 << 3 << 1 << PtrArgType
1260 <<
"structure pointer";
1268 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1269 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3 << 2
1270 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1274 const auto *FuncType =
1278 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1279 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3 << 2
1280 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1284 if (
const auto *FT = dyn_cast<FunctionProtoType>(FuncType)) {
1285 if (!FT->getNumParams()) {
1286 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1287 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1288 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1292 if (!FT->isVariadic() || FT->getReturnType() != Context.
IntTy ||
1295 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1296 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1297 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1308 case Builtin::BI__builtin___memcpy_chk:
1311 case Builtin::BI__builtin___memmove_chk:
1314 case Builtin::BI__builtin___memset_chk:
1317 case Builtin::BI__builtin___strlcat_chk:
1320 case Builtin::BI__builtin___strlcpy_chk:
1323 case Builtin::BI__builtin___strncat_chk:
1326 case Builtin::BI__builtin___strncpy_chk:
1329 case Builtin::BI__builtin___stpncpy_chk:
1332 case Builtin::BI__builtin___memccpy_chk:
1335 case Builtin::BI__builtin___snprintf_chk:
1338 case Builtin::BI__builtin___vsnprintf_chk:
1341 case Builtin::BI__builtin_call_with_static_chain:
1345 case Builtin::BI__exception_code:
1346 case Builtin::BI_exception_code:
1348 diag::err_seh___except_block))
1351 case Builtin::BI__exception_info:
1352 case Builtin::BI_exception_info:
1354 diag::err_seh___except_filter))
1357 case Builtin::BI__GetExceptionInfo:
1361 if (CheckCXXThrowOperand(
1370 case Builtin::BIread_pipe:
1371 case Builtin::BIwrite_pipe:
1377 case Builtin::BIreserve_read_pipe:
1378 case Builtin::BIreserve_write_pipe:
1379 case Builtin::BIwork_group_reserve_read_pipe:
1380 case Builtin::BIwork_group_reserve_write_pipe:
1384 case Builtin::BIsub_group_reserve_read_pipe:
1385 case Builtin::BIsub_group_reserve_write_pipe:
1390 case Builtin::BIcommit_read_pipe:
1391 case Builtin::BIcommit_write_pipe:
1392 case Builtin::BIwork_group_commit_read_pipe:
1393 case Builtin::BIwork_group_commit_write_pipe:
1397 case Builtin::BIsub_group_commit_read_pipe:
1398 case Builtin::BIsub_group_commit_write_pipe:
1403 case Builtin::BIget_pipe_num_packets:
1404 case Builtin::BIget_pipe_max_packets:
1408 case Builtin::BIto_global:
1409 case Builtin::BIto_local:
1410 case Builtin::BIto_private:
1415 case Builtin::BIenqueue_kernel:
1419 case Builtin::BIget_kernel_work_group_size:
1420 case Builtin::BIget_kernel_preferred_work_group_size_multiple:
1424 case Builtin::BIget_kernel_max_sub_group_size_for_ndrange:
1425 case Builtin::BIget_kernel_sub_group_count_for_ndrange:
1429 case Builtin::BI__builtin_os_log_format:
1430 case Builtin::BI__builtin_os_log_format_buffer_size:
1431 if (SemaBuiltinOSLogFormat(TheCall))
1440 case llvm::Triple::arm:
1441 case llvm::Triple::armeb:
1442 case llvm::Triple::thumb:
1443 case llvm::Triple::thumbeb:
1444 if (CheckARMBuiltinFunctionCall(BuiltinID, TheCall))
1447 case llvm::Triple::aarch64:
1448 case llvm::Triple::aarch64_be:
1449 if (CheckAArch64BuiltinFunctionCall(BuiltinID, TheCall))
1452 case llvm::Triple::hexagon:
1453 if (CheckHexagonBuiltinFunctionCall(BuiltinID, TheCall))
1456 case llvm::Triple::mips:
1457 case llvm::Triple::mipsel:
1458 case llvm::Triple::mips64:
1459 case llvm::Triple::mips64el:
1460 if (CheckMipsBuiltinFunctionCall(BuiltinID, TheCall))
1463 case llvm::Triple::systemz:
1464 if (CheckSystemZBuiltinFunctionCall(BuiltinID, TheCall))
1467 case llvm::Triple::x86:
1468 case llvm::Triple::x86_64:
1469 if (CheckX86BuiltinFunctionCall(BuiltinID, TheCall))
1472 case llvm::Triple::ppc:
1473 case llvm::Triple::ppc64:
1474 case llvm::Triple::ppc64le:
1475 if (CheckPPCBuiltinFunctionCall(BuiltinID, TheCall))
1483 return TheCallResult;
1487 static unsigned RFT(
unsigned t,
bool shift =
false,
bool ForceQuad =
false) {
1489 int IsQuad = ForceQuad ?
true : Type.
isQuad();
1493 return shift ? 7 : (8 << IsQuad) - 1;
1496 return shift ? 15 : (4 << IsQuad) - 1;
1498 return shift ? 31 : (2 << IsQuad) - 1;
1501 return shift ? 63 : (1 << IsQuad) - 1;
1503 return shift ? 127 : (1 << IsQuad) - 1;
1505 assert(!shift &&
"cannot shift float types!");
1506 return (4 << IsQuad) - 1;
1508 assert(!shift &&
"cannot shift float types!");
1509 return (2 << IsQuad) - 1;
1511 assert(!shift &&
"cannot shift float types!");
1512 return (1 << IsQuad) - 1;
1514 llvm_unreachable(
"Invalid NeonTypeFlag!");
1521 bool IsPolyUnsigned,
bool IsInt64Long) {
1553 llvm_unreachable(
"Invalid NeonTypeFlag!");
1556 bool Sema::CheckNeonBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
1557 llvm::APSInt Result;
1561 bool HasConstPtr =
false;
1562 switch (BuiltinID) {
1563 #define GET_NEON_OVERLOAD_CHECK 1564 #include "clang/Basic/arm_neon.inc" 1565 #include "clang/Basic/arm_fp16.inc" 1566 #undef GET_NEON_OVERLOAD_CHECK 1573 if (SemaBuiltinConstantArg(TheCall, ImmArg, Result))
1576 TV = Result.getLimitedValue(64);
1577 if ((TV > 63) || (mask & (1ULL << TV)) == 0)
1582 if (PtrArgNum >= 0) {
1586 Arg = ICE->getSubExpr();
1587 ExprResult RHS = DefaultFunctionArrayLvalueConversion(Arg);
1591 bool IsPolyUnsigned = Arch == llvm::Triple::aarch64 ||
1592 Arch == llvm::Triple::aarch64_be;
1600 AssignConvertType ConvTy;
1601 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
1604 if (DiagnoseAssignmentResult(ConvTy, Arg->
getBeginLoc(), LHSTy, RHSTy,
1605 RHS.
get(), AA_Assigning))
1611 unsigned i = 0, l = 0, u = 0;
1612 switch (BuiltinID) {
1615 #define GET_NEON_IMMEDIATE_CHECK 1616 #include "clang/Basic/arm_neon.inc" 1617 #include "clang/Basic/arm_fp16.inc" 1618 #undef GET_NEON_IMMEDIATE_CHECK 1621 return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
1624 bool Sema::CheckARMBuiltinExclusiveCall(
unsigned BuiltinID,
CallExpr *TheCall,
1625 unsigned MaxWidth) {
1626 assert((BuiltinID == ARM::BI__builtin_arm_ldrex ||
1627 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1628 BuiltinID == ARM::BI__builtin_arm_strex ||
1629 BuiltinID == ARM::BI__builtin_arm_stlex ||
1630 BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1631 BuiltinID == AArch64::BI__builtin_arm_ldaex ||
1632 BuiltinID == AArch64::BI__builtin_arm_strex ||
1633 BuiltinID == AArch64::BI__builtin_arm_stlex) &&
1634 "unexpected ARM builtin");
1635 bool IsLdrex = BuiltinID == ARM::BI__builtin_arm_ldrex ||
1636 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1637 BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1638 BuiltinID == AArch64::BI__builtin_arm_ldaex;
1650 Expr *PointerArg = TheCall->
getArg(IsLdrex ? 0 : 1);
1651 ExprResult PointerArgRes = DefaultFunctionArrayLvalueConversion(PointerArg);
1654 PointerArg = PointerArgRes.
get();
1674 CastNeeded = CK_BitCast;
1675 Diag(DRE->
getBeginLoc(), diag::ext_typecheck_convert_discards_qualifiers)
1682 PointerArgRes = ImpCastExprToType(PointerArg, AddrType, CastNeeded);
1685 PointerArg = PointerArgRes.
get();
1687 TheCall->
setArg(IsLdrex ? 0 : 1, PointerArg);
1692 Diag(DRE->
getBeginLoc(), diag::err_atomic_builtin_must_be_pointer_intfltptr)
1699 assert(MaxWidth == 64 &&
"Diagnostic unexpectedly inaccurate");
1700 Diag(DRE->
getBeginLoc(), diag::err_atomic_exclusive_builtin_pointer_size)
1727 Context, ValType,
false);
1728 ValArg = PerformCopyInitialization(Entity,
SourceLocation(), ValArg);
1739 bool Sema::CheckARMBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
1740 if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
1741 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1742 BuiltinID == ARM::BI__builtin_arm_strex ||
1743 BuiltinID == ARM::BI__builtin_arm_stlex) {
1744 return CheckARMBuiltinExclusiveCall(BuiltinID, TheCall, 64);
1747 if (BuiltinID == ARM::BI__builtin_arm_prefetch) {
1748 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
1749 SemaBuiltinConstantArgRange(TheCall, 2, 0, 1);
1752 if (BuiltinID == ARM::BI__builtin_arm_rsr64 ||
1753 BuiltinID == ARM::BI__builtin_arm_wsr64)
1754 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 3,
false);
1756 if (BuiltinID == ARM::BI__builtin_arm_rsr ||
1757 BuiltinID == ARM::BI__builtin_arm_rsrp ||
1758 BuiltinID == ARM::BI__builtin_arm_wsr ||
1759 BuiltinID == ARM::BI__builtin_arm_wsrp)
1760 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1762 if (CheckNeonBuiltinFunctionCall(BuiltinID, TheCall))
1768 switch (BuiltinID) {
1769 default:
return false;
1770 case ARM::BI__builtin_arm_ssat:
1771 return SemaBuiltinConstantArgRange(TheCall, 1, 1, 32);
1772 case ARM::BI__builtin_arm_usat:
1773 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 31);
1774 case ARM::BI__builtin_arm_ssat16:
1775 return SemaBuiltinConstantArgRange(TheCall, 1, 1, 16);
1776 case ARM::BI__builtin_arm_usat16:
1777 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
1778 case ARM::BI__builtin_arm_vcvtr_f:
1779 case ARM::BI__builtin_arm_vcvtr_d:
1780 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
1781 case ARM::BI__builtin_arm_dmb:
1782 case ARM::BI__builtin_arm_dsb:
1783 case ARM::BI__builtin_arm_isb:
1784 case ARM::BI__builtin_arm_dbg:
1785 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 15);
1789 bool Sema::CheckAArch64BuiltinFunctionCall(
unsigned BuiltinID,
1791 if (BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1792 BuiltinID == AArch64::BI__builtin_arm_ldaex ||
1793 BuiltinID == AArch64::BI__builtin_arm_strex ||
1794 BuiltinID == AArch64::BI__builtin_arm_stlex) {
1795 return CheckARMBuiltinExclusiveCall(BuiltinID, TheCall, 128);
1798 if (BuiltinID == AArch64::BI__builtin_arm_prefetch) {
1799 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
1800 SemaBuiltinConstantArgRange(TheCall, 2, 0, 2) ||
1801 SemaBuiltinConstantArgRange(TheCall, 3, 0, 1) ||
1802 SemaBuiltinConstantArgRange(TheCall, 4, 0, 1);
1805 if (BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
1806 BuiltinID == AArch64::BI__builtin_arm_wsr64)
1807 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1809 if (BuiltinID == AArch64::BI__builtin_arm_rsr ||
1810 BuiltinID == AArch64::BI__builtin_arm_rsrp ||
1811 BuiltinID == AArch64::BI__builtin_arm_wsr ||
1812 BuiltinID == AArch64::BI__builtin_arm_wsrp)
1813 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1818 if (BuiltinID == AArch64::BI_ReadStatusReg ||
1819 BuiltinID == AArch64::BI_WriteStatusReg)
1820 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 0x7fff);
1822 if (BuiltinID == AArch64::BI__getReg)
1823 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31);
1825 if (CheckNeonBuiltinFunctionCall(BuiltinID, TheCall))
1830 unsigned i = 0, l = 0, u = 0;
1831 switch (BuiltinID) {
1832 default:
return false;
1833 case AArch64::BI__builtin_arm_dmb:
1834 case AArch64::BI__builtin_arm_dsb:
1835 case AArch64::BI__builtin_arm_isb: l = 0; u = 15;
break;
1838 return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
1841 bool Sema::CheckHexagonBuiltinCpu(
unsigned BuiltinID,
CallExpr *TheCall) {
1842 struct BuiltinAndString {
1847 static BuiltinAndString ValidCPU[] = {
1848 { Hexagon::BI__builtin_HEXAGON_A6_vcmpbeq_notany,
"v65,v66" },
1849 { Hexagon::BI__builtin_HEXAGON_A6_vminub_RdP,
"v62,v65,v66" },
1850 { Hexagon::BI__builtin_HEXAGON_F2_dfadd,
"v66" },
1851 { Hexagon::BI__builtin_HEXAGON_F2_dfsub,
"v66" },
1852 { Hexagon::BI__builtin_HEXAGON_M2_mnaci,
"v66" },
1853 { Hexagon::BI__builtin_HEXAGON_M6_vabsdiffb,
"v62,v65,v66" },
1854 { Hexagon::BI__builtin_HEXAGON_M6_vabsdiffub,
"v62,v65,v66" },
1855 { Hexagon::BI__builtin_HEXAGON_S2_mask,
"v66" },
1856 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc,
"v60,v62,v65,v66" },
1857 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and,
"v60,v62,v65,v66" },
1858 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac,
"v60,v62,v65,v66" },
1859 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or,
"v60,v62,v65,v66" },
1860 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p,
"v60,v62,v65,v66" },
1861 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc,
"v60,v62,v65,v66" },
1862 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc,
"v60,v62,v65,v66" },
1863 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and,
"v60,v62,v65,v66" },
1864 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac,
"v60,v62,v65,v66" },
1865 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or,
"v60,v62,v65,v66" },
1866 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r,
"v60,v62,v65,v66" },
1867 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc,
"v60,v62,v65,v66" },
1868 { Hexagon::BI__builtin_HEXAGON_S6_vsplatrbp,
"v62,v65,v66" },
1869 { Hexagon::BI__builtin_HEXAGON_S6_vtrunehb_ppp,
"v62,v65,v66" },
1870 { Hexagon::BI__builtin_HEXAGON_S6_vtrunohb_ppp,
"v62,v65,v66" },
1873 static BuiltinAndString ValidHVX[] = {
1874 { Hexagon::BI__builtin_HEXAGON_V6_hi,
"v60,v62,v65,v66" },
1875 { Hexagon::BI__builtin_HEXAGON_V6_hi_128B,
"v60,v62,v65,v66" },
1876 { Hexagon::BI__builtin_HEXAGON_V6_lo,
"v60,v62,v65,v66" },
1877 { Hexagon::BI__builtin_HEXAGON_V6_lo_128B,
"v60,v62,v65,v66" },
1878 { Hexagon::BI__builtin_HEXAGON_V6_extractw,
"v60,v62,v65,v66" },
1879 { Hexagon::BI__builtin_HEXAGON_V6_extractw_128B,
"v60,v62,v65,v66" },
1880 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatb,
"v62,v65,v66" },
1881 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatb_128B,
"v62,v65,v66" },
1882 { Hexagon::BI__builtin_HEXAGON_V6_lvsplath,
"v62,v65,v66" },
1883 { Hexagon::BI__builtin_HEXAGON_V6_lvsplath_128B,
"v62,v65,v66" },
1884 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatw,
"v60,v62,v65,v66" },
1885 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatw_128B,
"v60,v62,v65,v66" },
1886 { Hexagon::BI__builtin_HEXAGON_V6_pred_and,
"v60,v62,v65,v66" },
1887 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_128B,
"v60,v62,v65,v66" },
1888 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_n,
"v60,v62,v65,v66" },
1889 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_n_128B,
"v60,v62,v65,v66" },
1890 { Hexagon::BI__builtin_HEXAGON_V6_pred_not,
"v60,v62,v65,v66" },
1891 { Hexagon::BI__builtin_HEXAGON_V6_pred_not_128B,
"v60,v62,v65,v66" },
1892 { Hexagon::BI__builtin_HEXAGON_V6_pred_or,
"v60,v62,v65,v66" },
1893 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_128B,
"v60,v62,v65,v66" },
1894 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_n,
"v60,v62,v65,v66" },
1895 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_n_128B,
"v60,v62,v65,v66" },
1896 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2,
"v60,v62,v65,v66" },
1897 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2_128B,
"v60,v62,v65,v66" },
1898 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2v2,
"v62,v65,v66" },
1899 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2v2_128B,
"v62,v65,v66" },
1900 { Hexagon::BI__builtin_HEXAGON_V6_pred_xor,
"v60,v62,v65,v66" },
1901 { Hexagon::BI__builtin_HEXAGON_V6_pred_xor_128B,
"v60,v62,v65,v66" },
1902 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqh,
"v62,v65,v66" },
1903 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqh_128B,
"v62,v65,v66" },
1904 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqw,
"v62,v65,v66" },
1905 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqw_128B,
"v62,v65,v66" },
1906 { Hexagon::BI__builtin_HEXAGON_V6_vabsb,
"v65,v66" },
1907 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_128B,
"v65,v66" },
1908 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_sat,
"v65,v66" },
1909 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_sat_128B,
"v65,v66" },
1910 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffh,
"v60,v62,v65,v66" },
1911 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffh_128B,
"v60,v62,v65,v66" },
1912 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffub,
"v60,v62,v65,v66" },
1913 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffub_128B,
"v60,v62,v65,v66" },
1914 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffuh,
"v60,v62,v65,v66" },
1915 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffuh_128B,
"v60,v62,v65,v66" },
1916 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffw,
"v60,v62,v65,v66" },
1917 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffw_128B,
"v60,v62,v65,v66" },
1918 { Hexagon::BI__builtin_HEXAGON_V6_vabsh,
"v60,v62,v65,v66" },
1919 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_128B,
"v60,v62,v65,v66" },
1920 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_sat,
"v60,v62,v65,v66" },
1921 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_sat_128B,
"v60,v62,v65,v66" },
1922 { Hexagon::BI__builtin_HEXAGON_V6_vabsw,
"v60,v62,v65,v66" },
1923 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_128B,
"v60,v62,v65,v66" },
1924 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_sat,
"v60,v62,v65,v66" },
1925 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_sat_128B,
"v60,v62,v65,v66" },
1926 { Hexagon::BI__builtin_HEXAGON_V6_vaddb,
"v60,v62,v65,v66" },
1927 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_128B,
"v60,v62,v65,v66" },
1928 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_dv,
"v60,v62,v65,v66" },
1929 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_dv_128B,
"v60,v62,v65,v66" },
1930 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat,
"v62,v65,v66" },
1931 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_128B,
"v62,v65,v66" },
1932 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_dv,
"v62,v65,v66" },
1933 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_dv_128B,
"v62,v65,v66" },
1934 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarry,
"v62,v65,v66" },
1935 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarry_128B,
"v62,v65,v66" },
1936 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarrysat,
"v66" },
1937 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarrysat_128B,
"v66" },
1938 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbh,
"v62,v65,v66" },
1939 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbh_128B,
"v62,v65,v66" },
1940 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbw,
"v62,v65,v66" },
1941 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbw_128B,
"v62,v65,v66" },
1942 { Hexagon::BI__builtin_HEXAGON_V6_vaddh,
"v60,v62,v65,v66" },
1943 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_128B,
"v60,v62,v65,v66" },
1944 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_dv,
"v60,v62,v65,v66" },
1945 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_dv_128B,
"v60,v62,v65,v66" },
1946 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat,
"v60,v62,v65,v66" },
1947 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_128B,
"v60,v62,v65,v66" },
1948 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_dv,
"v60,v62,v65,v66" },
1949 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_dv_128B,
"v60,v62,v65,v66" },
1950 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw,
"v60,v62,v65,v66" },
1951 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_128B,
"v60,v62,v65,v66" },
1952 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_acc,
"v62,v65,v66" },
1953 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_acc_128B,
"v62,v65,v66" },
1954 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh,
"v60,v62,v65,v66" },
1955 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_128B,
"v60,v62,v65,v66" },
1956 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_acc,
"v62,v65,v66" },
1957 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_acc_128B,
"v62,v65,v66" },
1958 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat,
"v60,v62,v65,v66" },
1959 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_128B,
"v60,v62,v65,v66" },
1960 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_dv,
"v60,v62,v65,v66" },
1961 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_dv_128B,
"v60,v62,v65,v66" },
1962 { Hexagon::BI__builtin_HEXAGON_V6_vaddububb_sat,
"v62,v65,v66" },
1963 { Hexagon::BI__builtin_HEXAGON_V6_vaddububb_sat_128B,
"v62,v65,v66" },
1964 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat,
"v60,v62,v65,v66" },
1965 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_128B,
"v60,v62,v65,v66" },
1966 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_dv,
"v60,v62,v65,v66" },
1967 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_dv_128B,
"v60,v62,v65,v66" },
1968 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw,
"v60,v62,v65,v66" },
1969 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_128B,
"v60,v62,v65,v66" },
1970 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_acc,
"v62,v65,v66" },
1971 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_acc_128B,
"v62,v65,v66" },
1972 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat,
"v62,v65,v66" },
1973 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_128B,
"v62,v65,v66" },
1974 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_dv,
"v62,v65,v66" },
1975 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_dv_128B,
"v62,v65,v66" },
1976 { Hexagon::BI__builtin_HEXAGON_V6_vaddw,
"v60,v62,v65,v66" },
1977 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_128B,
"v60,v62,v65,v66" },
1978 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_dv,
"v60,v62,v65,v66" },
1979 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_dv_128B,
"v60,v62,v65,v66" },
1980 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat,
"v60,v62,v65,v66" },
1981 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_128B,
"v60,v62,v65,v66" },
1982 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_dv,
"v60,v62,v65,v66" },
1983 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_dv_128B,
"v60,v62,v65,v66" },
1984 { Hexagon::BI__builtin_HEXAGON_V6_valignb,
"v60,v62,v65,v66" },
1985 { Hexagon::BI__builtin_HEXAGON_V6_valignb_128B,
"v60,v62,v65,v66" },
1986 { Hexagon::BI__builtin_HEXAGON_V6_valignbi,
"v60,v62,v65,v66" },
1987 { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B,
"v60,v62,v65,v66" },
1988 { Hexagon::BI__builtin_HEXAGON_V6_vand,
"v60,v62,v65,v66" },
1989 { Hexagon::BI__builtin_HEXAGON_V6_vand_128B,
"v60,v62,v65,v66" },
1990 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt,
"v62,v65,v66" },
1991 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_128B,
"v62,v65,v66" },
1992 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_acc,
"v62,v65,v66" },
1993 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_acc_128B,
"v62,v65,v66" },
1994 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt,
"v60,v62,v65,v66" },
1995 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_128B,
"v60,v62,v65,v66" },
1996 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_acc,
"v60,v62,v65,v66" },
1997 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_acc_128B,
"v60,v62,v65,v66" },
1998 { Hexagon::BI__builtin_HEXAGON_V6_vandvnqv,
"v62,v65,v66" },
1999 { Hexagon::BI__builtin_HEXAGON_V6_vandvnqv_128B,
"v62,v65,v66" },
2000 { Hexagon::BI__builtin_HEXAGON_V6_vandvqv,
"v62,v65,v66" },
2001 { Hexagon::BI__builtin_HEXAGON_V6_vandvqv_128B,
"v62,v65,v66" },
2002 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt,
"v60,v62,v65,v66" },
2003 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_128B,
"v60,v62,v65,v66" },
2004 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_acc,
"v60,v62,v65,v66" },
2005 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_acc_128B,
"v60,v62,v65,v66" },
2006 { Hexagon::BI__builtin_HEXAGON_V6_vaslh,
"v60,v62,v65,v66" },
2007 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_128B,
"v60,v62,v65,v66" },
2008 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_acc,
"v65,v66" },
2009 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_acc_128B,
"v65,v66" },
2010 { Hexagon::BI__builtin_HEXAGON_V6_vaslhv,
"v60,v62,v65,v66" },
2011 { Hexagon::BI__builtin_HEXAGON_V6_vaslhv_128B,
"v60,v62,v65,v66" },
2012 { Hexagon::BI__builtin_HEXAGON_V6_vaslw,
"v60,v62,v65,v66" },
2013 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_128B,
"v60,v62,v65,v66" },
2014 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_acc,
"v60,v62,v65,v66" },
2015 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_acc_128B,
"v60,v62,v65,v66" },
2016 { Hexagon::BI__builtin_HEXAGON_V6_vaslwv,
"v60,v62,v65,v66" },
2017 { Hexagon::BI__builtin_HEXAGON_V6_vaslwv_128B,
"v60,v62,v65,v66" },
2018 { Hexagon::BI__builtin_HEXAGON_V6_vasrh,
"v60,v62,v65,v66" },
2019 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_128B,
"v60,v62,v65,v66" },
2020 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_acc,
"v65,v66" },
2021 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_acc_128B,
"v65,v66" },
2022 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbrndsat,
"v60,v62,v65,v66" },
2023 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbrndsat_128B,
"v60,v62,v65,v66" },
2024 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbsat,
"v62,v65,v66" },
2025 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbsat_128B,
"v62,v65,v66" },
2026 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubrndsat,
"v60,v62,v65,v66" },
2027 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubrndsat_128B,
"v60,v62,v65,v66" },
2028 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubsat,
"v60,v62,v65,v66" },
2029 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubsat_128B,
"v60,v62,v65,v66" },
2030 { Hexagon::BI__builtin_HEXAGON_V6_vasrhv,
"v60,v62,v65,v66" },
2031 { Hexagon::BI__builtin_HEXAGON_V6_vasrhv_128B,
"v60,v62,v65,v66" },
2032 { Hexagon::BI__builtin_HEXAGON_V6_vasr_into,
"v66" },
2033 { Hexagon::BI__builtin_HEXAGON_V6_vasr_into_128B,
"v66" },
2034 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubrndsat,
"v65,v66" },
2035 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubrndsat_128B,
"v65,v66" },
2036 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubsat,
"v65,v66" },
2037 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubsat_128B,
"v65,v66" },
2038 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhrndsat,
"v62,v65,v66" },
2039 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhrndsat_128B,
"v62,v65,v66" },
2040 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhsat,
"v65,v66" },
2041 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhsat_128B,
"v65,v66" },
2042 { Hexagon::BI__builtin_HEXAGON_V6_vasrw,
"v60,v62,v65,v66" },
2043 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_128B,
"v60,v62,v65,v66" },
2044 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_acc,
"v60,v62,v65,v66" },
2045 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_acc_128B,
"v60,v62,v65,v66" },
2046 { Hexagon::BI__builtin_HEXAGON_V6_vasrwh,
"v60,v62,v65,v66" },
2047 { Hexagon::BI__builtin_HEXAGON_V6_vasrwh_128B,
"v60,v62,v65,v66" },
2048 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhrndsat,
"v60,v62,v65,v66" },
2049 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhrndsat_128B,
"v60,v62,v65,v66" },
2050 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhsat,
"v60,v62,v65,v66" },
2051 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhsat_128B,
"v60,v62,v65,v66" },
2052 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhrndsat,
"v62,v65,v66" },
2053 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhrndsat_128B,
"v62,v65,v66" },
2054 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhsat,
"v60,v62,v65,v66" },
2055 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhsat_128B,
"v60,v62,v65,v66" },
2056 { Hexagon::BI__builtin_HEXAGON_V6_vasrwv,
"v60,v62,v65,v66" },
2057 { Hexagon::BI__builtin_HEXAGON_V6_vasrwv_128B,
"v60,v62,v65,v66" },
2058 { Hexagon::BI__builtin_HEXAGON_V6_vassign,
"v60,v62,v65,v66" },
2059 { Hexagon::BI__builtin_HEXAGON_V6_vassign_128B,
"v60,v62,v65,v66" },
2060 { Hexagon::BI__builtin_HEXAGON_V6_vassignp,
"v60,v62,v65,v66" },
2061 { Hexagon::BI__builtin_HEXAGON_V6_vassignp_128B,
"v60,v62,v65,v66" },
2062 { Hexagon::BI__builtin_HEXAGON_V6_vavgb,
"v65,v66" },
2063 { Hexagon::BI__builtin_HEXAGON_V6_vavgb_128B,
"v65,v66" },
2064 { Hexagon::BI__builtin_HEXAGON_V6_vavgbrnd,
"v65,v66" },
2065 { Hexagon::BI__builtin_HEXAGON_V6_vavgbrnd_128B,
"v65,v66" },
2066 { Hexagon::BI__builtin_HEXAGON_V6_vavgh,
"v60,v62,v65,v66" },
2067 { Hexagon::BI__builtin_HEXAGON_V6_vavgh_128B,
"v60,v62,v65,v66" },
2068 { Hexagon::BI__builtin_HEXAGON_V6_vavghrnd,
"v60,v62,v65,v66" },
2069 { Hexagon::BI__builtin_HEXAGON_V6_vavghrnd_128B,
"v60,v62,v65,v66" },
2070 { Hexagon::BI__builtin_HEXAGON_V6_vavgub,
"v60,v62,v65,v66" },
2071 { Hexagon::BI__builtin_HEXAGON_V6_vavgub_128B,
"v60,v62,v65,v66" },
2072 { Hexagon::BI__builtin_HEXAGON_V6_vavgubrnd,
"v60,v62,v65,v66" },
2073 { Hexagon::BI__builtin_HEXAGON_V6_vavgubrnd_128B,
"v60,v62,v65,v66" },
2074 { Hexagon::BI__builtin_HEXAGON_V6_vavguh,
"v60,v62,v65,v66" },
2075 { Hexagon::BI__builtin_HEXAGON_V6_vavguh_128B,
"v60,v62,v65,v66" },
2076 { Hexagon::BI__builtin_HEXAGON_V6_vavguhrnd,
"v60,v62,v65,v66" },
2077 { Hexagon::BI__builtin_HEXAGON_V6_vavguhrnd_128B,
"v60,v62,v65,v66" },
2078 { Hexagon::BI__builtin_HEXAGON_V6_vavguw,
"v65,v66" },
2079 { Hexagon::BI__builtin_HEXAGON_V6_vavguw_128B,
"v65,v66" },
2080 { Hexagon::BI__builtin_HEXAGON_V6_vavguwrnd,
"v65,v66" },
2081 { Hexagon::BI__builtin_HEXAGON_V6_vavguwrnd_128B,
"v65,v66" },
2082 { Hexagon::BI__builtin_HEXAGON_V6_vavgw,
"v60,v62,v65,v66" },
2083 { Hexagon::BI__builtin_HEXAGON_V6_vavgw_128B,
"v60,v62,v65,v66" },
2084 { Hexagon::BI__builtin_HEXAGON_V6_vavgwrnd,
"v60,v62,v65,v66" },
2085 { Hexagon::BI__builtin_HEXAGON_V6_vavgwrnd_128B,
"v60,v62,v65,v66" },
2086 { Hexagon::BI__builtin_HEXAGON_V6_vcl0h,
"v60,v62,v65,v66" },
2087 { Hexagon::BI__builtin_HEXAGON_V6_vcl0h_128B,
"v60,v62,v65,v66" },
2088 { Hexagon::BI__builtin_HEXAGON_V6_vcl0w,
"v60,v62,v65,v66" },
2089 { Hexagon::BI__builtin_HEXAGON_V6_vcl0w_128B,
"v60,v62,v65,v66" },
2090 { Hexagon::BI__builtin_HEXAGON_V6_vcombine,
"v60,v62,v65,v66" },
2091 { Hexagon::BI__builtin_HEXAGON_V6_vcombine_128B,
"v60,v62,v65,v66" },
2092 { Hexagon::BI__builtin_HEXAGON_V6_vd0,
"v60,v62,v65,v66" },
2093 { Hexagon::BI__builtin_HEXAGON_V6_vd0_128B,
"v60,v62,v65,v66" },
2094 { Hexagon::BI__builtin_HEXAGON_V6_vdd0,
"v65,v66" },
2095 { Hexagon::BI__builtin_HEXAGON_V6_vdd0_128B,
"v65,v66" },
2096 { Hexagon::BI__builtin_HEXAGON_V6_vdealb,
"v60,v62,v65,v66" },
2097 { Hexagon::BI__builtin_HEXAGON_V6_vdealb_128B,
"v60,v62,v65,v66" },
2098 { Hexagon::BI__builtin_HEXAGON_V6_vdealb4w,
"v60,v62,v65,v66" },
2099 { Hexagon::BI__builtin_HEXAGON_V6_vdealb4w_128B,
"v60,v62,v65,v66" },
2100 { Hexagon::BI__builtin_HEXAGON_V6_vdealh,
"v60,v62,v65,v66" },
2101 { Hexagon::BI__builtin_HEXAGON_V6_vdealh_128B,
"v60,v62,v65,v66" },
2102 { Hexagon::BI__builtin_HEXAGON_V6_vdealvdd,
"v60,v62,v65,v66" },
2103 { Hexagon::BI__builtin_HEXAGON_V6_vdealvdd_128B,
"v60,v62,v65,v66" },
2104 { Hexagon::BI__builtin_HEXAGON_V6_vdelta,
"v60,v62,v65,v66" },
2105 { Hexagon::BI__builtin_HEXAGON_V6_vdelta_128B,
"v60,v62,v65,v66" },
2106 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus,
"v60,v62,v65,v66" },
2107 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_128B,
"v60,v62,v65,v66" },
2108 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_acc,
"v60,v62,v65,v66" },
2109 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_acc_128B,
"v60,v62,v65,v66" },
2110 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv,
"v60,v62,v65,v66" },
2111 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_128B,
"v60,v62,v65,v66" },
2112 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_acc,
"v60,v62,v65,v66" },
2113 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_acc_128B,
"v60,v62,v65,v66" },
2114 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb,
"v60,v62,v65,v66" },
2115 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_128B,
"v60,v62,v65,v66" },
2116 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_acc,
"v60,v62,v65,v66" },
2117 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_acc_128B,
"v60,v62,v65,v66" },
2118 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv,
"v60,v62,v65,v66" },
2119 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_128B,
"v60,v62,v65,v66" },
2120 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_acc,
"v60,v62,v65,v66" },
2121 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_acc_128B,
"v60,v62,v65,v66" },
2122 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat,
"v60,v62,v65,v66" },
2123 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_128B,
"v60,v62,v65,v66" },
2124 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_acc,
"v60,v62,v65,v66" },
2125 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_acc_128B,
"v60,v62,v65,v66" },
2126 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat,
"v60,v62,v65,v66" },
2127 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_128B,
"v60,v62,v65,v66" },
2128 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_acc,
"v60,v62,v65,v66" },
2129 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_acc_128B,
"v60,v62,v65,v66" },
2130 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat,
"v60,v62,v65,v66" },
2131 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_128B,
"v60,v62,v65,v66" },
2132 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_acc,
"v60,v62,v65,v66" },
2133 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_acc_128B,
"v60,v62,v65,v66" },
2134 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat,
"v60,v62,v65,v66" },
2135 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_128B,
"v60,v62,v65,v66" },
2136 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_acc,
"v60,v62,v65,v66" },
2137 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_acc_128B,
"v60,v62,v65,v66" },
2138 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat,
"v60,v62,v65,v66" },
2139 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_128B,
"v60,v62,v65,v66" },
2140 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_acc,
"v60,v62,v65,v66" },
2141 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_acc_128B,
"v60,v62,v65,v66" },
2142 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh,
"v60,v62,v65,v66" },
2143 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_128B,
"v60,v62,v65,v66" },
2144 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_acc,
"v60,v62,v65,v66" },
2145 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_acc_128B,
"v60,v62,v65,v66" },
2146 { Hexagon::BI__builtin_HEXAGON_V6_veqb,
"v60,v62,v65,v66" },
2147 { Hexagon::BI__builtin_HEXAGON_V6_veqb_128B,
"v60,v62,v65,v66" },
2148 { Hexagon::BI__builtin_HEXAGON_V6_veqb_and,
"v60,v62,v65,v66" },
2149 { Hexagon::BI__builtin_HEXAGON_V6_veqb_and_128B,
"v60,v62,v65,v66" },
2150 { Hexagon::BI__builtin_HEXAGON_V6_veqb_or,
"v60,v62,v65,v66" },
2151 { Hexagon::BI__builtin_HEXAGON_V6_veqb_or_128B,
"v60,v62,v65,v66" },
2152 { Hexagon::BI__builtin_HEXAGON_V6_veqb_xor,
"v60,v62,v65,v66" },
2153 { Hexagon::BI__builtin_HEXAGON_V6_veqb_xor_128B,
"v60,v62,v65,v66" },
2154 { Hexagon::BI__builtin_HEXAGON_V6_veqh,
"v60,v62,v65,v66" },
2155 { Hexagon::BI__builtin_HEXAGON_V6_veqh_128B,
"v60,v62,v65,v66" },
2156 { Hexagon::BI__builtin_HEXAGON_V6_veqh_and,
"v60,v62,v65,v66" },
2157 { Hexagon::BI__builtin_HEXAGON_V6_veqh_and_128B,
"v60,v62,v65,v66" },
2158 { Hexagon::BI__builtin_HEXAGON_V6_veqh_or,
"v60,v62,v65,v66" },
2159 { Hexagon::BI__builtin_HEXAGON_V6_veqh_or_128B,
"v60,v62,v65,v66" },
2160 { Hexagon::BI__builtin_HEXAGON_V6_veqh_xor,
"v60,v62,v65,v66" },
2161 { Hexagon::BI__builtin_HEXAGON_V6_veqh_xor_128B,
"v60,v62,v65,v66" },
2162 { Hexagon::BI__builtin_HEXAGON_V6_veqw,
"v60,v62,v65,v66" },
2163 { Hexagon::BI__builtin_HEXAGON_V6_veqw_128B,
"v60,v62,v65,v66" },
2164 { Hexagon::BI__builtin_HEXAGON_V6_veqw_and,
"v60,v62,v65,v66" },
2165 { Hexagon::BI__builtin_HEXAGON_V6_veqw_and_128B,
"v60,v62,v65,v66" },
2166 { Hexagon::BI__builtin_HEXAGON_V6_veqw_or,
"v60,v62,v65,v66" },
2167 { Hexagon::BI__builtin_HEXAGON_V6_veqw_or_128B,
"v60,v62,v65,v66" },
2168 { Hexagon::BI__builtin_HEXAGON_V6_veqw_xor,
"v60,v62,v65,v66" },
2169 { Hexagon::BI__builtin_HEXAGON_V6_veqw_xor_128B,
"v60,v62,v65,v66" },
2170 { Hexagon::BI__builtin_HEXAGON_V6_vgtb,
"v60,v62,v65,v66" },
2171 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_128B,
"v60,v62,v65,v66" },
2172 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_and,
"v60,v62,v65,v66" },
2173 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_and_128B,
"v60,v62,v65,v66" },
2174 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_or,
"v60,v62,v65,v66" },
2175 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_or_128B,
"v60,v62,v65,v66" },
2176 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_xor,
"v60,v62,v65,v66" },
2177 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_xor_128B,
"v60,v62,v65,v66" },
2178 { Hexagon::BI__builtin_HEXAGON_V6_vgth,
"v60,v62,v65,v66" },
2179 { Hexagon::BI__builtin_HEXAGON_V6_vgth_128B,
"v60,v62,v65,v66" },
2180 { Hexagon::BI__builtin_HEXAGON_V6_vgth_and,
"v60,v62,v65,v66" },
2181 { Hexagon::BI__builtin_HEXAGON_V6_vgth_and_128B,
"v60,v62,v65,v66" },
2182 { Hexagon::BI__builtin_HEXAGON_V6_vgth_or,
"v60,v62,v65,v66" },
2183 { Hexagon::BI__builtin_HEXAGON_V6_vgth_or_128B,
"v60,v62,v65,v66" },
2184 { Hexagon::BI__builtin_HEXAGON_V6_vgth_xor,
"v60,v62,v65,v66" },
2185 { Hexagon::BI__builtin_HEXAGON_V6_vgth_xor_128B,
"v60,v62,v65,v66" },
2186 { Hexagon::BI__builtin_HEXAGON_V6_vgtub,
"v60,v62,v65,v66" },
2187 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_128B,
"v60,v62,v65,v66" },
2188 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_and,
"v60,v62,v65,v66" },
2189 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_and_128B,
"v60,v62,v65,v66" },
2190 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_or,
"v60,v62,v65,v66" },
2191 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_or_128B,
"v60,v62,v65,v66" },
2192 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_xor,
"v60,v62,v65,v66" },
2193 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_xor_128B,
"v60,v62,v65,v66" },
2194 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh,
"v60,v62,v65,v66" },
2195 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_128B,
"v60,v62,v65,v66" },
2196 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_and,
"v60,v62,v65,v66" },
2197 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_and_128B,
"v60,v62,v65,v66" },
2198 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_or,
"v60,v62,v65,v66" },
2199 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_or_128B,
"v60,v62,v65,v66" },
2200 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_xor,
"v60,v62,v65,v66" },
2201 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_xor_128B,
"v60,v62,v65,v66" },
2202 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw,
"v60,v62,v65,v66" },
2203 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_128B,
"v60,v62,v65,v66" },
2204 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_and,
"v60,v62,v65,v66" },
2205 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_and_128B,
"v60,v62,v65,v66" },
2206 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_or,
"v60,v62,v65,v66" },
2207 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_or_128B,
"v60,v62,v65,v66" },
2208 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_xor,
"v60,v62,v65,v66" },
2209 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_xor_128B,
"v60,v62,v65,v66" },
2210 { Hexagon::BI__builtin_HEXAGON_V6_vgtw,
"v60,v62,v65,v66" },
2211 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_128B,
"v60,v62,v65,v66" },
2212 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_and,
"v60,v62,v65,v66" },
2213 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_and_128B,
"v60,v62,v65,v66" },
2214 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_or,
"v60,v62,v65,v66" },
2215 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_or_128B,
"v60,v62,v65,v66" },
2216 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_xor,
"v60,v62,v65,v66" },
2217 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_xor_128B,
"v60,v62,v65,v66" },
2218 { Hexagon::BI__builtin_HEXAGON_V6_vinsertwr,
"v60,v62,v65,v66" },
2219 { Hexagon::BI__builtin_HEXAGON_V6_vinsertwr_128B,
"v60,v62,v65,v66" },
2220 { Hexagon::BI__builtin_HEXAGON_V6_vlalignb,
"v60,v62,v65,v66" },
2221 { Hexagon::BI__builtin_HEXAGON_V6_vlalignb_128B,
"v60,v62,v65,v66" },
2222 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi,
"v60,v62,v65,v66" },
2223 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B,
"v60,v62,v65,v66" },
2224 { Hexagon::BI__builtin_HEXAGON_V6_vlsrb,
"v62,v65,v66" },
2225 { Hexagon::BI__builtin_HEXAGON_V6_vlsrb_128B,
"v62,v65,v66" },
2226 { Hexagon::BI__builtin_HEXAGON_V6_vlsrh,
"v60,v62,v65,v66" },
2227 { Hexagon::BI__builtin_HEXAGON_V6_vlsrh_128B,
"v60,v62,v65,v66" },
2228 { Hexagon::BI__builtin_HEXAGON_V6_vlsrhv,
"v60,v62,v65,v66" },
2229 { Hexagon::BI__builtin_HEXAGON_V6_vlsrhv_128B,
"v60,v62,v65,v66" },
2230 { Hexagon::BI__builtin_HEXAGON_V6_vlsrw,
"v60,v62,v65,v66" },
2231 { Hexagon::BI__builtin_HEXAGON_V6_vlsrw_128B,
"v60,v62,v65,v66" },
2232 { Hexagon::BI__builtin_HEXAGON_V6_vlsrwv,
"v60,v62,v65,v66" },
2233 { Hexagon::BI__builtin_HEXAGON_V6_vlsrwv_128B,
"v60,v62,v65,v66" },
2234 { Hexagon::BI__builtin_HEXAGON_V6_vlut4,
"v65,v66" },
2235 { Hexagon::BI__builtin_HEXAGON_V6_vlut4_128B,
"v65,v66" },
2236 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb,
"v60,v62,v65,v66" },
2237 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_128B,
"v60,v62,v65,v66" },
2238 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi,
"v62,v65,v66" },
2239 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi_128B,
"v62,v65,v66" },
2240 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_nm,
"v62,v65,v66" },
2241 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_nm_128B,
"v62,v65,v66" },
2242 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracc,
"v60,v62,v65,v66" },
2243 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracc_128B,
"v60,v62,v65,v66" },
2244 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci,
"v62,v65,v66" },
2245 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci_128B,
"v62,v65,v66" },
2246 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh,
"v60,v62,v65,v66" },
2247 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_128B,
"v60,v62,v65,v66" },
2248 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi,
"v62,v65,v66" },
2249 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi_128B,
"v62,v65,v66" },
2250 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_nm,
"v62,v65,v66" },
2251 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_nm_128B,
"v62,v65,v66" },
2252 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracc,
"v60,v62,v65,v66" },
2253 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracc_128B,
"v60,v62,v65,v66" },
2254 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci,
"v62,v65,v66" },
2255 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci_128B,
"v62,v65,v66" },
2256 { Hexagon::BI__builtin_HEXAGON_V6_vmaxb,
"v62,v65,v66" },
2257 { Hexagon::BI__builtin_HEXAGON_V6_vmaxb_128B,
"v62,v65,v66" },
2258 { Hexagon::BI__builtin_HEXAGON_V6_vmaxh,
"v60,v62,v65,v66" },
2259 { Hexagon::BI__builtin_HEXAGON_V6_vmaxh_128B,
"v60,v62,v65,v66" },
2260 { Hexagon::BI__builtin_HEXAGON_V6_vmaxub,
"v60,v62,v65,v66" },
2261 { Hexagon::BI__builtin_HEXAGON_V6_vmaxub_128B,
"v60,v62,v65,v66" },
2262 { Hexagon::BI__builtin_HEXAGON_V6_vmaxuh,
"v60,v62,v65,v66" },
2263 { Hexagon::BI__builtin_HEXAGON_V6_vmaxuh_128B,
"v60,v62,v65,v66" },
2264 { Hexagon::BI__builtin_HEXAGON_V6_vmaxw,
"v60,v62,v65,v66" },
2265 { Hexagon::BI__builtin_HEXAGON_V6_vmaxw_128B,
"v60,v62,v65,v66" },
2266 { Hexagon::BI__builtin_HEXAGON_V6_vminb,
"v62,v65,v66" },
2267 { Hexagon::BI__builtin_HEXAGON_V6_vminb_128B,
"v62,v65,v66" },
2268 { Hexagon::BI__builtin_HEXAGON_V6_vminh,
"v60,v62,v65,v66" },
2269 { Hexagon::BI__builtin_HEXAGON_V6_vminh_128B,
"v60,v62,v65,v66" },
2270 { Hexagon::BI__builtin_HEXAGON_V6_vminub,
"v60,v62,v65,v66" },
2271 { Hexagon::BI__builtin_HEXAGON_V6_vminub_128B,
"v60,v62,v65,v66" },
2272 { Hexagon::BI__builtin_HEXAGON_V6_vminuh,
"v60,v62,v65,v66" },
2273 { Hexagon::BI__builtin_HEXAGON_V6_vminuh_128B,
"v60,v62,v65,v66" },
2274 { Hexagon::BI__builtin_HEXAGON_V6_vminw,
"v60,v62,v65,v66" },
2275 { Hexagon::BI__builtin_HEXAGON_V6_vminw_128B,
"v60,v62,v65,v66" },
2276 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus,
"v60,v62,v65,v66" },
2277 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_128B,
"v60,v62,v65,v66" },
2278 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_acc,
"v60,v62,v65,v66" },
2279 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_acc_128B,
"v60,v62,v65,v66" },
2280 { Hexagon::BI__builtin_HEXAGON_V6_vmpabusv,
"v60,v62,v65,v66" },
2281 { Hexagon::BI__builtin_HEXAGON_V6_vmpabusv_128B,
"v60,v62,v65,v66" },
2282 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu,
"v65,v66" },
2283 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_128B,
"v65,v66" },
2284 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_acc,
"v65,v66" },
2285 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_acc_128B,
"v65,v66" },
2286 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuuv,
"v60,v62,v65,v66" },
2287 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuuv_128B,
"v60,v62,v65,v66" },
2288 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb,
"v60,v62,v65,v66" },
2289 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_128B,
"v60,v62,v65,v66" },
2290 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_acc,
"v60,v62,v65,v66" },
2291 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_acc_128B,
"v60,v62,v65,v66" },
2292 { Hexagon::BI__builtin_HEXAGON_V6_vmpahhsat,
"v65,v66" },
2293 { Hexagon::BI__builtin_HEXAGON_V6_vmpahhsat_128B,
"v65,v66" },
2294 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb,
"v62,v65,v66" },
2295 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_128B,
"v62,v65,v66" },
2296 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_acc,
"v62,v65,v66" },
2297 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_acc_128B,
"v62,v65,v66" },
2298 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhuhsat,
"v65,v66" },
2299 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhuhsat_128B,
"v65,v66" },
2300 { Hexagon::BI__builtin_HEXAGON_V6_vmpsuhuhsat,
"v65,v66" },
2301 { Hexagon::BI__builtin_HEXAGON_V6_vmpsuhuhsat_128B,
"v65,v66" },
2302 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus,
"v60,v62,v65,v66" },
2303 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_128B,
"v60,v62,v65,v66" },
2304 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_acc,
"v60,v62,v65,v66" },
2305 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_acc_128B,
"v60,v62,v65,v66" },
2306 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv,
"v60,v62,v65,v66" },
2307 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_128B,
"v60,v62,v65,v66" },
2308 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_acc,
"v60,v62,v65,v66" },
2309 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_acc_128B,
"v60,v62,v65,v66" },
2310 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv,
"v60,v62,v65,v66" },
2311 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_128B,
"v60,v62,v65,v66" },
2312 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_acc,
"v60,v62,v65,v66" },
2313 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_acc_128B,
"v60,v62,v65,v66" },
2314 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh,
"v60,v62,v65,v66" },
2315 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_128B,
"v60,v62,v65,v66" },
2316 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_64,
"v62,v65,v66" },
2317 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_64_128B,
"v62,v65,v66" },
2318 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh,
"v60,v62,v65,v66" },
2319 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_128B,
"v60,v62,v65,v66" },
2320 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_acc,
"v65,v66" },
2321 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_acc_128B,
"v65,v66" },
2322 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsat_acc,
"v60,v62,v65,v66" },
2323 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsat_acc_128B,
"v60,v62,v65,v66" },
2324 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsrs,
"v60,v62,v65,v66" },
2325 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsrs_128B,
"v60,v62,v65,v66" },
2326 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhss,
"v60,v62,v65,v66" },
2327 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhss_128B,
"v60,v62,v65,v66" },
2328 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus,
"v60,v62,v65,v66" },
2329 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_128B,
"v60,v62,v65,v66" },
2330 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_acc,
"v60,v62,v65,v66" },
2331 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_acc_128B,
"v60,v62,v65,v66" },
2332 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv,
"v60,v62,v65,v66" },
2333 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_128B,
"v60,v62,v65,v66" },
2334 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_acc,
"v60,v62,v65,v66" },
2335 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_acc_128B,
"v60,v62,v65,v66" },
2336 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhvsrs,
"v60,v62,v65,v66" },
2337 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhvsrs_128B,
"v60,v62,v65,v66" },
2338 { Hexagon::BI__builtin_HEXAGON_V6_vmpyieoh,
"v60,v62,v65,v66" },
2339 { Hexagon::BI__builtin_HEXAGON_V6_vmpyieoh_128B,
"v60,v62,v65,v66" },
2340 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewh_acc,
"v60,v62,v65,v66" },
2341 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewh_acc_128B,
"v60,v62,v65,v66" },
2342 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh,
"v60,v62,v65,v66" },
2343 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_128B,
"v60,v62,v65,v66" },
2344 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_acc,
"v60,v62,v65,v66" },
2345 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_acc_128B,
"v60,v62,v65,v66" },
2346 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih,
"v60,v62,v65,v66" },
2347 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_128B,
"v60,v62,v65,v66" },
2348 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_acc,
"v60,v62,v65,v66" },
2349 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_acc_128B,
"v60,v62,v65,v66" },
2350 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb,
"v60,v62,v65,v66" },
2351 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_128B,
"v60,v62,v65,v66" },
2352 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_acc,
"v60,v62,v65,v66" },
2353 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_acc_128B,
"v60,v62,v65,v66" },
2354 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiowh,
"v60,v62,v65,v66" },
2355 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiowh_128B,
"v60,v62,v65,v66" },
2356 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb,
"v60,v62,v65,v66" },
2357 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_128B,
"v60,v62,v65,v66" },
2358 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_acc,
"v60,v62,v65,v66" },
2359 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_acc_128B,
"v60,v62,v65,v66" },
2360 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh,
"v60,v62,v65,v66" },
2361 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_128B,
"v60,v62,v65,v66" },
2362 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_acc,
"v60,v62,v65,v66" },
2363 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_acc_128B,
"v60,v62,v65,v66" },
2364 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub,
"v62,v65,v66" },
2365 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_128B,
"v62,v65,v66" },
2366 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_acc,
"v62,v65,v66" },
2367 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_acc_128B,
"v62,v65,v66" },
2368 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh,
"v60,v62,v65,v66" },
2369 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_128B,
"v60,v62,v65,v66" },
2370 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_64_acc,
"v62,v65,v66" },
2371 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_64_acc_128B,
"v62,v65,v66" },
2372 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd,
"v60,v62,v65,v66" },
2373 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_128B,
"v60,v62,v65,v66" },
2374 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_sacc,
"v60,v62,v65,v66" },
2375 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_sacc_128B,
"v60,v62,v65,v66" },
2376 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_sacc,
"v60,v62,v65,v66" },
2377 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_sacc_128B,
"v60,v62,v65,v66" },
2378 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub,
"v60,v62,v65,v66" },
2379 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_128B,
"v60,v62,v65,v66" },
2380 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_acc,
"v60,v62,v65,v66" },
2381 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_acc_128B,
"v60,v62,v65,v66" },
2382 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv,
"v60,v62,v65,v66" },
2383 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_128B,
"v60,v62,v65,v66" },
2384 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_acc,
"v60,v62,v65,v66" },
2385 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_acc_128B,
"v60,v62,v65,v66" },
2386 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh,
"v60,v62,v65,v66" },
2387 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_128B,
"v60,v62,v65,v66" },
2388 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_acc,
"v60,v62,v65,v66" },
2389 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_acc_128B,
"v60,v62,v65,v66" },
2390 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe,
"v65,v66" },
2391 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_128B,
"v65,v66" },
2392 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_acc,
"v65,v66" },
2393 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_acc_128B,
"v65,v66" },
2394 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv,
"v60,v62,v65,v66" },
2395 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_128B,
"v60,v62,v65,v66" },
2396 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_acc,
"v60,v62,v65,v66" },
2397 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_acc_128B,
"v60,v62,v65,v66" },
2398 { Hexagon::BI__builtin_HEXAGON_V6_vmux,
"v60,v62,v65,v66" },
2399 { Hexagon::BI__builtin_HEXAGON_V6_vmux_128B,
"v60,v62,v65,v66" },
2400 { Hexagon::BI__builtin_HEXAGON_V6_vnavgb,
"v65,v66" },
2401 { Hexagon::BI__builtin_HEXAGON_V6_vnavgb_128B,
"v65,v66" },
2402 { Hexagon::BI__builtin_HEXAGON_V6_vnavgh,
"v60,v62,v65,v66" },
2403 { Hexagon::BI__builtin_HEXAGON_V6_vnavgh_128B,
"v60,v62,v65,v66" },
2404 { Hexagon::BI__builtin_HEXAGON_V6_vnavgub,
"v60,v62,v65,v66" },
2405 { Hexagon::BI__builtin_HEXAGON_V6_vnavgub_128B,
"v60,v62,v65,v66" },
2406 { Hexagon::BI__builtin_HEXAGON_V6_vnavgw,
"v60,v62,v65,v66" },
2407 { Hexagon::BI__builtin_HEXAGON_V6_vnavgw_128B,
"v60,v62,v65,v66" },
2408 { Hexagon::BI__builtin_HEXAGON_V6_vnormamth,
"v60,v62,v65,v66" },
2409 { Hexagon::BI__builtin_HEXAGON_V6_vnormamth_128B,
"v60,v62,v65,v66" },
2410 { Hexagon::BI__builtin_HEXAGON_V6_vnormamtw,
"v60,v62,v65,v66" },
2411 { Hexagon::BI__builtin_HEXAGON_V6_vnormamtw_128B,
"v60,v62,v65,v66" },
2412 { Hexagon::BI__builtin_HEXAGON_V6_vnot,
"v60,v62,v65,v66" },
2413 { Hexagon::BI__builtin_HEXAGON_V6_vnot_128B,
"v60,v62,v65,v66" },
2414 { Hexagon::BI__builtin_HEXAGON_V6_vor,
"v60,v62,v65,v66" },
2415 { Hexagon::BI__builtin_HEXAGON_V6_vor_128B,
"v60,v62,v65,v66" },
2416 { Hexagon::BI__builtin_HEXAGON_V6_vpackeb,
"v60,v62,v65,v66" },
2417 { Hexagon::BI__builtin_HEXAGON_V6_vpackeb_128B,
"v60,v62,v65,v66" },
2418 { Hexagon::BI__builtin_HEXAGON_V6_vpackeh,
"v60,v62,v65,v66" },
2419 { Hexagon::BI__builtin_HEXAGON_V6_vpackeh_128B,
"v60,v62,v65,v66" },
2420 { Hexagon::BI__builtin_HEXAGON_V6_vpackhb_sat,
"v60,v62,v65,v66" },
2421 { Hexagon::BI__builtin_HEXAGON_V6_vpackhb_sat_128B,
"v60,v62,v65,v66" },
2422 { Hexagon::BI__builtin_HEXAGON_V6_vpackhub_sat,
"v60,v62,v65,v66" },
2423 { Hexagon::BI__builtin_HEXAGON_V6_vpackhub_sat_128B,
"v60,v62,v65,v66" },
2424 { Hexagon::BI__builtin_HEXAGON_V6_vpackob,
"v60,v62,v65,v66" },
2425 { Hexagon::BI__builtin_HEXAGON_V6_vpackob_128B,
"v60,v62,v65,v66" },
2426 { Hexagon::BI__builtin_HEXAGON_V6_vpackoh,
"v60,v62,v65,v66" },
2427 { Hexagon::BI__builtin_HEXAGON_V6_vpackoh_128B,
"v60,v62,v65,v66" },
2428 { Hexagon::BI__builtin_HEXAGON_V6_vpackwh_sat,
"v60,v62,v65,v66" },
2429 { Hexagon::BI__builtin_HEXAGON_V6_vpackwh_sat_128B,
"v60,v62,v65,v66" },
2430 { Hexagon::BI__builtin_HEXAGON_V6_vpackwuh_sat,
"v60,v62,v65,v66" },
2431 { Hexagon::BI__builtin_HEXAGON_V6_vpackwuh_sat_128B,
"v60,v62,v65,v66" },
2432 { Hexagon::BI__builtin_HEXAGON_V6_vpopcounth,
"v60,v62,v65,v66" },
2433 { Hexagon::BI__builtin_HEXAGON_V6_vpopcounth_128B,
"v60,v62,v65,v66" },
2434 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqb,
"v65,v66" },
2435 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqb_128B,
"v65,v66" },
2436 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqh,
"v65,v66" },
2437 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqh_128B,
"v65,v66" },
2438 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqw,
"v65,v66" },
2439 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqw_128B,
"v65,v66" },
2440 { Hexagon::BI__builtin_HEXAGON_V6_vrdelta,
"v60,v62,v65,v66" },
2441 { Hexagon::BI__builtin_HEXAGON_V6_vrdelta_128B,
"v60,v62,v65,v66" },
2442 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt,
"v65" },
2443 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_128B,
"v65" },
2444 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_acc,
"v65" },
2445 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_acc_128B,
"v65" },
2446 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus,
"v60,v62,v65,v66" },
2447 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_128B,
"v60,v62,v65,v66" },
2448 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_acc,
"v60,v62,v65,v66" },
2449 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_acc_128B,
"v60,v62,v65,v66" },
2450 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi,
"v60,v62,v65,v66" },
2451 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B,
"v60,v62,v65,v66" },
2452 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc,
"v60,v62,v65,v66" },
2453 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B,
"v60,v62,v65,v66" },
2454 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv,
"v60,v62,v65,v66" },
2455 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_128B,
"v60,v62,v65,v66" },
2456 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_acc,
"v60,v62,v65,v66" },
2457 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_acc_128B,
"v60,v62,v65,v66" },
2458 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv,
"v60,v62,v65,v66" },
2459 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_128B,
"v60,v62,v65,v66" },
2460 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_acc,
"v60,v62,v65,v66" },
2461 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_acc_128B,
"v60,v62,v65,v66" },
2462 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub,
"v60,v62,v65,v66" },
2463 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_128B,
"v60,v62,v65,v66" },
2464 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_acc,
"v60,v62,v65,v66" },
2465 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_acc_128B,
"v60,v62,v65,v66" },
2466 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi,
"v60,v62,v65,v66" },
2467 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B,
"v60,v62,v65,v66" },
2468 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc,
"v60,v62,v65,v66" },
2469 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B,
"v60,v62,v65,v66" },
2470 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt,
"v65" },
2471 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_128B,
"v65" },
2472 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_acc,
"v65" },
2473 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,
"v65" },
2474 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv,
"v60,v62,v65,v66" },
2475 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_128B,
"v60,v62,v65,v66" },
2476 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_acc,
"v60,v62,v65,v66" },
2477 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_acc_128B,
"v60,v62,v65,v66" },
2478 { Hexagon::BI__builtin_HEXAGON_V6_vror,
"v60,v62,v65,v66" },
2479 { Hexagon::BI__builtin_HEXAGON_V6_vror_128B,
"v60,v62,v65,v66" },
2480 { Hexagon::BI__builtin_HEXAGON_V6_vrotr,
"v66" },
2481 { Hexagon::BI__builtin_HEXAGON_V6_vrotr_128B,
"v66" },
2482 { Hexagon::BI__builtin_HEXAGON_V6_vroundhb,
"v60,v62,v65,v66" },
2483 { Hexagon::BI__builtin_HEXAGON_V6_vroundhb_128B,
"v60,v62,v65,v66" },
2484 { Hexagon::BI__builtin_HEXAGON_V6_vroundhub,
"v60,v62,v65,v66" },
2485 { Hexagon::BI__builtin_HEXAGON_V6_vroundhub_128B,
"v60,v62,v65,v66" },
2486 { Hexagon::BI__builtin_HEXAGON_V6_vrounduhub,
"v62,v65,v66" },
2487 { Hexagon::BI__builtin_HEXAGON_V6_vrounduhub_128B,
"v62,v65,v66" },
2488 { Hexagon::BI__builtin_HEXAGON_V6_vrounduwuh,
"v62,v65,v66" },
2489 { Hexagon::BI__builtin_HEXAGON_V6_vrounduwuh_128B,
"v62,v65,v66" },
2490 { Hexagon::BI__builtin_HEXAGON_V6_vroundwh,
"v60,v62,v65,v66" },
2491 { Hexagon::BI__builtin_HEXAGON_V6_vroundwh_128B,
"v60,v62,v65,v66" },
2492 { Hexagon::BI__builtin_HEXAGON_V6_vroundwuh,
"v60,v62,v65,v66" },
2493 { Hexagon::BI__builtin_HEXAGON_V6_vroundwuh_128B,
"v60,v62,v65,v66" },
2494 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi,
"v60,v62,v65,v66" },
2495 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B,
"v60,v62,v65,v66" },
2496 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc,
"v60,v62,v65,v66" },
2497 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B,
"v60,v62,v65,v66" },
2498 { Hexagon::BI__builtin_HEXAGON_V6_vsatdw,
"v66" },
2499 { Hexagon::BI__builtin_HEXAGON_V6_vsatdw_128B,
"v66" },
2500 { Hexagon::BI__builtin_HEXAGON_V6_vsathub,
"v60,v62,v65,v66" },
2501 { Hexagon::BI__builtin_HEXAGON_V6_vsathub_128B,
"v60,v62,v65,v66" },
2502 { Hexagon::BI__builtin_HEXAGON_V6_vsatuwuh,
"v62,v65,v66" },
2503 { Hexagon::BI__builtin_HEXAGON_V6_vsatuwuh_128B,
"v62,v65,v66" },
2504 { Hexagon::BI__builtin_HEXAGON_V6_vsatwh,
"v60,v62,v65,v66" },
2505 { Hexagon::BI__builtin_HEXAGON_V6_vsatwh_128B,
"v60,v62,v65,v66" },
2506 { Hexagon::BI__builtin_HEXAGON_V6_vsb,
"v60,v62,v65,v66" },
2507 { Hexagon::BI__builtin_HEXAGON_V6_vsb_128B,
"v60,v62,v65,v66" },
2508 { Hexagon::BI__builtin_HEXAGON_V6_vsh,
"v60,v62,v65,v66" },
2509 { Hexagon::BI__builtin_HEXAGON_V6_vsh_128B,
"v60,v62,v65,v66" },
2510 { Hexagon::BI__builtin_HEXAGON_V6_vshufeh,
"v60,v62,v65,v66" },
2511 { Hexagon::BI__builtin_HEXAGON_V6_vshufeh_128B,
"v60,v62,v65,v66" },
2512 { Hexagon::BI__builtin_HEXAGON_V6_vshuffb,
"v60,v62,v65,v66" },
2513 { Hexagon::BI__builtin_HEXAGON_V6_vshuffb_128B,
"v60,v62,v65,v66" },
2514 { Hexagon::BI__builtin_HEXAGON_V6_vshuffeb,
"v60,v62,v65,v66" },
2515 { Hexagon::BI__builtin_HEXAGON_V6_vshuffeb_128B,
"v60,v62,v65,v66" },
2516 { Hexagon::BI__builtin_HEXAGON_V6_vshuffh,
"v60,v62,v65,v66" },
2517 { Hexagon::BI__builtin_HEXAGON_V6_vshuffh_128B,
"v60,v62,v65,v66" },
2518 { Hexagon::BI__builtin_HEXAGON_V6_vshuffob,
"v60,v62,v65,v66" },
2519 { Hexagon::BI__builtin_HEXAGON_V6_vshuffob_128B,
"v60,v62,v65,v66" },
2520 { Hexagon::BI__builtin_HEXAGON_V6_vshuffvdd,
"v60,v62,v65,v66" },
2521 { Hexagon::BI__builtin_HEXAGON_V6_vshuffvdd_128B,
"v60,v62,v65,v66" },
2522 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeb,
"v60,v62,v65,v66" },
2523 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeb_128B,
"v60,v62,v65,v66" },
2524 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeh,
"v60,v62,v65,v66" },
2525 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeh_128B,
"v60,v62,v65,v66" },
2526 { Hexagon::BI__builtin_HEXAGON_V6_vshufoh,
"v60,v62,v65,v66" },
2527 { Hexagon::BI__builtin_HEXAGON_V6_vshufoh_128B,
"v60,v62,v65,v66" },
2528 { Hexagon::BI__builtin_HEXAGON_V6_vsubb,
"v60,v62,v65,v66" },
2529 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_128B,
"v60,v62,v65,v66" },
2530 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_dv,
"v60,v62,v65,v66" },
2531 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_dv_128B,
"v60,v62,v65,v66" },
2532 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat,
"v62,v65,v66" },
2533 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_128B,
"v62,v65,v66" },
2534 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_dv,
"v62,v65,v66" },
2535 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_dv_128B,
"v62,v65,v66" },
2536 { Hexagon::BI__builtin_HEXAGON_V6_vsubcarry,
"v62,v65,v66" },
2537 { Hexagon::BI__builtin_HEXAGON_V6_vsubcarry_128B,
"v62,v65,v66" },
2538 { Hexagon::BI__builtin_HEXAGON_V6_vsubh,
"v60,v62,v65,v66" },
2539 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_128B,
"v60,v62,v65,v66" },
2540 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_dv,
"v60,v62,v65,v66" },
2541 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_dv_128B,
"v60,v62,v65,v66" },
2542 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat,
"v60,v62,v65,v66" },
2543 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_128B,
"v60,v62,v65,v66" },
2544 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_dv,
"v60,v62,v65,v66" },
2545 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_dv_128B,
"v60,v62,v65,v66" },
2546 { Hexagon::BI__builtin_HEXAGON_V6_vsubhw,
"v60,v62,v65,v66" },
2547 { Hexagon::BI__builtin_HEXAGON_V6_vsubhw_128B,
"v60,v62,v65,v66" },
2548 { Hexagon::BI__builtin_HEXAGON_V6_vsububh,
"v60,v62,v65,v66" },
2549 { Hexagon::BI__builtin_HEXAGON_V6_vsububh_128B,
"v60,v62,v65,v66" },
2550 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat,
"v60,v62,v65,v66" },
2551 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_128B,
"v60,v62,v65,v66" },
2552 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_dv,
"v60,v62,v65,v66" },
2553 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_dv_128B,
"v60,v62,v65,v66" },
2554 { Hexagon::BI__builtin_HEXAGON_V6_vsubububb_sat,
"v62,v65,v66" },
2555 { Hexagon::BI__builtin_HEXAGON_V6_vsubububb_sat_128B,
"v62,v65,v66" },
2556 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat,
"v60,v62,v65,v66" },
2557 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_128B,
"v60,v62,v65,v66" },
2558 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_dv,
"v60,v62,v65,v66" },
2559 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_dv_128B,
"v60,v62,v65,v66" },
2560 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhw,
"v60,v62,v65,v66" },
2561 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhw_128B,
"v60,v62,v65,v66" },
2562 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat,
"v62,v65,v66" },
2563 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_128B,
"v62,v65,v66" },
2564 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_dv,
"v62,v65,v66" },
2565 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_dv_128B,
"v62,v65,v66" },
2566 { Hexagon::BI__builtin_HEXAGON_V6_vsubw,
"v60,v62,v65,v66" },
2567 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_128B,
"v60,v62,v65,v66" },
2568 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_dv,
"v60,v62,v65,v66" },
2569 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_dv_128B,
"v60,v62,v65,v66" },
2570 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat,
"v60,v62,v65,v66" },
2571 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_128B,
"v60,v62,v65,v66" },
2572 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_dv,
"v60,v62,v65,v66" },
2573 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_dv_128B,
"v60,v62,v65,v66" },
2574 { Hexagon::BI__builtin_HEXAGON_V6_vswap,
"v60,v62,v65,v66" },
2575 { Hexagon::BI__builtin_HEXAGON_V6_vswap_128B,
"v60,v62,v65,v66" },
2576 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb,
"v60,v62,v65,v66" },
2577 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_128B,
"v60,v62,v65,v66" },
2578 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_acc,
"v60,v62,v65,v66" },
2579 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_acc_128B,
"v60,v62,v65,v66" },
2580 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus,
"v60,v62,v65,v66" },
2581 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_128B,
"v60,v62,v65,v66" },
2582 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_acc,
"v60,v62,v65,v66" },
2583 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_acc_128B,
"v60,v62,v65,v66" },
2584 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb,
"v60,v62,v65,v66" },
2585 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_128B,
"v60,v62,v65,v66" },
2586 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_acc,
"v60,v62,v65,v66" },
2587 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_acc_128B,
"v60,v62,v65,v66" },
2588 { Hexagon::BI__builtin_HEXAGON_V6_vunpackb,
"v60,v62,v65,v66" },
2589 { Hexagon::BI__builtin_HEXAGON_V6_vunpackb_128B,
"v60,v62,v65,v66" },
2590 { Hexagon::BI__builtin_HEXAGON_V6_vunpackh,
"v60,v62,v65,v66" },
2591 { Hexagon::BI__builtin_HEXAGON_V6_vunpackh_128B,
"v60,v62,v65,v66" },
2592 { Hexagon::BI__builtin_HEXAGON_V6_vunpackob,
"v60,v62,v65,v66" },
2593 { Hexagon::BI__builtin_HEXAGON_V6_vunpackob_128B,
"v60,v62,v65,v66" },
2594 { Hexagon::BI__builtin_HEXAGON_V6_vunpackoh,
"v60,v62,v65,v66" },
2595 { Hexagon::BI__builtin_HEXAGON_V6_vunpackoh_128B,
"v60,v62,v65,v66" },
2596 { Hexagon::BI__builtin_HEXAGON_V6_vunpackub,
"v60,v62,v65,v66" },
2597 { Hexagon::BI__builtin_HEXAGON_V6_vunpackub_128B,
"v60,v62,v65,v66" },
2598 { Hexagon::BI__builtin_HEXAGON_V6_vunpackuh,
"v60,v62,v65,v66" },
2599 { Hexagon::BI__builtin_HEXAGON_V6_vunpackuh_128B,
"v60,v62,v65,v66" },
2600 { Hexagon::BI__builtin_HEXAGON_V6_vxor,
"v60,v62,v65,v66" },
2601 { Hexagon::BI__builtin_HEXAGON_V6_vxor_128B,
"v60,v62,v65,v66" },
2602 { Hexagon::BI__builtin_HEXAGON_V6_vzb,
"v60,v62,v65,v66" },
2603 { Hexagon::BI__builtin_HEXAGON_V6_vzb_128B,
"v60,v62,v65,v66" },
2604 { Hexagon::BI__builtin_HEXAGON_V6_vzh,
"v60,v62,v65,v66" },
2605 { Hexagon::BI__builtin_HEXAGON_V6_vzh_128B,
"v60,v62,v65,v66" },
2609 auto SortCmp = [](
const BuiltinAndString &LHS,
const BuiltinAndString &RHS) {
2610 return LHS.BuiltinID < RHS.BuiltinID;
2612 static const bool SortOnce =
2613 (llvm::sort(ValidCPU, SortCmp),
2614 llvm::sort(ValidHVX, SortCmp),
true);
2616 auto LowerBoundCmp = [](
const BuiltinAndString &BI,
unsigned BuiltinID) {
2617 return BI.BuiltinID < BuiltinID;
2622 const BuiltinAndString *FC =
2623 std::lower_bound(std::begin(ValidCPU), std::end(ValidCPU), BuiltinID,
2625 if (FC != std::end(ValidCPU) && FC->BuiltinID == BuiltinID) {
2627 StringRef CPU = Opts.
CPU;
2629 assert(CPU.startswith(
"hexagon") &&
"Unexpected CPU name");
2630 CPU.consume_front(
"hexagon");
2632 StringRef(FC->Str).split(CPUs,
',');
2633 if (llvm::none_of(CPUs, [CPU](StringRef S) {
return S == CPU; }))
2635 diag::err_hexagon_builtin_unsupported_cpu);
2639 const BuiltinAndString *FH =
2640 std::lower_bound(std::begin(ValidHVX), std::end(ValidHVX), BuiltinID,
2642 if (FH != std::end(ValidHVX) && FH->BuiltinID == BuiltinID) {
2645 diag::err_hexagon_builtin_requires_hvx);
2648 StringRef(FH->Str).split(HVXs,
',');
2649 bool IsValid = llvm::any_of(HVXs,
2650 [&TI] (StringRef V) {
2651 std::string F =
"hvx" + V.str();
2656 diag::err_hexagon_builtin_unsupported_hvx);
2662 bool Sema::CheckHexagonBuiltinArgument(
unsigned BuiltinID,
CallExpr *TheCall) {
2675 { Hexagon::BI__builtin_circ_ldd, {{ 3,
true, 4, 3 }} },
2676 { Hexagon::BI__builtin_circ_ldw, {{ 3,
true, 4, 2 }} },
2677 { Hexagon::BI__builtin_circ_ldh, {{ 3,
true, 4, 1 }} },
2678 { Hexagon::BI__builtin_circ_lduh, {{ 3,
true, 4, 0 }} },
2679 { Hexagon::BI__builtin_circ_ldb, {{ 3,
true, 4, 0 }} },
2680 { Hexagon::BI__builtin_circ_ldub, {{ 3,
true, 4, 0 }} },
2681 { Hexagon::BI__builtin_circ_std, {{ 3,
true, 4, 3 }} },
2682 { Hexagon::BI__builtin_circ_stw, {{ 3,
true, 4, 2 }} },
2683 { Hexagon::BI__builtin_circ_sth, {{ 3,
true, 4, 1 }} },
2684 { Hexagon::BI__builtin_circ_sthhi, {{ 3,
true, 4, 1 }} },
2685 { Hexagon::BI__builtin_circ_stb, {{ 3,
true, 4, 0 }} },
2687 { Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{ 1,
true, 4, 0 }} },
2688 { Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{ 1,
true, 4, 0 }} },
2689 { Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{ 1,
true, 4, 1 }} },
2690 { Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{ 1,
true, 4, 1 }} },
2691 { Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{ 1,
true, 4, 2 }} },
2692 { Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{ 1,
true, 4, 3 }} },
2693 { Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{ 1,
true, 4, 0 }} },
2694 { Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{ 1,
true, 4, 1 }} },
2695 { Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{ 1,
true, 4, 1 }} },
2696 { Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{ 1,
true, 4, 2 }} },
2697 { Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{ 1,
true, 4, 3 }} },
2699 { Hexagon::BI__builtin_HEXAGON_A2_combineii, {{ 1,
true, 8, 0 }} },
2700 { Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{ 1,
false, 16, 0 }} },
2701 { Hexagon::BI__builtin_HEXAGON_A2_tfril, {{ 1,
false, 16, 0 }} },
2702 { Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{ 0,
true, 8, 0 }} },
2703 { Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{ 1,
false, 5, 0 }} },
2704 { Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{ 1,
false, 8, 0 }} },
2705 { Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{ 1,
true, 8, 0 }} },
2706 { Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{ 1,
false, 5, 0 }} },
2707 { Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{ 1,
false, 5, 0 }} },
2708 { Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{ 1,
false, 5, 0 }} },
2709 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{ 1,
false, 8, 0 }} },
2710 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{ 1,
true, 8, 0 }} },
2711 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{ 1,
false, 7, 0 }} },
2712 { Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{ 1,
true, 8, 0 }} },
2713 { Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{ 1,
true, 8, 0 }} },
2714 { Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{ 1,
false, 7, 0 }} },
2715 { Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{ 1,
true, 8, 0 }} },
2716 { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{ 1,
true, 8, 0 }} },
2717 { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{ 1,
false, 7, 0 }} },
2718 { Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{ 1,
false, 6, 0 }} },
2719 { Hexagon::BI__builtin_HEXAGON_C2_muxii, {{ 2,
true, 8, 0 }} },
2720 { Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{ 1,
false, 6, 0 }} },
2721 { Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{ 1,
false, 5, 0 }} },
2722 { Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{ 0,
false, 10, 0 }} },
2723 { Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{ 0,
false, 10, 0 }} },
2724 { Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{ 1,
false, 5, 0 }} },
2725 { Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{ 0,
false, 10, 0 }} },
2726 { Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{ 0,
false, 10, 0 }} },
2727 { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{ 2,
false, 6, 0 }} },
2728 { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{ 1,
false, 6, 2 }} },
2729 { Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{ 2,
false, 3, 0 }} },
2730 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{ 2,
false, 6, 0 }} },
2731 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{ 2,
false, 6, 0 }} },
2732 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{ 1,
false, 6, 0 }} },
2733 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{ 2,
false, 6, 0 }} },
2734 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{ 2,
false, 6, 0 }} },
2735 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{ 2,
false, 6, 0 }} },
2736 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{ 2,
false, 5, 0 }} },
2737 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{ 2,
false, 5, 0 }} },
2738 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{ 1,
false, 5, 0 }} },
2739 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{ 2,
false, 5, 0 }} },
2740 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{ 2,
false, 5, 0 }} },
2741 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{ 1,
false, 5, 0 }} },
2742 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{ 2,
false, 5, 0 }} },
2743 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{ 1,
false, 4, 0 }} },
2744 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{ 1,
false, 5, 0 }} },
2745 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{ 2,
false, 6, 0 }} },
2746 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{ 2,
false, 6, 0 }} },
2747 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{ 1,
false, 6, 0 }} },
2748 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{ 2,
false, 6, 0 }} },
2749 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{ 2,
false, 6, 0 }} },
2750 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax,
2751 {{ 1,
false, 6, 0 }} },
2752 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{ 1,
false, 6, 0 }} },
2753 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{ 2,
false, 5, 0 }} },
2754 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{ 2,
false, 5, 0 }} },
2755 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{ 1,
false, 5, 0 }} },
2756 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{ 2,
false, 5, 0 }} },
2757 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{ 2,
false, 5, 0 }} },
2758 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax,
2759 {{ 1,
false, 5, 0 }} },
2760 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{ 1,
false, 5, 0 }} },
2761 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{ 1,
false, 5, 0 }} },
2762 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{ 1,
false, 4, 0 }} },
2763 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{ 1,
false, 5, 0 }} },
2764 { Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{ 1,
false, 5, 0 }} },
2765 { Hexagon::BI__builtin_HEXAGON_S2_extractu, {{ 1,
false, 5, 0 },
2766 { 2,
false, 5, 0 }} },
2767 { Hexagon::BI__builtin_HEXAGON_S2_extractup, {{ 1,
false, 6, 0 },
2768 { 2,
false, 6, 0 }} },
2769 { Hexagon::BI__builtin_HEXAGON_S2_insert, {{ 2,
false, 5, 0 },
2770 { 3,
false, 5, 0 }} },
2771 { Hexagon::BI__builtin_HEXAGON_S2_insertp, {{ 2,
false, 6, 0 },
2772 { 3,
false, 6, 0 }} },
2773 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{ 2,
false, 6, 0 }} },
2774 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{ 2,
false, 6, 0 }} },
2775 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{ 1,
false, 6, 0 }} },
2776 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{ 2,
false, 6, 0 }} },
2777 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{ 2,
false, 6, 0 }} },
2778 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{ 2,
false, 6, 0 }} },
2779 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{ 2,
false, 5, 0 }} },
2780 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{ 2,
false, 5, 0 }} },
2781 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{ 1,
false, 5, 0 }} },
2782 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{ 2,
false, 5, 0 }} },
2783 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{ 2,
false, 5, 0 }} },
2784 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{ 2,
false, 5, 0 }} },
2785 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{ 1,
false, 4, 0 }} },
2786 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{ 1,
false, 5, 0 }} },
2787 { Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{ 1,
false, 5, 0 }} },
2788 { Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax,
2789 {{ 2,
false, 4, 0 },
2790 { 3,
false, 5, 0 }} },
2791 { Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax,
2792 {{ 2,
false, 4, 0 },
2793 { 3,
false, 5, 0 }} },
2794 { Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax,
2795 {{ 2,
false, 4, 0 },
2796 { 3,
false, 5, 0 }} },
2797 { Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax,
2798 {{ 2,
false, 4, 0 },
2799 { 3,
false, 5, 0 }} },
2800 { Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{ 1,
false, 5, 0 }} },
2801 { Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{ 1,
false, 5, 0 }} },
2802 { Hexagon::BI__builtin_HEXAGON_S2_valignib, {{ 2,
false, 3, 0 }} },
2803 { Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{ 2,
false, 3, 0 }} },
2804 { Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{ 2,
false, 5, 0 }} },
2805 { Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{ 2,
false, 5, 0 }} },
2806 { Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{ 2,
false, 5, 0 }} },
2807 { Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{ 2,
false, 5, 0 }} },
2808 { Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{ 1,
true , 6, 0 }} },
2809 { Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{ 1,
true, 6, 0 }} },
2810 { Hexagon::BI__builtin_HEXAGON_S4_extract, {{ 1,
false, 5, 0 },
2811 { 2,
false, 5, 0 }} },
2812 { Hexagon::BI__builtin_HEXAGON_S4_extractp, {{ 1,
false, 6, 0 },
2813 { 2,
false, 6, 0 }} },
2814 { Hexagon::BI__builtin_HEXAGON_S4_lsli, {{ 0,
true, 6, 0 }} },
2815 { Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{ 1,
false, 5, 0 }} },
2816 { Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{ 2,
false, 5, 0 }} },
2817 { Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{ 2,
false, 5, 0 }} },
2818 { Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{ 2,
false, 5, 0 }} },
2819 { Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{ 2,
false, 5, 0 }} },
2820 { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{ 3,
false, 2, 0 }} },
2821 { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{ 2,
false, 2, 0 }} },
2822 { Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax,
2823 {{ 1,
false, 4, 0 }} },
2824 { Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{ 1,
false, 4, 0 }} },
2825 { Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax,
2826 {{ 1,
false, 4, 0 }} },
2827 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{ 1,
false, 6, 0 }} },
2828 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{ 2,
false, 6, 0 }} },
2829 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{ 2,
false, 6, 0 }} },
2830 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{ 2,
false, 6, 0 }} },
2831 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{ 2,
false, 6, 0 }} },
2832 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{ 2,
false, 6, 0 }} },
2833 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{ 1,
false, 5, 0 }} },
2834 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{ 2,
false, 5, 0 }} },
2835 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{ 2,
false, 5, 0 }} },
2836 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{ 2,
false, 5, 0 }} },
2837 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{ 2,
false, 5, 0 }} },
2838 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{ 2,
false, 5, 0 }} },
2839 { Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{ 2,
false, 3, 0 }} },
2840 { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{ 2,
false, 3, 0 }} },
2841 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{ 2,
false, 3, 0 }} },
2842 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{ 2,
false, 3, 0 }} },
2843 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{ 2,
false, 1, 0 }} },
2844 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{ 2,
false, 1, 0 }} },
2845 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{ 3,
false, 1, 0 }} },
2846 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B,
2847 {{ 3,
false, 1, 0 }} },
2848 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{ 2,
false, 1, 0 }} },
2849 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{ 2,
false, 1, 0 }} },
2850 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{ 3,
false, 1, 0 }} },
2851 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B,
2852 {{ 3,
false, 1, 0 }} },
2853 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{ 2,
false, 1, 0 }} },
2854 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{ 2,
false, 1, 0 }} },
2855 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{ 3,
false, 1, 0 }} },
2856 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B,
2857 {{ 3,
false, 1, 0 }} },
2862 static const bool SortOnce =
2865 return LHS.BuiltinID < RHS.BuiltinID;
2871 std::lower_bound(std::begin(Infos), std::end(Infos), BuiltinID,
2873 return BI.BuiltinID < BuiltinID;
2875 if (F == std::end(Infos) || F->BuiltinID != BuiltinID)
2880 for (
const ArgInfo &A : F->Infos) {
2882 if (A.BitWidth == 0)
2885 int32_t Min = A.IsSigned ? -(1 << (A.BitWidth - 1)) : 0;
2886 int32_t Max = (1 << (A.IsSigned ? A.BitWidth - 1 : A.BitWidth)) - 1;
2888 Error |= SemaBuiltinConstantArgRange(TheCall, A.OpNum, Min, Max);
2890 unsigned M = 1 << A.Align;
2893 Error |= SemaBuiltinConstantArgRange(TheCall, A.OpNum, Min, Max) |
2894 SemaBuiltinConstantArgMultiple(TheCall, A.OpNum, M);
2900 bool Sema::CheckHexagonBuiltinFunctionCall(
unsigned BuiltinID,
2902 return CheckHexagonBuiltinCpu(BuiltinID, TheCall) ||
2903 CheckHexagonBuiltinArgument(BuiltinID, TheCall);
2916 bool Sema::CheckMipsBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
2917 unsigned i = 0, l = 0, u = 0, m = 0;
2918 switch (BuiltinID) {
2919 default:
return false;
2920 case Mips::BI__builtin_mips_wrdsp: i = 1; l = 0; u = 63;
break;
2921 case Mips::BI__builtin_mips_rddsp: i = 0; l = 0; u = 63;
break;
2922 case Mips::BI__builtin_mips_append: i = 2; l = 0; u = 31;
break;
2923 case Mips::BI__builtin_mips_balign: i = 2; l = 0; u = 3;
break;
2924 case Mips::BI__builtin_mips_precr_sra_ph_w: i = 2; l = 0; u = 31;
break;
2925 case Mips::BI__builtin_mips_precr_sra_r_ph_w: i = 2; l = 0; u = 31;
break;
2926 case Mips::BI__builtin_mips_prepend: i = 2; l = 0; u = 31;
break;
2930 case Mips::BI__builtin_msa_bclri_b:
2931 case Mips::BI__builtin_msa_bnegi_b:
2932 case Mips::BI__builtin_msa_bseti_b:
2933 case Mips::BI__builtin_msa_sat_s_b:
2934 case Mips::BI__builtin_msa_sat_u_b:
2935 case Mips::BI__builtin_msa_slli_b:
2936 case Mips::BI__builtin_msa_srai_b:
2937 case Mips::BI__builtin_msa_srari_b:
2938 case Mips::BI__builtin_msa_srli_b:
2939 case Mips::BI__builtin_msa_srlri_b: i = 1; l = 0; u = 7;
break;
2940 case Mips::BI__builtin_msa_binsli_b:
2941 case Mips::BI__builtin_msa_binsri_b: i = 2; l = 0; u = 7;
break;
2943 case Mips::BI__builtin_msa_bclri_h:
2944 case Mips::BI__builtin_msa_bnegi_h:
2945 case Mips::BI__builtin_msa_bseti_h:
2946 case Mips::BI__builtin_msa_sat_s_h:
2947 case Mips::BI__builtin_msa_sat_u_h:
2948 case Mips::BI__builtin_msa_slli_h:
2949 case Mips::BI__builtin_msa_srai_h:
2950 case Mips::BI__builtin_msa_srari_h:
2951 case Mips::BI__builtin_msa_srli_h:
2952 case Mips::BI__builtin_msa_srlri_h: i = 1; l = 0; u = 15;
break;
2953 case Mips::BI__builtin_msa_binsli_h:
2954 case Mips::BI__builtin_msa_binsri_h: i = 2; l = 0; u = 15;
break;
2958 case Mips::BI__builtin_msa_clei_u_b:
2959 case Mips::BI__builtin_msa_clei_u_h:
2960 case Mips::BI__builtin_msa_clei_u_w:
2961 case Mips::BI__builtin_msa_clei_u_d:
2962 case Mips::BI__builtin_msa_clti_u_b:
2963 case Mips::BI__builtin_msa_clti_u_h:
2964 case Mips::BI__builtin_msa_clti_u_w:
2965 case Mips::BI__builtin_msa_clti_u_d:
2966 case Mips::BI__builtin_msa_maxi_u_b:
2967 case Mips::BI__builtin_msa_maxi_u_h:
2968 case Mips::BI__builtin_msa_maxi_u_w:
2969 case Mips::BI__builtin_msa_maxi_u_d:
2970 case Mips::BI__builtin_msa_mini_u_b:
2971 case Mips::BI__builtin_msa_mini_u_h:
2972 case Mips::BI__builtin_msa_mini_u_w:
2973 case Mips::BI__builtin_msa_mini_u_d:
2974 case Mips::BI__builtin_msa_addvi_b:
2975 case Mips::BI__builtin_msa_addvi_h:
2976 case Mips::BI__builtin_msa_addvi_w:
2977 case Mips::BI__builtin_msa_addvi_d:
2978 case Mips::BI__builtin_msa_bclri_w:
2979 case Mips::BI__builtin_msa_bnegi_w:
2980 case Mips::BI__builtin_msa_bseti_w:
2981 case Mips::BI__builtin_msa_sat_s_w:
2982 case Mips::BI__builtin_msa_sat_u_w:
2983 case Mips::BI__builtin_msa_slli_w:
2984 case Mips::BI__builtin_msa_srai_w:
2985 case Mips::BI__builtin_msa_srari_w:
2986 case Mips::BI__builtin_msa_srli_w:
2987 case Mips::BI__builtin_msa_srlri_w:
2988 case Mips::BI__builtin_msa_subvi_b:
2989 case Mips::BI__builtin_msa_subvi_h:
2990 case Mips::BI__builtin_msa_subvi_w:
2991 case Mips::BI__builtin_msa_subvi_d: i = 1; l = 0; u = 31;
break;
2992 case Mips::BI__builtin_msa_binsli_w:
2993 case Mips::BI__builtin_msa_binsri_w: i = 2; l = 0; u = 31;
break;
2995 case Mips::BI__builtin_msa_bclri_d:
2996 case Mips::BI__builtin_msa_bnegi_d:
2997 case Mips::BI__builtin_msa_bseti_d:
2998 case Mips::BI__builtin_msa_sat_s_d:
2999 case Mips::BI__builtin_msa_sat_u_d:
3000 case Mips::BI__builtin_msa_slli_d:
3001 case Mips::BI__builtin_msa_srai_d:
3002 case Mips::BI__builtin_msa_srari_d:
3003 case Mips::BI__builtin_msa_srli_d:
3004 case Mips::BI__builtin_msa_srlri_d: i = 1; l = 0; u = 63;
break;
3005 case Mips::BI__builtin_msa_binsli_d:
3006 case Mips::BI__builtin_msa_binsri_d: i = 2; l = 0; u = 63;
break;
3008 case Mips::BI__builtin_msa_ceqi_b:
3009 case Mips::BI__builtin_msa_ceqi_h:
3010 case Mips::BI__builtin_msa_ceqi_w:
3011 case Mips::BI__builtin_msa_ceqi_d:
3012 case Mips::BI__builtin_msa_clti_s_b:
3013 case Mips::BI__builtin_msa_clti_s_h:
3014 case Mips::BI__builtin_msa_clti_s_w:
3015 case Mips::BI__builtin_msa_clti_s_d:
3016 case Mips::BI__builtin_msa_clei_s_b:
3017 case Mips::BI__builtin_msa_clei_s_h:
3018 case Mips::BI__builtin_msa_clei_s_w:
3019 case Mips::BI__builtin_msa_clei_s_d:
3020 case Mips::BI__builtin_msa_maxi_s_b:
3021 case Mips::BI__builtin_msa_maxi_s_h:
3022 case Mips::BI__builtin_msa_maxi_s_w:
3023 case Mips::BI__builtin_msa_maxi_s_d:
3024 case Mips::BI__builtin_msa_mini_s_b:
3025 case Mips::BI__builtin_msa_mini_s_h:
3026 case Mips::BI__builtin_msa_mini_s_w:
3027 case Mips::BI__builtin_msa_mini_s_d: i = 1; l = -16; u = 15;
break;
3029 case Mips::BI__builtin_msa_andi_b:
3030 case Mips::BI__builtin_msa_nori_b:
3031 case Mips::BI__builtin_msa_ori_b:
3032 case Mips::BI__builtin_msa_shf_b:
3033 case Mips::BI__builtin_msa_shf_h:
3034 case Mips::BI__builtin_msa_shf_w:
3035 case Mips::BI__builtin_msa_xori_b: i = 1; l = 0; u = 255;
break;
3036 case Mips::BI__builtin_msa_bseli_b:
3037 case Mips::BI__builtin_msa_bmnzi_b:
3038 case Mips::BI__builtin_msa_bmzi_b: i = 2; l = 0; u = 255;
break;
3041 case Mips::BI__builtin_msa_copy_s_b:
3042 case Mips::BI__builtin_msa_copy_u_b:
3043 case Mips::BI__builtin_msa_insve_b:
3044 case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15;
break;
3045 case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15;
break;
3047 case Mips::BI__builtin_msa_copy_s_h:
3048 case Mips::BI__builtin_msa_copy_u_h:
3049 case Mips::BI__builtin_msa_insve_h:
3050 case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7;
break;
3051 case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7;
break;
3053 case Mips::BI__builtin_msa_copy_s_w:
3054 case Mips::BI__builtin_msa_copy_u_w:
3055 case Mips::BI__builtin_msa_insve_w:
3056 case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3;
break;
3057 case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3;
break;
3059 case Mips::BI__builtin_msa_copy_s_d:
3060 case Mips::BI__builtin_msa_copy_u_d:
3061 case Mips::BI__builtin_msa_insve_d:
3062 case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1;
break;
3063 case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1;
break;
3066 case Mips::BI__builtin_msa_ldi_b: i = 0; l = -128; u = 255;
break;
3067 case Mips::BI__builtin_msa_ldi_h:
3068 case Mips::BI__builtin_msa_ldi_w:
3069 case Mips::BI__builtin_msa_ldi_d: i = 0; l = -512; u = 511;
break;
3070 case Mips::BI__builtin_msa_ld_b: i = 1; l = -512; u = 511; m = 1;
break;
3071 case Mips::BI__builtin_msa_ld_h: i = 1; l = -1024; u = 1022; m = 2;
break;
3072 case Mips::BI__builtin_msa_ld_w: i = 1; l = -2048; u = 2044; m = 4;
break;
3073 case Mips::BI__builtin_msa_ld_d: i = 1; l = -4096; u = 4088; m = 8;
break;
3074 case Mips::BI__builtin_msa_st_b: i = 2; l = -512; u = 511; m = 1;
break;
3075 case Mips::BI__builtin_msa_st_h: i = 2; l = -1024; u = 1022; m = 2;
break;
3076 case Mips::BI__builtin_msa_st_w: i = 2; l = -2048; u = 2044; m = 4;
break;
3077 case Mips::BI__builtin_msa_st_d: i = 2; l = -4096; u = 4088; m = 8;
break;
3081 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3083 return SemaBuiltinConstantArgRange(TheCall, i, l, u) ||
3084 SemaBuiltinConstantArgMultiple(TheCall, i, m);
3087 bool Sema::CheckPPCBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
3088 unsigned i = 0, l = 0, u = 0;
3089 bool Is64BitBltin = BuiltinID == PPC::BI__builtin_divde ||
3090 BuiltinID == PPC::BI__builtin_divdeu ||
3091 BuiltinID == PPC::BI__builtin_bpermd;
3095 .getIntPtrType()) == 64;
3096 bool IsBltinExtDiv = BuiltinID == PPC::BI__builtin_divwe ||
3097 BuiltinID == PPC::BI__builtin_divweu ||
3098 BuiltinID == PPC::BI__builtin_divde ||
3099 BuiltinID == PPC::BI__builtin_divdeu;
3101 if (Is64BitBltin && !IsTarget64Bit)
3102 return Diag(TheCall->
getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
3106 (BuiltinID == PPC::BI__builtin_bpermd &&
3108 return Diag(TheCall->
getBeginLoc(), diag::err_ppc_builtin_only_on_pwr7)
3111 auto SemaVSXCheck = [&](
CallExpr *TheCall) ->
bool {
3113 return Diag(TheCall->
getBeginLoc(), diag::err_ppc_builtin_only_on_pwr7)
3118 switch (BuiltinID) {
3119 default:
return false;
3120 case PPC::BI__builtin_altivec_crypto_vshasigmaw:
3121 case PPC::BI__builtin_altivec_crypto_vshasigmad:
3122 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
3123 SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
3124 case PPC::BI__builtin_tbegin:
3125 case PPC::BI__builtin_tend: i = 0; l = 0; u = 1;
break;
3126 case PPC::BI__builtin_tsr: i = 0; l = 0; u = 7;
break;
3127 case PPC::BI__builtin_tabortwc:
3128 case PPC::BI__builtin_tabortdc: i = 0; l = 0; u = 31;
break;
3129 case PPC::BI__builtin_tabortwci:
3130 case PPC::BI__builtin_tabortdci:
3131 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
3132 SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
3133 case PPC::BI__builtin_vsx_xxpermdi:
3134 case PPC::BI__builtin_vsx_xxsldwi:
3135 return SemaBuiltinVSX(TheCall);
3136 case PPC::BI__builtin_unpack_vector_int128:
3137 return SemaVSXCheck(TheCall) ||
3138 SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
3139 case PPC::BI__builtin_pack_vector_int128:
3140 return SemaVSXCheck(TheCall);
3142 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3145 bool Sema::CheckSystemZBuiltinFunctionCall(
unsigned BuiltinID,
3147 if (BuiltinID == SystemZ::BI__builtin_tabort) {
3149 llvm::APSInt AbortCode(32);
3151 AbortCode.getSExtValue() >= 0 && AbortCode.getSExtValue() < 256)
3152 return Diag(Arg->
getBeginLoc(), diag::err_systemz_invalid_tabort_code)
3158 unsigned i = 0, l = 0, u = 0;
3159 switch (BuiltinID) {
3160 default:
return false;
3161 case SystemZ::BI__builtin_s390_lcbb: i = 1; l = 0; u = 15;
break;
3162 case SystemZ::BI__builtin_s390_verimb:
3163 case SystemZ::BI__builtin_s390_verimh:
3164 case SystemZ::BI__builtin_s390_verimf:
3165 case SystemZ::BI__builtin_s390_verimg: i = 3; l = 0; u = 255;
break;
3166 case SystemZ::BI__builtin_s390_vfaeb:
3167 case SystemZ::BI__builtin_s390_vfaeh:
3168 case SystemZ::BI__builtin_s390_vfaef:
3169 case SystemZ::BI__builtin_s390_vfaebs:
3170 case SystemZ::BI__builtin_s390_vfaehs:
3171 case SystemZ::BI__builtin_s390_vfaefs:
3172 case SystemZ::BI__builtin_s390_vfaezb:
3173 case SystemZ::BI__builtin_s390_vfaezh:
3174 case SystemZ::BI__builtin_s390_vfaezf:
3175 case SystemZ::BI__builtin_s390_vfaezbs:
3176 case SystemZ::BI__builtin_s390_vfaezhs:
3177 case SystemZ::BI__builtin_s390_vfaezfs: i = 2; l = 0; u = 15;
break;
3178 case SystemZ::BI__builtin_s390_vfisb:
3179 case SystemZ::BI__builtin_s390_vfidb:
3180 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15) ||
3181 SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
3182 case SystemZ::BI__builtin_s390_vftcisb:
3183 case SystemZ::BI__builtin_s390_vftcidb: i = 1; l = 0; u = 4095;
break;
3184 case SystemZ::BI__builtin_s390_vlbb: i = 1; l = 0; u = 15;
break;
3185 case SystemZ::BI__builtin_s390_vpdi: i = 2; l = 0; u = 15;
break;
3186 case SystemZ::BI__builtin_s390_vsldb: i = 2; l = 0; u = 15;
break;
3187 case SystemZ::BI__builtin_s390_vstrcb:
3188 case SystemZ::BI__builtin_s390_vstrch:
3189 case SystemZ::BI__builtin_s390_vstrcf:
3190 case SystemZ::BI__builtin_s390_vstrczb:
3191 case SystemZ::BI__builtin_s390_vstrczh:
3192 case SystemZ::BI__builtin_s390_vstrczf:
3193 case SystemZ::BI__builtin_s390_vstrcbs:
3194 case SystemZ::BI__builtin_s390_vstrchs:
3195 case SystemZ::BI__builtin_s390_vstrcfs:
3196 case SystemZ::BI__builtin_s390_vstrczbs:
3197 case SystemZ::BI__builtin_s390_vstrczhs:
3198 case SystemZ::BI__builtin_s390_vstrczfs: i = 3; l = 0; u = 15;
break;
3199 case SystemZ::BI__builtin_s390_vmslg: i = 3; l = 0; u = 15;
break;
3200 case SystemZ::BI__builtin_s390_vfminsb:
3201 case SystemZ::BI__builtin_s390_vfmaxsb:
3202 case SystemZ::BI__builtin_s390_vfmindb:
3203 case SystemZ::BI__builtin_s390_vfmaxdb: i = 2; l = 0; u = 15;
break;
3205 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3216 return S.
Diag(TheCall->
getBeginLoc(), diag::err_expr_not_string_literal)
3236 return S.
Diag(TheCall->
getBeginLoc(), diag::err_expr_not_string_literal)
3249 bool Sema::CheckX86BuiltinRoundingOrSAE(
unsigned BuiltinID,
CallExpr *TheCall) {
3253 unsigned ArgNum = 0;
3254 switch (BuiltinID) {
3257 case X86::BI__builtin_ia32_vcvttsd2si32:
3258 case X86::BI__builtin_ia32_vcvttsd2si64:
3259 case X86::BI__builtin_ia32_vcvttsd2usi32:
3260 case X86::BI__builtin_ia32_vcvttsd2usi64:
3261 case X86::BI__builtin_ia32_vcvttss2si32:
3262 case X86::BI__builtin_ia32_vcvttss2si64:
3263 case X86::BI__builtin_ia32_vcvttss2usi32:
3264 case X86::BI__builtin_ia32_vcvttss2usi64:
3267 case X86::BI__builtin_ia32_maxpd512:
3268 case X86::BI__builtin_ia32_maxps512:
3269 case X86::BI__builtin_ia32_minpd512:
3270 case X86::BI__builtin_ia32_minps512:
3273 case X86::BI__builtin_ia32_cvtps2pd512_mask:
3274 case X86::BI__builtin_ia32_cvttpd2dq512_mask:
3275 case X86::BI__builtin_ia32_cvttpd2qq512_mask:
3276 case X86::BI__builtin_ia32_cvttpd2udq512_mask:
3277 case X86::BI__builtin_ia32_cvttpd2uqq512_mask:
3278 case X86::BI__builtin_ia32_cvttps2dq512_mask:
3279 case X86::BI__builtin_ia32_cvttps2qq512_mask:
3280 case X86::BI__builtin_ia32_cvttps2udq512_mask:
3281 case X86::BI__builtin_ia32_cvttps2uqq512_mask:
3282 case X86::BI__builtin_ia32_exp2pd_mask:
3283 case X86::BI__builtin_ia32_exp2ps_mask:
3284 case X86::BI__builtin_ia32_getexppd512_mask:
3285 case X86::BI__builtin_ia32_getexpps512_mask:
3286 case X86::BI__builtin_ia32_rcp28pd_mask:
3287 case X86::BI__builtin_ia32_rcp28ps_mask:
3288 case X86::BI__builtin_ia32_rsqrt28pd_mask:
3289 case X86::BI__builtin_ia32_rsqrt28ps_mask:
3290 case X86::BI__builtin_ia32_vcomisd:
3291 case X86::BI__builtin_ia32_vcomiss:
3292 case X86::BI__builtin_ia32_vcvtph2ps512_mask:
3295 case X86::BI__builtin_ia32_cmppd512_mask:
3296 case X86::BI__builtin_ia32_cmpps512_mask:
3297 case X86::BI__builtin_ia32_cmpsd_mask:
3298 case X86::BI__builtin_ia32_cmpss_mask:
3299 case X86::BI__builtin_ia32_cvtss2sd_round_mask:
3300 case X86::BI__builtin_ia32_getexpsd128_round_mask:
3301 case X86::BI__builtin_ia32_getexpss128_round_mask:
3302 case X86::BI__builtin_ia32_maxsd_round_mask:
3303 case X86::BI__builtin_ia32_maxss_round_mask:
3304 case X86::BI__builtin_ia32_minsd_round_mask:
3305 case X86::BI__builtin_ia32_minss_round_mask:
3306 case X86::BI__builtin_ia32_rcp28sd_round_mask:
3307 case X86::BI__builtin_ia32_rcp28ss_round_mask:
3308 case X86::BI__builtin_ia32_reducepd512_mask:
3309 case X86::BI__builtin_ia32_reduceps512_mask:
3310 case X86::BI__builtin_ia32_rndscalepd_mask:
3311 case X86::BI__builtin_ia32_rndscaleps_mask:
3312 case X86::BI__builtin_ia32_rsqrt28sd_round_mask:
3313 case X86::BI__builtin_ia32_rsqrt28ss_round_mask:
3316 case X86::BI__builtin_ia32_fixupimmpd512_mask:
3317 case X86::BI__builtin_ia32_fixupimmpd512_maskz:
3318 case X86::BI__builtin_ia32_fixupimmps512_mask:
3319 case X86::BI__builtin_ia32_fixupimmps512_maskz:
3320 case X86::BI__builtin_ia32_fixupimmsd_mask:
3321 case X86::BI__builtin_ia32_fixupimmsd_maskz:
3322 case X86::BI__builtin_ia32_fixupimmss_mask:
3323 case X86::BI__builtin_ia32_fixupimmss_maskz:
3324 case X86::BI__builtin_ia32_rangepd512_mask:
3325 case X86::BI__builtin_ia32_rangeps512_mask:
3326 case X86::BI__builtin_ia32_rangesd128_round_mask:
3327 case X86::BI__builtin_ia32_rangess128_round_mask:
3328 case X86::BI__builtin_ia32_reducesd_mask:
3329 case X86::BI__builtin_ia32_reducess_mask:
3330 case X86::BI__builtin_ia32_rndscalesd_round_mask:
3331 case X86::BI__builtin_ia32_rndscaless_round_mask:
3334 case X86::BI__builtin_ia32_vcvtsd2si64:
3335 case X86::BI__builtin_ia32_vcvtsd2si32:
3336 case X86::BI__builtin_ia32_vcvtsd2usi32:
3337 case X86::BI__builtin_ia32_vcvtsd2usi64:
3338 case X86::BI__builtin_ia32_vcvtss2si32:
3339 case X86::BI__builtin_ia32_vcvtss2si64:
3340 case X86::BI__builtin_ia32_vcvtss2usi32:
3341 case X86::BI__builtin_ia32_vcvtss2usi64:
3342 case X86::BI__builtin_ia32_sqrtpd512:
3343 case X86::BI__builtin_ia32_sqrtps512:
3347 case X86::BI__builtin_ia32_addpd512:
3348 case X86::BI__builtin_ia32_addps512:
3349 case X86::BI__builtin_ia32_divpd512:
3350 case X86::BI__builtin_ia32_divps512:
3351 case X86::BI__builtin_ia32_mulpd512:
3352 case X86::BI__builtin_ia32_mulps512:
3353 case X86::BI__builtin_ia32_subpd512:
3354 case X86::BI__builtin_ia32_subps512:
3355 case X86::BI__builtin_ia32_cvtsi2sd64:
3356 case X86::BI__builtin_ia32_cvtsi2ss32:
3357 case X86::BI__builtin_ia32_cvtsi2ss64:
3358 case X86::BI__builtin_ia32_cvtusi2sd64:
3359 case X86::BI__builtin_ia32_cvtusi2ss32:
3360 case X86::BI__builtin_ia32_cvtusi2ss64:
3364 case X86::BI__builtin_ia32_cvtdq2ps512_mask:
3365 case X86::BI__builtin_ia32_cvtudq2ps512_mask:
3366 case X86::BI__builtin_ia32_cvtpd2ps512_mask:
3367 case X86::BI__builtin_ia32_cvtpd2qq512_mask:
3368 case X86::BI__builtin_ia32_cvtpd2uqq512_mask:
3369 case X86::BI__builtin_ia32_cvtps2qq512_mask:
3370 case X86::BI__builtin_ia32_cvtps2uqq512_mask:
3371 case X86::BI__builtin_ia32_cvtqq2pd512_mask:
3372 case X86::BI__builtin_ia32_cvtqq2ps512_mask:
3373 case X86::BI__builtin_ia32_cvtuqq2pd512_mask:
3374 case X86::BI__builtin_ia32_cvtuqq2ps512_mask:
3378 case X86::BI__builtin_ia32_addss_round_mask:
3379 case X86::BI__builtin_ia32_addsd_round_mask:
3380 case X86::BI__builtin_ia32_divss_round_mask:
3381 case X86::BI__builtin_ia32_divsd_round_mask:
3382 case X86::BI__builtin_ia32_mulss_round_mask:
3383 case X86::BI__builtin_ia32_mulsd_round_mask:
3384 case X86::BI__builtin_ia32_subss_round_mask:
3385 case X86::BI__builtin_ia32_subsd_round_mask:
3386 case X86::BI__builtin_ia32_scalefpd512_mask:
3387 case X86::BI__builtin_ia32_scalefps512_mask:
3388 case X86::BI__builtin_ia32_scalefsd_round_mask:
3389 case X86::BI__builtin_ia32_scalefss_round_mask:
3390 case X86::BI__builtin_ia32_getmantpd512_mask:
3391 case X86::BI__builtin_ia32_getmantps512_mask:
3392 case X86::BI__builtin_ia32_cvtsd2ss_round_mask:
3393 case X86::BI__builtin_ia32_sqrtsd_round_mask:
3394 case X86::BI__builtin_ia32_sqrtss_round_mask:
3395 case X86::BI__builtin_ia32_vfmaddsd3_mask:
3396 case X86::BI__builtin_ia32_vfmaddsd3_maskz:
3397 case X86::BI__builtin_ia32_vfmaddsd3_mask3:
3398 case X86::BI__builtin_ia32_vfmaddss3_mask:
3399 case X86::BI__builtin_ia32_vfmaddss3_maskz:
3400 case X86::BI__builtin_ia32_vfmaddss3_mask3:
3401 case X86::BI__builtin_ia32_vfmaddpd512_mask:
3402 case X86::BI__builtin_ia32_vfmaddpd512_maskz:
3403 case X86::BI__builtin_ia32_vfmaddpd512_mask3:
3404 case X86::BI__builtin_ia32_vfmsubpd512_mask3:
3405 case X86::BI__builtin_ia32_vfmaddps512_mask:
3406 case X86::BI__builtin_ia32_vfmaddps512_maskz:
3407 case X86::BI__builtin_ia32_vfmaddps512_mask3:
3408 case X86::BI__builtin_ia32_vfmsubps512_mask3:
3409 case X86::BI__builtin_ia32_vfmaddsubpd512_mask:
3410 case X86::BI__builtin_ia32_vfmaddsubpd512_maskz:
3411 case X86::BI__builtin_ia32_vfmaddsubpd512_mask3:
3412 case X86::BI__builtin_ia32_vfmsubaddpd512_mask3:
3413 case X86::BI__builtin_ia32_vfmaddsubps512_mask:
3414 case X86::BI__builtin_ia32_vfmaddsubps512_maskz:
3415 case X86::BI__builtin_ia32_vfmaddsubps512_mask3:
3416 case X86::BI__builtin_ia32_vfmsubaddps512_mask3:
3420 case X86::BI__builtin_ia32_getmantsd_round_mask:
3421 case X86::BI__builtin_ia32_getmantss_round_mask:
3427 llvm::APSInt Result;
3435 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
3443 (HasRC && Result.getZExtValue() >= 8 && Result.getZExtValue() <= 11))
3446 return Diag(TheCall->
getBeginLoc(), diag::err_x86_builtin_invalid_rounding)
3451 bool Sema::CheckX86BuiltinGatherScatterScale(
unsigned BuiltinID,
3453 unsigned ArgNum = 0;
3454 switch (BuiltinID) {
3457 case X86::BI__builtin_ia32_gatherpfdpd:
3458 case X86::BI__builtin_ia32_gatherpfdps:
3459 case X86::BI__builtin_ia32_gatherpfqpd:
3460 case X86::BI__builtin_ia32_gatherpfqps:
3461 case X86::BI__builtin_ia32_scatterpfdpd:
3462 case X86::BI__builtin_ia32_scatterpfdps:
3463 case X86::BI__builtin_ia32_scatterpfqpd:
3464 case X86::BI__builtin_ia32_scatterpfqps:
3467 case X86::BI__builtin_ia32_gatherd_pd:
3468 case X86::BI__builtin_ia32_gatherd_pd256:
3469 case X86::BI__builtin_ia32_gatherq_pd:
3470 case X86::BI__builtin_ia32_gatherq_pd256:
3471 case X86::BI__builtin_ia32_gatherd_ps:
3472 case X86::BI__builtin_ia32_gatherd_ps256:
3473 case X86::BI__builtin_ia32_gatherq_ps:
3474 case X86::BI__builtin_ia32_gatherq_ps256:
3475 case X86::BI__builtin_ia32_gatherd_q:
3476 case X86::BI__builtin_ia32_gatherd_q256:
3477 case X86::BI__builtin_ia32_gatherq_q:
3478 case X86::BI__builtin_ia32_gatherq_q256:
3479 case X86::BI__builtin_ia32_gatherd_d:
3480 case X86::BI__builtin_ia32_gatherd_d256:
3481 case X86::BI__builtin_ia32_gatherq_d:
3482 case X86::BI__builtin_ia32_gatherq_d256:
3483 case X86::BI__builtin_ia32_gather3div2df:
3484 case X86::BI__builtin_ia32_gather3div2di:
3485 case X86::BI__builtin_ia32_gather3div4df:
3486 case X86::BI__builtin_ia32_gather3div4di:
3487 case X86::BI__builtin_ia32_gather3div4sf:
3488 case X86::BI__builtin_ia32_gather3div4si:
3489 case X86::BI__builtin_ia32_gather3div8sf:
3490 case X86::BI__builtin_ia32_gather3div8si:
3491 case X86::BI__builtin_ia32_gather3siv2df:
3492 case X86::BI__builtin_ia32_gather3siv2di:
3493 case X86::BI__builtin_ia32_gather3siv4df:
3494 case X86::BI__builtin_ia32_gather3siv4di:
3495 case X86::BI__builtin_ia32_gather3siv4sf:
3496 case X86::BI__builtin_ia32_gather3siv4si:
3497 case X86::BI__builtin_ia32_gather3siv8sf:
3498 case X86::BI__builtin_ia32_gather3siv8si:
3499 case X86::BI__builtin_ia32_gathersiv8df:
3500 case X86::BI__builtin_ia32_gathersiv16sf:
3501 case X86::BI__builtin_ia32_gatherdiv8df:
3502 case X86::BI__builtin_ia32_gatherdiv16sf:
3503 case X86::BI__builtin_ia32_gathersiv8di:
3504 case X86::BI__builtin_ia32_gathersiv16si:
3505 case X86::BI__builtin_ia32_gatherdiv8di:
3506 case X86::BI__builtin_ia32_gatherdiv16si:
3507 case X86::BI__builtin_ia32_scatterdiv2df:
3508 case X86::BI__builtin_ia32_scatterdiv2di:
3509 case X86::BI__builtin_ia32_scatterdiv4df:
3510 case X86::BI__builtin_ia32_scatterdiv4di:
3511 case X86::BI__builtin_ia32_scatterdiv4sf:
3512 case X86::BI__builtin_ia32_scatterdiv4si:
3513 case X86::BI__builtin_ia32_scatterdiv8sf:
3514 case X86::BI__builtin_ia32_scatterdiv8si:
3515 case X86::BI__builtin_ia32_scattersiv2df:
3516 case X86::BI__builtin_ia32_scattersiv2di:
3517 case X86::BI__builtin_ia32_scattersiv4df:
3518 case X86::BI__builtin_ia32_scattersiv4di:
3519 case X86::BI__builtin_ia32_scattersiv4sf:
3520 case X86::BI__builtin_ia32_scattersiv4si:
3521 case X86::BI__builtin_ia32_scattersiv8sf:
3522 case X86::BI__builtin_ia32_scattersiv8si:
3523 case X86::BI__builtin_ia32_scattersiv8df:
3524 case X86::BI__builtin_ia32_scattersiv16sf:
3525 case X86::BI__builtin_ia32_scatterdiv8df:
3526 case X86::BI__builtin_ia32_scatterdiv16sf:
3527 case X86::BI__builtin_ia32_scattersiv8di:
3528 case X86::BI__builtin_ia32_scattersiv16si:
3529 case X86::BI__builtin_ia32_scatterdiv8di:
3530 case X86::BI__builtin_ia32_scatterdiv16si:
3535 llvm::APSInt Result;
3543 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
3546 if (Result == 1 || Result == 2 || Result == 4 || Result == 8)
3549 return Diag(TheCall->
getBeginLoc(), diag::err_x86_builtin_invalid_scale)
3555 switch (BuiltinID) {
3556 case X86::BI__builtin_ia32_readeflags_u32:
3557 case X86::BI__builtin_ia32_writeeflags_u32:
3564 bool Sema::CheckX86BuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
3565 if (BuiltinID == X86::BI__builtin_cpu_supports)
3568 if (BuiltinID == X86::BI__builtin_cpu_is)
3575 diag::err_32_bit_builtin_64_bit_tgt);
3578 if (CheckX86BuiltinRoundingOrSAE(BuiltinID, TheCall))
3582 if (CheckX86BuiltinGatherScatterScale(BuiltinID, TheCall))
3587 int i = 0, l = 0, u = 0;
3588 switch (BuiltinID) {
3591 case X86::BI__builtin_ia32_vec_ext_v2si:
3592 case X86::BI__builtin_ia32_vec_ext_v2di:
3593 case X86::BI__builtin_ia32_vextractf128_pd256:
3594 case X86::BI__builtin_ia32_vextractf128_ps256:
3595 case X86::BI__builtin_ia32_vextractf128_si256:
3596 case X86::BI__builtin_ia32_extract128i256:
3597 case X86::BI__builtin_ia32_extractf64x4_mask:
3598 case X86::BI__builtin_ia32_extracti64x4_mask:
3599 case X86::BI__builtin_ia32_extractf32x8_mask:
3600 case X86::BI__builtin_ia32_extracti32x8_mask:
3601 case X86::BI__builtin_ia32_extractf64x2_256_mask:
3602 case X86::BI__builtin_ia32_extracti64x2_256_mask:
3603 case X86::BI__builtin_ia32_extractf32x4_256_mask:
3604 case X86::BI__builtin_ia32_extracti32x4_256_mask:
3605 i = 1; l = 0; u = 1;
3607 case X86::BI__builtin_ia32_vec_set_v2di:
3608 case X86::BI__builtin_ia32_vinsertf128_pd256:
3609 case X86::BI__builtin_ia32_vinsertf128_ps256:
3610 case X86::BI__builtin_ia32_vinsertf128_si256:
3611 case X86::BI__builtin_ia32_insert128i256:
3612 case X86::BI__builtin_ia32_insertf32x8:
3613 case X86::BI__builtin_ia32_inserti32x8:
3614 case X86::BI__builtin_ia32_insertf64x4:
3615 case X86::BI__builtin_ia32_inserti64x4:
3616 case X86::BI__builtin_ia32_insertf64x2_256:
3617 case X86::BI__builtin_ia32_inserti64x2_256:
3618 case X86::BI__builtin_ia32_insertf32x4_256:
3619 case X86::BI__builtin_ia32_inserti32x4_256:
3620 i = 2; l = 0; u = 1;
3622 case X86::BI__builtin_ia32_vpermilpd:
3623 case X86::BI__builtin_ia32_vec_ext_v4hi:
3624 case X86::BI__builtin_ia32_vec_ext_v4si:
3625 case X86::BI__builtin_ia32_vec_ext_v4sf:
3626 case X86::BI__builtin_ia32_vec_ext_v4di:
3627 case X86::BI__builtin_ia32_extractf32x4_mask:
3628 case X86::BI__builtin_ia32_extracti32x4_mask:
3629 case X86::BI__builtin_ia32_extractf64x2_512_mask:
3630 case X86::BI__builtin_ia32_extracti64x2_512_mask:
3631 i = 1; l = 0; u = 3;
3633 case X86::BI_mm_prefetch:
3634 case X86::BI__builtin_ia32_vec_ext_v8hi:
3635 case X86::BI__builtin_ia32_vec_ext_v8si:
3636 i = 1; l = 0; u = 7;
3638 case X86::BI__builtin_ia32_sha1rnds4:
3639 case X86::BI__builtin_ia32_blendpd:
3640 case X86::BI__builtin_ia32_shufpd:
3641 case X86::BI__builtin_ia32_vec_set_v4hi:
3642 case X86::BI__builtin_ia32_vec_set_v4si:
3643 case X86::BI__builtin_ia32_vec_set_v4di:
3644 case X86::BI__builtin_ia32_shuf_f32x4_256:
3645 case X86::BI__builtin_ia32_shuf_f64x2_256:
3646 case X86::BI__builtin_ia32_shuf_i32x4_256:
3647 case X86::BI__builtin_ia32_shuf_i64x2_256:
3648 case X86::BI__builtin_ia32_insertf64x2_512:
3649 case X86::BI__builtin_ia32_inserti64x2_512:
3650 case X86::BI__builtin_ia32_insertf32x4:
3651 case X86::BI__builtin_ia32_inserti32x4:
3652 i = 2; l = 0; u = 3;
3654 case X86::BI__builtin_ia32_vpermil2pd:
3655 case X86::BI__builtin_ia32_vpermil2pd256:
3656 case X86::BI__builtin_ia32_vpermil2ps:
3657 case X86::BI__builtin_ia32_vpermil2ps256:
3658 i = 3; l = 0; u = 3;
3660 case X86::BI__builtin_ia32_cmpb128_mask:
3661 case X86::BI__builtin_ia32_cmpw128_mask:
3662 case X86::BI__builtin_ia32_cmpd128_mask:
3663 case X86::BI__builtin_ia32_cmpq128_mask:
3664 case X86::BI__builtin_ia32_cmpb256_mask:
3665 case X86::BI__builtin_ia32_cmpw256_mask:
3666 case X86::BI__builtin_ia32_cmpd256_mask:
3667 case X86::BI__builtin_ia32_cmpq256_mask:
3668 case X86::BI__builtin_ia32_cmpb512_mask:
3669 case X86::BI__builtin_ia32_cmpw512_mask:
3670 case X86::BI__builtin_ia32_cmpd512_mask:
3671 case X86::BI__builtin_ia32_cmpq512_mask:
3672 case X86::BI__builtin_ia32_ucmpb128_mask:
3673 case X86::BI__builtin_ia32_ucmpw128_mask:
3674 case X86::BI__builtin_ia32_ucmpd128_mask:
3675 case X86::BI__builtin_ia32_ucmpq128_mask:
3676 case X86::BI__builtin_ia32_ucmpb256_mask:
3677 case X86::BI__builtin_ia32_ucmpw256_mask:
3678 case X86::BI__builtin_ia32_ucmpd256_mask:
3679 case X86::BI__builtin_ia32_ucmpq256_mask:
3680 case X86::BI__builtin_ia32_ucmpb512_mask:
3681 case X86::BI__builtin_ia32_ucmpw512_mask:
3682 case X86::BI__builtin_ia32_ucmpd512_mask:
3683 case X86::BI__builtin_ia32_ucmpq512_mask:
3684 case X86::BI__builtin_ia32_vpcomub:
3685 case X86::BI__builtin_ia32_vpcomuw:
3686 case X86::BI__builtin_ia32_vpcomud:
3687 case X86::BI__builtin_ia32_vpcomuq:
3688 case X86::BI__builtin_ia32_vpcomb:
3689 case X86::BI__builtin_ia32_vpcomw:
3690 case X86::BI__builtin_ia32_vpcomd:
3691 case X86::BI__builtin_ia32_vpcomq:
3692 case X86::BI__builtin_ia32_vec_set_v8hi:
3693 case X86::BI__builtin_ia32_vec_set_v8si:
3694 i = 2; l = 0; u = 7;
3696 case X86::BI__builtin_ia32_vpermilpd256:
3697 case X86::BI__builtin_ia32_roundps:
3698 case X86::BI__builtin_ia32_roundpd:
3699 case X86::BI__builtin_ia32_roundps256:
3700 case X86::BI__builtin_ia32_roundpd256:
3701 case X86::BI__builtin_ia32_getmantpd128_mask:
3702 case X86::BI__builtin_ia32_getmantpd256_mask:
3703 case X86::BI__builtin_ia32_getmantps128_mask:
3704 case X86::BI__builtin_ia32_getmantps256_mask:
3705 case X86::BI__builtin_ia32_getmantpd512_mask:
3706 case X86::BI__builtin_ia32_getmantps512_mask:
3707 case X86::BI__builtin_ia32_vec_ext_v16qi:
3708 case X86::BI__builtin_ia32_vec_ext_v16hi:
3709 i = 1; l = 0; u = 15;
3711 case X86::BI__builtin_ia32_pblendd128:
3712 case X86::BI__builtin_ia32_blendps:
3713 case X86::BI__builtin_ia32_blendpd256:
3714 case X86::BI__builtin_ia32_shufpd256:
3715 case X86::BI__builtin_ia32_roundss:
3716 case X86::BI__builtin_ia32_roundsd:
3717 case X86::BI__builtin_ia32_rangepd128_mask:
3718 case X86::BI__builtin_ia32_rangepd256_mask:
3719 case X86::BI__builtin_ia32_rangepd512_mask:
3720 case X86::BI__builtin_ia32_rangeps128_mask:
3721 case X86::BI__builtin_ia32_rangeps256_mask:
3722 case X86::BI__builtin_ia32_rangeps512_mask:
3723 case X86::BI__builtin_ia32_getmantsd_round_mask:
3724 case X86::BI__builtin_ia32_getmantss_round_mask:
3725 case X86::BI__builtin_ia32_vec_set_v16qi:
3726 case X86::BI__builtin_ia32_vec_set_v16hi:
3727 i = 2; l = 0; u = 15;
3729 case X86::BI__builtin_ia32_vec_ext_v32qi:
3730 i = 1; l = 0; u = 31;
3732 case X86::BI__builtin_ia32_cmpps:
3733 case X86::BI__builtin_ia32_cmpss:
3734 case X86::BI__builtin_ia32_cmppd:
3735 case X86::BI__builtin_ia32_cmpsd:
3736 case X86::BI__builtin_ia32_cmpps256:
3737 case X86::BI__builtin_ia32_cmppd256:
3738 case X86::BI__builtin_ia32_cmpps128_mask:
3739 case X86::BI__builtin_ia32_cmppd128_mask:
3740 case X86::BI__builtin_ia32_cmpps256_mask:
3741 case X86::BI__builtin_ia32_cmppd256_mask:
3742 case X86::BI__builtin_ia32_cmpps512_mask:
3743 case X86::BI__builtin_ia32_cmppd512_mask:
3744 case X86::BI__builtin_ia32_cmpsd_mask:
3745 case X86::BI__builtin_ia32_cmpss_mask:
3746 case X86::BI__builtin_ia32_vec_set_v32qi:
3747 i = 2; l = 0; u = 31;
3749 case X86::BI__builtin_ia32_permdf256:
3750 case X86::BI__builtin_ia32_permdi256:
3751 case X86::BI__builtin_ia32_permdf512:
3752 case X86::BI__builtin_ia32_permdi512:
3753 case X86::BI__builtin_ia32_vpermilps:
3754 case X86::BI__builtin_ia32_vpermilps256:
3755 case X86::BI__builtin_ia32_vpermilpd512:
3756 case X86::BI__builtin_ia32_vpermilps512:
3757 case X86::BI__builtin_ia32_pshufd:
3758 case X86::BI__builtin_ia32_pshufd256:
3759 case X86::BI__builtin_ia32_pshufd512:
3760 case X86::BI__builtin_ia32_pshufhw:
3761 case X86::BI__builtin_ia32_pshufhw256:
3762 case X86::BI__builtin_ia32_pshufhw512:
3763 case X86::BI__builtin_ia32_pshuflw:
3764 case X86::BI__builtin_ia32_pshuflw256:
3765 case X86::BI__builtin_ia32_pshuflw512:
3766 case X86::BI__builtin_ia32_vcvtps2ph:
3767 case X86::BI__builtin_ia32_vcvtps2ph_mask:
3768 case X86::BI__builtin_ia32_vcvtps2ph256:
3769 case X86::BI__builtin_ia32_vcvtps2ph256_mask:
3770 case X86::BI__builtin_ia32_vcvtps2ph512_mask:
3771 case X86::BI__builtin_ia32_rndscaleps_128_mask:
3772 case X86::BI__builtin_ia32_rndscalepd_128_mask:
3773 case X86::BI__builtin_ia32_rndscaleps_256_mask:
3774 case X86::BI__builtin_ia32_rndscalepd_256_mask:
3775 case X86::BI__builtin_ia32_rndscaleps_mask:
3776 case X86::BI__builtin_ia32_rndscalepd_mask:
3777 case X86::BI__builtin_ia32_reducepd128_mask:
3778 case X86::BI__builtin_ia32_reducepd256_mask:
3779 case X86::BI__builtin_ia32_reducepd512_mask:
3780 case X86::BI__builtin_ia32_reduceps128_mask:
3781 case X86::BI__builtin_ia32_reduceps256_mask:
3782 case X86::BI__builtin_ia32_reduceps512_mask:
3783 case X86::BI__builtin_ia32_prold512:
3784 case X86::BI__builtin_ia32_prolq512:
3785 case X86::BI__builtin_ia32_prold128:
3786 case X86::BI__builtin_ia32_prold256:
3787 case X86::BI__builtin_ia32_prolq128:
3788 case X86::BI__builtin_ia32_prolq256:
3789 case X86::BI__builtin_ia32_prord512:
3790 case X86::BI__builtin_ia32_prorq512:
3791 case X86::BI__builtin_ia32_prord128:
3792 case X86::BI__builtin_ia32_prord256:
3793 case X86::BI__builtin_ia32_prorq128:
3794 case X86::BI__builtin_ia32_prorq256:
3795 case X86::BI__builtin_ia32_fpclasspd128_mask:
3796 case X86::BI__builtin_ia32_fpclasspd256_mask:
3797 case X86::BI__builtin_ia32_fpclassps128_mask:
3798 case X86::BI__builtin_ia32_fpclassps256_mask:
3799 case X86::BI__builtin_ia32_fpclassps512_mask:
3800 case X86::BI__builtin_ia32_fpclasspd512_mask:
3801 case X86::BI__builtin_ia32_fpclasssd_mask:
3802 case X86::BI__builtin_ia32_fpclassss_mask:
3803 case X86::BI__builtin_ia32_pslldqi128_byteshift:
3804 case X86::BI__builtin_ia32_pslldqi256_byteshift:
3805 case X86::BI__builtin_ia32_pslldqi512_byteshift:
3806 case X86::BI__builtin_ia32_psrldqi128_byteshift:
3807 case X86::BI__builtin_ia32_psrldqi256_byteshift:
3808 case X86::BI__builtin_ia32_psrldqi512_byteshift:
3809 case X86::BI__builtin_ia32_kshiftliqi:
3810 case X86::BI__builtin_ia32_kshiftlihi:
3811 case X86::BI__builtin_ia32_kshiftlisi:
3812 case X86::BI__builtin_ia32_kshiftlidi:
3813 case X86::BI__builtin_ia32_kshiftriqi:
3814 case X86::BI__builtin_ia32_kshiftrihi:
3815 case X86::BI__builtin_ia32_kshiftrisi:
3816 case X86::BI__builtin_ia32_kshiftridi:
3817 i = 1; l = 0; u = 255;
3819 case X86::BI__builtin_ia32_vperm2f128_pd256:
3820 case X86::BI__builtin_ia32_vperm2f128_ps256:
3821 case X86::BI__builtin_ia32_vperm2f128_si256:
3822 case X86::BI__builtin_ia32_permti256:
3823 case X86::BI__builtin_ia32_pblendw128:
3824 case X86::BI__builtin_ia32_pblendw256:
3825 case X86::BI__builtin_ia32_blendps256:
3826 case X86::BI__builtin_ia32_pblendd256:
3827 case X86::BI__builtin_ia32_palignr128:
3828 case X86::BI__builtin_ia32_palignr256:
3829 case X86::BI__builtin_ia32_palignr512:
3830 case X86::BI__builtin_ia32_alignq512:
3831 case X86::BI__builtin_ia32_alignd512:
3832 case X86::BI__builtin_ia32_alignd128:
3833 case X86::BI__builtin_ia32_alignd256:
3834 case X86::BI__builtin_ia32_alignq128:
3835 case X86::BI__builtin_ia32_alignq256:
3836 case X86::BI__builtin_ia32_vcomisd:
3837 case X86::BI__builtin_ia32_vcomiss:
3838 case X86::BI__builtin_ia32_shuf_f32x4:
3839 case X86::BI__builtin_ia32_shuf_f64x2:
3840 case X86::BI__builtin_ia32_shuf_i32x4:
3841 case X86::BI__builtin_ia32_shuf_i64x2:
3842 case X86::BI__builtin_ia32_shufpd512:
3843 case X86::BI__builtin_ia32_shufps:
3844 case X86::BI__builtin_ia32_shufps256:
3845 case X86::BI__builtin_ia32_shufps512:
3846 case X86::BI__builtin_ia32_dbpsadbw128:
3847 case X86::BI__builtin_ia32_dbpsadbw256:
3848 case X86::BI__builtin_ia32_dbpsadbw512:
3849 case X86::BI__builtin_ia32_vpshldd128:
3850 case X86::BI__builtin_ia32_vpshldd256:
3851 case X86::BI__builtin_ia32_vpshldd512:
3852 case X86::BI__builtin_ia32_vpshldq128:
3853 case X86::BI__builtin_ia32_vpshldq256:
3854 case X86::BI__builtin_ia32_vpshldq512:
3855 case X86::BI__builtin_ia32_vpshldw128:
3856 case X86::BI__builtin_ia32_vpshldw256:
3857 case X86::BI__builtin_ia32_vpshldw512:
3858 case X86::BI__builtin_ia32_vpshrdd128:
3859 case X86::BI__builtin_ia32_vpshrdd256:
3860 case X86::BI__builtin_ia32_vpshrdd512:
3861 case X86::BI__builtin_ia32_vpshrdq128:
3862 case X86::BI__builtin_ia32_vpshrdq256:
3863 case X86::BI__builtin_ia32_vpshrdq512:
3864 case X86::BI__builtin_ia32_vpshrdw128:
3865 case X86::BI__builtin_ia32_vpshrdw256:
3866 case X86::BI__builtin_ia32_vpshrdw512:
3867 i = 2; l = 0; u = 255;
3869 case X86::BI__builtin_ia32_fixupimmpd512_mask:
3870 case X86::BI__builtin_ia32_fixupimmpd512_maskz:
3871 case X86::BI__builtin_ia32_fixupimmps512_mask:
3872 case X86::BI__builtin_ia32_fixupimmps512_maskz:
3873 case X86::BI__builtin_ia32_fixupimmsd_mask:
3874 case X86::BI__builtin_ia32_fixupimmsd_maskz:
3875 case X86::BI__builtin_ia32_fixupimmss_mask:
3876 case X86::BI__builtin_ia32_fixupimmss_maskz:
3877 case X86::BI__builtin_ia32_fixupimmpd128_mask:
3878 case X86::BI__builtin_ia32_fixupimmpd128_maskz:
3879 case X86::BI__builtin_ia32_fixupimmpd256_mask:
3880 case X86::BI__builtin_ia32_fixupimmpd256_maskz:
3881 case X86::BI__builtin_ia32_fixupimmps128_mask:
3882 case X86::BI__builtin_ia32_fixupimmps128_maskz:
3883 case X86::BI__builtin_ia32_fixupimmps256_mask:
3884 case X86::BI__builtin_ia32_fixupimmps256_maskz:
3885 case X86::BI__builtin_ia32_pternlogd512_mask:
3886 case X86::BI__builtin_ia32_pternlogd512_maskz:
3887 case X86::BI__builtin_ia32_pternlogq512_mask:
3888 case X86::BI__builtin_ia32_pternlogq512_maskz:
3889 case X86::BI__builtin_ia32_pternlogd128_mask:
3890 case X86::BI__builtin_ia32_pternlogd128_maskz:
3891 case X86::BI__builtin_ia32_pternlogd256_mask:
3892 case X86::BI__builtin_ia32_pternlogd256_maskz:
3893 case X86::BI__builtin_ia32_pternlogq128_mask:
3894 case X86::BI__builtin_ia32_pternlogq128_maskz:
3895 case X86::BI__builtin_ia32_pternlogq256_mask:
3896 case X86::BI__builtin_ia32_pternlogq256_maskz:
3897 i = 3; l = 0; u = 255;
3899 case X86::BI__builtin_ia32_gatherpfdpd:
3900 case X86::BI__builtin_ia32_gatherpfdps:
3901 case X86::BI__builtin_ia32_gatherpfqpd:
3902 case X86::BI__builtin_ia32_gatherpfqps:
3903 case X86::BI__builtin_ia32_scatterpfdpd:
3904 case X86::BI__builtin_ia32_scatterpfdps:
3905 case X86::BI__builtin_ia32_scatterpfqpd:
3906 case X86::BI__builtin_ia32_scatterpfqps:
3907 i = 4; l = 2; u = 3;
3909 case X86::BI__builtin_ia32_rndscalesd_round_mask:
3910 case X86::BI__builtin_ia32_rndscaless_round_mask:
3911 i = 4; l = 0; u = 255;
3919 return SemaBuiltinConstantArgRange(TheCall, i, l, u,
false);
3926 bool Sema::getFormatStringInfo(
const FormatAttr *Format,
bool IsCXXMember,
3927 FormatStringInfo *FSI) {
3928 FSI->HasVAListArg = Format->getFirstArg() == 0;
3929 FSI->FormatIdx = Format->getFormatIdx() - 1;
3930 FSI->FirstDataArg = FSI->HasVAListArg ? 0 : Format->getFirstArg() - 1;
3936 if(FSI->FormatIdx == 0)
3939 if (FSI->FirstDataArg != 0)
3940 --FSI->FirstDataArg;
3950 if (
auto nullability
3959 if (UT->getDecl()->hasAttr<TransparentUnionAttr>())
3961 dyn_cast<CompoundLiteralExpr>(Expr))
3963 dyn_cast<InitListExpr>(CLE->getInitializer()))
3964 Expr = ILE->getInit(0);
3974 const Expr *ArgExpr,
3982 FormatStringInfo FSI;
3983 if ((GetFormatStringType(Format) == FST_NSString) &&
3984 getFormatStringInfo(Format,
false, &FSI)) {
3985 Idx = FSI.FormatIdx;
3999 bool Format =
false;
4012 if (!Format || NumArgs <= Idx)
4014 const Expr *FormatExpr = Args[Idx];
4015 if (
const CStyleCastExpr *CSCE = dyn_cast<CStyleCastExpr>(FormatExpr))
4016 FormatExpr = CSCE->getSubExpr();
4026 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
4044 ArrayRef<const Expr *> Args,
4046 assert((FDecl || Proto) &&
"Need a function declaration or prototype");
4049 llvm::SmallBitVector NonNullArgs;
4055 for (
const auto *Arg : Args)
4062 unsigned IdxAST = Idx.getASTIndex();
4063 if (IdxAST >= Args.size())
4065 if (NonNullArgs.empty())
4066 NonNullArgs.resize(Args.size());
4067 NonNullArgs.set(IdxAST);
4072 if (FDecl && (isa<FunctionDecl>(FDecl) || isa<ObjCMethodDecl>(FDecl))) {
4075 ArrayRef<ParmVarDecl*> parms;
4076 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(FDecl))
4077 parms = FD->parameters();
4079 parms = cast<ObjCMethodDecl>(FDecl)->parameters();
4081 unsigned ParamIndex = 0;
4082 for (ArrayRef<ParmVarDecl*>::iterator I = parms.begin(), E = parms.end();
4083 I != E; ++I, ++ParamIndex) {
4085 if (PVD->
hasAttr<NonNullAttr>() ||
4087 if (NonNullArgs.empty())
4088 NonNullArgs.resize(Args.size());
4090 NonNullArgs.set(ParamIndex);
4097 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(FDecl)) {
4116 if (NonNullArgs.empty())
4117 NonNullArgs.resize(Args.size());
4119 NonNullArgs.set(Index);
4128 for (
unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
4129 ArgIndex != ArgIndexEnd; ++ArgIndex) {
4130 if (NonNullArgs[ArgIndex])
4139 const Expr *ThisArg, ArrayRef<const Expr *> Args,
4143 if (CurContext->isDependentContext())
4147 llvm::SmallBitVector CheckedVarArgs;
4151 CheckedVarArgs.resize(Args.size());
4153 CheckFormatArguments(I, Args, IsMemberFunction, CallType, Loc, Range,
4160 auto *FD = dyn_cast_or_null<FunctionDecl>(FDecl);
4161 if (CallType != VariadicDoesNotApply &&
4162 (!FD || FD->getBuiltinID() != Builtin::BI__noop)) {
4164 : FDecl && isa<FunctionDecl>(FDecl)
4165 ? cast<FunctionDecl>(FDecl)->getNumParams()
4166 : FDecl && isa<ObjCMethodDecl>(FDecl)
4167 ? cast<ObjCMethodDecl>(FDecl)->param_size()
4170 for (
unsigned ArgIdx = NumParams; ArgIdx < Args.size(); ++ArgIdx) {
4172 if (
const Expr *Arg = Args[ArgIdx]) {
4173 if (CheckedVarArgs.empty() || !CheckedVarArgs[ArgIdx])
4174 checkVariadicArgument(Arg, CallType);
4179 if (FDecl || Proto) {
4184 for (
const auto *I : FDecl->
specific_attrs<ArgumentWithTypeTagAttr>())
4185 CheckArgumentWithTypeTag(I, Args, Loc);
4190 diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc);
4196 ArrayRef<const Expr *> Args,
4199 VariadicCallType CallType =
4200 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
4201 checkCall(FDecl, Proto,
nullptr, Args,
true,
4209 bool IsMemberOperatorCall = isa<CXXOperatorCallExpr>(TheCall) &&
4210 isa<CXXMethodDecl>(FDecl);
4211 bool IsMemberFunction = isa<CXXMemberCallExpr>(TheCall) ||
4212 IsMemberOperatorCall;
4213 VariadicCallType CallType = getVariadicCallType(FDecl, Proto,
4218 Expr *ImplicitThis =
nullptr;
4219 if (IsMemberOperatorCall) {
4223 ImplicitThis = Args[0];
4226 }
else if (IsMemberFunction)
4228 cast<CXXMemberCallExpr>(TheCall)->getImplicitObjectArgument();
4230 checkCall(FDecl, Proto, ImplicitThis, llvm::makeArrayRef(Args, NumArgs),
4240 CheckAbsoluteValueFunction(TheCall, FDecl);
4241 CheckMaxUnsignedZero(TheCall, FDecl);
4243 if (getLangOpts().ObjC)
4251 if (CMId == Builtin::BIstrlcpy || CMId == Builtin::BIstrlcat)
4252 CheckStrlcpycatArguments(TheCall, FnInfo);
4253 else if (CMId == Builtin::BIstrncat)
4254 CheckStrncatArguments(TheCall, FnInfo);
4256 CheckMemaccessArguments(TheCall, CMId, FnInfo);
4262 ArrayRef<const Expr *> Args) {
4263 VariadicCallType CallType =
4264 Method->
isVariadic() ? VariadicMethod : VariadicDoesNotApply;
4266 checkCall(Method,
nullptr,
nullptr, Args,
4276 if (
const auto *V = dyn_cast<VarDecl>(NDecl))
4277 Ty = V->getType().getNonReferenceType();
4278 else if (
const auto *F = dyn_cast<FieldDecl>(NDecl))
4279 Ty = F->getType().getNonReferenceType();
4287 VariadicCallType CallType;
4289 CallType = VariadicDoesNotApply;
4291 CallType = VariadicBlock;
4293 CallType = VariadicFunction;
4296 checkCall(NDecl, Proto,
nullptr,
4307 VariadicCallType CallType = getVariadicCallType(
nullptr, Proto,
4309 checkCall(
nullptr, Proto,
nullptr,
4318 if (!llvm::isValidAtomicOrderingCABI(Ordering))
4321 auto OrderingCABI = (llvm::AtomicOrderingCABI)Ordering;
4323 case AtomicExpr::AO__c11_atomic_init:
4324 case AtomicExpr::AO__opencl_atomic_init:
4325 llvm_unreachable(
"There is no ordering argument for an init");
4327 case AtomicExpr::AO__c11_atomic_load:
4328 case AtomicExpr::AO__opencl_atomic_load:
4329 case AtomicExpr::AO__atomic_load_n:
4330 case AtomicExpr::AO__atomic_load:
4331 return OrderingCABI != llvm::AtomicOrderingCABI::release &&
4332 OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
4334 case AtomicExpr::AO__c11_atomic_store:
4335 case AtomicExpr::AO__opencl_atomic_store:
4336 case AtomicExpr::AO__atomic_store:
4337 case AtomicExpr::AO__atomic_store_n:
4338 return OrderingCABI != llvm::AtomicOrderingCABI::consume &&
4339 OrderingCABI != llvm::AtomicOrderingCABI::acquire &&
4340 OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
4349 CallExpr *TheCall = cast<CallExpr>(TheCallResult.
get());
4384 const unsigned NumForm = GNUCmpXchg + 1;
4385 const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 3, 4, 5, 6 };
4386 const unsigned NumVals[] = { 1, 0, 1, 1, 1, 1, 2, 2, 3 };
4394 static_assert(
sizeof(NumArgs)/
sizeof(NumArgs[0]) == NumForm
4395 &&
sizeof(NumVals)/
sizeof(NumVals[0]) == NumForm,
4396 "need to update code for modified forms");
4397 static_assert(AtomicExpr::AO__c11_atomic_init == 0 &&
4398 AtomicExpr::AO__c11_atomic_fetch_xor + 1 ==
4399 AtomicExpr::AO__atomic_load,
4400 "need to update code for modified C11 atomics");
4401 bool IsOpenCL = Op >= AtomicExpr::AO__opencl_atomic_init &&
4402 Op <= AtomicExpr::AO__opencl_atomic_fetch_max;
4403 bool IsC11 = (Op >= AtomicExpr::AO__c11_atomic_init &&
4404 Op <= AtomicExpr::AO__c11_atomic_fetch_xor) ||
4406 bool IsN = Op == AtomicExpr::AO__atomic_load_n ||
4407 Op == AtomicExpr::AO__atomic_store_n ||
4408 Op == AtomicExpr::AO__atomic_exchange_n ||
4409 Op == AtomicExpr::AO__atomic_compare_exchange_n;
4410 bool IsAddSub =
false;
4411 bool IsMinMax =
false;
4414 case AtomicExpr::AO__c11_atomic_init:
4415 case AtomicExpr::AO__opencl_atomic_init:
4419 case AtomicExpr::AO__c11_atomic_load:
4420 case AtomicExpr::AO__opencl_atomic_load:
4421 case AtomicExpr::AO__atomic_load_n:
4425 case AtomicExpr::AO__atomic_load:
4429 case AtomicExpr::AO__c11_atomic_store:
4430 case AtomicExpr::AO__opencl_atomic_store:
4431 case AtomicExpr::AO__atomic_store:
4432 case AtomicExpr::AO__atomic_store_n:
4436 case AtomicExpr::AO__c11_atomic_fetch_add:
4437 case AtomicExpr::AO__c11_atomic_fetch_sub:
4438 case AtomicExpr::AO__opencl_atomic_fetch_add:
4439 case AtomicExpr::AO__opencl_atomic_fetch_sub:
4440 case AtomicExpr::AO__opencl_atomic_fetch_min:
4441 case AtomicExpr::AO__opencl_atomic_fetch_max:
4442 case AtomicExpr::AO__atomic_fetch_add:
4443 case AtomicExpr::AO__atomic_fetch_sub:
4444 case AtomicExpr::AO__atomic_add_fetch:
4445 case AtomicExpr::AO__atomic_sub_fetch:
4448 case AtomicExpr::AO__c11_atomic_fetch_and:
4449 case AtomicExpr::AO__c11_atomic_fetch_or:
4450 case AtomicExpr::AO__c11_atomic_fetch_xor:
4451 case AtomicExpr::AO__opencl_atomic_fetch_and:
4452 case AtomicExpr::AO__opencl_atomic_fetch_or:
4453 case AtomicExpr::AO__opencl_atomic_fetch_xor:
4454 case AtomicExpr::AO__atomic_fetch_and:
4455 case AtomicExpr::AO__atomic_fetch_or:
4456 case AtomicExpr::AO__atomic_fetch_xor:
4457 case AtomicExpr::AO__atomic_fetch_nand:
4458 case AtomicExpr::AO__atomic_and_fetch:
4459 case AtomicExpr::AO__atomic_or_fetch:
4460 case AtomicExpr::AO__atomic_xor_fetch:
4461 case AtomicExpr::AO__atomic_nand_fetch:
4465 case AtomicExpr::AO__atomic_fetch_min:
4466 case AtomicExpr::AO__atomic_fetch_max:
4471 case AtomicExpr::AO__c11_atomic_exchange:
4472 case AtomicExpr::AO__opencl_atomic_exchange:
4473 case AtomicExpr::AO__atomic_exchange_n:
4477 case AtomicExpr::AO__atomic_exchange:
4481 case AtomicExpr::AO__c11_atomic_compare_exchange_strong:
4482 case AtomicExpr::AO__c11_atomic_compare_exchange_weak:
4483 case AtomicExpr::AO__opencl_atomic_compare_exchange_strong:
4484 case AtomicExpr::AO__opencl_atomic_compare_exchange_weak:
4488 case AtomicExpr::AO__atomic_compare_exchange:
4489 case AtomicExpr::AO__atomic_compare_exchange_n:
4494 unsigned AdjustedNumArgs = NumArgs[Form];
4495 if (IsOpenCL && Op != AtomicExpr::AO__opencl_atomic_init)
4498 if (TheCall->
getNumArgs() < AdjustedNumArgs) {
4499 Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
4500 << 0 << AdjustedNumArgs << TheCall->
getNumArgs()
4503 }
else if (TheCall->
getNumArgs() > AdjustedNumArgs) {
4505 diag::err_typecheck_call_too_many_args)
4506 << 0 << AdjustedNumArgs << TheCall->
getNumArgs()
4513 ExprResult ConvertedPtr = DefaultFunctionArrayLvalueConversion(Ptr);
4517 Ptr = ConvertedPtr.
get();
4520 Diag(DRE->getBeginLoc(), diag::err_atomic_builtin_must_be_pointer)
4530 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_atomic)
4536 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_non_const_atomic)
4542 }
else if (Form != Load && Form != LoadCopy) {
4544 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_non_const_pointer)
4551 if (Form == Arithmetic) {
4555 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_atomic_int_or_ptr)
4561 if (!BT || (BT->
getKind() != BuiltinType::Int &&
4562 BT->
getKind() != BuiltinType::UInt)) {
4563 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_int32_or_ptr);
4568 Diag(DRE->getBeginLoc(), diag::err_atomic_op_bitwise_needs_atomic_int)
4574 diag::err_incomplete_type)) {
4580 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_atomic_int_or_ptr)
4589 Diag(DRE->getBeginLoc(), diag::err_atomic_op_needs_trivial_copy)
4605 Diag(DRE->getBeginLoc(), diag::err_arc_atomic_ownership)
4617 if (Form == Copy || Form == LoadCopy || Form == GNUXchg ||
4619 ResultType = Context.
VoidTy;
4620 else if (Form == C11CmpXchg || Form == GNUCmpXchg)
4621 ResultType = Context.
BoolTy;
4626 bool IsPassedByAddress =
false;
4627 if (!IsC11 && !IsN) {
4629 IsPassedByAddress =
true;
4637 for (
unsigned i = 0; i != TheCall->
getNumArgs(); ++i) {
4639 if (i < NumVals[Form] + 1) {
4652 assert(Form != Load);
4653 if (Form == Init || (Form == Arithmetic && ValType->
isIntegerType()))
4655 else if (Form == Copy || Form == Xchg) {
4656 if (IsPassedByAddress)
4660 }
else if (Form == Arithmetic)
4670 AS = PtrTy->getPointeeType().getAddressSpace();
4679 if (IsPassedByAddress)
4704 SubExprs.push_back(Ptr);
4708 SubExprs.push_back(TheCall->
getArg(1));
4711 SubExprs.push_back(TheCall->
getArg(1));
4717 SubExprs.push_back(TheCall->
getArg(2));
4718 SubExprs.push_back(TheCall->
getArg(1));
4722 SubExprs.push_back(TheCall->
getArg(3));
4723 SubExprs.push_back(TheCall->
getArg(1));
4724 SubExprs.push_back(TheCall->
getArg(2));
4727 SubExprs.push_back(TheCall->
getArg(3));
4728 SubExprs.push_back(TheCall->
getArg(1));
4729 SubExprs.push_back(TheCall->
getArg(4));
4730 SubExprs.push_back(TheCall->
getArg(2));
4733 SubExprs.push_back(TheCall->
getArg(4));
4734 SubExprs.push_back(TheCall->
getArg(1));
4735 SubExprs.push_back(TheCall->
getArg(5));
4736 SubExprs.push_back(TheCall->
getArg(2));
4737 SubExprs.push_back(TheCall->
getArg(3));
4741 if (SubExprs.size() >= 2 && Form != Init) {
4742 llvm::APSInt Result(32);
4743 if (SubExprs[1]->isIntegerConstantExpr(Result, Context) &&
4745 Diag(SubExprs[1]->getBeginLoc(),
4746 diag::warn_atomic_op_has_invalid_memory_order)
4747 << SubExprs[1]->getSourceRange();
4752 llvm::APSInt Result(32);
4753 if (
Scope->isIntegerConstantExpr(Result, Context) &&
4754 !ScopeModel->isValid(Result.getZExtValue())) {
4755 Diag(
Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_synch_scope)
4756 <<
Scope->getSourceRange();
4758 SubExprs.push_back(
Scope);
4765 if ((Op == AtomicExpr::AO__c11_atomic_load ||
4766 Op == AtomicExpr::AO__c11_atomic_store ||
4767 Op == AtomicExpr::AO__opencl_atomic_load ||
4768 Op == AtomicExpr::AO__opencl_atomic_store ) &&
4771 << ((Op == AtomicExpr::AO__c11_atomic_load ||
4772 Op == AtomicExpr::AO__opencl_atomic_load)
4788 assert(Fn &&
"builtin call without direct callee!");
4811 Sema::SemaBuiltinAtomicOverloaded(
ExprResult TheCallResult) {
4819 Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args_at_least)
4830 ExprResult FirstArgResult = DefaultFunctionArrayLvalueConversion(FirstArg);
4833 FirstArg = FirstArgResult.
get();
4834 TheCall->
setArg(0, FirstArg);
4846 Diag(DRE->
getBeginLoc(), diag::err_atomic_builtin_must_be_pointer_intptr)
4881 #define BUILTIN_ROW(x) \ 4882 { Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \ 4883 Builtin::BI##x##_8, Builtin::BI##x##_16 } 4885 static const unsigned BuiltinIndices[][5] = {
4911 case 1: SizeIndex = 0;
break;
4912 case 2: SizeIndex = 1;
break;
4913 case 4: SizeIndex = 2;
break;
4914 case 8: SizeIndex = 3;
break;
4915 case 16: SizeIndex = 4;
break;
4926 unsigned BuiltinID = FDecl->getBuiltinID();
4927 unsigned BuiltinIndex, NumFixed = 1;
4928 bool WarnAboutSemanticsChange =
false;
4929 switch (BuiltinID) {
4930 default: llvm_unreachable(
"Unknown overloaded atomic builtin!");
4931 case Builtin::BI__sync_fetch_and_add:
4932 case Builtin::BI__sync_fetch_and_add_1:
4933 case Builtin::BI__sync_fetch_and_add_2:
4934 case Builtin::BI__sync_fetch_and_add_4:
4935 case Builtin::BI__sync_fetch_and_add_8:
4936 case Builtin::BI__sync_fetch_and_add_16:
4940 case Builtin::BI__sync_fetch_and_sub:
4941 case Builtin::BI__sync_fetch_and_sub_1:
4942 case Builtin::BI__sync_fetch_and_sub_2:
4943 case Builtin::BI__sync_fetch_and_sub_4:
4944 case Builtin::BI__sync_fetch_and_sub_8:
4945 case Builtin::BI__sync_fetch_and_sub_16:
4949 case Builtin::BI__sync_fetch_and_or:
4950 case Builtin::BI__sync_fetch_and_or_1:
4951 case Builtin::BI__sync_fetch_and_or_2:
4952 case Builtin::BI__sync_fetch_and_or_4:
4953 case Builtin::BI__sync_fetch_and_or_8:
4954 case Builtin::BI__sync_fetch_and_or_16:
4958 case Builtin::BI__sync_fetch_and_and:
4959 case Builtin::BI__sync_fetch_and_and_1:
4960 case Builtin::BI__sync_fetch_and_and_2:
4961 case Builtin::BI__sync_fetch_and_and_4:
4962 case Builtin::BI__sync_fetch_and_and_8:
4963 case Builtin::BI__sync_fetch_and_and_16:
4967 case Builtin::BI__sync_fetch_and_xor:
4968 case Builtin::BI__sync_fetch_and_xor_1:
4969 case Builtin::BI__sync_fetch_and_xor_2:
4970 case Builtin::BI__sync_fetch_and_xor_4:
4971 case Builtin::BI__sync_fetch_and_xor_8:
4972 case Builtin::BI__sync_fetch_and_xor_16:
4976 case Builtin::BI__sync_fetch_and_nand:
4977 case Builtin::BI__sync_fetch_and_nand_1:
4978 case Builtin::BI__sync_fetch_and_nand_2:
4979 case Builtin::BI__sync_fetch_and_nand_4:
4980 case Builtin::BI__sync_fetch_and_nand_8:
4981 case Builtin::BI__sync_fetch_and_nand_16:
4983 WarnAboutSemanticsChange =
true;
4986 case Builtin::BI__sync_add_and_fetch:
4987 case Builtin::BI__sync_add_and_fetch_1:
4988 case Builtin::BI__sync_add_and_fetch_2:
4989 case Builtin::BI__sync_add_and_fetch_4:
4990 case Builtin::BI__sync_add_and_fetch_8:
4991 case Builtin::BI__sync_add_and_fetch_16:
4995 case Builtin::BI__sync_sub_and_fetch:
4996 case Builtin::BI__sync_sub_and_fetch_1:
4997 case Builtin::BI__sync_sub_and_fetch_2:
4998 case Builtin::BI__sync_sub_and_fetch_4:
4999 case Builtin::BI__sync_sub_and_fetch_8:
5000 case Builtin::BI__sync_sub_and_fetch_16:
5004 case Builtin::BI__sync_and_and_fetch:
5005 case Builtin::BI__sync_and_and_fetch_1:
5006 case Builtin::BI__sync_and_and_fetch_2:
5007 case Builtin::BI__sync_and_and_fetch_4:
5008 case Builtin::BI__sync_and_and_fetch_8:
5009 case Builtin::BI__sync_and_and_fetch_16:
5013 case Builtin::BI__sync_or_and_fetch:
5014 case Builtin::BI__sync_or_and_fetch_1:
5015 case Builtin::BI__sync_or_and_fetch_2:
5016 case Builtin::BI__sync_or_and_fetch_4:
5017 case Builtin::BI__sync_or_and_fetch_8:
5018 case Builtin::BI__sync_or_and_fetch_16:
5022 case Builtin::BI__sync_xor_and_fetch:
5023 case Builtin::BI__sync_xor_and_fetch_1:
5024 case Builtin::BI__sync_xor_and_fetch_2:
5025 case Builtin::BI__sync_xor_and_fetch_4:
5026 case Builtin::BI__sync_xor_and_fetch_8:
5027 case Builtin::BI__sync_xor_and_fetch_16:
5031 case Builtin::BI__sync_nand_and_fetch:
5032 case Builtin::BI__sync_nand_and_fetch_1:
5033 case Builtin::BI__sync_nand_and_fetch_2:
5034 case Builtin::BI__sync_nand_and_fetch_4:
5035 case Builtin::BI__sync_nand_and_fetch_8:
5036 case Builtin::BI__sync_nand_and_fetch_16:
5038 WarnAboutSemanticsChange =
true;
5041 case Builtin::BI__sync_val_compare_and_swap:
5042 case Builtin::BI__sync_val_compare_and_swap_1:
5043 case Builtin::BI__sync_val_compare_and_swap_2:
5044 case Builtin::BI__sync_val_compare_and_swap_4:
5045 case Builtin::BI__sync_val_compare_and_swap_8:
5046 case Builtin::BI__sync_val_compare_and_swap_16:
5051 case Builtin::BI__sync_bool_compare_and_swap:
5052 case Builtin::BI__sync_bool_compare_and_swap_1:
5053 case Builtin::BI__sync_bool_compare_and_swap_2:
5054 case Builtin::BI__sync_bool_compare_and_swap_4:
5055 case Builtin::BI__sync_bool_compare_and_swap_8:
5056 case Builtin::BI__sync_bool_compare_and_swap_16:
5059 ResultType = Context.
BoolTy;
5062 case Builtin::BI__sync_lock_test_and_set:
5063 case Builtin::BI__sync_lock_test_and_set_1:
5064 case Builtin::BI__sync_lock_test_and_set_2:
5065 case Builtin::BI__sync_lock_test_and_set_4:
5066 case Builtin::BI__sync_lock_test_and_set_8:
5067 case Builtin::BI__sync_lock_test_and_set_16:
5071 case Builtin::BI__sync_lock_release:
5072 case Builtin::BI__sync_lock_release_1:
5073 case Builtin::BI__sync_lock_release_2:
5074 case Builtin::BI__sync_lock_release_4:
5075 case Builtin::BI__sync_lock_release_8:
5076 case Builtin::BI__sync_lock_release_16:
5079 ResultType = Context.
VoidTy;
5082 case Builtin::BI__sync_swap:
5083 case Builtin::BI__sync_swap_1:
5084 case Builtin::BI__sync_swap_2:
5085 case Builtin::BI__sync_swap_4:
5086 case Builtin::BI__sync_swap_8:
5087 case Builtin::BI__sync_swap_16:
5095 Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args_at_least)
5096 << 0 << 1 + NumFixed << TheCall->
getNumArgs()
5101 Diag(TheCall->
getEndLoc(), diag::warn_atomic_implicit_seq_cst)
5104 if (WarnAboutSemanticsChange) {
5105 Diag(TheCall->
getEndLoc(), diag::warn_sync_fetch_and_nand_semantics_change)
5111 unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
5114 if (NewBuiltinID == BuiltinID)
5115 NewBuiltinDecl = FDecl;
5120 LookupName(Res, TUScope,
true);
5121 assert(Res.getFoundDecl());
5122 NewBuiltinDecl = dyn_cast<
FunctionDecl>(Res.getFoundDecl());
5123 if (!NewBuiltinDecl)
5130 for (
unsigned i = 0; i != NumFixed; ++i) {
5165 ExprResult PromotedCall = ImpCastExprToType(NewDRE, CalleePtrTy,
5166 CK_BuiltinFnToFnPtr);
5174 return TheCallResult;
5189 assert((BuiltinID == Builtin::BI__builtin_nontemporal_store ||
5190 BuiltinID == Builtin::BI__builtin_nontemporal_load) &&
5191 "Unexpected nontemporal load/store builtin!");
5192 bool isStore = BuiltinID == Builtin::BI__builtin_nontemporal_store;
5193 unsigned numArgs = isStore ? 2 : 1;
5203 Expr *PointerArg = TheCall->
getArg(numArgs - 1);
5205 DefaultFunctionArrayLvalueConversion(PointerArg);
5209 PointerArg = PointerArgResult.
get();
5210 TheCall->
setArg(numArgs - 1, PointerArg);
5214 Diag(DRE->
getBeginLoc(), diag::err_nontemporal_builtin_must_be_pointer)
5227 diag::err_nontemporal_builtin_must_be_pointer_intfltptr_or_vector)
5234 return TheCallResult;
5239 Context, ValType,
false);
5240 ValArg = PerformCopyInitialization(Entity,
SourceLocation(), ValArg);
5246 return TheCallResult;
5253 bool Sema::CheckObjCString(
Expr *Arg) {
5257 if (!Literal || !Literal->
isAscii()) {
5258 Diag(Arg->
getBeginLoc(), diag::err_cfstring_literal_not_string_constant)
5264 StringRef String = Literal->
getString();
5265 unsigned NumBytes = String.size();
5267 const llvm::UTF8 *FromPtr = (
const llvm::UTF8 *)String.data();
5268 llvm::UTF16 *ToPtr = &ToBuf[0];
5270 llvm::ConversionResult Result =
5271 llvm::ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes, &ToPtr,
5272 ToPtr + NumBytes, llvm::strictConversion);
5274 if (Result != llvm::conversionOK)
5287 if (
auto *ObjcLiteral = dyn_cast<ObjCStringLiteral>(Arg)) {
5292 if (!Literal || (!Literal->isAscii() && !Literal->isUTF8())) {
5302 Result = PerformCopyInitialization(Entity,
SourceLocation(), Result);
5310 bool IsX64 = TT.getArch() == llvm::Triple::x86_64;
5311 bool IsAArch64 = TT.getArch() == llvm::Triple::aarch64;
5312 bool IsWindows = TT.isOSWindows();
5313 bool IsMSVAStart = BuiltinID == Builtin::BI__builtin_ms_va_start;
5314 if (IsX64 || IsAArch64) {
5317 CC = FD->getType()->getAs<
FunctionType>()->getCallConv();
5322 diag::err_ms_va_start_used_in_sysv_function);
5331 diag::err_va_start_used_in_wrong_abi_function)
5346 bool IsVariadic =
false;
5347 ArrayRef<ParmVarDecl *> Params;
5349 if (
auto *Block = dyn_cast<BlockDecl>(Caller)) {
5350 IsVariadic = Block->isVariadic();
5351 Params = Block->parameters();
5352 }
else if (
auto *FD = dyn_cast<FunctionDecl>(Caller)) {
5353 IsVariadic = FD->isVariadic();
5354 Params = FD->parameters();
5355 }
else if (
auto *MD = dyn_cast<ObjCMethodDecl>(Caller)) {
5356 IsVariadic = MD->isVariadic();
5358 Params = MD->parameters();
5359 }
else if (isa<CapturedDecl>(Caller)) {
5375 *LastParam = Params.empty() ? nullptr : Params.back();
5383 bool Sema::SemaBuiltinVAStart(
unsigned BuiltinID,
CallExpr *TheCall) {
5391 diag::err_typecheck_call_too_many_args)
5395 (*(TheCall->
arg_end() - 1))->getEndLoc());
5401 diag::err_typecheck_call_too_few_args_at_least)
5416 bool SecondArgIsLastNamedArgument =
false;
5423 bool IsCRegister =
false;
5425 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Arg)) {
5426 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {
5427 SecondArgIsLastNamedArgument = PV == LastParam;
5429 Type = PV->getType();
5430 ParamLoc = PV->getLocation();
5432 PV->getStorageClass() ==
SC_Register && !getLangOpts().CPlusPlus;
5436 if (!SecondArgIsLastNamedArgument)
5438 diag::warn_second_arg_of_va_start_not_last_named_param);
5451 unsigned Reason = 0;
5453 else if (IsCRegister) Reason = 2;
5454 Diag(Arg->
getBeginLoc(), diag::warn_va_start_type_is_undefined) << Reason;
5455 Diag(ParamLoc, diag::note_parameter_type) << Type;
5462 bool Sema::SemaBuiltinVAStartARMMicrosoft(
CallExpr *Call) {
5470 diag::err_typecheck_call_too_few_args_at_least)
5494 << Arg1->
getType() << ConstCharPtrTy << 1
5497 << 2 << Arg1->
getType() << ConstCharPtrTy;
5502 << Arg2->
getType() << SizeTy << 1
5505 << 3 << Arg2->
getType() << SizeTy;
5512 bool Sema::SemaBuiltinUnorderedCompare(
CallExpr *TheCall) {
5514 return Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
5518 diag::err_typecheck_call_too_many_args)
5521 (*(TheCall->
arg_end() - 1))->getEndLoc());
5528 QualType Res = UsualArithmeticConversions(OrigArg0, OrigArg1,
false);
5529 if (OrigArg0.isInvalid() || OrigArg1.
isInvalid())
5535 TheCall->
setArg(0, OrigArg0.get());
5538 if (OrigArg0.get()->isTypeDependent() || OrigArg1.
get()->isTypeDependent())
5544 return Diag(OrigArg0.get()->getBeginLoc(),
5545 diag::err_typecheck_call_invalid_ordered_compare)
5546 << OrigArg0.get()->getType() << OrigArg1.
get()->getType()
5548 OrigArg1.
get()->getEndLoc());
5557 bool Sema::SemaBuiltinFPClassification(
CallExpr *TheCall,
unsigned NumArgs) {
5559 return Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
5563 diag::err_typecheck_call_too_many_args)
5566 (*(TheCall->
arg_end() - 1))->getEndLoc());
5570 if (OrigArg->isTypeDependent())
5574 if (!OrigArg->getType()->isRealFloatingType())
5575 return Diag(OrigArg->getBeginLoc(),
5576 diag::err_typecheck_call_invalid_unary_fp)
5577 << OrigArg->getType() << OrigArg->getSourceRange();
5583 if (Cast->getCastKind() == CK_FloatingCast) {
5584 Expr *CastArg = Cast->getSubExpr();
5587 (Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) ||
5588 Cast->getType()->isSpecificBuiltinType(BuiltinType::Float) ||
5589 Cast->getType()->isSpecificBuiltinType(BuiltinType::LongDouble)) &&
5590 "promotion from float to either float, double, or long double is " 5591 "the only expected cast here");
5592 Cast->setSubExpr(
nullptr);
5593 TheCall->
setArg(NumArgs-1, CastArg);
5608 bool Sema::SemaBuiltinVSX(
CallExpr *TheCall) {
5609 unsigned ExpectedNumArgs = 3;
5612 diag::err_typecheck_call_too_few_args_at_least)
5613 << 0 << ExpectedNumArgs << TheCall->
getNumArgs()
5618 diag::err_typecheck_call_too_many_args_at_most)
5619 << 0 << ExpectedNumArgs << TheCall->
getNumArgs()
5626 diag::err_vsx_builtin_nonconstant_argument)
5636 if ((!Arg1Ty->isVectorType() && !Arg1Ty->isDependentType()) ||
5638 return Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
5646 return Diag(BuiltinLoc, diag::err_vec_builtin_incompatible_vector)
5665 diag::err_typecheck_call_too_few_args_at_least)
5673 unsigned numElements = 0;
5688 unsigned numResElements = TheCall->
getNumArgs() - 2;
5697 diag::err_vec_builtin_incompatible_vector)
5703 diag::err_vec_builtin_incompatible_vector)
5707 }
else if (numElements != numResElements) {
5714 for (
unsigned i = 2; i < TheCall->
getNumArgs(); i++) {
5719 llvm::APSInt Result(32);
5722 diag::err_shufflevector_nonconstant_argument)
5726 if (Result.isSigned() && Result.isAllOnesValue())
5729 if (Result.getActiveBits() > 64 || Result.getZExtValue() >= numElements*2)
5731 diag::err_shufflevector_argument_too_large)
5737 for (
unsigned i = 0, e = TheCall->
getNumArgs(); i != e; i++) {
5738 exprs.push_back(TheCall->
getArg(i));
5739 TheCall->
setArg(i,
nullptr);
5758 diag::err_convertvector_non_vector)
5762 diag::err_convertvector_non_vector_type));
5767 if (SrcElts != DstElts)
5769 diag::err_convertvector_incompatible_vector)
5773 return new (Context)
5780 bool Sema::SemaBuiltinPrefetch(
CallExpr *TheCall) {
5785 diag::err_typecheck_call_too_many_args_at_most)
5790 for (
unsigned i = 1; i != NumArgs; ++i)
5791 if (SemaBuiltinConstantArgRange(TheCall, i, 0, i == 1 ? 1 : 3))
5800 bool Sema::SemaBuiltinAssume(
CallExpr *TheCall) {
5815 bool Sema::SemaBuiltinAllocaWithAlign(
CallExpr *TheCall) {
5821 if (
const auto *UE =
5830 if (!Result.isPowerOf2())
5831 return Diag(TheCall->
getBeginLoc(), diag::err_alignment_not_power_of_two)
5848 bool Sema::SemaBuiltinAssumeAligned(
CallExpr *TheCall) {
5853 diag::err_typecheck_call_too_many_args_at_most)
5861 llvm::APSInt Result;
5862 if (SemaBuiltinConstantArg(TheCall, 1, Result))
5865 if (!Result.isPowerOf2())
5866 return Diag(TheCall->
getBeginLoc(), diag::err_alignment_not_power_of_two)
5875 if (Arg.isInvalid())
return true;
5876 TheCall->
setArg(2, Arg.get());
5882 bool Sema::SemaBuiltinOSLogFormat(
CallExpr *TheCall) {
5883 unsigned BuiltinID =
5884 cast<FunctionDecl>(TheCall->
getCalleeDecl())->getBuiltinID();
5885 bool IsSizeCall = BuiltinID == Builtin::BI__builtin_os_log_format_buffer_size;
5888 unsigned NumRequiredArgs = IsSizeCall ? 1 : 2;
5889 if (NumArgs < NumRequiredArgs) {
5890 return Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
5891 << 0 << NumRequiredArgs << NumArgs
5894 if (NumArgs >= NumRequiredArgs + 0x100) {
5896 diag::err_typecheck_call_too_many_args_at_most)
5897 << 0 << (NumRequiredArgs + 0xff) << NumArgs
5908 if (Arg.isInvalid())
5910 TheCall->
setArg(i, Arg.get());
5915 unsigned FormatIdx = i;
5925 unsigned FirstDataArg = i;
5926 while (i < NumArgs) {
5927 ExprResult Arg = DefaultVariadicArgumentPromotion(
5928 TheCall->
getArg(i), VariadicFunction,
nullptr);
5933 return Diag(Arg.
get()->getEndLoc(), diag::err_os_log_argument_too_big)
5944 llvm::SmallBitVector CheckedVarArgs(NumArgs,
false);
5946 bool Success = CheckFormatArguments(
5947 Args,
false, FormatIdx, FirstDataArg, FST_OSLog,
5964 bool Sema::SemaBuiltinConstantArg(
CallExpr *TheCall,
int ArgNum,
5965 llvm::APSInt &Result) {
5973 return Diag(TheCall->
getBeginLoc(), diag::err_constant_integer_arg_type)
5981 bool Sema::SemaBuiltinConstantArgRange(
CallExpr *TheCall,
int ArgNum,
5982 int Low,
int High,
bool RangeIsError) {
5983 llvm::APSInt Result;
5991 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
5994 if (Result.getSExtValue() < Low || Result.getSExtValue() > High) {
6001 DiagRuntimeBehavior(TheCall->
getBeginLoc(), TheCall,
6002 PDiag(diag::warn_argument_invalid_range)
6003 << Result.toString(10) << Low << High
6012 bool Sema::SemaBuiltinConstantArgMultiple(
CallExpr *TheCall,
int ArgNum,
6014 llvm::APSInt Result;
6022 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
6025 if (Result.getSExtValue() % Num != 0)
6034 bool Sema::SemaBuiltinARMSpecialReg(
unsigned BuiltinID,
CallExpr *TheCall,
6035 int ArgNum,
unsigned ExpectedFieldNum,
6037 bool IsARMBuiltin = BuiltinID == ARM::BI__builtin_arm_rsr64 ||
6038 BuiltinID == ARM::BI__builtin_arm_wsr64 ||
6039 BuiltinID == ARM::BI__builtin_arm_rsr ||
6040 BuiltinID == ARM::BI__builtin_arm_rsrp ||
6041 BuiltinID == ARM::BI__builtin_arm_wsr ||
6042 BuiltinID == ARM::BI__builtin_arm_wsrp;
6043 bool IsAArch64Builtin = BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
6044 BuiltinID == AArch64::BI__builtin_arm_wsr64 ||
6045 BuiltinID == AArch64::BI__builtin_arm_rsr ||
6046 BuiltinID == AArch64::BI__builtin_arm_rsrp ||
6047 BuiltinID == AArch64::BI__builtin_arm_wsr ||
6048 BuiltinID == AArch64::BI__builtin_arm_wsrp;
6049 assert((IsARMBuiltin || IsAArch64Builtin) &&
"Unexpected ARM builtin.");
6058 return Diag(TheCall->
getBeginLoc(), diag::err_expr_not_string_literal)
6064 Reg.split(Fields,
":");
6066 if (Fields.size() != ExpectedFieldNum && !(AllowName && Fields.size() == 1))
6074 if (Fields.size() > 1) {
6075 bool FiveFields = Fields.size() == 5;
6077 bool ValidString =
true;
6079 ValidString &= Fields[0].startswith_lower(
"cp") ||
6080 Fields[0].startswith_lower(
"p");
6083 Fields[0].drop_front(Fields[0].startswith_lower(
"cp") ? 2 : 1);
6085 ValidString &= Fields[2].startswith_lower(
"c");
6087 Fields[2] = Fields[2].drop_front(1);
6090 ValidString &= Fields[3].startswith_lower(
"c");
6092 Fields[3] = Fields[3].drop_front(1);
6098 Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 15, 15, 7});
6100 Ranges.append({15, 7, 15});
6102 for (
unsigned i=0; i<Fields.size(); ++i) {
6104 ValidString &= !Fields[i].getAsInteger(10, IntField);
6105 ValidString &= (IntField >= 0 && IntField <= Ranges[i]);
6111 }
else if (IsAArch64Builtin && Fields.size() == 1) {
6121 std::string RegLower = Reg.lower();
6122 if (RegLower !=
"spsel" && RegLower !=
"daifset" && RegLower !=
"daifclr" &&
6123 RegLower !=
"pan" && RegLower !=
"uao")
6126 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
6135 bool Sema::SemaBuiltinLongjmp(
CallExpr *TheCall) {
6137 return Diag(TheCall->
getBeginLoc(), diag::err_builtin_longjmp_unsupported)
6141 llvm::APSInt Result;
6144 if (SemaBuiltinConstantArg(TheCall, 1, Result))
6148 return Diag(TheCall->
getBeginLoc(), diag::err_builtin_longjmp_invalid_val)
6156 bool Sema::SemaBuiltinSetjmp(
CallExpr *TheCall) {
6158 return Diag(TheCall->
getBeginLoc(), diag::err_builtin_setjmp_unsupported)
6165 class UncoveredArgHandler {
6166 enum { Unknown = -1, AllCovered = -2 };
6168 signed FirstUncoveredArg = Unknown;
6172 UncoveredArgHandler() =
default;
6174 bool hasUncoveredArg()
const {
6175 return (FirstUncoveredArg >= 0);
6178 unsigned getUncoveredArg()
const {
6179 assert(hasUncoveredArg() &&
"no uncovered argument");
6180 return FirstUncoveredArg;
6183 void setAllCovered() {
6186 DiagnosticExprs.clear();
6187 FirstUncoveredArg = AllCovered;
6190 void Update(
signed NewFirstUncoveredArg,
const Expr *StrExpr) {
6191 assert(NewFirstUncoveredArg >= 0 &&
"Outside range");
6194 if (FirstUncoveredArg == AllCovered)
6199 if (NewFirstUncoveredArg == FirstUncoveredArg)
6200 DiagnosticExprs.push_back(StrExpr);
6201 else if (NewFirstUncoveredArg > FirstUncoveredArg) {
6202 DiagnosticExprs.clear();
6203 DiagnosticExprs.push_back(StrExpr);
6204 FirstUncoveredArg = NewFirstUncoveredArg;
6208 void Diagnose(
Sema &S,
bool IsFunctionCall,
const Expr *ArgExpr);
6213 SLCT_UncheckedLiteral,
6221 bool AddendIsRight) {
6222 unsigned BitWidth = Offset.getBitWidth();
6223 unsigned AddendBitWidth = Addend.getBitWidth();
6225 if (Addend.isUnsigned()) {
6226 Addend = Addend.zext(++AddendBitWidth);
6227 Addend.setIsSigned(
true);
6230 if (AddendBitWidth > BitWidth) {
6231 Offset = Offset.sext(AddendBitWidth);
6232 BitWidth = AddendBitWidth;
6233 }
else if (BitWidth > AddendBitWidth) {
6234 Addend = Addend.sext(BitWidth);
6238 llvm::APSInt ResOffset =
Offset;
6239 if (BinOpKind == BO_Add)
6240 ResOffset = Offset.sadd_ov(Addend, Ov);
6242 assert(AddendIsRight && BinOpKind == BO_Sub &&
6243 "operator must be add or sub with addend on the right");
6244 ResOffset = Offset.ssub_ov(Addend, Ov);
6251 "index (intermediate) result too big");
6252 Offset = Offset.sext(2 * BitWidth);
6253 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
6265 class FormatStringLiteral {
6270 FormatStringLiteral(
const StringLiteral *fexpr, int64_t Offset = 0)
6271 : FExpr(fexpr),
Offset(Offset) {}
6273 StringRef getString()
const {
6274 return FExpr->
getString().drop_front(Offset);
6277 unsigned getByteLength()
const {
6288 bool isAscii()
const {
return FExpr->
isAscii(); }
6289 bool isWide()
const {
return FExpr->
isWide(); }
6290 bool isUTF8()
const {
return FExpr->
isUTF8(); }
6291 bool isUTF16()
const {
return FExpr->
isUTF16(); }
6292 bool isUTF32()
const {
return FExpr->
isUTF32(); }
6293 bool isPascal()
const {
return FExpr->
isPascal(); }
6298 unsigned *StartTokenByteOffset =
nullptr)
const {
6300 StartToken, StartTokenByteOffset);
6313 const Expr *OrigFormatExpr,
6314 ArrayRef<const Expr *> Args,
6315 bool HasVAListArg,
unsigned format_idx,
6316 unsigned firstDataArg,
6318 bool inFunctionCall,
6320 llvm::SmallBitVector &CheckedVarArgs,
6321 UncoveredArgHandler &UncoveredArg);
6329 bool HasVAListArg,
unsigned format_idx,
6332 llvm::SmallBitVector &CheckedVarArgs,
6333 UncoveredArgHandler &UncoveredArg,
6336 assert(Offset.isSigned() &&
"invalid offset");
6339 return SLCT_NotALiteral;
6348 return SLCT_UncheckedLiteral;
6351 case Stmt::BinaryConditionalOperatorClass:
6352 case Stmt::ConditionalOperatorClass: {
6356 cast<AbstractConditionalOperator>(E);
6361 bool CheckLeft =
true, CheckRight =
true;
6377 Left = SLCT_UncheckedLiteral;
6380 HasVAListArg, format_idx, firstDataArg,
6381 Type, CallType, InFunctionCall,
6382 CheckedVarArgs, UncoveredArg,
Offset);
6383 if (Left == SLCT_NotALiteral || !CheckRight) {
6390 HasVAListArg, format_idx, firstDataArg,
6391 Type, CallType, InFunctionCall, CheckedVarArgs,
6394 return (CheckLeft && Left < Right) ? Left : Right;
6397 case Stmt::ImplicitCastExprClass:
6398 E = cast<ImplicitCastExpr>(E)->getSubExpr();
6401 case Stmt::OpaqueValueExprClass:
6402 if (
const Expr *src = cast<OpaqueValueExpr>(E)->getSourceExpr()) {
6406 return SLCT_NotALiteral;
6408 case Stmt::PredefinedExprClass:
6412 return SLCT_UncheckedLiteral;
6414 case Stmt::DeclRefExprClass: {
6420 bool isConstant =
false;
6424 isConstant = AT->getElementType().isConstant(S.
Context);
6427 PT->getPointeeType().isConstant(S.
Context);
6435 if (
const Expr *Init = VD->getAnyInitializer()) {
6437 if (
const InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
6438 if (InitList->isStringLiteralInit())
6439 Init = InitList->getInit(0)->IgnoreParenImpCasts();
6442 HasVAListArg, format_idx,
6443 firstDataArg, Type, CallType,
6444 false, CheckedVarArgs,
6445 UncoveredArg, Offset);
6464 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(VD)) {
6465 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(PV->getDeclContext())) {
6466 int PVIndex = PV->getFunctionScopeIndex() + 1;
6467 for (
const auto *PVFormat : ND->specific_attrs<FormatAttr>()) {
6470 if (MD->isInstance())
6474 if (PVIndex == PVFormat->getFormatIdx() &&
6476 return SLCT_UncheckedLiteral;
6483 return SLCT_NotALiteral;
6486 case Stmt::CallExprClass:
6487 case Stmt::CXXMemberCallExprClass: {
6488 const CallExpr *CE = cast<CallExpr>(E);
6490 bool IsFirst =
true;
6492 for (
const auto *FA : ND->specific_attrs<FormatArgAttr>()) {
6493 const Expr *Arg = CE->
getArg(FA->getFormatIdx().getASTIndex());
6495 S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
6496 CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
6498 CommonResult = Result;
6503 return CommonResult;
6505 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
6506 unsigned BuiltinID = FD->getBuiltinID();
6507 if (BuiltinID == Builtin::BI__builtin___CFStringMakeConstantString ||
6508 BuiltinID == Builtin::BI__builtin___NSStringMakeConstantString) {
6511 HasVAListArg, format_idx,
6512 firstDataArg, Type, CallType,
6513 InFunctionCall, CheckedVarArgs,
6514 UncoveredArg, Offset);
6519 return SLCT_NotALiteral;
6521 case Stmt::ObjCMessageExprClass: {
6522 const auto *ME = cast<ObjCMessageExpr>(E);
6523 if (
const auto *ND = ME->getMethodDecl()) {
6524 if (
const auto *FA = ND->getAttr<FormatArgAttr>()) {
6525 const Expr *Arg = ME->getArg(FA->getFormatIdx().getASTIndex());
6527 S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
6528 CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
6532 return SLCT_NotALiteral;
6534 case Stmt::ObjCStringLiteralClass:
6535 case Stmt::StringLiteralClass: {
6541 StrE = cast<StringLiteral>(E);
6544 if (Offset.isNegative() || Offset > StrE->
getLength()) {
6547 return SLCT_NotALiteral;
6549 FormatStringLiteral FStr(StrE, Offset.sextOrTrunc(64).getSExtValue());
6551 firstDataArg, Type, InFunctionCall, CallType,
6552 CheckedVarArgs, UncoveredArg);
6553 return SLCT_CheckedLiteral;
6556 return SLCT_NotALiteral;
6558 case Stmt::BinaryOperatorClass: {
6568 if (LIsInt != RIsInt) {
6572 if (BinOpKind == BO_Add) {
6585 return SLCT_NotALiteral;
6587 case Stmt::UnaryOperatorClass: {
6590 if (UnaOp->
getOpcode() == UO_AddrOf && ASE) {
6592 if (ASE->getRHS()->EvaluateAsInt(IndexResult, S.
Context)) {
6600 return SLCT_NotALiteral;
6604 return SLCT_NotALiteral;
6609 return llvm::StringSwitch<FormatStringType>(Format->getType()->getName())
6610 .Case(
"scanf", FST_Scanf)
6611 .Cases(
"printf",
"printf0", FST_Printf)
6612 .Cases(
"NSString",
"CFString", FST_NSString)
6613 .Case(
"strftime", FST_Strftime)
6614 .Case(
"strfmon", FST_Strfmon)
6615 .Cases(
"kprintf",
"cmn_err",
"vcmn_err",
"zcmn_err", FST_Kprintf)
6616 .Case(
"freebsd_kprintf", FST_FreeBSDKPrintf)
6617 .Case(
"os_trace", FST_OSLog)
6618 .Case(
"os_log", FST_OSLog)
6619 .Default(FST_Unknown);
6625 bool Sema::CheckFormatArguments(
const FormatAttr *Format,
6630 llvm::SmallBitVector &CheckedVarArgs) {
6631 FormatStringInfo FSI;
6632 if (getFormatStringInfo(Format, IsCXXMember, &FSI))
6633 return CheckFormatArguments(Args, FSI.HasVAListArg, FSI.FormatIdx,
6634 FSI.FirstDataArg, GetFormatStringType(Format),
6635 CallType, Loc, Range, CheckedVarArgs);
6640 bool HasVAListArg,
unsigned format_idx,
6644 llvm::SmallBitVector &CheckedVarArgs) {
6646 if (format_idx >= Args.size()) {
6647 Diag(Loc, diag::warn_missing_format_string) << Range;
6651 const Expr *OrigFormatExpr = Args[format_idx]->IgnoreParenCasts();
6665 UncoveredArgHandler UncoveredArg;
6668 format_idx, firstDataArg,
Type, CallType,
6669 true, CheckedVarArgs,
6671 llvm::APSInt(64,
false) = 0);
6674 if (UncoveredArg.hasUncoveredArg()) {
6675 unsigned ArgIdx = UncoveredArg.getUncoveredArg() + firstDataArg;
6676 assert(ArgIdx < Args.size() &&
"ArgIdx outside bounds");
6677 UncoveredArg.Diagnose(*
this,
true, Args[ArgIdx]);
6680 if (CT != SLCT_NotALiteral)
6682 return CT == SLCT_CheckedLiteral;
6686 if (
Type == FST_Strftime)
6694 if (
Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
6699 if (Args.size() == firstDataArg) {
6700 Diag(FormatLoc, diag::warn_format_nonliteral_noargs)
6706 case FST_FreeBSDKPrintf:
6708 Diag(FormatLoc, diag::note_format_security_fixit)
6712 Diag(FormatLoc, diag::note_format_security_fixit)
6717 Diag(FormatLoc, diag::warn_format_nonliteral)
6728 const FormatStringLiteral *FExpr;
6729 const Expr *OrigFormatExpr;
6731 const unsigned FirstDataArg;
6732 const unsigned NumDataArgs;
6734 const bool HasVAListArg;
6737 llvm::SmallBitVector CoveredArgs;
6738 bool usesPositionalArgs =
false;
6739 bool atFirstArg =
true;
6740 bool inFunctionCall;
6742 llvm::SmallBitVector &CheckedVarArgs;
6743 UncoveredArgHandler &UncoveredArg;
6746 CheckFormatHandler(
Sema &s,
const FormatStringLiteral *fexpr,
6747 const Expr *origFormatExpr,
6749 unsigned numDataArgs,
const char *beg,
bool hasVAListArg,
6752 llvm::SmallBitVector &CheckedVarArgs,
6753 UncoveredArgHandler &UncoveredArg)
6754 : S(s), FExpr(fexpr), OrigFormatExpr(origFormatExpr), FSType(type),
6755 FirstDataArg(firstDataArg), NumDataArgs(numDataArgs), Beg(beg),
6756 HasVAListArg(hasVAListArg), Args(Args), FormatIdx(formatIdx),
6757 inFunctionCall(inFunctionCall), CallType(callType),
6758 CheckedVarArgs(CheckedVarArgs), UncoveredArg(UncoveredArg) {
6759 CoveredArgs.resize(numDataArgs);
6760 CoveredArgs.reset();
6763 void DoneProcessing();
6765 void HandleIncompleteSpecifier(
const char *startSpecifier,
6766 unsigned specifierLen)
override;
6768 void HandleInvalidLengthModifier(
6771 const char *startSpecifier,
unsigned specifierLen,
6774 void HandleNonStandardLengthModifier(
6776 const char *startSpecifier,
unsigned specifierLen);
6778 void HandleNonStandardConversionSpecifier(
6780 const char *startSpecifier,
unsigned specifierLen);
6782 void HandlePosition(
const char *startPos,
unsigned posLen)
override;
6784 void HandleInvalidPosition(
const char *startSpecifier,
6785 unsigned specifierLen,
6788 void HandleZeroPosition(
const char *startPos,
unsigned posLen)
override;
6790 void HandleNullChar(
const char *nullCharacter)
override;
6792 template <
typename Range>
6794 EmitFormatDiagnostic(
Sema &S,
bool inFunctionCall,
const Expr *ArgumentExpr,
6796 bool IsStringLocation, Range StringRange,
6800 bool HandleInvalidConversionSpecifier(
unsigned argIndex,
SourceLocation Loc,
6801 const char *startSpec,
6802 unsigned specifierLen,
6803 const char *csStart,
unsigned csLen);
6806 const char *startSpec,
6807 unsigned specifierLen);
6811 unsigned specifierLen);
6814 const Expr *getDataArg(
unsigned i)
const;
6818 const char *startSpecifier,
unsigned specifierLen,
6821 template <
typename Range>
6823 bool IsStringLocation, Range StringRange,
6829 SourceRange CheckFormatHandler::getFormatStringRange() {
6834 getSpecifierRange(
const char *startSpecifier,
unsigned specifierLen) {
6844 SourceLocation CheckFormatHandler::getLocationOfByte(
const char *x) {
6849 void CheckFormatHandler::HandleIncompleteSpecifier(
const char *startSpecifier,
6850 unsigned specifierLen){
6851 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_incomplete_specifier),
6852 getLocationOfByte(startSpecifier),
6854 getSpecifierRange(startSpecifier, specifierLen));
6857 void CheckFormatHandler::HandleInvalidLengthModifier(
6860 const char *startSpecifier,
unsigned specifierLen,
unsigned DiagID) {
6861 using namespace analyze_format_string;
6864 CharSourceRange LMRange = getSpecifierRange(LM.getStart(), LM.getLength());
6869 EmitFormatDiagnostic(S.
PDiag(DiagID) << LM.toString() << CS.
toString(),
6870 getLocationOfByte(LM.getStart()),
6872 getSpecifierRange(startSpecifier, specifierLen));
6874 S.
Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
6875 << FixedLM->toString()
6880 if (DiagID == diag::warn_format_nonsensical_length)
6883 EmitFormatDiagnostic(S.
PDiag(DiagID) << LM.toString() << CS.
toString(),
6884 getLocationOfByte(LM.getStart()),
6886 getSpecifierRange(startSpecifier, specifierLen),
6891 void CheckFormatHandler::HandleNonStandardLengthModifier(
6893 const char *startSpecifier,
unsigned specifierLen) {
6894 using namespace analyze_format_string;
6897 CharSourceRange LMRange = getSpecifierRange(LM.getStart(), LM.getLength());
6902 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
6903 << LM.toString() << 0,
6904 getLocationOfByte(LM.getStart()),
6906 getSpecifierRange(startSpecifier, specifierLen));
6908 S.
Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
6909 << FixedLM->toString()
6913 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
6914 << LM.toString() << 0,
6915 getLocationOfByte(LM.getStart()),
6917 getSpecifierRange(startSpecifier, specifierLen));
6921 void CheckFormatHandler::HandleNonStandardConversionSpecifier(
6923 const char *startSpecifier,
unsigned specifierLen) {
6924 using namespace analyze_format_string;
6929 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
6933 getSpecifierRange(startSpecifier, specifierLen));
6936 S.
Diag(getLocationOfByte(CS.
getStart()), diag::note_format_fix_specifier)
6937 << FixedCS->toString()
6940 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
6944 getSpecifierRange(startSpecifier, specifierLen));
6948 void CheckFormatHandler::HandlePosition(
const char *startPos,
6950 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard_positional_arg),
6951 getLocationOfByte(startPos),
6953 getSpecifierRange(startPos, posLen));
6957 CheckFormatHandler::HandleInvalidPosition(
const char *startPos,
unsigned posLen,
6959 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_positional_specifier)
6961 getLocationOfByte(startPos),
true,
6962 getSpecifierRange(startPos, posLen));
6965 void CheckFormatHandler::HandleZeroPosition(
const char *startPos,
6967 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_zero_positional_specifier),
6968 getLocationOfByte(startPos),
6970 getSpecifierRange(startPos, posLen));
6973 void CheckFormatHandler::HandleNullChar(
const char *nullCharacter) {
6974 if (!isa<ObjCStringLiteral>(OrigFormatExpr)) {
6976 EmitFormatDiagnostic(
6977 S.
PDiag(diag::warn_printf_format_string_contains_null_char),
6978 getLocationOfByte(nullCharacter),
true,
6979 getFormatStringRange());
6985 const Expr *CheckFormatHandler::getDataArg(
unsigned i)
const {
6986 return Args[FirstDataArg + i];
6989 void CheckFormatHandler::DoneProcessing() {
6992 if (!HasVAListArg) {
6995 signed notCoveredArg = CoveredArgs.find_first();
6996 if (notCoveredArg >= 0) {
6997 assert((
unsigned)notCoveredArg < NumDataArgs);
6998 UncoveredArg.Update(notCoveredArg, OrigFormatExpr);
7000 UncoveredArg.setAllCovered();
7005 void UncoveredArgHandler::Diagnose(
Sema &S,
bool IsFunctionCall,
7006 const Expr *ArgExpr) {
7007 assert(hasUncoveredArg() && DiagnosticExprs.size() > 0 &&
7019 for (
auto E : DiagnosticExprs)
7022 CheckFormatHandler::EmitFormatDiagnostic(
7023 S, IsFunctionCall, DiagnosticExprs[0],
7029 CheckFormatHandler::HandleInvalidConversionSpecifier(
unsigned argIndex,
7031 const char *startSpec,
7032 unsigned specifierLen,
7033 const char *csStart,
7035 bool keepGoing =
true;
7036 if (argIndex < NumDataArgs) {
7039 CoveredArgs.set(argIndex);
7055 std::string CodePointStr;
7056 if (!llvm::sys::locale::isPrint(*csStart)) {
7057 llvm::UTF32 CodePoint;
7058 const llvm::UTF8 **B =
reinterpret_cast<const llvm::UTF8 **
>(&csStart);
7059 const llvm::UTF8 *E =
7060 reinterpret_cast<const llvm::UTF8 *
>(csStart + csLen);
7061 llvm::ConversionResult Result =
7062 llvm::convertUTF8Sequence(B, E, &CodePoint, llvm::strictConversion);
7064 if (Result != llvm::conversionOK) {
7065 unsigned char FirstChar = *csStart;
7066 CodePoint = (llvm::UTF32)FirstChar;
7069 llvm::raw_string_ostream OS(CodePointStr);
7070 if (CodePoint < 256)
7071 OS <<
"\\x" << llvm::format(
"%02x", CodePoint);
7072 else if (CodePoint <= 0xFFFF)
7073 OS <<
"\\u" << llvm::format(
"%04x", CodePoint);
7075 OS <<
"\\U" << llvm::format(
"%08x", CodePoint);
7077 Specifier = CodePointStr;
7080 EmitFormatDiagnostic(
7082 true, getSpecifierRange(startSpec, specifierLen));
7088 CheckFormatHandler::HandlePositionalNonpositionalArgs(
SourceLocation Loc,
7089 const char *startSpec,
7090 unsigned specifierLen) {
7091 EmitFormatDiagnostic(
7092 S.
PDiag(diag::warn_format_mix_positional_nonpositional_args),
7093 Loc,
true, getSpecifierRange(startSpec, specifierLen));
7097 CheckFormatHandler::CheckNumArgs(
7100 const char *startSpecifier,
unsigned specifierLen,
unsigned argIndex) {
7102 if (argIndex >= NumDataArgs) {
7104 ? (S.
PDiag(diag::warn_printf_positional_arg_exceeds_data_args)
7105 << (argIndex+1) << NumDataArgs)
7106 : S.
PDiag(diag::warn_printf_insufficient_data_args);
7107 EmitFormatDiagnostic(
7108 PDiag, getLocationOfByte(CS.
getStart()),
true,
7109 getSpecifierRange(startSpecifier, specifierLen));
7113 UncoveredArg.setAllCovered();
7119 template<
typename Range>
7122 bool IsStringLocation,
7125 EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag,
7126 Loc, IsStringLocation, StringRange, FixIt);
7156 template <
typename Range>
7157 void CheckFormatHandler::EmitFormatDiagnostic(
7158 Sema &S,
bool InFunctionCall,
const Expr *ArgumentExpr,
7161 if (InFunctionCall) {
7166 S.
Diag(IsStringLocation ? ArgumentExpr->
getExprLoc() : Loc, PDiag)
7170 S.
Diag(IsStringLocation ? Loc : StringRange.getBegin(),
7171 diag::note_format_string_defined);
7173 Note << StringRange;
7182 class CheckPrintfHandler :
public CheckFormatHandler {
7184 CheckPrintfHandler(
Sema &s,
const FormatStringLiteral *fexpr,
7185 const Expr *origFormatExpr,
7187 unsigned numDataArgs,
bool isObjC,
const char *beg,
7189 unsigned formatIdx,
bool inFunctionCall,
7191 llvm::SmallBitVector &CheckedVarArgs,
7192 UncoveredArgHandler &UncoveredArg)
7193 : CheckFormatHandler(s, fexpr, origFormatExpr, type, firstDataArg,
7194 numDataArgs, beg, hasVAListArg, Args, formatIdx,
7195 inFunctionCall, CallType, CheckedVarArgs,
7201 bool allowsObjCArg()
const {
7206 bool HandleInvalidPrintfConversionSpecifier(
7208 const char *startSpecifier,
7209 unsigned specifierLen)
override;
7211 void handleInvalidMaskType(StringRef MaskType)
override;
7214 const char *startSpecifier,
7215 unsigned specifierLen)
override;
7217 const char *StartSpecifier,
7218 unsigned SpecifierLen,
7222 const char *startSpecifier,
unsigned specifierLen);
7226 const char *startSpecifier,
unsigned specifierLen);
7229 const char *startSpecifier,
unsigned specifierLen);
7233 const char *startSpecifier,
unsigned specifierLen);
7237 void HandleEmptyObjCModifierFlag(
const char *startFlag,
7238 unsigned flagLen)
override;
7240 void HandleInvalidObjCModifierFlag(
const char *startFlag,
7241 unsigned flagLen)
override;
7243 void HandleObjCFlagsWithNonObjCConversion(
const char *flagsStart,
7244 const char *flagsEnd,
7245 const char *conversionPosition)
7251 bool CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier(
7253 const char *startSpecifier,
7254 unsigned specifierLen) {
7258 return HandleInvalidConversionSpecifier(FS.
getArgIndex(),
7260 startSpecifier, specifierLen,
7264 void CheckPrintfHandler::handleInvalidMaskType(StringRef MaskType) {
7265 S.
Diag(getLocationOfByte(MaskType.data()), diag::err_invalid_mask_type_size);
7268 bool CheckPrintfHandler::HandleAmount(
7270 unsigned k,
const char *startSpecifier,
7271 unsigned specifierLen) {
7273 if (!HasVAListArg) {
7275 if (argIndex >= NumDataArgs) {
7276 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_asterisk_missing_arg)
7280 getSpecifierRange(startSpecifier, specifierLen));
7290 CoveredArgs.set(argIndex);
7291 const Expr *Arg = getDataArg(argIndex);
7301 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_asterisk_wrong_type)
7306 getSpecifierRange(startSpecifier, specifierLen));
7316 void CheckPrintfHandler::HandleInvalidAmount(
7320 const char *startSpecifier,
7321 unsigned specifierLen) {
7331 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_nonsensical_optional_amount)
7335 getSpecifierRange(startSpecifier, specifierLen),
7341 const char *startSpecifier,
7342 unsigned specifierLen) {
7346 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_nonsensical_flag)
7350 getSpecifierRange(startSpecifier, specifierLen),
7355 void CheckPrintfHandler::HandleIgnoredFlag(
7359 const char *startSpecifier,
7360 unsigned specifierLen) {
7362 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_ignored_flag)
7366 getSpecifierRange(startSpecifier, specifierLen),
7368 getSpecifierRange(ignoredFlag.
getPosition(), 1)));
7371 void CheckPrintfHandler::HandleEmptyObjCModifierFlag(
const char *startFlag,
7374 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_empty_objc_flag),
7375 getLocationOfByte(startFlag),
7377 getSpecifierRange(startFlag, flagLen));
7380 void CheckPrintfHandler::HandleInvalidObjCModifierFlag(
const char *startFlag,
7383 auto Range = getSpecifierRange(startFlag, flagLen);
7384 StringRef flag(startFlag, flagLen);
7385 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_invalid_objc_flag) << flag,
7386 getLocationOfByte(startFlag),
7391 void CheckPrintfHandler::HandleObjCFlagsWithNonObjCConversion(
7392 const char *flagsStart,
const char *flagsEnd,
const char *conversionPosition) {
7394 auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1);
7395 auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion;
7396 EmitFormatDiagnostic(S.
PDiag(diag) << StringRef(conversionPosition, 1),
7397 getLocationOfByte(conversionPosition),
7405 template<
typename MemberKind>
7406 static llvm::SmallPtrSet<MemberKind*, 1>
7409 llvm::SmallPtrSet<MemberKind*, 1> Results;
7426 if (MemberKind *FK = dyn_cast<MemberKind>(decl))
7437 using MethodSet = llvm::SmallPtrSet<CXXMethodDecl *, 1>;
7440 CXXRecordMembersNamed<CXXMethodDecl>(
"c_str", *
this, E->
getType());
7441 for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
7443 if ((*MI)->getMinRequiredArguments() == 0)
7451 bool CheckPrintfHandler::checkForCStrMembers(
7453 using MethodSet = llvm::SmallPtrSet<CXXMethodDecl *, 1>;
7456 CXXRecordMembersNamed<CXXMethodDecl>(
"c_str", S, E->
getType());
7458 for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
7477 const char *startSpecifier,
7478 unsigned specifierLen) {
7479 using namespace analyze_format_string;
7480 using namespace analyze_printf;
7490 HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
7491 startSpecifier, specifierLen);
7499 startSpecifier, specifierLen)) {
7504 startSpecifier, specifierLen)) {
7508 if (!CS.consumesDataArgument()) {
7516 if (argIndex < NumDataArgs) {
7520 CoveredArgs.set(argIndex);
7524 if (CS.getKind() == ConversionSpecifier::FreeBSDbArg ||
7525 CS.getKind() == ConversionSpecifier::FreeBSDDArg) {
7527 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex + 1))
7531 CoveredArgs.set(argIndex + 1);
7534 const Expr *Ex = getDataArg(argIndex);
7536 (CS.getKind() == ConversionSpecifier::FreeBSDbArg) ?
7539 EmitFormatDiagnostic(
7540 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
7544 getSpecifierRange(startSpecifier, specifierLen));
7547 Ex = getDataArg(argIndex + 1);
7550 EmitFormatDiagnostic(
7551 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
7553 <<
false << Ex->getSourceRange(),
7554 Ex->getBeginLoc(),
false,
7555 getSpecifierRange(startSpecifier, specifierLen));
7562 if (!allowsObjCArg() && CS.isObjCArg()) {
7563 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
7568 if (FSType !=
Sema::FST_OSLog && CS.getKind() == ConversionSpecifier::PArg) {
7569 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
7574 if (FSType ==
Sema::FST_OSLog && CS.getKind() == ConversionSpecifier::nArg) {
7575 EmitFormatDiagnostic(S.
PDiag(diag::warn_os_log_format_narg),
7576 getLocationOfByte(CS.getStart()),
7578 getSpecifierRange(startSpecifier, specifierLen));
7585 (CS.getKind() == ConversionSpecifier::PArg ||
7586 CS.getKind() == ConversionSpecifier::sArg ||
7587 CS.getKind() == ConversionSpecifier::ObjCObjArg)) {
7588 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
7595 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_annotation)
7599 getSpecifierRange(startSpecifier, specifierLen));
7602 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_annotation)
7606 getSpecifierRange(startSpecifier, specifierLen));
7613 startSpecifier, specifierLen);
7619 startSpecifier, specifierLen);
7623 if (CS.getKind() == ConversionSpecifier::PArg &&
7625 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_P_no_precision),
7626 getLocationOfByte(startSpecifier),
7628 getSpecifierRange(startSpecifier, specifierLen));
7637 HandleFlag(FS, FS.
hasPlusPrefix(), startSpecifier, specifierLen);
7639 HandleFlag(FS, FS.
hasSpacePrefix(), startSpecifier, specifierLen);
7648 startSpecifier, specifierLen);
7651 startSpecifier, specifierLen);
7655 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
7656 diag::warn_format_nonsensical_length);
7658 HandleNonStandardLengthModifier(FS, startSpecifier, specifierLen);
7660 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
7661 diag::warn_format_non_standard_conversion_spec);
7664 HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
7670 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex))
7673 const Expr *Arg = getDataArg(argIndex);
7677 return checkFormatExpr(FS, startSpecifier, specifierLen, Arg);
7689 case Stmt::ArraySubscriptExprClass:
7690 case Stmt::CallExprClass:
7691 case Stmt::CharacterLiteralClass:
7692 case Stmt::CXXBoolLiteralExprClass:
7693 case Stmt::DeclRefExprClass:
7694 case Stmt::FloatingLiteralClass:
7695 case Stmt::IntegerLiteralClass:
7696 case Stmt::MemberExprClass:
7697 case Stmt::ObjCArrayLiteralClass:
7698 case Stmt::ObjCBoolLiteralExprClass:
7699 case Stmt::ObjCBoxedExprClass:
7700 case Stmt::ObjCDictionaryLiteralClass:
7701 case Stmt::ObjCEncodeExprClass:
7702 case Stmt::ObjCIvarRefExprClass:
7703 case Stmt::ObjCMessageExprClass:
7704 case Stmt::ObjCPropertyRefExprClass:
7705 case Stmt::ObjCStringLiteralClass:
7706 case Stmt::ObjCSubscriptRefExprClass:
7707 case Stmt::ParenExprClass:
7708 case Stmt::StringLiteralClass:
7709 case Stmt::UnaryOperatorClass:
7716 static std::pair<QualType, StringRef>
7723 StringRef Name = UserTy->getDecl()->getName();
7724 QualType CastTy = llvm::StringSwitch<QualType>(Name)
7728 .Case(
"SInt32", Context.
IntTy)
7733 return std::make_pair(CastTy, Name);
7735 TyTy = UserTy->desugar();
7739 if (
const ParenExpr *PE = dyn_cast<ParenExpr>(E))
7741 PE->getSubExpr()->getType(),
7750 StringRef TrueName, FalseName;
7752 std::tie(TrueTy, TrueName) =
7754 CO->getTrueExpr()->getType(),
7756 std::tie(FalseTy, FalseName) =
7758 CO->getFalseExpr()->getType(),
7759 CO->getFalseExpr());
7761 if (TrueTy == FalseTy)
7762 return std::make_pair(TrueTy, TrueName);
7763 else if (TrueTy.
isNull())
7764 return std::make_pair(FalseTy, FalseName);
7765 else if (FalseTy.
isNull())
7766 return std::make_pair(TrueTy, TrueName);
7769 return std::make_pair(
QualType(), StringRef());
7788 From = VecTy->getElementType();
7790 To = VecTy->getElementType();
7798 const char *StartSpecifier,
7799 unsigned SpecifierLen,
7801 using namespace analyze_format_string;
7802 using namespace analyze_printf;
7811 while (
const TypeOfExprType *TET = dyn_cast<TypeOfExprType>(ExprTy)) {
7812 ExprTy = TET->getUnderlyingExpr()->getType();
7816 AT.matchesType(S.
Context, ExprTy);
7828 E = ICE->getSubExpr();
7837 if (AT.matchesType(S.
Context, ExprTy))
7851 bool IsEnum =
false;
7853 ExprTy = EnumTy->getDecl()->getIntegerType();
7861 if (isObjCContext() &&
7872 const llvm::APInt &V = IL->getValue();
7882 if (TD->getUnderlyingType() == IntendedTy)
7890 bool ShouldNotPrintDirectly =
false; StringRef CastTyName;
7897 if ((CastTyName ==
"NSInteger" || CastTyName ==
"NSUInteger") &&
7898 (AT.isSizeT() || AT.isPtrdiffT()) &&
7899 AT.matchesType(S.
Context, CastTy))
7901 IntendedTy = CastTy;
7902 ShouldNotPrintDirectly =
true;
7907 PrintfSpecifier fixedFS = FS;
7914 llvm::raw_svector_ostream os(buf);
7915 fixedFS.toString(os);
7917 CharSourceRange SpecRange = getSpecifierRange(StartSpecifier, SpecifierLen);
7919 if (IntendedTy == ExprTy && !ShouldNotPrintDirectly) {
7922 ? diag::warn_format_conversion_argument_type_mismatch_pedantic
7923 : diag::warn_format_conversion_argument_type_mismatch;
7926 EmitFormatDiagnostic(S.
PDiag(Diag)
7927 << AT.getRepresentativeTypeName(S.
Context)
7941 llvm::raw_svector_ostream CastFix(CastBuf);
7947 if (!AT.matchesType(S.
Context, IntendedTy) || ShouldNotPrintDirectly)
7952 SourceRange CastRange(CCast->getLParenLoc(), CCast->getRParenLoc());
7970 if (ShouldNotPrintDirectly) {
7975 if (
const TypedefType *TypedefTy = dyn_cast<TypedefType>(ExprTy))
7976 Name = TypedefTy->getDecl()->getName();
7979 unsigned Diag = Pedantic
7980 ? diag::warn_format_argument_needs_cast_pedantic
7981 : diag::warn_format_argument_needs_cast;
7982 EmitFormatDiagnostic(S.
PDiag(Diag) << Name << IntendedTy << IsEnum
7990 EmitFormatDiagnostic(
7991 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
7992 << AT.getRepresentativeTypeName(S.
Context) << ExprTy << IsEnum
8008 ? diag::warn_format_conversion_argument_type_mismatch_pedantic
8009 : diag::warn_format_conversion_argument_type_mismatch;
8011 EmitFormatDiagnostic(
8012 S.
PDiag(Diag) << AT.getRepresentativeTypeName(S.
Context) << ExprTy
8019 EmitFormatDiagnostic(S.
PDiag(diag::warn_non_pod_vararg_with_format_string)
8022 << AT.getRepresentativeTypeName(S.
Context) << CSR
8025 checkForCStrMembers(AT, E);
8030 EmitFormatDiagnostic(
8031 S.
PDiag(diag::err_cannot_pass_objc_interface_to_vararg_format)
8032 << S.
getLangOpts().CPlusPlus11 << ExprTy << CallType
8033 << AT.getRepresentativeTypeName(S.
Context) << CSR
8040 << isa<InitListExpr>(E) << ExprTy << CallType
8045 assert(FirstDataArg + FS.
getArgIndex() < CheckedVarArgs.size() &&
8046 "format string specifier index out of range");
8047 CheckedVarArgs[FirstDataArg + FS.
getArgIndex()] =
true;
8057 class CheckScanfHandler :
public CheckFormatHandler {
8059 CheckScanfHandler(
Sema &s,
const FormatStringLiteral *fexpr,
8061 unsigned firstDataArg,
unsigned numDataArgs,
8062 const char *beg,
bool hasVAListArg,
8063 ArrayRef<const Expr *> Args,
unsigned formatIdx,
8065 llvm::SmallBitVector &CheckedVarArgs,
8066 UncoveredArgHandler &UncoveredArg)
8067 : CheckFormatHandler(s, fexpr, origFormatExpr, type, firstDataArg,
8068 numDataArgs, beg, hasVAListArg, Args, formatIdx,
8069 inFunctionCall, CallType, CheckedVarArgs,
8073 const char *startSpecifier,
8074 unsigned specifierLen)
override;
8076 bool HandleInvalidScanfConversionSpecifier(
8078 const char *startSpecifier,
8079 unsigned specifierLen)
override;
8081 void HandleIncompleteScanList(
const char *start,
const char *end)
override;
8086 void CheckScanfHandler::HandleIncompleteScanList(
const char *start,
8088 EmitFormatDiagnostic(S.
PDiag(diag::warn_scanf_scanlist_incomplete),
8089 getLocationOfByte(end),
true,
8090 getSpecifierRange(start, end - start));
8093 bool CheckScanfHandler::HandleInvalidScanfConversionSpecifier(
8095 const char *startSpecifier,
8096 unsigned specifierLen) {
8100 return HandleInvalidConversionSpecifier(FS.
getArgIndex(),
8102 startSpecifier, specifierLen,
8106 bool CheckScanfHandler::HandleScanfSpecifier(
8108 const char *startSpecifier,
8109 unsigned specifierLen) {
8110 using namespace analyze_scanf;
8111 using namespace analyze_format_string;
8123 HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
8124 startSpecifier, specifierLen);
8131 if (Amt.getHowSpecified() == OptionalAmount::Constant) {
8132 if (Amt.getConstantAmount() == 0) {
8134 Amt.getConstantLength());
8135 EmitFormatDiagnostic(S.
PDiag(diag::warn_scanf_nonzero_width),
8136 getLocationOfByte(Amt.getStart()),
8150 if (argIndex < NumDataArgs) {
8154 CoveredArgs.set(argIndex);
8159 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
8160 diag::warn_format_nonsensical_length);
8162 HandleNonStandardLengthModifier(FS, startSpecifier, specifierLen);
8164 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
8165 diag::warn_format_non_standard_conversion_spec);
8168 HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
8174 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex))
8178 const Expr *Ex = getDataArg(argIndex);
8194 ScanfSpecifier fixedFS = FS;
8199 Pedantic ? diag::warn_format_conversion_argument_type_mismatch_pedantic
8200 : diag::warn_format_conversion_argument_type_mismatch;
8205 llvm::raw_svector_ostream os(buf);
8206 fixedFS.toString(os);
8208 EmitFormatDiagnostic(
8213 getSpecifierRange(startSpecifier, specifierLen),
8215 getSpecifierRange(startSpecifier, specifierLen), os.str()));
8217 EmitFormatDiagnostic(S.
PDiag(Diag)
8222 getSpecifierRange(startSpecifier, specifierLen));
8229 const Expr *OrigFormatExpr,
8230 ArrayRef<const Expr *> Args,
8231 bool HasVAListArg,
unsigned format_idx,
8232 unsigned firstDataArg,
8234 bool inFunctionCall,
8236 llvm::SmallBitVector &CheckedVarArgs,
8237 UncoveredArgHandler &UncoveredArg) {
8239 if (!FExpr->isAscii() && !FExpr->isUTF8()) {
8240 CheckFormatHandler::EmitFormatDiagnostic(
8241 S, inFunctionCall, Args[format_idx],
8242 S.
PDiag(diag::warn_format_string_is_wide_literal), FExpr->getBeginLoc(),
8248 StringRef StrRef = FExpr->getString();
8249 const char *Str = StrRef.data();
8253 assert(T &&
"String literal not of constant array type!");
8254 size_t TypeSize = T->
getSize().getZExtValue();
8255 size_t StrLen =
std::min(
std::max(TypeSize,
size_t(1)) - 1, StrRef.size());
8256 const unsigned numDataArgs = Args.size() - firstDataArg;
8260 if (TypeSize <= StrRef.size() &&
8261 StrRef.substr(0, TypeSize).find(
'\0') == StringRef::npos) {
8262 CheckFormatHandler::EmitFormatDiagnostic(
8263 S, inFunctionCall, Args[format_idx],
8264 S.
PDiag(diag::warn_printf_format_string_not_null_terminated),
8265 FExpr->getBeginLoc(),
8271 if (StrLen == 0 && numDataArgs > 0) {
8272 CheckFormatHandler::EmitFormatDiagnostic(
8273 S, inFunctionCall, Args[format_idx],
8274 S.
PDiag(diag::warn_empty_format_string), FExpr->getBeginLoc(),
8282 CheckPrintfHandler H(
8283 S, FExpr, OrigFormatExpr, Type, firstDataArg, numDataArgs,
8285 HasVAListArg, Args, format_idx, inFunctionCall, CallType,
8286 CheckedVarArgs, UncoveredArg);
8294 CheckScanfHandler H(S, FExpr, OrigFormatExpr, Type, firstDataArg,
8295 numDataArgs, Str, HasVAListArg, Args, format_idx,
8296 inFunctionCall, CallType, CheckedVarArgs, UncoveredArg);
8308 const char *Str = StrRef.data();
8311 assert(T &&
"String literal not of constant array type!");
8312 size_t TypeSize = T->
getSize().getZExtValue();
8313 size_t StrLen =
std::min(
std::max(TypeSize,
size_t(1)) - 1, StrRef.size());
8324 switch (AbsFunction) {
8328 case Builtin::BI__builtin_abs:
8329 return Builtin::BI__builtin_labs;
8330 case Builtin::BI__builtin_labs:
8331 return Builtin::BI__builtin_llabs;
8332 case Builtin::BI__builtin_llabs:
8335 case Builtin::BI__builtin_fabsf:
8336 return Builtin::BI__builtin_fabs;
8337 case Builtin::BI__builtin_fabs:
8338 return Builtin::BI__builtin_fabsl;
8339 case Builtin::BI__builtin_fabsl:
8342 case Builtin::BI__builtin_cabsf:
8343 return Builtin::BI__builtin_cabs;
8344 case Builtin::BI__builtin_cabs:
8345 return Builtin::BI__builtin_cabsl;
8346 case Builtin::BI__builtin_cabsl:
8349 case Builtin::BIabs:
8350 return Builtin::BIlabs;
8351 case Builtin::BIlabs:
8352 return Builtin::BIllabs;
8353 case Builtin::BIllabs:
8356 case Builtin::BIfabsf:
8357 return Builtin::BIfabs;
8358 case Builtin::BIfabs:
8359 return Builtin::BIfabsl;
8360 case Builtin::BIfabsl:
8363 case Builtin::BIcabsf:
8364 return Builtin::BIcabs;
8365 case Builtin::BIcabs:
8366 return Builtin::BIcabsl;
8367 case Builtin::BIcabsl:
8396 unsigned AbsFunctionKind) {
8397 unsigned BestKind = 0;
8399 for (
unsigned Kind = AbsFunctionKind;
Kind != 0;
8405 else if (Context.
hasSameType(ParamType, ArgType)) {
8428 llvm_unreachable(
"Type not integer, floating, or complex");
8435 switch (ValueKind) {
8440 case Builtin::BI__builtin_fabsf:
8441 case Builtin::BI__builtin_fabs:
8442 case Builtin::BI__builtin_fabsl:
8443 case Builtin::BI__builtin_cabsf:
8444 case Builtin::BI__builtin_cabs:
8445 case Builtin::BI__builtin_cabsl:
8446 return Builtin::BI__builtin_abs;
8447 case Builtin::BIfabsf:
8448 case Builtin::BIfabs:
8449 case Builtin::BIfabsl:
8450 case Builtin::BIcabsf:
8451 case Builtin::BIcabs:
8452 case Builtin::BIcabsl:
8453 return Builtin::BIabs;
8459 case Builtin::BI__builtin_abs:
8460 case Builtin::BI__builtin_labs:
8461 case Builtin::BI__builtin_llabs:
8462 case Builtin::BI__builtin_cabsf:
8463 case Builtin::BI__builtin_cabs:
8464 case Builtin::BI__builtin_cabsl:
8465 return Builtin::BI__builtin_fabsf;
8466 case Builtin::BIabs:
8467 case Builtin::BIlabs:
8468 case Builtin::BIllabs:
8469 case Builtin::BIcabsf:
8470 case Builtin::BIcabs:
8471 case Builtin::BIcabsl:
8472 return Builtin::BIfabsf;
8478 case Builtin::BI__builtin_abs:
8479 case Builtin::BI__builtin_labs:
8480 case Builtin::BI__builtin_llabs:
8481 case Builtin::BI__builtin_fabsf:
8482 case Builtin::BI__builtin_fabs:
8483 case Builtin::BI__builtin_fabsl:
8484 return Builtin::BI__builtin_cabsf;
8485 case Builtin::BIabs:
8486 case Builtin::BIlabs:
8487 case Builtin::BIllabs:
8488 case Builtin::BIfabsf:
8489 case Builtin::BIfabs:
8490 case Builtin::BIfabsl:
8491 return Builtin::BIcabsf;
8494 llvm_unreachable(
"Unable to convert function");
8505 case Builtin::BI__builtin_abs:
8506 case Builtin::BI__builtin_fabs:
8507 case Builtin::BI__builtin_fabsf:
8508 case Builtin::BI__builtin_fabsl:
8509 case Builtin::BI__builtin_labs:
8510 case Builtin::BI__builtin_llabs:
8511 case Builtin::BI__builtin_cabs:
8512 case Builtin::BI__builtin_cabsf:
8513 case Builtin::BI__builtin_cabsl:
8514 case Builtin::BIabs:
8515 case Builtin::BIlabs:
8516 case Builtin::BIllabs:
8517 case Builtin::BIfabs:
8518 case Builtin::BIfabsf:
8519 case Builtin::BIfabsl:
8520 case Builtin::BIcabs:
8521 case Builtin::BIcabsf:
8522 case Builtin::BIcabsl:
8525 llvm_unreachable(
"Unknown Builtin type");
8531 unsigned AbsKind,
QualType ArgType) {
8532 bool EmitHeaderHint =
true;
8533 const char *HeaderName =
nullptr;
8534 const char *FunctionName =
nullptr;
8536 FunctionName =
"std::abs";
8538 HeaderName =
"cstdlib";
8540 HeaderName =
"cmath";
8542 llvm_unreachable(
"Invalid Type");
8551 for (
const auto *I : R) {
8554 FDecl = dyn_cast<
FunctionDecl>(UsingD->getTargetDecl());
8571 EmitHeaderHint =
false;
8583 R.suppressDiagnostics();
8586 if (R.isSingleResult()) {
8589 EmitHeaderHint =
false;
8593 }
else if (!R.empty()) {
8599 S.
Diag(Loc, diag::note_replace_abs_function)
8605 if (!EmitHeaderHint)
8608 S.
Diag(Loc, diag::note_include_header_or_declare) << HeaderName
8612 template <std::
size_t StrLen>
8614 const char (&Str)[StrLen]) {
8626 void Sema::CheckAbsoluteValueFunction(
const CallExpr *Call,
8633 if (AbsKind == 0 && !IsStdAbs)
8642 const char *FunctionName =
8644 Diag(Call->
getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType;
8654 unsigned DiagType = 0;
8660 Diag(Call->
getExprLoc(), diag::warn_pointer_abs) << DiagType << ArgType;
8674 if (ArgValueKind == ParamValueKind) {
8680 << FDecl << ArgType << ParamType;
8682 if (NewAbsKind == 0)
8695 if (NewAbsKind == 0)
8699 << FDecl << ParamValueKind << ArgValueKind;
8706 void Sema::CheckMaxUnsignedZero(
const CallExpr *Call,
8708 if (!Call || !FDecl)
return;
8711 if (inTemplateInstantiation())
return;
8718 if (!ArgList)
return;
8719 if (ArgList->size() != 1)
return;
8722 const auto& TA = ArgList->
get(0);
8728 auto IsLiteralZeroArg = [](
const Expr* E) ->
bool {
8730 if (!MTE)
return false;
8731 const auto *Num = dyn_cast<
IntegerLiteral>(MTE->GetTemporaryExpr());
8732 if (!Num)
return false;
8733 if (Num->getValue() != 0)
return false;
8739 const bool IsFirstArgZero = IsLiteralZeroArg(FirstArg);
8740 const bool IsSecondArgZero = IsLiteralZeroArg(SecondArg);
8743 if (IsFirstArgZero == IsSecondArgZero)
return;
8748 SourceRange ZeroRange = IsFirstArgZero ? FirstRange : SecondRange;
8755 if (IsFirstArgZero) {
8788 << SizeRange << FnName;
8789 S.
Diag(FnLoc, diag::note_memsize_comparison_paren)
8794 S.
Diag(SizeRange.
getBegin(), diag::note_memsize_comparison_cast_silence)
8805 bool &IsContained) {
8808 IsContained =
false;
8821 for (
auto *FD : RD->
fields()) {
8834 if (
const auto *Unary = dyn_cast<UnaryExprOrTypeTraitExpr>(E))
8844 if (!SizeOf->isArgumentType())
8852 return SizeOf->getTypeOfArgument();
8858 struct SearchNonTrivialToInitializeField
8863 SearchNonTrivialToInitializeField(
const Expr *E,
Sema &S) : E(E), S(S) {}
8867 if (
const auto *AT = asDerived().getContext().getAsArrayType(FT)) {
8868 asDerived().visitArray(PDIK, AT, SL);
8872 Super::visitWithKind(PDIK, FT, SL);
8883 visit(FD->getType(), FD->getLocation());
8887 visit(getContext().getBaseElementType(AT), SL);
8892 SearchNonTrivialToInitializeField(E, S).visitStruct(RT,
SourceLocation());
8901 struct SearchNonTrivialToCopyField
8905 SearchNonTrivialToCopyField(
const Expr *E,
Sema &S) : E(E), S(S) {}
8909 if (
const auto *AT = asDerived().getContext().getAsArrayType(FT)) {
8910 asDerived().visitArray(PCK, AT, SL);
8914 Super::visitWithKind(PCK, FT, SL);
8925 visit(FD->getType(), FD->getLocation());
8929 visit(getContext().getBaseElementType(AT), SL);
8937 SearchNonTrivialToCopyField(E, S).visitStruct(RT,
SourceLocation());
8952 if (
const auto *BO = dyn_cast<BinaryOperator>(SizeofExpr)) {
8953 if (BO->getOpcode() != BO_Mul && BO->getOpcode() != BO_Add)
8986 if (BId != Builtin::BImemset && BId != Builtin::BIbzero)
8989 const Expr *SizeArg =
8992 auto isLiteralZero = [](
const Expr *E) {
8993 return isa<IntegerLiteral>(E) && cast<IntegerLiteral>(E)->getValue() == 0;
8999 if (isLiteralZero(SizeArg) &&
9006 if (BId == Builtin::BIbzero ||
9009 S.
Diag(DiagLoc, diag::warn_suspicious_bzero_size);
9010 S.
Diag(DiagLoc, diag::note_suspicious_bzero_size_silence);
9012 S.
Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 0;
9013 S.
Diag(DiagLoc, diag::note_suspicious_sizeof_memset_silence) << 0;
9021 if (BId == Builtin::BImemset &&
9025 S.
Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 1;
9026 S.
Diag(DiagLoc, diag::note_suspicious_sizeof_memset_silence) << 1;
9038 void Sema::CheckMemaccessArguments(
const CallExpr *Call,
9045 unsigned ExpectedNumArgs =
9046 (BId == Builtin::BIstrndup || BId == Builtin::BIbzero ? 2 : 3);
9050 unsigned LastArg = (BId == Builtin::BImemset || BId == Builtin::BIbzero ||
9051 BId == Builtin::BIstrndup ? 1 : 2);
9053 (BId == Builtin::BIbzero || BId == Builtin::BIstrndup ? 1 : 2);
9066 llvm::FoldingSetNodeID SizeOfArgID;
9075 for (
unsigned ArgIdx = 0; ArgIdx != LastArg; ++ArgIdx) {
9094 !Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess,
9098 if (SizeOfArgID == llvm::FoldingSetNodeID())
9099 SizeOfArg->
Profile(SizeOfArgID, Context,
true);
9100 llvm::FoldingSetNodeID DestID;
9101 Dest->
Profile(DestID, Context,
true);
9102 if (DestID == SizeOfArgID) {
9105 unsigned ActionIdx = 0;
9106 StringRef ReadableName = FnName->
getName();
9108 if (
const UnaryOperator *UnaryOp = dyn_cast<UnaryOperator>(Dest))
9109 if (UnaryOp->getOpcode() == UO_AddrOf)
9132 DiagRuntimeBehavior(SL, SizeOfArg,
9133 PDiag(diag::warn_sizeof_pointer_expr_memaccess)
9139 DiagRuntimeBehavior(SL, SizeOfArg,
9140 PDiag(diag::warn_sizeof_pointer_expr_memaccess_note)
9154 DiagRuntimeBehavior(LenExpr->
getExprLoc(), Dest,
9155 PDiag(diag::warn_sizeof_pointer_type_memaccess)
9156 << FnName << SizeOfArgTy << ArgIdx
9174 unsigned OperationType = 0;
9177 if (ArgIdx != 0 || BId == Builtin::BImemcmp) {
9178 if (BId == Builtin::BImemcpy)
9180 else if(BId == Builtin::BImemmove)
9182 else if (BId == Builtin::BImemcmp)
9186 DiagRuntimeBehavior(
9188 PDiag(diag::warn_dyn_class_memaccess)
9189 << (BId == Builtin::BImemcmp ? ArgIdx + 2 : ArgIdx)
9190 << FnName << IsContained << ContainedRD << OperationType
9193 BId != Builtin::BImemset)
9194 DiagRuntimeBehavior(
9196 PDiag(diag::warn_arc_object_memaccess)
9197 << ArgIdx << FnName << PointeeTy
9200 if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
9201 RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize()) {
9202 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9203 PDiag(diag::warn_cstruct_memaccess)
9204 << ArgIdx << FnName << PointeeTy << 0);
9205 SearchNonTrivialToInitializeField::diag(PointeeTy, Dest, *
this);
9206 }
else if ((BId == Builtin::BImemcpy || BId == Builtin::BImemmove) &&
9207 RT->getDecl()->isNonTrivialToPrimitiveCopy()) {
9208 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9209 PDiag(diag::warn_cstruct_memaccess)
9210 << ArgIdx << FnName << PointeeTy << 1);
9211 SearchNonTrivialToCopyField::diag(PointeeTy, Dest, *
this);
9218 DiagRuntimeBehavior(
9220 PDiag(diag::note_bad_memaccess_silence)
9240 if (isa<IntegerLiteral>(RHS))
9242 else if (isa<IntegerLiteral>(LHS))
9256 if (CAT->getSize().getSExtValue() <= 1)
9266 void Sema::CheckStrlcpycatArguments(
const CallExpr *Call,
9271 if ((NumArgs != 3) && (NumArgs != 4))
9276 const Expr *CompareWithSrc =
nullptr;
9284 CompareWithSrc = Ex;
9287 if (
const CallExpr *SizeCall = dyn_cast<CallExpr>(SizeArg)) {
9288 if (SizeCall->getBuiltinCallee() == Builtin::BIstrlen &&
9289 SizeCall->getNumArgs() == 1)
9294 if (!CompareWithSrc)
9306 if (!CompareWithSrcDRE ||
9310 const Expr *OriginalSizeArg = Call->
getArg(2);
9311 Diag(CompareWithSrcDRE->
getBeginLoc(), diag::warn_strlcpycat_wrong_size)
9323 llvm::raw_svector_ostream OS(sizeString);
9325 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9328 Diag(OriginalSizeArg->
getBeginLoc(), diag::note_strlcpycat_wrong_size)
9335 if (
const DeclRefExpr *D1 = dyn_cast_or_null<DeclRefExpr>(E1))
9336 if (
const DeclRefExpr *D2 = dyn_cast_or_null<DeclRefExpr>(E2))
9337 return D1->getDecl() == D2->getDecl();
9342 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
9346 return CE->getArg(0)->IgnoreParenCasts();
9354 void Sema::CheckStrncatArguments(
const CallExpr *CE,
9369 unsigned PatternType = 0;
9377 }
else if (
const BinaryOperator *BE = dyn_cast<BinaryOperator>(LenArg)) {
9378 if (BE->getOpcode() == BO_Sub) {
9391 if (PatternType == 0)
9410 if (!isKnownSizeArray) {
9411 if (PatternType == 1)
9412 Diag(SL, diag::warn_strncat_wrong_size) << SR;
9414 Diag(SL, diag::warn_strncat_src_size) << SR;
9418 if (PatternType == 1)
9419 Diag(SL, diag::warn_strncat_large_size) << SR;
9421 Diag(SL, diag::warn_strncat_src_size) << SR;
9424 llvm::raw_svector_ostream OS(sizeString);
9426 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9429 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9432 Diag(SL, diag::note_strncat_wrong_size)
9437 Sema::CheckReturnValExpr(
Expr *RetValExp,
QualType lhsType,
9443 if (((Attrs && hasSpecificAttr<ReturnsNonNullAttr>(*Attrs)) ||
9446 Diag(ReturnLoc, diag::warn_null_ret)
9456 if (Op == OO_New || Op == OO_Array_New) {
9461 Diag(ReturnLoc, diag::warn_operator_new_returns_null)
9462 << FD << getLangOpts().CPlusPlus11;
9478 if (
DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(LeftExprSansParen))
9479 if (
DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(RightExprSansParen))
9480 if (DRL->getDecl() == DRR->getDecl())
9488 if (
FloatingLiteral* FLL = dyn_cast<FloatingLiteral>(LeftExprSansParen)) {
9492 if (
FloatingLiteral* FLR = dyn_cast<FloatingLiteral>(RightExprSansParen))
9497 if (
CallExpr* CL = dyn_cast<CallExpr>(LeftExprSansParen))
9498 if (CL->getBuiltinCallee())
9501 if (
CallExpr* CR = dyn_cast<CallExpr>(RightExprSansParen))
9502 if (CR->getBuiltinCallee())
9506 Diag(Loc, diag::warn_floatingpoint_eq)
9524 IntRange(
unsigned Width,
bool NonNegative)
9525 : Width(Width), NonNegative(NonNegative) {}
9528 static IntRange forBoolType() {
9529 return IntRange(1,
true);
9534 return forValueOfCanonicalType(C,
9539 static IntRange forValueOfCanonicalType(
ASTContext &C,
const Type *T) {
9542 if (
const VectorType *VT = dyn_cast<VectorType>(T))
9543 T = VT->getElementType().getTypePtr();
9544 if (
const ComplexType *CT = dyn_cast<ComplexType>(T))
9545 T = CT->getElementType().getTypePtr();
9546 if (
const AtomicType *AT = dyn_cast<AtomicType>(T))
9547 T = AT->getValueType().getTypePtr();
9551 if (
const EnumType *ET = dyn_cast<EnumType>(T))
9552 T = ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
9553 }
else if (
const EnumType *ET = dyn_cast<EnumType>(T)) {
9560 !ET->isSignedIntegerOrEnumerationType());
9566 if (NumNegative == 0)
9567 return IntRange(NumPositive,
true);
9569 return IntRange(
std::max(NumPositive + 1, NumNegative),
9584 static IntRange forTargetOfCanonicalType(
ASTContext &C,
const Type *T) {
9587 if (
const VectorType *VT = dyn_cast<VectorType>(T))
9588 T = VT->getElementType().getTypePtr();
9589 if (
const ComplexType *CT = dyn_cast<ComplexType>(T))
9590 T = CT->getElementType().getTypePtr();
9591 if (
const AtomicType *AT = dyn_cast<AtomicType>(T))
9592 T = AT->getValueType().getTypePtr();
9593 if (
const EnumType *ET = dyn_cast<EnumType>(T))
9603 static IntRange join(IntRange L, IntRange R) {
9604 return IntRange(
std::max(L.Width, R.Width),
9605 L.NonNegative && R.NonNegative);
9609 static IntRange meet(IntRange L, IntRange R) {
9610 return IntRange(
std::min(L.Width, R.Width),
9611 L.NonNegative || R.NonNegative);
9618 unsigned MaxWidth) {
9619 if (value.isSigned() && value.isNegative())
9620 return IntRange(value.getMinSignedBits(),
false);
9622 if (value.getBitWidth() > MaxWidth)
9623 value = value.trunc(MaxWidth);
9627 return IntRange(value.getActiveBits(),
true);
9631 unsigned MaxWidth) {
9639 R = IntRange::join(R, El);
9647 return IntRange::join(R, I);
9662 Ty = AtomicRHS->getValueType();
9681 if (
const auto *CE = dyn_cast<ImplicitCastExpr>(E)) {
9682 if (CE->getCastKind() == CK_NoOp || CE->getCastKind() == CK_LValueToRValue)
9685 IntRange OutputTypeRange = IntRange::forValueOfType(C,
GetExprType(CE));
9687 bool isIntegerCast = CE->getCastKind() == CK_IntegralCast ||
9688 CE->getCastKind() == CK_BooleanToSignedIntegral;
9692 return OutputTypeRange;
9696 std::min(MaxWidth, OutputTypeRange.Width));
9699 if (SubRange.Width >= OutputTypeRange.Width)
9700 return OutputTypeRange;
9704 return IntRange(SubRange.Width,
9705 SubRange.NonNegative || OutputTypeRange.NonNegative);
9708 if (
const auto *CO = dyn_cast<ConditionalOperator>(E)) {
9711 if (CO->getCond()->EvaluateAsBooleanCondition(CondResult, C))
9713 : CO->getFalseExpr(),
9717 IntRange L =
GetExprRange(C, CO->getTrueExpr(), MaxWidth);
9718 IntRange R =
GetExprRange(C, CO->getFalseExpr(), MaxWidth);
9719 return IntRange::join(L, R);
9722 if (
const auto *BO = dyn_cast<BinaryOperator>(E)) {
9723 switch (BO->getOpcode()) {
9725 llvm_unreachable(
"builtin <=> should have class type");
9736 return IntRange::forBoolType();
9748 return IntRange::forValueOfType(C,
GetExprType(E));
9759 return IntRange::forValueOfType(C,
GetExprType(E));
9764 return IntRange::meet(
GetExprRange(C, BO->getLHS(), MaxWidth),
9772 = dyn_cast<IntegerLiteral>(BO->getLHS()->IgnoreParenCasts())) {
9773 if (I->getValue() == 1) {
9774 IntRange R = IntRange::forValueOfType(C,
GetExprType(E));
9775 return IntRange(R.Width,
true);
9781 return IntRange::forValueOfType(C,
GetExprType(E));
9785 case BO_ShrAssign: {
9791 if (BO->getRHS()->isIntegerConstantExpr(shift, C) &&
9792 shift.isNonNegative()) {
9793 unsigned zext = shift.getZExtValue();
9794 if (zext >= L.Width)
9795 L.Width = (L.NonNegative ? 0 : 1);
9809 if (BO->getLHS()->getType()->isPointerType())
9810 return IntRange::forValueOfType(C,
GetExprType(E));
9821 llvm::APSInt divisor;
9822 if (BO->getRHS()->isIntegerConstantExpr(divisor, C)) {
9823 unsigned log2 = divisor.logBase2();
9824 if (log2 >= L.Width)
9825 L.Width = (L.NonNegative ? 0 : 1);
9827 L.Width =
std::min(L.Width - log2, MaxWidth);
9833 return IntRange(L.Width, L.NonNegative && R.NonNegative);
9844 IntRange meet = IntRange::meet(L, R);
9845 meet.Width =
std::min(meet.Width, MaxWidth);
9861 return IntRange::join(L, R);
9864 if (
const auto *UO = dyn_cast<UnaryOperator>(E)) {
9865 switch (UO->getOpcode()) {
9868 return IntRange::forBoolType();
9873 return IntRange::forValueOfType(C,
GetExprType(E));
9880 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
9881 return GetExprRange(C, OVE->getSourceExpr(), MaxWidth);
9884 return IntRange(BitField->getBitWidthValue(C),
9885 BitField->getType()->isUnsignedIntegerOrEnumerationType());
9887 return IntRange::forValueOfType(C,
GetExprType(E));
9898 const llvm::fltSemantics &Src,
9899 const llvm::fltSemantics &Tgt) {
9900 llvm::APFloat truncated = value;
9903 truncated.convert(Src, llvm::APFloat::rmNearestTiesToEven, &ignored);
9904 truncated.convert(Tgt, llvm::APFloat::rmNearestTiesToEven, &ignored);
9906 return truncated.bitwiseIsEqual(value);
9915 const llvm::fltSemantics &Src,
9916 const llvm::fltSemantics &Tgt) {
9938 if (isa<EnumConstantDecl>(DR->getDecl()))
9965 struct PromotedRange {
9967 llvm::APSInt PromotedMin;
9969 llvm::APSInt PromotedMax;
9971 PromotedRange(IntRange R,
unsigned BitWidth,
bool Unsigned) {
9973 PromotedMin = PromotedMax = llvm::APSInt(BitWidth, Unsigned);
9974 else if (R.Width >= BitWidth && !Unsigned) {
9978 PromotedMin = llvm::APSInt::getMinValue(BitWidth, Unsigned);
9979 PromotedMax = llvm::APSInt::getMaxValue(BitWidth, Unsigned);
9981 PromotedMin = llvm::APSInt::getMinValue(R.Width, R.NonNegative)
9982 .extOrTrunc(BitWidth);
9983 PromotedMin.setIsUnsigned(Unsigned);
9985 PromotedMax = llvm::APSInt::getMaxValue(R.Width, R.NonNegative)
9986 .extOrTrunc(BitWidth);
9987 PromotedMax.setIsUnsigned(Unsigned);
9992 bool isContiguous()
const {
return PromotedMin <= PromotedMax; }
9995 enum ComparisonResult {
10002 InRangeFlag = 0x40,
10005 Min = LE | InRangeFlag,
10006 InRange = InRangeFlag,
10007 Max = GE | InRangeFlag,
10010 OnlyValue = LE | GE | EQ | InRangeFlag,
10014 ComparisonResult
compare(
const llvm::APSInt &
Value)
const {
10015 assert(Value.getBitWidth() == PromotedMin.getBitWidth() &&
10016 Value.isUnsigned() == PromotedMin.isUnsigned());
10017 if (!isContiguous()) {
10018 assert(Value.isUnsigned() &&
"discontiguous range for signed compare");
10019 if (Value.isMinValue())
return Min;
10020 if (Value.isMaxValue())
return Max;
10021 if (Value >= PromotedMin)
return InRange;
10022 if (Value <= PromotedMax)
return InRange;
10026 switch (llvm::APSInt::compareValues(Value, PromotedMin)) {
10027 case -1:
return Less;
10028 case 0:
return PromotedMin == PromotedMax ? OnlyValue : Min;
10030 switch (llvm::APSInt::compareValues(Value, PromotedMax)) {
10031 case -1:
return InRange;
10032 case 0:
return Max;
10037 llvm_unreachable(
"impossible compare result");
10042 if (Op == BO_Cmp) {
10043 ComparisonResult LTFlag =
LT, GTFlag = GT;
10044 if (ConstantOnRHS) std::swap(LTFlag, GTFlag);
10046 if (R & EQ)
return StringRef(
"'std::strong_ordering::equal'");
10047 if (R & LTFlag)
return StringRef(
"'std::strong_ordering::less'");
10048 if (R & GTFlag)
return StringRef(
"'std::strong_ordering::greater'");
10052 ComparisonResult TrueFlag, FalseFlag;
10056 }
else if (Op == BO_NE) {
10060 if ((Op == BO_LT || Op == BO_GE) ^ ConstantOnRHS) {
10067 if (Op == BO_GE || Op == BO_LE)
10068 std::swap(TrueFlag, FalseFlag);
10071 return StringRef(
"true");
10073 return StringRef(
"false");
10082 if (ICE->getCastKind() != CK_IntegralCast &&
10083 ICE->getCastKind() != CK_NoOp)
10085 E = ICE->getSubExpr();
10094 enum ConstantValueKind {
10099 if (
auto *BL = dyn_cast<CXXBoolLiteralExpr>(Constant))
10100 return BL->getValue() ? ConstantValueKind::LiteralTrue
10101 : ConstantValueKind::LiteralFalse;
10102 return ConstantValueKind::Miscellaneous;
10107 const llvm::APSInt &
Value,
10108 bool RhsConstant) {
10112 Expr *OriginalOther = Other;
10132 OtherT = AT->getValueType();
10133 IntRange OtherRange = IntRange::forValueOfType(S.
Context, OtherT);
10137 bool OtherIsBooleanDespiteType =
10139 if (OtherIsBooleanDespiteType)
10140 OtherRange = IntRange::forBoolType();
10144 PromotedRange OtherPromotedRange(OtherRange, Value.getBitWidth(),
10145 Value.isUnsigned());
10146 auto Cmp = OtherPromotedRange.compare(Value);
10147 auto Result = PromotedRange::constantValue(E->
getOpcode(), Cmp, RhsConstant);
10157 bool InRange = Cmp & PromotedRange::InRangeFlag;
10164 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Constant))
10165 ED = dyn_cast<EnumConstantDecl>(DR->getDecl());
10169 llvm::raw_svector_ostream OS(PrettySourceValue);
10171 OS <<
'\'' << *ED <<
"' (" << Value <<
")";
10181 S.
PDiag(!InRange ? diag::warn_out_of_range_compare
10182 : diag::warn_tautological_bool_compare)
10184 << OtherT << OtherIsBooleanDespiteType << *Result
10189 ? diag::warn_unsigned_enum_always_true_comparison
10190 : diag::warn_unsigned_always_true_comparison)
10191 : diag::warn_tautological_constant_compare;
10194 << RhsConstant << OtherT << E->
getOpcodeStr() << OS.str() << *Result
10228 llvm::APSInt RHSValue;
10229 llvm::APSInt LHSValue;
10235 if (IsRHSIntegralLiteral && IsLHSIntegralLiteral)
10239 if (IsRHSIntegralLiteral ^ IsLHSIntegralLiteral) {
10241 const bool RhsConstant = IsRHSIntegralLiteral;
10242 Expr *Const = RhsConstant ? RHS : LHS;
10243 Expr *Other = RhsConstant ? LHS : RHS;
10244 const llvm::APSInt &
Value = RhsConstant ? RHSValue : LHSValue;
10267 if (
const auto *TET = dyn_cast<TypeOfExprType>(LHS->
getType()))
10269 if (
const auto *TET = dyn_cast<TypeOfExprType>(RHS->
getType()))
10275 Expr *signedOperand, *unsignedOperand;
10278 "unsigned comparison between two signed integer expressions?");
10279 signedOperand = LHS;
10280 unsignedOperand = RHS;
10282 signedOperand = RHS;
10283 unsignedOperand = LHS;
10297 if (signedRange.NonNegative)
10310 assert(unsignedRange.NonNegative &&
"unsigned range includes negative?");
10312 if (unsignedRange.Width < comparisonWidth)
10317 S.
PDiag(diag::warn_mixed_sign_comparison)
10345 S.
Diag(InitLoc, diag::warn_no_underlying_type_specified_for_enum_bitfield)
10383 unsigned DiagID = 0;
10384 if (SignedEnum && !SignedBitfield) {
10385 DiagID = diag::warn_unsigned_bitfield_assigned_signed_enum;
10386 }
else if (SignedBitfield && !SignedEnum &&
10388 DiagID = diag::warn_signed_bitfield_enum_conversion;
10392 S.
Diag(InitLoc, DiagID) << Bitfield << ED;
10397 << SignedEnum << TypeRange;
10408 if (BitsNeeded > FieldWidth) {
10410 S.
Diag(InitLoc, diag::warn_bitfield_too_small_for_enum)
10422 unsigned OriginalWidth = Value.getBitWidth();
10424 if (!Value.isSigned() || Value.isNegative())
10425 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(OriginalInit))
10426 if (UO->getOpcode() == UO_Minus || UO->getOpcode() == UO_Not)
10427 OriginalWidth = Value.getMinSignedBits();
10429 if (OriginalWidth <= FieldWidth)
10433 llvm::APSInt TruncatedValue = Value.trunc(FieldWidth);
10437 TruncatedValue = TruncatedValue.extend(OriginalWidth);
10438 if (llvm::APSInt::isSameValue(Value, TruncatedValue))
10443 if (FieldWidth == 1 && Value == 1)
10446 std::string PrettyValue = Value.toString(10);
10447 std::string PrettyTrunc = TruncatedValue.toString(10);
10449 S.
Diag(InitLoc, diag::warn_impcast_bitfield_precision_constant)
10450 << PrettyValue << PrettyTrunc << OriginalInit->
getType()
10483 bool pruneControlFlow =
false) {
10484 if (pruneControlFlow) {
10498 unsigned diag,
bool pruneControlFlow =
false) {
10511 if (UOp->getOpcode() == UO_Minus || UOp->getOpcode() == UO_Plus)
10514 const bool IsLiteral =
10515 isa<FloatingLiteral>(E) || isa<FloatingLiteral>(InnerE);
10517 llvm::APFloat
Value(0.0);
10522 diag::warn_impcast_float_integer, PruneWarnings);
10525 bool isExact =
false;
10529 llvm::APFloat::opStatus Result = Value.convertToInteger(
10530 IntegerValue, llvm::APFloat::rmTowardZero, &isExact);
10532 if (Result == llvm::APFloat::opOK && isExact) {
10533 if (IsLiteral)
return;
10534 return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer,
10540 if (!IsBool && Result == llvm::APFloat::opInvalidOp)
10543 IsLiteral ? diag::warn_impcast_literal_float_to_integer_out_of_range
10544 : diag::warn_impcast_float_to_integer_out_of_range,
10547 unsigned DiagID = 0;
10550 DiagID = diag::warn_impcast_literal_float_to_integer;
10551 }
else if (IntegerValue == 0) {
10552 if (Value.isZero()) {
10554 diag::warn_impcast_float_integer, PruneWarnings);
10557 DiagID = diag::warn_impcast_float_to_integer_zero;
10559 if (IntegerValue.isUnsigned()) {
10560 if (!IntegerValue.isMaxValue()) {
10562 diag::warn_impcast_float_integer, PruneWarnings);
10565 if (!IntegerValue.isMaxSignedValue() &&
10566 !IntegerValue.isMinSignedValue()) {
10568 diag::warn_impcast_float_integer, PruneWarnings);
10572 DiagID = diag::warn_impcast_float_to_integer;
10581 unsigned precision = llvm::APFloat::semanticsPrecision(Value.getSemantics());
10582 precision = (precision * 59 + 195) / 196;
10583 Value.toString(PrettySourceValue, precision);
10587 PrettyTargetValue = Value.isZero() ?
"false" :
"true";
10589 IntegerValue.toString(PrettyTargetValue);
10591 if (PruneWarnings) {
10595 << PrettySourceValue << PrettyTargetValue
10607 assert(isa<CompoundAssignOperator>(E) &&
10608 "Must be compound assignment operation");
10618 const auto *RBT = cast<CompoundAssignOperator>(E)
10619 ->getComputationResultType()
10626 if (ResultBT->isInteger())
10628 E->
getExprLoc(), diag::warn_impcast_float_integer);
10632 else if (ResultBT->isFloatingPoint() && ResultBT->getKind() < RBT->
getKind() &&
10637 diag::warn_impcast_float_result_precision);
10642 if (!Range.Width)
return "0";
10644 llvm::APSInt ValueInRange =
Value;
10645 ValueInRange.setIsSigned(!Range.NonNegative);
10646 ValueInRange = ValueInRange.trunc(Range.Width);
10647 return ValueInRange.toString(10);
10651 if (!isa<ImplicitCastExpr>(Ex))
10656 const Type *Source =
10663 const Type *BoolCandidateType = ToBool ? Target : Source;
10665 return (BoolCandidateType->isSpecificBuiltinType(BuiltinType::Bool) &&
10672 for (
unsigned i = 0; i < NumArgs; ++i) {
10677 bool IsSwapped = ((i > 0) &&
10679 IsSwapped |= ((i < (NumArgs - 1)) &&
10685 diag::warn_impcast_floating_point_to_bool);
10692 if (S.
Diags.
isIgnored(diag::warn_impcast_null_pointer_to_integer,
10697 if (isa<CallExpr>(E))
10723 if (MacroName ==
"NULL")
10731 S.
Diag(Loc, diag::warn_impcast_null_pointer_to_integer)
10749 unsigned ElementKind) {
10751 if (
auto ICE = dyn_cast<ImplicitCastExpr>(Element)) {
10752 if (ICE->getCastKind() == CK_BitCast &&
10754 Element = ICE->getSubExpr();
10764 S.
Diag(Element->
getBeginLoc(), diag::warn_objc_collection_literal_element)
10765 << ElementType << ElementKind << TargetElementType
10769 if (
auto ArrayLiteral = dyn_cast<ObjCArrayLiteral>(Element))
10771 else if (
auto DictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(Element))
10783 if (!TargetObjCPtr)
10786 if (TargetObjCPtr->isUnspecialized() ||
10787 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
10792 if (TypeArgs.size() != 1)
10795 QualType TargetElementType = TypeArgs[0];
10796 for (
unsigned I = 0, N = ArrayLiteral->
getNumElements(); I != N; ++I) {
10812 if (!TargetObjCPtr)
10815 if (TargetObjCPtr->isUnspecialized() ||
10816 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
10821 if (TypeArgs.size() != 2)
10824 QualType TargetKeyType = TypeArgs[0];
10825 QualType TargetObjectType = TypeArgs[1];
10826 for (
unsigned I = 0, N = DictionaryLiteral->
getNumElements(); I != N; ++I) {
10841 const char FirstLiteralCharacter =
10843 if (FirstLiteralCharacter ==
'0')
10850 const char FirstContextCharacter =
10852 if (FirstContextCharacter ==
'{')
10861 bool *ICContext =
nullptr) {
10866 if (Source == Target)
return;
10882 if (isa<StringLiteral>(E))
10887 diag::warn_impcast_string_literal_to_bool);
10888 if (isa<ObjCStringLiteral>(E) || isa<ObjCArrayLiteral>(E) ||
10889 isa<ObjCDictionaryLiteral>(E) || isa<ObjCBoxedExpr>(E)) {
10893 diag::warn_impcast_objective_c_literal_to_bool);
10904 if (
auto *ArrayLiteral = dyn_cast<ObjCArrayLiteral>(E))
10906 else if (
auto *DictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(E))
10910 if (isa<VectorType>(Source)) {
10911 if (!isa<VectorType>(Target)) {
10914 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_vector_scalar);
10922 Source = cast<VectorType>(Source)->getElementType().getTypePtr();
10923 Target = cast<VectorType>(Target)->getElementType().getTypePtr();
10925 if (
auto VecTy = dyn_cast<VectorType>(Target))
10926 Target = VecTy->getElementType().getTypePtr();
10929 if (isa<ComplexType>(Source)) {
10930 if (!isa<ComplexType>(Target)) {
10936 ? diag::err_impcast_complex_scalar
10937 : diag::warn_impcast_complex_scalar);
10940 Source = cast<ComplexType>(Source)->getElementType().getTypePtr();
10941 Target = cast<ComplexType>(Target)->getElementType().getTypePtr();
10950 if (TargetBT && TargetBT->isFloatingPoint()) {
10954 if (SourceBT->
getKind() > TargetBT->getKind()) {
10972 else if (TargetBT->getKind() > SourceBT->
getKind()) {
10982 if (TargetBT && TargetBT->isInteger()) {
11001 CallExpr *CEx = cast<CallExpr>(E);
11005 if (isa<ImplicitCastExpr>(LastA) &&
11009 diag::warn_impcast_floating_point_to_bool);
11029 IntRange TargetRange = IntRange::forTargetOfCanonicalType(S.
Context, Target);
11031 if (SourceRange.Width > TargetRange.Width) {
11036 llvm::APSInt
Value(32);
11042 std::string PrettySourceValue = Value.toString(10);
11046 S.
PDiag(diag::warn_impcast_integer_precision_constant)
11047 << PrettySourceValue << PrettyTargetValue
11058 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_64_32,
11060 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_precision);
11063 if (TargetRange.Width > SourceRange.Width) {
11064 if (
auto *UO = dyn_cast<UnaryOperator>(E))
11065 if (UO->getOpcode() == UO_Minus)
11069 diag::warn_impcast_high_order_zero_bits);
11072 diag::warn_impcast_nonnegative_result);
11076 if (TargetRange.Width == SourceRange.Width && !TargetRange.NonNegative &&
11087 std::string PrettySourceValue = Value.toString(10);
11092 S.
PDiag(diag::warn_impcast_integer_precision_constant)
11093 << PrettySourceValue << PrettyTargetValue << E->
getType() << T
11102 if ((TargetRange.NonNegative && !SourceRange.NonNegative) ||
11103 (!TargetRange.NonNegative && SourceRange.NonNegative &&
11104 SourceRange.Width == TargetRange.Width)) {
11108 unsigned DiagID = diag::warn_impcast_integer_sign;
11116 DiagID = diag::warn_impcast_integer_sign_conditional;
11130 EnumDecl *Enum = cast<EnumDecl>(ECD->getDeclContext());
11138 if (SourceEnum->getDecl()->hasNameForLinkage() &&
11139 TargetEnum->getDecl()->hasNameForLinkage() &&
11140 SourceEnum != TargetEnum) {
11145 diag::warn_impcast_different_enum_types);
11156 if (isa<ConditionalOperator>(E))
11168 bool Suspicious =
false;
11174 if (!Suspicious)
return;
11177 if (!S.
Diags.
isIgnored(diag::warn_impcast_integer_sign_conditional, CC))
11182 if (E->
getType() == T)
return;
11184 Suspicious =
false;
11186 E->
getType(), CC, &Suspicious);
11189 E->
getType(), CC, &Suspicious);
11215 if (isa<ConditionalOperator>(E)) {
11222 if (
CallExpr *Call = dyn_cast<CallExpr>(E))
11237 for (
auto *SE : POE->semantics())
11238 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(SE))
11243 if (
auto *CE = dyn_cast<ExplicitCastExpr>(E)) {
11252 if (BO->isComparisonOp())
11256 if (BO->getOpcode() == BO_Assign)
11259 if (BO->isAssignmentOp())
11267 if (isa<StmtExpr>(E))
return;
11270 if (isa<UnaryExprOrTypeTraitExpr>(E))
return;
11275 bool IsLogicalAndOperator = BO && BO->
getOpcode() == BO_LAnd;
11277 Expr *ChildExpr = dyn_cast_or_null<Expr>(SubStmt);
11281 if (IsLogicalAndOperator &&
11291 if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
11295 if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
11300 if (U->getOpcode() == UO_LNot) {
11302 }
else if (U->getOpcode() != UO_AddrOf) {
11303 if (U->getSubExpr()->getType()->isAtomicType())
11304 S.
Diag(U->getSubExpr()->getBeginLoc(),
11305 diag::warn_atomic_implicit_seq_cst);
11316 diag::err_opencl_enqueue_kernel_invalid_local_size_type);
11333 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11334 if (!DRE->getDecl()->getType()->isReferenceType())
11336 }
else if (
const MemberExpr *M = dyn_cast<MemberExpr>(E)) {
11337 if (!M->getMemberDecl()->getType()->isReferenceType())
11339 }
else if (
const CallExpr *Call = dyn_cast<CallExpr>(E)) {
11351 SemaRef.
Diag(FD->
getLocation(), diag::note_reference_is_return_value) << FD;
11396 if (isa<CXXThisExpr>(E)) {
11397 unsigned DiagID = IsCompare ? diag::warn_this_null_compare
11398 : diag::warn_this_bool_conversion;
11403 bool IsAddressOf =
false;
11406 if (UO->getOpcode() != UO_AddrOf)
11408 IsAddressOf =
true;
11409 E = UO->getSubExpr();
11413 unsigned DiagID = IsCompare
11414 ? diag::warn_address_of_reference_null_compare
11415 : diag::warn_address_of_reference_bool_conversion;
11423 auto ComplainAboutNonnullParamOrCall = [&](
const Attr *NonnullAttr) {
11424 bool IsParam = isa<NonNullAttr>(NonnullAttr);
11426 llvm::raw_string_ostream S(Str);
11428 unsigned DiagID = IsCompare ? diag::warn_nonnull_expr_compare
11429 : diag::warn_cast_nonnull_to_bool;
11432 Diag(NonnullAttr->getLocation(), diag::note_declared_nonnull) << IsParam;
11438 if (
const Attr *A = Callee->getAttr<ReturnsNonNullAttr>()) {
11439 ComplainAboutNonnullParamOrCall(A);
11449 }
else if (
MemberExpr *M = dyn_cast<MemberExpr>(E)) {
11450 D = M->getMemberDecl();
11458 if (
const auto* PV = dyn_cast<ParmVarDecl>(D)) {
11459 if (getCurFunction() &&
11460 !getCurFunction()->ModifiedNonNullParams.count(PV)) {
11461 if (
const Attr *A = PV->getAttr<NonNullAttr>()) {
11462 ComplainAboutNonnullParamOrCall(A);
11466 if (
const auto *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
11467 auto ParamIter = llvm::find(FD->
parameters(), PV);
11473 ComplainAboutNonnullParamOrCall(
NonNull);
11478 if (ArgNo.getASTIndex() == ParamNo) {
11479 ComplainAboutNonnullParamOrCall(
NonNull);
11493 if (IsAddressOf && IsFunction) {
11498 if (!IsAddressOf && !IsFunction && !IsArray)
11503 llvm::raw_string_ostream S(Str);
11506 unsigned DiagID = IsCompare ? diag::warn_null_pointer_compare
11507 : diag::warn_impcast_pointer_to_bool;
11514 DiagType = AddressOf;
11515 else if (IsFunction)
11516 DiagType = FunctionPointer;
11518 DiagType = ArrayPointer;
11520 llvm_unreachable(
"Could not determine diagnostic.");
11522 << Range << IsEqual;
11534 tryExprAsCall(*E, ReturnType, NonTemplateOverloads);
11535 if (ReturnType.isNull())
11542 if (!ReturnType->isPointerType()) {
11545 if (!ReturnType->isIntegerType())
11554 if (!ReturnType->isSpecificBuiltinType(BuiltinType::Bool))
11570 if (isUnevaluatedContext())
11580 CheckArrayAccess(E);
11594 void Sema::CheckForIntOverflow (
Expr *E) {
11599 Expr *OriginalE = Exprs.pop_back_val();
11602 if (isa<BinaryOperator>(E)) {
11607 if (
auto InitList = dyn_cast<InitListExpr>(OriginalE))
11608 Exprs.append(InitList->inits().begin(), InitList->inits().end());
11609 else if (isa<ObjCBoxedExpr>(OriginalE))
11611 else if (
auto Call = dyn_cast<CallExpr>(E))
11613 else if (
auto Message = dyn_cast<ObjCMessageExpr>(E))
11614 Exprs.append(Message->arg_begin(), Message->arg_end());
11615 }
while (!Exprs.empty());
11630 class SequenceTree {
11634 unsigned Merged : 1;
11642 friend class SequenceTree;
11644 unsigned Index = 0;
11646 explicit Seq(
unsigned N) : Index(N) {}
11652 SequenceTree() { Values.push_back(
Value(0)); }
11653 Seq root()
const {
return Seq(0); }
11658 Seq allocate(Seq
Parent) {
11659 Values.push_back(
Value(Parent.Index));
11660 return Seq(Values.size() - 1);
11664 void merge(Seq S) {
11665 Values[S.Index].Merged =
true;
11671 bool isUnsequenced(Seq Cur, Seq Old) {
11672 unsigned C = representative(Cur.Index);
11673 unsigned Target = representative(Old.Index);
11674 while (C >= Target) {
11677 C = Values[
C].Parent;
11684 unsigned representative(
unsigned K) {
11685 if (Values[K].Merged)
11687 return Values[K].Parent = representative(Values[K].Parent);
11707 UK_ModAsSideEffect,
11709 UK_Count = UK_ModAsSideEffect + 1
11713 Expr *Use =
nullptr;
11714 SequenceTree::Seq Seq;
11720 Usage Uses[UK_Count];
11723 bool Diagnosed =
false;
11725 UsageInfo() =
default;
11727 using UsageInfoMap = llvm::SmallDenseMap<Object, UsageInfo, 16>;
11735 UsageInfoMap UsageMap;
11738 SequenceTree::Seq Region;
11753 struct SequencedSubexpression {
11754 SequencedSubexpression(SequenceChecker &Self)
11755 : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) {
11756 Self.ModAsSideEffect = &ModAsSideEffect;
11759 ~SequencedSubexpression() {
11760 for (
auto &M : llvm::reverse(ModAsSideEffect)) {
11761 UsageInfo &U = Self.UsageMap[M.first];
11762 auto &SideEffectUsage = U.Uses[UK_ModAsSideEffect];
11763 Self.addUsage(U, M.first, SideEffectUsage.Use, UK_ModAsValue);
11764 SideEffectUsage = M.second;
11766 Self.ModAsSideEffect = OldModAsSideEffect;
11769 SequenceChecker &Self;
11778 class EvaluationTracker {
11780 EvaluationTracker(SequenceChecker &Self)
11781 : Self(Self), Prev(Self.EvalTracker) {
11782 Self.EvalTracker =
this;
11785 ~EvaluationTracker() {
11786 Self.EvalTracker = Prev;
11788 Prev->EvalOK &= EvalOK;
11791 bool evaluate(
const Expr *E,
bool &Result) {
11799 SequenceChecker &Self;
11800 EvaluationTracker *Prev;
11801 bool EvalOK =
true;
11802 } *EvalTracker =
nullptr;
11806 Object getObject(
Expr *E,
bool Mod)
const {
11809 if (Mod && (UO->getOpcode() == UO_PreInc || UO->getOpcode() == UO_PreDec))
11810 return getObject(UO->getSubExpr(), Mod);
11812 if (BO->getOpcode() == BO_Comma)
11813 return getObject(BO->getRHS(), Mod);
11814 if (Mod && BO->isAssignmentOp())
11815 return getObject(BO->getLHS(), Mod);
11816 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
11818 if (isa<CXXThisExpr>(ME->getBase()->IgnoreParenCasts()))
11819 return ME->getMemberDecl();
11820 }
else if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
11822 return DRE->getDecl();
11827 void addUsage(UsageInfo &UI, Object O,
Expr *Ref, UsageKind UK) {
11828 Usage &U = UI.Uses[UK];
11829 if (!U.Use || !Tree.isUnsequenced(Region, U.Seq)) {
11830 if (UK == UK_ModAsSideEffect && ModAsSideEffect)
11831 ModAsSideEffect->push_back(std::make_pair(O, U));
11838 void checkUsage(Object O, UsageInfo &UI,
Expr *Ref, UsageKind OtherKind,
11843 const Usage &U = UI.Uses[OtherKind];
11844 if (!U.Use || !Tree.isUnsequenced(Region, U.Seq))
11848 Expr *ModOrUse = Ref;
11849 if (OtherKind == UK_Use)
11850 std::swap(Mod, ModOrUse);
11853 IsModMod ? diag::warn_unsequenced_mod_mod
11854 : diag::warn_unsequenced_mod_use)
11856 UI.Diagnosed =
true;
11859 void notePreUse(Object O,
Expr *Use) {
11860 UsageInfo &U = UsageMap[O];
11862 checkUsage(O, U, Use, UK_ModAsValue,
false);
11865 void notePostUse(Object O,
Expr *Use) {
11866 UsageInfo &U = UsageMap[O];
11867 checkUsage(O, U, Use, UK_ModAsSideEffect,
false);
11868 addUsage(U, O, Use, UK_Use);
11871 void notePreMod(Object O,
Expr *Mod) {
11872 UsageInfo &U = UsageMap[O];
11874 checkUsage(O, U, Mod, UK_ModAsValue,
true);
11875 checkUsage(O, U, Mod, UK_Use,
false);
11878 void notePostMod(Object O,
Expr *Use, UsageKind UK) {
11879 UsageInfo &U = UsageMap[O];
11880 checkUsage(O, U, Use, UK_ModAsSideEffect,
true);
11881 addUsage(U, O, Use, UK);
11886 :
Base(S.
Context), SemaRef(S), Region(Tree.root()), WorkList(WorkList) {
11890 void VisitStmt(
Stmt *S) {
11894 void VisitExpr(
Expr *E) {
11896 Base::VisitStmt(E);
11900 Object O = Object();
11911 void VisitSequencedExpressions(
Expr *SequencedBefore,
Expr *SequencedAfter) {
11912 SequenceTree::Seq BeforeRegion = Tree.allocate(Region);
11913 SequenceTree::Seq AfterRegion = Tree.allocate(Region);
11914 SequenceTree::Seq OldRegion = Region;
11917 SequencedSubexpression SeqBefore(*
this);
11918 Region = BeforeRegion;
11919 Visit(SequencedBefore);
11922 Region = AfterRegion;
11923 Visit(SequencedAfter);
11925 Region = OldRegion;
11927 Tree.merge(BeforeRegion);
11928 Tree.merge(AfterRegion);
11936 VisitSequencedExpressions(ASE->
getLHS(), ASE->
getRHS());
11938 Base::VisitStmt(ASE);
11946 VisitSequencedExpressions(BO->
getLHS(), BO->
getRHS());
11953 Object O = getObject(BO->
getLHS(),
true);
11955 return VisitExpr(BO);
11965 if (isa<CompoundAssignOperator>(BO))
11970 if (isa<CompoundAssignOperator>(BO))
11971 notePostUse(O, BO);
11979 notePostMod(O, BO, SemaRef.
getLangOpts().CPlusPlus ? UK_ModAsValue
11980 : UK_ModAsSideEffect);
11984 VisitBinAssign(CAO);
11987 void VisitUnaryPreInc(
UnaryOperator *UO) { VisitUnaryPreIncDec(UO); }
11988 void VisitUnaryPreDec(
UnaryOperator *UO) { VisitUnaryPreIncDec(UO); }
11990 Object O = getObject(UO->
getSubExpr(),
true);
11992 return VisitExpr(UO);
11998 notePostMod(O, UO, SemaRef.
getLangOpts().CPlusPlus ? UK_ModAsValue
11999 : UK_ModAsSideEffect);
12002 void VisitUnaryPostInc(
UnaryOperator *UO) { VisitUnaryPostIncDec(UO); }
12003 void VisitUnaryPostDec(
UnaryOperator *UO) { VisitUnaryPostIncDec(UO); }
12005 Object O = getObject(UO->
getSubExpr(),
true);
12007 return VisitExpr(UO);
12011 notePostMod(O, UO, UK_ModAsSideEffect);
12020 EvaluationTracker Eval(*
this);
12022 SequencedSubexpression Sequenced(*
this);
12027 if (Eval.evaluate(BO->
getLHS(), Result)) {
12037 WorkList.push_back(BO->
getRHS());
12041 EvaluationTracker Eval(*
this);
12043 SequencedSubexpression Sequenced(*
this);
12048 if (Eval.evaluate(BO->
getLHS(), Result)) {
12052 WorkList.push_back(BO->
getRHS());
12059 EvaluationTracker Eval(*
this);
12061 SequencedSubexpression Sequenced(*
this);
12066 if (Eval.evaluate(CO->
getCond(), Result))
12074 void VisitCallExpr(
CallExpr *CE) {
12081 SequencedSubexpression Sequenced(*
this);
12082 Base::VisitCallExpr(CE);
12089 SequencedSubexpression Sequenced(*
this);
12092 return VisitExpr(CCE);
12096 SequenceTree::Seq
Parent = Region;
12100 Region = Tree.allocate(Parent);
12101 Elts.push_back(Region);
12107 for (
unsigned I = 0; I < Elts.size(); ++I)
12108 Tree.merge(Elts[I]);
12113 return VisitExpr(ILE);
12117 SequenceTree::Seq
Parent = Region;
12118 for (
unsigned I = 0; I < ILE->
getNumInits(); ++I) {
12121 Region = Tree.allocate(Parent);
12122 Elts.push_back(Region);
12128 for (
unsigned I = 0; I < Elts.size(); ++I)
12129 Tree.merge(Elts[I]);
12135 void Sema::CheckUnsequencedOperations(
Expr *E) {
12137 WorkList.push_back(E);
12138 while (!WorkList.empty()) {
12139 Expr *Item = WorkList.pop_back_val();
12140 SequenceChecker(*
this, Item, WorkList);
12145 bool IsConstexpr) {
12146 CheckImplicitConversions(E, CheckLoc);
12148 CheckUnsequencedOperations(E);
12150 CheckForIntOverflow(E);
12151 DiagnoseMisalignedMembers();
12164 if (
const auto *PointerTy = dyn_cast<PointerType>(PType)) {
12168 if (
const auto *ReferenceTy = dyn_cast<ReferenceType>(PType)) {
12172 if (
const auto *ParenTy = dyn_cast<ParenType>(PType)) {
12186 S.
Diag(Loc, diag::err_array_star_in_function_definition);
12195 bool CheckParameterNames) {
12196 bool HasInvalidParm =
false;
12203 if (!Param->isInvalidDecl() &&
12204 RequireCompleteType(Param->getLocation(), Param->getType(),
12205 diag::err_typecheck_decl_incomplete_type)) {
12206 Param->setInvalidDecl();
12207 HasInvalidParm =
true;
12212 if (CheckParameterNames &&
12213 Param->getIdentifier() ==
nullptr &&
12214 !Param->isImplicit() &&
12215 !getLangOpts().CPlusPlus)
12216 Diag(Param->getLocation(), diag::err_parameter_name_omitted);
12223 QualType PType = Param->getOriginalType();
12231 if (!Param->isInvalidDecl()) {
12232 if (
CXXRecordDecl *ClassDecl = Param->getType()->getAsCXXRecordDecl()) {
12233 if (!ClassDecl->isInvalidDecl() &&
12234 !ClassDecl->hasIrrelevantDestructor() &&
12235 !ClassDecl->isDependentContext() &&
12236 ClassDecl->isParamDestroyedInCallee()) {
12238 MarkFunctionReferenced(Param->getLocation(), Destructor);
12239 DiagnoseUseOfDecl(Destructor, Param->
getLocation());
12248 if (
const auto *
Attr = Param->getAttr<PassObjectSizeAttr>())
12249 if (!Param->getType().isConstQualified())
12250 Diag(Param->getLocation(), diag::err_attribute_pointers_only)
12254 if (LangOpts.CPlusPlus && !Param->isInvalidDecl()) {
12259 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC->
getParent()))
12260 CheckShadowInheritedFields(Param->getLocation(), Param->getDeclName(),
12266 return HasInvalidParm;
12273 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
12276 if (
const auto *ME = dyn_cast<MemberExpr>(E))
12287 if (getDiagnostics().isIgnored(diag::warn_cast_align, TRange.
getBegin()))
12296 if (!DestPtr)
return;
12302 if (DestAlign.
isOne())
return;
12306 if (!SrcPtr)
return;
12317 if (
auto *CE = dyn_cast<CastExpr>(Op)) {
12318 if (CE->getCastKind() == CK_ArrayToPointerDecay)
12319 SrcAlign =
getDeclAlign(CE->getSubExpr(), SrcAlign, Context);
12320 }
else if (
auto *UO = dyn_cast<UnaryOperator>(Op)) {
12321 if (UO->getOpcode() == UO_AddrOf)
12322 SrcAlign =
getDeclAlign(UO->getSubExpr(), SrcAlign, Context);
12325 if (SrcAlign >= DestAlign)
return;
12330 << static_cast<unsigned>(DestAlign.
getQuantity())
12341 if (Size != 1 || !ND)
return false;
12344 if (!FD)
return false;
12367 if (!RD)
return false;
12368 if (RD->
isUnion())
return false;
12369 if (
const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
12370 if (!CRD->isStandardLayout())
return false;
12374 const Decl *D = FD;
12376 if (isa<FieldDecl>(D))
12381 void Sema::CheckArrayAccess(
const Expr *BaseExpr,
const Expr *IndexExpr,
12383 bool AllowOnePastEnd,
bool IndexNegated) {
12388 const Type *EffectiveType =
12403 llvm::APSInt index = Result.
Val.
getInt();
12408 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr))
12409 ND = DRE->getDecl();
12410 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr))
12411 ND = ME->getMemberDecl();
12413 if (index.isUnsigned() || !index.isNegative()) {
12423 llvm::APInt size = ArrayTy->
getSize();
12424 if (!size.isStrictlyPositive())
12427 if (BaseType != EffectiveType) {
12429 uint64_t ptrarith_typesize = Context.
getTypeSize(EffectiveType);
12430 uint64_t array_typesize = Context.
getTypeSize(BaseType);
12432 if (!ptrarith_typesize) ptrarith_typesize = 1;
12433 if (ptrarith_typesize != array_typesize) {
12435 uint64_t ratio = array_typesize / ptrarith_typesize;
12438 if (ptrarith_typesize * ratio == array_typesize)
12439 size *= llvm::APInt(size.getBitWidth(), ratio);
12443 if (size.getBitWidth() > index.getBitWidth())
12444 index = index.zext(size.getBitWidth());
12445 else if (size.getBitWidth() < index.getBitWidth())
12446 size = size.zext(index.getBitWidth());
12452 if (AllowOnePastEnd ? index.ule(size) : index.ult(size))
12467 if (SourceMgr.isInSystemHeader(RBracketLoc)) {
12469 SourceMgr.getSpellingLoc(IndexExpr->
getBeginLoc());
12470 if (SourceMgr.isWrittenInSameFile(RBracketLoc, IndexLoc))
12475 unsigned DiagID = diag::warn_ptr_arith_exceeds_bounds;
12477 DiagID = diag::warn_array_index_exceeds_bounds;
12479 DiagRuntimeBehavior(BaseExpr->
getBeginLoc(), BaseExpr,
12480 PDiag(DiagID) << index.toString(10,
true)
12481 << size.toString(10,
true)
12482 << (unsigned)size.getLimitedValue(~0U)
12485 unsigned DiagID = diag::warn_array_index_precedes_bounds;
12487 DiagID = diag::warn_ptr_arith_precedes_bounds;
12488 if (index.isNegative()) index = -index;
12491 DiagRuntimeBehavior(BaseExpr->
getBeginLoc(), BaseExpr,
12492 PDiag(DiagID) << index.toString(10,
true)
12499 dyn_cast<ArraySubscriptExpr>(BaseExpr))
12501 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr))
12502 ND = DRE->getDecl();
12503 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr))
12504 ND = ME->getMemberDecl();
12509 PDiag(diag::note_array_index_out_of_bounds)
12513 void Sema::CheckArrayAccess(
const Expr *
expr) {
12514 int AllowOnePastEnd = 0;
12518 case Stmt::ArraySubscriptExprClass: {
12521 AllowOnePastEnd > 0);
12525 case Stmt::MemberExprClass: {
12526 expr = cast<MemberExpr>(
expr)->getBase();
12529 case Stmt::OMPArraySectionExprClass: {
12533 nullptr, AllowOnePastEnd > 0);
12536 case Stmt::UnaryOperatorClass: {
12552 case Stmt::ConditionalOperatorClass: {
12555 CheckArrayAccess(lhs);
12557 CheckArrayAccess(rhs);
12560 case Stmt::CXXOperatorCallExprClass: {
12561 const auto *OCE = cast<CXXOperatorCallExpr>(
expr);
12562 for (
const auto *Arg : OCE->arguments())
12563 CheckArrayAccess(Arg);
12576 struct RetainCycleOwner {
12580 bool Indirect =
false;
12582 RetainCycleOwner() =
default;
12584 void setLocsFrom(
Expr *e) {
12601 owner.Variable = var;
12603 owner.setLocsFrom(ref);
12611 switch (
cast->getCastKind()) {
12613 case CK_LValueBitCast:
12614 case CK_LValueToRValue:
12615 case CK_ARCReclaimReturnedObject:
12616 e =
cast->getSubExpr();
12633 if (ref->isFreeIvar()) owner.setLocsFrom(ref);
12634 owner.Indirect =
true;
12638 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(e)) {
12640 if (!var)
return false;
12644 if (
MemberExpr *member = dyn_cast<MemberExpr>(e)) {
12645 if (member->isArrow())
return false;
12648 e = member->getBase();
12657 if (!pre)
return false;
12660 if (!property->isRetaining() &&
12661 !(
property->getPropertyIvarDecl() &&
12662 property->getPropertyIvarDecl()->getType()
12666 owner.Indirect =
true;
12669 if (!owner.Variable)
12675 e =
const_cast<Expr*
>(cast<OpaqueValueExpr>(pre->
getBase())
12676 ->getSourceExpr());
12691 Expr *Capturer =
nullptr;
12692 bool VarWillBeReased =
false;
12696 Context(Context), Variable(variable) {}
12699 if (ref->
getDecl() == Variable && !Capturer)
12704 if (Capturer)
return;
12710 void VisitBlockExpr(
BlockExpr *block) {
12717 if (Capturer)
return;
12723 if (!Variable || VarWillBeReased || BinOp->
getOpcode() != BO_Assign)
12726 if (
const DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(LHS)) {
12727 if (DRE->getDecl() != Variable)
12731 llvm::APSInt
Value;
12733 (RHS && RHS->isIntegerConstantExpr(Value, Context) && Value == 0);
12744 assert(owner.Variable && owner.Loc.isValid());
12752 e = ME->getInstanceReceiver();
12755 e = e->IgnoreParenCasts();
12757 }
else if (
CallExpr *CE = dyn_cast<CallExpr>(e)) {
12762 if (FnI && FnI->
isStr(
"_Block_copy")) {
12773 FindCaptureVisitor visitor(S.
Context, owner.Variable);
12775 return visitor.VarWillBeReased ? nullptr : visitor.Capturer;
12779 RetainCycleOwner &owner) {
12781 assert(owner.Variable && owner.Loc.isValid());
12785 S.
Diag(owner.Loc, diag::note_arc_retain_cycle_owner)
12786 << owner.Indirect << owner.Range;
12795 while (!str.empty() && str.front() ==
'_') str = str.substr(1);
12796 if (str.startswith(
"set"))
12797 str = str.substr(3);
12798 else if (str.startswith(
"add")) {
12800 if (sel.
getNumArgs() == 1 && str.startswith(
"addOperationWithBlock"))
12802 str = str.substr(3);
12807 if (str.empty())
return true;
12813 bool IsMutableArray = S.
NSAPIObj->isSubclassOfNSClass(
12816 if (!IsMutableArray) {
12823 S.
NSAPIObj->getNSArrayMethodKind(Sel);
12848 bool IsMutableDictionary = S.
NSAPIObj->isSubclassOfNSClass(
12851 if (!IsMutableDictionary) {
12858 S.
NSAPIObj->getNSDictionaryMethodKind(Sel);
12879 bool IsMutableSet = S.
NSAPIObj->isSubclassOfNSClass(
12883 bool IsMutableOrderedSet = S.
NSAPIObj->isSubclassOfNSClass(
12886 if (!IsMutableSet && !IsMutableOrderedSet) {
12925 int ArgIndex = *ArgOpt;
12933 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
12934 if (ArgRE->isObjCSelfExpr()) {
12936 diag::warn_objc_circular_container)
12937 << ArgRE->getDecl() << StringRef(
"'super'");
12947 if (
DeclRefExpr *ReceiverRE = dyn_cast<DeclRefExpr>(Receiver)) {
12948 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
12949 if (ReceiverRE->getDecl() == ArgRE->getDecl()) {
12952 diag::warn_objc_circular_container)
12954 if (!ArgRE->isObjCSelfExpr()) {
12956 diag::note_objc_circular_container_declared_here)
12961 }
else if (
ObjCIvarRefExpr *IvarRE = dyn_cast<ObjCIvarRefExpr>(Receiver)) {
12963 if (IvarRE->getDecl() == IvarArgRE->getDecl()) {
12966 diag::warn_objc_circular_container)
12969 diag::note_objc_circular_container_declared_here)
12984 RetainCycleOwner owner;
12990 owner.Variable = getCurMethodDecl()->getSelfDecl();
12997 for (
unsigned i = 0, e = msg->
getNumArgs(); i != e; ++i) {
13000 if (MD && MD->
parameters()[i]->hasAttr<NoEscapeAttr>())
13009 RetainCycleOwner owner;
13018 RetainCycleOwner Owner;
13032 Expr *RHS,
bool isProperty) {
13044 S.
Diag(Loc, diag::warn_arc_literal_assign)
13046 << (isProperty ? 0 : 1)
13054 Expr *RHS,
bool isProperty) {
13057 if (
cast->getCastKind() == CK_ARCConsumeObject) {
13058 S.
Diag(Loc, diag::warn_arc_retained_assign)
13060 << (isProperty ? 0 : 1)
13064 RHS =
cast->getSubExpr();
13106 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
13107 getCurFunction()->markSafeWeakUse(LHS);
13110 if (checkUnsafeAssigns(Loc, LHSType, RHS))
13130 if (!(AsWrittenAttr & ObjCPropertyDecl::OBJC_PR_assign) &&
13135 if (
cast->getCastKind() == CK_ARCConsumeObject) {
13136 Diag(Loc, diag::warn_arc_retained_property_assign)
13140 RHS =
cast->getSubExpr();
13164 bool StmtLineInvalid;
13167 if (StmtLineInvalid)
13170 bool BodyLineInvalid;
13173 if (BodyLineInvalid)
13177 if (StmtLine != BodyLine)
13188 if (CurrentInstantiationScope)
13201 Diag(NBody->
getSemiLoc(), diag::note_empty_body_on_separate_line);
13205 const Stmt *PossibleBody) {
13206 assert(!CurrentInstantiationScope);
13211 if (
const ForStmt *FS = dyn_cast<ForStmt>(S)) {
13212 StmtLoc = FS->getRParenLoc();
13213 Body = FS->getBody();
13214 DiagID = diag::warn_empty_for_body;
13215 }
else if (
const WhileStmt *WS = dyn_cast<WhileStmt>(S)) {
13216 StmtLoc = WS->getCond()->getSourceRange().getEnd();
13217 Body = WS->getBody();
13218 DiagID = diag::warn_empty_while_body;
13228 if (Diags.isIgnored(DiagID, NBody->
getSemiLoc()))
13246 bool ProbableTypo = isa<CompoundStmt>(PossibleBody);
13247 if (!ProbableTypo) {
13248 bool BodyColInvalid;
13249 unsigned BodyCol = SourceMgr.getPresumedColumnNumber(
13251 if (BodyColInvalid)
13254 bool StmtColInvalid;
13256 SourceMgr.getPresumedColumnNumber(S->
getBeginLoc(), &StmtColInvalid);
13257 if (StmtColInvalid)
13260 if (BodyCol > StmtCol)
13261 ProbableTypo =
true;
13264 if (ProbableTypo) {
13266 Diag(NBody->
getSemiLoc(), diag::note_empty_body_on_separate_line);
13275 if (Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess, OpLoc))
13278 if (inTemplateInstantiation())
13295 RHSExpr = CE->
getArg(0);
13301 if (LHSDeclRef && RHSDeclRef) {
13302 if (!LHSDeclRef->
getDecl() || !RHSDeclRef->getDecl())
13308 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
13318 const Expr *LHSBase = LHSExpr;
13319 const Expr *RHSBase = RHSExpr;
13322 if (!LHSME || !RHSME)
13325 while (LHSME && RHSME) {
13331 RHSBase = RHSME->getBase();
13338 if (LHSDeclRef && RHSDeclRef) {
13339 if (!LHSDeclRef->getDecl() || !RHSDeclRef->getDecl())
13341 if (LHSDeclRef->getDecl()->getCanonicalDecl() !=
13342 RHSDeclRef->getDecl()->getCanonicalDecl())
13345 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
13351 if (isa<CXXThisExpr>(LHSBase) && isa<CXXThisExpr>(RHSBase))
13352 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
13384 if (Bits1 != Bits2)
13396 if (
const CXXRecordDecl *D1CXX = dyn_cast<CXXRecordDecl>(RD1)) {
13401 if (D1CXX->getNumBases() != D2CXX->
getNumBases())
13406 Base1 = D1CXX->bases_begin(),
13407 BaseEnd1 = D1CXX->bases_end(),
13410 ++Base1, ++Base2) {
13414 }
else if (
const CXXRecordDecl *D2CXX = dyn_cast<CXXRecordDecl>(RD2)) {
13416 if (D2CXX->getNumBases() > 0)
13425 for ( ; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) {
13429 if (Field1 != Field1End || Field2 != Field2End)
13439 llvm::SmallPtrSet<FieldDecl *, 8> UnmatchedFields;
13440 for (
auto *Field2 : RD2->
fields())
13441 UnmatchedFields.insert(Field2);
13443 for (
auto *Field1 : RD1->
fields()) {
13444 llvm::SmallPtrSet<FieldDecl *, 8>::iterator
13445 I = UnmatchedFields.begin(),
13446 E = UnmatchedFields.end();
13448 for ( ; I != E; ++I) {
13450 bool Result = UnmatchedFields.erase(*I);
13460 return UnmatchedFields.empty();
13494 if (TC1 == Type::Enum) {
13496 cast<EnumType>(T1)->getDecl(),
13497 cast<EnumType>(T2)->getDecl());
13498 }
else if (TC1 == Type::Record) {
13503 cast<RecordType>(T1)->getDecl(),
13504 cast<RecordType>(T2)->getDecl());
13520 const ValueDecl **VD, uint64_t *MagicValue) {
13528 case Stmt::UnaryOperatorClass: {
13537 case Stmt::DeclRefExprClass: {
13538 const DeclRefExpr *DRE = cast<DeclRefExpr>(TypeExpr);
13543 case Stmt::IntegerLiteralClass: {
13545 llvm::APInt MagicValueAPInt = IL->
getValue();
13546 if (MagicValueAPInt.getActiveBits() <= 64) {
13547 *MagicValue = MagicValueAPInt.getZExtValue();
13553 case Stmt::BinaryConditionalOperatorClass:
13554 case Stmt::ConditionalOperatorClass: {
13556 cast<AbstractConditionalOperator>(TypeExpr);
13568 case Stmt::BinaryOperatorClass: {
13571 TypeExpr = BO->
getRHS();
13600 bool &FoundWrongKind,
13602 FoundWrongKind =
false;
13607 uint64_t MagicValue;
13613 if (TypeTagForDatatypeAttr *I = VD->
getAttr<TypeTagForDatatypeAttr>()) {
13614 if (I->getArgumentKind() != ArgumentKind) {
13615 FoundWrongKind =
true;
13618 TypeInfo.
Type = I->getMatchingCType();
13631 MagicValues->find(std::make_pair(ArgumentKind, MagicValue));
13632 if (I == MagicValues->end())
13635 TypeInfo = I->second;
13641 bool LayoutCompatible,
13643 if (!TypeTagForDatatypeMagicValues)
13644 TypeTagForDatatypeMagicValues.reset(
13645 new llvm::DenseMap<TypeTagMagicValue, TypeTagData>);
13648 (*TypeTagForDatatypeMagicValues)[Magic] =
13664 return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) ||
13665 (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) ||
13666 (T1Kind == BuiltinType::Char_U && T2Kind == BuiltinType::UChar) ||
13667 (T1Kind == BuiltinType::Char_S && T2Kind == BuiltinType::SChar);
13670 void Sema::CheckArgumentWithTypeTag(
const ArgumentWithTypeTagAttr *
Attr,
13671 const ArrayRef<const Expr *> ExprArgs,
13674 bool IsPointerAttr = Attr->getIsPointer();
13677 unsigned TypeTagIdxAST = Attr->getTypeTagIdx().getASTIndex();
13678 if (TypeTagIdxAST >= ExprArgs.size()) {
13679 Diag(CallSiteLoc, diag::err_tag_index_out_of_range)
13680 << 0 << Attr->getTypeTagIdx().getSourceIndex();
13683 const Expr *TypeTagExpr = ExprArgs[TypeTagIdxAST];
13684 bool FoundWrongKind;
13687 TypeTagForDatatypeMagicValues.get(),
13688 FoundWrongKind, TypeInfo)) {
13689 if (FoundWrongKind)
13691 diag::warn_type_tag_for_datatype_wrong_kind)
13697 unsigned ArgumentIdxAST = Attr->getArgumentIdx().getASTIndex();
13698 if (ArgumentIdxAST >= ExprArgs.size()) {
13699 Diag(CallSiteLoc, diag::err_tag_index_out_of_range)
13700 << 1 << Attr->getArgumentIdx().getSourceIndex();
13703 const Expr *ArgumentExpr = ExprArgs[ArgumentIdxAST];
13704 if (IsPointerAttr) {
13706 if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(ArgumentExpr))
13707 if (ICE->getType()->isVoidPointerType() &&
13708 ICE->getCastKind() == CK_BitCast)
13709 ArgumentExpr = ICE->getSubExpr();
13717 if (TypeInfo.MustBeNull) {
13722 diag::warn_type_safety_null_pointer_required)
13730 QualType RequiredType = TypeInfo.Type;
13734 bool mismatch =
false;
13735 if (!TypeInfo.LayoutCompatible) {
13736 mismatch = !Context.
hasSameType(ArgumentType, RequiredType);
13757 Diag(ArgumentExpr->
getExprLoc(), diag::warn_type_safety_type_mismatch)
13758 << ArgumentType << ArgumentKind
13759 << TypeInfo.LayoutCompatible << RequiredType
13766 MisalignedMembers.emplace_back(E, RD, MD, Alignment);
13770 for (MisalignedMember &m : MisalignedMembers) {
13776 Diag(m.E->getBeginLoc(), diag::warn_taking_address_of_packed_member)
13779 MisalignedMembers.clear();
13786 if (isa<UnaryOperator>(E) &&
13787 cast<UnaryOperator>(E)->
getOpcode() == UO_AddrOf) {
13788 auto *Op = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
13789 if (isa<MemberExpr>(Op)) {
13790 auto MA = std::find(MisalignedMembers.begin(), MisalignedMembers.end(),
13791 MisalignedMember(Op));
13792 if (MA != MisalignedMembers.end() &&
13797 MisalignedMembers.erase(MA);
13818 bool AnyIsPacked =
false;
13820 QualType BaseType = ME->getBase()->getType();
13834 AnyIsPacked || (RD->
hasAttr<PackedAttr>() || MD->
hasAttr<PackedAttr>());
13835 ReverseMemberChain.push_back(FD);
13838 ME = dyn_cast<
MemberExpr>(ME->getBase()->IgnoreParens());
13840 assert(TopME &&
"We did not compute a topmost MemberExpr!");
13847 const auto *DRE = dyn_cast<
DeclRefExpr>(TopBase);
13851 if (!DRE && !isa<CXXThisExpr>(TopBase))
13858 if (ExpectedAlignment.
isOne())
13863 for (
auto I = ReverseMemberChain.rbegin(); I != ReverseMemberChain.rend();
13870 ReverseMemberChain.back()->getParent()->getTypeForDecl());
13874 if (DRE && !TopME->
isArrow()) {
13877 CompleteObjectAlignment =
13882 if (Offset % ExpectedAlignment != 0 ||
13885 CompleteObjectAlignment < ExpectedAlignment) {
13896 for (
FieldDecl *FDI : ReverseMemberChain) {
13897 if (FDI->hasAttr<PackedAttr>() ||
13898 FDI->getParent()->hasAttr<PackedAttr>()) {
13906 assert(FD &&
"We did not find a packed FieldDecl!");
13907 Action(E, FD->
getParent(), FD, Alignment);
13911 void Sema::CheckAddressOfPackedMember(
Expr *rhs) {
13912 using namespace std::placeholders;
13914 RefersToMemberWithReducedAlignment(
13915 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...
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
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.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
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
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.
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.
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
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.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
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.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
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.
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)
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...
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...
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 isUnarySelector() const
bool hasValidPlusPrefix() const
Describes an C or C++ initializer list.
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
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.
bool EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsFloat - Return true if this is a constant which we can fold and convert to a floating point...
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
IgnoreParenCasts - Ignore parentheses and casts.
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...
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)
Iterator for iterating over Stmt * arrays that contain only Expr *.
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()
APValue & getVectorElt(unsigned I)
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.
Pepresents 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.
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 bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx, const ValueDecl **VD, uint64_t *MagicValue)
Given a type tag expression find the type tag itself.
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
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.
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.
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...
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.
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.
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.
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.
BinaryOperator::Opcode getOpcode(const SymExpr *SE)
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.
static void SemaBuiltinMemChkCall(Sema &S, FunctionDecl *FDecl, CallExpr *TheCall, unsigned SizeIdx, unsigned DstSizeIdx, StringRef LikelyMacroName)
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
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
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.
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...
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)
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.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
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)
Retrieve the C type corresponding to type tag TypeExpr.
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
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
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
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...
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.
__DEVICE__ int max(int __a, int __b)
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...
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
__DEVICE__ int min(int __a, int __b)
SourceManager & SourceMgr
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
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 IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth)
Pseudo-evaluate the given integer expression, estimating the range of values it might take...
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).
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
ArrayRef< ParmVarDecl * > parameters() const
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
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