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->
getLocEnd(), 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->
getLocEnd(), 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->getLocStart(), 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()->getLocStart(), 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()->getLocStart(),
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,
241 unsigned DstSizeIdx) {
246 const Expr *SizeArg = TheCall->
getArg(SizeIdx);
247 const Expr *DstSizeArg = TheCall->
getArg(DstSizeIdx);
249 llvm::APSInt Size, DstSize;
256 if (Size.ule(DstSize))
264 S.
Diag(SL, diag::warn_memcpy_chk_overflow) << SR << FnName;
277 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_not_call)
282 auto CE = cast<CallExpr>(Call);
283 if (CE->getCallee()->getType()->isBlockPointerType()) {
284 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_block_call)
289 const Decl *TargetDecl = CE->getCalleeDecl();
290 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
291 if (FD->getBuiltinID()) {
292 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_builtin_call)
297 if (isa<CXXPseudoDestructorExpr>(CE->getCallee()->IgnoreParens())) {
298 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_pdtor_call)
306 if (!ChainResult.
get()->getType()->isPointerType()) {
307 S.
Diag(BuiltinLoc, diag::err_second_argument_to_cwsc_not_pointer)
313 QualType ArgTys[2] = { ReturnTy, ChainResult.
get()->getType() };
321 BuiltinCall->
setType(CE->getType());
325 BuiltinCall->
setArg(1, ChainResult.
get());
342 if (!S || !(S->
getFlags() & NeededScopeFlags)) {
345 << DRE->getDecl()->getIdentifier();
361 ArrayRef<QualType> Params =
363 unsigned ArgCounter = 0;
364 bool IllegalParams =
false;
367 for (ArrayRef<QualType>::iterator I = Params.begin(), E = Params.end();
368 I != E; ++I, ++ArgCounter) {
369 if (!(*I)->isPointerType() || !(*I)->getPointeeType()->isVoidType() ||
370 (*I)->getPointeeType().getQualifiers().getAddressSpace() !=
376 if (isa<BlockExpr>(BlockArg)) {
377 BlockDecl *BD = cast<BlockExpr>(BlockArg)->getBlockDecl();
379 }
else if (isa<DeclRefExpr>(BlockArg)) {
380 ErrorLoc = cast<DeclRefExpr>(BlockArg)->getLocStart();
383 diag::err_opencl_enqueue_kernel_blocks_non_local_void_args);
384 IllegalParams =
true;
388 return IllegalParams;
411 diag::err_opencl_builtin_expected_type)
419 diag::err_opencl_builtin_expected_type)
436 diag::err_opencl_builtin_expected_type)
448 unsigned Start,
unsigned End) {
449 bool IllegalParams =
false;
450 for (
unsigned I = Start; I <=
End; ++I)
453 return IllegalParams;
460 unsigned NumNonVarArgs) {
463 unsigned NumBlockParams =
465 unsigned TotalNumArgs = TheCall->
getNumArgs();
469 if (TotalNumArgs != NumBlockParams + NumNonVarArgs) {
471 diag::err_opencl_enqueue_kernel_local_size_args);
522 diag::err_opencl_builtin_expected_type)
530 diag::err_opencl_builtin_expected_type)
531 << TheCall->
getDirectCallee() <<
"'kernel_enqueue_flags_t' (i.e. uint)";
538 diag::err_opencl_builtin_expected_type)
557 diag::err_opencl_enqueue_kernel_blocks_no_args);
581 diag::err_opencl_builtin_expected_type)
594 diag::err_opencl_builtin_expected_type)
606 diag::err_opencl_builtin_expected_type)
620 diag::err_opencl_enqueue_kernel_incorrect_args);
626 return D->
getAttr<OpenCLAccessAttr>();
638 OpenCLAccessAttr *AccessQual =
645 case Builtin::BIread_pipe:
646 case Builtin::BIreserve_read_pipe:
647 case Builtin::BIcommit_read_pipe:
648 case Builtin::BIwork_group_reserve_read_pipe:
649 case Builtin::BIsub_group_reserve_read_pipe:
650 case Builtin::BIwork_group_commit_read_pipe:
651 case Builtin::BIsub_group_commit_read_pipe:
652 if (!(!AccessQual || AccessQual->isReadOnly())) {
654 diag::err_opencl_builtin_pipe_invalid_access_modifier)
659 case Builtin::BIwrite_pipe:
660 case Builtin::BIreserve_write_pipe:
661 case Builtin::BIcommit_write_pipe:
662 case Builtin::BIwork_group_reserve_write_pipe:
663 case Builtin::BIsub_group_reserve_write_pipe:
664 case Builtin::BIwork_group_commit_write_pipe:
665 case Builtin::BIsub_group_commit_write_pipe:
666 if (!(AccessQual && AccessQual->isWriteOnly())) {
668 diag::err_opencl_builtin_pipe_invalid_access_modifier)
838 if (!RT->isPointerType() || RT->getPointeeType()
840 S.
Diag(Call->
getLocStart(), diag::err_opencl_builtin_to_addr_invalid_arg)
845 RT = RT->getPointeeType();
846 auto Qual = RT.getQualifiers();
848 case Builtin::BIto_global:
851 case Builtin::BIto_local:
854 case Builtin::BIto_private:
858 llvm_unreachable(
"Invalid builtin function");
861 RT.getUnqualifiedType(), Qual)));
870 ArrayRef<llvm::Triple::ArchType> SupportedArchs) {
871 llvm::Triple::ArchType CurArch =
873 if (llvm::is_contained(SupportedArchs, CurArch))
881 Sema::CheckBuiltinFunctionCall(
FunctionDecl *FDecl,
unsigned BuiltinID,
886 unsigned ICEArguments = 0;
893 for (
unsigned ArgNo = 0; ICEArguments != 0; ++ArgNo) {
895 if ((ICEArguments & (1 << ArgNo)) == 0)
continue;
898 if (SemaBuiltinConstantArg(TheCall, ArgNo, Result))
900 ICEArguments &= ~(1 << ArgNo);
904 case Builtin::BI__builtin___CFStringMakeConstantString:
906 "Wrong # arguments to builtin CFStringMakeConstantString");
907 if (CheckObjCString(TheCall->
getArg(0)))
910 case Builtin::BI__builtin_ms_va_start:
911 case Builtin::BI__builtin_stdarg_start:
912 case Builtin::BI__builtin_va_start:
913 if (SemaBuiltinVAStart(BuiltinID, TheCall))
916 case Builtin::BI__va_start: {
918 case llvm::Triple::arm:
919 case llvm::Triple::thumb:
920 if (SemaBuiltinVAStartARMMicrosoft(TheCall))
924 if (SemaBuiltinVAStart(BuiltinID, TheCall))
932 case Builtin::BI_interlockedbittestandset_acq:
933 case Builtin::BI_interlockedbittestandset_rel:
934 case Builtin::BI_interlockedbittestandset_nf:
935 case Builtin::BI_interlockedbittestandreset_acq:
936 case Builtin::BI_interlockedbittestandreset_rel:
937 case Builtin::BI_interlockedbittestandreset_nf:
939 *
this, BuiltinID, TheCall,
940 {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
945 case Builtin::BI_bittest64:
946 case Builtin::BI_bittestandcomplement64:
947 case Builtin::BI_bittestandreset64:
948 case Builtin::BI_bittestandset64:
949 case Builtin::BI_interlockedbittestandreset64:
950 case Builtin::BI_interlockedbittestandset64:
952 {llvm::Triple::x86_64, llvm::Triple::arm,
953 llvm::Triple::thumb, llvm::Triple::aarch64}))
957 case Builtin::BI__builtin_isgreater:
958 case Builtin::BI__builtin_isgreaterequal:
959 case Builtin::BI__builtin_isless:
960 case Builtin::BI__builtin_islessequal:
961 case Builtin::BI__builtin_islessgreater:
962 case Builtin::BI__builtin_isunordered:
963 if (SemaBuiltinUnorderedCompare(TheCall))
966 case Builtin::BI__builtin_fpclassify:
967 if (SemaBuiltinFPClassification(TheCall, 6))
970 case Builtin::BI__builtin_isfinite:
971 case Builtin::BI__builtin_isinf:
972 case Builtin::BI__builtin_isinf_sign:
973 case Builtin::BI__builtin_isnan:
974 case Builtin::BI__builtin_isnormal:
975 case Builtin::BI__builtin_signbit:
976 case Builtin::BI__builtin_signbitf:
977 case Builtin::BI__builtin_signbitl:
978 if (SemaBuiltinFPClassification(TheCall, 1))
981 case Builtin::BI__builtin_shufflevector:
982 return SemaBuiltinShuffleVector(TheCall);
985 case Builtin::BI__builtin_prefetch:
986 if (SemaBuiltinPrefetch(TheCall))
989 case Builtin::BI__builtin_alloca_with_align:
990 if (SemaBuiltinAllocaWithAlign(TheCall))
993 case Builtin::BI__assume:
994 case Builtin::BI__builtin_assume:
995 if (SemaBuiltinAssume(TheCall))
998 case Builtin::BI__builtin_assume_aligned:
999 if (SemaBuiltinAssumeAligned(TheCall))
1002 case Builtin::BI__builtin_object_size:
1003 if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 3))
1006 case Builtin::BI__builtin_longjmp:
1007 if (SemaBuiltinLongjmp(TheCall))
1010 case Builtin::BI__builtin_setjmp:
1011 if (SemaBuiltinSetjmp(TheCall))
1014 case Builtin::BI_setjmp:
1015 case Builtin::BI_setjmpex:
1019 case Builtin::BI__builtin_classify_type:
1023 case Builtin::BI__builtin_constant_p:
1027 case Builtin::BI__sync_fetch_and_add:
1028 case Builtin::BI__sync_fetch_and_add_1:
1029 case Builtin::BI__sync_fetch_and_add_2:
1030 case Builtin::BI__sync_fetch_and_add_4:
1031 case Builtin::BI__sync_fetch_and_add_8:
1032 case Builtin::BI__sync_fetch_and_add_16:
1033 case Builtin::BI__sync_fetch_and_sub:
1034 case Builtin::BI__sync_fetch_and_sub_1:
1035 case Builtin::BI__sync_fetch_and_sub_2:
1036 case Builtin::BI__sync_fetch_and_sub_4:
1037 case Builtin::BI__sync_fetch_and_sub_8:
1038 case Builtin::BI__sync_fetch_and_sub_16:
1039 case Builtin::BI__sync_fetch_and_or:
1040 case Builtin::BI__sync_fetch_and_or_1:
1041 case Builtin::BI__sync_fetch_and_or_2:
1042 case Builtin::BI__sync_fetch_and_or_4:
1043 case Builtin::BI__sync_fetch_and_or_8:
1044 case Builtin::BI__sync_fetch_and_or_16:
1045 case Builtin::BI__sync_fetch_and_and:
1046 case Builtin::BI__sync_fetch_and_and_1:
1047 case Builtin::BI__sync_fetch_and_and_2:
1048 case Builtin::BI__sync_fetch_and_and_4:
1049 case Builtin::BI__sync_fetch_and_and_8:
1050 case Builtin::BI__sync_fetch_and_and_16:
1051 case Builtin::BI__sync_fetch_and_xor:
1052 case Builtin::BI__sync_fetch_and_xor_1:
1053 case Builtin::BI__sync_fetch_and_xor_2:
1054 case Builtin::BI__sync_fetch_and_xor_4:
1055 case Builtin::BI__sync_fetch_and_xor_8:
1056 case Builtin::BI__sync_fetch_and_xor_16:
1057 case Builtin::BI__sync_fetch_and_nand:
1058 case Builtin::BI__sync_fetch_and_nand_1:
1059 case Builtin::BI__sync_fetch_and_nand_2:
1060 case Builtin::BI__sync_fetch_and_nand_4:
1061 case Builtin::BI__sync_fetch_and_nand_8:
1062 case Builtin::BI__sync_fetch_and_nand_16:
1063 case Builtin::BI__sync_add_and_fetch:
1064 case Builtin::BI__sync_add_and_fetch_1:
1065 case Builtin::BI__sync_add_and_fetch_2:
1066 case Builtin::BI__sync_add_and_fetch_4:
1067 case Builtin::BI__sync_add_and_fetch_8:
1068 case Builtin::BI__sync_add_and_fetch_16:
1069 case Builtin::BI__sync_sub_and_fetch:
1070 case Builtin::BI__sync_sub_and_fetch_1:
1071 case Builtin::BI__sync_sub_and_fetch_2:
1072 case Builtin::BI__sync_sub_and_fetch_4:
1073 case Builtin::BI__sync_sub_and_fetch_8:
1074 case Builtin::BI__sync_sub_and_fetch_16:
1075 case Builtin::BI__sync_and_and_fetch:
1076 case Builtin::BI__sync_and_and_fetch_1:
1077 case Builtin::BI__sync_and_and_fetch_2:
1078 case Builtin::BI__sync_and_and_fetch_4:
1079 case Builtin::BI__sync_and_and_fetch_8:
1080 case Builtin::BI__sync_and_and_fetch_16:
1081 case Builtin::BI__sync_or_and_fetch:
1082 case Builtin::BI__sync_or_and_fetch_1:
1083 case Builtin::BI__sync_or_and_fetch_2:
1084 case Builtin::BI__sync_or_and_fetch_4:
1085 case Builtin::BI__sync_or_and_fetch_8:
1086 case Builtin::BI__sync_or_and_fetch_16:
1087 case Builtin::BI__sync_xor_and_fetch:
1088 case Builtin::BI__sync_xor_and_fetch_1:
1089 case Builtin::BI__sync_xor_and_fetch_2:
1090 case Builtin::BI__sync_xor_and_fetch_4:
1091 case Builtin::BI__sync_xor_and_fetch_8:
1092 case Builtin::BI__sync_xor_and_fetch_16:
1093 case Builtin::BI__sync_nand_and_fetch:
1094 case Builtin::BI__sync_nand_and_fetch_1:
1095 case Builtin::BI__sync_nand_and_fetch_2:
1096 case Builtin::BI__sync_nand_and_fetch_4:
1097 case Builtin::BI__sync_nand_and_fetch_8:
1098 case Builtin::BI__sync_nand_and_fetch_16:
1099 case Builtin::BI__sync_val_compare_and_swap:
1100 case Builtin::BI__sync_val_compare_and_swap_1:
1101 case Builtin::BI__sync_val_compare_and_swap_2:
1102 case Builtin::BI__sync_val_compare_and_swap_4:
1103 case Builtin::BI__sync_val_compare_and_swap_8:
1104 case Builtin::BI__sync_val_compare_and_swap_16:
1105 case Builtin::BI__sync_bool_compare_and_swap:
1106 case Builtin::BI__sync_bool_compare_and_swap_1:
1107 case Builtin::BI__sync_bool_compare_and_swap_2:
1108 case Builtin::BI__sync_bool_compare_and_swap_4:
1109 case Builtin::BI__sync_bool_compare_and_swap_8:
1110 case Builtin::BI__sync_bool_compare_and_swap_16:
1111 case Builtin::BI__sync_lock_test_and_set:
1112 case Builtin::BI__sync_lock_test_and_set_1:
1113 case Builtin::BI__sync_lock_test_and_set_2:
1114 case Builtin::BI__sync_lock_test_and_set_4:
1115 case Builtin::BI__sync_lock_test_and_set_8:
1116 case Builtin::BI__sync_lock_test_and_set_16:
1117 case Builtin::BI__sync_lock_release:
1118 case Builtin::BI__sync_lock_release_1:
1119 case Builtin::BI__sync_lock_release_2:
1120 case Builtin::BI__sync_lock_release_4:
1121 case Builtin::BI__sync_lock_release_8:
1122 case Builtin::BI__sync_lock_release_16:
1123 case Builtin::BI__sync_swap:
1124 case Builtin::BI__sync_swap_1:
1125 case Builtin::BI__sync_swap_2:
1126 case Builtin::BI__sync_swap_4:
1127 case Builtin::BI__sync_swap_8:
1128 case Builtin::BI__sync_swap_16:
1129 return SemaBuiltinAtomicOverloaded(TheCallResult);
1130 case Builtin::BI__builtin_nontemporal_load:
1131 case Builtin::BI__builtin_nontemporal_store:
1132 return SemaBuiltinNontemporalOverloaded(TheCallResult);
1133 #define BUILTIN(ID, TYPE, ATTRS) 1134 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ 1135 case Builtin::BI##ID: \ 1136 return SemaAtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID); 1137 #include "clang/Basic/Builtins.def" 1138 case Builtin::BI__annotation:
1142 case Builtin::BI__builtin_annotation:
1146 case Builtin::BI__builtin_addressof:
1150 case Builtin::BI__builtin_add_overflow:
1151 case Builtin::BI__builtin_sub_overflow:
1152 case Builtin::BI__builtin_mul_overflow:
1156 case Builtin::BI__builtin_operator_new:
1157 case Builtin::BI__builtin_operator_delete: {
1158 bool IsDelete = BuiltinID == Builtin::BI__builtin_operator_delete;
1160 SemaBuiltinOperatorNewDeleteOverloaded(TheCallResult, IsDelete);
1162 CorrectDelayedTyposInExpr(TheCallResult.
get());
1165 case Builtin::BI__builtin_dump_struct: {
1175 << PtrArgType <<
"structure pointer" << 1 << 0 << 3 << 1 << PtrArgType
1176 <<
"structure pointer";
1184 Diag(FnPtrArg->
getLocStart(), diag::err_typecheck_convert_incompatible)
1185 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1186 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1190 const auto *FuncType =
1194 Diag(FnPtrArg->
getLocStart(), diag::err_typecheck_convert_incompatible)
1195 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1196 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1200 if (
const auto *FT = dyn_cast<FunctionProtoType>(FuncType)) {
1201 if (!FT->getNumParams()) {
1202 Diag(FnPtrArg->
getLocStart(), diag::err_typecheck_convert_incompatible)
1203 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1204 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1208 if (!FT->isVariadic() || FT->getReturnType() != Context.
IntTy ||
1211 Diag(FnPtrArg->
getLocStart(), diag::err_typecheck_convert_incompatible)
1212 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1213 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1224 case Builtin::BI__builtin___memcpy_chk:
1225 case Builtin::BI__builtin___memmove_chk:
1226 case Builtin::BI__builtin___memset_chk:
1227 case Builtin::BI__builtin___strlcat_chk:
1228 case Builtin::BI__builtin___strlcpy_chk:
1229 case Builtin::BI__builtin___strncat_chk:
1230 case Builtin::BI__builtin___strncpy_chk:
1231 case Builtin::BI__builtin___stpncpy_chk:
1234 case Builtin::BI__builtin___memccpy_chk:
1237 case Builtin::BI__builtin___snprintf_chk:
1238 case Builtin::BI__builtin___vsnprintf_chk:
1241 case Builtin::BI__builtin_call_with_static_chain:
1245 case Builtin::BI__exception_code:
1246 case Builtin::BI_exception_code:
1248 diag::err_seh___except_block))
1251 case Builtin::BI__exception_info:
1252 case Builtin::BI_exception_info:
1254 diag::err_seh___except_filter))
1257 case Builtin::BI__GetExceptionInfo:
1261 if (CheckCXXThrowOperand(
1270 case Builtin::BIread_pipe:
1271 case Builtin::BIwrite_pipe:
1278 case Builtin::BIreserve_read_pipe:
1279 case Builtin::BIreserve_write_pipe:
1280 case Builtin::BIwork_group_reserve_read_pipe:
1281 case Builtin::BIwork_group_reserve_write_pipe:
1285 case Builtin::BIsub_group_reserve_read_pipe:
1286 case Builtin::BIsub_group_reserve_write_pipe:
1291 case Builtin::BIcommit_read_pipe:
1292 case Builtin::BIcommit_write_pipe:
1293 case Builtin::BIwork_group_commit_read_pipe:
1294 case Builtin::BIwork_group_commit_write_pipe:
1298 case Builtin::BIsub_group_commit_read_pipe:
1299 case Builtin::BIsub_group_commit_write_pipe:
1304 case Builtin::BIget_pipe_num_packets:
1305 case Builtin::BIget_pipe_max_packets:
1310 case Builtin::BIto_global:
1311 case Builtin::BIto_local:
1312 case Builtin::BIto_private:
1317 case Builtin::BIenqueue_kernel:
1321 case Builtin::BIget_kernel_work_group_size:
1322 case Builtin::BIget_kernel_preferred_work_group_size_multiple:
1326 case Builtin::BIget_kernel_max_sub_group_size_for_ndrange:
1327 case Builtin::BIget_kernel_sub_group_count_for_ndrange:
1331 case Builtin::BI__builtin_os_log_format:
1332 case Builtin::BI__builtin_os_log_format_buffer_size:
1333 if (SemaBuiltinOSLogFormat(TheCall))
1342 case llvm::Triple::arm:
1343 case llvm::Triple::armeb:
1344 case llvm::Triple::thumb:
1345 case llvm::Triple::thumbeb:
1346 if (CheckARMBuiltinFunctionCall(BuiltinID, TheCall))
1349 case llvm::Triple::aarch64:
1350 case llvm::Triple::aarch64_be:
1351 if (CheckAArch64BuiltinFunctionCall(BuiltinID, TheCall))
1354 case llvm::Triple::hexagon:
1355 if (CheckHexagonBuiltinFunctionCall(BuiltinID, TheCall))
1358 case llvm::Triple::mips:
1359 case llvm::Triple::mipsel:
1360 case llvm::Triple::mips64:
1361 case llvm::Triple::mips64el:
1362 if (CheckMipsBuiltinFunctionCall(BuiltinID, TheCall))
1365 case llvm::Triple::systemz:
1366 if (CheckSystemZBuiltinFunctionCall(BuiltinID, TheCall))
1369 case llvm::Triple::x86:
1370 case llvm::Triple::x86_64:
1371 if (CheckX86BuiltinFunctionCall(BuiltinID, TheCall))
1374 case llvm::Triple::ppc:
1375 case llvm::Triple::ppc64:
1376 case llvm::Triple::ppc64le:
1377 if (CheckPPCBuiltinFunctionCall(BuiltinID, TheCall))
1385 return TheCallResult;
1389 static unsigned RFT(
unsigned t,
bool shift =
false,
bool ForceQuad =
false) {
1391 int IsQuad = ForceQuad ?
true : Type.
isQuad();
1395 return shift ? 7 : (8 << IsQuad) - 1;
1398 return shift ? 15 : (4 << IsQuad) - 1;
1400 return shift ? 31 : (2 << IsQuad) - 1;
1403 return shift ? 63 : (1 << IsQuad) - 1;
1405 return shift ? 127 : (1 << IsQuad) - 1;
1407 assert(!shift &&
"cannot shift float types!");
1408 return (4 << IsQuad) - 1;
1410 assert(!shift &&
"cannot shift float types!");
1411 return (2 << IsQuad) - 1;
1413 assert(!shift &&
"cannot shift float types!");
1414 return (1 << IsQuad) - 1;
1416 llvm_unreachable(
"Invalid NeonTypeFlag!");
1423 bool IsPolyUnsigned,
bool IsInt64Long) {
1455 llvm_unreachable(
"Invalid NeonTypeFlag!");
1458 bool Sema::CheckNeonBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
1459 llvm::APSInt Result;
1463 bool HasConstPtr =
false;
1464 switch (BuiltinID) {
1465 #define GET_NEON_OVERLOAD_CHECK 1466 #include "clang/Basic/arm_neon.inc" 1467 #include "clang/Basic/arm_fp16.inc" 1468 #undef GET_NEON_OVERLOAD_CHECK 1475 if (SemaBuiltinConstantArg(TheCall, ImmArg, Result))
1478 TV = Result.getLimitedValue(64);
1479 if ((TV > 63) || (mask & (1ULL << TV)) == 0)
1484 if (PtrArgNum >= 0) {
1488 Arg = ICE->getSubExpr();
1489 ExprResult RHS = DefaultFunctionArrayLvalueConversion(Arg);
1493 bool IsPolyUnsigned = Arch == llvm::Triple::aarch64 ||
1494 Arch == llvm::Triple::aarch64_be;
1502 AssignConvertType ConvTy;
1503 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
1506 if (DiagnoseAssignmentResult(ConvTy, Arg->
getLocStart(), LHSTy, RHSTy,
1507 RHS.
get(), AA_Assigning))
1513 unsigned i = 0, l = 0, u = 0;
1514 switch (BuiltinID) {
1517 #define GET_NEON_IMMEDIATE_CHECK 1518 #include "clang/Basic/arm_neon.inc" 1519 #include "clang/Basic/arm_fp16.inc" 1520 #undef GET_NEON_IMMEDIATE_CHECK 1523 return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
1526 bool Sema::CheckARMBuiltinExclusiveCall(
unsigned BuiltinID,
CallExpr *TheCall,
1527 unsigned MaxWidth) {
1528 assert((BuiltinID == ARM::BI__builtin_arm_ldrex ||
1529 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1530 BuiltinID == ARM::BI__builtin_arm_strex ||
1531 BuiltinID == ARM::BI__builtin_arm_stlex ||
1532 BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1533 BuiltinID == AArch64::BI__builtin_arm_ldaex ||
1534 BuiltinID == AArch64::BI__builtin_arm_strex ||
1535 BuiltinID == AArch64::BI__builtin_arm_stlex) &&
1536 "unexpected ARM builtin");
1537 bool IsLdrex = BuiltinID == ARM::BI__builtin_arm_ldrex ||
1538 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1539 BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1540 BuiltinID == AArch64::BI__builtin_arm_ldaex;
1552 Expr *PointerArg = TheCall->
getArg(IsLdrex ? 0 : 1);
1553 ExprResult PointerArgRes = DefaultFunctionArrayLvalueConversion(PointerArg);
1556 PointerArg = PointerArgRes.
get();
1576 CastNeeded = CK_BitCast;
1577 Diag(DRE->
getLocStart(), diag::ext_typecheck_convert_discards_qualifiers)
1585 PointerArgRes = ImpCastExprToType(PointerArg, AddrType, CastNeeded);
1588 PointerArg = PointerArgRes.
get();
1590 TheCall->
setArg(IsLdrex ? 0 : 1, PointerArg);
1595 Diag(DRE->
getLocStart(), diag::err_atomic_builtin_must_be_pointer_intfltptr)
1602 assert(MaxWidth == 64 &&
"Diagnostic unexpectedly inaccurate");
1603 Diag(DRE->
getLocStart(), diag::err_atomic_exclusive_builtin_pointer_size)
1630 Context, ValType,
false);
1631 ValArg = PerformCopyInitialization(Entity,
SourceLocation(), ValArg);
1642 bool Sema::CheckARMBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
1643 if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
1644 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1645 BuiltinID == ARM::BI__builtin_arm_strex ||
1646 BuiltinID == ARM::BI__builtin_arm_stlex) {
1647 return CheckARMBuiltinExclusiveCall(BuiltinID, TheCall, 64);
1650 if (BuiltinID == ARM::BI__builtin_arm_prefetch) {
1651 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
1652 SemaBuiltinConstantArgRange(TheCall, 2, 0, 1);
1655 if (BuiltinID == ARM::BI__builtin_arm_rsr64 ||
1656 BuiltinID == ARM::BI__builtin_arm_wsr64)
1657 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 3,
false);
1659 if (BuiltinID == ARM::BI__builtin_arm_rsr ||
1660 BuiltinID == ARM::BI__builtin_arm_rsrp ||
1661 BuiltinID == ARM::BI__builtin_arm_wsr ||
1662 BuiltinID == ARM::BI__builtin_arm_wsrp)
1663 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1665 if (CheckNeonBuiltinFunctionCall(BuiltinID, TheCall))
1671 switch (BuiltinID) {
1672 default:
return false;
1673 case ARM::BI__builtin_arm_ssat:
1674 return SemaBuiltinConstantArgRange(TheCall, 1, 1, 32);
1675 case ARM::BI__builtin_arm_usat:
1676 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 31);
1677 case ARM::BI__builtin_arm_ssat16:
1678 return SemaBuiltinConstantArgRange(TheCall, 1, 1, 16);
1679 case ARM::BI__builtin_arm_usat16:
1680 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
1681 case ARM::BI__builtin_arm_vcvtr_f:
1682 case ARM::BI__builtin_arm_vcvtr_d:
1683 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
1684 case ARM::BI__builtin_arm_dmb:
1685 case ARM::BI__builtin_arm_dsb:
1686 case ARM::BI__builtin_arm_isb:
1687 case ARM::BI__builtin_arm_dbg:
1688 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 15);
1692 bool Sema::CheckAArch64BuiltinFunctionCall(
unsigned BuiltinID,
1694 if (BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1695 BuiltinID == AArch64::BI__builtin_arm_ldaex ||
1696 BuiltinID == AArch64::BI__builtin_arm_strex ||
1697 BuiltinID == AArch64::BI__builtin_arm_stlex) {
1698 return CheckARMBuiltinExclusiveCall(BuiltinID, TheCall, 128);
1701 if (BuiltinID == AArch64::BI__builtin_arm_prefetch) {
1702 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
1703 SemaBuiltinConstantArgRange(TheCall, 2, 0, 2) ||
1704 SemaBuiltinConstantArgRange(TheCall, 3, 0, 1) ||
1705 SemaBuiltinConstantArgRange(TheCall, 4, 0, 1);
1708 if (BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
1709 BuiltinID == AArch64::BI__builtin_arm_wsr64)
1710 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1712 if (BuiltinID == AArch64::BI__builtin_arm_rsr ||
1713 BuiltinID == AArch64::BI__builtin_arm_rsrp ||
1714 BuiltinID == AArch64::BI__builtin_arm_wsr ||
1715 BuiltinID == AArch64::BI__builtin_arm_wsrp)
1716 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1718 if (CheckNeonBuiltinFunctionCall(BuiltinID, TheCall))
1723 unsigned i = 0, l = 0, u = 0;
1724 switch (BuiltinID) {
1725 default:
return false;
1726 case AArch64::BI__builtin_arm_dmb:
1727 case AArch64::BI__builtin_arm_dsb:
1728 case AArch64::BI__builtin_arm_isb: l = 0; u = 15;
break;
1731 return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
1734 bool Sema::CheckHexagonBuiltinCpu(
unsigned BuiltinID,
CallExpr *TheCall) {
1735 static const std::map<unsigned, std::vector<StringRef>> ValidCPU = {
1736 { Hexagon::BI__builtin_HEXAGON_A6_vcmpbeq_notany, {
"v65"} },
1737 { Hexagon::BI__builtin_HEXAGON_A6_vminub_RdP, {
"v62",
"v65"} },
1738 { Hexagon::BI__builtin_HEXAGON_M6_vabsdiffb, {
"v62",
"v65"} },
1739 { Hexagon::BI__builtin_HEXAGON_M6_vabsdiffub, {
"v62",
"v65"} },
1740 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {
"v60",
"v62",
"v65"} },
1741 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {
"v60",
"v62",
"v65"} },
1742 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {
"v60",
"v62",
"v65"} },
1743 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {
"v60",
"v62",
"v65"} },
1744 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {
"v60",
"v62",
"v65"} },
1745 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {
"v60",
"v62",
"v65"} },
1746 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {
"v60",
"v62",
"v65"} },
1747 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {
"v60",
"v62",
"v65"} },
1748 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {
"v60",
"v62",
"v65"} },
1749 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {
"v60",
"v62",
"v65"} },
1750 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {
"v60",
"v62",
"v65"} },
1751 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {
"v60",
"v62",
"v65"} },
1752 { Hexagon::BI__builtin_HEXAGON_S6_vsplatrbp, {
"v62",
"v65"} },
1753 { Hexagon::BI__builtin_HEXAGON_S6_vtrunehb_ppp, {
"v62",
"v65"} },
1754 { Hexagon::BI__builtin_HEXAGON_S6_vtrunohb_ppp, {
"v62",
"v65"} },
1757 static const std::map<unsigned, std::vector<StringRef>> ValidHVX = {
1758 { Hexagon::BI__builtin_HEXAGON_V6_extractw, {
"v60",
"v62",
"v65"} },
1759 { Hexagon::BI__builtin_HEXAGON_V6_extractw_128B, {
"v60",
"v62",
"v65"} },
1760 { Hexagon::BI__builtin_HEXAGON_V6_hi, {
"v60",
"v62",
"v65"} },
1761 { Hexagon::BI__builtin_HEXAGON_V6_hi_128B, {
"v60",
"v62",
"v65"} },
1762 { Hexagon::BI__builtin_HEXAGON_V6_lo, {
"v60",
"v62",
"v65"} },
1763 { Hexagon::BI__builtin_HEXAGON_V6_lo_128B, {
"v60",
"v62",
"v65"} },
1764 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatb, {
"v62",
"v65"} },
1765 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatb_128B, {
"v62",
"v65"} },
1766 { Hexagon::BI__builtin_HEXAGON_V6_lvsplath, {
"v62",
"v65"} },
1767 { Hexagon::BI__builtin_HEXAGON_V6_lvsplath_128B, {
"v62",
"v65"} },
1768 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatw, {
"v60",
"v62",
"v65"} },
1769 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatw_128B, {
"v60",
"v62",
"v65"} },
1770 { Hexagon::BI__builtin_HEXAGON_V6_pred_and, {
"v60",
"v62",
"v65"} },
1771 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_128B, {
"v60",
"v62",
"v65"} },
1772 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_n, {
"v60",
"v62",
"v65"} },
1773 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_n_128B, {
"v60",
"v62",
"v65"} },
1774 { Hexagon::BI__builtin_HEXAGON_V6_pred_not, {
"v60",
"v62",
"v65"} },
1775 { Hexagon::BI__builtin_HEXAGON_V6_pred_not_128B, {
"v60",
"v62",
"v65"} },
1776 { Hexagon::BI__builtin_HEXAGON_V6_pred_or, {
"v60",
"v62",
"v65"} },
1777 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_128B, {
"v60",
"v62",
"v65"} },
1778 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_n, {
"v60",
"v62",
"v65"} },
1779 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_n_128B, {
"v60",
"v62",
"v65"} },
1780 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2, {
"v60",
"v62",
"v65"} },
1781 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2_128B, {
"v60",
"v62",
"v65"} },
1782 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2v2, {
"v62",
"v65"} },
1783 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2v2_128B, {
"v62",
"v65"} },
1784 { Hexagon::BI__builtin_HEXAGON_V6_pred_xor, {
"v60",
"v62",
"v65"} },
1785 { Hexagon::BI__builtin_HEXAGON_V6_pred_xor_128B, {
"v60",
"v62",
"v65"} },
1786 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqh, {
"v62",
"v65"} },
1787 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqh_128B, {
"v62",
"v65"} },
1788 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqw, {
"v62",
"v65"} },
1789 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqw_128B, {
"v62",
"v65"} },
1790 { Hexagon::BI__builtin_HEXAGON_V6_vabsb, {
"v65"} },
1791 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_128B, {
"v65"} },
1792 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_sat, {
"v65"} },
1793 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_sat_128B, {
"v65"} },
1794 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffh, {
"v60",
"v62",
"v65"} },
1795 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffh_128B, {
"v60",
"v62",
"v65"} },
1796 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffub, {
"v60",
"v62",
"v65"} },
1797 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffub_128B, {
"v60",
"v62",
"v65"} },
1798 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffuh, {
"v60",
"v62",
"v65"} },
1799 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffuh_128B, {
"v60",
"v62",
"v65"} },
1800 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffw, {
"v60",
"v62",
"v65"} },
1801 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffw_128B, {
"v60",
"v62",
"v65"} },
1802 { Hexagon::BI__builtin_HEXAGON_V6_vabsh, {
"v60",
"v62",
"v65"} },
1803 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_128B, {
"v60",
"v62",
"v65"} },
1804 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_sat, {
"v60",
"v62",
"v65"} },
1805 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_sat_128B, {
"v60",
"v62",
"v65"} },
1806 { Hexagon::BI__builtin_HEXAGON_V6_vabsw, {
"v60",
"v62",
"v65"} },
1807 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_128B, {
"v60",
"v62",
"v65"} },
1808 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_sat, {
"v60",
"v62",
"v65"} },
1809 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_sat_128B, {
"v60",
"v62",
"v65"} },
1810 { Hexagon::BI__builtin_HEXAGON_V6_vaddb, {
"v60",
"v62",
"v65"} },
1811 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_128B, {
"v60",
"v62",
"v65"} },
1812 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_dv, {
"v60",
"v62",
"v65"} },
1813 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_dv_128B, {
"v60",
"v62",
"v65"} },
1814 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat, {
"v62",
"v65"} },
1815 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_128B, {
"v62",
"v65"} },
1816 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_dv, {
"v62",
"v65"} },
1817 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_dv_128B, {
"v62",
"v65"} },
1818 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarry, {
"v62",
"v65"} },
1819 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarry_128B, {
"v62",
"v65"} },
1820 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbh, {
"v62",
"v65"} },
1821 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbh_128B, {
"v62",
"v65"} },
1822 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbw, {
"v62",
"v65"} },
1823 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbw_128B, {
"v62",
"v65"} },
1824 { Hexagon::BI__builtin_HEXAGON_V6_vaddh, {
"v60",
"v62",
"v65"} },
1825 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_128B, {
"v60",
"v62",
"v65"} },
1826 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_dv, {
"v60",
"v62",
"v65"} },
1827 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_dv_128B, {
"v60",
"v62",
"v65"} },
1828 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat, {
"v60",
"v62",
"v65"} },
1829 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_128B, {
"v60",
"v62",
"v65"} },
1830 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_dv, {
"v60",
"v62",
"v65"} },
1831 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_dv_128B, {
"v60",
"v62",
"v65"} },
1832 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw, {
"v60",
"v62",
"v65"} },
1833 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_128B, {
"v60",
"v62",
"v65"} },
1834 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_acc, {
"v62",
"v65"} },
1835 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_acc_128B, {
"v62",
"v65"} },
1836 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh, {
"v60",
"v62",
"v65"} },
1837 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_128B, {
"v60",
"v62",
"v65"} },
1838 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_acc, {
"v62",
"v65"} },
1839 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_acc_128B, {
"v62",
"v65"} },
1840 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat, {
"v60",
"v62",
"v65"} },
1841 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_128B, {
"v60",
"v62",
"v65"} },
1842 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_dv, {
"v60",
"v62",
"v65"} },
1843 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_dv_128B, {
"v60",
"v62",
"v65"} },
1844 { Hexagon::BI__builtin_HEXAGON_V6_vaddububb_sat, {
"v62",
"v65"} },
1845 { Hexagon::BI__builtin_HEXAGON_V6_vaddububb_sat_128B, {
"v62",
"v65"} },
1846 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat, {
"v60",
"v62",
"v65"} },
1847 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_128B, {
"v60",
"v62",
"v65"} },
1848 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_dv, {
"v60",
"v62",
"v65"} },
1849 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_dv_128B, {
"v60",
"v62",
"v65"} },
1850 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw, {
"v60",
"v62",
"v65"} },
1851 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_128B, {
"v60",
"v62",
"v65"} },
1852 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_acc, {
"v62",
"v65"} },
1853 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_acc_128B, {
"v62",
"v65"} },
1854 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat, {
"v62",
"v65"} },
1855 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_128B, {
"v62",
"v65"} },
1856 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_dv, {
"v62",
"v65"} },
1857 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_dv_128B, {
"v62",
"v65"} },
1858 { Hexagon::BI__builtin_HEXAGON_V6_vaddw, {
"v60",
"v62",
"v65"} },
1859 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_128B, {
"v60",
"v62",
"v65"} },
1860 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_dv, {
"v60",
"v62",
"v65"} },
1861 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_dv_128B, {
"v60",
"v62",
"v65"} },
1862 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat, {
"v60",
"v62",
"v65"} },
1863 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_128B, {
"v60",
"v62",
"v65"} },
1864 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_dv, {
"v60",
"v62",
"v65"} },
1865 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_dv_128B, {
"v60",
"v62",
"v65"} },
1866 { Hexagon::BI__builtin_HEXAGON_V6_valignb, {
"v60",
"v62",
"v65"} },
1867 { Hexagon::BI__builtin_HEXAGON_V6_valignb_128B, {
"v60",
"v62",
"v65"} },
1868 { Hexagon::BI__builtin_HEXAGON_V6_valignbi, {
"v60",
"v62",
"v65"} },
1869 { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {
"v60",
"v62",
"v65"} },
1870 { Hexagon::BI__builtin_HEXAGON_V6_vand, {
"v60",
"v62",
"v65"} },
1871 { Hexagon::BI__builtin_HEXAGON_V6_vand_128B, {
"v60",
"v62",
"v65"} },
1872 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt, {
"v62",
"v65"} },
1873 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_128B, {
"v62",
"v65"} },
1874 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_acc, {
"v62",
"v65"} },
1875 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_acc_128B, {
"v62",
"v65"} },
1876 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt, {
"v60",
"v62",
"v65"} },
1877 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_128B, {
"v60",
"v62",
"v65"} },
1878 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_acc, {
"v60",
"v62",
"v65"} },
1879 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_acc_128B, {
"v60",
"v62",
"v65"} },
1880 { Hexagon::BI__builtin_HEXAGON_V6_vandvnqv, {
"v62",
"v65"} },
1881 { Hexagon::BI__builtin_HEXAGON_V6_vandvnqv_128B, {
"v62",
"v65"} },
1882 { Hexagon::BI__builtin_HEXAGON_V6_vandvqv, {
"v62",
"v65"} },
1883 { Hexagon::BI__builtin_HEXAGON_V6_vandvqv_128B, {
"v62",
"v65"} },
1884 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt, {
"v60",
"v62",
"v65"} },
1885 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_128B, {
"v60",
"v62",
"v65"} },
1886 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_acc, {
"v60",
"v62",
"v65"} },
1887 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_acc_128B, {
"v60",
"v62",
"v65"} },
1888 { Hexagon::BI__builtin_HEXAGON_V6_vaslh, {
"v60",
"v62",
"v65"} },
1889 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_128B, {
"v60",
"v62",
"v65"} },
1890 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_acc, {
"v65"} },
1891 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_acc_128B, {
"v65"} },
1892 { Hexagon::BI__builtin_HEXAGON_V6_vaslhv, {
"v60",
"v62",
"v65"} },
1893 { Hexagon::BI__builtin_HEXAGON_V6_vaslhv_128B, {
"v60",
"v62",
"v65"} },
1894 { Hexagon::BI__builtin_HEXAGON_V6_vaslw, {
"v60",
"v62",
"v65"} },
1895 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_128B, {
"v60",
"v62",
"v65"} },
1896 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_acc, {
"v60",
"v62",
"v65"} },
1897 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_acc_128B, {
"v60",
"v62",
"v65"} },
1898 { Hexagon::BI__builtin_HEXAGON_V6_vaslwv, {
"v60",
"v62",
"v65"} },
1899 { Hexagon::BI__builtin_HEXAGON_V6_vaslwv_128B, {
"v60",
"v62",
"v65"} },
1900 { Hexagon::BI__builtin_HEXAGON_V6_vasrh, {
"v60",
"v62",
"v65"} },
1901 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_128B, {
"v60",
"v62",
"v65"} },
1902 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_acc, {
"v65"} },
1903 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_acc_128B, {
"v65"} },
1904 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbrndsat, {
"v60",
"v62",
"v65"} },
1905 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbrndsat_128B, {
"v60",
"v62",
"v65"} },
1906 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbsat, {
"v62",
"v65"} },
1907 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbsat_128B, {
"v62",
"v65"} },
1908 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubrndsat, {
"v60",
"v62",
"v65"} },
1909 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubrndsat_128B, {
"v60",
"v62",
"v65"} },
1910 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubsat, {
"v60",
"v62",
"v65"} },
1911 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubsat_128B, {
"v60",
"v62",
"v65"} },
1912 { Hexagon::BI__builtin_HEXAGON_V6_vasrhv, {
"v60",
"v62",
"v65"} },
1913 { Hexagon::BI__builtin_HEXAGON_V6_vasrhv_128B, {
"v60",
"v62",
"v65"} },
1914 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubrndsat, {
"v65"} },
1915 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubrndsat_128B, {
"v65"} },
1916 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubsat, {
"v65"} },
1917 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubsat_128B, {
"v65"} },
1918 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhrndsat, {
"v62",
"v65"} },
1919 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhrndsat_128B, {
"v62",
"v65"} },
1920 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhsat, {
"v65"} },
1921 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhsat_128B, {
"v65"} },
1922 { Hexagon::BI__builtin_HEXAGON_V6_vasrw, {
"v60",
"v62",
"v65"} },
1923 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_128B, {
"v60",
"v62",
"v65"} },
1924 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_acc, {
"v60",
"v62",
"v65"} },
1925 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_acc_128B, {
"v60",
"v62",
"v65"} },
1926 { Hexagon::BI__builtin_HEXAGON_V6_vasrwh, {
"v60",
"v62",
"v65"} },
1927 { Hexagon::BI__builtin_HEXAGON_V6_vasrwh_128B, {
"v60",
"v62",
"v65"} },
1928 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhrndsat, {
"v60",
"v62",
"v65"} },
1929 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhrndsat_128B, {
"v60",
"v62",
"v65"} },
1930 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhsat, {
"v60",
"v62",
"v65"} },
1931 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhsat_128B, {
"v60",
"v62",
"v65"} },
1932 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhrndsat, {
"v62",
"v65"} },
1933 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhrndsat_128B, {
"v62",
"v65"} },
1934 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhsat, {
"v60",
"v62",
"v65"} },
1935 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhsat_128B, {
"v60",
"v62",
"v65"} },
1936 { Hexagon::BI__builtin_HEXAGON_V6_vasrwv, {
"v60",
"v62",
"v65"} },
1937 { Hexagon::BI__builtin_HEXAGON_V6_vasrwv_128B, {
"v60",
"v62",
"v65"} },
1938 { Hexagon::BI__builtin_HEXAGON_V6_vassign, {
"v60",
"v62",
"v65"} },
1939 { Hexagon::BI__builtin_HEXAGON_V6_vassign_128B, {
"v60",
"v62",
"v65"} },
1940 { Hexagon::BI__builtin_HEXAGON_V6_vassignp, {
"v60",
"v62",
"v65"} },
1941 { Hexagon::BI__builtin_HEXAGON_V6_vassignp_128B, {
"v60",
"v62",
"v65"} },
1942 { Hexagon::BI__builtin_HEXAGON_V6_vavgb, {
"v65"} },
1943 { Hexagon::BI__builtin_HEXAGON_V6_vavgb_128B, {
"v65"} },
1944 { Hexagon::BI__builtin_HEXAGON_V6_vavgbrnd, {
"v65"} },
1945 { Hexagon::BI__builtin_HEXAGON_V6_vavgbrnd_128B, {
"v65"} },
1946 { Hexagon::BI__builtin_HEXAGON_V6_vavgh, {
"v60",
"v62",
"v65"} },
1947 { Hexagon::BI__builtin_HEXAGON_V6_vavgh_128B, {
"v60",
"v62",
"v65"} },
1948 { Hexagon::BI__builtin_HEXAGON_V6_vavghrnd, {
"v60",
"v62",
"v65"} },
1949 { Hexagon::BI__builtin_HEXAGON_V6_vavghrnd_128B, {
"v60",
"v62",
"v65"} },
1950 { Hexagon::BI__builtin_HEXAGON_V6_vavgub, {
"v60",
"v62",
"v65"} },
1951 { Hexagon::BI__builtin_HEXAGON_V6_vavgub_128B, {
"v60",
"v62",
"v65"} },
1952 { Hexagon::BI__builtin_HEXAGON_V6_vavgubrnd, {
"v60",
"v62",
"v65"} },
1953 { Hexagon::BI__builtin_HEXAGON_V6_vavgubrnd_128B, {
"v60",
"v62",
"v65"} },
1954 { Hexagon::BI__builtin_HEXAGON_V6_vavguh, {
"v60",
"v62",
"v65"} },
1955 { Hexagon::BI__builtin_HEXAGON_V6_vavguh_128B, {
"v60",
"v62",
"v65"} },
1956 { Hexagon::BI__builtin_HEXAGON_V6_vavguhrnd, {
"v60",
"v62",
"v65"} },
1957 { Hexagon::BI__builtin_HEXAGON_V6_vavguhrnd_128B, {
"v60",
"v62",
"v65"} },
1958 { Hexagon::BI__builtin_HEXAGON_V6_vavguw, {
"v65"} },
1959 { Hexagon::BI__builtin_HEXAGON_V6_vavguw_128B, {
"v65"} },
1960 { Hexagon::BI__builtin_HEXAGON_V6_vavguwrnd, {
"v65"} },
1961 { Hexagon::BI__builtin_HEXAGON_V6_vavguwrnd_128B, {
"v65"} },
1962 { Hexagon::BI__builtin_HEXAGON_V6_vavgw, {
"v60",
"v62",
"v65"} },
1963 { Hexagon::BI__builtin_HEXAGON_V6_vavgw_128B, {
"v60",
"v62",
"v65"} },
1964 { Hexagon::BI__builtin_HEXAGON_V6_vavgwrnd, {
"v60",
"v62",
"v65"} },
1965 { Hexagon::BI__builtin_HEXAGON_V6_vavgwrnd_128B, {
"v60",
"v62",
"v65"} },
1966 { Hexagon::BI__builtin_HEXAGON_V6_vcl0h, {
"v60",
"v62",
"v65"} },
1967 { Hexagon::BI__builtin_HEXAGON_V6_vcl0h_128B, {
"v60",
"v62",
"v65"} },
1968 { Hexagon::BI__builtin_HEXAGON_V6_vcl0w, {
"v60",
"v62",
"v65"} },
1969 { Hexagon::BI__builtin_HEXAGON_V6_vcl0w_128B, {
"v60",
"v62",
"v65"} },
1970 { Hexagon::BI__builtin_HEXAGON_V6_vcombine, {
"v60",
"v62",
"v65"} },
1971 { Hexagon::BI__builtin_HEXAGON_V6_vcombine_128B, {
"v60",
"v62",
"v65"} },
1972 { Hexagon::BI__builtin_HEXAGON_V6_vd0, {
"v60",
"v62",
"v65"} },
1973 { Hexagon::BI__builtin_HEXAGON_V6_vd0_128B, {
"v60",
"v62",
"v65"} },
1974 { Hexagon::BI__builtin_HEXAGON_V6_vdd0, {
"v65"} },
1975 { Hexagon::BI__builtin_HEXAGON_V6_vdd0_128B, {
"v65"} },
1976 { Hexagon::BI__builtin_HEXAGON_V6_vdealb, {
"v60",
"v62",
"v65"} },
1977 { Hexagon::BI__builtin_HEXAGON_V6_vdealb_128B, {
"v60",
"v62",
"v65"} },
1978 { Hexagon::BI__builtin_HEXAGON_V6_vdealb4w, {
"v60",
"v62",
"v65"} },
1979 { Hexagon::BI__builtin_HEXAGON_V6_vdealb4w_128B, {
"v60",
"v62",
"v65"} },
1980 { Hexagon::BI__builtin_HEXAGON_V6_vdealh, {
"v60",
"v62",
"v65"} },
1981 { Hexagon::BI__builtin_HEXAGON_V6_vdealh_128B, {
"v60",
"v62",
"v65"} },
1982 { Hexagon::BI__builtin_HEXAGON_V6_vdealvdd, {
"v60",
"v62",
"v65"} },
1983 { Hexagon::BI__builtin_HEXAGON_V6_vdealvdd_128B, {
"v60",
"v62",
"v65"} },
1984 { Hexagon::BI__builtin_HEXAGON_V6_vdelta, {
"v60",
"v62",
"v65"} },
1985 { Hexagon::BI__builtin_HEXAGON_V6_vdelta_128B, {
"v60",
"v62",
"v65"} },
1986 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus, {
"v60",
"v62",
"v65"} },
1987 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_128B, {
"v60",
"v62",
"v65"} },
1988 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_acc, {
"v60",
"v62",
"v65"} },
1989 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_acc_128B, {
"v60",
"v62",
"v65"} },
1990 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv, {
"v60",
"v62",
"v65"} },
1991 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_128B, {
"v60",
"v62",
"v65"} },
1992 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_acc, {
"v60",
"v62",
"v65"} },
1993 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_acc_128B, {
"v60",
"v62",
"v65"} },
1994 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb, {
"v60",
"v62",
"v65"} },
1995 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_128B, {
"v60",
"v62",
"v65"} },
1996 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_acc, {
"v60",
"v62",
"v65"} },
1997 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_acc_128B, {
"v60",
"v62",
"v65"} },
1998 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv, {
"v60",
"v62",
"v65"} },
1999 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_128B, {
"v60",
"v62",
"v65"} },
2000 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_acc, {
"v60",
"v62",
"v65"} },
2001 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_acc_128B, {
"v60",
"v62",
"v65"} },
2002 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat, {
"v60",
"v62",
"v65"} },
2003 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_128B, {
"v60",
"v62",
"v65"} },
2004 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_acc, {
"v60",
"v62",
"v65"} },
2005 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_acc_128B, {
"v60",
"v62",
"v65"} },
2006 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat, {
"v60",
"v62",
"v65"} },
2007 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_128B, {
"v60",
"v62",
"v65"} },
2008 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_acc, {
"v60",
"v62",
"v65"} },
2009 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_acc_128B, {
"v60",
"v62",
"v65"} },
2010 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat, {
"v60",
"v62",
"v65"} },
2011 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_128B, {
"v60",
"v62",
"v65"} },
2012 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_acc, {
"v60",
"v62",
"v65"} },
2013 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_acc_128B, {
"v60",
"v62",
"v65"} },
2014 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat, {
"v60",
"v62",
"v65"} },
2015 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_128B, {
"v60",
"v62",
"v65"} },
2016 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_acc, {
"v60",
"v62",
"v65"} },
2017 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_acc_128B, {
"v60",
"v62",
"v65"} },
2018 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat, {
"v60",
"v62",
"v65"} },
2019 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_128B, {
"v60",
"v62",
"v65"} },
2020 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_acc, {
"v60",
"v62",
"v65"} },
2021 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_acc_128B, {
"v60",
"v62",
"v65"} },
2022 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh, {
"v60",
"v62",
"v65"} },
2023 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_128B, {
"v60",
"v62",
"v65"} },
2024 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_acc, {
"v60",
"v62",
"v65"} },
2025 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_acc_128B, {
"v60",
"v62",
"v65"} },
2026 { Hexagon::BI__builtin_HEXAGON_V6_veqb, {
"v60",
"v62",
"v65"} },
2027 { Hexagon::BI__builtin_HEXAGON_V6_veqb_128B, {
"v60",
"v62",
"v65"} },
2028 { Hexagon::BI__builtin_HEXAGON_V6_veqb_and, {
"v60",
"v62",
"v65"} },
2029 { Hexagon::BI__builtin_HEXAGON_V6_veqb_and_128B, {
"v60",
"v62",
"v65"} },
2030 { Hexagon::BI__builtin_HEXAGON_V6_veqb_or, {
"v60",
"v62",
"v65"} },
2031 { Hexagon::BI__builtin_HEXAGON_V6_veqb_or_128B, {
"v60",
"v62",
"v65"} },
2032 { Hexagon::BI__builtin_HEXAGON_V6_veqb_xor, {
"v60",
"v62",
"v65"} },
2033 { Hexagon::BI__builtin_HEXAGON_V6_veqb_xor_128B, {
"v60",
"v62",
"v65"} },
2034 { Hexagon::BI__builtin_HEXAGON_V6_veqh, {
"v60",
"v62",
"v65"} },
2035 { Hexagon::BI__builtin_HEXAGON_V6_veqh_128B, {
"v60",
"v62",
"v65"} },
2036 { Hexagon::BI__builtin_HEXAGON_V6_veqh_and, {
"v60",
"v62",
"v65"} },
2037 { Hexagon::BI__builtin_HEXAGON_V6_veqh_and_128B, {
"v60",
"v62",
"v65"} },
2038 { Hexagon::BI__builtin_HEXAGON_V6_veqh_or, {
"v60",
"v62",
"v65"} },
2039 { Hexagon::BI__builtin_HEXAGON_V6_veqh_or_128B, {
"v60",
"v62",
"v65"} },
2040 { Hexagon::BI__builtin_HEXAGON_V6_veqh_xor, {
"v60",
"v62",
"v65"} },
2041 { Hexagon::BI__builtin_HEXAGON_V6_veqh_xor_128B, {
"v60",
"v62",
"v65"} },
2042 { Hexagon::BI__builtin_HEXAGON_V6_veqw, {
"v60",
"v62",
"v65"} },
2043 { Hexagon::BI__builtin_HEXAGON_V6_veqw_128B, {
"v60",
"v62",
"v65"} },
2044 { Hexagon::BI__builtin_HEXAGON_V6_veqw_and, {
"v60",
"v62",
"v65"} },
2045 { Hexagon::BI__builtin_HEXAGON_V6_veqw_and_128B, {
"v60",
"v62",
"v65"} },
2046 { Hexagon::BI__builtin_HEXAGON_V6_veqw_or, {
"v60",
"v62",
"v65"} },
2047 { Hexagon::BI__builtin_HEXAGON_V6_veqw_or_128B, {
"v60",
"v62",
"v65"} },
2048 { Hexagon::BI__builtin_HEXAGON_V6_veqw_xor, {
"v60",
"v62",
"v65"} },
2049 { Hexagon::BI__builtin_HEXAGON_V6_veqw_xor_128B, {
"v60",
"v62",
"v65"} },
2050 { Hexagon::BI__builtin_HEXAGON_V6_vgtb, {
"v60",
"v62",
"v65"} },
2051 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_128B, {
"v60",
"v62",
"v65"} },
2052 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_and, {
"v60",
"v62",
"v65"} },
2053 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_and_128B, {
"v60",
"v62",
"v65"} },
2054 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_or, {
"v60",
"v62",
"v65"} },
2055 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_or_128B, {
"v60",
"v62",
"v65"} },
2056 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_xor, {
"v60",
"v62",
"v65"} },
2057 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_xor_128B, {
"v60",
"v62",
"v65"} },
2058 { Hexagon::BI__builtin_HEXAGON_V6_vgth, {
"v60",
"v62",
"v65"} },
2059 { Hexagon::BI__builtin_HEXAGON_V6_vgth_128B, {
"v60",
"v62",
"v65"} },
2060 { Hexagon::BI__builtin_HEXAGON_V6_vgth_and, {
"v60",
"v62",
"v65"} },
2061 { Hexagon::BI__builtin_HEXAGON_V6_vgth_and_128B, {
"v60",
"v62",
"v65"} },
2062 { Hexagon::BI__builtin_HEXAGON_V6_vgth_or, {
"v60",
"v62",
"v65"} },
2063 { Hexagon::BI__builtin_HEXAGON_V6_vgth_or_128B, {
"v60",
"v62",
"v65"} },
2064 { Hexagon::BI__builtin_HEXAGON_V6_vgth_xor, {
"v60",
"v62",
"v65"} },
2065 { Hexagon::BI__builtin_HEXAGON_V6_vgth_xor_128B, {
"v60",
"v62",
"v65"} },
2066 { Hexagon::BI__builtin_HEXAGON_V6_vgtub, {
"v60",
"v62",
"v65"} },
2067 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_128B, {
"v60",
"v62",
"v65"} },
2068 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_and, {
"v60",
"v62",
"v65"} },
2069 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_and_128B, {
"v60",
"v62",
"v65"} },
2070 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_or, {
"v60",
"v62",
"v65"} },
2071 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_or_128B, {
"v60",
"v62",
"v65"} },
2072 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_xor, {
"v60",
"v62",
"v65"} },
2073 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_xor_128B, {
"v60",
"v62",
"v65"} },
2074 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh, {
"v60",
"v62",
"v65"} },
2075 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_128B, {
"v60",
"v62",
"v65"} },
2076 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_and, {
"v60",
"v62",
"v65"} },
2077 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_and_128B, {
"v60",
"v62",
"v65"} },
2078 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_or, {
"v60",
"v62",
"v65"} },
2079 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_or_128B, {
"v60",
"v62",
"v65"} },
2080 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_xor, {
"v60",
"v62",
"v65"} },
2081 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_xor_128B, {
"v60",
"v62",
"v65"} },
2082 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw, {
"v60",
"v62",
"v65"} },
2083 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_128B, {
"v60",
"v62",
"v65"} },
2084 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_and, {
"v60",
"v62",
"v65"} },
2085 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_and_128B, {
"v60",
"v62",
"v65"} },
2086 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_or, {
"v60",
"v62",
"v65"} },
2087 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_or_128B, {
"v60",
"v62",
"v65"} },
2088 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_xor, {
"v60",
"v62",
"v65"} },
2089 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_xor_128B, {
"v60",
"v62",
"v65"} },
2090 { Hexagon::BI__builtin_HEXAGON_V6_vgtw, {
"v60",
"v62",
"v65"} },
2091 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_128B, {
"v60",
"v62",
"v65"} },
2092 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_and, {
"v60",
"v62",
"v65"} },
2093 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_and_128B, {
"v60",
"v62",
"v65"} },
2094 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_or, {
"v60",
"v62",
"v65"} },
2095 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_or_128B, {
"v60",
"v62",
"v65"} },
2096 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_xor, {
"v60",
"v62",
"v65"} },
2097 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_xor_128B, {
"v60",
"v62",
"v65"} },
2098 { Hexagon::BI__builtin_HEXAGON_V6_vinsertwr, {
"v60",
"v62",
"v65"} },
2099 { Hexagon::BI__builtin_HEXAGON_V6_vinsertwr_128B, {
"v60",
"v62",
"v65"} },
2100 { Hexagon::BI__builtin_HEXAGON_V6_vlalignb, {
"v60",
"v62",
"v65"} },
2101 { Hexagon::BI__builtin_HEXAGON_V6_vlalignb_128B, {
"v60",
"v62",
"v65"} },
2102 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {
"v60",
"v62",
"v65"} },
2103 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {
"v60",
"v62",
"v65"} },
2104 { Hexagon::BI__builtin_HEXAGON_V6_vlsrb, {
"v62",
"v65"} },
2105 { Hexagon::BI__builtin_HEXAGON_V6_vlsrb_128B, {
"v62",
"v65"} },
2106 { Hexagon::BI__builtin_HEXAGON_V6_vlsrh, {
"v60",
"v62",
"v65"} },
2107 { Hexagon::BI__builtin_HEXAGON_V6_vlsrh_128B, {
"v60",
"v62",
"v65"} },
2108 { Hexagon::BI__builtin_HEXAGON_V6_vlsrhv, {
"v60",
"v62",
"v65"} },
2109 { Hexagon::BI__builtin_HEXAGON_V6_vlsrhv_128B, {
"v60",
"v62",
"v65"} },
2110 { Hexagon::BI__builtin_HEXAGON_V6_vlsrw, {
"v60",
"v62",
"v65"} },
2111 { Hexagon::BI__builtin_HEXAGON_V6_vlsrw_128B, {
"v60",
"v62",
"v65"} },
2112 { Hexagon::BI__builtin_HEXAGON_V6_vlsrwv, {
"v60",
"v62",
"v65"} },
2113 { Hexagon::BI__builtin_HEXAGON_V6_vlsrwv_128B, {
"v60",
"v62",
"v65"} },
2114 { Hexagon::BI__builtin_HEXAGON_V6_vlut4, {
"v65"} },
2115 { Hexagon::BI__builtin_HEXAGON_V6_vlut4_128B, {
"v65"} },
2116 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb, {
"v60",
"v62",
"v65"} },
2117 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_128B, {
"v60",
"v62",
"v65"} },
2118 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi, {
"v62",
"v65"} },
2119 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi_128B, {
"v62",
"v65"} },
2120 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_nm, {
"v62",
"v65"} },
2121 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_nm_128B, {
"v62",
"v65"} },
2122 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracc, {
"v60",
"v62",
"v65"} },
2123 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracc_128B, {
"v60",
"v62",
"v65"} },
2124 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci, {
"v62",
"v65"} },
2125 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci_128B, {
"v62",
"v65"} },
2126 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh, {
"v60",
"v62",
"v65"} },
2127 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_128B, {
"v60",
"v62",
"v65"} },
2128 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi, {
"v62",
"v65"} },
2129 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi_128B, {
"v62",
"v65"} },
2130 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_nm, {
"v62",
"v65"} },
2131 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_nm_128B, {
"v62",
"v65"} },
2132 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracc, {
"v60",
"v62",
"v65"} },
2133 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracc_128B, {
"v60",
"v62",
"v65"} },
2134 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci, {
"v62",
"v65"} },
2135 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci_128B, {
"v62",
"v65"} },
2136 { Hexagon::BI__builtin_HEXAGON_V6_vmaxb, {
"v62",
"v65"} },
2137 { Hexagon::BI__builtin_HEXAGON_V6_vmaxb_128B, {
"v62",
"v65"} },
2138 { Hexagon::BI__builtin_HEXAGON_V6_vmaxh, {
"v60",
"v62",
"v65"} },
2139 { Hexagon::BI__builtin_HEXAGON_V6_vmaxh_128B, {
"v60",
"v62",
"v65"} },
2140 { Hexagon::BI__builtin_HEXAGON_V6_vmaxub, {
"v60",
"v62",
"v65"} },
2141 { Hexagon::BI__builtin_HEXAGON_V6_vmaxub_128B, {
"v60",
"v62",
"v65"} },
2142 { Hexagon::BI__builtin_HEXAGON_V6_vmaxuh, {
"v60",
"v62",
"v65"} },
2143 { Hexagon::BI__builtin_HEXAGON_V6_vmaxuh_128B, {
"v60",
"v62",
"v65"} },
2144 { Hexagon::BI__builtin_HEXAGON_V6_vmaxw, {
"v60",
"v62",
"v65"} },
2145 { Hexagon::BI__builtin_HEXAGON_V6_vmaxw_128B, {
"v60",
"v62",
"v65"} },
2146 { Hexagon::BI__builtin_HEXAGON_V6_vminb, {
"v62",
"v65"} },
2147 { Hexagon::BI__builtin_HEXAGON_V6_vminb_128B, {
"v62",
"v65"} },
2148 { Hexagon::BI__builtin_HEXAGON_V6_vminh, {
"v60",
"v62",
"v65"} },
2149 { Hexagon::BI__builtin_HEXAGON_V6_vminh_128B, {
"v60",
"v62",
"v65"} },
2150 { Hexagon::BI__builtin_HEXAGON_V6_vminub, {
"v60",
"v62",
"v65"} },
2151 { Hexagon::BI__builtin_HEXAGON_V6_vminub_128B, {
"v60",
"v62",
"v65"} },
2152 { Hexagon::BI__builtin_HEXAGON_V6_vminuh, {
"v60",
"v62",
"v65"} },
2153 { Hexagon::BI__builtin_HEXAGON_V6_vminuh_128B, {
"v60",
"v62",
"v65"} },
2154 { Hexagon::BI__builtin_HEXAGON_V6_vminw, {
"v60",
"v62",
"v65"} },
2155 { Hexagon::BI__builtin_HEXAGON_V6_vminw_128B, {
"v60",
"v62",
"v65"} },
2156 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus, {
"v60",
"v62",
"v65"} },
2157 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_128B, {
"v60",
"v62",
"v65"} },
2158 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_acc, {
"v60",
"v62",
"v65"} },
2159 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_acc_128B, {
"v60",
"v62",
"v65"} },
2160 { Hexagon::BI__builtin_HEXAGON_V6_vmpabusv, {
"v60",
"v62",
"v65"} },
2161 { Hexagon::BI__builtin_HEXAGON_V6_vmpabusv_128B, {
"v60",
"v62",
"v65"} },
2162 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu, {
"v65"} },
2163 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_128B, {
"v65"} },
2164 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_acc, {
"v65"} },
2165 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_acc_128B, {
"v65"} },
2166 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuuv, {
"v60",
"v62",
"v65"} },
2167 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuuv_128B, {
"v60",
"v62",
"v65"} },
2168 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb, {
"v60",
"v62",
"v65"} },
2169 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_128B, {
"v60",
"v62",
"v65"} },
2170 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_acc, {
"v60",
"v62",
"v65"} },
2171 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_acc_128B, {
"v60",
"v62",
"v65"} },
2172 { Hexagon::BI__builtin_HEXAGON_V6_vmpahhsat, {
"v65"} },
2173 { Hexagon::BI__builtin_HEXAGON_V6_vmpahhsat_128B, {
"v65"} },
2174 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb, {
"v62",
"v65"} },
2175 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_128B, {
"v62",
"v65"} },
2176 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_acc, {
"v62",
"v65"} },
2177 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_acc_128B, {
"v62",
"v65"} },
2178 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhuhsat, {
"v65"} },
2179 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhuhsat_128B, {
"v65"} },
2180 { Hexagon::BI__builtin_HEXAGON_V6_vmpsuhuhsat, {
"v65"} },
2181 { Hexagon::BI__builtin_HEXAGON_V6_vmpsuhuhsat_128B, {
"v65"} },
2182 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus, {
"v60",
"v62",
"v65"} },
2183 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_128B, {
"v60",
"v62",
"v65"} },
2184 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_acc, {
"v60",
"v62",
"v65"} },
2185 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_acc_128B, {
"v60",
"v62",
"v65"} },
2186 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv, {
"v60",
"v62",
"v65"} },
2187 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_128B, {
"v60",
"v62",
"v65"} },
2188 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_acc, {
"v60",
"v62",
"v65"} },
2189 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_acc_128B, {
"v60",
"v62",
"v65"} },
2190 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv, {
"v60",
"v62",
"v65"} },
2191 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_128B, {
"v60",
"v62",
"v65"} },
2192 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_acc, {
"v60",
"v62",
"v65"} },
2193 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_acc_128B, {
"v60",
"v62",
"v65"} },
2194 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh, {
"v60",
"v62",
"v65"} },
2195 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_128B, {
"v60",
"v62",
"v65"} },
2196 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_64, {
"v62",
"v65"} },
2197 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_64_128B, {
"v62",
"v65"} },
2198 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh, {
"v60",
"v62",
"v65"} },
2199 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_128B, {
"v60",
"v62",
"v65"} },
2200 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_acc, {
"v65"} },
2201 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_acc_128B, {
"v65"} },
2202 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsat_acc, {
"v60",
"v62",
"v65"} },
2203 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsat_acc_128B, {
"v60",
"v62",
"v65"} },
2204 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsrs, {
"v60",
"v62",
"v65"} },
2205 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsrs_128B, {
"v60",
"v62",
"v65"} },
2206 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhss, {
"v60",
"v62",
"v65"} },
2207 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhss_128B, {
"v60",
"v62",
"v65"} },
2208 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus, {
"v60",
"v62",
"v65"} },
2209 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_128B, {
"v60",
"v62",
"v65"} },
2210 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_acc, {
"v60",
"v62",
"v65"} },
2211 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_acc_128B, {
"v60",
"v62",
"v65"} },
2212 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv, {
"v60",
"v62",
"v65"} },
2213 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_128B, {
"v60",
"v62",
"v65"} },
2214 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_acc, {
"v60",
"v62",
"v65"} },
2215 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_acc_128B, {
"v60",
"v62",
"v65"} },
2216 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhvsrs, {
"v60",
"v62",
"v65"} },
2217 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhvsrs_128B, {
"v60",
"v62",
"v65"} },
2218 { Hexagon::BI__builtin_HEXAGON_V6_vmpyieoh, {
"v60",
"v62",
"v65"} },
2219 { Hexagon::BI__builtin_HEXAGON_V6_vmpyieoh_128B, {
"v60",
"v62",
"v65"} },
2220 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewh_acc, {
"v60",
"v62",
"v65"} },
2221 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewh_acc_128B, {
"v60",
"v62",
"v65"} },
2222 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh, {
"v60",
"v62",
"v65"} },
2223 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_128B, {
"v60",
"v62",
"v65"} },
2224 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_acc, {
"v60",
"v62",
"v65"} },
2225 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_acc_128B, {
"v60",
"v62",
"v65"} },
2226 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih, {
"v60",
"v62",
"v65"} },
2227 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_128B, {
"v60",
"v62",
"v65"} },
2228 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_acc, {
"v60",
"v62",
"v65"} },
2229 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_acc_128B, {
"v60",
"v62",
"v65"} },
2230 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb, {
"v60",
"v62",
"v65"} },
2231 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_128B, {
"v60",
"v62",
"v65"} },
2232 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_acc, {
"v60",
"v62",
"v65"} },
2233 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_acc_128B, {
"v60",
"v62",
"v65"} },
2234 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiowh, {
"v60",
"v62",
"v65"} },
2235 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiowh_128B, {
"v60",
"v62",
"v65"} },
2236 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb, {
"v60",
"v62",
"v65"} },
2237 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_128B, {
"v60",
"v62",
"v65"} },
2238 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_acc, {
"v60",
"v62",
"v65"} },
2239 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_acc_128B, {
"v60",
"v62",
"v65"} },
2240 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh, {
"v60",
"v62",
"v65"} },
2241 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_128B, {
"v60",
"v62",
"v65"} },
2242 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_acc, {
"v60",
"v62",
"v65"} },
2243 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_acc_128B, {
"v60",
"v62",
"v65"} },
2244 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub, {
"v62",
"v65"} },
2245 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_128B, {
"v62",
"v65"} },
2246 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_acc, {
"v62",
"v65"} },
2247 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_acc_128B, {
"v62",
"v65"} },
2248 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh, {
"v60",
"v62",
"v65"} },
2249 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_128B, {
"v60",
"v62",
"v65"} },
2250 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_64_acc, {
"v62",
"v65"} },
2251 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_64_acc_128B, {
"v62",
"v65"} },
2252 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd, {
"v60",
"v62",
"v65"} },
2253 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_128B, {
"v60",
"v62",
"v65"} },
2254 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_sacc, {
"v60",
"v62",
"v65"} },
2255 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_sacc_128B, {
"v60",
"v62",
"v65"} },
2256 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_sacc, {
"v60",
"v62",
"v65"} },
2257 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_sacc_128B, {
"v60",
"v62",
"v65"} },
2258 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub, {
"v60",
"v62",
"v65"} },
2259 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_128B, {
"v60",
"v62",
"v65"} },
2260 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_acc, {
"v60",
"v62",
"v65"} },
2261 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_acc_128B, {
"v60",
"v62",
"v65"} },
2262 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv, {
"v60",
"v62",
"v65"} },
2263 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_128B, {
"v60",
"v62",
"v65"} },
2264 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_acc, {
"v60",
"v62",
"v65"} },
2265 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_acc_128B, {
"v60",
"v62",
"v65"} },
2266 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh, {
"v60",
"v62",
"v65"} },
2267 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_128B, {
"v60",
"v62",
"v65"} },
2268 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_acc, {
"v60",
"v62",
"v65"} },
2269 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_acc_128B, {
"v60",
"v62",
"v65"} },
2270 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe, {
"v65"} },
2271 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_128B, {
"v65"} },
2272 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_acc, {
"v65"} },
2273 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_acc_128B, {
"v65"} },
2274 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv, {
"v60",
"v62",
"v65"} },
2275 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_128B, {
"v60",
"v62",
"v65"} },
2276 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_acc, {
"v60",
"v62",
"v65"} },
2277 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_acc_128B, {
"v60",
"v62",
"v65"} },
2278 { Hexagon::BI__builtin_HEXAGON_V6_vmux, {
"v60",
"v62",
"v65"} },
2279 { Hexagon::BI__builtin_HEXAGON_V6_vmux_128B, {
"v60",
"v62",
"v65"} },
2280 { Hexagon::BI__builtin_HEXAGON_V6_vnavgb, {
"v65"} },
2281 { Hexagon::BI__builtin_HEXAGON_V6_vnavgb_128B, {
"v65"} },
2282 { Hexagon::BI__builtin_HEXAGON_V6_vnavgh, {
"v60",
"v62",
"v65"} },
2283 { Hexagon::BI__builtin_HEXAGON_V6_vnavgh_128B, {
"v60",
"v62",
"v65"} },
2284 { Hexagon::BI__builtin_HEXAGON_V6_vnavgub, {
"v60",
"v62",
"v65"} },
2285 { Hexagon::BI__builtin_HEXAGON_V6_vnavgub_128B, {
"v60",
"v62",
"v65"} },
2286 { Hexagon::BI__builtin_HEXAGON_V6_vnavgw, {
"v60",
"v62",
"v65"} },
2287 { Hexagon::BI__builtin_HEXAGON_V6_vnavgw_128B, {
"v60",
"v62",
"v65"} },
2288 { Hexagon::BI__builtin_HEXAGON_V6_vnormamth, {
"v60",
"v62",
"v65"} },
2289 { Hexagon::BI__builtin_HEXAGON_V6_vnormamth_128B, {
"v60",
"v62",
"v65"} },
2290 { Hexagon::BI__builtin_HEXAGON_V6_vnormamtw, {
"v60",
"v62",
"v65"} },
2291 { Hexagon::BI__builtin_HEXAGON_V6_vnormamtw_128B, {
"v60",
"v62",
"v65"} },
2292 { Hexagon::BI__builtin_HEXAGON_V6_vnot, {
"v60",
"v62",
"v65"} },
2293 { Hexagon::BI__builtin_HEXAGON_V6_vnot_128B, {
"v60",
"v62",
"v65"} },
2294 { Hexagon::BI__builtin_HEXAGON_V6_vor, {
"v60",
"v62",
"v65"} },
2295 { Hexagon::BI__builtin_HEXAGON_V6_vor_128B, {
"v60",
"v62",
"v65"} },
2296 { Hexagon::BI__builtin_HEXAGON_V6_vpackeb, {
"v60",
"v62",
"v65"} },
2297 { Hexagon::BI__builtin_HEXAGON_V6_vpackeb_128B, {
"v60",
"v62",
"v65"} },
2298 { Hexagon::BI__builtin_HEXAGON_V6_vpackeh, {
"v60",
"v62",
"v65"} },
2299 { Hexagon::BI__builtin_HEXAGON_V6_vpackeh_128B, {
"v60",
"v62",
"v65"} },
2300 { Hexagon::BI__builtin_HEXAGON_V6_vpackhb_sat, {
"v60",
"v62",
"v65"} },
2301 { Hexagon::BI__builtin_HEXAGON_V6_vpackhb_sat_128B, {
"v60",
"v62",
"v65"} },
2302 { Hexagon::BI__builtin_HEXAGON_V6_vpackhub_sat, {
"v60",
"v62",
"v65"} },
2303 { Hexagon::BI__builtin_HEXAGON_V6_vpackhub_sat_128B, {
"v60",
"v62",
"v65"} },
2304 { Hexagon::BI__builtin_HEXAGON_V6_vpackob, {
"v60",
"v62",
"v65"} },
2305 { Hexagon::BI__builtin_HEXAGON_V6_vpackob_128B, {
"v60",
"v62",
"v65"} },
2306 { Hexagon::BI__builtin_HEXAGON_V6_vpackoh, {
"v60",
"v62",
"v65"} },
2307 { Hexagon::BI__builtin_HEXAGON_V6_vpackoh_128B, {
"v60",
"v62",
"v65"} },
2308 { Hexagon::BI__builtin_HEXAGON_V6_vpackwh_sat, {
"v60",
"v62",
"v65"} },
2309 { Hexagon::BI__builtin_HEXAGON_V6_vpackwh_sat_128B, {
"v60",
"v62",
"v65"} },
2310 { Hexagon::BI__builtin_HEXAGON_V6_vpackwuh_sat, {
"v60",
"v62",
"v65"} },
2311 { Hexagon::BI__builtin_HEXAGON_V6_vpackwuh_sat_128B, {
"v60",
"v62",
"v65"} },
2312 { Hexagon::BI__builtin_HEXAGON_V6_vpopcounth, {
"v60",
"v62",
"v65"} },
2313 { Hexagon::BI__builtin_HEXAGON_V6_vpopcounth_128B, {
"v60",
"v62",
"v65"} },
2314 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqb, {
"v65"} },
2315 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqb_128B, {
"v65"} },
2316 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqh, {
"v65"} },
2317 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqh_128B, {
"v65"} },
2318 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqw, {
"v65"} },
2319 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqw_128B, {
"v65"} },
2320 { Hexagon::BI__builtin_HEXAGON_V6_vrdelta, {
"v60",
"v62",
"v65"} },
2321 { Hexagon::BI__builtin_HEXAGON_V6_vrdelta_128B, {
"v60",
"v62",
"v65"} },
2322 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt, {
"v65"} },
2323 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_128B, {
"v65"} },
2324 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_acc, {
"v65"} },
2325 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_acc_128B, {
"v65"} },
2326 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus, {
"v60",
"v62",
"v65"} },
2327 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_128B, {
"v60",
"v62",
"v65"} },
2328 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_acc, {
"v60",
"v62",
"v65"} },
2329 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_acc_128B, {
"v60",
"v62",
"v65"} },
2330 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {
"v60",
"v62",
"v65"} },
2331 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {
"v60",
"v62",
"v65"} },
2332 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {
"v60",
"v62",
"v65"} },
2333 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B, {
"v60",
"v62",
"v65"} },
2334 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv, {
"v60",
"v62",
"v65"} },
2335 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_128B, {
"v60",
"v62",
"v65"} },
2336 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_acc, {
"v60",
"v62",
"v65"} },
2337 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_acc_128B, {
"v60",
"v62",
"v65"} },
2338 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv, {
"v60",
"v62",
"v65"} },
2339 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_128B, {
"v60",
"v62",
"v65"} },
2340 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_acc, {
"v60",
"v62",
"v65"} },
2341 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_acc_128B, {
"v60",
"v62",
"v65"} },
2342 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub, {
"v60",
"v62",
"v65"} },
2343 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_128B, {
"v60",
"v62",
"v65"} },
2344 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_acc, {
"v60",
"v62",
"v65"} },
2345 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_acc_128B, {
"v60",
"v62",
"v65"} },
2346 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {
"v60",
"v62",
"v65"} },
2347 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {
"v60",
"v62",
"v65"} },
2348 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {
"v60",
"v62",
"v65"} },
2349 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B, {
"v60",
"v62",
"v65"} },
2350 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt, {
"v65"} },
2351 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_128B, {
"v65"} },
2352 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_acc, {
"v65"} },
2353 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B, {
"v65"} },
2354 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv, {
"v60",
"v62",
"v65"} },
2355 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_128B, {
"v60",
"v62",
"v65"} },
2356 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_acc, {
"v60",
"v62",
"v65"} },
2357 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_acc_128B, {
"v60",
"v62",
"v65"} },
2358 { Hexagon::BI__builtin_HEXAGON_V6_vror, {
"v60",
"v62",
"v65"} },
2359 { Hexagon::BI__builtin_HEXAGON_V6_vror_128B, {
"v60",
"v62",
"v65"} },
2360 { Hexagon::BI__builtin_HEXAGON_V6_vroundhb, {
"v60",
"v62",
"v65"} },
2361 { Hexagon::BI__builtin_HEXAGON_V6_vroundhb_128B, {
"v60",
"v62",
"v65"} },
2362 { Hexagon::BI__builtin_HEXAGON_V6_vroundhub, {
"v60",
"v62",
"v65"} },
2363 { Hexagon::BI__builtin_HEXAGON_V6_vroundhub_128B, {
"v60",
"v62",
"v65"} },
2364 { Hexagon::BI__builtin_HEXAGON_V6_vrounduhub, {
"v62",
"v65"} },
2365 { Hexagon::BI__builtin_HEXAGON_V6_vrounduhub_128B, {
"v62",
"v65"} },
2366 { Hexagon::BI__builtin_HEXAGON_V6_vrounduwuh, {
"v62",
"v65"} },
2367 { Hexagon::BI__builtin_HEXAGON_V6_vrounduwuh_128B, {
"v62",
"v65"} },
2368 { Hexagon::BI__builtin_HEXAGON_V6_vroundwh, {
"v60",
"v62",
"v65"} },
2369 { Hexagon::BI__builtin_HEXAGON_V6_vroundwh_128B, {
"v60",
"v62",
"v65"} },
2370 { Hexagon::BI__builtin_HEXAGON_V6_vroundwuh, {
"v60",
"v62",
"v65"} },
2371 { Hexagon::BI__builtin_HEXAGON_V6_vroundwuh_128B, {
"v60",
"v62",
"v65"} },
2372 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {
"v60",
"v62",
"v65"} },
2373 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {
"v60",
"v62",
"v65"} },
2374 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {
"v60",
"v62",
"v65"} },
2375 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B, {
"v60",
"v62",
"v65"} },
2376 { Hexagon::BI__builtin_HEXAGON_V6_vsathub, {
"v60",
"v62",
"v65"} },
2377 { Hexagon::BI__builtin_HEXAGON_V6_vsathub_128B, {
"v60",
"v62",
"v65"} },
2378 { Hexagon::BI__builtin_HEXAGON_V6_vsatuwuh, {
"v62",
"v65"} },
2379 { Hexagon::BI__builtin_HEXAGON_V6_vsatuwuh_128B, {
"v62",
"v65"} },
2380 { Hexagon::BI__builtin_HEXAGON_V6_vsatwh, {
"v60",
"v62",
"v65"} },
2381 { Hexagon::BI__builtin_HEXAGON_V6_vsatwh_128B, {
"v60",
"v62",
"v65"} },
2382 { Hexagon::BI__builtin_HEXAGON_V6_vsb, {
"v60",
"v62",
"v65"} },
2383 { Hexagon::BI__builtin_HEXAGON_V6_vsb_128B, {
"v60",
"v62",
"v65"} },
2384 { Hexagon::BI__builtin_HEXAGON_V6_vsh, {
"v60",
"v62",
"v65"} },
2385 { Hexagon::BI__builtin_HEXAGON_V6_vsh_128B, {
"v60",
"v62",
"v65"} },
2386 { Hexagon::BI__builtin_HEXAGON_V6_vshufeh, {
"v60",
"v62",
"v65"} },
2387 { Hexagon::BI__builtin_HEXAGON_V6_vshufeh_128B, {
"v60",
"v62",
"v65"} },
2388 { Hexagon::BI__builtin_HEXAGON_V6_vshuffb, {
"v60",
"v62",
"v65"} },
2389 { Hexagon::BI__builtin_HEXAGON_V6_vshuffb_128B, {
"v60",
"v62",
"v65"} },
2390 { Hexagon::BI__builtin_HEXAGON_V6_vshuffeb, {
"v60",
"v62",
"v65"} },
2391 { Hexagon::BI__builtin_HEXAGON_V6_vshuffeb_128B, {
"v60",
"v62",
"v65"} },
2392 { Hexagon::BI__builtin_HEXAGON_V6_vshuffh, {
"v60",
"v62",
"v65"} },
2393 { Hexagon::BI__builtin_HEXAGON_V6_vshuffh_128B, {
"v60",
"v62",
"v65"} },
2394 { Hexagon::BI__builtin_HEXAGON_V6_vshuffob, {
"v60",
"v62",
"v65"} },
2395 { Hexagon::BI__builtin_HEXAGON_V6_vshuffob_128B, {
"v60",
"v62",
"v65"} },
2396 { Hexagon::BI__builtin_HEXAGON_V6_vshuffvdd, {
"v60",
"v62",
"v65"} },
2397 { Hexagon::BI__builtin_HEXAGON_V6_vshuffvdd_128B, {
"v60",
"v62",
"v65"} },
2398 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeb, {
"v60",
"v62",
"v65"} },
2399 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeb_128B, {
"v60",
"v62",
"v65"} },
2400 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeh, {
"v60",
"v62",
"v65"} },
2401 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeh_128B, {
"v60",
"v62",
"v65"} },
2402 { Hexagon::BI__builtin_HEXAGON_V6_vshufoh, {
"v60",
"v62",
"v65"} },
2403 { Hexagon::BI__builtin_HEXAGON_V6_vshufoh_128B, {
"v60",
"v62",
"v65"} },
2404 { Hexagon::BI__builtin_HEXAGON_V6_vsubb, {
"v60",
"v62",
"v65"} },
2405 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_128B, {
"v60",
"v62",
"v65"} },
2406 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_dv, {
"v60",
"v62",
"v65"} },
2407 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_dv_128B, {
"v60",
"v62",
"v65"} },
2408 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat, {
"v62",
"v65"} },
2409 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_128B, {
"v62",
"v65"} },
2410 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_dv, {
"v62",
"v65"} },
2411 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_dv_128B, {
"v62",
"v65"} },
2412 { Hexagon::BI__builtin_HEXAGON_V6_vsubcarry, {
"v62",
"v65"} },
2413 { Hexagon::BI__builtin_HEXAGON_V6_vsubcarry_128B, {
"v62",
"v65"} },
2414 { Hexagon::BI__builtin_HEXAGON_V6_vsubh, {
"v60",
"v62",
"v65"} },
2415 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_128B, {
"v60",
"v62",
"v65"} },
2416 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_dv, {
"v60",
"v62",
"v65"} },
2417 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_dv_128B, {
"v60",
"v62",
"v65"} },
2418 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat, {
"v60",
"v62",
"v65"} },
2419 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_128B, {
"v60",
"v62",
"v65"} },
2420 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_dv, {
"v60",
"v62",
"v65"} },
2421 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_dv_128B, {
"v60",
"v62",
"v65"} },
2422 { Hexagon::BI__builtin_HEXAGON_V6_vsubhw, {
"v60",
"v62",
"v65"} },
2423 { Hexagon::BI__builtin_HEXAGON_V6_vsubhw_128B, {
"v60",
"v62",
"v65"} },
2424 { Hexagon::BI__builtin_HEXAGON_V6_vsububh, {
"v60",
"v62",
"v65"} },
2425 { Hexagon::BI__builtin_HEXAGON_V6_vsububh_128B, {
"v60",
"v62",
"v65"} },
2426 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat, {
"v60",
"v62",
"v65"} },
2427 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_128B, {
"v60",
"v62",
"v65"} },
2428 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_dv, {
"v60",
"v62",
"v65"} },
2429 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_dv_128B, {
"v60",
"v62",
"v65"} },
2430 { Hexagon::BI__builtin_HEXAGON_V6_vsubububb_sat, {
"v62",
"v65"} },
2431 { Hexagon::BI__builtin_HEXAGON_V6_vsubububb_sat_128B, {
"v62",
"v65"} },
2432 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat, {
"v60",
"v62",
"v65"} },
2433 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_128B, {
"v60",
"v62",
"v65"} },
2434 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_dv, {
"v60",
"v62",
"v65"} },
2435 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_dv_128B, {
"v60",
"v62",
"v65"} },
2436 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhw, {
"v60",
"v62",
"v65"} },
2437 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhw_128B, {
"v60",
"v62",
"v65"} },
2438 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat, {
"v62",
"v65"} },
2439 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_128B, {
"v62",
"v65"} },
2440 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_dv, {
"v62",
"v65"} },
2441 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_dv_128B, {
"v62",
"v65"} },
2442 { Hexagon::BI__builtin_HEXAGON_V6_vsubw, {
"v60",
"v62",
"v65"} },
2443 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_128B, {
"v60",
"v62",
"v65"} },
2444 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_dv, {
"v60",
"v62",
"v65"} },
2445 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_dv_128B, {
"v60",
"v62",
"v65"} },
2446 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat, {
"v60",
"v62",
"v65"} },
2447 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_128B, {
"v60",
"v62",
"v65"} },
2448 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_dv, {
"v60",
"v62",
"v65"} },
2449 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_dv_128B, {
"v60",
"v62",
"v65"} },
2450 { Hexagon::BI__builtin_HEXAGON_V6_vswap, {
"v60",
"v62",
"v65"} },
2451 { Hexagon::BI__builtin_HEXAGON_V6_vswap_128B, {
"v60",
"v62",
"v65"} },
2452 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb, {
"v60",
"v62",
"v65"} },
2453 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_128B, {
"v60",
"v62",
"v65"} },
2454 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_acc, {
"v60",
"v62",
"v65"} },
2455 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_acc_128B, {
"v60",
"v62",
"v65"} },
2456 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus, {
"v60",
"v62",
"v65"} },
2457 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_128B, {
"v60",
"v62",
"v65"} },
2458 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_acc, {
"v60",
"v62",
"v65"} },
2459 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_acc_128B, {
"v60",
"v62",
"v65"} },
2460 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb, {
"v60",
"v62",
"v65"} },
2461 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_128B, {
"v60",
"v62",
"v65"} },
2462 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_acc, {
"v60",
"v62",
"v65"} },
2463 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_acc_128B, {
"v60",
"v62",
"v65"} },
2464 { Hexagon::BI__builtin_HEXAGON_V6_vunpackb, {
"v60",
"v62",
"v65"} },
2465 { Hexagon::BI__builtin_HEXAGON_V6_vunpackb_128B, {
"v60",
"v62",
"v65"} },
2466 { Hexagon::BI__builtin_HEXAGON_V6_vunpackh, {
"v60",
"v62",
"v65"} },
2467 { Hexagon::BI__builtin_HEXAGON_V6_vunpackh_128B, {
"v60",
"v62",
"v65"} },
2468 { Hexagon::BI__builtin_HEXAGON_V6_vunpackob, {
"v60",
"v62",
"v65"} },
2469 { Hexagon::BI__builtin_HEXAGON_V6_vunpackob_128B, {
"v60",
"v62",
"v65"} },
2470 { Hexagon::BI__builtin_HEXAGON_V6_vunpackoh, {
"v60",
"v62",
"v65"} },
2471 { Hexagon::BI__builtin_HEXAGON_V6_vunpackoh_128B, {
"v60",
"v62",
"v65"} },
2472 { Hexagon::BI__builtin_HEXAGON_V6_vunpackub, {
"v60",
"v62",
"v65"} },
2473 { Hexagon::BI__builtin_HEXAGON_V6_vunpackub_128B, {
"v60",
"v62",
"v65"} },
2474 { Hexagon::BI__builtin_HEXAGON_V6_vunpackuh, {
"v60",
"v62",
"v65"} },
2475 { Hexagon::BI__builtin_HEXAGON_V6_vunpackuh_128B, {
"v60",
"v62",
"v65"} },
2476 { Hexagon::BI__builtin_HEXAGON_V6_vxor, {
"v60",
"v62",
"v65"} },
2477 { Hexagon::BI__builtin_HEXAGON_V6_vxor_128B, {
"v60",
"v62",
"v65"} },
2478 { Hexagon::BI__builtin_HEXAGON_V6_vzb, {
"v60",
"v62",
"v65"} },
2479 { Hexagon::BI__builtin_HEXAGON_V6_vzb_128B, {
"v60",
"v62",
"v65"} },
2480 { Hexagon::BI__builtin_HEXAGON_V6_vzh, {
"v60",
"v62",
"v65"} },
2481 { Hexagon::BI__builtin_HEXAGON_V6_vzh_128B, {
"v60",
"v62",
"v65"} },
2486 auto FC = ValidCPU.find(BuiltinID);
2487 if (FC != ValidCPU.end()) {
2489 StringRef CPU = Opts.
CPU;
2491 assert(CPU.startswith(
"hexagon") &&
"Unexpected CPU name");
2492 CPU.consume_front(
"hexagon");
2493 if (llvm::none_of(FC->second, [CPU](StringRef S) { return S == CPU; }))
2495 diag::err_hexagon_builtin_unsupported_cpu);
2499 auto FH = ValidHVX.find(BuiltinID);
2500 if (FH != ValidHVX.end()) {
2503 diag::err_hexagon_builtin_requires_hvx);
2505 bool IsValid = llvm::any_of(FH->second,
2506 [&TI] (StringRef V) {
2507 std::string F =
"hvx" + V.str();
2508 return TI.hasFeature(F);
2512 diag::err_hexagon_builtin_unsupported_hvx);
2518 bool Sema::CheckHexagonBuiltinArgument(
unsigned BuiltinID,
CallExpr *TheCall) {
2520 ArgInfo(
unsigned O,
bool S,
unsigned W,
unsigned A)
2521 : OpNum(O), IsSigned(S), BitWidth(W), Align(A) {}
2523 bool IsSigned =
false;
2524 unsigned BitWidth = 0;
2528 static const std::map<unsigned, std::vector<ArgInfo>> Infos = {
2529 { Hexagon::BI__builtin_circ_ldd, {{ 3,
true, 4, 3 }} },
2530 { Hexagon::BI__builtin_circ_ldw, {{ 3,
true, 4, 2 }} },
2531 { Hexagon::BI__builtin_circ_ldh, {{ 3,
true, 4, 1 }} },
2532 { Hexagon::BI__builtin_circ_lduh, {{ 3,
true, 4, 0 }} },
2533 { Hexagon::BI__builtin_circ_ldb, {{ 3,
true, 4, 0 }} },
2534 { Hexagon::BI__builtin_circ_ldub, {{ 3,
true, 4, 0 }} },
2535 { Hexagon::BI__builtin_circ_std, {{ 3,
true, 4, 3 }} },
2536 { Hexagon::BI__builtin_circ_stw, {{ 3,
true, 4, 2 }} },
2537 { Hexagon::BI__builtin_circ_sth, {{ 3,
true, 4, 1 }} },
2538 { Hexagon::BI__builtin_circ_sthhi, {{ 3,
true, 4, 1 }} },
2539 { Hexagon::BI__builtin_circ_stb, {{ 3,
true, 4, 0 }} },
2541 { Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{ 1,
true, 4, 0 }} },
2542 { Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{ 1,
true, 4, 0 }} },
2543 { Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{ 1,
true, 4, 1 }} },
2544 { Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{ 1,
true, 4, 1 }} },
2545 { Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{ 1,
true, 4, 2 }} },
2546 { Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{ 1,
true, 4, 3 }} },
2547 { Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{ 1,
true, 4, 0 }} },
2548 { Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{ 1,
true, 4, 1 }} },
2549 { Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{ 1,
true, 4, 1 }} },
2550 { Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{ 1,
true, 4, 2 }} },
2551 { Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{ 1,
true, 4, 3 }} },
2553 { Hexagon::BI__builtin_HEXAGON_A2_combineii, {{ 1,
true, 8, 0 }} },
2554 { Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{ 1,
false, 16, 0 }} },
2555 { Hexagon::BI__builtin_HEXAGON_A2_tfril, {{ 1,
false, 16, 0 }} },
2556 { Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{ 0,
true, 8, 0 }} },
2557 { Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{ 1,
false, 5, 0 }} },
2558 { Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{ 1,
false, 8, 0 }} },
2559 { Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{ 1,
true, 8, 0 }} },
2560 { Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{ 1,
false, 5, 0 }} },
2561 { Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{ 1,
false, 5, 0 }} },
2562 { Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{ 1,
false, 5, 0 }} },
2563 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{ 1,
false, 8, 0 }} },
2564 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{ 1,
true, 8, 0 }} },
2565 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{ 1,
false, 7, 0 }} },
2566 { Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{ 1,
true, 8, 0 }} },
2567 { Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{ 1,
true, 8, 0 }} },
2568 { Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{ 1,
false, 7, 0 }} },
2569 { Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{ 1,
true, 8, 0 }} },
2570 { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{ 1,
true, 8, 0 }} },
2571 { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{ 1,
false, 7, 0 }} },
2572 { Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{ 1,
false, 6, 0 }} },
2573 { Hexagon::BI__builtin_HEXAGON_C2_muxii, {{ 2,
true, 8, 0 }} },
2574 { Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{ 1,
false, 6, 0 }} },
2575 { Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{ 1,
false, 5, 0 }} },
2576 { Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{ 0,
false, 10, 0 }} },
2577 { Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{ 0,
false, 10, 0 }} },
2578 { Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{ 1,
false, 5, 0 }} },
2579 { Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{ 0,
false, 10, 0 }} },
2580 { Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{ 0,
false, 10, 0 }} },
2581 { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{ 2,
false, 6, 0 }} },
2582 { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{ 1,
false, 6, 2 }} },
2583 { Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{ 2,
false, 3, 0 }} },
2584 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{ 2,
false, 6, 0 }} },
2585 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{ 2,
false, 6, 0 }} },
2586 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{ 1,
false, 6, 0 }} },
2587 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{ 2,
false, 6, 0 }} },
2588 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{ 2,
false, 6, 0 }} },
2589 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{ 2,
false, 6, 0 }} },
2590 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{ 2,
false, 5, 0 }} },
2591 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{ 2,
false, 5, 0 }} },
2592 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{ 1,
false, 5, 0 }} },
2593 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{ 2,
false, 5, 0 }} },
2594 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{ 2,
false, 5, 0 }} },
2595 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{ 1,
false, 5, 0 }} },
2596 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{ 2,
false, 5, 0 }} },
2597 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{ 1,
false, 4, 0 }} },
2598 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{ 1,
false, 5, 0 }} },
2599 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{ 2,
false, 6, 0 }} },
2600 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{ 2,
false, 6, 0 }} },
2601 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{ 1,
false, 6, 0 }} },
2602 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{ 2,
false, 6, 0 }} },
2603 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{ 2,
false, 6, 0 }} },
2604 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax,
2605 {{ 1,
false, 6, 0 }} },
2606 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{ 1,
false, 6, 0 }} },
2607 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{ 2,
false, 5, 0 }} },
2608 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{ 2,
false, 5, 0 }} },
2609 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{ 1,
false, 5, 0 }} },
2610 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{ 2,
false, 5, 0 }} },
2611 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{ 2,
false, 5, 0 }} },
2612 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax,
2613 {{ 1,
false, 5, 0 }} },
2614 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{ 1,
false, 5, 0 }} },
2615 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{ 1,
false, 5, 0 }} },
2616 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{ 1,
false, 4, 0 }} },
2617 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{ 1,
false, 5, 0 }} },
2618 { Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{ 1,
false, 5, 0 }} },
2619 { Hexagon::BI__builtin_HEXAGON_S2_extractu, {{ 1,
false, 5, 0 },
2620 { 2,
false, 5, 0 }} },
2621 { Hexagon::BI__builtin_HEXAGON_S2_extractup, {{ 1,
false, 6, 0 },
2622 { 2,
false, 6, 0 }} },
2623 { Hexagon::BI__builtin_HEXAGON_S2_insert, {{ 2,
false, 5, 0 },
2624 { 3,
false, 5, 0 }} },
2625 { Hexagon::BI__builtin_HEXAGON_S2_insertp, {{ 2,
false, 6, 0 },
2626 { 3,
false, 6, 0 }} },
2627 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{ 2,
false, 6, 0 }} },
2628 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{ 2,
false, 6, 0 }} },
2629 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{ 1,
false, 6, 0 }} },
2630 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{ 2,
false, 6, 0 }} },
2631 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{ 2,
false, 6, 0 }} },
2632 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{ 2,
false, 6, 0 }} },
2633 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{ 2,
false, 5, 0 }} },
2634 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{ 2,
false, 5, 0 }} },
2635 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{ 1,
false, 5, 0 }} },
2636 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{ 2,
false, 5, 0 }} },
2637 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{ 2,
false, 5, 0 }} },
2638 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{ 2,
false, 5, 0 }} },
2639 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{ 1,
false, 4, 0 }} },
2640 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{ 1,
false, 5, 0 }} },
2641 { Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{ 1,
false, 5, 0 }} },
2642 { Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax,
2643 {{ 2,
false, 4, 0 },
2644 { 3,
false, 5, 0 }} },
2645 { Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax,
2646 {{ 2,
false, 4, 0 },
2647 { 3,
false, 5, 0 }} },
2648 { Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax,
2649 {{ 2,
false, 4, 0 },
2650 { 3,
false, 5, 0 }} },
2651 { Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax,
2652 {{ 2,
false, 4, 0 },
2653 { 3,
false, 5, 0 }} },
2654 { Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{ 1,
false, 5, 0 }} },
2655 { Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{ 1,
false, 5, 0 }} },
2656 { Hexagon::BI__builtin_HEXAGON_S2_valignib, {{ 2,
false, 3, 0 }} },
2657 { Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{ 2,
false, 3, 0 }} },
2658 { Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{ 2,
false, 5, 0 }} },
2659 { Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{ 2,
false, 5, 0 }} },
2660 { Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{ 2,
false, 5, 0 }} },
2661 { Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{ 2,
false, 5, 0 }} },
2662 { Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{ 1,
true , 6, 0 }} },
2663 { Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{ 1,
true, 6, 0 }} },
2664 { Hexagon::BI__builtin_HEXAGON_S4_extract, {{ 1,
false, 5, 0 },
2665 { 2,
false, 5, 0 }} },
2666 { Hexagon::BI__builtin_HEXAGON_S4_extractp, {{ 1,
false, 6, 0 },
2667 { 2,
false, 6, 0 }} },
2668 { Hexagon::BI__builtin_HEXAGON_S4_lsli, {{ 0,
true, 6, 0 }} },
2669 { Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{ 1,
false, 5, 0 }} },
2670 { Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{ 2,
false, 5, 0 }} },
2671 { Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{ 2,
false, 5, 0 }} },
2672 { Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{ 2,
false, 5, 0 }} },
2673 { Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{ 2,
false, 5, 0 }} },
2674 { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{ 3,
false, 2, 0 }} },
2675 { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{ 2,
false, 2, 0 }} },
2676 { Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax,
2677 {{ 1,
false, 4, 0 }} },
2678 { Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{ 1,
false, 4, 0 }} },
2679 { Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax,
2680 {{ 1,
false, 4, 0 }} },
2681 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{ 1,
false, 6, 0 }} },
2682 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{ 2,
false, 6, 0 }} },
2683 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{ 2,
false, 6, 0 }} },
2684 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{ 2,
false, 6, 0 }} },
2685 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{ 2,
false, 6, 0 }} },
2686 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{ 2,
false, 6, 0 }} },
2687 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{ 1,
false, 5, 0 }} },
2688 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{ 2,
false, 5, 0 }} },
2689 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{ 2,
false, 5, 0 }} },
2690 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{ 2,
false, 5, 0 }} },
2691 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{ 2,
false, 5, 0 }} },
2692 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{ 2,
false, 5, 0 }} },
2693 { Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{ 2,
false, 3, 0 }} },
2694 { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{ 2,
false, 3, 0 }} },
2695 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{ 2,
false, 3, 0 }} },
2696 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{ 2,
false, 3, 0 }} },
2697 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{ 2,
false, 1, 0 }} },
2698 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{ 2,
false, 1, 0 }} },
2699 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{ 3,
false, 1, 0 }} },
2700 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B,
2701 {{ 3,
false, 1, 0 }} },
2702 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{ 2,
false, 1, 0 }} },
2703 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{ 2,
false, 1, 0 }} },
2704 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{ 3,
false, 1, 0 }} },
2705 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B,
2706 {{ 3,
false, 1, 0 }} },
2707 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{ 2,
false, 1, 0 }} },
2708 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{ 2,
false, 1, 0 }} },
2709 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{ 3,
false, 1, 0 }} },
2710 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B,
2711 {{ 3,
false, 1, 0 }} },
2714 auto F = Infos.find(BuiltinID);
2715 if (F == Infos.end())
2720 for (
const ArgInfo &A : F->second) {
2721 int32_t Min = A.IsSigned ? -(1 << (A.BitWidth-1)) : 0;
2722 int32_t Max = (1 << (A.IsSigned ? A.BitWidth-1 : A.BitWidth)) - 1;
2724 Error |= SemaBuiltinConstantArgRange(TheCall, A.OpNum, Min, Max);
2726 unsigned M = 1 << A.Align;
2729 Error |= SemaBuiltinConstantArgRange(TheCall, A.OpNum, Min, Max) |
2730 SemaBuiltinConstantArgMultiple(TheCall, A.OpNum, M);
2736 bool Sema::CheckHexagonBuiltinFunctionCall(
unsigned BuiltinID,
2738 return CheckHexagonBuiltinCpu(BuiltinID, TheCall) ||
2739 CheckHexagonBuiltinArgument(BuiltinID, TheCall);
2752 bool Sema::CheckMipsBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
2753 unsigned i = 0, l = 0, u = 0, m = 0;
2754 switch (BuiltinID) {
2755 default:
return false;
2756 case Mips::BI__builtin_mips_wrdsp: i = 1; l = 0; u = 63;
break;
2757 case Mips::BI__builtin_mips_rddsp: i = 0; l = 0; u = 63;
break;
2758 case Mips::BI__builtin_mips_append: i = 2; l = 0; u = 31;
break;
2759 case Mips::BI__builtin_mips_balign: i = 2; l = 0; u = 3;
break;
2760 case Mips::BI__builtin_mips_precr_sra_ph_w: i = 2; l = 0; u = 31;
break;
2761 case Mips::BI__builtin_mips_precr_sra_r_ph_w: i = 2; l = 0; u = 31;
break;
2762 case Mips::BI__builtin_mips_prepend: i = 2; l = 0; u = 31;
break;
2766 case Mips::BI__builtin_msa_bclri_b:
2767 case Mips::BI__builtin_msa_bnegi_b:
2768 case Mips::BI__builtin_msa_bseti_b:
2769 case Mips::BI__builtin_msa_sat_s_b:
2770 case Mips::BI__builtin_msa_sat_u_b:
2771 case Mips::BI__builtin_msa_slli_b:
2772 case Mips::BI__builtin_msa_srai_b:
2773 case Mips::BI__builtin_msa_srari_b:
2774 case Mips::BI__builtin_msa_srli_b:
2775 case Mips::BI__builtin_msa_srlri_b: i = 1; l = 0; u = 7;
break;
2776 case Mips::BI__builtin_msa_binsli_b:
2777 case Mips::BI__builtin_msa_binsri_b: i = 2; l = 0; u = 7;
break;
2779 case Mips::BI__builtin_msa_bclri_h:
2780 case Mips::BI__builtin_msa_bnegi_h:
2781 case Mips::BI__builtin_msa_bseti_h:
2782 case Mips::BI__builtin_msa_sat_s_h:
2783 case Mips::BI__builtin_msa_sat_u_h:
2784 case Mips::BI__builtin_msa_slli_h:
2785 case Mips::BI__builtin_msa_srai_h:
2786 case Mips::BI__builtin_msa_srari_h:
2787 case Mips::BI__builtin_msa_srli_h:
2788 case Mips::BI__builtin_msa_srlri_h: i = 1; l = 0; u = 15;
break;
2789 case Mips::BI__builtin_msa_binsli_h:
2790 case Mips::BI__builtin_msa_binsri_h: i = 2; l = 0; u = 15;
break;
2794 case Mips::BI__builtin_msa_clei_u_b:
2795 case Mips::BI__builtin_msa_clei_u_h:
2796 case Mips::BI__builtin_msa_clei_u_w:
2797 case Mips::BI__builtin_msa_clei_u_d:
2798 case Mips::BI__builtin_msa_clti_u_b:
2799 case Mips::BI__builtin_msa_clti_u_h:
2800 case Mips::BI__builtin_msa_clti_u_w:
2801 case Mips::BI__builtin_msa_clti_u_d:
2802 case Mips::BI__builtin_msa_maxi_u_b:
2803 case Mips::BI__builtin_msa_maxi_u_h:
2804 case Mips::BI__builtin_msa_maxi_u_w:
2805 case Mips::BI__builtin_msa_maxi_u_d:
2806 case Mips::BI__builtin_msa_mini_u_b:
2807 case Mips::BI__builtin_msa_mini_u_h:
2808 case Mips::BI__builtin_msa_mini_u_w:
2809 case Mips::BI__builtin_msa_mini_u_d:
2810 case Mips::BI__builtin_msa_addvi_b:
2811 case Mips::BI__builtin_msa_addvi_h:
2812 case Mips::BI__builtin_msa_addvi_w:
2813 case Mips::BI__builtin_msa_addvi_d:
2814 case Mips::BI__builtin_msa_bclri_w:
2815 case Mips::BI__builtin_msa_bnegi_w:
2816 case Mips::BI__builtin_msa_bseti_w:
2817 case Mips::BI__builtin_msa_sat_s_w:
2818 case Mips::BI__builtin_msa_sat_u_w:
2819 case Mips::BI__builtin_msa_slli_w:
2820 case Mips::BI__builtin_msa_srai_w:
2821 case Mips::BI__builtin_msa_srari_w:
2822 case Mips::BI__builtin_msa_srli_w:
2823 case Mips::BI__builtin_msa_srlri_w:
2824 case Mips::BI__builtin_msa_subvi_b:
2825 case Mips::BI__builtin_msa_subvi_h:
2826 case Mips::BI__builtin_msa_subvi_w:
2827 case Mips::BI__builtin_msa_subvi_d: i = 1; l = 0; u = 31;
break;
2828 case Mips::BI__builtin_msa_binsli_w:
2829 case Mips::BI__builtin_msa_binsri_w: i = 2; l = 0; u = 31;
break;
2831 case Mips::BI__builtin_msa_bclri_d:
2832 case Mips::BI__builtin_msa_bnegi_d:
2833 case Mips::BI__builtin_msa_bseti_d:
2834 case Mips::BI__builtin_msa_sat_s_d:
2835 case Mips::BI__builtin_msa_sat_u_d:
2836 case Mips::BI__builtin_msa_slli_d:
2837 case Mips::BI__builtin_msa_srai_d:
2838 case Mips::BI__builtin_msa_srari_d:
2839 case Mips::BI__builtin_msa_srli_d:
2840 case Mips::BI__builtin_msa_srlri_d: i = 1; l = 0; u = 63;
break;
2841 case Mips::BI__builtin_msa_binsli_d:
2842 case Mips::BI__builtin_msa_binsri_d: i = 2; l = 0; u = 63;
break;
2844 case Mips::BI__builtin_msa_ceqi_b:
2845 case Mips::BI__builtin_msa_ceqi_h:
2846 case Mips::BI__builtin_msa_ceqi_w:
2847 case Mips::BI__builtin_msa_ceqi_d:
2848 case Mips::BI__builtin_msa_clti_s_b:
2849 case Mips::BI__builtin_msa_clti_s_h:
2850 case Mips::BI__builtin_msa_clti_s_w:
2851 case Mips::BI__builtin_msa_clti_s_d:
2852 case Mips::BI__builtin_msa_clei_s_b:
2853 case Mips::BI__builtin_msa_clei_s_h:
2854 case Mips::BI__builtin_msa_clei_s_w:
2855 case Mips::BI__builtin_msa_clei_s_d:
2856 case Mips::BI__builtin_msa_maxi_s_b:
2857 case Mips::BI__builtin_msa_maxi_s_h:
2858 case Mips::BI__builtin_msa_maxi_s_w:
2859 case Mips::BI__builtin_msa_maxi_s_d:
2860 case Mips::BI__builtin_msa_mini_s_b:
2861 case Mips::BI__builtin_msa_mini_s_h:
2862 case Mips::BI__builtin_msa_mini_s_w:
2863 case Mips::BI__builtin_msa_mini_s_d: i = 1; l = -16; u = 15;
break;
2865 case Mips::BI__builtin_msa_andi_b:
2866 case Mips::BI__builtin_msa_nori_b:
2867 case Mips::BI__builtin_msa_ori_b:
2868 case Mips::BI__builtin_msa_shf_b:
2869 case Mips::BI__builtin_msa_shf_h:
2870 case Mips::BI__builtin_msa_shf_w:
2871 case Mips::BI__builtin_msa_xori_b: i = 1; l = 0; u = 255;
break;
2872 case Mips::BI__builtin_msa_bseli_b:
2873 case Mips::BI__builtin_msa_bmnzi_b:
2874 case Mips::BI__builtin_msa_bmzi_b: i = 2; l = 0; u = 255;
break;
2877 case Mips::BI__builtin_msa_copy_s_b:
2878 case Mips::BI__builtin_msa_copy_u_b:
2879 case Mips::BI__builtin_msa_insve_b:
2880 case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15;
break;
2881 case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15;
break;
2883 case Mips::BI__builtin_msa_copy_s_h:
2884 case Mips::BI__builtin_msa_copy_u_h:
2885 case Mips::BI__builtin_msa_insve_h:
2886 case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7;
break;
2887 case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7;
break;
2889 case Mips::BI__builtin_msa_copy_s_w:
2890 case Mips::BI__builtin_msa_copy_u_w:
2891 case Mips::BI__builtin_msa_insve_w:
2892 case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3;
break;
2893 case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3;
break;
2895 case Mips::BI__builtin_msa_copy_s_d:
2896 case Mips::BI__builtin_msa_copy_u_d:
2897 case Mips::BI__builtin_msa_insve_d:
2898 case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1;
break;
2899 case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1;
break;
2902 case Mips::BI__builtin_msa_ldi_b: i = 0; l = -128; u = 255;
break;
2903 case Mips::BI__builtin_msa_ldi_h:
2904 case Mips::BI__builtin_msa_ldi_w:
2905 case Mips::BI__builtin_msa_ldi_d: i = 0; l = -512; u = 511;
break;
2906 case Mips::BI__builtin_msa_ld_b: i = 1; l = -512; u = 511; m = 16;
break;
2907 case Mips::BI__builtin_msa_ld_h: i = 1; l = -1024; u = 1022; m = 16;
break;
2908 case Mips::BI__builtin_msa_ld_w: i = 1; l = -2048; u = 2044; m = 16;
break;
2909 case Mips::BI__builtin_msa_ld_d: i = 1; l = -4096; u = 4088; m = 16;
break;
2910 case Mips::BI__builtin_msa_st_b: i = 2; l = -512; u = 511; m = 16;
break;
2911 case Mips::BI__builtin_msa_st_h: i = 2; l = -1024; u = 1022; m = 16;
break;
2912 case Mips::BI__builtin_msa_st_w: i = 2; l = -2048; u = 2044; m = 16;
break;
2913 case Mips::BI__builtin_msa_st_d: i = 2; l = -4096; u = 4088; m = 16;
break;
2917 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
2919 return SemaBuiltinConstantArgRange(TheCall, i, l, u) ||
2920 SemaBuiltinConstantArgMultiple(TheCall, i, m);
2923 bool Sema::CheckPPCBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
2924 unsigned i = 0, l = 0, u = 0;
2925 bool Is64BitBltin = BuiltinID == PPC::BI__builtin_divde ||
2926 BuiltinID == PPC::BI__builtin_divdeu ||
2927 BuiltinID == PPC::BI__builtin_bpermd;
2931 .getIntPtrType()) == 64;
2932 bool IsBltinExtDiv = BuiltinID == PPC::BI__builtin_divwe ||
2933 BuiltinID == PPC::BI__builtin_divweu ||
2934 BuiltinID == PPC::BI__builtin_divde ||
2935 BuiltinID == PPC::BI__builtin_divdeu;
2937 if (Is64BitBltin && !IsTarget64Bit)
2938 return Diag(TheCall->
getLocStart(), diag::err_64_bit_builtin_32_bit_tgt)
2942 (BuiltinID == PPC::BI__builtin_bpermd &&
2944 return Diag(TheCall->
getLocStart(), diag::err_ppc_builtin_only_on_pwr7)
2947 switch (BuiltinID) {
2948 default:
return false;
2949 case PPC::BI__builtin_altivec_crypto_vshasigmaw:
2950 case PPC::BI__builtin_altivec_crypto_vshasigmad:
2951 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
2952 SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
2953 case PPC::BI__builtin_tbegin:
2954 case PPC::BI__builtin_tend: i = 0; l = 0; u = 1;
break;
2955 case PPC::BI__builtin_tsr: i = 0; l = 0; u = 7;
break;
2956 case PPC::BI__builtin_tabortwc:
2957 case PPC::BI__builtin_tabortdc: i = 0; l = 0; u = 31;
break;
2958 case PPC::BI__builtin_tabortwci:
2959 case PPC::BI__builtin_tabortdci:
2960 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
2961 SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
2962 case PPC::BI__builtin_vsx_xxpermdi:
2963 case PPC::BI__builtin_vsx_xxsldwi:
2964 return SemaBuiltinVSX(TheCall);
2966 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
2969 bool Sema::CheckSystemZBuiltinFunctionCall(
unsigned BuiltinID,
2971 if (BuiltinID == SystemZ::BI__builtin_tabort) {
2973 llvm::APSInt AbortCode(32);
2975 AbortCode.getSExtValue() >= 0 && AbortCode.getSExtValue() < 256)
2976 return Diag(Arg->
getLocStart(), diag::err_systemz_invalid_tabort_code)
2982 unsigned i = 0, l = 0, u = 0;
2983 switch (BuiltinID) {
2984 default:
return false;
2985 case SystemZ::BI__builtin_s390_lcbb: i = 1; l = 0; u = 15;
break;
2986 case SystemZ::BI__builtin_s390_verimb:
2987 case SystemZ::BI__builtin_s390_verimh:
2988 case SystemZ::BI__builtin_s390_verimf:
2989 case SystemZ::BI__builtin_s390_verimg: i = 3; l = 0; u = 255;
break;
2990 case SystemZ::BI__builtin_s390_vfaeb:
2991 case SystemZ::BI__builtin_s390_vfaeh:
2992 case SystemZ::BI__builtin_s390_vfaef:
2993 case SystemZ::BI__builtin_s390_vfaebs:
2994 case SystemZ::BI__builtin_s390_vfaehs:
2995 case SystemZ::BI__builtin_s390_vfaefs:
2996 case SystemZ::BI__builtin_s390_vfaezb:
2997 case SystemZ::BI__builtin_s390_vfaezh:
2998 case SystemZ::BI__builtin_s390_vfaezf:
2999 case SystemZ::BI__builtin_s390_vfaezbs:
3000 case SystemZ::BI__builtin_s390_vfaezhs:
3001 case SystemZ::BI__builtin_s390_vfaezfs: i = 2; l = 0; u = 15;
break;
3002 case SystemZ::BI__builtin_s390_vfisb:
3003 case SystemZ::BI__builtin_s390_vfidb:
3004 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15) ||
3005 SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
3006 case SystemZ::BI__builtin_s390_vftcisb:
3007 case SystemZ::BI__builtin_s390_vftcidb: i = 1; l = 0; u = 4095;
break;
3008 case SystemZ::BI__builtin_s390_vlbb: i = 1; l = 0; u = 15;
break;
3009 case SystemZ::BI__builtin_s390_vpdi: i = 2; l = 0; u = 15;
break;
3010 case SystemZ::BI__builtin_s390_vsldb: i = 2; l = 0; u = 15;
break;
3011 case SystemZ::BI__builtin_s390_vstrcb:
3012 case SystemZ::BI__builtin_s390_vstrch:
3013 case SystemZ::BI__builtin_s390_vstrcf:
3014 case SystemZ::BI__builtin_s390_vstrczb:
3015 case SystemZ::BI__builtin_s390_vstrczh:
3016 case SystemZ::BI__builtin_s390_vstrczf:
3017 case SystemZ::BI__builtin_s390_vstrcbs:
3018 case SystemZ::BI__builtin_s390_vstrchs:
3019 case SystemZ::BI__builtin_s390_vstrcfs:
3020 case SystemZ::BI__builtin_s390_vstrczbs:
3021 case SystemZ::BI__builtin_s390_vstrczhs:
3022 case SystemZ::BI__builtin_s390_vstrczfs: i = 3; l = 0; u = 15;
break;
3023 case SystemZ::BI__builtin_s390_vmslg: i = 3; l = 0; u = 15;
break;
3024 case SystemZ::BI__builtin_s390_vfminsb:
3025 case SystemZ::BI__builtin_s390_vfmaxsb:
3026 case SystemZ::BI__builtin_s390_vfmindb:
3027 case SystemZ::BI__builtin_s390_vfmaxdb: i = 2; l = 0; u = 15;
break;
3029 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3040 return S.
Diag(TheCall->
getLocStart(), diag::err_expr_not_string_literal)
3060 return S.
Diag(TheCall->
getLocStart(), diag::err_expr_not_string_literal)
3073 bool Sema::CheckX86BuiltinRoundingOrSAE(
unsigned BuiltinID,
CallExpr *TheCall) {
3077 unsigned ArgNum = 0;
3078 switch (BuiltinID) {
3081 case X86::BI__builtin_ia32_vcvttsd2si32:
3082 case X86::BI__builtin_ia32_vcvttsd2si64:
3083 case X86::BI__builtin_ia32_vcvttsd2usi32:
3084 case X86::BI__builtin_ia32_vcvttsd2usi64:
3085 case X86::BI__builtin_ia32_vcvttss2si32:
3086 case X86::BI__builtin_ia32_vcvttss2si64:
3087 case X86::BI__builtin_ia32_vcvttss2usi32:
3088 case X86::BI__builtin_ia32_vcvttss2usi64:
3091 case X86::BI__builtin_ia32_maxpd512:
3092 case X86::BI__builtin_ia32_maxps512:
3093 case X86::BI__builtin_ia32_minpd512:
3094 case X86::BI__builtin_ia32_minps512:
3097 case X86::BI__builtin_ia32_cvtps2pd512_mask:
3098 case X86::BI__builtin_ia32_cvttpd2dq512_mask:
3099 case X86::BI__builtin_ia32_cvttpd2qq512_mask:
3100 case X86::BI__builtin_ia32_cvttpd2udq512_mask:
3101 case X86::BI__builtin_ia32_cvttpd2uqq512_mask:
3102 case X86::BI__builtin_ia32_cvttps2dq512_mask:
3103 case X86::BI__builtin_ia32_cvttps2qq512_mask:
3104 case X86::BI__builtin_ia32_cvttps2udq512_mask:
3105 case X86::BI__builtin_ia32_cvttps2uqq512_mask:
3106 case X86::BI__builtin_ia32_exp2pd_mask:
3107 case X86::BI__builtin_ia32_exp2ps_mask:
3108 case X86::BI__builtin_ia32_getexppd512_mask:
3109 case X86::BI__builtin_ia32_getexpps512_mask:
3110 case X86::BI__builtin_ia32_rcp28pd_mask:
3111 case X86::BI__builtin_ia32_rcp28ps_mask:
3112 case X86::BI__builtin_ia32_rsqrt28pd_mask:
3113 case X86::BI__builtin_ia32_rsqrt28ps_mask:
3114 case X86::BI__builtin_ia32_vcomisd:
3115 case X86::BI__builtin_ia32_vcomiss:
3116 case X86::BI__builtin_ia32_vcvtph2ps512_mask:
3119 case X86::BI__builtin_ia32_cmppd512_mask:
3120 case X86::BI__builtin_ia32_cmpps512_mask:
3121 case X86::BI__builtin_ia32_cmpsd_mask:
3122 case X86::BI__builtin_ia32_cmpss_mask:
3123 case X86::BI__builtin_ia32_cvtss2sd_round_mask:
3124 case X86::BI__builtin_ia32_getexpsd128_round_mask:
3125 case X86::BI__builtin_ia32_getexpss128_round_mask:
3126 case X86::BI__builtin_ia32_maxsd_round_mask:
3127 case X86::BI__builtin_ia32_maxss_round_mask:
3128 case X86::BI__builtin_ia32_minsd_round_mask:
3129 case X86::BI__builtin_ia32_minss_round_mask:
3130 case X86::BI__builtin_ia32_rcp28sd_round_mask:
3131 case X86::BI__builtin_ia32_rcp28ss_round_mask:
3132 case X86::BI__builtin_ia32_reducepd512_mask:
3133 case X86::BI__builtin_ia32_reduceps512_mask:
3134 case X86::BI__builtin_ia32_rndscalepd_mask:
3135 case X86::BI__builtin_ia32_rndscaleps_mask:
3136 case X86::BI__builtin_ia32_rsqrt28sd_round_mask:
3137 case X86::BI__builtin_ia32_rsqrt28ss_round_mask:
3140 case X86::BI__builtin_ia32_fixupimmpd512_mask:
3141 case X86::BI__builtin_ia32_fixupimmpd512_maskz:
3142 case X86::BI__builtin_ia32_fixupimmps512_mask:
3143 case X86::BI__builtin_ia32_fixupimmps512_maskz:
3144 case X86::BI__builtin_ia32_fixupimmsd_mask:
3145 case X86::BI__builtin_ia32_fixupimmsd_maskz:
3146 case X86::BI__builtin_ia32_fixupimmss_mask:
3147 case X86::BI__builtin_ia32_fixupimmss_maskz:
3148 case X86::BI__builtin_ia32_rangepd512_mask:
3149 case X86::BI__builtin_ia32_rangeps512_mask:
3150 case X86::BI__builtin_ia32_rangesd128_round_mask:
3151 case X86::BI__builtin_ia32_rangess128_round_mask:
3152 case X86::BI__builtin_ia32_reducesd_mask:
3153 case X86::BI__builtin_ia32_reducess_mask:
3154 case X86::BI__builtin_ia32_rndscalesd_round_mask:
3155 case X86::BI__builtin_ia32_rndscaless_round_mask:
3158 case X86::BI__builtin_ia32_vcvtsd2si64:
3159 case X86::BI__builtin_ia32_vcvtsd2si32:
3160 case X86::BI__builtin_ia32_vcvtsd2usi32:
3161 case X86::BI__builtin_ia32_vcvtsd2usi64:
3162 case X86::BI__builtin_ia32_vcvtss2si32:
3163 case X86::BI__builtin_ia32_vcvtss2si64:
3164 case X86::BI__builtin_ia32_vcvtss2usi32:
3165 case X86::BI__builtin_ia32_vcvtss2usi64:
3166 case X86::BI__builtin_ia32_sqrtpd512:
3167 case X86::BI__builtin_ia32_sqrtps512:
3171 case X86::BI__builtin_ia32_addpd512:
3172 case X86::BI__builtin_ia32_addps512:
3173 case X86::BI__builtin_ia32_divpd512:
3174 case X86::BI__builtin_ia32_divps512:
3175 case X86::BI__builtin_ia32_mulpd512:
3176 case X86::BI__builtin_ia32_mulps512:
3177 case X86::BI__builtin_ia32_subpd512:
3178 case X86::BI__builtin_ia32_subps512:
3179 case X86::BI__builtin_ia32_cvtsi2sd64:
3180 case X86::BI__builtin_ia32_cvtsi2ss32:
3181 case X86::BI__builtin_ia32_cvtsi2ss64:
3182 case X86::BI__builtin_ia32_cvtusi2sd64:
3183 case X86::BI__builtin_ia32_cvtusi2ss32:
3184 case X86::BI__builtin_ia32_cvtusi2ss64:
3188 case X86::BI__builtin_ia32_cvtdq2ps512_mask:
3189 case X86::BI__builtin_ia32_cvtudq2ps512_mask:
3190 case X86::BI__builtin_ia32_cvtpd2ps512_mask:
3191 case X86::BI__builtin_ia32_cvtpd2qq512_mask:
3192 case X86::BI__builtin_ia32_cvtpd2uqq512_mask:
3193 case X86::BI__builtin_ia32_cvtps2qq512_mask:
3194 case X86::BI__builtin_ia32_cvtps2uqq512_mask:
3195 case X86::BI__builtin_ia32_cvtqq2pd512_mask:
3196 case X86::BI__builtin_ia32_cvtqq2ps512_mask:
3197 case X86::BI__builtin_ia32_cvtuqq2pd512_mask:
3198 case X86::BI__builtin_ia32_cvtuqq2ps512_mask:
3202 case X86::BI__builtin_ia32_addss_round_mask:
3203 case X86::BI__builtin_ia32_addsd_round_mask:
3204 case X86::BI__builtin_ia32_divss_round_mask:
3205 case X86::BI__builtin_ia32_divsd_round_mask:
3206 case X86::BI__builtin_ia32_mulss_round_mask:
3207 case X86::BI__builtin_ia32_mulsd_round_mask:
3208 case X86::BI__builtin_ia32_subss_round_mask:
3209 case X86::BI__builtin_ia32_subsd_round_mask:
3210 case X86::BI__builtin_ia32_scalefpd512_mask:
3211 case X86::BI__builtin_ia32_scalefps512_mask:
3212 case X86::BI__builtin_ia32_scalefsd_round_mask:
3213 case X86::BI__builtin_ia32_scalefss_round_mask:
3214 case X86::BI__builtin_ia32_getmantpd512_mask:
3215 case X86::BI__builtin_ia32_getmantps512_mask:
3216 case X86::BI__builtin_ia32_cvtsd2ss_round_mask:
3217 case X86::BI__builtin_ia32_sqrtsd_round_mask:
3218 case X86::BI__builtin_ia32_sqrtss_round_mask:
3219 case X86::BI__builtin_ia32_vfmaddsd3_mask:
3220 case X86::BI__builtin_ia32_vfmaddsd3_maskz:
3221 case X86::BI__builtin_ia32_vfmaddsd3_mask3:
3222 case X86::BI__builtin_ia32_vfmaddss3_mask:
3223 case X86::BI__builtin_ia32_vfmaddss3_maskz:
3224 case X86::BI__builtin_ia32_vfmaddss3_mask3:
3225 case X86::BI__builtin_ia32_vfmaddpd512_mask:
3226 case X86::BI__builtin_ia32_vfmaddpd512_maskz:
3227 case X86::BI__builtin_ia32_vfmaddpd512_mask3:
3228 case X86::BI__builtin_ia32_vfmsubpd512_mask3:
3229 case X86::BI__builtin_ia32_vfmaddps512_mask:
3230 case X86::BI__builtin_ia32_vfmaddps512_maskz:
3231 case X86::BI__builtin_ia32_vfmaddps512_mask3:
3232 case X86::BI__builtin_ia32_vfmsubps512_mask3:
3233 case X86::BI__builtin_ia32_vfmaddsubpd512_mask:
3234 case X86::BI__builtin_ia32_vfmaddsubpd512_maskz:
3235 case X86::BI__builtin_ia32_vfmaddsubpd512_mask3:
3236 case X86::BI__builtin_ia32_vfmsubaddpd512_mask3:
3237 case X86::BI__builtin_ia32_vfmaddsubps512_mask:
3238 case X86::BI__builtin_ia32_vfmaddsubps512_maskz:
3239 case X86::BI__builtin_ia32_vfmaddsubps512_mask3:
3240 case X86::BI__builtin_ia32_vfmsubaddps512_mask3:
3244 case X86::BI__builtin_ia32_getmantsd_round_mask:
3245 case X86::BI__builtin_ia32_getmantss_round_mask:
3251 llvm::APSInt Result;
3259 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
3267 (HasRC && Result.getZExtValue() >= 8 && Result.getZExtValue() <= 11))
3270 return Diag(TheCall->
getLocStart(), diag::err_x86_builtin_invalid_rounding)
3275 bool Sema::CheckX86BuiltinGatherScatterScale(
unsigned BuiltinID,
3277 unsigned ArgNum = 0;
3278 switch (BuiltinID) {
3281 case X86::BI__builtin_ia32_gatherpfdpd:
3282 case X86::BI__builtin_ia32_gatherpfdps:
3283 case X86::BI__builtin_ia32_gatherpfqpd:
3284 case X86::BI__builtin_ia32_gatherpfqps:
3285 case X86::BI__builtin_ia32_scatterpfdpd:
3286 case X86::BI__builtin_ia32_scatterpfdps:
3287 case X86::BI__builtin_ia32_scatterpfqpd:
3288 case X86::BI__builtin_ia32_scatterpfqps:
3291 case X86::BI__builtin_ia32_gatherd_pd:
3292 case X86::BI__builtin_ia32_gatherd_pd256:
3293 case X86::BI__builtin_ia32_gatherq_pd:
3294 case X86::BI__builtin_ia32_gatherq_pd256:
3295 case X86::BI__builtin_ia32_gatherd_ps:
3296 case X86::BI__builtin_ia32_gatherd_ps256:
3297 case X86::BI__builtin_ia32_gatherq_ps:
3298 case X86::BI__builtin_ia32_gatherq_ps256:
3299 case X86::BI__builtin_ia32_gatherd_q:
3300 case X86::BI__builtin_ia32_gatherd_q256:
3301 case X86::BI__builtin_ia32_gatherq_q:
3302 case X86::BI__builtin_ia32_gatherq_q256:
3303 case X86::BI__builtin_ia32_gatherd_d:
3304 case X86::BI__builtin_ia32_gatherd_d256:
3305 case X86::BI__builtin_ia32_gatherq_d:
3306 case X86::BI__builtin_ia32_gatherq_d256:
3307 case X86::BI__builtin_ia32_gather3div2df:
3308 case X86::BI__builtin_ia32_gather3div2di:
3309 case X86::BI__builtin_ia32_gather3div4df:
3310 case X86::BI__builtin_ia32_gather3div4di:
3311 case X86::BI__builtin_ia32_gather3div4sf:
3312 case X86::BI__builtin_ia32_gather3div4si:
3313 case X86::BI__builtin_ia32_gather3div8sf:
3314 case X86::BI__builtin_ia32_gather3div8si:
3315 case X86::BI__builtin_ia32_gather3siv2df:
3316 case X86::BI__builtin_ia32_gather3siv2di:
3317 case X86::BI__builtin_ia32_gather3siv4df:
3318 case X86::BI__builtin_ia32_gather3siv4di:
3319 case X86::BI__builtin_ia32_gather3siv4sf:
3320 case X86::BI__builtin_ia32_gather3siv4si:
3321 case X86::BI__builtin_ia32_gather3siv8sf:
3322 case X86::BI__builtin_ia32_gather3siv8si:
3323 case X86::BI__builtin_ia32_gathersiv8df:
3324 case X86::BI__builtin_ia32_gathersiv16sf:
3325 case X86::BI__builtin_ia32_gatherdiv8df:
3326 case X86::BI__builtin_ia32_gatherdiv16sf:
3327 case X86::BI__builtin_ia32_gathersiv8di:
3328 case X86::BI__builtin_ia32_gathersiv16si:
3329 case X86::BI__builtin_ia32_gatherdiv8di:
3330 case X86::BI__builtin_ia32_gatherdiv16si:
3331 case X86::BI__builtin_ia32_scatterdiv2df:
3332 case X86::BI__builtin_ia32_scatterdiv2di:
3333 case X86::BI__builtin_ia32_scatterdiv4df:
3334 case X86::BI__builtin_ia32_scatterdiv4di:
3335 case X86::BI__builtin_ia32_scatterdiv4sf:
3336 case X86::BI__builtin_ia32_scatterdiv4si:
3337 case X86::BI__builtin_ia32_scatterdiv8sf:
3338 case X86::BI__builtin_ia32_scatterdiv8si:
3339 case X86::BI__builtin_ia32_scattersiv2df:
3340 case X86::BI__builtin_ia32_scattersiv2di:
3341 case X86::BI__builtin_ia32_scattersiv4df:
3342 case X86::BI__builtin_ia32_scattersiv4di:
3343 case X86::BI__builtin_ia32_scattersiv4sf:
3344 case X86::BI__builtin_ia32_scattersiv4si:
3345 case X86::BI__builtin_ia32_scattersiv8sf:
3346 case X86::BI__builtin_ia32_scattersiv8si:
3347 case X86::BI__builtin_ia32_scattersiv8df:
3348 case X86::BI__builtin_ia32_scattersiv16sf:
3349 case X86::BI__builtin_ia32_scatterdiv8df:
3350 case X86::BI__builtin_ia32_scatterdiv16sf:
3351 case X86::BI__builtin_ia32_scattersiv8di:
3352 case X86::BI__builtin_ia32_scattersiv16si:
3353 case X86::BI__builtin_ia32_scatterdiv8di:
3354 case X86::BI__builtin_ia32_scatterdiv16si:
3359 llvm::APSInt Result;
3367 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
3370 if (Result == 1 || Result == 2 || Result == 4 || Result == 8)
3373 return Diag(TheCall->
getLocStart(), diag::err_x86_builtin_invalid_scale)
3379 switch (BuiltinID) {
3380 case X86::BI__builtin_ia32_readeflags_u32:
3381 case X86::BI__builtin_ia32_writeeflags_u32:
3388 bool Sema::CheckX86BuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
3389 if (BuiltinID == X86::BI__builtin_cpu_supports)
3392 if (BuiltinID == X86::BI__builtin_cpu_is)
3399 diag::err_32_bit_builtin_64_bit_tgt);
3402 if (CheckX86BuiltinRoundingOrSAE(BuiltinID, TheCall))
3406 if (CheckX86BuiltinGatherScatterScale(BuiltinID, TheCall))
3411 int i = 0, l = 0, u = 0;
3412 switch (BuiltinID) {
3415 case X86::BI__builtin_ia32_vec_ext_v2si:
3416 case X86::BI__builtin_ia32_vec_ext_v2di:
3417 case X86::BI__builtin_ia32_vextractf128_pd256:
3418 case X86::BI__builtin_ia32_vextractf128_ps256:
3419 case X86::BI__builtin_ia32_vextractf128_si256:
3420 case X86::BI__builtin_ia32_extract128i256:
3421 case X86::BI__builtin_ia32_extractf64x4_mask:
3422 case X86::BI__builtin_ia32_extracti64x4_mask:
3423 case X86::BI__builtin_ia32_extractf32x8_mask:
3424 case X86::BI__builtin_ia32_extracti32x8_mask:
3425 case X86::BI__builtin_ia32_extractf64x2_256_mask:
3426 case X86::BI__builtin_ia32_extracti64x2_256_mask:
3427 case X86::BI__builtin_ia32_extractf32x4_256_mask:
3428 case X86::BI__builtin_ia32_extracti32x4_256_mask:
3429 i = 1; l = 0; u = 1;
3431 case X86::BI__builtin_ia32_vec_set_v2di:
3432 case X86::BI__builtin_ia32_vinsertf128_pd256:
3433 case X86::BI__builtin_ia32_vinsertf128_ps256:
3434 case X86::BI__builtin_ia32_vinsertf128_si256:
3435 case X86::BI__builtin_ia32_insert128i256:
3436 case X86::BI__builtin_ia32_insertf32x8:
3437 case X86::BI__builtin_ia32_inserti32x8:
3438 case X86::BI__builtin_ia32_insertf64x4:
3439 case X86::BI__builtin_ia32_inserti64x4:
3440 case X86::BI__builtin_ia32_insertf64x2_256:
3441 case X86::BI__builtin_ia32_inserti64x2_256:
3442 case X86::BI__builtin_ia32_insertf32x4_256:
3443 case X86::BI__builtin_ia32_inserti32x4_256:
3444 i = 2; l = 0; u = 1;
3446 case X86::BI__builtin_ia32_vpermilpd:
3447 case X86::BI__builtin_ia32_vec_ext_v4hi:
3448 case X86::BI__builtin_ia32_vec_ext_v4si:
3449 case X86::BI__builtin_ia32_vec_ext_v4sf:
3450 case X86::BI__builtin_ia32_vec_ext_v4di:
3451 case X86::BI__builtin_ia32_extractf32x4_mask:
3452 case X86::BI__builtin_ia32_extracti32x4_mask:
3453 case X86::BI__builtin_ia32_extractf64x2_512_mask:
3454 case X86::BI__builtin_ia32_extracti64x2_512_mask:
3455 i = 1; l = 0; u = 3;
3457 case X86::BI_mm_prefetch:
3458 case X86::BI__builtin_ia32_vec_ext_v8hi:
3459 case X86::BI__builtin_ia32_vec_ext_v8si:
3460 i = 1; l = 0; u = 7;
3462 case X86::BI__builtin_ia32_sha1rnds4:
3463 case X86::BI__builtin_ia32_blendpd:
3464 case X86::BI__builtin_ia32_shufpd:
3465 case X86::BI__builtin_ia32_vec_set_v4hi:
3466 case X86::BI__builtin_ia32_vec_set_v4si:
3467 case X86::BI__builtin_ia32_vec_set_v4di:
3468 case X86::BI__builtin_ia32_shuf_f32x4_256:
3469 case X86::BI__builtin_ia32_shuf_f64x2_256:
3470 case X86::BI__builtin_ia32_shuf_i32x4_256:
3471 case X86::BI__builtin_ia32_shuf_i64x2_256:
3472 case X86::BI__builtin_ia32_insertf64x2_512:
3473 case X86::BI__builtin_ia32_inserti64x2_512:
3474 case X86::BI__builtin_ia32_insertf32x4:
3475 case X86::BI__builtin_ia32_inserti32x4:
3476 i = 2; l = 0; u = 3;
3478 case X86::BI__builtin_ia32_vpermil2pd:
3479 case X86::BI__builtin_ia32_vpermil2pd256:
3480 case X86::BI__builtin_ia32_vpermil2ps:
3481 case X86::BI__builtin_ia32_vpermil2ps256:
3482 i = 3; l = 0; u = 3;
3484 case X86::BI__builtin_ia32_cmpb128_mask:
3485 case X86::BI__builtin_ia32_cmpw128_mask:
3486 case X86::BI__builtin_ia32_cmpd128_mask:
3487 case X86::BI__builtin_ia32_cmpq128_mask:
3488 case X86::BI__builtin_ia32_cmpb256_mask:
3489 case X86::BI__builtin_ia32_cmpw256_mask:
3490 case X86::BI__builtin_ia32_cmpd256_mask:
3491 case X86::BI__builtin_ia32_cmpq256_mask:
3492 case X86::BI__builtin_ia32_cmpb512_mask:
3493 case X86::BI__builtin_ia32_cmpw512_mask:
3494 case X86::BI__builtin_ia32_cmpd512_mask:
3495 case X86::BI__builtin_ia32_cmpq512_mask:
3496 case X86::BI__builtin_ia32_ucmpb128_mask:
3497 case X86::BI__builtin_ia32_ucmpw128_mask:
3498 case X86::BI__builtin_ia32_ucmpd128_mask:
3499 case X86::BI__builtin_ia32_ucmpq128_mask:
3500 case X86::BI__builtin_ia32_ucmpb256_mask:
3501 case X86::BI__builtin_ia32_ucmpw256_mask:
3502 case X86::BI__builtin_ia32_ucmpd256_mask:
3503 case X86::BI__builtin_ia32_ucmpq256_mask:
3504 case X86::BI__builtin_ia32_ucmpb512_mask:
3505 case X86::BI__builtin_ia32_ucmpw512_mask:
3506 case X86::BI__builtin_ia32_ucmpd512_mask:
3507 case X86::BI__builtin_ia32_ucmpq512_mask:
3508 case X86::BI__builtin_ia32_vpcomub:
3509 case X86::BI__builtin_ia32_vpcomuw:
3510 case X86::BI__builtin_ia32_vpcomud:
3511 case X86::BI__builtin_ia32_vpcomuq:
3512 case X86::BI__builtin_ia32_vpcomb:
3513 case X86::BI__builtin_ia32_vpcomw:
3514 case X86::BI__builtin_ia32_vpcomd:
3515 case X86::BI__builtin_ia32_vpcomq:
3516 case X86::BI__builtin_ia32_vec_set_v8hi:
3517 case X86::BI__builtin_ia32_vec_set_v8si:
3518 i = 2; l = 0; u = 7;
3520 case X86::BI__builtin_ia32_vpermilpd256:
3521 case X86::BI__builtin_ia32_roundps:
3522 case X86::BI__builtin_ia32_roundpd:
3523 case X86::BI__builtin_ia32_roundps256:
3524 case X86::BI__builtin_ia32_roundpd256:
3525 case X86::BI__builtin_ia32_getmantpd128_mask:
3526 case X86::BI__builtin_ia32_getmantpd256_mask:
3527 case X86::BI__builtin_ia32_getmantps128_mask:
3528 case X86::BI__builtin_ia32_getmantps256_mask:
3529 case X86::BI__builtin_ia32_getmantpd512_mask:
3530 case X86::BI__builtin_ia32_getmantps512_mask:
3531 case X86::BI__builtin_ia32_vec_ext_v16qi:
3532 case X86::BI__builtin_ia32_vec_ext_v16hi:
3533 i = 1; l = 0; u = 15;
3535 case X86::BI__builtin_ia32_pblendd128:
3536 case X86::BI__builtin_ia32_blendps:
3537 case X86::BI__builtin_ia32_blendpd256:
3538 case X86::BI__builtin_ia32_shufpd256:
3539 case X86::BI__builtin_ia32_roundss:
3540 case X86::BI__builtin_ia32_roundsd:
3541 case X86::BI__builtin_ia32_rangepd128_mask:
3542 case X86::BI__builtin_ia32_rangepd256_mask:
3543 case X86::BI__builtin_ia32_rangepd512_mask:
3544 case X86::BI__builtin_ia32_rangeps128_mask:
3545 case X86::BI__builtin_ia32_rangeps256_mask:
3546 case X86::BI__builtin_ia32_rangeps512_mask:
3547 case X86::BI__builtin_ia32_getmantsd_round_mask:
3548 case X86::BI__builtin_ia32_getmantss_round_mask:
3549 case X86::BI__builtin_ia32_vec_set_v16qi:
3550 case X86::BI__builtin_ia32_vec_set_v16hi:
3551 i = 2; l = 0; u = 15;
3553 case X86::BI__builtin_ia32_vec_ext_v32qi:
3554 i = 1; l = 0; u = 31;
3556 case X86::BI__builtin_ia32_cmpps:
3557 case X86::BI__builtin_ia32_cmpss:
3558 case X86::BI__builtin_ia32_cmppd:
3559 case X86::BI__builtin_ia32_cmpsd:
3560 case X86::BI__builtin_ia32_cmpps256:
3561 case X86::BI__builtin_ia32_cmppd256:
3562 case X86::BI__builtin_ia32_cmpps128_mask:
3563 case X86::BI__builtin_ia32_cmppd128_mask:
3564 case X86::BI__builtin_ia32_cmpps256_mask:
3565 case X86::BI__builtin_ia32_cmppd256_mask:
3566 case X86::BI__builtin_ia32_cmpps512_mask:
3567 case X86::BI__builtin_ia32_cmppd512_mask:
3568 case X86::BI__builtin_ia32_cmpsd_mask:
3569 case X86::BI__builtin_ia32_cmpss_mask:
3570 case X86::BI__builtin_ia32_vec_set_v32qi:
3571 i = 2; l = 0; u = 31;
3573 case X86::BI__builtin_ia32_permdf256:
3574 case X86::BI__builtin_ia32_permdi256:
3575 case X86::BI__builtin_ia32_permdf512:
3576 case X86::BI__builtin_ia32_permdi512:
3577 case X86::BI__builtin_ia32_vpermilps:
3578 case X86::BI__builtin_ia32_vpermilps256:
3579 case X86::BI__builtin_ia32_vpermilpd512:
3580 case X86::BI__builtin_ia32_vpermilps512:
3581 case X86::BI__builtin_ia32_pshufd:
3582 case X86::BI__builtin_ia32_pshufd256:
3583 case X86::BI__builtin_ia32_pshufd512:
3584 case X86::BI__builtin_ia32_pshufhw:
3585 case X86::BI__builtin_ia32_pshufhw256:
3586 case X86::BI__builtin_ia32_pshufhw512:
3587 case X86::BI__builtin_ia32_pshuflw:
3588 case X86::BI__builtin_ia32_pshuflw256:
3589 case X86::BI__builtin_ia32_pshuflw512:
3590 case X86::BI__builtin_ia32_vcvtps2ph:
3591 case X86::BI__builtin_ia32_vcvtps2ph_mask:
3592 case X86::BI__builtin_ia32_vcvtps2ph256:
3593 case X86::BI__builtin_ia32_vcvtps2ph256_mask:
3594 case X86::BI__builtin_ia32_vcvtps2ph512_mask:
3595 case X86::BI__builtin_ia32_rndscaleps_128_mask:
3596 case X86::BI__builtin_ia32_rndscalepd_128_mask:
3597 case X86::BI__builtin_ia32_rndscaleps_256_mask:
3598 case X86::BI__builtin_ia32_rndscalepd_256_mask:
3599 case X86::BI__builtin_ia32_rndscaleps_mask:
3600 case X86::BI__builtin_ia32_rndscalepd_mask:
3601 case X86::BI__builtin_ia32_reducepd128_mask:
3602 case X86::BI__builtin_ia32_reducepd256_mask:
3603 case X86::BI__builtin_ia32_reducepd512_mask:
3604 case X86::BI__builtin_ia32_reduceps128_mask:
3605 case X86::BI__builtin_ia32_reduceps256_mask:
3606 case X86::BI__builtin_ia32_reduceps512_mask:
3607 case X86::BI__builtin_ia32_prold512:
3608 case X86::BI__builtin_ia32_prolq512:
3609 case X86::BI__builtin_ia32_prold128:
3610 case X86::BI__builtin_ia32_prold256:
3611 case X86::BI__builtin_ia32_prolq128:
3612 case X86::BI__builtin_ia32_prolq256:
3613 case X86::BI__builtin_ia32_prord512:
3614 case X86::BI__builtin_ia32_prorq512:
3615 case X86::BI__builtin_ia32_prord128:
3616 case X86::BI__builtin_ia32_prord256:
3617 case X86::BI__builtin_ia32_prorq128:
3618 case X86::BI__builtin_ia32_prorq256:
3619 case X86::BI__builtin_ia32_fpclasspd128_mask:
3620 case X86::BI__builtin_ia32_fpclasspd256_mask:
3621 case X86::BI__builtin_ia32_fpclassps128_mask:
3622 case X86::BI__builtin_ia32_fpclassps256_mask:
3623 case X86::BI__builtin_ia32_fpclassps512_mask:
3624 case X86::BI__builtin_ia32_fpclasspd512_mask:
3625 case X86::BI__builtin_ia32_fpclasssd_mask:
3626 case X86::BI__builtin_ia32_fpclassss_mask:
3627 case X86::BI__builtin_ia32_pslldqi128_byteshift:
3628 case X86::BI__builtin_ia32_pslldqi256_byteshift:
3629 case X86::BI__builtin_ia32_pslldqi512_byteshift:
3630 case X86::BI__builtin_ia32_psrldqi128_byteshift:
3631 case X86::BI__builtin_ia32_psrldqi256_byteshift:
3632 case X86::BI__builtin_ia32_psrldqi512_byteshift:
3633 i = 1; l = 0; u = 255;
3635 case X86::BI__builtin_ia32_vperm2f128_pd256:
3636 case X86::BI__builtin_ia32_vperm2f128_ps256:
3637 case X86::BI__builtin_ia32_vperm2f128_si256:
3638 case X86::BI__builtin_ia32_permti256:
3639 case X86::BI__builtin_ia32_pblendw128:
3640 case X86::BI__builtin_ia32_pblendw256:
3641 case X86::BI__builtin_ia32_blendps256:
3642 case X86::BI__builtin_ia32_pblendd256:
3643 case X86::BI__builtin_ia32_palignr128:
3644 case X86::BI__builtin_ia32_palignr256:
3645 case X86::BI__builtin_ia32_palignr512:
3646 case X86::BI__builtin_ia32_alignq512:
3647 case X86::BI__builtin_ia32_alignd512:
3648 case X86::BI__builtin_ia32_alignd128:
3649 case X86::BI__builtin_ia32_alignd256:
3650 case X86::BI__builtin_ia32_alignq128:
3651 case X86::BI__builtin_ia32_alignq256:
3652 case X86::BI__builtin_ia32_vcomisd:
3653 case X86::BI__builtin_ia32_vcomiss:
3654 case X86::BI__builtin_ia32_shuf_f32x4:
3655 case X86::BI__builtin_ia32_shuf_f64x2:
3656 case X86::BI__builtin_ia32_shuf_i32x4:
3657 case X86::BI__builtin_ia32_shuf_i64x2:
3658 case X86::BI__builtin_ia32_shufpd512:
3659 case X86::BI__builtin_ia32_shufps:
3660 case X86::BI__builtin_ia32_shufps256:
3661 case X86::BI__builtin_ia32_shufps512:
3662 case X86::BI__builtin_ia32_dbpsadbw128:
3663 case X86::BI__builtin_ia32_dbpsadbw256:
3664 case X86::BI__builtin_ia32_dbpsadbw512:
3665 case X86::BI__builtin_ia32_vpshldd128:
3666 case X86::BI__builtin_ia32_vpshldd256:
3667 case X86::BI__builtin_ia32_vpshldd512:
3668 case X86::BI__builtin_ia32_vpshldq128:
3669 case X86::BI__builtin_ia32_vpshldq256:
3670 case X86::BI__builtin_ia32_vpshldq512:
3671 case X86::BI__builtin_ia32_vpshldw128:
3672 case X86::BI__builtin_ia32_vpshldw256:
3673 case X86::BI__builtin_ia32_vpshldw512:
3674 case X86::BI__builtin_ia32_vpshrdd128:
3675 case X86::BI__builtin_ia32_vpshrdd256:
3676 case X86::BI__builtin_ia32_vpshrdd512:
3677 case X86::BI__builtin_ia32_vpshrdq128:
3678 case X86::BI__builtin_ia32_vpshrdq256:
3679 case X86::BI__builtin_ia32_vpshrdq512:
3680 case X86::BI__builtin_ia32_vpshrdw128:
3681 case X86::BI__builtin_ia32_vpshrdw256:
3682 case X86::BI__builtin_ia32_vpshrdw512:
3683 i = 2; l = 0; u = 255;
3685 case X86::BI__builtin_ia32_fixupimmpd512_mask:
3686 case X86::BI__builtin_ia32_fixupimmpd512_maskz:
3687 case X86::BI__builtin_ia32_fixupimmps512_mask:
3688 case X86::BI__builtin_ia32_fixupimmps512_maskz:
3689 case X86::BI__builtin_ia32_fixupimmsd_mask:
3690 case X86::BI__builtin_ia32_fixupimmsd_maskz:
3691 case X86::BI__builtin_ia32_fixupimmss_mask:
3692 case X86::BI__builtin_ia32_fixupimmss_maskz:
3693 case X86::BI__builtin_ia32_fixupimmpd128_mask:
3694 case X86::BI__builtin_ia32_fixupimmpd128_maskz:
3695 case X86::BI__builtin_ia32_fixupimmpd256_mask:
3696 case X86::BI__builtin_ia32_fixupimmpd256_maskz:
3697 case X86::BI__builtin_ia32_fixupimmps128_mask:
3698 case X86::BI__builtin_ia32_fixupimmps128_maskz:
3699 case X86::BI__builtin_ia32_fixupimmps256_mask:
3700 case X86::BI__builtin_ia32_fixupimmps256_maskz:
3701 case X86::BI__builtin_ia32_pternlogd512_mask:
3702 case X86::BI__builtin_ia32_pternlogd512_maskz:
3703 case X86::BI__builtin_ia32_pternlogq512_mask:
3704 case X86::BI__builtin_ia32_pternlogq512_maskz:
3705 case X86::BI__builtin_ia32_pternlogd128_mask:
3706 case X86::BI__builtin_ia32_pternlogd128_maskz:
3707 case X86::BI__builtin_ia32_pternlogd256_mask:
3708 case X86::BI__builtin_ia32_pternlogd256_maskz:
3709 case X86::BI__builtin_ia32_pternlogq128_mask:
3710 case X86::BI__builtin_ia32_pternlogq128_maskz:
3711 case X86::BI__builtin_ia32_pternlogq256_mask:
3712 case X86::BI__builtin_ia32_pternlogq256_maskz:
3713 i = 3; l = 0; u = 255;
3715 case X86::BI__builtin_ia32_gatherpfdpd:
3716 case X86::BI__builtin_ia32_gatherpfdps:
3717 case X86::BI__builtin_ia32_gatherpfqpd:
3718 case X86::BI__builtin_ia32_gatherpfqps:
3719 case X86::BI__builtin_ia32_scatterpfdpd:
3720 case X86::BI__builtin_ia32_scatterpfdps:
3721 case X86::BI__builtin_ia32_scatterpfqpd:
3722 case X86::BI__builtin_ia32_scatterpfqps:
3723 i = 4; l = 2; u = 3;
3725 case X86::BI__builtin_ia32_rndscalesd_round_mask:
3726 case X86::BI__builtin_ia32_rndscaless_round_mask:
3727 i = 4; l = 0; u = 255;
3735 return SemaBuiltinConstantArgRange(TheCall, i, l, u,
false);
3742 bool Sema::getFormatStringInfo(
const FormatAttr *Format,
bool IsCXXMember,
3743 FormatStringInfo *FSI) {
3744 FSI->HasVAListArg = Format->getFirstArg() == 0;
3745 FSI->FormatIdx = Format->getFormatIdx() - 1;
3746 FSI->FirstDataArg = FSI->HasVAListArg ? 0 : Format->getFirstArg() - 1;
3752 if(FSI->FormatIdx == 0)
3755 if (FSI->FirstDataArg != 0)
3756 --FSI->FirstDataArg;
3766 if (
auto nullability
3775 if (UT->getDecl()->hasAttr<TransparentUnionAttr>())
3777 dyn_cast<CompoundLiteralExpr>(Expr))
3779 dyn_cast<InitListExpr>(CLE->getInitializer()))
3780 Expr = ILE->getInit(0);
3790 const Expr *ArgExpr,
3798 FormatStringInfo FSI;
3799 if ((GetFormatStringType(Format) == FST_NSString) &&
3800 getFormatStringInfo(Format,
false, &FSI)) {
3801 Idx = FSI.FormatIdx;
3815 bool Format =
false;
3828 if (!Format || NumArgs <= Idx)
3830 const Expr *FormatExpr = Args[Idx];
3831 if (
const CStyleCastExpr *CSCE = dyn_cast<CStyleCastExpr>(FormatExpr))
3832 FormatExpr = CSCE->getSubExpr();
3842 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
3860 ArrayRef<const Expr *> Args,
3862 assert((FDecl || Proto) &&
"Need a function declaration or prototype");
3865 llvm::SmallBitVector NonNullArgs;
3871 for (
const auto *Arg : Args)
3878 unsigned IdxAST = Idx.getASTIndex();
3879 if (IdxAST >= Args.size())
3881 if (NonNullArgs.empty())
3882 NonNullArgs.resize(Args.size());
3883 NonNullArgs.set(IdxAST);
3888 if (FDecl && (isa<FunctionDecl>(FDecl) || isa<ObjCMethodDecl>(FDecl))) {
3891 ArrayRef<ParmVarDecl*> parms;
3892 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(FDecl))
3893 parms = FD->parameters();
3895 parms = cast<ObjCMethodDecl>(FDecl)->parameters();
3897 unsigned ParamIndex = 0;
3898 for (ArrayRef<ParmVarDecl*>::iterator I = parms.begin(), E = parms.end();
3899 I != E; ++I, ++ParamIndex) {
3901 if (PVD->
hasAttr<NonNullAttr>() ||
3903 if (NonNullArgs.empty())
3904 NonNullArgs.resize(Args.size());
3906 NonNullArgs.set(ParamIndex);
3913 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(FDecl)) {
3932 if (NonNullArgs.empty())
3933 NonNullArgs.resize(Args.size());
3935 NonNullArgs.set(Index);
3944 for (
unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
3945 ArgIndex != ArgIndexEnd; ++ArgIndex) {
3946 if (NonNullArgs[ArgIndex])
3955 const Expr *ThisArg, ArrayRef<const Expr *> Args,
3959 if (CurContext->isDependentContext())
3963 llvm::SmallBitVector CheckedVarArgs;
3967 CheckedVarArgs.resize(Args.size());
3969 CheckFormatArguments(I, Args, IsMemberFunction, CallType, Loc, Range,
3976 auto *FD = dyn_cast_or_null<FunctionDecl>(FDecl);
3977 if (CallType != VariadicDoesNotApply &&
3978 (!FD || FD->getBuiltinID() != Builtin::BI__noop)) {
3980 : FDecl && isa<FunctionDecl>(FDecl)
3981 ? cast<FunctionDecl>(FDecl)->getNumParams()
3982 : FDecl && isa<ObjCMethodDecl>(FDecl)
3983 ? cast<ObjCMethodDecl>(FDecl)->param_size()
3986 for (
unsigned ArgIdx = NumParams; ArgIdx < Args.size(); ++ArgIdx) {
3988 if (
const Expr *Arg = Args[ArgIdx]) {
3989 if (CheckedVarArgs.empty() || !CheckedVarArgs[ArgIdx])
3990 checkVariadicArgument(Arg, CallType);
3995 if (FDecl || Proto) {
4000 for (
const auto *I : FDecl->
specific_attrs<ArgumentWithTypeTagAttr>())
4001 CheckArgumentWithTypeTag(I, Args, Loc);
4006 diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc);
4012 ArrayRef<const Expr *> Args,
4015 VariadicCallType CallType =
4016 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
4017 checkCall(FDecl, Proto,
nullptr, Args,
true,
4025 bool IsMemberOperatorCall = isa<CXXOperatorCallExpr>(TheCall) &&
4026 isa<CXXMethodDecl>(FDecl);
4027 bool IsMemberFunction = isa<CXXMemberCallExpr>(TheCall) ||
4028 IsMemberOperatorCall;
4029 VariadicCallType CallType = getVariadicCallType(FDecl, Proto,
4034 Expr *ImplicitThis =
nullptr;
4035 if (IsMemberOperatorCall) {
4039 ImplicitThis = Args[0];
4042 }
else if (IsMemberFunction)
4044 cast<CXXMemberCallExpr>(TheCall)->getImplicitObjectArgument();
4046 checkCall(FDecl, Proto, ImplicitThis, llvm::makeArrayRef(Args, NumArgs),
4056 CheckAbsoluteValueFunction(TheCall, FDecl);
4057 CheckMaxUnsignedZero(TheCall, FDecl);
4059 if (getLangOpts().ObjC1)
4067 if (CMId == Builtin::BIstrlcpy || CMId == Builtin::BIstrlcat)
4068 CheckStrlcpycatArguments(TheCall, FnInfo);
4069 else if (CMId == Builtin::BIstrncat)
4070 CheckStrncatArguments(TheCall, FnInfo);
4072 CheckMemaccessArguments(TheCall, CMId, FnInfo);
4078 ArrayRef<const Expr *> Args) {
4079 VariadicCallType CallType =
4080 Method->
isVariadic() ? VariadicMethod : VariadicDoesNotApply;
4082 checkCall(Method,
nullptr,
nullptr, Args,
4092 if (
const auto *V = dyn_cast<VarDecl>(NDecl))
4093 Ty = V->getType().getNonReferenceType();
4094 else if (
const auto *F = dyn_cast<FieldDecl>(NDecl))
4095 Ty = F->getType().getNonReferenceType();
4103 VariadicCallType CallType;
4105 CallType = VariadicDoesNotApply;
4107 CallType = VariadicBlock;
4109 CallType = VariadicFunction;
4112 checkCall(NDecl, Proto,
nullptr,
4123 VariadicCallType CallType = getVariadicCallType(
nullptr, Proto,
4125 checkCall(
nullptr, Proto,
nullptr,
4134 if (!llvm::isValidAtomicOrderingCABI(Ordering))
4137 auto OrderingCABI = (llvm::AtomicOrderingCABI)Ordering;
4139 case AtomicExpr::AO__c11_atomic_init:
4140 case AtomicExpr::AO__opencl_atomic_init:
4141 llvm_unreachable(
"There is no ordering argument for an init");
4143 case AtomicExpr::AO__c11_atomic_load:
4144 case AtomicExpr::AO__opencl_atomic_load:
4145 case AtomicExpr::AO__atomic_load_n:
4146 case AtomicExpr::AO__atomic_load:
4147 return OrderingCABI != llvm::AtomicOrderingCABI::release &&
4148 OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
4150 case AtomicExpr::AO__c11_atomic_store:
4151 case AtomicExpr::AO__opencl_atomic_store:
4152 case AtomicExpr::AO__atomic_store:
4153 case AtomicExpr::AO__atomic_store_n:
4154 return OrderingCABI != llvm::AtomicOrderingCABI::consume &&
4155 OrderingCABI != llvm::AtomicOrderingCABI::acquire &&
4156 OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
4165 CallExpr *TheCall = cast<CallExpr>(TheCallResult.
get());
4200 const unsigned NumForm = GNUCmpXchg + 1;
4201 const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 3, 4, 5, 6 };
4202 const unsigned NumVals[] = { 1, 0, 1, 1, 1, 1, 2, 2, 3 };
4210 static_assert(
sizeof(NumArgs)/
sizeof(NumArgs[0]) == NumForm
4211 &&
sizeof(NumVals)/
sizeof(NumVals[0]) == NumForm,
4212 "need to update code for modified forms");
4213 static_assert(AtomicExpr::AO__c11_atomic_init == 0 &&
4214 AtomicExpr::AO__c11_atomic_fetch_xor + 1 ==
4215 AtomicExpr::AO__atomic_load,
4216 "need to update code for modified C11 atomics");
4217 bool IsOpenCL = Op >= AtomicExpr::AO__opencl_atomic_init &&
4218 Op <= AtomicExpr::AO__opencl_atomic_fetch_max;
4219 bool IsC11 = (Op >= AtomicExpr::AO__c11_atomic_init &&
4220 Op <= AtomicExpr::AO__c11_atomic_fetch_xor) ||
4222 bool IsN = Op == AtomicExpr::AO__atomic_load_n ||
4223 Op == AtomicExpr::AO__atomic_store_n ||
4224 Op == AtomicExpr::AO__atomic_exchange_n ||
4225 Op == AtomicExpr::AO__atomic_compare_exchange_n;
4226 bool IsAddSub =
false;
4227 bool IsMinMax =
false;
4230 case AtomicExpr::AO__c11_atomic_init:
4231 case AtomicExpr::AO__opencl_atomic_init:
4235 case AtomicExpr::AO__c11_atomic_load:
4236 case AtomicExpr::AO__opencl_atomic_load:
4237 case AtomicExpr::AO__atomic_load_n:
4241 case AtomicExpr::AO__atomic_load:
4245 case AtomicExpr::AO__c11_atomic_store:
4246 case AtomicExpr::AO__opencl_atomic_store:
4247 case AtomicExpr::AO__atomic_store:
4248 case AtomicExpr::AO__atomic_store_n:
4252 case AtomicExpr::AO__c11_atomic_fetch_add:
4253 case AtomicExpr::AO__c11_atomic_fetch_sub:
4254 case AtomicExpr::AO__opencl_atomic_fetch_add:
4255 case AtomicExpr::AO__opencl_atomic_fetch_sub:
4256 case AtomicExpr::AO__opencl_atomic_fetch_min:
4257 case AtomicExpr::AO__opencl_atomic_fetch_max:
4258 case AtomicExpr::AO__atomic_fetch_add:
4259 case AtomicExpr::AO__atomic_fetch_sub:
4260 case AtomicExpr::AO__atomic_add_fetch:
4261 case AtomicExpr::AO__atomic_sub_fetch:
4264 case AtomicExpr::AO__c11_atomic_fetch_and:
4265 case AtomicExpr::AO__c11_atomic_fetch_or:
4266 case AtomicExpr::AO__c11_atomic_fetch_xor:
4267 case AtomicExpr::AO__opencl_atomic_fetch_and:
4268 case AtomicExpr::AO__opencl_atomic_fetch_or:
4269 case AtomicExpr::AO__opencl_atomic_fetch_xor:
4270 case AtomicExpr::AO__atomic_fetch_and:
4271 case AtomicExpr::AO__atomic_fetch_or:
4272 case AtomicExpr::AO__atomic_fetch_xor:
4273 case AtomicExpr::AO__atomic_fetch_nand:
4274 case AtomicExpr::AO__atomic_and_fetch:
4275 case AtomicExpr::AO__atomic_or_fetch:
4276 case AtomicExpr::AO__atomic_xor_fetch:
4277 case AtomicExpr::AO__atomic_nand_fetch:
4281 case AtomicExpr::AO__atomic_fetch_min:
4282 case AtomicExpr::AO__atomic_fetch_max:
4287 case AtomicExpr::AO__c11_atomic_exchange:
4288 case AtomicExpr::AO__opencl_atomic_exchange:
4289 case AtomicExpr::AO__atomic_exchange_n:
4293 case AtomicExpr::AO__atomic_exchange:
4297 case AtomicExpr::AO__c11_atomic_compare_exchange_strong:
4298 case AtomicExpr::AO__c11_atomic_compare_exchange_weak:
4299 case AtomicExpr::AO__opencl_atomic_compare_exchange_strong:
4300 case AtomicExpr::AO__opencl_atomic_compare_exchange_weak:
4304 case AtomicExpr::AO__atomic_compare_exchange:
4305 case AtomicExpr::AO__atomic_compare_exchange_n:
4310 unsigned AdjustedNumArgs = NumArgs[Form];
4311 if (IsOpenCL && Op != AtomicExpr::AO__opencl_atomic_init)
4314 if (TheCall->
getNumArgs() < AdjustedNumArgs) {
4315 Diag(TheCall->
getLocEnd(), diag::err_typecheck_call_too_few_args)
4316 << 0 << AdjustedNumArgs << TheCall->
getNumArgs()
4319 }
else if (TheCall->
getNumArgs() > AdjustedNumArgs) {
4321 diag::err_typecheck_call_too_many_args)
4322 << 0 << AdjustedNumArgs << TheCall->
getNumArgs()
4329 ExprResult ConvertedPtr = DefaultFunctionArrayLvalueConversion(Ptr);
4333 Ptr = ConvertedPtr.
get();
4336 Diag(DRE->getLocStart(), diag::err_atomic_builtin_must_be_pointer)
4346 Diag(DRE->getLocStart(), diag::err_atomic_op_needs_atomic)
4352 Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_atomic)
4358 }
else if (Form != Load && Form != LoadCopy) {
4360 Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_pointer)
4367 if (Form == Arithmetic) {
4371 Diag(DRE->getLocStart(), diag::err_atomic_op_needs_atomic_int_or_ptr)
4377 if (!BT || (BT->
getKind() != BuiltinType::Int &&
4378 BT->
getKind() != BuiltinType::UInt)) {
4379 Diag(DRE->getLocStart(), diag::err_atomic_op_needs_int32_or_ptr);
4384 Diag(DRE->getLocStart(), diag::err_atomic_op_bitwise_needs_atomic_int)
4390 diag::err_incomplete_type)) {
4396 Diag(DRE->getLocStart(), diag::err_atomic_op_needs_atomic_int_or_ptr)
4405 Diag(DRE->getLocStart(), diag::err_atomic_op_needs_trivial_copy)
4421 Diag(DRE->getLocStart(), diag::err_arc_atomic_ownership)
4433 if (Form == Copy || Form == LoadCopy || Form == GNUXchg ||
4435 ResultType = Context.
VoidTy;
4436 else if (Form == C11CmpXchg || Form == GNUCmpXchg)
4437 ResultType = Context.
BoolTy;
4442 bool IsPassedByAddress =
false;
4443 if (!IsC11 && !IsN) {
4445 IsPassedByAddress =
true;
4453 for (
unsigned i = 0; i != TheCall->
getNumArgs(); ++i) {
4455 if (i < NumVals[Form] + 1) {
4468 assert(Form != Load);
4469 if (Form == Init || (Form == Arithmetic && ValType->
isIntegerType()))
4471 else if (Form == Copy || Form == Xchg) {
4472 if (IsPassedByAddress)
4476 }
else if (Form == Arithmetic)
4486 AS = PtrTy->getPointeeType().getAddressSpace();
4495 if (IsPassedByAddress)
4520 SubExprs.push_back(Ptr);
4524 SubExprs.push_back(TheCall->
getArg(1));
4527 SubExprs.push_back(TheCall->
getArg(1));
4533 SubExprs.push_back(TheCall->
getArg(2));
4534 SubExprs.push_back(TheCall->
getArg(1));
4538 SubExprs.push_back(TheCall->
getArg(3));
4539 SubExprs.push_back(TheCall->
getArg(1));
4540 SubExprs.push_back(TheCall->
getArg(2));
4543 SubExprs.push_back(TheCall->
getArg(3));
4544 SubExprs.push_back(TheCall->
getArg(1));
4545 SubExprs.push_back(TheCall->
getArg(4));
4546 SubExprs.push_back(TheCall->
getArg(2));
4549 SubExprs.push_back(TheCall->
getArg(4));
4550 SubExprs.push_back(TheCall->
getArg(1));
4551 SubExprs.push_back(TheCall->
getArg(5));
4552 SubExprs.push_back(TheCall->
getArg(2));
4553 SubExprs.push_back(TheCall->
getArg(3));
4557 if (SubExprs.size() >= 2 && Form != Init) {
4558 llvm::APSInt Result(32);
4559 if (SubExprs[1]->isIntegerConstantExpr(Result, Context) &&
4561 Diag(SubExprs[1]->getLocStart(),
4562 diag::warn_atomic_op_has_invalid_memory_order)
4563 << SubExprs[1]->getSourceRange();
4568 llvm::APSInt Result(32);
4569 if (
Scope->isIntegerConstantExpr(Result, Context) &&
4570 !ScopeModel->isValid(Result.getZExtValue())) {
4571 Diag(
Scope->getLocStart(), diag::err_atomic_op_has_invalid_synch_scope)
4572 <<
Scope->getSourceRange();
4574 SubExprs.push_back(
Scope);
4578 SubExprs, ResultType, Op,
4581 if ((Op == AtomicExpr::AO__c11_atomic_load ||
4582 Op == AtomicExpr::AO__c11_atomic_store ||
4583 Op == AtomicExpr::AO__opencl_atomic_load ||
4584 Op == AtomicExpr::AO__opencl_atomic_store ) &&
4587 << ((Op == AtomicExpr::AO__c11_atomic_load ||
4588 Op == AtomicExpr::AO__opencl_atomic_load)
4603 assert(Fn &&
"builtin call without direct callee!");
4627 Sema::SemaBuiltinAtomicOverloaded(
ExprResult TheCallResult) {
4634 Diag(TheCall->
getLocEnd(), diag::err_typecheck_call_too_few_args_at_least)
4646 ExprResult FirstArgResult = DefaultFunctionArrayLvalueConversion(FirstArg);
4649 FirstArg = FirstArgResult.
get();
4650 TheCall->
setArg(0, FirstArg);
4662 Diag(DRE->
getLocStart(), diag::err_atomic_builtin_must_be_pointer_intptr)
4697 #define BUILTIN_ROW(x) \ 4698 { Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \ 4699 Builtin::BI##x##_8, Builtin::BI##x##_16 } 4701 static const unsigned BuiltinIndices[][5] = {
4727 case 1: SizeIndex = 0;
break;
4728 case 2: SizeIndex = 1;
break;
4729 case 4: SizeIndex = 2;
break;
4730 case 8: SizeIndex = 3;
break;
4731 case 16: SizeIndex = 4;
break;
4742 unsigned BuiltinID = FDecl->getBuiltinID();
4743 unsigned BuiltinIndex, NumFixed = 1;
4744 bool WarnAboutSemanticsChange =
false;
4745 switch (BuiltinID) {
4746 default: llvm_unreachable(
"Unknown overloaded atomic builtin!");
4747 case Builtin::BI__sync_fetch_and_add:
4748 case Builtin::BI__sync_fetch_and_add_1:
4749 case Builtin::BI__sync_fetch_and_add_2:
4750 case Builtin::BI__sync_fetch_and_add_4:
4751 case Builtin::BI__sync_fetch_and_add_8:
4752 case Builtin::BI__sync_fetch_and_add_16:
4756 case Builtin::BI__sync_fetch_and_sub:
4757 case Builtin::BI__sync_fetch_and_sub_1:
4758 case Builtin::BI__sync_fetch_and_sub_2:
4759 case Builtin::BI__sync_fetch_and_sub_4:
4760 case Builtin::BI__sync_fetch_and_sub_8:
4761 case Builtin::BI__sync_fetch_and_sub_16:
4765 case Builtin::BI__sync_fetch_and_or:
4766 case Builtin::BI__sync_fetch_and_or_1:
4767 case Builtin::BI__sync_fetch_and_or_2:
4768 case Builtin::BI__sync_fetch_and_or_4:
4769 case Builtin::BI__sync_fetch_and_or_8:
4770 case Builtin::BI__sync_fetch_and_or_16:
4774 case Builtin::BI__sync_fetch_and_and:
4775 case Builtin::BI__sync_fetch_and_and_1:
4776 case Builtin::BI__sync_fetch_and_and_2:
4777 case Builtin::BI__sync_fetch_and_and_4:
4778 case Builtin::BI__sync_fetch_and_and_8:
4779 case Builtin::BI__sync_fetch_and_and_16:
4783 case Builtin::BI__sync_fetch_and_xor:
4784 case Builtin::BI__sync_fetch_and_xor_1:
4785 case Builtin::BI__sync_fetch_and_xor_2:
4786 case Builtin::BI__sync_fetch_and_xor_4:
4787 case Builtin::BI__sync_fetch_and_xor_8:
4788 case Builtin::BI__sync_fetch_and_xor_16:
4792 case Builtin::BI__sync_fetch_and_nand:
4793 case Builtin::BI__sync_fetch_and_nand_1:
4794 case Builtin::BI__sync_fetch_and_nand_2:
4795 case Builtin::BI__sync_fetch_and_nand_4:
4796 case Builtin::BI__sync_fetch_and_nand_8:
4797 case Builtin::BI__sync_fetch_and_nand_16:
4799 WarnAboutSemanticsChange =
true;
4802 case Builtin::BI__sync_add_and_fetch:
4803 case Builtin::BI__sync_add_and_fetch_1:
4804 case Builtin::BI__sync_add_and_fetch_2:
4805 case Builtin::BI__sync_add_and_fetch_4:
4806 case Builtin::BI__sync_add_and_fetch_8:
4807 case Builtin::BI__sync_add_and_fetch_16:
4811 case Builtin::BI__sync_sub_and_fetch:
4812 case Builtin::BI__sync_sub_and_fetch_1:
4813 case Builtin::BI__sync_sub_and_fetch_2:
4814 case Builtin::BI__sync_sub_and_fetch_4:
4815 case Builtin::BI__sync_sub_and_fetch_8:
4816 case Builtin::BI__sync_sub_and_fetch_16:
4820 case Builtin::BI__sync_and_and_fetch:
4821 case Builtin::BI__sync_and_and_fetch_1:
4822 case Builtin::BI__sync_and_and_fetch_2:
4823 case Builtin::BI__sync_and_and_fetch_4:
4824 case Builtin::BI__sync_and_and_fetch_8:
4825 case Builtin::BI__sync_and_and_fetch_16:
4829 case Builtin::BI__sync_or_and_fetch:
4830 case Builtin::BI__sync_or_and_fetch_1:
4831 case Builtin::BI__sync_or_and_fetch_2:
4832 case Builtin::BI__sync_or_and_fetch_4:
4833 case Builtin::BI__sync_or_and_fetch_8:
4834 case Builtin::BI__sync_or_and_fetch_16:
4838 case Builtin::BI__sync_xor_and_fetch:
4839 case Builtin::BI__sync_xor_and_fetch_1:
4840 case Builtin::BI__sync_xor_and_fetch_2:
4841 case Builtin::BI__sync_xor_and_fetch_4:
4842 case Builtin::BI__sync_xor_and_fetch_8:
4843 case Builtin::BI__sync_xor_and_fetch_16:
4847 case Builtin::BI__sync_nand_and_fetch:
4848 case Builtin::BI__sync_nand_and_fetch_1:
4849 case Builtin::BI__sync_nand_and_fetch_2:
4850 case Builtin::BI__sync_nand_and_fetch_4:
4851 case Builtin::BI__sync_nand_and_fetch_8:
4852 case Builtin::BI__sync_nand_and_fetch_16:
4854 WarnAboutSemanticsChange =
true;
4857 case Builtin::BI__sync_val_compare_and_swap:
4858 case Builtin::BI__sync_val_compare_and_swap_1:
4859 case Builtin::BI__sync_val_compare_and_swap_2:
4860 case Builtin::BI__sync_val_compare_and_swap_4:
4861 case Builtin::BI__sync_val_compare_and_swap_8:
4862 case Builtin::BI__sync_val_compare_and_swap_16:
4867 case Builtin::BI__sync_bool_compare_and_swap:
4868 case Builtin::BI__sync_bool_compare_and_swap_1:
4869 case Builtin::BI__sync_bool_compare_and_swap_2:
4870 case Builtin::BI__sync_bool_compare_and_swap_4:
4871 case Builtin::BI__sync_bool_compare_and_swap_8:
4872 case Builtin::BI__sync_bool_compare_and_swap_16:
4875 ResultType = Context.
BoolTy;
4878 case Builtin::BI__sync_lock_test_and_set:
4879 case Builtin::BI__sync_lock_test_and_set_1:
4880 case Builtin::BI__sync_lock_test_and_set_2:
4881 case Builtin::BI__sync_lock_test_and_set_4:
4882 case Builtin::BI__sync_lock_test_and_set_8:
4883 case Builtin::BI__sync_lock_test_and_set_16:
4887 case Builtin::BI__sync_lock_release:
4888 case Builtin::BI__sync_lock_release_1:
4889 case Builtin::BI__sync_lock_release_2:
4890 case Builtin::BI__sync_lock_release_4:
4891 case Builtin::BI__sync_lock_release_8:
4892 case Builtin::BI__sync_lock_release_16:
4895 ResultType = Context.
VoidTy;
4898 case Builtin::BI__sync_swap:
4899 case Builtin::BI__sync_swap_1:
4900 case Builtin::BI__sync_swap_2:
4901 case Builtin::BI__sync_swap_4:
4902 case Builtin::BI__sync_swap_8:
4903 case Builtin::BI__sync_swap_16:
4911 Diag(TheCall->
getLocEnd(), diag::err_typecheck_call_too_few_args_at_least)
4917 if (WarnAboutSemanticsChange) {
4918 Diag(TheCall->
getLocEnd(), diag::warn_sync_fetch_and_nand_semantics_change)
4924 unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
4927 if (NewBuiltinID == BuiltinID)
4928 NewBuiltinDecl = FDecl;
4933 LookupName(Res, TUScope,
true);
4934 assert(Res.getFoundDecl());
4935 NewBuiltinDecl = dyn_cast<
FunctionDecl>(Res.getFoundDecl());
4936 if (!NewBuiltinDecl)
4943 for (
unsigned i = 0; i != NumFixed; ++i) {
4980 ExprResult PromotedCall = ImpCastExprToType(NewDRE, CalleePtrTy,
4981 CK_BuiltinFnToFnPtr);
4989 return TheCallResult;
5004 assert((BuiltinID == Builtin::BI__builtin_nontemporal_store ||
5005 BuiltinID == Builtin::BI__builtin_nontemporal_load) &&
5006 "Unexpected nontemporal load/store builtin!");
5007 bool isStore = BuiltinID == Builtin::BI__builtin_nontemporal_store;
5008 unsigned numArgs = isStore ? 2 : 1;
5018 Expr *PointerArg = TheCall->
getArg(numArgs - 1);
5020 DefaultFunctionArrayLvalueConversion(PointerArg);
5024 PointerArg = PointerArgResult.
get();
5025 TheCall->
setArg(numArgs - 1, PointerArg);
5029 Diag(DRE->
getLocStart(), diag::err_nontemporal_builtin_must_be_pointer)
5042 diag::err_nontemporal_builtin_must_be_pointer_intfltptr_or_vector)
5049 return TheCallResult;
5054 Context, ValType,
false);
5055 ValArg = PerformCopyInitialization(Entity,
SourceLocation(), ValArg);
5061 return TheCallResult;
5068 bool Sema::CheckObjCString(
Expr *Arg) {
5072 if (!Literal || !Literal->
isAscii()) {
5073 Diag(Arg->
getLocStart(), diag::err_cfstring_literal_not_string_constant)
5079 StringRef String = Literal->
getString();
5080 unsigned NumBytes = String.size();
5082 const llvm::UTF8 *FromPtr = (
const llvm::UTF8 *)String.data();
5083 llvm::UTF16 *ToPtr = &ToBuf[0];
5085 llvm::ConversionResult Result =
5086 llvm::ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes, &ToPtr,
5087 ToPtr + NumBytes, llvm::strictConversion);
5089 if (Result != llvm::conversionOK)
5102 if (
auto *ObjcLiteral = dyn_cast<ObjCStringLiteral>(Arg)) {
5107 if (!Literal || (!Literal->isAscii() && !Literal->isUTF8())) {
5117 Result = PerformCopyInitialization(Entity,
SourceLocation(), Result);
5125 bool IsX64 = TT.getArch() == llvm::Triple::x86_64;
5126 bool IsAArch64 = TT.getArch() == llvm::Triple::aarch64;
5127 bool IsWindows = TT.isOSWindows();
5128 bool IsMSVAStart = BuiltinID == Builtin::BI__builtin_ms_va_start;
5129 if (IsX64 || IsAArch64) {
5132 CC = FD->getType()->getAs<
FunctionType>()->getCallConv();
5137 diag::err_ms_va_start_used_in_sysv_function);
5146 diag::err_va_start_used_in_wrong_abi_function)
5161 bool IsVariadic =
false;
5162 ArrayRef<ParmVarDecl *> Params;
5164 if (
auto *Block = dyn_cast<BlockDecl>(Caller)) {
5165 IsVariadic = Block->isVariadic();
5166 Params = Block->parameters();
5167 }
else if (
auto *FD = dyn_cast<FunctionDecl>(Caller)) {
5168 IsVariadic = FD->isVariadic();
5169 Params = FD->parameters();
5170 }
else if (
auto *MD = dyn_cast<ObjCMethodDecl>(Caller)) {
5171 IsVariadic = MD->isVariadic();
5173 Params = MD->parameters();
5174 }
else if (isa<CapturedDecl>(Caller)) {
5190 *LastParam = Params.empty() ? nullptr : Params.back();
5198 bool Sema::SemaBuiltinVAStart(
unsigned BuiltinID,
CallExpr *TheCall) {
5206 diag::err_typecheck_call_too_many_args)
5210 (*(TheCall->
arg_end()-1))->getLocEnd());
5216 diag::err_typecheck_call_too_few_args_at_least)
5231 bool SecondArgIsLastNamedArgument =
false;
5238 bool IsCRegister =
false;
5240 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Arg)) {
5241 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {
5242 SecondArgIsLastNamedArgument = PV == LastParam;
5244 Type = PV->getType();
5245 ParamLoc = PV->getLocation();
5247 PV->getStorageClass() ==
SC_Register && !getLangOpts().CPlusPlus;
5251 if (!SecondArgIsLastNamedArgument)
5253 diag::warn_second_arg_of_va_start_not_last_named_param);
5266 unsigned Reason = 0;
5268 else if (IsCRegister) Reason = 2;
5269 Diag(Arg->
getLocStart(), diag::warn_va_start_type_is_undefined) << Reason;
5270 Diag(ParamLoc, diag::note_parameter_type) << Type;
5277 bool Sema::SemaBuiltinVAStartARMMicrosoft(
CallExpr *Call) {
5285 diag::err_typecheck_call_too_few_args_at_least)
5309 << Arg1->
getType() << ConstCharPtrTy
5313 << 2 << Arg1->
getType() << ConstCharPtrTy;
5322 << 3 << Arg2->
getType() << SizeTy;
5329 bool Sema::SemaBuiltinUnorderedCompare(
CallExpr *TheCall) {
5331 return Diag(TheCall->
getLocEnd(), diag::err_typecheck_call_too_few_args)
5335 diag::err_typecheck_call_too_many_args)
5338 (*(TheCall->
arg_end()-1))->getLocEnd());
5345 QualType Res = UsualArithmeticConversions(OrigArg0, OrigArg1,
false);
5346 if (OrigArg0.isInvalid() || OrigArg1.
isInvalid())
5352 TheCall->
setArg(0, OrigArg0.get());
5355 if (OrigArg0.get()->isTypeDependent() || OrigArg1.
get()->isTypeDependent())
5361 return Diag(OrigArg0.get()->getLocStart(),
5362 diag::err_typecheck_call_invalid_ordered_compare)
5363 << OrigArg0.get()->getType() << OrigArg1.
get()->getType()
5364 <<
SourceRange(OrigArg0.get()->getLocStart(), OrigArg1.
get()->getLocEnd());
5373 bool Sema::SemaBuiltinFPClassification(
CallExpr *TheCall,
unsigned NumArgs) {
5375 return Diag(TheCall->
getLocEnd(), diag::err_typecheck_call_too_few_args)
5379 diag::err_typecheck_call_too_many_args)
5382 (*(TheCall->
arg_end()-1))->getLocEnd());
5386 if (OrigArg->isTypeDependent())
5390 if (!OrigArg->getType()->isRealFloatingType())
5391 return Diag(OrigArg->getLocStart(),
5392 diag::err_typecheck_call_invalid_unary_fp)
5393 << OrigArg->getType() << OrigArg->getSourceRange();
5399 if (Cast->getCastKind() == CK_FloatingCast) {
5400 Expr *CastArg = Cast->getSubExpr();
5403 (Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) ||
5404 Cast->getType()->isSpecificBuiltinType(BuiltinType::Float) ||
5405 Cast->getType()->isSpecificBuiltinType(BuiltinType::LongDouble)) &&
5406 "promotion from float to either float, double, or long double is " 5407 "the only expected cast here");
5408 Cast->setSubExpr(
nullptr);
5409 TheCall->
setArg(NumArgs-1, CastArg);
5424 bool Sema::SemaBuiltinVSX(
CallExpr *TheCall) {
5425 unsigned ExpectedNumArgs = 3;
5428 diag::err_typecheck_call_too_few_args_at_least)
5429 << 0 << ExpectedNumArgs << TheCall->
getNumArgs()
5434 diag::err_typecheck_call_too_many_args_at_most)
5435 << 0 << ExpectedNumArgs << TheCall->
getNumArgs()
5442 diag::err_vsx_builtin_nonconstant_argument)
5452 if ((!Arg1Ty->isVectorType() && !Arg1Ty->isDependentType()) ||
5454 return Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
5462 return Diag(BuiltinLoc, diag::err_vec_builtin_incompatible_vector)
5481 diag::err_typecheck_call_too_few_args_at_least)
5489 unsigned numElements = 0;
5498 diag::err_vec_builtin_non_vector)
5504 unsigned numResElements = TheCall->
getNumArgs() - 2;
5513 diag::err_vec_builtin_incompatible_vector)
5519 diag::err_vec_builtin_incompatible_vector)
5523 }
else if (numElements != numResElements) {
5530 for (
unsigned i = 2; i < TheCall->
getNumArgs(); i++) {
5535 llvm::APSInt Result(32);
5538 diag::err_shufflevector_nonconstant_argument)
5542 if (Result.isSigned() && Result.isAllOnesValue())
5545 if (Result.getActiveBits() > 64 || Result.getZExtValue() >= numElements*2)
5547 diag::err_shufflevector_argument_too_large)
5553 for (
unsigned i = 0, e = TheCall->
getNumArgs(); i != e; i++) {
5554 exprs.push_back(TheCall->
getArg(i));
5555 TheCall->
setArg(i,
nullptr);
5574 diag::err_convertvector_non_vector)
5578 diag::err_convertvector_non_vector_type));
5583 if (SrcElts != DstElts)
5585 diag::err_convertvector_incompatible_vector)
5589 return new (Context)
5596 bool Sema::SemaBuiltinPrefetch(
CallExpr *TheCall) {
5601 diag::err_typecheck_call_too_many_args_at_most)
5602 << 0 << 3 << NumArgs
5607 for (
unsigned i = 1; i != NumArgs; ++i)
5608 if (SemaBuiltinConstantArgRange(TheCall, i, 0, i == 1 ? 1 : 3))
5617 bool Sema::SemaBuiltinAssume(
CallExpr *TheCall) {
5632 bool Sema::SemaBuiltinAllocaWithAlign(
CallExpr *TheCall) {
5638 if (
const auto *UE =
5646 if (!Result.isPowerOf2())
5648 diag::err_alignment_not_power_of_two)
5667 bool Sema::SemaBuiltinAssumeAligned(
CallExpr *TheCall) {
5672 diag::err_typecheck_call_too_many_args_at_most)
5673 << 0 << 3 << NumArgs
5681 llvm::APSInt Result;
5682 if (SemaBuiltinConstantArg(TheCall, 1, Result))
5685 if (!Result.isPowerOf2())
5687 diag::err_alignment_not_power_of_two)
5696 if (Arg.isInvalid())
return true;
5697 TheCall->
setArg(2, Arg.get());
5703 bool Sema::SemaBuiltinOSLogFormat(
CallExpr *TheCall) {
5704 unsigned BuiltinID =
5705 cast<FunctionDecl>(TheCall->
getCalleeDecl())->getBuiltinID();
5706 bool IsSizeCall = BuiltinID == Builtin::BI__builtin_os_log_format_buffer_size;
5709 unsigned NumRequiredArgs = IsSizeCall ? 1 : 2;
5710 if (NumArgs < NumRequiredArgs) {
5711 return Diag(TheCall->
getLocEnd(), diag::err_typecheck_call_too_few_args)
5712 << 0 << NumRequiredArgs << NumArgs
5715 if (NumArgs >= NumRequiredArgs + 0x100) {
5717 diag::err_typecheck_call_too_many_args_at_most)
5718 << 0 << (NumRequiredArgs + 0xff) << NumArgs
5729 if (Arg.isInvalid())
5731 TheCall->
setArg(i, Arg.get());
5736 unsigned FormatIdx = i;
5746 unsigned FirstDataArg = i;
5747 while (i < NumArgs) {
5748 ExprResult Arg = DefaultVariadicArgumentPromotion(
5749 TheCall->
getArg(i), VariadicFunction,
nullptr);
5754 return Diag(Arg.
get()->getLocEnd(), diag::err_os_log_argument_too_big)
5765 llvm::SmallBitVector CheckedVarArgs(NumArgs,
false);
5767 bool Success = CheckFormatArguments(
5768 Args,
false, FormatIdx, FirstDataArg, FST_OSLog,
5785 bool Sema::SemaBuiltinConstantArg(
CallExpr *TheCall,
int ArgNum,
5786 llvm::APSInt &Result) {
5794 return Diag(TheCall->
getLocStart(), diag::err_constant_integer_arg_type)
5802 bool Sema::SemaBuiltinConstantArgRange(
CallExpr *TheCall,
int ArgNum,
5803 int Low,
int High,
bool RangeIsError) {
5804 llvm::APSInt Result;
5812 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
5815 if (Result.getSExtValue() < Low || Result.getSExtValue() > High) {
5822 DiagRuntimeBehavior(TheCall->
getLocStart(), TheCall,
5823 PDiag(diag::warn_argument_invalid_range)
5824 << Result.toString(10) << Low << High
5833 bool Sema::SemaBuiltinConstantArgMultiple(
CallExpr *TheCall,
int ArgNum,
5835 llvm::APSInt Result;
5843 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
5846 if (Result.getSExtValue() % Num != 0)
5855 bool Sema::SemaBuiltinARMSpecialReg(
unsigned BuiltinID,
CallExpr *TheCall,
5856 int ArgNum,
unsigned ExpectedFieldNum,
5858 bool IsARMBuiltin = BuiltinID == ARM::BI__builtin_arm_rsr64 ||
5859 BuiltinID == ARM::BI__builtin_arm_wsr64 ||
5860 BuiltinID == ARM::BI__builtin_arm_rsr ||
5861 BuiltinID == ARM::BI__builtin_arm_rsrp ||
5862 BuiltinID == ARM::BI__builtin_arm_wsr ||
5863 BuiltinID == ARM::BI__builtin_arm_wsrp;
5864 bool IsAArch64Builtin = BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
5865 BuiltinID == AArch64::BI__builtin_arm_wsr64 ||
5866 BuiltinID == AArch64::BI__builtin_arm_rsr ||
5867 BuiltinID == AArch64::BI__builtin_arm_rsrp ||
5868 BuiltinID == AArch64::BI__builtin_arm_wsr ||
5869 BuiltinID == AArch64::BI__builtin_arm_wsrp;
5870 assert((IsARMBuiltin || IsAArch64Builtin) &&
"Unexpected ARM builtin.");
5879 return Diag(TheCall->
getLocStart(), diag::err_expr_not_string_literal)
5885 Reg.split(Fields,
":");
5887 if (Fields.size() != ExpectedFieldNum && !(AllowName && Fields.size() == 1))
5895 if (Fields.size() > 1) {
5896 bool FiveFields = Fields.size() == 5;
5898 bool ValidString =
true;
5900 ValidString &= Fields[0].startswith_lower(
"cp") ||
5901 Fields[0].startswith_lower(
"p");
5904 Fields[0].drop_front(Fields[0].startswith_lower(
"cp") ? 2 : 1);
5906 ValidString &= Fields[2].startswith_lower(
"c");
5908 Fields[2] = Fields[2].drop_front(1);
5911 ValidString &= Fields[3].startswith_lower(
"c");
5913 Fields[3] = Fields[3].drop_front(1);
5919 Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 15, 15, 7});
5921 Ranges.append({15, 7, 15});
5923 for (
unsigned i=0; i<Fields.size(); ++i) {
5925 ValidString &= !Fields[i].getAsInteger(10, IntField);
5926 ValidString &= (IntField >= 0 && IntField <= Ranges[i]);
5932 }
else if (IsAArch64Builtin && Fields.size() == 1) {
5942 std::string RegLower = Reg.lower();
5943 if (RegLower !=
"spsel" && RegLower !=
"daifset" && RegLower !=
"daifclr" &&
5944 RegLower !=
"pan" && RegLower !=
"uao")
5947 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
5956 bool Sema::SemaBuiltinLongjmp(
CallExpr *TheCall) {
5958 return Diag(TheCall->
getLocStart(), diag::err_builtin_longjmp_unsupported)
5962 llvm::APSInt Result;
5965 if (SemaBuiltinConstantArg(TheCall, 1, Result))
5969 return Diag(TheCall->
getLocStart(), diag::err_builtin_longjmp_invalid_val)
5977 bool Sema::SemaBuiltinSetjmp(
CallExpr *TheCall) {
5979 return Diag(TheCall->
getLocStart(), diag::err_builtin_setjmp_unsupported)
5986 class UncoveredArgHandler {
5987 enum { Unknown = -1, AllCovered = -2 };
5989 signed FirstUncoveredArg = Unknown;
5993 UncoveredArgHandler() =
default;
5995 bool hasUncoveredArg()
const {
5996 return (FirstUncoveredArg >= 0);
5999 unsigned getUncoveredArg()
const {
6000 assert(hasUncoveredArg() &&
"no uncovered argument");
6001 return FirstUncoveredArg;
6004 void setAllCovered() {
6007 DiagnosticExprs.clear();
6008 FirstUncoveredArg = AllCovered;
6011 void Update(
signed NewFirstUncoveredArg,
const Expr *StrExpr) {
6012 assert(NewFirstUncoveredArg >= 0 &&
"Outside range");
6015 if (FirstUncoveredArg == AllCovered)
6020 if (NewFirstUncoveredArg == FirstUncoveredArg)
6021 DiagnosticExprs.push_back(StrExpr);
6022 else if (NewFirstUncoveredArg > FirstUncoveredArg) {
6023 DiagnosticExprs.clear();
6024 DiagnosticExprs.push_back(StrExpr);
6025 FirstUncoveredArg = NewFirstUncoveredArg;
6029 void Diagnose(
Sema &S,
bool IsFunctionCall,
const Expr *ArgExpr);
6034 SLCT_UncheckedLiteral,
6042 bool AddendIsRight) {
6043 unsigned BitWidth = Offset.getBitWidth();
6044 unsigned AddendBitWidth = Addend.getBitWidth();
6046 if (Addend.isUnsigned()) {
6047 Addend = Addend.zext(++AddendBitWidth);
6048 Addend.setIsSigned(
true);
6051 if (AddendBitWidth > BitWidth) {
6052 Offset = Offset.sext(AddendBitWidth);
6053 BitWidth = AddendBitWidth;
6054 }
else if (BitWidth > AddendBitWidth) {
6055 Addend = Addend.sext(BitWidth);
6059 llvm::APSInt ResOffset =
Offset;
6060 if (BinOpKind == BO_Add)
6061 ResOffset = Offset.sadd_ov(Addend, Ov);
6063 assert(AddendIsRight && BinOpKind == BO_Sub &&
6064 "operator must be add or sub with addend on the right");
6065 ResOffset = Offset.ssub_ov(Addend, Ov);
6072 "index (intermediate) result too big");
6073 Offset = Offset.sext(2 * BitWidth);
6074 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
6086 class FormatStringLiteral {
6091 FormatStringLiteral(
const StringLiteral *fexpr, int64_t Offset = 0)
6092 : FExpr(fexpr),
Offset(Offset) {}
6094 StringRef getString()
const {
6095 return FExpr->
getString().drop_front(Offset);
6098 unsigned getByteLength()
const {
6109 bool isAscii()
const {
return FExpr->
isAscii(); }
6110 bool isWide()
const {
return FExpr->
isWide(); }
6111 bool isUTF8()
const {
return FExpr->
isUTF8(); }
6112 bool isUTF16()
const {
return FExpr->
isUTF16(); }
6113 bool isUTF32()
const {
return FExpr->
isUTF32(); }
6114 bool isPascal()
const {
return FExpr->
isPascal(); }
6119 unsigned *StartTokenByteOffset =
nullptr)
const {
6121 StartToken, StartTokenByteOffset);
6124 SourceLocation getLocStart()
const LLVM_READONLY {
return getBeginLoc(); }
6129 SourceLocation getLocEnd()
const LLVM_READONLY {
return getEndLoc(); }
6136 const Expr *OrigFormatExpr,
6137 ArrayRef<const Expr *> Args,
6138 bool HasVAListArg,
unsigned format_idx,
6139 unsigned firstDataArg,
6141 bool inFunctionCall,
6143 llvm::SmallBitVector &CheckedVarArgs,
6144 UncoveredArgHandler &UncoveredArg);
6152 bool HasVAListArg,
unsigned format_idx,
6155 llvm::SmallBitVector &CheckedVarArgs,
6156 UncoveredArgHandler &UncoveredArg,
6159 assert(Offset.isSigned() &&
"invalid offset");
6162 return SLCT_NotALiteral;
6171 return SLCT_UncheckedLiteral;
6174 case Stmt::BinaryConditionalOperatorClass:
6175 case Stmt::ConditionalOperatorClass: {
6179 cast<AbstractConditionalOperator>(E);
6184 bool CheckLeft =
true, CheckRight =
true;
6200 Left = SLCT_UncheckedLiteral;
6203 HasVAListArg, format_idx, firstDataArg,
6204 Type, CallType, InFunctionCall,
6205 CheckedVarArgs, UncoveredArg,
Offset);
6206 if (Left == SLCT_NotALiteral || !CheckRight) {
6213 HasVAListArg, format_idx, firstDataArg,
6214 Type, CallType, InFunctionCall, CheckedVarArgs,
6217 return (CheckLeft && Left < Right) ? Left : Right;
6220 case Stmt::ImplicitCastExprClass:
6221 E = cast<ImplicitCastExpr>(E)->getSubExpr();
6224 case Stmt::OpaqueValueExprClass:
6225 if (
const Expr *src = cast<OpaqueValueExpr>(E)->getSourceExpr()) {
6229 return SLCT_NotALiteral;
6231 case Stmt::PredefinedExprClass:
6235 return SLCT_UncheckedLiteral;
6237 case Stmt::DeclRefExprClass: {
6243 bool isConstant =
false;
6247 isConstant = AT->getElementType().isConstant(S.
Context);
6250 PT->getPointeeType().isConstant(S.
Context);
6258 if (
const Expr *Init = VD->getAnyInitializer()) {
6260 if (
const InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
6261 if (InitList->isStringLiteralInit())
6262 Init = InitList->getInit(0)->IgnoreParenImpCasts();
6265 HasVAListArg, format_idx,
6266 firstDataArg, Type, CallType,
6267 false, CheckedVarArgs,
6268 UncoveredArg, Offset);
6287 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(VD)) {
6288 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(PV->getDeclContext())) {
6289 int PVIndex = PV->getFunctionScopeIndex() + 1;
6290 for (
const auto *PVFormat : ND->specific_attrs<FormatAttr>()) {
6293 if (MD->isInstance())
6297 if (PVIndex == PVFormat->getFormatIdx() &&
6299 return SLCT_UncheckedLiteral;
6306 return SLCT_NotALiteral;
6309 case Stmt::CallExprClass:
6310 case Stmt::CXXMemberCallExprClass: {
6311 const CallExpr *CE = cast<CallExpr>(E);
6313 bool IsFirst =
true;
6315 for (
const auto *FA : ND->specific_attrs<FormatArgAttr>()) {
6316 const Expr *Arg = CE->
getArg(FA->getFormatIdx().getASTIndex());
6318 S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
6319 CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
6321 CommonResult = Result;
6326 return CommonResult;
6328 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
6329 unsigned BuiltinID = FD->getBuiltinID();
6330 if (BuiltinID == Builtin::BI__builtin___CFStringMakeConstantString ||
6331 BuiltinID == Builtin::BI__builtin___NSStringMakeConstantString) {
6334 HasVAListArg, format_idx,
6335 firstDataArg, Type, CallType,
6336 InFunctionCall, CheckedVarArgs,
6337 UncoveredArg, Offset);
6342 return SLCT_NotALiteral;
6344 case Stmt::ObjCMessageExprClass: {
6345 const auto *ME = cast<ObjCMessageExpr>(E);
6346 if (
const auto *ND = ME->getMethodDecl()) {
6347 if (
const auto *FA = ND->getAttr<FormatArgAttr>()) {
6348 const Expr *Arg = ME->getArg(FA->getFormatIdx().getASTIndex());
6350 S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
6351 CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
6355 return SLCT_NotALiteral;
6357 case Stmt::ObjCStringLiteralClass:
6358 case Stmt::StringLiteralClass: {
6364 StrE = cast<StringLiteral>(E);
6367 if (Offset.isNegative() || Offset > StrE->
getLength()) {
6370 return SLCT_NotALiteral;
6372 FormatStringLiteral FStr(StrE, Offset.sextOrTrunc(64).getSExtValue());
6374 firstDataArg, Type, InFunctionCall, CallType,
6375 CheckedVarArgs, UncoveredArg);
6376 return SLCT_CheckedLiteral;
6379 return SLCT_NotALiteral;
6381 case Stmt::BinaryOperatorClass: {
6382 llvm::APSInt LResult;
6383 llvm::APSInt RResult;
6392 if (LIsInt != RIsInt) {
6396 if (BinOpKind == BO_Add) {
6397 sumOffsets(Offset, LResult, BinOpKind, RIsInt);
6402 sumOffsets(Offset, RResult, BinOpKind, RIsInt);
6409 return SLCT_NotALiteral;
6411 case Stmt::UnaryOperatorClass: {
6414 if (UnaOp->
getOpcode() == UO_AddrOf && ASE) {
6415 llvm::APSInt IndexResult;
6416 if (ASE->getRHS()->EvaluateAsInt(IndexResult, S.
Context)) {
6417 sumOffsets(Offset, IndexResult, BO_Add,
true);
6423 return SLCT_NotALiteral;
6427 return SLCT_NotALiteral;
6432 return llvm::StringSwitch<FormatStringType>(Format->getType()->getName())
6433 .Case(
"scanf", FST_Scanf)
6434 .Cases(
"printf",
"printf0", FST_Printf)
6435 .Cases(
"NSString",
"CFString", FST_NSString)
6436 .Case(
"strftime", FST_Strftime)
6437 .Case(
"strfmon", FST_Strfmon)
6438 .Cases(
"kprintf",
"cmn_err",
"vcmn_err",
"zcmn_err", FST_Kprintf)
6439 .Case(
"freebsd_kprintf", FST_FreeBSDKPrintf)
6440 .Case(
"os_trace", FST_OSLog)
6441 .Case(
"os_log", FST_OSLog)
6442 .Default(FST_Unknown);
6448 bool Sema::CheckFormatArguments(
const FormatAttr *Format,
6453 llvm::SmallBitVector &CheckedVarArgs) {
6454 FormatStringInfo FSI;
6455 if (getFormatStringInfo(Format, IsCXXMember, &FSI))
6456 return CheckFormatArguments(Args, FSI.HasVAListArg, FSI.FormatIdx,
6457 FSI.FirstDataArg, GetFormatStringType(Format),
6458 CallType, Loc, Range, CheckedVarArgs);
6463 bool HasVAListArg,
unsigned format_idx,
6467 llvm::SmallBitVector &CheckedVarArgs) {
6469 if (format_idx >= Args.size()) {
6470 Diag(Loc, diag::warn_missing_format_string) << Range;
6474 const Expr *OrigFormatExpr = Args[format_idx]->IgnoreParenCasts();
6488 UncoveredArgHandler UncoveredArg;
6491 format_idx, firstDataArg,
Type, CallType,
6492 true, CheckedVarArgs,
6494 llvm::APSInt(64,
false) = 0);
6497 if (UncoveredArg.hasUncoveredArg()) {
6498 unsigned ArgIdx = UncoveredArg.getUncoveredArg() + firstDataArg;
6499 assert(ArgIdx < Args.size() &&
"ArgIdx outside bounds");
6500 UncoveredArg.Diagnose(*
this,
true, Args[ArgIdx]);
6503 if (CT != SLCT_NotALiteral)
6505 return CT == SLCT_CheckedLiteral;
6509 if (
Type == FST_Strftime)
6517 if (
Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
6522 if (Args.size() == firstDataArg) {
6523 Diag(FormatLoc, diag::warn_format_nonliteral_noargs)
6529 case FST_FreeBSDKPrintf:
6531 Diag(FormatLoc, diag::note_format_security_fixit)
6535 Diag(FormatLoc, diag::note_format_security_fixit)
6540 Diag(FormatLoc, diag::warn_format_nonliteral)
6551 const FormatStringLiteral *FExpr;
6552 const Expr *OrigFormatExpr;
6554 const unsigned FirstDataArg;
6555 const unsigned NumDataArgs;
6557 const bool HasVAListArg;
6560 llvm::SmallBitVector CoveredArgs;
6561 bool usesPositionalArgs =
false;
6562 bool atFirstArg =
true;
6563 bool inFunctionCall;
6565 llvm::SmallBitVector &CheckedVarArgs;
6566 UncoveredArgHandler &UncoveredArg;
6569 CheckFormatHandler(
Sema &s,
const FormatStringLiteral *fexpr,
6570 const Expr *origFormatExpr,
6572 unsigned numDataArgs,
const char *beg,
bool hasVAListArg,
6575 llvm::SmallBitVector &CheckedVarArgs,
6576 UncoveredArgHandler &UncoveredArg)
6577 : S(s), FExpr(fexpr), OrigFormatExpr(origFormatExpr), FSType(type),
6578 FirstDataArg(firstDataArg), NumDataArgs(numDataArgs), Beg(beg),
6579 HasVAListArg(hasVAListArg), Args(Args), FormatIdx(formatIdx),
6580 inFunctionCall(inFunctionCall), CallType(callType),
6581 CheckedVarArgs(CheckedVarArgs), UncoveredArg(UncoveredArg) {
6582 CoveredArgs.resize(numDataArgs);
6583 CoveredArgs.reset();
6586 void DoneProcessing();
6588 void HandleIncompleteSpecifier(
const char *startSpecifier,
6589 unsigned specifierLen)
override;
6591 void HandleInvalidLengthModifier(
6594 const char *startSpecifier,
unsigned specifierLen,
6597 void HandleNonStandardLengthModifier(
6599 const char *startSpecifier,
unsigned specifierLen);
6601 void HandleNonStandardConversionSpecifier(
6603 const char *startSpecifier,
unsigned specifierLen);
6605 void HandlePosition(
const char *startPos,
unsigned posLen)
override;
6607 void HandleInvalidPosition(
const char *startSpecifier,
6608 unsigned specifierLen,
6611 void HandleZeroPosition(
const char *startPos,
unsigned posLen)
override;
6613 void HandleNullChar(
const char *nullCharacter)
override;
6615 template <
typename Range>
6617 EmitFormatDiagnostic(
Sema &S,
bool inFunctionCall,
const Expr *ArgumentExpr,
6619 bool IsStringLocation, Range StringRange,
6623 bool HandleInvalidConversionSpecifier(
unsigned argIndex,
SourceLocation Loc,
6624 const char *startSpec,
6625 unsigned specifierLen,
6626 const char *csStart,
unsigned csLen);
6629 const char *startSpec,
6630 unsigned specifierLen);
6634 unsigned specifierLen);
6637 const Expr *getDataArg(
unsigned i)
const;
6641 const char *startSpecifier,
unsigned specifierLen,
6644 template <
typename Range>
6646 bool IsStringLocation, Range StringRange,
6652 SourceRange CheckFormatHandler::getFormatStringRange() {
6657 getSpecifierRange(
const char *startSpecifier,
unsigned specifierLen) {
6667 SourceLocation CheckFormatHandler::getLocationOfByte(
const char *x) {
6672 void CheckFormatHandler::HandleIncompleteSpecifier(
const char *startSpecifier,
6673 unsigned specifierLen){
6674 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_incomplete_specifier),
6675 getLocationOfByte(startSpecifier),
6677 getSpecifierRange(startSpecifier, specifierLen));
6680 void CheckFormatHandler::HandleInvalidLengthModifier(
6683 const char *startSpecifier,
unsigned specifierLen,
unsigned DiagID) {
6684 using namespace analyze_format_string;
6687 CharSourceRange LMRange = getSpecifierRange(LM.getStart(), LM.getLength());
6692 EmitFormatDiagnostic(S.
PDiag(DiagID) << LM.toString() << CS.
toString(),
6693 getLocationOfByte(LM.getStart()),
6695 getSpecifierRange(startSpecifier, specifierLen));
6697 S.
Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
6698 << FixedLM->toString()
6703 if (DiagID == diag::warn_format_nonsensical_length)
6706 EmitFormatDiagnostic(S.
PDiag(DiagID) << LM.toString() << CS.
toString(),
6707 getLocationOfByte(LM.getStart()),
6709 getSpecifierRange(startSpecifier, specifierLen),
6714 void CheckFormatHandler::HandleNonStandardLengthModifier(
6716 const char *startSpecifier,
unsigned specifierLen) {
6717 using namespace analyze_format_string;
6720 CharSourceRange LMRange = getSpecifierRange(LM.getStart(), LM.getLength());
6725 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
6726 << LM.toString() << 0,
6727 getLocationOfByte(LM.getStart()),
6729 getSpecifierRange(startSpecifier, specifierLen));
6731 S.
Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
6732 << FixedLM->toString()
6736 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
6737 << LM.toString() << 0,
6738 getLocationOfByte(LM.getStart()),
6740 getSpecifierRange(startSpecifier, specifierLen));
6744 void CheckFormatHandler::HandleNonStandardConversionSpecifier(
6746 const char *startSpecifier,
unsigned specifierLen) {
6747 using namespace analyze_format_string;
6752 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
6756 getSpecifierRange(startSpecifier, specifierLen));
6759 S.
Diag(getLocationOfByte(CS.
getStart()), diag::note_format_fix_specifier)
6760 << FixedCS->toString()
6763 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
6767 getSpecifierRange(startSpecifier, specifierLen));
6771 void CheckFormatHandler::HandlePosition(
const char *startPos,
6773 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard_positional_arg),
6774 getLocationOfByte(startPos),
6776 getSpecifierRange(startPos, posLen));
6780 CheckFormatHandler::HandleInvalidPosition(
const char *startPos,
unsigned posLen,
6782 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_positional_specifier)
6784 getLocationOfByte(startPos),
true,
6785 getSpecifierRange(startPos, posLen));
6788 void CheckFormatHandler::HandleZeroPosition(
const char *startPos,
6790 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_zero_positional_specifier),
6791 getLocationOfByte(startPos),
6793 getSpecifierRange(startPos, posLen));
6796 void CheckFormatHandler::HandleNullChar(
const char *nullCharacter) {
6797 if (!isa<ObjCStringLiteral>(OrigFormatExpr)) {
6799 EmitFormatDiagnostic(
6800 S.
PDiag(diag::warn_printf_format_string_contains_null_char),
6801 getLocationOfByte(nullCharacter),
true,
6802 getFormatStringRange());
6808 const Expr *CheckFormatHandler::getDataArg(
unsigned i)
const {
6809 return Args[FirstDataArg + i];
6812 void CheckFormatHandler::DoneProcessing() {
6815 if (!HasVAListArg) {
6818 signed notCoveredArg = CoveredArgs.find_first();
6819 if (notCoveredArg >= 0) {
6820 assert((
unsigned)notCoveredArg < NumDataArgs);
6821 UncoveredArg.Update(notCoveredArg, OrigFormatExpr);
6823 UncoveredArg.setAllCovered();
6828 void UncoveredArgHandler::Diagnose(
Sema &S,
bool IsFunctionCall,
6829 const Expr *ArgExpr) {
6830 assert(hasUncoveredArg() && DiagnosticExprs.size() > 0 &&
6842 for (
auto E : DiagnosticExprs)
6845 CheckFormatHandler::EmitFormatDiagnostic(
6846 S, IsFunctionCall, DiagnosticExprs[0],
6852 CheckFormatHandler::HandleInvalidConversionSpecifier(
unsigned argIndex,
6854 const char *startSpec,
6855 unsigned specifierLen,
6856 const char *csStart,
6858 bool keepGoing =
true;
6859 if (argIndex < NumDataArgs) {
6862 CoveredArgs.set(argIndex);
6878 std::string CodePointStr;
6879 if (!llvm::sys::locale::isPrint(*csStart)) {
6880 llvm::UTF32 CodePoint;
6881 const llvm::UTF8 **B =
reinterpret_cast<const llvm::UTF8 **
>(&csStart);
6882 const llvm::UTF8 *E =
6883 reinterpret_cast<const llvm::UTF8 *
>(csStart + csLen);
6884 llvm::ConversionResult Result =
6885 llvm::convertUTF8Sequence(B, E, &CodePoint, llvm::strictConversion);
6887 if (Result != llvm::conversionOK) {
6888 unsigned char FirstChar = *csStart;
6889 CodePoint = (llvm::UTF32)FirstChar;
6892 llvm::raw_string_ostream OS(CodePointStr);
6893 if (CodePoint < 256)
6894 OS <<
"\\x" << llvm::format(
"%02x", CodePoint);
6895 else if (CodePoint <= 0xFFFF)
6896 OS <<
"\\u" << llvm::format(
"%04x", CodePoint);
6898 OS <<
"\\U" << llvm::format(
"%08x", CodePoint);
6900 Specifier = CodePointStr;
6903 EmitFormatDiagnostic(
6905 true, getSpecifierRange(startSpec, specifierLen));
6911 CheckFormatHandler::HandlePositionalNonpositionalArgs(
SourceLocation Loc,
6912 const char *startSpec,
6913 unsigned specifierLen) {
6914 EmitFormatDiagnostic(
6915 S.
PDiag(diag::warn_format_mix_positional_nonpositional_args),
6916 Loc,
true, getSpecifierRange(startSpec, specifierLen));
6920 CheckFormatHandler::CheckNumArgs(
6923 const char *startSpecifier,
unsigned specifierLen,
unsigned argIndex) {
6925 if (argIndex >= NumDataArgs) {
6927 ? (S.
PDiag(diag::warn_printf_positional_arg_exceeds_data_args)
6928 << (argIndex+1) << NumDataArgs)
6929 : S.
PDiag(diag::warn_printf_insufficient_data_args);
6930 EmitFormatDiagnostic(
6931 PDiag, getLocationOfByte(CS.
getStart()),
true,
6932 getSpecifierRange(startSpecifier, specifierLen));
6936 UncoveredArg.setAllCovered();
6942 template<
typename Range>
6945 bool IsStringLocation,
6948 EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag,
6949 Loc, IsStringLocation, StringRange, FixIt);
6979 template <
typename Range>
6980 void CheckFormatHandler::EmitFormatDiagnostic(
6981 Sema &S,
bool InFunctionCall,
const Expr *ArgumentExpr,
6984 if (InFunctionCall) {
6989 S.
Diag(IsStringLocation ? ArgumentExpr->
getExprLoc() : Loc, PDiag)
6993 S.
Diag(IsStringLocation ? Loc : StringRange.getBegin(),
6994 diag::note_format_string_defined);
6996 Note << StringRange;
7005 class CheckPrintfHandler :
public CheckFormatHandler {
7007 CheckPrintfHandler(
Sema &s,
const FormatStringLiteral *fexpr,
7008 const Expr *origFormatExpr,
7010 unsigned numDataArgs,
bool isObjC,
const char *beg,
7012 unsigned formatIdx,
bool inFunctionCall,
7014 llvm::SmallBitVector &CheckedVarArgs,
7015 UncoveredArgHandler &UncoveredArg)
7016 : CheckFormatHandler(s, fexpr, origFormatExpr, type, firstDataArg,
7017 numDataArgs, beg, hasVAListArg, Args, formatIdx,
7018 inFunctionCall, CallType, CheckedVarArgs,
7024 bool allowsObjCArg()
const {
7029 bool HandleInvalidPrintfConversionSpecifier(
7031 const char *startSpecifier,
7032 unsigned specifierLen)
override;
7035 const char *startSpecifier,
7036 unsigned specifierLen)
override;
7038 const char *StartSpecifier,
7039 unsigned SpecifierLen,
7043 const char *startSpecifier,
unsigned specifierLen);
7047 const char *startSpecifier,
unsigned specifierLen);
7050 const char *startSpecifier,
unsigned specifierLen);
7054 const char *startSpecifier,
unsigned specifierLen);
7058 void HandleEmptyObjCModifierFlag(
const char *startFlag,
7059 unsigned flagLen)
override;
7061 void HandleInvalidObjCModifierFlag(
const char *startFlag,
7062 unsigned flagLen)
override;
7064 void HandleObjCFlagsWithNonObjCConversion(
const char *flagsStart,
7065 const char *flagsEnd,
7066 const char *conversionPosition)
7072 bool CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier(
7074 const char *startSpecifier,
7075 unsigned specifierLen) {
7079 return HandleInvalidConversionSpecifier(FS.
getArgIndex(),
7081 startSpecifier, specifierLen,
7085 bool CheckPrintfHandler::HandleAmount(
7087 unsigned k,
const char *startSpecifier,
7088 unsigned specifierLen) {
7090 if (!HasVAListArg) {
7092 if (argIndex >= NumDataArgs) {
7093 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_asterisk_missing_arg)
7097 getSpecifierRange(startSpecifier, specifierLen));
7107 CoveredArgs.set(argIndex);
7108 const Expr *Arg = getDataArg(argIndex);
7118 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_asterisk_wrong_type)
7123 getSpecifierRange(startSpecifier, specifierLen));
7133 void CheckPrintfHandler::HandleInvalidAmount(
7137 const char *startSpecifier,
7138 unsigned specifierLen) {
7148 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_nonsensical_optional_amount)
7152 getSpecifierRange(startSpecifier, specifierLen),
7158 const char *startSpecifier,
7159 unsigned specifierLen) {
7163 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_nonsensical_flag)
7167 getSpecifierRange(startSpecifier, specifierLen),
7172 void CheckPrintfHandler::HandleIgnoredFlag(
7176 const char *startSpecifier,
7177 unsigned specifierLen) {
7179 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_ignored_flag)
7183 getSpecifierRange(startSpecifier, specifierLen),
7185 getSpecifierRange(ignoredFlag.
getPosition(), 1)));
7188 void CheckPrintfHandler::HandleEmptyObjCModifierFlag(
const char *startFlag,
7191 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_empty_objc_flag),
7192 getLocationOfByte(startFlag),
7194 getSpecifierRange(startFlag, flagLen));
7197 void CheckPrintfHandler::HandleInvalidObjCModifierFlag(
const char *startFlag,
7200 auto Range = getSpecifierRange(startFlag, flagLen);
7201 StringRef flag(startFlag, flagLen);
7202 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_invalid_objc_flag) << flag,
7203 getLocationOfByte(startFlag),
7208 void CheckPrintfHandler::HandleObjCFlagsWithNonObjCConversion(
7209 const char *flagsStart,
const char *flagsEnd,
const char *conversionPosition) {
7211 auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1);
7212 auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion;
7213 EmitFormatDiagnostic(S.
PDiag(diag) << StringRef(conversionPosition, 1),
7214 getLocationOfByte(conversionPosition),
7222 template<
typename MemberKind>
7223 static llvm::SmallPtrSet<MemberKind*, 1>
7226 llvm::SmallPtrSet<MemberKind*, 1> Results;
7243 if (MemberKind *FK = dyn_cast<MemberKind>(decl))
7254 using MethodSet = llvm::SmallPtrSet<CXXMethodDecl *, 1>;
7257 CXXRecordMembersNamed<CXXMethodDecl>(
"c_str", *
this, E->
getType());
7258 for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
7260 if ((*MI)->getMinRequiredArguments() == 0)
7268 bool CheckPrintfHandler::checkForCStrMembers(
7270 using MethodSet = llvm::SmallPtrSet<CXXMethodDecl *, 1>;
7273 CXXRecordMembersNamed<CXXMethodDecl>(
"c_str", S, E->
getType());
7275 for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
7295 const char *startSpecifier,
7296 unsigned specifierLen) {
7297 using namespace analyze_format_string;
7298 using namespace analyze_printf;
7308 HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
7309 startSpecifier, specifierLen);
7317 startSpecifier, specifierLen)) {
7322 startSpecifier, specifierLen)) {
7326 if (!CS.consumesDataArgument()) {
7334 if (argIndex < NumDataArgs) {
7338 CoveredArgs.set(argIndex);
7342 if (CS.getKind() == ConversionSpecifier::FreeBSDbArg ||
7343 CS.getKind() == ConversionSpecifier::FreeBSDDArg) {
7345 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex + 1))
7349 CoveredArgs.set(argIndex + 1);
7352 const Expr *Ex = getDataArg(argIndex);
7354 (CS.getKind() == ConversionSpecifier::FreeBSDbArg) ?
7357 EmitFormatDiagnostic(
7358 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
7362 getSpecifierRange(startSpecifier, specifierLen));
7365 Ex = getDataArg(argIndex + 1);
7368 EmitFormatDiagnostic(
7369 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
7371 <<
false << Ex->getSourceRange(),
7372 Ex->getLocStart(),
false,
7373 getSpecifierRange(startSpecifier, specifierLen));
7380 if (!allowsObjCArg() && CS.isObjCArg()) {
7381 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
7386 if (FSType !=
Sema::FST_OSLog && CS.getKind() == ConversionSpecifier::PArg) {
7387 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
7392 if (FSType ==
Sema::FST_OSLog && CS.getKind() == ConversionSpecifier::nArg) {
7393 EmitFormatDiagnostic(S.
PDiag(diag::warn_os_log_format_narg),
7394 getLocationOfByte(CS.getStart()),
7396 getSpecifierRange(startSpecifier, specifierLen));
7403 (CS.getKind() == ConversionSpecifier::PArg ||
7404 CS.getKind() == ConversionSpecifier::sArg ||
7405 CS.getKind() == ConversionSpecifier::ObjCObjArg)) {
7406 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
7413 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_annotation)
7417 getSpecifierRange(startSpecifier, specifierLen));
7420 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_annotation)
7424 getSpecifierRange(startSpecifier, specifierLen));
7431 startSpecifier, specifierLen);
7437 startSpecifier, specifierLen);
7441 if (CS.getKind() == ConversionSpecifier::PArg &&
7443 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_P_no_precision),
7444 getLocationOfByte(startSpecifier),
7446 getSpecifierRange(startSpecifier, specifierLen));
7455 HandleFlag(FS, FS.
hasPlusPrefix(), startSpecifier, specifierLen);
7457 HandleFlag(FS, FS.
hasSpacePrefix(), startSpecifier, specifierLen);
7466 startSpecifier, specifierLen);
7469 startSpecifier, specifierLen);
7473 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
7474 diag::warn_format_nonsensical_length);
7476 HandleNonStandardLengthModifier(FS, startSpecifier, specifierLen);
7478 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
7479 diag::warn_format_non_standard_conversion_spec);
7482 HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
7488 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex))
7491 const Expr *Arg = getDataArg(argIndex);
7495 return checkFormatExpr(FS, startSpecifier, specifierLen, Arg);
7507 case Stmt::ArraySubscriptExprClass:
7508 case Stmt::CallExprClass:
7509 case Stmt::CharacterLiteralClass:
7510 case Stmt::CXXBoolLiteralExprClass:
7511 case Stmt::DeclRefExprClass:
7512 case Stmt::FloatingLiteralClass:
7513 case Stmt::IntegerLiteralClass:
7514 case Stmt::MemberExprClass:
7515 case Stmt::ObjCArrayLiteralClass:
7516 case Stmt::ObjCBoolLiteralExprClass:
7517 case Stmt::ObjCBoxedExprClass:
7518 case Stmt::ObjCDictionaryLiteralClass:
7519 case Stmt::ObjCEncodeExprClass:
7520 case Stmt::ObjCIvarRefExprClass:
7521 case Stmt::ObjCMessageExprClass:
7522 case Stmt::ObjCPropertyRefExprClass:
7523 case Stmt::ObjCStringLiteralClass:
7524 case Stmt::ObjCSubscriptRefExprClass:
7525 case Stmt::ParenExprClass:
7526 case Stmt::StringLiteralClass:
7527 case Stmt::UnaryOperatorClass:
7534 static std::pair<QualType, StringRef>
7541 StringRef Name = UserTy->getDecl()->getName();
7542 QualType CastTy = llvm::StringSwitch<QualType>(Name)
7546 .Case(
"SInt32", Context.
IntTy)
7551 return std::make_pair(CastTy, Name);
7553 TyTy = UserTy->desugar();
7557 if (
const ParenExpr *PE = dyn_cast<ParenExpr>(E))
7559 PE->getSubExpr()->getType(),
7568 StringRef TrueName, FalseName;
7570 std::tie(TrueTy, TrueName) =
7572 CO->getTrueExpr()->getType(),
7574 std::tie(FalseTy, FalseName) =
7576 CO->getFalseExpr()->getType(),
7577 CO->getFalseExpr());
7579 if (TrueTy == FalseTy)
7580 return std::make_pair(TrueTy, TrueName);
7581 else if (TrueTy.
isNull())
7582 return std::make_pair(FalseTy, FalseName);
7583 else if (FalseTy.
isNull())
7584 return std::make_pair(TrueTy, TrueName);
7587 return std::make_pair(
QualType(), StringRef());
7592 const char *StartSpecifier,
7593 unsigned SpecifierLen,
7595 using namespace analyze_format_string;
7596 using namespace analyze_printf;
7605 while (
const TypeOfExprType *TET = dyn_cast<TypeOfExprType>(ExprTy)) {
7606 ExprTy = TET->getUnderlyingExpr()->getType();
7610 AT.matchesType(S.
Context, ExprTy);
7620 if (ICE->getCastKind() == CK_IntegralCast ||
7621 ICE->getCastKind() == CK_FloatingCast) {
7622 E = ICE->getSubExpr();
7631 if (AT.matchesType(S.
Context, ExprTy))
7645 bool IsEnum =
false;
7647 ExprTy = EnumTy->getDecl()->getIntegerType();
7655 if (isObjCContext() &&
7666 const llvm::APInt &V = IL->getValue();
7676 if (TD->getUnderlyingType() == IntendedTy)
7684 bool ShouldNotPrintDirectly =
false; StringRef CastTyName;
7691 if ((CastTyName ==
"NSInteger" || CastTyName ==
"NSUInteger") &&
7692 (AT.isSizeT() || AT.isPtrdiffT()) &&
7693 AT.matchesType(S.
Context, CastTy))
7695 IntendedTy = CastTy;
7696 ShouldNotPrintDirectly =
true;
7701 PrintfSpecifier fixedFS = FS;
7708 llvm::raw_svector_ostream os(buf);
7709 fixedFS.toString(os);
7711 CharSourceRange SpecRange = getSpecifierRange(StartSpecifier, SpecifierLen);
7713 if (IntendedTy == ExprTy && !ShouldNotPrintDirectly) {
7716 ? diag::warn_format_conversion_argument_type_mismatch_pedantic
7717 : diag::warn_format_conversion_argument_type_mismatch;
7720 EmitFormatDiagnostic(S.
PDiag(Diag)
7721 << AT.getRepresentativeTypeName(S.
Context)
7735 llvm::raw_svector_ostream CastFix(CastBuf);
7741 if (!AT.matchesType(S.
Context, IntendedTy) || ShouldNotPrintDirectly)
7746 SourceRange CastRange(CCast->getLParenLoc(), CCast->getRParenLoc());
7764 if (ShouldNotPrintDirectly) {
7769 if (
const TypedefType *TypedefTy = dyn_cast<TypedefType>(ExprTy))
7770 Name = TypedefTy->getDecl()->getName();
7773 unsigned Diag = Pedantic
7774 ? diag::warn_format_argument_needs_cast_pedantic
7775 : diag::warn_format_argument_needs_cast;
7776 EmitFormatDiagnostic(S.
PDiag(Diag) << Name << IntendedTy << IsEnum
7784 EmitFormatDiagnostic(
7785 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
7786 << AT.getRepresentativeTypeName(S.
Context) << ExprTy << IsEnum
7803 ? diag::warn_format_conversion_argument_type_mismatch_pedantic
7804 : diag::warn_format_conversion_argument_type_mismatch;
7806 EmitFormatDiagnostic(
7807 S.
PDiag(Diag) << AT.getRepresentativeTypeName(S.
Context) << ExprTy
7814 EmitFormatDiagnostic(
7815 S.
PDiag(diag::warn_non_pod_vararg_with_format_string)
7819 << AT.getRepresentativeTypeName(S.
Context)
7823 checkForCStrMembers(AT, E);
7828 EmitFormatDiagnostic(
7829 S.
PDiag(diag::err_cannot_pass_objc_interface_to_vararg_format)
7833 << AT.getRepresentativeTypeName(S.
Context)
7841 << isa<InitListExpr>(E) << ExprTy << CallType
7842 << AT.getRepresentativeTypeName(S.
Context)
7847 assert(FirstDataArg + FS.
getArgIndex() < CheckedVarArgs.size() &&
7848 "format string specifier index out of range");
7849 CheckedVarArgs[FirstDataArg + FS.
getArgIndex()] =
true;
7859 class CheckScanfHandler :
public CheckFormatHandler {
7861 CheckScanfHandler(
Sema &s,
const FormatStringLiteral *fexpr,
7863 unsigned firstDataArg,
unsigned numDataArgs,
7864 const char *beg,
bool hasVAListArg,
7865 ArrayRef<const Expr *> Args,
unsigned formatIdx,
7867 llvm::SmallBitVector &CheckedVarArgs,
7868 UncoveredArgHandler &UncoveredArg)
7869 : CheckFormatHandler(s, fexpr, origFormatExpr, type, firstDataArg,
7870 numDataArgs, beg, hasVAListArg, Args, formatIdx,
7871 inFunctionCall, CallType, CheckedVarArgs,
7875 const char *startSpecifier,
7876 unsigned specifierLen)
override;
7878 bool HandleInvalidScanfConversionSpecifier(
7880 const char *startSpecifier,
7881 unsigned specifierLen)
override;
7883 void HandleIncompleteScanList(
const char *start,
const char *end)
override;
7888 void CheckScanfHandler::HandleIncompleteScanList(
const char *start,
7890 EmitFormatDiagnostic(S.
PDiag(diag::warn_scanf_scanlist_incomplete),
7891 getLocationOfByte(end),
true,
7892 getSpecifierRange(start, end - start));
7895 bool CheckScanfHandler::HandleInvalidScanfConversionSpecifier(
7897 const char *startSpecifier,
7898 unsigned specifierLen) {
7902 return HandleInvalidConversionSpecifier(FS.
getArgIndex(),
7904 startSpecifier, specifierLen,
7908 bool CheckScanfHandler::HandleScanfSpecifier(
7910 const char *startSpecifier,
7911 unsigned specifierLen) {
7912 using namespace analyze_scanf;
7913 using namespace analyze_format_string;
7925 HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
7926 startSpecifier, specifierLen);
7933 if (Amt.getHowSpecified() == OptionalAmount::Constant) {
7934 if (Amt.getConstantAmount() == 0) {
7936 Amt.getConstantLength());
7937 EmitFormatDiagnostic(S.
PDiag(diag::warn_scanf_nonzero_width),
7938 getLocationOfByte(Amt.getStart()),
7952 if (argIndex < NumDataArgs) {
7956 CoveredArgs.set(argIndex);
7961 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
7962 diag::warn_format_nonsensical_length);
7964 HandleNonStandardLengthModifier(FS, startSpecifier, specifierLen);
7966 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
7967 diag::warn_format_non_standard_conversion_spec);
7970 HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
7976 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex))
7980 const Expr *Ex = getDataArg(argIndex);
7996 ScanfSpecifier fixedFS = FS;
8001 Pedantic ? diag::warn_format_conversion_argument_type_mismatch_pedantic
8002 : diag::warn_format_conversion_argument_type_mismatch;
8007 llvm::raw_svector_ostream os(buf);
8008 fixedFS.toString(os);
8010 EmitFormatDiagnostic(
8015 getSpecifierRange(startSpecifier, specifierLen),
8017 getSpecifierRange(startSpecifier, specifierLen), os.str()));
8019 EmitFormatDiagnostic(S.
PDiag(Diag)
8024 getSpecifierRange(startSpecifier, specifierLen));
8031 const Expr *OrigFormatExpr,
8032 ArrayRef<const Expr *> Args,
8033 bool HasVAListArg,
unsigned format_idx,
8034 unsigned firstDataArg,
8036 bool inFunctionCall,
8038 llvm::SmallBitVector &CheckedVarArgs,
8039 UncoveredArgHandler &UncoveredArg) {
8041 if (!FExpr->isAscii() && !FExpr->isUTF8()) {
8042 CheckFormatHandler::EmitFormatDiagnostic(
8043 S, inFunctionCall, Args[format_idx],
8044 S.
PDiag(diag::warn_format_string_is_wide_literal), FExpr->getLocStart(),
8050 StringRef StrRef = FExpr->getString();
8051 const char *Str = StrRef.data();
8055 assert(T &&
"String literal not of constant array type!");
8056 size_t TypeSize = T->
getSize().getZExtValue();
8057 size_t StrLen =
std::min(
std::max(TypeSize,
size_t(1)) - 1, StrRef.size());
8058 const unsigned numDataArgs = Args.size() - firstDataArg;
8062 if (TypeSize <= StrRef.size() &&
8063 StrRef.substr(0, TypeSize).find(
'\0') == StringRef::npos) {
8064 CheckFormatHandler::EmitFormatDiagnostic(
8065 S, inFunctionCall, Args[format_idx],
8066 S.
PDiag(diag::warn_printf_format_string_not_null_terminated),
8067 FExpr->getLocStart(),
8073 if (StrLen == 0 && numDataArgs > 0) {
8074 CheckFormatHandler::EmitFormatDiagnostic(
8075 S, inFunctionCall, Args[format_idx],
8076 S.
PDiag(diag::warn_empty_format_string), FExpr->getLocStart(),
8084 CheckPrintfHandler H(
8085 S, FExpr, OrigFormatExpr, Type, firstDataArg, numDataArgs,
8087 HasVAListArg, Args, format_idx, inFunctionCall, CallType,
8088 CheckedVarArgs, UncoveredArg);
8096 CheckScanfHandler H(S, FExpr, OrigFormatExpr, Type, firstDataArg,
8097 numDataArgs, Str, HasVAListArg, Args, format_idx,
8098 inFunctionCall, CallType, CheckedVarArgs, UncoveredArg);
8110 const char *Str = StrRef.data();
8113 assert(T &&
"String literal not of constant array type!");
8114 size_t TypeSize = T->
getSize().getZExtValue();
8115 size_t StrLen =
std::min(
std::max(TypeSize,
size_t(1)) - 1, StrRef.size());
8126 switch (AbsFunction) {
8130 case Builtin::BI__builtin_abs:
8131 return Builtin::BI__builtin_labs;
8132 case Builtin::BI__builtin_labs:
8133 return Builtin::BI__builtin_llabs;
8134 case Builtin::BI__builtin_llabs:
8137 case Builtin::BI__builtin_fabsf:
8138 return Builtin::BI__builtin_fabs;
8139 case Builtin::BI__builtin_fabs:
8140 return Builtin::BI__builtin_fabsl;
8141 case Builtin::BI__builtin_fabsl:
8144 case Builtin::BI__builtin_cabsf:
8145 return Builtin::BI__builtin_cabs;
8146 case Builtin::BI__builtin_cabs:
8147 return Builtin::BI__builtin_cabsl;
8148 case Builtin::BI__builtin_cabsl:
8151 case Builtin::BIabs:
8152 return Builtin::BIlabs;
8153 case Builtin::BIlabs:
8154 return Builtin::BIllabs;
8155 case Builtin::BIllabs:
8158 case Builtin::BIfabsf:
8159 return Builtin::BIfabs;
8160 case Builtin::BIfabs:
8161 return Builtin::BIfabsl;
8162 case Builtin::BIfabsl:
8165 case Builtin::BIcabsf:
8166 return Builtin::BIcabs;
8167 case Builtin::BIcabs:
8168 return Builtin::BIcabsl;
8169 case Builtin::BIcabsl:
8198 unsigned AbsFunctionKind) {
8199 unsigned BestKind = 0;
8201 for (
unsigned Kind = AbsFunctionKind;
Kind != 0;
8207 else if (Context.
hasSameType(ParamType, ArgType)) {
8230 llvm_unreachable(
"Type not integer, floating, or complex");
8237 switch (ValueKind) {
8242 case Builtin::BI__builtin_fabsf:
8243 case Builtin::BI__builtin_fabs:
8244 case Builtin::BI__builtin_fabsl:
8245 case Builtin::BI__builtin_cabsf:
8246 case Builtin::BI__builtin_cabs:
8247 case Builtin::BI__builtin_cabsl:
8248 return Builtin::BI__builtin_abs;
8249 case Builtin::BIfabsf:
8250 case Builtin::BIfabs:
8251 case Builtin::BIfabsl:
8252 case Builtin::BIcabsf:
8253 case Builtin::BIcabs:
8254 case Builtin::BIcabsl:
8255 return Builtin::BIabs;
8261 case Builtin::BI__builtin_abs:
8262 case Builtin::BI__builtin_labs:
8263 case Builtin::BI__builtin_llabs:
8264 case Builtin::BI__builtin_cabsf:
8265 case Builtin::BI__builtin_cabs:
8266 case Builtin::BI__builtin_cabsl:
8267 return Builtin::BI__builtin_fabsf;
8268 case Builtin::BIabs:
8269 case Builtin::BIlabs:
8270 case Builtin::BIllabs:
8271 case Builtin::BIcabsf:
8272 case Builtin::BIcabs:
8273 case Builtin::BIcabsl:
8274 return Builtin::BIfabsf;
8280 case Builtin::BI__builtin_abs:
8281 case Builtin::BI__builtin_labs:
8282 case Builtin::BI__builtin_llabs:
8283 case Builtin::BI__builtin_fabsf:
8284 case Builtin::BI__builtin_fabs:
8285 case Builtin::BI__builtin_fabsl:
8286 return Builtin::BI__builtin_cabsf;
8287 case Builtin::BIabs:
8288 case Builtin::BIlabs:
8289 case Builtin::BIllabs:
8290 case Builtin::BIfabsf:
8291 case Builtin::BIfabs:
8292 case Builtin::BIfabsl:
8293 return Builtin::BIcabsf;
8296 llvm_unreachable(
"Unable to convert function");
8307 case Builtin::BI__builtin_abs:
8308 case Builtin::BI__builtin_fabs:
8309 case Builtin::BI__builtin_fabsf:
8310 case Builtin::BI__builtin_fabsl:
8311 case Builtin::BI__builtin_labs:
8312 case Builtin::BI__builtin_llabs:
8313 case Builtin::BI__builtin_cabs:
8314 case Builtin::BI__builtin_cabsf:
8315 case Builtin::BI__builtin_cabsl:
8316 case Builtin::BIabs:
8317 case Builtin::BIlabs:
8318 case Builtin::BIllabs:
8319 case Builtin::BIfabs:
8320 case Builtin::BIfabsf:
8321 case Builtin::BIfabsl:
8322 case Builtin::BIcabs:
8323 case Builtin::BIcabsf:
8324 case Builtin::BIcabsl:
8327 llvm_unreachable(
"Unknown Builtin type");
8333 unsigned AbsKind,
QualType ArgType) {
8334 bool EmitHeaderHint =
true;
8335 const char *HeaderName =
nullptr;
8336 const char *FunctionName =
nullptr;
8338 FunctionName =
"std::abs";
8340 HeaderName =
"cstdlib";
8342 HeaderName =
"cmath";
8344 llvm_unreachable(
"Invalid Type");
8353 for (
const auto *I : R) {
8356 FDecl = dyn_cast<
FunctionDecl>(UsingD->getTargetDecl());
8373 EmitHeaderHint =
false;
8385 R.suppressDiagnostics();
8388 if (R.isSingleResult()) {
8391 EmitHeaderHint =
false;
8395 }
else if (!R.empty()) {
8401 S.
Diag(Loc, diag::note_replace_abs_function)
8407 if (!EmitHeaderHint)
8410 S.
Diag(Loc, diag::note_include_header_or_declare) << HeaderName
8414 template <std::
size_t StrLen>
8416 const char (&Str)[StrLen]) {
8428 void Sema::CheckAbsoluteValueFunction(
const CallExpr *Call,
8435 if (AbsKind == 0 && !IsStdAbs)
8444 const char *FunctionName =
8446 Diag(Call->
getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType;
8456 unsigned DiagType = 0;
8462 Diag(Call->
getExprLoc(), diag::warn_pointer_abs) << DiagType << ArgType;
8476 if (ArgValueKind == ParamValueKind) {
8482 << FDecl << ArgType << ParamType;
8484 if (NewAbsKind == 0)
8497 if (NewAbsKind == 0)
8501 << FDecl << ParamValueKind << ArgValueKind;
8508 void Sema::CheckMaxUnsignedZero(
const CallExpr *Call,
8510 if (!Call || !FDecl)
return;
8513 if (inTemplateInstantiation())
return;
8520 if (!ArgList)
return;
8521 if (ArgList->size() != 1)
return;
8524 const auto& TA = ArgList->
get(0);
8530 auto IsLiteralZeroArg = [](
const Expr* E) ->
bool {
8532 if (!MTE)
return false;
8533 const auto *Num = dyn_cast<
IntegerLiteral>(MTE->GetTemporaryExpr());
8534 if (!Num)
return false;
8535 if (Num->getValue() != 0)
return false;
8541 const bool IsFirstArgZero = IsLiteralZeroArg(FirstArg);
8542 const bool IsSecondArgZero = IsLiteralZeroArg(SecondArg);
8545 if (IsFirstArgZero == IsSecondArgZero)
return;
8550 SourceRange ZeroRange = IsFirstArgZero ? FirstRange : SecondRange;
8557 if (IsFirstArgZero) {
8590 << SizeRange << FnName;
8591 S.
Diag(FnLoc, diag::note_memsize_comparison_paren)
8595 S.
Diag(SizeRange.
getBegin(), diag::note_memsize_comparison_cast_silence)
8606 bool &IsContained) {
8609 IsContained =
false;
8622 for (
auto *FD : RD->
fields()) {
8635 if (
const auto *Unary = dyn_cast<UnaryExprOrTypeTraitExpr>(E))
8645 if (!SizeOf->isArgumentType())
8653 return SizeOf->getTypeOfArgument();
8659 struct SearchNonTrivialToInitializeField
8664 SearchNonTrivialToInitializeField(
const Expr *E,
Sema &S) : E(E), S(S) {}
8668 if (
const auto *AT = asDerived().getContext().getAsArrayType(FT)) {
8669 asDerived().visitArray(PDIK, AT, SL);
8673 Super::visitWithKind(PDIK, FT, SL);
8684 visit(FD->getType(), FD->getLocation());
8688 visit(getContext().getBaseElementType(AT), SL);
8693 SearchNonTrivialToInitializeField(E, S).visitStruct(RT,
SourceLocation());
8702 struct SearchNonTrivialToCopyField
8706 SearchNonTrivialToCopyField(
const Expr *E,
Sema &S) : E(E), S(S) {}
8710 if (
const auto *AT = asDerived().getContext().getAsArrayType(FT)) {
8711 asDerived().visitArray(PCK, AT, SL);
8715 Super::visitWithKind(PCK, FT, SL);
8726 visit(FD->getType(), FD->getLocation());
8730 visit(getContext().getBaseElementType(AT), SL);
8738 SearchNonTrivialToCopyField(E, S).visitStruct(RT,
SourceLocation());
8753 if (
const auto *BO = dyn_cast<BinaryOperator>(SizeofExpr)) {
8754 if (BO->getOpcode() != BO_Mul && BO->getOpcode() != BO_Add)
8787 if (BId != Builtin::BImemset && BId != Builtin::BIbzero)
8790 const Expr *SizeArg =
8793 auto isLiteralZero = [](
const Expr *E) {
8794 return isa<IntegerLiteral>(E) && cast<IntegerLiteral>(E)->getValue() == 0;
8800 if (isLiteralZero(SizeArg) &&
8807 if (BId == Builtin::BIbzero ||
8810 S.
Diag(DiagLoc, diag::warn_suspicious_bzero_size);
8811 S.
Diag(DiagLoc, diag::note_suspicious_bzero_size_silence);
8813 S.
Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 0;
8814 S.
Diag(DiagLoc, diag::note_suspicious_sizeof_memset_silence) << 0;
8822 if (BId == Builtin::BImemset &&
8826 S.
Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 1;
8827 S.
Diag(DiagLoc, diag::note_suspicious_sizeof_memset_silence) << 1;
8839 void Sema::CheckMemaccessArguments(
const CallExpr *Call,
8846 unsigned ExpectedNumArgs =
8847 (BId == Builtin::BIstrndup || BId == Builtin::BIbzero ? 2 : 3);
8851 unsigned LastArg = (BId == Builtin::BImemset || BId == Builtin::BIbzero ||
8852 BId == Builtin::BIstrndup ? 1 : 2);
8854 (BId == Builtin::BIbzero || BId == Builtin::BIstrndup ? 1 : 2);
8867 llvm::FoldingSetNodeID SizeOfArgID;
8876 for (
unsigned ArgIdx = 0; ArgIdx != LastArg; ++ArgIdx) {
8895 !Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess,
8899 if (SizeOfArgID == llvm::FoldingSetNodeID())
8900 SizeOfArg->
Profile(SizeOfArgID, Context,
true);
8901 llvm::FoldingSetNodeID DestID;
8902 Dest->
Profile(DestID, Context,
true);
8903 if (DestID == SizeOfArgID) {
8906 unsigned ActionIdx = 0;
8907 StringRef ReadableName = FnName->
getName();
8909 if (
const UnaryOperator *UnaryOp = dyn_cast<UnaryOperator>(Dest))
8910 if (UnaryOp->getOpcode() == UO_AddrOf)
8933 DiagRuntimeBehavior(SL, SizeOfArg,
8934 PDiag(diag::warn_sizeof_pointer_expr_memaccess)
8940 DiagRuntimeBehavior(SL, SizeOfArg,
8941 PDiag(diag::warn_sizeof_pointer_expr_memaccess_note)
8955 DiagRuntimeBehavior(LenExpr->
getExprLoc(), Dest,
8956 PDiag(diag::warn_sizeof_pointer_type_memaccess)
8957 << FnName << SizeOfArgTy << ArgIdx
8975 unsigned OperationType = 0;
8978 if (ArgIdx != 0 || BId == Builtin::BImemcmp) {
8979 if (BId == Builtin::BImemcpy)
8981 else if(BId == Builtin::BImemmove)
8983 else if (BId == Builtin::BImemcmp)
8987 DiagRuntimeBehavior(
8989 PDiag(diag::warn_dyn_class_memaccess)
8990 << (BId == Builtin::BImemcmp ? ArgIdx + 2 : ArgIdx)
8991 << FnName << IsContained << ContainedRD << OperationType
8994 BId != Builtin::BImemset)
8995 DiagRuntimeBehavior(
8997 PDiag(diag::warn_arc_object_memaccess)
8998 << ArgIdx << FnName << PointeeTy
9001 if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
9002 RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize()) {
9003 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9004 PDiag(diag::warn_cstruct_memaccess)
9005 << ArgIdx << FnName << PointeeTy << 0);
9006 SearchNonTrivialToInitializeField::diag(PointeeTy, Dest, *
this);
9007 }
else if ((BId == Builtin::BImemcpy || BId == Builtin::BImemmove) &&
9008 RT->getDecl()->isNonTrivialToPrimitiveCopy()) {
9009 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9010 PDiag(diag::warn_cstruct_memaccess)
9011 << ArgIdx << FnName << PointeeTy << 1);
9012 SearchNonTrivialToCopyField::diag(PointeeTy, Dest, *
this);
9019 DiagRuntimeBehavior(
9021 PDiag(diag::note_bad_memaccess_silence)
9041 if (isa<IntegerLiteral>(RHS))
9043 else if (isa<IntegerLiteral>(LHS))
9057 if (CAT->getSize().getSExtValue() <= 1)
9067 void Sema::CheckStrlcpycatArguments(
const CallExpr *Call,
9072 if ((NumArgs != 3) && (NumArgs != 4))
9077 const Expr *CompareWithSrc =
nullptr;
9085 CompareWithSrc = Ex;
9088 if (
const CallExpr *SizeCall = dyn_cast<CallExpr>(SizeArg)) {
9089 if (SizeCall->getBuiltinCallee() == Builtin::BIstrlen &&
9090 SizeCall->getNumArgs() == 1)
9095 if (!CompareWithSrc)
9107 if (!CompareWithSrcDRE ||
9111 const Expr *OriginalSizeArg = Call->
getArg(2);
9112 Diag(CompareWithSrcDRE->
getLocStart(), diag::warn_strlcpycat_wrong_size)
9124 llvm::raw_svector_ostream OS(sizeString);
9126 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9129 Diag(OriginalSizeArg->
getLocStart(), diag::note_strlcpycat_wrong_size)
9136 if (
const DeclRefExpr *D1 = dyn_cast_or_null<DeclRefExpr>(E1))
9137 if (
const DeclRefExpr *D2 = dyn_cast_or_null<DeclRefExpr>(E2))
9138 return D1->getDecl() == D2->getDecl();
9143 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
9147 return CE->getArg(0)->IgnoreParenCasts();
9155 void Sema::CheckStrncatArguments(
const CallExpr *CE,
9170 unsigned PatternType = 0;
9178 }
else if (
const BinaryOperator *BE = dyn_cast<BinaryOperator>(LenArg)) {
9179 if (BE->getOpcode() == BO_Sub) {
9192 if (PatternType == 0)
9211 if (!isKnownSizeArray) {
9212 if (PatternType == 1)
9213 Diag(SL, diag::warn_strncat_wrong_size) << SR;
9215 Diag(SL, diag::warn_strncat_src_size) << SR;
9219 if (PatternType == 1)
9220 Diag(SL, diag::warn_strncat_large_size) << SR;
9222 Diag(SL, diag::warn_strncat_src_size) << SR;
9225 llvm::raw_svector_ostream OS(sizeString);
9227 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9230 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9233 Diag(SL, diag::note_strncat_wrong_size)
9238 Sema::CheckReturnValExpr(
Expr *RetValExp,
QualType lhsType,
9244 if (((Attrs && hasSpecificAttr<ReturnsNonNullAttr>(*Attrs)) ||
9247 Diag(ReturnLoc, diag::warn_null_ret)
9257 if (Op == OO_New || Op == OO_Array_New) {
9262 Diag(ReturnLoc, diag::warn_operator_new_returns_null)
9263 << FD << getLangOpts().CPlusPlus11;
9279 if (
DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(LeftExprSansParen))
9280 if (
DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(RightExprSansParen))
9281 if (DRL->getDecl() == DRR->getDecl())
9289 if (
FloatingLiteral* FLL = dyn_cast<FloatingLiteral>(LeftExprSansParen)) {
9293 if (
FloatingLiteral* FLR = dyn_cast<FloatingLiteral>(RightExprSansParen))
9298 if (
CallExpr* CL = dyn_cast<CallExpr>(LeftExprSansParen))
9299 if (CL->getBuiltinCallee())
9302 if (
CallExpr* CR = dyn_cast<CallExpr>(RightExprSansParen))
9303 if (CR->getBuiltinCallee())
9307 Diag(Loc, diag::warn_floatingpoint_eq)
9325 IntRange(
unsigned Width,
bool NonNegative)
9326 : Width(Width), NonNegative(NonNegative) {}
9329 static IntRange forBoolType() {
9330 return IntRange(1,
true);
9335 return forValueOfCanonicalType(C,
9340 static IntRange forValueOfCanonicalType(
ASTContext &C,
const Type *T) {
9343 if (
const VectorType *VT = dyn_cast<VectorType>(T))
9344 T = VT->getElementType().getTypePtr();
9345 if (
const ComplexType *CT = dyn_cast<ComplexType>(T))
9346 T = CT->getElementType().getTypePtr();
9347 if (
const AtomicType *AT = dyn_cast<AtomicType>(T))
9348 T = AT->getValueType().getTypePtr();
9352 if (
const EnumType *ET = dyn_cast<EnumType>(T))
9353 T = ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
9354 }
else if (
const EnumType *ET = dyn_cast<EnumType>(T)) {
9361 !ET->isSignedIntegerOrEnumerationType());
9367 if (NumNegative == 0)
9368 return IntRange(NumPositive,
true);
9370 return IntRange(
std::max(NumPositive + 1, NumNegative),
9385 static IntRange forTargetOfCanonicalType(
ASTContext &C,
const Type *T) {
9388 if (
const VectorType *VT = dyn_cast<VectorType>(T))
9389 T = VT->getElementType().getTypePtr();
9390 if (
const ComplexType *CT = dyn_cast<ComplexType>(T))
9391 T = CT->getElementType().getTypePtr();
9392 if (
const AtomicType *AT = dyn_cast<AtomicType>(T))
9393 T = AT->getValueType().getTypePtr();
9394 if (
const EnumType *ET = dyn_cast<EnumType>(T))
9404 static IntRange join(IntRange L, IntRange R) {
9405 return IntRange(
std::max(L.Width, R.Width),
9406 L.NonNegative && R.NonNegative);
9410 static IntRange meet(IntRange L, IntRange R) {
9411 return IntRange(
std::min(L.Width, R.Width),
9412 L.NonNegative || R.NonNegative);
9419 unsigned MaxWidth) {
9420 if (value.isSigned() && value.isNegative())
9421 return IntRange(value.getMinSignedBits(),
false);
9423 if (value.getBitWidth() > MaxWidth)
9424 value = value.trunc(MaxWidth);
9428 return IntRange(value.getActiveBits(),
true);
9432 unsigned MaxWidth) {
9440 R = IntRange::join(R, El);
9448 return IntRange::join(R, I);
9463 Ty = AtomicRHS->getValueType();
9482 if (
const auto *CE = dyn_cast<ImplicitCastExpr>(E)) {
9483 if (CE->getCastKind() == CK_NoOp || CE->getCastKind() == CK_LValueToRValue)
9486 IntRange OutputTypeRange = IntRange::forValueOfType(C,
GetExprType(CE));
9488 bool isIntegerCast = CE->getCastKind() == CK_IntegralCast ||
9489 CE->getCastKind() == CK_BooleanToSignedIntegral;
9493 return OutputTypeRange;
9497 std::min(MaxWidth, OutputTypeRange.Width));
9500 if (SubRange.Width >= OutputTypeRange.Width)
9501 return OutputTypeRange;
9505 return IntRange(SubRange.Width,
9506 SubRange.NonNegative || OutputTypeRange.NonNegative);
9509 if (
const auto *CO = dyn_cast<ConditionalOperator>(E)) {
9512 if (CO->getCond()->EvaluateAsBooleanCondition(CondResult, C))
9514 : CO->getFalseExpr(),
9518 IntRange L =
GetExprRange(C, CO->getTrueExpr(), MaxWidth);
9519 IntRange R =
GetExprRange(C, CO->getFalseExpr(), MaxWidth);
9520 return IntRange::join(L, R);
9523 if (
const auto *BO = dyn_cast<BinaryOperator>(E)) {
9524 switch (BO->getOpcode()) {
9526 llvm_unreachable(
"builtin <=> should have class type");
9537 return IntRange::forBoolType();
9549 return IntRange::forValueOfType(C,
GetExprType(E));
9560 return IntRange::forValueOfType(C,
GetExprType(E));
9565 return IntRange::meet(
GetExprRange(C, BO->getLHS(), MaxWidth),
9573 = dyn_cast<IntegerLiteral>(BO->getLHS()->IgnoreParenCasts())) {
9574 if (I->getValue() == 1) {
9575 IntRange R = IntRange::forValueOfType(C,
GetExprType(E));
9576 return IntRange(R.Width,
true);
9582 return IntRange::forValueOfType(C,
GetExprType(E));
9586 case BO_ShrAssign: {
9592 if (BO->getRHS()->isIntegerConstantExpr(shift, C) &&
9593 shift.isNonNegative()) {
9594 unsigned zext = shift.getZExtValue();
9595 if (zext >= L.Width)
9596 L.Width = (L.NonNegative ? 0 : 1);
9610 if (BO->getLHS()->getType()->isPointerType())
9611 return IntRange::forValueOfType(C,
GetExprType(E));
9622 llvm::APSInt divisor;
9623 if (BO->getRHS()->isIntegerConstantExpr(divisor, C)) {
9624 unsigned log2 = divisor.logBase2();
9625 if (log2 >= L.Width)
9626 L.Width = (L.NonNegative ? 0 : 1);
9628 L.Width =
std::min(L.Width - log2, MaxWidth);
9634 return IntRange(L.Width, L.NonNegative && R.NonNegative);
9645 IntRange meet = IntRange::meet(L, R);
9646 meet.Width =
std::min(meet.Width, MaxWidth);
9662 return IntRange::join(L, R);
9665 if (
const auto *UO = dyn_cast<UnaryOperator>(E)) {
9666 switch (UO->getOpcode()) {
9669 return IntRange::forBoolType();
9674 return IntRange::forValueOfType(C,
GetExprType(E));
9681 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
9682 return GetExprRange(C, OVE->getSourceExpr(), MaxWidth);
9685 return IntRange(BitField->getBitWidthValue(C),
9686 BitField->getType()->isUnsignedIntegerOrEnumerationType());
9688 return IntRange::forValueOfType(C,
GetExprType(E));
9699 const llvm::fltSemantics &Src,
9700 const llvm::fltSemantics &Tgt) {
9701 llvm::APFloat truncated = value;
9704 truncated.convert(Src, llvm::APFloat::rmNearestTiesToEven, &ignored);
9705 truncated.convert(Tgt, llvm::APFloat::rmNearestTiesToEven, &ignored);
9707 return truncated.bitwiseIsEqual(value);
9716 const llvm::fltSemantics &Src,
9717 const llvm::fltSemantics &Tgt) {
9739 if (isa<EnumConstantDecl>(DR->getDecl()))
9766 struct PromotedRange {
9768 llvm::APSInt PromotedMin;
9770 llvm::APSInt PromotedMax;
9772 PromotedRange(IntRange R,
unsigned BitWidth,
bool Unsigned) {
9774 PromotedMin = PromotedMax = llvm::APSInt(BitWidth, Unsigned);
9775 else if (R.Width >= BitWidth && !Unsigned) {
9779 PromotedMin = llvm::APSInt::getMinValue(BitWidth, Unsigned);
9780 PromotedMax = llvm::APSInt::getMaxValue(BitWidth, Unsigned);
9782 PromotedMin = llvm::APSInt::getMinValue(R.Width, R.NonNegative)
9783 .extOrTrunc(BitWidth);
9784 PromotedMin.setIsUnsigned(Unsigned);
9786 PromotedMax = llvm::APSInt::getMaxValue(R.Width, R.NonNegative)
9787 .extOrTrunc(BitWidth);
9788 PromotedMax.setIsUnsigned(Unsigned);
9793 bool isContiguous()
const {
return PromotedMin <= PromotedMax; }
9796 enum ComparisonResult {
9805 Less = LE | LT | NE,
9806 Min = LE | InRangeFlag,
9807 InRange = InRangeFlag,
9808 Max = GE | InRangeFlag,
9811 OnlyValue = LE | GE | EQ | InRangeFlag,
9815 ComparisonResult
compare(
const llvm::APSInt &
Value)
const {
9816 assert(Value.getBitWidth() == PromotedMin.getBitWidth() &&
9817 Value.isUnsigned() == PromotedMin.isUnsigned());
9818 if (!isContiguous()) {
9819 assert(Value.isUnsigned() &&
"discontiguous range for signed compare");
9820 if (Value.isMinValue())
return Min;
9821 if (Value.isMaxValue())
return Max;
9822 if (Value >= PromotedMin)
return InRange;
9823 if (Value <= PromotedMax)
return InRange;
9827 switch (llvm::APSInt::compareValues(Value, PromotedMin)) {
9828 case -1:
return Less;
9829 case 0:
return PromotedMin == PromotedMax ? OnlyValue : Min;
9831 switch (llvm::APSInt::compareValues(Value, PromotedMax)) {
9832 case -1:
return InRange;
9838 llvm_unreachable(
"impossible compare result");
9844 ComparisonResult LTFlag = LT, GTFlag = GT;
9845 if (ConstantOnRHS) std::swap(LTFlag, GTFlag);
9847 if (R & EQ)
return StringRef(
"'std::strong_ordering::equal'");
9848 if (R & LTFlag)
return StringRef(
"'std::strong_ordering::less'");
9849 if (R & GTFlag)
return StringRef(
"'std::strong_ordering::greater'");
9853 ComparisonResult TrueFlag, FalseFlag;
9857 }
else if (Op == BO_NE) {
9861 if ((Op == BO_LT || Op == BO_GE) ^ ConstantOnRHS) {
9868 if (Op == BO_GE || Op == BO_LE)
9869 std::swap(TrueFlag, FalseFlag);
9872 return StringRef(
"true");
9874 return StringRef(
"false");
9883 if (ICE->getCastKind() != CK_IntegralCast &&
9884 ICE->getCastKind() != CK_NoOp)
9886 E = ICE->getSubExpr();
9895 enum ConstantValueKind {
9900 if (
auto *BL = dyn_cast<CXXBoolLiteralExpr>(Constant))
9901 return BL->getValue() ? ConstantValueKind::LiteralTrue
9902 : ConstantValueKind::LiteralFalse;
9903 return ConstantValueKind::Miscellaneous;
9908 const llvm::APSInt &
Value,
9913 Expr *OriginalOther = Other;
9933 OtherT = AT->getValueType();
9934 IntRange OtherRange = IntRange::forValueOfType(S.
Context, OtherT);
9938 bool OtherIsBooleanDespiteType =
9940 if (OtherIsBooleanDespiteType)
9941 OtherRange = IntRange::forBoolType();
9945 PromotedRange OtherPromotedRange(OtherRange, Value.getBitWidth(),
9946 Value.isUnsigned());
9947 auto Cmp = OtherPromotedRange.compare(Value);
9948 auto Result = PromotedRange::constantValue(E->
getOpcode(), Cmp, RhsConstant);
9958 bool InRange = Cmp & PromotedRange::InRangeFlag;
9965 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Constant))
9966 ED = dyn_cast<EnumConstantDecl>(DR->getDecl());
9970 llvm::raw_svector_ostream OS(PrettySourceValue);
9972 OS <<
'\'' << *ED <<
"' (" << Value <<
")";
9982 S.
PDiag(!InRange ? diag::warn_out_of_range_compare
9983 : diag::warn_tautological_bool_compare)
9985 << OtherT << OtherIsBooleanDespiteType << *Result
9990 ? diag::warn_unsigned_enum_always_true_comparison
9991 : diag::warn_unsigned_always_true_comparison)
9992 : diag::warn_tautological_constant_compare;
9995 << RhsConstant << OtherT << E->
getOpcodeStr() << OS.str() << *Result
10029 llvm::APSInt RHSValue;
10030 llvm::APSInt LHSValue;
10036 if (IsRHSIntegralLiteral && IsLHSIntegralLiteral)
10040 if (IsRHSIntegralLiteral ^ IsLHSIntegralLiteral) {
10042 const bool RhsConstant = IsRHSIntegralLiteral;
10043 Expr *Const = RhsConstant ? RHS : LHS;
10044 Expr *Other = RhsConstant ? LHS : RHS;
10045 const llvm::APSInt &
Value = RhsConstant ? RHSValue : LHSValue;
10068 if (
const auto *TET = dyn_cast<TypeOfExprType>(LHS->
getType()))
10070 if (
const auto *TET = dyn_cast<TypeOfExprType>(RHS->
getType()))
10076 Expr *signedOperand, *unsignedOperand;
10079 "unsigned comparison between two signed integer expressions?");
10080 signedOperand = LHS;
10081 unsignedOperand = RHS;
10083 signedOperand = RHS;
10084 unsignedOperand = LHS;
10098 if (signedRange.NonNegative)
10111 assert(unsignedRange.NonNegative &&
"unsigned range includes negative?");
10113 if (unsignedRange.Width < comparisonWidth)
10118 S.
PDiag(diag::warn_mixed_sign_comparison)
10146 S.
Diag(InitLoc, diag::warn_no_underlying_type_specified_for_enum_bitfield)
10164 llvm::APSInt
Value;
10184 unsigned DiagID = 0;
10185 if (SignedEnum && !SignedBitfield) {
10186 DiagID = diag::warn_unsigned_bitfield_assigned_signed_enum;
10187 }
else if (SignedBitfield && !SignedEnum &&
10189 DiagID = diag::warn_signed_bitfield_enum_conversion;
10193 S.
Diag(InitLoc, DiagID) << Bitfield << ED;
10198 << SignedEnum << TypeRange;
10209 if (BitsNeeded > FieldWidth) {
10211 S.
Diag(InitLoc, diag::warn_bitfield_too_small_for_enum)
10221 unsigned OriginalWidth = Value.getBitWidth();
10223 if (!Value.isSigned() || Value.isNegative())
10224 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(OriginalInit))
10225 if (UO->getOpcode() == UO_Minus || UO->getOpcode() == UO_Not)
10226 OriginalWidth = Value.getMinSignedBits();
10228 if (OriginalWidth <= FieldWidth)
10232 llvm::APSInt TruncatedValue = Value.trunc(FieldWidth);
10236 TruncatedValue = TruncatedValue.extend(OriginalWidth);
10237 if (llvm::APSInt::isSameValue(Value, TruncatedValue))
10242 if (FieldWidth == 1 && Value == 1)
10245 std::string PrettyValue = Value.toString(10);
10246 std::string PrettyTrunc = TruncatedValue.toString(10);
10248 S.
Diag(InitLoc, diag::warn_impcast_bitfield_precision_constant)
10249 << PrettyValue << PrettyTrunc << OriginalInit->
getType()
10278 bool pruneControlFlow =
false) {
10279 if (pruneControlFlow) {
10293 unsigned diag,
bool pruneControlFlow =
false) {
10300 assert(isa<CompoundAssignOperator>(E) &&
10301 "Must be compound assignment operation");
10308 const auto *RBT = cast<CompoundAssignOperator>(E)
10309 ->getComputationResultType()
10313 if (ResultBT && ResultBT->isFloatingPoint() && RBT && RBT->
isFloatingPoint())
10315 if (ResultBT->getKind() < RBT->
getKind())
10321 diag::warn_impcast_float_result_precision);
10333 if (UOp->getOpcode() == UO_Minus || UOp->getOpcode() == UO_Plus)
10336 const bool IsLiteral =
10337 isa<FloatingLiteral>(E) || isa<FloatingLiteral>(InnerE);
10339 llvm::APFloat
Value(0.0);
10344 diag::warn_impcast_float_integer, PruneWarnings);
10347 bool isExact =
false;
10351 llvm::APFloat::opStatus Result = Value.convertToInteger(
10352 IntegerValue, llvm::APFloat::rmTowardZero, &isExact);
10354 if (Result == llvm::APFloat::opOK && isExact) {
10355 if (IsLiteral)
return;
10356 return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer,
10362 if (!IsBool && Result == llvm::APFloat::opInvalidOp)
10365 IsLiteral ? diag::warn_impcast_literal_float_to_integer_out_of_range
10366 : diag::warn_impcast_float_to_integer_out_of_range,
10369 unsigned DiagID = 0;
10372 DiagID = diag::warn_impcast_literal_float_to_integer;
10373 }
else if (IntegerValue == 0) {
10374 if (Value.isZero()) {
10376 diag::warn_impcast_float_integer, PruneWarnings);
10379 DiagID = diag::warn_impcast_float_to_integer_zero;
10381 if (IntegerValue.isUnsigned()) {
10382 if (!IntegerValue.isMaxValue()) {
10384 diag::warn_impcast_float_integer, PruneWarnings);
10387 if (!IntegerValue.isMaxSignedValue() &&
10388 !IntegerValue.isMinSignedValue()) {
10390 diag::warn_impcast_float_integer, PruneWarnings);
10394 DiagID = diag::warn_impcast_float_to_integer;
10403 unsigned precision = llvm::APFloat::semanticsPrecision(Value.getSemantics());
10404 precision = (precision * 59 + 195) / 196;
10405 Value.toString(PrettySourceValue, precision);
10409 PrettyTargetValue = Value.isZero() ?
"false" :
"true";
10411 IntegerValue.toString(PrettyTargetValue);
10413 if (PruneWarnings) {
10417 << PrettySourceValue << PrettyTargetValue
10428 if (!Range.Width)
return "0";
10430 llvm::APSInt ValueInRange =
Value;
10431 ValueInRange.setIsSigned(!Range.NonNegative);
10432 ValueInRange = ValueInRange.trunc(Range.Width);
10433 return ValueInRange.toString(10);
10437 if (!isa<ImplicitCastExpr>(Ex))
10442 const Type *Source =
10449 const Type *BoolCandidateType = ToBool ?
Target : Source;
10451 return (BoolCandidateType->isSpecificBuiltinType(BuiltinType::Bool) &&
10458 for (
unsigned i = 0; i < NumArgs; ++i) {
10463 bool IsSwapped = ((i > 0) &&
10465 IsSwapped |= ((i < (NumArgs - 1)) &&
10471 diag::warn_impcast_floating_point_to_bool);
10478 if (S.
Diags.
isIgnored(diag::warn_impcast_null_pointer_to_integer,
10483 if (isa<CallExpr>(E))
10509 if (MacroName ==
"NULL")
10517 S.
Diag(Loc, diag::warn_impcast_null_pointer_to_integer)
10535 unsigned ElementKind) {
10537 if (
auto ICE = dyn_cast<ImplicitCastExpr>(Element)) {
10538 if (ICE->getCastKind() == CK_BitCast &&
10540 Element = ICE->getSubExpr();
10551 diag::warn_objc_collection_literal_element)
10552 << ElementType << ElementKind << TargetElementType
10556 if (
auto ArrayLiteral = dyn_cast<ObjCArrayLiteral>(Element))
10558 else if (
auto DictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(Element))
10570 if (!TargetObjCPtr)
10573 if (TargetObjCPtr->isUnspecialized() ||
10574 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
10579 if (TypeArgs.size() != 1)
10582 QualType TargetElementType = TypeArgs[0];
10583 for (
unsigned I = 0, N = ArrayLiteral->
getNumElements(); I != N; ++I) {
10599 if (!TargetObjCPtr)
10602 if (TargetObjCPtr->isUnspecialized() ||
10603 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
10608 if (TypeArgs.size() != 2)
10611 QualType TargetKeyType = TypeArgs[0];
10612 QualType TargetObjectType = TypeArgs[1];
10613 for (
unsigned I = 0, N = DictionaryLiteral->
getNumElements(); I != N; ++I) {
10628 const char FirstLiteralCharacter =
10630 if (FirstLiteralCharacter ==
'0')
10637 const char FirstContextCharacter =
10639 if (FirstContextCharacter ==
'{')
10648 bool *ICContext =
nullptr) {
10653 if (Source == Target)
return;
10666 if (isa<StringLiteral>(E))
10671 diag::warn_impcast_string_literal_to_bool);
10672 if (isa<ObjCStringLiteral>(E) || isa<ObjCArrayLiteral>(E) ||
10673 isa<ObjCDictionaryLiteral>(E) || isa<ObjCBoxedExpr>(E)) {
10677 diag::warn_impcast_objective_c_literal_to_bool);
10688 if (
auto *ArrayLiteral = dyn_cast<ObjCArrayLiteral>(E))
10690 else if (
auto *DictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(E))
10694 if (isa<VectorType>(Source)) {
10695 if (!isa<VectorType>(Target)) {
10698 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_vector_scalar);
10706 Source = cast<VectorType>(Source)->getElementType().getTypePtr();
10707 Target = cast<VectorType>(
Target)->getElementType().getTypePtr();
10709 if (
auto VecTy = dyn_cast<VectorType>(Target))
10710 Target = VecTy->getElementType().getTypePtr();
10713 if (isa<ComplexType>(Source)) {
10714 if (!isa<ComplexType>(Target)) {
10720 ? diag::err_impcast_complex_scalar
10721 : diag::warn_impcast_complex_scalar);
10724 Source = cast<ComplexType>(Source)->getElementType().getTypePtr();
10725 Target = cast<ComplexType>(
Target)->getElementType().getTypePtr();
10734 if (TargetBT && TargetBT->isFloatingPoint()) {
10738 if (SourceBT->
getKind() > TargetBT->getKind()) {
10756 else if (TargetBT->getKind() > SourceBT->
getKind()) {
10766 if (TargetBT && TargetBT->isInteger()) {
10785 CallExpr *CEx = cast<CallExpr>(E);
10789 if (isa<ImplicitCastExpr>(LastA) &&
10793 diag::warn_impcast_floating_point_to_bool);
10813 IntRange TargetRange = IntRange::forTargetOfCanonicalType(S.
Context, Target);
10815 if (SourceRange.Width > TargetRange.Width) {
10818 llvm::APSInt
Value(32);
10823 std::string PrettySourceValue = Value.toString(10);
10827 S.
PDiag(diag::warn_impcast_integer_precision_constant)
10828 << PrettySourceValue << PrettyTargetValue
10839 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_64_32,
10841 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_precision);
10844 if (TargetRange.Width == SourceRange.Width && !TargetRange.NonNegative &&
10850 llvm::APSInt
Value;
10854 std::string PrettySourceValue = Value.toString(10);
10859 S.
PDiag(diag::warn_impcast_integer_precision_constant)
10860 << PrettySourceValue << PrettyTargetValue << E->
getType() << T
10869 if ((TargetRange.NonNegative && !SourceRange.NonNegative) ||
10870 (!TargetRange.NonNegative && SourceRange.NonNegative &&
10871 SourceRange.Width == TargetRange.Width)) {
10875 unsigned DiagID = diag::warn_impcast_integer_sign;
10883 DiagID = diag::warn_impcast_integer_sign_conditional;
10897 EnumDecl *Enum = cast<EnumDecl>(ECD->getDeclContext());
10905 if (SourceEnum->getDecl()->hasNameForLinkage() &&
10906 TargetEnum->getDecl()->hasNameForLinkage() &&
10907 SourceEnum != TargetEnum) {
10912 diag::warn_impcast_different_enum_types);
10923 if (isa<ConditionalOperator>(E))
10935 bool Suspicious =
false;
10941 if (!Suspicious)
return;
10944 if (!S.
Diags.
isIgnored(diag::warn_impcast_integer_sign_conditional, CC))
10949 if (E->
getType() == T)
return;
10951 Suspicious =
false;
10953 E->
getType(), CC, &Suspicious);
10956 E->
getType(), CC, &Suspicious);
10980 if (isa<ConditionalOperator>(E)) {
10987 if (
CallExpr *Call = dyn_cast<CallExpr>(E))
11002 for (
auto *SE : POE->semantics())
11003 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(SE))
11008 if (isa<ExplicitCastExpr>(E)) {
11015 if (BO->isComparisonOp())
11019 if (BO->getOpcode() == BO_Assign)
11022 if (BO->isAssignmentOp())
11030 if (isa<StmtExpr>(E))
return;
11033 if (isa<UnaryExprOrTypeTraitExpr>(E))
return;
11038 bool IsLogicalAndOperator = BO && BO->
getOpcode() == BO_LAnd;
11040 Expr *ChildExpr = dyn_cast_or_null<Expr>(SubStmt);
11044 if (IsLogicalAndOperator &&
11054 if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
11058 if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
11063 if (U->getOpcode() == UO_LNot)
11073 diag::err_opencl_enqueue_kernel_invalid_local_size_type);
11090 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11091 if (!DRE->getDecl()->getType()->isReferenceType())
11093 }
else if (
const MemberExpr *M = dyn_cast<MemberExpr>(E)) {
11094 if (!M->getMemberDecl()->getType()->isReferenceType())
11096 }
else if (
const CallExpr *Call = dyn_cast<CallExpr>(E)) {
11108 SemaRef.
Diag(FD->
getLocation(), diag::note_reference_is_return_value) << FD;
11153 if (isa<CXXThisExpr>(E)) {
11154 unsigned DiagID = IsCompare ? diag::warn_this_null_compare
11155 : diag::warn_this_bool_conversion;
11160 bool IsAddressOf =
false;
11163 if (UO->getOpcode() != UO_AddrOf)
11165 IsAddressOf =
true;
11166 E = UO->getSubExpr();
11170 unsigned DiagID = IsCompare
11171 ? diag::warn_address_of_reference_null_compare
11172 : diag::warn_address_of_reference_bool_conversion;
11180 auto ComplainAboutNonnullParamOrCall = [&](
const Attr *NonnullAttr) {
11181 bool IsParam = isa<NonNullAttr>(NonnullAttr);
11183 llvm::raw_string_ostream S(Str);
11185 unsigned DiagID = IsCompare ? diag::warn_nonnull_expr_compare
11186 : diag::warn_cast_nonnull_to_bool;
11189 Diag(NonnullAttr->getLocation(), diag::note_declared_nonnull) << IsParam;
11195 if (
const Attr *A = Callee->getAttr<ReturnsNonNullAttr>()) {
11196 ComplainAboutNonnullParamOrCall(A);
11206 }
else if (
MemberExpr *M = dyn_cast<MemberExpr>(E)) {
11207 D = M->getMemberDecl();
11215 if (
const auto* PV = dyn_cast<ParmVarDecl>(D)) {
11216 if (getCurFunction() &&
11217 !getCurFunction()->ModifiedNonNullParams.count(PV)) {
11218 if (
const Attr *A = PV->getAttr<NonNullAttr>()) {
11219 ComplainAboutNonnullParamOrCall(A);
11223 if (
const auto *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
11224 auto ParamIter = llvm::find(FD->
parameters(), PV);
11230 ComplainAboutNonnullParamOrCall(
NonNull);
11235 if (ArgNo.getASTIndex() == ParamNo) {
11236 ComplainAboutNonnullParamOrCall(
NonNull);
11250 if (IsAddressOf && IsFunction) {
11255 if (!IsAddressOf && !IsFunction && !IsArray)
11260 llvm::raw_string_ostream S(Str);
11263 unsigned DiagID = IsCompare ? diag::warn_null_pointer_compare
11264 : diag::warn_impcast_pointer_to_bool;
11271 DiagType = AddressOf;
11272 else if (IsFunction)
11273 DiagType = FunctionPointer;
11275 DiagType = ArrayPointer;
11277 llvm_unreachable(
"Could not determine diagnostic.");
11279 << Range << IsEqual;
11291 tryExprAsCall(*E, ReturnType, NonTemplateOverloads);
11292 if (ReturnType.isNull())
11299 if (!ReturnType->isPointerType()) {
11302 if (!ReturnType->isIntegerType())
11311 if (!ReturnType->isSpecificBuiltinType(BuiltinType::Bool))
11327 if (isUnevaluatedContext())
11337 CheckArrayAccess(E);
11351 void Sema::CheckForIntOverflow (
Expr *E) {
11356 Expr *OriginalE = Exprs.pop_back_val();
11359 if (isa<BinaryOperator>(E)) {
11364 if (
auto InitList = dyn_cast<InitListExpr>(OriginalE))
11365 Exprs.append(InitList->inits().begin(), InitList->inits().end());
11366 else if (isa<ObjCBoxedExpr>(OriginalE))
11368 else if (
auto Call = dyn_cast<CallExpr>(E))
11370 else if (
auto Message = dyn_cast<ObjCMessageExpr>(E))
11371 Exprs.append(Message->arg_begin(), Message->arg_end());
11372 }
while (!Exprs.empty());
11387 class SequenceTree {
11391 unsigned Merged : 1;
11399 friend class SequenceTree;
11401 unsigned Index = 0;
11403 explicit Seq(
unsigned N) : Index(N) {}
11409 SequenceTree() { Values.push_back(
Value(0)); }
11410 Seq root()
const {
return Seq(0); }
11415 Seq allocate(Seq
Parent) {
11416 Values.push_back(
Value(Parent.Index));
11417 return Seq(Values.size() - 1);
11421 void merge(Seq S) {
11422 Values[S.Index].Merged =
true;
11428 bool isUnsequenced(Seq Cur, Seq Old) {
11429 unsigned C = representative(Cur.Index);
11430 unsigned Target = representative(Old.Index);
11431 while (C >= Target) {
11434 C = Values[
C].Parent;
11441 unsigned representative(
unsigned K) {
11442 if (Values[K].Merged)
11444 return Values[K].Parent = representative(Values[K].Parent);
11464 UK_ModAsSideEffect,
11466 UK_Count = UK_ModAsSideEffect + 1
11470 Expr *Use =
nullptr;
11471 SequenceTree::Seq Seq;
11477 Usage Uses[UK_Count];
11480 bool Diagnosed =
false;
11482 UsageInfo() =
default;
11484 using UsageInfoMap = llvm::SmallDenseMap<Object, UsageInfo, 16>;
11492 UsageInfoMap UsageMap;
11495 SequenceTree::Seq Region;
11510 struct SequencedSubexpression {
11511 SequencedSubexpression(SequenceChecker &Self)
11512 : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) {
11513 Self.ModAsSideEffect = &ModAsSideEffect;
11516 ~SequencedSubexpression() {
11517 for (
auto &M : llvm::reverse(ModAsSideEffect)) {
11518 UsageInfo &U = Self.UsageMap[M.first];
11519 auto &SideEffectUsage = U.Uses[UK_ModAsSideEffect];
11520 Self.addUsage(U, M.first, SideEffectUsage.Use, UK_ModAsValue);
11521 SideEffectUsage = M.second;
11523 Self.ModAsSideEffect = OldModAsSideEffect;
11526 SequenceChecker &Self;
11535 class EvaluationTracker {
11537 EvaluationTracker(SequenceChecker &Self)
11538 : Self(Self), Prev(Self.EvalTracker) {
11539 Self.EvalTracker =
this;
11542 ~EvaluationTracker() {
11543 Self.EvalTracker = Prev;
11545 Prev->EvalOK &= EvalOK;
11548 bool evaluate(
const Expr *E,
bool &Result) {
11556 SequenceChecker &Self;
11557 EvaluationTracker *Prev;
11558 bool EvalOK =
true;
11559 } *EvalTracker =
nullptr;
11563 Object getObject(
Expr *E,
bool Mod)
const {
11566 if (Mod && (UO->getOpcode() == UO_PreInc || UO->getOpcode() == UO_PreDec))
11567 return getObject(UO->getSubExpr(), Mod);
11569 if (BO->getOpcode() == BO_Comma)
11570 return getObject(BO->getRHS(), Mod);
11571 if (Mod && BO->isAssignmentOp())
11572 return getObject(BO->getLHS(), Mod);
11573 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
11575 if (isa<CXXThisExpr>(ME->getBase()->IgnoreParenCasts()))
11576 return ME->getMemberDecl();
11577 }
else if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
11579 return DRE->getDecl();
11584 void addUsage(UsageInfo &UI, Object O,
Expr *Ref, UsageKind UK) {
11585 Usage &U = UI.Uses[UK];
11586 if (!U.Use || !Tree.isUnsequenced(Region, U.Seq)) {
11587 if (UK == UK_ModAsSideEffect && ModAsSideEffect)
11588 ModAsSideEffect->push_back(std::make_pair(O, U));
11595 void checkUsage(Object O, UsageInfo &UI,
Expr *Ref, UsageKind OtherKind,
11600 const Usage &U = UI.Uses[OtherKind];
11601 if (!U.Use || !Tree.isUnsequenced(Region, U.Seq))
11605 Expr *ModOrUse = Ref;
11606 if (OtherKind == UK_Use)
11607 std::swap(Mod, ModOrUse);
11610 IsModMod ? diag::warn_unsequenced_mod_mod
11611 : diag::warn_unsequenced_mod_use)
11613 UI.Diagnosed =
true;
11616 void notePreUse(Object O,
Expr *Use) {
11617 UsageInfo &U = UsageMap[O];
11619 checkUsage(O, U, Use, UK_ModAsValue,
false);
11622 void notePostUse(Object O,
Expr *Use) {
11623 UsageInfo &U = UsageMap[O];
11624 checkUsage(O, U, Use, UK_ModAsSideEffect,
false);
11625 addUsage(U, O, Use, UK_Use);
11628 void notePreMod(Object O,
Expr *Mod) {
11629 UsageInfo &U = UsageMap[O];
11631 checkUsage(O, U, Mod, UK_ModAsValue,
true);
11632 checkUsage(O, U, Mod, UK_Use,
false);
11635 void notePostMod(Object O,
Expr *Use, UsageKind UK) {
11636 UsageInfo &U = UsageMap[O];
11637 checkUsage(O, U, Use, UK_ModAsSideEffect,
true);
11638 addUsage(U, O, Use, UK);
11643 :
Base(S.
Context), SemaRef(S), Region(Tree.root()), WorkList(WorkList) {
11647 void VisitStmt(
Stmt *S) {
11651 void VisitExpr(
Expr *E) {
11653 Base::VisitStmt(E);
11657 Object O = Object();
11673 SequenceTree::Seq LHS = Tree.allocate(Region);
11674 SequenceTree::Seq RHS = Tree.allocate(Region);
11675 SequenceTree::Seq OldRegion = Region;
11678 SequencedSubexpression SeqLHS(*
this);
11686 Region = OldRegion;
11698 Object O = getObject(BO->
getLHS(),
true);
11700 return VisitExpr(BO);
11710 if (isa<CompoundAssignOperator>(BO))
11715 if (isa<CompoundAssignOperator>(BO))
11716 notePostUse(O, BO);
11724 notePostMod(O, BO, SemaRef.
getLangOpts().CPlusPlus ? UK_ModAsValue
11725 : UK_ModAsSideEffect);
11729 VisitBinAssign(CAO);
11732 void VisitUnaryPreInc(
UnaryOperator *UO) { VisitUnaryPreIncDec(UO); }
11733 void VisitUnaryPreDec(
UnaryOperator *UO) { VisitUnaryPreIncDec(UO); }
11735 Object O = getObject(UO->
getSubExpr(),
true);
11737 return VisitExpr(UO);
11743 notePostMod(O, UO, SemaRef.
getLangOpts().CPlusPlus ? UK_ModAsValue
11744 : UK_ModAsSideEffect);
11747 void VisitUnaryPostInc(
UnaryOperator *UO) { VisitUnaryPostIncDec(UO); }
11748 void VisitUnaryPostDec(
UnaryOperator *UO) { VisitUnaryPostIncDec(UO); }
11750 Object O = getObject(UO->
getSubExpr(),
true);
11752 return VisitExpr(UO);
11756 notePostMod(O, UO, UK_ModAsSideEffect);
11765 EvaluationTracker Eval(*
this);
11767 SequencedSubexpression Sequenced(*
this);
11772 if (Eval.evaluate(BO->
getLHS(), Result)) {
11782 WorkList.push_back(BO->
getRHS());
11786 EvaluationTracker Eval(*
this);
11788 SequencedSubexpression Sequenced(*
this);
11793 if (Eval.evaluate(BO->
getLHS(), Result)) {
11797 WorkList.push_back(BO->
getRHS());
11804 EvaluationTracker Eval(*
this);
11806 SequencedSubexpression Sequenced(*
this);
11811 if (Eval.evaluate(CO->
getCond(), Result))
11819 void VisitCallExpr(
CallExpr *CE) {
11826 SequencedSubexpression Sequenced(*
this);
11827 Base::VisitCallExpr(CE);
11834 SequencedSubexpression Sequenced(*
this);
11837 return VisitExpr(CCE);
11841 SequenceTree::Seq
Parent = Region;
11845 Region = Tree.allocate(Parent);
11846 Elts.push_back(Region);
11852 for (
unsigned I = 0; I < Elts.size(); ++I)
11853 Tree.merge(Elts[I]);
11858 return VisitExpr(ILE);
11862 SequenceTree::Seq
Parent = Region;
11863 for (
unsigned I = 0; I < ILE->
getNumInits(); ++I) {
11866 Region = Tree.allocate(Parent);
11867 Elts.push_back(Region);
11873 for (
unsigned I = 0; I < Elts.size(); ++I)
11874 Tree.merge(Elts[I]);
11880 void Sema::CheckUnsequencedOperations(
Expr *E) {
11882 WorkList.push_back(E);
11883 while (!WorkList.empty()) {
11884 Expr *Item = WorkList.pop_back_val();
11885 SequenceChecker(*
this, Item, WorkList);
11890 bool IsConstexpr) {
11891 CheckImplicitConversions(E, CheckLoc);
11893 CheckUnsequencedOperations(E);
11895 CheckForIntOverflow(E);
11896 DiagnoseMisalignedMembers();
11909 if (
const auto *PointerTy = dyn_cast<PointerType>(PType)) {
11913 if (
const auto *ReferenceTy = dyn_cast<ReferenceType>(PType)) {
11917 if (
const auto *ParenTy = dyn_cast<ParenType>(PType)) {
11931 S.
Diag(Loc, diag::err_array_star_in_function_definition);
11940 bool CheckParameterNames) {
11941 bool HasInvalidParm =
false;
11948 if (!Param->isInvalidDecl() &&
11949 RequireCompleteType(Param->getLocation(), Param->getType(),
11950 diag::err_typecheck_decl_incomplete_type)) {
11951 Param->setInvalidDecl();
11952 HasInvalidParm =
true;
11957 if (CheckParameterNames &&
11958 Param->getIdentifier() ==
nullptr &&
11959 !Param->isImplicit() &&
11960 !getLangOpts().CPlusPlus)
11961 Diag(Param->getLocation(), diag::err_parameter_name_omitted);
11968 QualType PType = Param->getOriginalType();
11976 if (!Param->isInvalidDecl()) {
11977 if (
CXXRecordDecl *ClassDecl = Param->getType()->getAsCXXRecordDecl()) {
11978 if (!ClassDecl->isInvalidDecl() &&
11979 !ClassDecl->hasIrrelevantDestructor() &&
11980 !ClassDecl->isDependentContext() &&
11981 ClassDecl->isParamDestroyedInCallee()) {
11983 MarkFunctionReferenced(Param->getLocation(), Destructor);
11984 DiagnoseUseOfDecl(Destructor, Param->
getLocation());
11993 if (
const auto *
Attr = Param->getAttr<PassObjectSizeAttr>())
11994 if (!Param->getType().isConstQualified())
11995 Diag(Param->getLocation(), diag::err_attribute_pointers_only)
11999 return HasInvalidParm;
12006 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
12009 if (
const auto *ME = dyn_cast<MemberExpr>(E))
12020 if (getDiagnostics().isIgnored(diag::warn_cast_align, TRange.
getBegin()))
12029 if (!DestPtr)
return;
12035 if (DestAlign.
isOne())
return;
12039 if (!SrcPtr)
return;
12050 if (
auto *CE = dyn_cast<CastExpr>(Op)) {
12051 if (CE->getCastKind() == CK_ArrayToPointerDecay)
12052 SrcAlign =
getDeclAlign(CE->getSubExpr(), SrcAlign, Context);
12053 }
else if (
auto *UO = dyn_cast<UnaryOperator>(Op)) {
12054 if (UO->getOpcode() == UO_AddrOf)
12055 SrcAlign =
getDeclAlign(UO->getSubExpr(), SrcAlign, Context);
12058 if (SrcAlign >= DestAlign)
return;
12063 << static_cast<unsigned>(DestAlign.
getQuantity())
12074 if (Size != 1 || !ND)
return false;
12077 if (!FD)
return false;
12100 if (!RD)
return false;
12101 if (RD->
isUnion())
return false;
12102 if (
const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
12103 if (!CRD->isStandardLayout())
return false;
12107 const Decl *D = FD;
12109 if (isa<FieldDecl>(D))
12114 void Sema::CheckArrayAccess(
const Expr *BaseExpr,
const Expr *IndexExpr,
12116 bool AllowOnePastEnd,
bool IndexNegated) {
12121 const Type *EffectiveType =
12129 llvm::APSInt index;
12136 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr))
12137 ND = DRE->getDecl();
12138 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr))
12139 ND = ME->getMemberDecl();
12141 if (index.isUnsigned() || !index.isNegative()) {
12142 llvm::APInt size = ArrayTy->
getSize();
12143 if (!size.isStrictlyPositive())
12147 if (BaseType != EffectiveType) {
12149 uint64_t ptrarith_typesize = Context.
getTypeSize(EffectiveType);
12150 uint64_t array_typesize = Context.
getTypeSize(BaseType);
12152 if (!ptrarith_typesize) ptrarith_typesize = 1;
12153 if (ptrarith_typesize != array_typesize) {
12155 uint64_t ratio = array_typesize / ptrarith_typesize;
12158 if (ptrarith_typesize * ratio == array_typesize)
12159 size *= llvm::APInt(size.getBitWidth(), ratio);
12163 if (size.getBitWidth() > index.getBitWidth())
12164 index = index.zext(size.getBitWidth());
12165 else if (size.getBitWidth() < index.getBitWidth())
12166 size = size.zext(index.getBitWidth());
12172 if (AllowOnePastEnd ? index.ule(size) : index.ult(size))
12187 if (SourceMgr.isInSystemHeader(RBracketLoc)) {
12190 if (SourceMgr.isWrittenInSameFile(RBracketLoc, IndexLoc))
12195 unsigned DiagID = diag::warn_ptr_arith_exceeds_bounds;
12197 DiagID = diag::warn_array_index_exceeds_bounds;
12199 DiagRuntimeBehavior(BaseExpr->
getLocStart(), BaseExpr,
12200 PDiag(DiagID) << index.toString(10,
true)
12201 << size.toString(10,
true)
12202 << (unsigned)size.getLimitedValue(~0U)
12205 unsigned DiagID = diag::warn_array_index_precedes_bounds;
12207 DiagID = diag::warn_ptr_arith_precedes_bounds;
12208 if (index.isNegative()) index = -index;
12211 DiagRuntimeBehavior(BaseExpr->
getLocStart(), BaseExpr,
12212 PDiag(DiagID) << index.toString(10,
true)
12219 dyn_cast<ArraySubscriptExpr>(BaseExpr))
12221 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr))
12222 ND = DRE->getDecl();
12223 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr))
12224 ND = ME->getMemberDecl();
12229 PDiag(diag::note_array_index_out_of_bounds)
12233 void Sema::CheckArrayAccess(
const Expr *
expr) {
12234 int AllowOnePastEnd = 0;
12238 case Stmt::ArraySubscriptExprClass: {
12241 AllowOnePastEnd > 0);
12245 case Stmt::MemberExprClass: {
12246 expr = cast<MemberExpr>(
expr)->getBase();
12249 case Stmt::OMPArraySectionExprClass: {
12253 nullptr, AllowOnePastEnd > 0);
12256 case Stmt::UnaryOperatorClass: {
12272 case Stmt::ConditionalOperatorClass: {
12275 CheckArrayAccess(lhs);
12277 CheckArrayAccess(rhs);
12280 case Stmt::CXXOperatorCallExprClass: {
12281 const auto *OCE = cast<CXXOperatorCallExpr>(
expr);
12282 for (
const auto *Arg : OCE->arguments())
12283 CheckArrayAccess(Arg);
12296 struct RetainCycleOwner {
12300 bool Indirect =
false;
12302 RetainCycleOwner() =
default;
12304 void setLocsFrom(
Expr *e) {
12321 owner.Variable = var;
12323 owner.setLocsFrom(ref);
12331 switch (
cast->getCastKind()) {
12333 case CK_LValueBitCast:
12334 case CK_LValueToRValue:
12335 case CK_ARCReclaimReturnedObject:
12336 e =
cast->getSubExpr();
12353 if (ref->isFreeIvar()) owner.setLocsFrom(ref);
12354 owner.Indirect =
true;
12358 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(e)) {
12360 if (!var)
return false;
12364 if (
MemberExpr *member = dyn_cast<MemberExpr>(e)) {
12365 if (member->isArrow())
return false;
12368 e = member->getBase();
12377 if (!pre)
return false;
12380 if (!property->isRetaining() &&
12381 !(
property->getPropertyIvarDecl() &&
12382 property->getPropertyIvarDecl()->getType()
12386 owner.Indirect =
true;
12389 if (!owner.Variable)
12395 e =
const_cast<Expr*
>(cast<OpaqueValueExpr>(pre->
getBase())
12396 ->getSourceExpr());
12411 Expr *Capturer =
nullptr;
12412 bool VarWillBeReased =
false;
12416 Context(Context), Variable(variable) {}
12419 if (ref->
getDecl() == Variable && !Capturer)
12424 if (Capturer)
return;
12430 void VisitBlockExpr(
BlockExpr *block) {
12437 if (Capturer)
return;
12443 if (!Variable || VarWillBeReased || BinOp->
getOpcode() != BO_Assign)
12446 if (
const DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(LHS)) {
12447 if (DRE->getDecl() != Variable)
12451 llvm::APSInt
Value;
12453 (RHS && RHS->isIntegerConstantExpr(Value, Context) && Value == 0);
12464 assert(owner.Variable && owner.Loc.isValid());
12472 e = ME->getInstanceReceiver();
12475 e = e->IgnoreParenCasts();
12477 }
else if (
CallExpr *CE = dyn_cast<CallExpr>(e)) {
12482 if (FnI && FnI->
isStr(
"_Block_copy")) {
12493 FindCaptureVisitor visitor(S.
Context, owner.Variable);
12495 return visitor.VarWillBeReased ? nullptr : visitor.Capturer;
12499 RetainCycleOwner &owner) {
12501 assert(owner.Variable && owner.Loc.isValid());
12505 S.
Diag(owner.Loc, diag::note_arc_retain_cycle_owner)
12506 << owner.Indirect << owner.Range;
12515 while (!str.empty() && str.front() ==
'_') str = str.substr(1);
12516 if (str.startswith(
"set"))
12517 str = str.substr(3);
12518 else if (str.startswith(
"add")) {
12520 if (sel.
getNumArgs() == 1 && str.startswith(
"addOperationWithBlock"))
12522 str = str.substr(3);
12527 if (str.empty())
return true;
12533 bool IsMutableArray = S.
NSAPIObj->isSubclassOfNSClass(
12536 if (!IsMutableArray) {
12543 S.
NSAPIObj->getNSArrayMethodKind(Sel);
12568 bool IsMutableDictionary = S.
NSAPIObj->isSubclassOfNSClass(
12571 if (!IsMutableDictionary) {
12578 S.
NSAPIObj->getNSDictionaryMethodKind(Sel);
12599 bool IsMutableSet = S.
NSAPIObj->isSubclassOfNSClass(
12603 bool IsMutableOrderedSet = S.
NSAPIObj->isSubclassOfNSClass(
12606 if (!IsMutableSet && !IsMutableOrderedSet) {
12645 int ArgIndex = *ArgOpt;
12653 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
12654 if (ArgRE->isObjCSelfExpr()) {
12656 diag::warn_objc_circular_container)
12657 << ArgRE->getDecl() << StringRef(
"'super'");
12667 if (
DeclRefExpr *ReceiverRE = dyn_cast<DeclRefExpr>(Receiver)) {
12668 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
12669 if (ReceiverRE->getDecl() == ArgRE->getDecl()) {
12672 diag::warn_objc_circular_container)
12674 if (!ArgRE->isObjCSelfExpr()) {
12676 diag::note_objc_circular_container_declared_here)
12681 }
else if (
ObjCIvarRefExpr *IvarRE = dyn_cast<ObjCIvarRefExpr>(Receiver)) {
12683 if (IvarRE->getDecl() == IvarArgRE->getDecl()) {
12686 diag::warn_objc_circular_container)
12689 diag::note_objc_circular_container_declared_here)
12704 RetainCycleOwner owner;
12710 owner.Variable = getCurMethodDecl()->getSelfDecl();
12717 for (
unsigned i = 0, e = msg->
getNumArgs(); i != e; ++i) {
12720 if (MD && MD->
parameters()[i]->hasAttr<NoEscapeAttr>())
12729 RetainCycleOwner owner;
12738 RetainCycleOwner Owner;
12752 Expr *RHS,
bool isProperty) {
12764 S.
Diag(Loc, diag::warn_arc_literal_assign)
12766 << (isProperty ? 0 : 1)
12774 Expr *RHS,
bool isProperty) {
12777 if (
cast->getCastKind() == CK_ARCConsumeObject) {
12778 S.
Diag(Loc, diag::warn_arc_retained_assign)
12780 << (isProperty ? 0 : 1)
12784 RHS =
cast->getSubExpr();
12826 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
12827 getCurFunction()->markSafeWeakUse(LHS);
12830 if (checkUnsafeAssigns(Loc, LHSType, RHS))
12850 if (!(AsWrittenAttr & ObjCPropertyDecl::OBJC_PR_assign) &&
12855 if (
cast->getCastKind() == CK_ARCConsumeObject) {
12856 Diag(Loc, diag::warn_arc_retained_property_assign)
12860 RHS =
cast->getSubExpr();
12884 bool StmtLineInvalid;
12887 if (StmtLineInvalid)
12890 bool BodyLineInvalid;
12893 if (BodyLineInvalid)
12897 if (StmtLine != BodyLine)
12908 if (CurrentInstantiationScope)
12921 Diag(NBody->
getSemiLoc(), diag::note_empty_body_on_separate_line);
12925 const Stmt *PossibleBody) {
12926 assert(!CurrentInstantiationScope);
12931 if (
const ForStmt *FS = dyn_cast<ForStmt>(S)) {
12932 StmtLoc = FS->getRParenLoc();
12933 Body = FS->getBody();
12934 DiagID = diag::warn_empty_for_body;
12935 }
else if (
const WhileStmt *WS = dyn_cast<WhileStmt>(S)) {
12936 StmtLoc = WS->getCond()->getSourceRange().getEnd();
12937 Body = WS->getBody();
12938 DiagID = diag::warn_empty_while_body;
12948 if (Diags.isIgnored(DiagID, NBody->
getSemiLoc()))
12966 bool ProbableTypo = isa<CompoundStmt>(PossibleBody);
12967 if (!ProbableTypo) {
12968 bool BodyColInvalid;
12969 unsigned BodyCol = SourceMgr.getPresumedColumnNumber(
12972 if (BodyColInvalid)
12975 bool StmtColInvalid;
12976 unsigned StmtCol = SourceMgr.getPresumedColumnNumber(
12979 if (StmtColInvalid)
12982 if (BodyCol > StmtCol)
12983 ProbableTypo =
true;
12986 if (ProbableTypo) {
12988 Diag(NBody->
getSemiLoc(), diag::note_empty_body_on_separate_line);
12997 if (Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess, OpLoc))
13000 if (inTemplateInstantiation())
13017 RHSExpr = CE->
getArg(0);
13023 if (LHSDeclRef && RHSDeclRef) {
13024 if (!LHSDeclRef->
getDecl() || !RHSDeclRef->getDecl())
13030 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
13040 const Expr *LHSBase = LHSExpr;
13041 const Expr *RHSBase = RHSExpr;
13044 if (!LHSME || !RHSME)
13047 while (LHSME && RHSME) {
13053 RHSBase = RHSME->getBase();
13060 if (LHSDeclRef && RHSDeclRef) {
13061 if (!LHSDeclRef->getDecl() || !RHSDeclRef->getDecl())
13063 if (LHSDeclRef->getDecl()->getCanonicalDecl() !=
13064 RHSDeclRef->getDecl()->getCanonicalDecl())
13067 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
13073 if (isa<CXXThisExpr>(LHSBase) && isa<CXXThisExpr>(RHSBase))
13074 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
13106 if (Bits1 != Bits2)
13118 if (
const CXXRecordDecl *D1CXX = dyn_cast<CXXRecordDecl>(RD1)) {
13123 if (D1CXX->getNumBases() != D2CXX->
getNumBases())
13128 Base1 = D1CXX->bases_begin(),
13129 BaseEnd1 = D1CXX->bases_end(),
13132 ++Base1, ++Base2) {
13136 }
else if (
const CXXRecordDecl *D2CXX = dyn_cast<CXXRecordDecl>(RD2)) {
13138 if (D2CXX->getNumBases() > 0)
13147 for ( ; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) {
13151 if (Field1 != Field1End || Field2 != Field2End)
13161 llvm::SmallPtrSet<FieldDecl *, 8> UnmatchedFields;
13162 for (
auto *Field2 : RD2->
fields())
13163 UnmatchedFields.insert(Field2);
13165 for (
auto *Field1 : RD1->
fields()) {
13166 llvm::SmallPtrSet<FieldDecl *, 8>::iterator
13167 I = UnmatchedFields.begin(),
13168 E = UnmatchedFields.end();
13170 for ( ; I != E; ++I) {
13172 bool Result = UnmatchedFields.erase(*I);
13182 return UnmatchedFields.empty();
13216 if (TC1 == Type::Enum) {
13218 cast<EnumType>(T1)->getDecl(),
13219 cast<EnumType>(T2)->getDecl());
13220 }
else if (TC1 == Type::Record) {
13225 cast<RecordType>(T1)->getDecl(),
13226 cast<RecordType>(T2)->getDecl());
13242 const ValueDecl **VD, uint64_t *MagicValue) {
13250 case Stmt::UnaryOperatorClass: {
13259 case Stmt::DeclRefExprClass: {
13260 const DeclRefExpr *DRE = cast<DeclRefExpr>(TypeExpr);
13265 case Stmt::IntegerLiteralClass: {
13267 llvm::APInt MagicValueAPInt = IL->
getValue();
13268 if (MagicValueAPInt.getActiveBits() <= 64) {
13269 *MagicValue = MagicValueAPInt.getZExtValue();
13275 case Stmt::BinaryConditionalOperatorClass:
13276 case Stmt::ConditionalOperatorClass: {
13278 cast<AbstractConditionalOperator>(TypeExpr);
13290 case Stmt::BinaryOperatorClass: {
13293 TypeExpr = BO->
getRHS();
13322 bool &FoundWrongKind,
13324 FoundWrongKind =
false;
13329 uint64_t MagicValue;
13335 if (TypeTagForDatatypeAttr *I = VD->
getAttr<TypeTagForDatatypeAttr>()) {
13336 if (I->getArgumentKind() != ArgumentKind) {
13337 FoundWrongKind =
true;
13340 TypeInfo.
Type = I->getMatchingCType();
13353 MagicValues->find(std::make_pair(ArgumentKind, MagicValue));
13354 if (I == MagicValues->end())
13357 TypeInfo = I->second;
13363 bool LayoutCompatible,
13365 if (!TypeTagForDatatypeMagicValues)
13366 TypeTagForDatatypeMagicValues.reset(
13367 new llvm::DenseMap<TypeTagMagicValue, TypeTagData>);
13370 (*TypeTagForDatatypeMagicValues)[Magic] =
13386 return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) ||
13387 (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) ||
13388 (T1Kind == BuiltinType::Char_U && T2Kind == BuiltinType::UChar) ||
13389 (T1Kind == BuiltinType::Char_S && T2Kind == BuiltinType::SChar);
13392 void Sema::CheckArgumentWithTypeTag(
const ArgumentWithTypeTagAttr *
Attr,
13393 const ArrayRef<const Expr *> ExprArgs,
13396 bool IsPointerAttr = Attr->getIsPointer();
13399 unsigned TypeTagIdxAST = Attr->getTypeTagIdx().getASTIndex();
13400 if (TypeTagIdxAST >= ExprArgs.size()) {
13401 Diag(CallSiteLoc, diag::err_tag_index_out_of_range)
13402 << 0 << Attr->getTypeTagIdx().getSourceIndex();
13405 const Expr *TypeTagExpr = ExprArgs[TypeTagIdxAST];
13406 bool FoundWrongKind;
13409 TypeTagForDatatypeMagicValues.get(),
13410 FoundWrongKind, TypeInfo)) {
13411 if (FoundWrongKind)
13413 diag::warn_type_tag_for_datatype_wrong_kind)
13419 unsigned ArgumentIdxAST = Attr->getArgumentIdx().getASTIndex();
13420 if (ArgumentIdxAST >= ExprArgs.size()) {
13421 Diag(CallSiteLoc, diag::err_tag_index_out_of_range)
13422 << 1 << Attr->getArgumentIdx().getSourceIndex();
13425 const Expr *ArgumentExpr = ExprArgs[ArgumentIdxAST];
13426 if (IsPointerAttr) {
13428 if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(ArgumentExpr))
13429 if (ICE->getType()->isVoidPointerType() &&
13430 ICE->getCastKind() == CK_BitCast)
13431 ArgumentExpr = ICE->getSubExpr();
13439 if (TypeInfo.MustBeNull) {
13444 diag::warn_type_safety_null_pointer_required)
13452 QualType RequiredType = TypeInfo.Type;
13456 bool mismatch =
false;
13457 if (!TypeInfo.LayoutCompatible) {
13458 mismatch = !Context.
hasSameType(ArgumentType, RequiredType);
13479 Diag(ArgumentExpr->
getExprLoc(), diag::warn_type_safety_type_mismatch)
13480 << ArgumentType << ArgumentKind
13481 << TypeInfo.LayoutCompatible << RequiredType
13488 MisalignedMembers.emplace_back(E, RD, MD, Alignment);
13492 for (MisalignedMember &m : MisalignedMembers) {
13498 Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
13501 MisalignedMembers.clear();
13508 if (isa<UnaryOperator>(E) &&
13509 cast<UnaryOperator>(E)->
getOpcode() == UO_AddrOf) {
13510 auto *Op = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
13511 if (isa<MemberExpr>(Op)) {
13512 auto MA = std::find(MisalignedMembers.begin(), MisalignedMembers.end(),
13513 MisalignedMember(Op));
13514 if (MA != MisalignedMembers.end() &&
13519 MisalignedMembers.erase(MA);
13540 bool AnyIsPacked =
false;
13542 QualType BaseType = ME->getBase()->getType();
13556 AnyIsPacked || (RD->
hasAttr<PackedAttr>() || MD->
hasAttr<PackedAttr>());
13557 ReverseMemberChain.push_back(FD);
13560 ME = dyn_cast<
MemberExpr>(ME->getBase()->IgnoreParens());
13562 assert(TopME &&
"We did not compute a topmost MemberExpr!");
13569 const auto *DRE = dyn_cast<
DeclRefExpr>(TopBase);
13573 if (!DRE && !isa<CXXThisExpr>(TopBase))
13580 if (ExpectedAlignment.
isOne())
13585 for (
auto I = ReverseMemberChain.rbegin(); I != ReverseMemberChain.rend();
13592 ReverseMemberChain.back()->getParent()->getTypeForDecl());
13596 if (DRE && !TopME->
isArrow()) {
13599 CompleteObjectAlignment =
13604 if (Offset % ExpectedAlignment != 0 ||
13607 CompleteObjectAlignment < ExpectedAlignment) {
13618 for (
FieldDecl *FDI : ReverseMemberChain) {
13619 if (FDI->hasAttr<PackedAttr>() ||
13620 FDI->getParent()->hasAttr<PackedAttr>()) {
13628 assert(FD &&
"We did not find a packed FieldDecl!");
13629 Action(E, FD->
getParent(), FD, Alignment);
13633 void Sema::CheckAddressOfPackedMember(
Expr *rhs) {
13634 using namespace std::placeholders;
13636 RefersToMemberWithReducedAlignment(
13637 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.
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.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
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.
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.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
SourceLocation getLocStart() const LLVM_READONLY
bool isSuperReceiver() const
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
const Expr * getInit(unsigned Init) const
bool containsNonAsciiOrNull() const
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
Stmt - This represents one statement.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
static Optional< int > GetNSMutableArrayArgumentIndex(Sema &S, ObjCMessageExpr *Message)
Expr * getBitWidth() const
bool consumesDataArgument() const
FunctionType - C99 6.7.5.3 - Function Declarators.
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken=nullptr, unsigned *StartTokenByteOffset=nullptr) const
getLocationOfByte - Return a source location that points to the specified byte of this string literal...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
An instance of this object exists for each enum constant that is defined.
bool isRealFloatingType() const
Floating point categories.
C Language Family Type Representation.
Defines the SourceManager interface.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
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.
SourceLocation getLocEnd() const LLVM_READONLY
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
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.
SourceLocation getLocStart() const LLVM_READONLY
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 isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
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...
bool EvaluateAsInt(llvm::APSInt &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...
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
field_range fields() const
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
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)
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 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.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
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.
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 getLocEnd() const LLVM_READONLY
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.
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...
static void SemaBuiltinMemChkCall(Sema &S, FunctionDecl *FDecl, CallExpr *TheCall, unsigned SizeIdx, unsigned DstSizeIdx)
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 ...
Expr - 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.
const Expr * getCallee() const
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.
void removeLocalVolatile()
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.
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)
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...
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)
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 isVoidPointerType() const
bool isConstQualified() const
Determine whether this type is const-qualified.
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)
SourceLocation getLocStart() const LLVM_READONLY
EltType getEltType() const
Defines the clang::OpenCLOptions class.
static bool IsStdFunction(const FunctionDecl *FDecl, const char(&Str)[StrLen])
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.
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.
SourceLocation getLocStart() const LLVM_READONLY
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)
CheckBoolLikeConversion - Check conversion of given expression to boolean.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Look up any declaration with any name.
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.
SourceLocation getLocEnd() const LLVM_READONLY
TypeClass getTypeClass() const
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)
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.
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 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.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
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
DeclarationName - 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)
SourceLocation getLocStart() const LLVM_READONLY
static bool isSetterLikeSelector(Selector sel)
Check for a keyword selector that starts with the word 'add' or 'set'.
A set of unresolved declarations.
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
Expression is a C++11 nullptr.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
const OptionalFlag & isPrivate() const
Flags to identify the types for overloaded Neon builtins.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange)
CheckCastAlign - Implements -Wcast-align, which warns when a pointer cast increases the alignment req...
static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner)
static bool IsSameCharType(QualType T1, QualType T2)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
SemaConvertVectorExpr - Handle __builtin_convertvector.
Expr * IgnoreParenImpCasts() LLVM_READONLY
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. ...
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
SourceLocation getExprLoc() const LLVM_READONLY
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]...
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.
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)
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 *).
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.
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