63 #include "llvm/ADT/APFloat.h" 64 #include "llvm/ADT/APInt.h" 65 #include "llvm/ADT/APSInt.h" 66 #include "llvm/ADT/ArrayRef.h" 67 #include "llvm/ADT/DenseMap.h" 68 #include "llvm/ADT/FoldingSet.h" 69 #include "llvm/ADT/None.h" 70 #include "llvm/ADT/Optional.h" 71 #include "llvm/ADT/STLExtras.h" 72 #include "llvm/ADT/SmallBitVector.h" 73 #include "llvm/ADT/SmallPtrSet.h" 74 #include "llvm/ADT/SmallString.h" 75 #include "llvm/ADT/SmallVector.h" 76 #include "llvm/ADT/StringRef.h" 77 #include "llvm/ADT/StringSwitch.h" 78 #include "llvm/ADT/Triple.h" 79 #include "llvm/Support/AtomicOrdering.h" 80 #include "llvm/Support/Casting.h" 81 #include "llvm/Support/Compiler.h" 82 #include "llvm/Support/ConvertUTF.h" 83 #include "llvm/Support/ErrorHandling.h" 84 #include "llvm/Support/Format.h" 85 #include "llvm/Support/Locale.h" 86 #include "llvm/Support/MathExtras.h" 87 #include "llvm/Support/SaveAndRestore.h" 88 #include "llvm/Support/raw_ostream.h" 99 using namespace clang;
100 using namespace sema;
103 unsigned ByteNo)
const {
112 if (argCount == desiredArgCount)
return false;
114 if (argCount < desiredArgCount)
115 return S.
Diag(call->
getEndLoc(), diag::err_typecheck_call_too_few_args)
116 << 0 << desiredArgCount << argCount
123 return S.
Diag(
range.getBegin(), diag::err_typecheck_call_too_many_args)
124 << 0 << desiredArgCount << argCount
146 if (!Literal || !Literal->
isAscii()) {
159 S.
Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args_at_least)
167 auto *Literal = dyn_cast<
StringLiteral>(Arg->IgnoreParenCasts());
168 if (!Literal || !Literal->isWide()) {
169 S.
Diag(Arg->getBeginLoc(), diag::err_msvc_annotation_wide_str)
170 << Arg->getSourceRange();
186 if (ResultType.isNull())
189 TheCall->
setArg(0, Arg.get());
212 bool IsBooleanAlignBuiltin = ID == Builtin::BI__builtin_is_aligned;
214 auto IsValidIntegerType = [](
QualType Ty) {
215 return Ty->isIntegerType() && !Ty->isEnumeralType() && !Ty->isBooleanType();
222 if ((!SrcTy->
isPointerType() && !IsValidIntegerType(SrcTy)) ||
226 S.
Diag(Source->
getExprLoc(), diag::err_typecheck_expect_scalar_operand)
232 if (!IsValidIntegerType(AlignOp->
getType())) {
245 llvm::APInt::getOneBitSet(MaxAlignmentBits + 1, MaxAlignmentBits));
246 if (AlignValue < 1) {
247 S.
Diag(AlignOp->
getExprLoc(), diag::err_alignment_too_small) << 1;
250 if (llvm::APSInt::compareValues(AlignValue, MaxValue) > 0) {
252 << MaxValue.toString(10);
255 if (!AlignValue.isPowerOf2()) {
256 S.
Diag(AlignOp->
getExprLoc(), diag::err_alignment_not_power_of_two);
259 if (AlignValue == 1) {
260 S.
Diag(AlignOp->
getExprLoc(), diag::warn_alignment_builtin_useless)
261 << IsBooleanAlignBuiltin;
290 for (
unsigned I = 0; I < 2; ++I) {
294 S.
Diag(Arg.
get()->getBeginLoc(), diag::err_overflow_builtin_must_be_int)
295 << Ty << Arg.
get()->getSourceRange();
303 TheCall->
setArg(I, Arg.get());
313 if (!(PtrTy && PtrTy->getPointeeType()->isIntegerType() &&
314 !PtrTy->getPointeeType().isConstQualified())) {
315 S.
Diag(Arg.
get()->getBeginLoc(),
316 diag::err_overflow_builtin_must_be_ptr_int)
317 << Ty << Arg.
get()->getSourceRange();
325 TheCall->
setArg(2, Arg.get());
340 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_not_call)
345 auto CE = cast<CallExpr>(Call);
346 if (CE->getCallee()->getType()->isBlockPointerType()) {
347 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_block_call)
352 const Decl *TargetDecl = CE->getCalleeDecl();
353 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
354 if (FD->getBuiltinID()) {
355 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_builtin_call)
360 if (isa<CXXPseudoDestructorExpr>(CE->getCallee()->IgnoreParens())) {
361 S.
Diag(BuiltinLoc, diag::err_first_argument_to_cwsc_pdtor_call)
369 if (!ChainResult.
get()->getType()->isPointerType()) {
370 S.
Diag(BuiltinLoc, diag::err_second_argument_to_cwsc_not_pointer)
376 QualType ArgTys[2] = { ReturnTy, ChainResult.
get()->getType() };
384 BuiltinCall->
setType(CE->getType());
388 BuiltinCall->
setArg(1, ChainResult.
get());
396 void Sema::checkFortifiedBuiltinMemoryFunction(
FunctionDecl *FD,
403 isConstantEvaluated())
411 bool IsChkVariant =
false;
412 unsigned SizeIndex, ObjectIndex;
416 case Builtin::BI__builtin___memcpy_chk:
417 case Builtin::BI__builtin___memmove_chk:
418 case Builtin::BI__builtin___memset_chk:
419 case Builtin::BI__builtin___strlcat_chk:
420 case Builtin::BI__builtin___strlcpy_chk:
421 case Builtin::BI__builtin___strncat_chk:
422 case Builtin::BI__builtin___strncpy_chk:
423 case Builtin::BI__builtin___stpncpy_chk:
424 case Builtin::BI__builtin___memccpy_chk:
425 case Builtin::BI__builtin___mempcpy_chk: {
426 DiagID = diag::warn_builtin_chk_overflow;
433 case Builtin::BI__builtin___snprintf_chk:
434 case Builtin::BI__builtin___vsnprintf_chk: {
435 DiagID = diag::warn_builtin_chk_overflow;
442 case Builtin::BIstrncat:
443 case Builtin::BI__builtin_strncat:
444 case Builtin::BIstrncpy:
445 case Builtin::BI__builtin_strncpy:
446 case Builtin::BIstpncpy:
447 case Builtin::BI__builtin_stpncpy: {
453 DiagID = diag::warn_fortify_source_size_mismatch;
459 case Builtin::BImemcpy:
460 case Builtin::BI__builtin_memcpy:
461 case Builtin::BImemmove:
462 case Builtin::BI__builtin_memmove:
463 case Builtin::BImemset:
464 case Builtin::BI__builtin_memset:
465 case Builtin::BImempcpy:
466 case Builtin::BI__builtin_mempcpy: {
467 DiagID = diag::warn_fortify_source_overflow;
472 case Builtin::BIsnprintf:
473 case Builtin::BI__builtin_snprintf:
474 case Builtin::BIvsnprintf:
475 case Builtin::BI__builtin_vsnprintf: {
476 DiagID = diag::warn_fortify_source_size_mismatch;
499 if (
const auto *POS =
501 BOSType = POS->getType();
508 const TargetInfo &TI = getASTContext().getTargetInfo();
510 ObjectSize = llvm::APSInt::getUnsigned(Result).extOrTrunc(SizeTypeWidth);
515 Expr *UsedSizeArg = TheCall->
getArg(SizeIndex);
520 if (UsedSize.ule(ObjectSize))
523 StringRef FunctionName = getASTContext().BuiltinInfo.getName(BuiltinID);
527 FunctionName = FunctionName.drop_front(std::strlen(
"__builtin___"));
528 FunctionName = FunctionName.drop_back(std::strlen(
"_chk"));
529 }
else if (FunctionName.startswith(
"__builtin_")) {
530 FunctionName = FunctionName.drop_front(std::strlen(
"__builtin_"));
533 DiagRuntimeBehavior(TheCall->
getBeginLoc(), TheCall,
535 << FunctionName << ObjectSize.toString(10)
536 << UsedSize.toString(10));
551 if (!S || !(S->
getFlags() & NeededScopeFlags)) {
554 << DRE->getDecl()->getIdentifier();
570 ArrayRef<QualType> Params =
572 unsigned ArgCounter = 0;
573 bool IllegalParams =
false;
576 for (ArrayRef<QualType>::iterator I = Params.begin(), E = Params.end();
577 I != E; ++I, ++ArgCounter) {
578 if (!(*I)->isPointerType() || !(*I)->getPointeeType()->isVoidType() ||
579 (*I)->getPointeeType().getQualifiers().getAddressSpace() !=
585 if (isa<BlockExpr>(BlockArg)) {
586 BlockDecl *BD = cast<BlockExpr>(BlockArg)->getBlockDecl();
588 }
else if (isa<DeclRefExpr>(BlockArg)) {
589 ErrorLoc = cast<DeclRefExpr>(BlockArg)->getBeginLoc();
592 diag::err_opencl_enqueue_kernel_blocks_non_local_void_args);
593 IllegalParams =
true;
597 return IllegalParams;
619 S.
Diag(NDRangeArg->
getBeginLoc(), diag::err_opencl_builtin_expected_type)
626 S.
Diag(BlockArg->
getBeginLoc(), diag::err_opencl_builtin_expected_type)
642 S.
Diag(BlockArg->
getBeginLoc(), diag::err_opencl_builtin_expected_type)
654 unsigned Start,
unsigned End) {
655 bool IllegalParams =
false;
656 for (
unsigned I = Start; I <=
End; ++I)
659 return IllegalParams;
666 unsigned NumNonVarArgs) {
669 unsigned NumBlockParams =
671 unsigned TotalNumArgs = TheCall->
getNumArgs();
675 if (TotalNumArgs != NumBlockParams + NumNonVarArgs) {
677 diag::err_opencl_enqueue_kernel_local_size_args);
717 diag::err_typecheck_call_too_few_args_at_least)
718 << 0 << 4 << NumArgs;
730 diag::err_opencl_builtin_expected_type)
738 diag::err_opencl_builtin_expected_type)
739 << TheCall->
getDirectCallee() <<
"'kernel_enqueue_flags_t' (i.e. uint)";
746 diag::err_opencl_builtin_expected_type)
765 diag::err_opencl_enqueue_kernel_blocks_no_args);
789 diag::err_opencl_builtin_expected_type)
802 diag::err_opencl_builtin_expected_type)
814 diag::err_opencl_builtin_expected_type)
828 diag::err_opencl_enqueue_kernel_incorrect_args);
834 return D->
getAttr<OpenCLAccessAttr>();
846 OpenCLAccessAttr *AccessQual =
853 case Builtin::BIread_pipe:
854 case Builtin::BIreserve_read_pipe:
855 case Builtin::BIcommit_read_pipe:
856 case Builtin::BIwork_group_reserve_read_pipe:
857 case Builtin::BIsub_group_reserve_read_pipe:
858 case Builtin::BIwork_group_commit_read_pipe:
859 case Builtin::BIsub_group_commit_read_pipe:
860 if (!(!AccessQual || AccessQual->isReadOnly())) {
862 diag::err_opencl_builtin_pipe_invalid_access_modifier)
867 case Builtin::BIwrite_pipe:
868 case Builtin::BIreserve_write_pipe:
869 case Builtin::BIcommit_write_pipe:
870 case Builtin::BIwork_group_reserve_write_pipe:
871 case Builtin::BIsub_group_reserve_write_pipe:
872 case Builtin::BIwork_group_commit_write_pipe:
873 case Builtin::BIsub_group_commit_write_pipe:
874 if (!(AccessQual && AccessQual->isWriteOnly())) {
876 diag::err_opencl_builtin_pipe_invalid_access_modifier)
1004 S.
Diag(Call->
getBeginLoc(), diag::err_opencl_builtin_pipe_invalid_arg)
1046 if (!RT->isPointerType() || RT->getPointeeType()
1048 S.
Diag(Call->
getBeginLoc(), diag::err_opencl_builtin_to_addr_invalid_arg)
1055 diag::warn_opencl_generic_address_space_arg)
1060 RT = RT->getPointeeType();
1061 auto Qual = RT.getQualifiers();
1062 switch (BuiltinID) {
1063 case Builtin::BIto_global:
1066 case Builtin::BIto_local:
1069 case Builtin::BIto_private:
1073 llvm_unreachable(
"Invalid builtin function");
1076 RT.getUnqualifiedType(), Qual)));
1111 if (DiagSelect.hasValue()) {
1124 diag::err_incomplete_type))
1128 "Unhandled non-object pointer case");
1145 ArrayRef<llvm::Triple::ArchType> SupportedArchs) {
1146 llvm::Triple::ArchType CurArch =
1148 if (llvm::is_contained(SupportedArchs, CurArch))
1156 Sema::CheckBuiltinFunctionCall(
FunctionDecl *FDecl,
unsigned BuiltinID,
1161 unsigned ICEArguments = 0;
1168 for (
unsigned ArgNo = 0; ICEArguments != 0; ++ArgNo) {
1170 if ((ICEArguments & (1 << ArgNo)) == 0)
continue;
1173 if (SemaBuiltinConstantArg(TheCall, ArgNo, Result))
1175 ICEArguments &= ~(1 << ArgNo);
1178 switch (BuiltinID) {
1179 case Builtin::BI__builtin___CFStringMakeConstantString:
1181 "Wrong # arguments to builtin CFStringMakeConstantString");
1182 if (CheckObjCString(TheCall->
getArg(0)))
1185 case Builtin::BI__builtin_ms_va_start:
1186 case Builtin::BI__builtin_stdarg_start:
1187 case Builtin::BI__builtin_va_start:
1188 if (SemaBuiltinVAStart(BuiltinID, TheCall))
1191 case Builtin::BI__va_start: {
1193 case llvm::Triple::aarch64:
1194 case llvm::Triple::arm:
1195 case llvm::Triple::thumb:
1196 if (SemaBuiltinVAStartARMMicrosoft(TheCall))
1200 if (SemaBuiltinVAStart(BuiltinID, TheCall))
1208 case Builtin::BI_interlockedbittestandset_acq:
1209 case Builtin::BI_interlockedbittestandset_rel:
1210 case Builtin::BI_interlockedbittestandset_nf:
1211 case Builtin::BI_interlockedbittestandreset_acq:
1212 case Builtin::BI_interlockedbittestandreset_rel:
1213 case Builtin::BI_interlockedbittestandreset_nf:
1215 *
this, BuiltinID, TheCall,
1216 {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
1221 case Builtin::BI_bittest64:
1222 case Builtin::BI_bittestandcomplement64:
1223 case Builtin::BI_bittestandreset64:
1224 case Builtin::BI_bittestandset64:
1225 case Builtin::BI_interlockedbittestandreset64:
1226 case Builtin::BI_interlockedbittestandset64:
1228 {llvm::Triple::x86_64, llvm::Triple::arm,
1229 llvm::Triple::thumb, llvm::Triple::aarch64}))
1233 case Builtin::BI__builtin_isgreater:
1234 case Builtin::BI__builtin_isgreaterequal:
1235 case Builtin::BI__builtin_isless:
1236 case Builtin::BI__builtin_islessequal:
1237 case Builtin::BI__builtin_islessgreater:
1238 case Builtin::BI__builtin_isunordered:
1239 if (SemaBuiltinUnorderedCompare(TheCall))
1242 case Builtin::BI__builtin_fpclassify:
1243 if (SemaBuiltinFPClassification(TheCall, 6))
1246 case Builtin::BI__builtin_isfinite:
1247 case Builtin::BI__builtin_isinf:
1248 case Builtin::BI__builtin_isinf_sign:
1249 case Builtin::BI__builtin_isnan:
1250 case Builtin::BI__builtin_isnormal:
1251 case Builtin::BI__builtin_signbit:
1252 case Builtin::BI__builtin_signbitf:
1253 case Builtin::BI__builtin_signbitl:
1254 if (SemaBuiltinFPClassification(TheCall, 1))
1257 case Builtin::BI__builtin_shufflevector:
1258 return SemaBuiltinShuffleVector(TheCall);
1261 case Builtin::BI__builtin_prefetch:
1262 if (SemaBuiltinPrefetch(TheCall))
1265 case Builtin::BI__builtin_alloca_with_align:
1266 if (SemaBuiltinAllocaWithAlign(TheCall))
1269 case Builtin::BI__builtin_alloca:
1273 case Builtin::BI__assume:
1274 case Builtin::BI__builtin_assume:
1275 if (SemaBuiltinAssume(TheCall))
1278 case Builtin::BI__builtin_assume_aligned:
1279 if (SemaBuiltinAssumeAligned(TheCall))
1282 case Builtin::BI__builtin_dynamic_object_size:
1283 case Builtin::BI__builtin_object_size:
1284 if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 3))
1287 case Builtin::BI__builtin_longjmp:
1288 if (SemaBuiltinLongjmp(TheCall))
1291 case Builtin::BI__builtin_setjmp:
1292 if (SemaBuiltinSetjmp(TheCall))
1295 case Builtin::BI_setjmp:
1296 case Builtin::BI_setjmpex:
1300 case Builtin::BI__builtin_classify_type:
1304 case Builtin::BI__builtin_constant_p: {
1312 case Builtin::BI__builtin_launder:
1314 case Builtin::BI__sync_fetch_and_add:
1315 case Builtin::BI__sync_fetch_and_add_1:
1316 case Builtin::BI__sync_fetch_and_add_2:
1317 case Builtin::BI__sync_fetch_and_add_4:
1318 case Builtin::BI__sync_fetch_and_add_8:
1319 case Builtin::BI__sync_fetch_and_add_16:
1320 case Builtin::BI__sync_fetch_and_sub:
1321 case Builtin::BI__sync_fetch_and_sub_1:
1322 case Builtin::BI__sync_fetch_and_sub_2:
1323 case Builtin::BI__sync_fetch_and_sub_4:
1324 case Builtin::BI__sync_fetch_and_sub_8:
1325 case Builtin::BI__sync_fetch_and_sub_16:
1326 case Builtin::BI__sync_fetch_and_or:
1327 case Builtin::BI__sync_fetch_and_or_1:
1328 case Builtin::BI__sync_fetch_and_or_2:
1329 case Builtin::BI__sync_fetch_and_or_4:
1330 case Builtin::BI__sync_fetch_and_or_8:
1331 case Builtin::BI__sync_fetch_and_or_16:
1332 case Builtin::BI__sync_fetch_and_and:
1333 case Builtin::BI__sync_fetch_and_and_1:
1334 case Builtin::BI__sync_fetch_and_and_2:
1335 case Builtin::BI__sync_fetch_and_and_4:
1336 case Builtin::BI__sync_fetch_and_and_8:
1337 case Builtin::BI__sync_fetch_and_and_16:
1338 case Builtin::BI__sync_fetch_and_xor:
1339 case Builtin::BI__sync_fetch_and_xor_1:
1340 case Builtin::BI__sync_fetch_and_xor_2:
1341 case Builtin::BI__sync_fetch_and_xor_4:
1342 case Builtin::BI__sync_fetch_and_xor_8:
1343 case Builtin::BI__sync_fetch_and_xor_16:
1344 case Builtin::BI__sync_fetch_and_nand:
1345 case Builtin::BI__sync_fetch_and_nand_1:
1346 case Builtin::BI__sync_fetch_and_nand_2:
1347 case Builtin::BI__sync_fetch_and_nand_4:
1348 case Builtin::BI__sync_fetch_and_nand_8:
1349 case Builtin::BI__sync_fetch_and_nand_16:
1350 case Builtin::BI__sync_add_and_fetch:
1351 case Builtin::BI__sync_add_and_fetch_1:
1352 case Builtin::BI__sync_add_and_fetch_2:
1353 case Builtin::BI__sync_add_and_fetch_4:
1354 case Builtin::BI__sync_add_and_fetch_8:
1355 case Builtin::BI__sync_add_and_fetch_16:
1356 case Builtin::BI__sync_sub_and_fetch:
1357 case Builtin::BI__sync_sub_and_fetch_1:
1358 case Builtin::BI__sync_sub_and_fetch_2:
1359 case Builtin::BI__sync_sub_and_fetch_4:
1360 case Builtin::BI__sync_sub_and_fetch_8:
1361 case Builtin::BI__sync_sub_and_fetch_16:
1362 case Builtin::BI__sync_and_and_fetch:
1363 case Builtin::BI__sync_and_and_fetch_1:
1364 case Builtin::BI__sync_and_and_fetch_2:
1365 case Builtin::BI__sync_and_and_fetch_4:
1366 case Builtin::BI__sync_and_and_fetch_8:
1367 case Builtin::BI__sync_and_and_fetch_16:
1368 case Builtin::BI__sync_or_and_fetch:
1369 case Builtin::BI__sync_or_and_fetch_1:
1370 case Builtin::BI__sync_or_and_fetch_2:
1371 case Builtin::BI__sync_or_and_fetch_4:
1372 case Builtin::BI__sync_or_and_fetch_8:
1373 case Builtin::BI__sync_or_and_fetch_16:
1374 case Builtin::BI__sync_xor_and_fetch:
1375 case Builtin::BI__sync_xor_and_fetch_1:
1376 case Builtin::BI__sync_xor_and_fetch_2:
1377 case Builtin::BI__sync_xor_and_fetch_4:
1378 case Builtin::BI__sync_xor_and_fetch_8:
1379 case Builtin::BI__sync_xor_and_fetch_16:
1380 case Builtin::BI__sync_nand_and_fetch:
1381 case Builtin::BI__sync_nand_and_fetch_1:
1382 case Builtin::BI__sync_nand_and_fetch_2:
1383 case Builtin::BI__sync_nand_and_fetch_4:
1384 case Builtin::BI__sync_nand_and_fetch_8:
1385 case Builtin::BI__sync_nand_and_fetch_16:
1386 case Builtin::BI__sync_val_compare_and_swap:
1387 case Builtin::BI__sync_val_compare_and_swap_1:
1388 case Builtin::BI__sync_val_compare_and_swap_2:
1389 case Builtin::BI__sync_val_compare_and_swap_4:
1390 case Builtin::BI__sync_val_compare_and_swap_8:
1391 case Builtin::BI__sync_val_compare_and_swap_16:
1392 case Builtin::BI__sync_bool_compare_and_swap:
1393 case Builtin::BI__sync_bool_compare_and_swap_1:
1394 case Builtin::BI__sync_bool_compare_and_swap_2:
1395 case Builtin::BI__sync_bool_compare_and_swap_4:
1396 case Builtin::BI__sync_bool_compare_and_swap_8:
1397 case Builtin::BI__sync_bool_compare_and_swap_16:
1398 case Builtin::BI__sync_lock_test_and_set:
1399 case Builtin::BI__sync_lock_test_and_set_1:
1400 case Builtin::BI__sync_lock_test_and_set_2:
1401 case Builtin::BI__sync_lock_test_and_set_4:
1402 case Builtin::BI__sync_lock_test_and_set_8:
1403 case Builtin::BI__sync_lock_test_and_set_16:
1404 case Builtin::BI__sync_lock_release:
1405 case Builtin::BI__sync_lock_release_1:
1406 case Builtin::BI__sync_lock_release_2:
1407 case Builtin::BI__sync_lock_release_4:
1408 case Builtin::BI__sync_lock_release_8:
1409 case Builtin::BI__sync_lock_release_16:
1410 case Builtin::BI__sync_swap:
1411 case Builtin::BI__sync_swap_1:
1412 case Builtin::BI__sync_swap_2:
1413 case Builtin::BI__sync_swap_4:
1414 case Builtin::BI__sync_swap_8:
1415 case Builtin::BI__sync_swap_16:
1416 return SemaBuiltinAtomicOverloaded(TheCallResult);
1417 case Builtin::BI__sync_synchronize:
1421 case Builtin::BI__builtin_nontemporal_load:
1422 case Builtin::BI__builtin_nontemporal_store:
1423 return SemaBuiltinNontemporalOverloaded(TheCallResult);
1424 #define BUILTIN(ID, TYPE, ATTRS) 1425 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ 1426 case Builtin::BI##ID: \ 1427 return SemaAtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID); 1428 #include "clang/Basic/Builtins.def" 1429 case Builtin::BI__annotation:
1433 case Builtin::BI__builtin_annotation:
1437 case Builtin::BI__builtin_addressof:
1441 case Builtin::BI__builtin_is_aligned:
1442 case Builtin::BI__builtin_align_up:
1443 case Builtin::BI__builtin_align_down:
1447 case Builtin::BI__builtin_add_overflow:
1448 case Builtin::BI__builtin_sub_overflow:
1449 case Builtin::BI__builtin_mul_overflow:
1453 case Builtin::BI__builtin_operator_new:
1454 case Builtin::BI__builtin_operator_delete: {
1455 bool IsDelete = BuiltinID == Builtin::BI__builtin_operator_delete;
1457 SemaBuiltinOperatorNewDeleteOverloaded(TheCallResult, IsDelete);
1459 CorrectDelayedTyposInExpr(TheCallResult.
get());
1462 case Builtin::BI__builtin_dump_struct: {
1472 << PtrArgType <<
"structure pointer" << 1 << 0 << 3 << 1 << PtrArgType
1473 <<
"structure pointer";
1481 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1482 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3 << 2
1483 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1487 const auto *FuncType =
1491 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1492 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3 << 2
1493 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1497 if (
const auto *FT = dyn_cast<FunctionProtoType>(FuncType)) {
1498 if (!FT->getNumParams()) {
1499 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1500 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1501 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1505 if (!FT->isVariadic() || FT->getReturnType() != Context.
IntTy ||
1508 Diag(FnPtrArg->
getBeginLoc(), diag::err_typecheck_convert_incompatible)
1509 << FnPtrArgType <<
"'int (*)(const char *, ...)'" << 1 << 0 << 3
1510 << 2 << FnPtrArgType <<
"'int (*)(const char *, ...)'";
1518 case Builtin::BI__builtin_preserve_access_index:
1522 case Builtin::BI__builtin_call_with_static_chain:
1526 case Builtin::BI__exception_code:
1527 case Builtin::BI_exception_code:
1529 diag::err_seh___except_block))
1532 case Builtin::BI__exception_info:
1533 case Builtin::BI_exception_info:
1535 diag::err_seh___except_filter))
1538 case Builtin::BI__GetExceptionInfo:
1542 if (CheckCXXThrowOperand(
1551 case Builtin::BIread_pipe:
1552 case Builtin::BIwrite_pipe:
1558 case Builtin::BIreserve_read_pipe:
1559 case Builtin::BIreserve_write_pipe:
1560 case Builtin::BIwork_group_reserve_read_pipe:
1561 case Builtin::BIwork_group_reserve_write_pipe:
1565 case Builtin::BIsub_group_reserve_read_pipe:
1566 case Builtin::BIsub_group_reserve_write_pipe:
1571 case Builtin::BIcommit_read_pipe:
1572 case Builtin::BIcommit_write_pipe:
1573 case Builtin::BIwork_group_commit_read_pipe:
1574 case Builtin::BIwork_group_commit_write_pipe:
1578 case Builtin::BIsub_group_commit_read_pipe:
1579 case Builtin::BIsub_group_commit_write_pipe:
1584 case Builtin::BIget_pipe_num_packets:
1585 case Builtin::BIget_pipe_max_packets:
1589 case Builtin::BIto_global:
1590 case Builtin::BIto_local:
1591 case Builtin::BIto_private:
1596 case Builtin::BIenqueue_kernel:
1600 case Builtin::BIget_kernel_work_group_size:
1601 case Builtin::BIget_kernel_preferred_work_group_size_multiple:
1605 case Builtin::BIget_kernel_max_sub_group_size_for_ndrange:
1606 case Builtin::BIget_kernel_sub_group_count_for_ndrange:
1610 case Builtin::BI__builtin_os_log_format:
1611 case Builtin::BI__builtin_os_log_format_buffer_size:
1612 if (SemaBuiltinOSLogFormat(TheCall))
1621 case llvm::Triple::arm:
1622 case llvm::Triple::armeb:
1623 case llvm::Triple::thumb:
1624 case llvm::Triple::thumbeb:
1625 if (CheckARMBuiltinFunctionCall(BuiltinID, TheCall))
1628 case llvm::Triple::aarch64:
1629 case llvm::Triple::aarch64_32:
1630 case llvm::Triple::aarch64_be:
1631 if (CheckAArch64BuiltinFunctionCall(BuiltinID, TheCall))
1634 case llvm::Triple::bpfeb:
1635 case llvm::Triple::bpfel:
1636 if (CheckBPFBuiltinFunctionCall(BuiltinID, TheCall))
1639 case llvm::Triple::hexagon:
1640 if (CheckHexagonBuiltinFunctionCall(BuiltinID, TheCall))
1643 case llvm::Triple::mips:
1644 case llvm::Triple::mipsel:
1645 case llvm::Triple::mips64:
1646 case llvm::Triple::mips64el:
1647 if (CheckMipsBuiltinFunctionCall(BuiltinID, TheCall))
1650 case llvm::Triple::systemz:
1651 if (CheckSystemZBuiltinFunctionCall(BuiltinID, TheCall))
1654 case llvm::Triple::x86:
1655 case llvm::Triple::x86_64:
1656 if (CheckX86BuiltinFunctionCall(BuiltinID, TheCall))
1659 case llvm::Triple::ppc:
1660 case llvm::Triple::ppc64:
1661 case llvm::Triple::ppc64le:
1662 if (CheckPPCBuiltinFunctionCall(BuiltinID, TheCall))
1670 return TheCallResult;
1674 static unsigned RFT(
unsigned t,
bool shift =
false,
bool ForceQuad =
false) {
1676 int IsQuad = ForceQuad ?
true : Type.
isQuad();
1680 return shift ? 7 : (8 << IsQuad) - 1;
1683 return shift ? 15 : (4 << IsQuad) - 1;
1685 return shift ? 31 : (2 << IsQuad) - 1;
1688 return shift ? 63 : (1 << IsQuad) - 1;
1690 return shift ? 127 : (1 << IsQuad) - 1;
1692 assert(!shift &&
"cannot shift float types!");
1693 return (4 << IsQuad) - 1;
1695 assert(!shift &&
"cannot shift float types!");
1696 return (2 << IsQuad) - 1;
1698 assert(!shift &&
"cannot shift float types!");
1699 return (1 << IsQuad) - 1;
1701 llvm_unreachable(
"Invalid NeonTypeFlag!");
1708 bool IsPolyUnsigned,
bool IsInt64Long) {
1740 llvm_unreachable(
"Invalid NeonTypeFlag!");
1743 bool Sema::CheckNeonBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
1748 bool HasConstPtr =
false;
1749 switch (BuiltinID) {
1750 #define GET_NEON_OVERLOAD_CHECK 1751 #include "clang/Basic/arm_neon.inc" 1752 #include "clang/Basic/arm_fp16.inc" 1753 #undef GET_NEON_OVERLOAD_CHECK 1760 if (SemaBuiltinConstantArg(TheCall, ImmArg, Result))
1763 TV = Result.getLimitedValue(64);
1764 if ((TV > 63) || (mask & (1ULL << TV)) == 0)
1769 if (PtrArgNum >= 0) {
1773 Arg = ICE->getSubExpr();
1774 ExprResult RHS = DefaultFunctionArrayLvalueConversion(Arg);
1778 bool IsPolyUnsigned = Arch == llvm::Triple::aarch64 ||
1779 Arch == llvm::Triple::aarch64_32 ||
1780 Arch == llvm::Triple::aarch64_be;
1788 AssignConvertType ConvTy;
1789 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
1792 if (DiagnoseAssignmentResult(ConvTy, Arg->
getBeginLoc(), LHSTy, RHSTy,
1793 RHS.
get(), AA_Assigning))
1799 unsigned i = 0, l = 0, u = 0;
1800 switch (BuiltinID) {
1803 #define GET_NEON_IMMEDIATE_CHECK 1804 #include "clang/Basic/arm_neon.inc" 1805 #include "clang/Basic/arm_fp16.inc" 1806 #undef GET_NEON_IMMEDIATE_CHECK 1809 return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
1812 bool Sema::CheckMVEBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
1813 switch (BuiltinID) {
1816 #include "clang/Basic/arm_mve_builtin_sema.inc" 1820 bool Sema::CheckARMBuiltinExclusiveCall(
unsigned BuiltinID,
CallExpr *TheCall,
1821 unsigned MaxWidth) {
1822 assert((BuiltinID == ARM::BI__builtin_arm_ldrex ||
1823 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1824 BuiltinID == ARM::BI__builtin_arm_strex ||
1825 BuiltinID == ARM::BI__builtin_arm_stlex ||
1826 BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1827 BuiltinID == AArch64::BI__builtin_arm_ldaex ||
1828 BuiltinID == AArch64::BI__builtin_arm_strex ||
1829 BuiltinID == AArch64::BI__builtin_arm_stlex) &&
1830 "unexpected ARM builtin");
1831 bool IsLdrex = BuiltinID == ARM::BI__builtin_arm_ldrex ||
1832 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1833 BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1834 BuiltinID == AArch64::BI__builtin_arm_ldaex;
1846 Expr *PointerArg = TheCall->
getArg(IsLdrex ? 0 : 1);
1847 ExprResult PointerArgRes = DefaultFunctionArrayLvalueConversion(PointerArg);
1850 PointerArg = PointerArgRes.
get();
1870 CastNeeded = CK_BitCast;
1871 Diag(DRE->
getBeginLoc(), diag::ext_typecheck_convert_discards_qualifiers)
1878 PointerArgRes = ImpCastExprToType(PointerArg, AddrType, CastNeeded);
1881 PointerArg = PointerArgRes.
get();
1883 TheCall->
setArg(IsLdrex ? 0 : 1, PointerArg);
1888 Diag(DRE->
getBeginLoc(), diag::err_atomic_builtin_must_be_pointer_intfltptr)
1895 assert(MaxWidth == 64 &&
"Diagnostic unexpectedly inaccurate");
1896 Diag(DRE->
getBeginLoc(), diag::err_atomic_exclusive_builtin_pointer_size)
1923 Context, ValType,
false);
1924 ValArg = PerformCopyInitialization(Entity,
SourceLocation(), ValArg);
1935 bool Sema::CheckARMBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
1936 if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
1937 BuiltinID == ARM::BI__builtin_arm_ldaex ||
1938 BuiltinID == ARM::BI__builtin_arm_strex ||
1939 BuiltinID == ARM::BI__builtin_arm_stlex) {
1940 return CheckARMBuiltinExclusiveCall(BuiltinID, TheCall, 64);
1943 if (BuiltinID == ARM::BI__builtin_arm_prefetch) {
1944 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
1945 SemaBuiltinConstantArgRange(TheCall, 2, 0, 1);
1948 if (BuiltinID == ARM::BI__builtin_arm_rsr64 ||
1949 BuiltinID == ARM::BI__builtin_arm_wsr64)
1950 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 3,
false);
1952 if (BuiltinID == ARM::BI__builtin_arm_rsr ||
1953 BuiltinID == ARM::BI__builtin_arm_rsrp ||
1954 BuiltinID == ARM::BI__builtin_arm_wsr ||
1955 BuiltinID == ARM::BI__builtin_arm_wsrp)
1956 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
1958 if (CheckNeonBuiltinFunctionCall(BuiltinID, TheCall))
1960 if (CheckMVEBuiltinFunctionCall(BuiltinID, TheCall))
1966 switch (BuiltinID) {
1967 default:
return false;
1968 case ARM::BI__builtin_arm_ssat:
1969 return SemaBuiltinConstantArgRange(TheCall, 1, 1, 32);
1970 case ARM::BI__builtin_arm_usat:
1971 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 31);
1972 case ARM::BI__builtin_arm_ssat16:
1973 return SemaBuiltinConstantArgRange(TheCall, 1, 1, 16);
1974 case ARM::BI__builtin_arm_usat16:
1975 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
1976 case ARM::BI__builtin_arm_vcvtr_f:
1977 case ARM::BI__builtin_arm_vcvtr_d:
1978 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
1979 case ARM::BI__builtin_arm_dmb:
1980 case ARM::BI__builtin_arm_dsb:
1981 case ARM::BI__builtin_arm_isb:
1982 case ARM::BI__builtin_arm_dbg:
1983 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 15);
1987 bool Sema::CheckAArch64BuiltinFunctionCall(
unsigned BuiltinID,
1989 if (BuiltinID == AArch64::BI__builtin_arm_ldrex ||
1990 BuiltinID == AArch64::BI__builtin_arm_ldaex ||
1991 BuiltinID == AArch64::BI__builtin_arm_strex ||
1992 BuiltinID == AArch64::BI__builtin_arm_stlex) {
1993 return CheckARMBuiltinExclusiveCall(BuiltinID, TheCall, 128);
1996 if (BuiltinID == AArch64::BI__builtin_arm_prefetch) {
1997 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
1998 SemaBuiltinConstantArgRange(TheCall, 2, 0, 2) ||
1999 SemaBuiltinConstantArgRange(TheCall, 3, 0, 1) ||
2000 SemaBuiltinConstantArgRange(TheCall, 4, 0, 1);
2003 if (BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
2004 BuiltinID == AArch64::BI__builtin_arm_wsr64)
2005 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
2008 if (BuiltinID == AArch64::BI__builtin_arm_irg ||
2009 BuiltinID == AArch64::BI__builtin_arm_addg ||
2010 BuiltinID == AArch64::BI__builtin_arm_gmi ||
2011 BuiltinID == AArch64::BI__builtin_arm_ldg ||
2012 BuiltinID == AArch64::BI__builtin_arm_stg ||
2013 BuiltinID == AArch64::BI__builtin_arm_subp) {
2014 return SemaBuiltinARMMemoryTaggingCall(BuiltinID, TheCall);
2017 if (BuiltinID == AArch64::BI__builtin_arm_rsr ||
2018 BuiltinID == AArch64::BI__builtin_arm_rsrp ||
2019 BuiltinID == AArch64::BI__builtin_arm_wsr ||
2020 BuiltinID == AArch64::BI__builtin_arm_wsrp)
2021 return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5,
true);
2026 if (BuiltinID == AArch64::BI_ReadStatusReg ||
2027 BuiltinID == AArch64::BI_WriteStatusReg)
2028 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 0x7fff);
2030 if (BuiltinID == AArch64::BI__getReg)
2031 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31);
2033 if (CheckNeonBuiltinFunctionCall(BuiltinID, TheCall))
2038 unsigned i = 0, l = 0, u = 0;
2039 switch (BuiltinID) {
2040 default:
return false;
2041 case AArch64::BI__builtin_arm_dmb:
2042 case AArch64::BI__builtin_arm_dsb:
2043 case AArch64::BI__builtin_arm_isb: l = 0; u = 15;
break;
2044 case AArch64::BI__builtin_arm_tcancel: l = 0; u = 65535;
break;
2047 return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
2050 bool Sema::CheckBPFBuiltinFunctionCall(
unsigned BuiltinID,
2052 assert(BuiltinID == BPF::BI__builtin_preserve_field_info &&
2053 "unexpected ARM builtin");
2084 bool Sema::CheckHexagonBuiltinCpu(
unsigned BuiltinID,
CallExpr *TheCall) {
2085 struct BuiltinAndString {
2090 static BuiltinAndString ValidCPU[] = {
2091 { Hexagon::BI__builtin_HEXAGON_A6_vcmpbeq_notany,
"v65,v66" },
2092 { Hexagon::BI__builtin_HEXAGON_A6_vminub_RdP,
"v62,v65,v66" },
2093 { Hexagon::BI__builtin_HEXAGON_F2_dfadd,
"v66" },
2094 { Hexagon::BI__builtin_HEXAGON_F2_dfsub,
"v66" },
2095 { Hexagon::BI__builtin_HEXAGON_M2_mnaci,
"v66" },
2096 { Hexagon::BI__builtin_HEXAGON_M6_vabsdiffb,
"v62,v65,v66" },
2097 { Hexagon::BI__builtin_HEXAGON_M6_vabsdiffub,
"v62,v65,v66" },
2098 { Hexagon::BI__builtin_HEXAGON_S2_mask,
"v66" },
2099 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc,
"v60,v62,v65,v66" },
2100 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and,
"v60,v62,v65,v66" },
2101 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac,
"v60,v62,v65,v66" },
2102 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or,
"v60,v62,v65,v66" },
2103 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p,
"v60,v62,v65,v66" },
2104 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc,
"v60,v62,v65,v66" },
2105 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc,
"v60,v62,v65,v66" },
2106 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and,
"v60,v62,v65,v66" },
2107 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac,
"v60,v62,v65,v66" },
2108 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or,
"v60,v62,v65,v66" },
2109 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r,
"v60,v62,v65,v66" },
2110 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc,
"v60,v62,v65,v66" },
2111 { Hexagon::BI__builtin_HEXAGON_S6_vsplatrbp,
"v62,v65,v66" },
2112 { Hexagon::BI__builtin_HEXAGON_S6_vtrunehb_ppp,
"v62,v65,v66" },
2113 { Hexagon::BI__builtin_HEXAGON_S6_vtrunohb_ppp,
"v62,v65,v66" },
2116 static BuiltinAndString ValidHVX[] = {
2117 { Hexagon::BI__builtin_HEXAGON_V6_hi,
"v60,v62,v65,v66" },
2118 { Hexagon::BI__builtin_HEXAGON_V6_hi_128B,
"v60,v62,v65,v66" },
2119 { Hexagon::BI__builtin_HEXAGON_V6_lo,
"v60,v62,v65,v66" },
2120 { Hexagon::BI__builtin_HEXAGON_V6_lo_128B,
"v60,v62,v65,v66" },
2121 { Hexagon::BI__builtin_HEXAGON_V6_extractw,
"v60,v62,v65,v66" },
2122 { Hexagon::BI__builtin_HEXAGON_V6_extractw_128B,
"v60,v62,v65,v66" },
2123 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatb,
"v62,v65,v66" },
2124 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatb_128B,
"v62,v65,v66" },
2125 { Hexagon::BI__builtin_HEXAGON_V6_lvsplath,
"v62,v65,v66" },
2126 { Hexagon::BI__builtin_HEXAGON_V6_lvsplath_128B,
"v62,v65,v66" },
2127 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatw,
"v60,v62,v65,v66" },
2128 { Hexagon::BI__builtin_HEXAGON_V6_lvsplatw_128B,
"v60,v62,v65,v66" },
2129 { Hexagon::BI__builtin_HEXAGON_V6_pred_and,
"v60,v62,v65,v66" },
2130 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_128B,
"v60,v62,v65,v66" },
2131 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_n,
"v60,v62,v65,v66" },
2132 { Hexagon::BI__builtin_HEXAGON_V6_pred_and_n_128B,
"v60,v62,v65,v66" },
2133 { Hexagon::BI__builtin_HEXAGON_V6_pred_not,
"v60,v62,v65,v66" },
2134 { Hexagon::BI__builtin_HEXAGON_V6_pred_not_128B,
"v60,v62,v65,v66" },
2135 { Hexagon::BI__builtin_HEXAGON_V6_pred_or,
"v60,v62,v65,v66" },
2136 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_128B,
"v60,v62,v65,v66" },
2137 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_n,
"v60,v62,v65,v66" },
2138 { Hexagon::BI__builtin_HEXAGON_V6_pred_or_n_128B,
"v60,v62,v65,v66" },
2139 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2,
"v60,v62,v65,v66" },
2140 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2_128B,
"v60,v62,v65,v66" },
2141 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2v2,
"v62,v65,v66" },
2142 { Hexagon::BI__builtin_HEXAGON_V6_pred_scalar2v2_128B,
"v62,v65,v66" },
2143 { Hexagon::BI__builtin_HEXAGON_V6_pred_xor,
"v60,v62,v65,v66" },
2144 { Hexagon::BI__builtin_HEXAGON_V6_pred_xor_128B,
"v60,v62,v65,v66" },
2145 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqh,
"v62,v65,v66" },
2146 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqh_128B,
"v62,v65,v66" },
2147 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqw,
"v62,v65,v66" },
2148 { Hexagon::BI__builtin_HEXAGON_V6_shuffeqw_128B,
"v62,v65,v66" },
2149 { Hexagon::BI__builtin_HEXAGON_V6_vabsb,
"v65,v66" },
2150 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_128B,
"v65,v66" },
2151 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_sat,
"v65,v66" },
2152 { Hexagon::BI__builtin_HEXAGON_V6_vabsb_sat_128B,
"v65,v66" },
2153 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffh,
"v60,v62,v65,v66" },
2154 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffh_128B,
"v60,v62,v65,v66" },
2155 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffub,
"v60,v62,v65,v66" },
2156 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffub_128B,
"v60,v62,v65,v66" },
2157 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffuh,
"v60,v62,v65,v66" },
2158 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffuh_128B,
"v60,v62,v65,v66" },
2159 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffw,
"v60,v62,v65,v66" },
2160 { Hexagon::BI__builtin_HEXAGON_V6_vabsdiffw_128B,
"v60,v62,v65,v66" },
2161 { Hexagon::BI__builtin_HEXAGON_V6_vabsh,
"v60,v62,v65,v66" },
2162 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_128B,
"v60,v62,v65,v66" },
2163 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_sat,
"v60,v62,v65,v66" },
2164 { Hexagon::BI__builtin_HEXAGON_V6_vabsh_sat_128B,
"v60,v62,v65,v66" },
2165 { Hexagon::BI__builtin_HEXAGON_V6_vabsw,
"v60,v62,v65,v66" },
2166 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_128B,
"v60,v62,v65,v66" },
2167 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_sat,
"v60,v62,v65,v66" },
2168 { Hexagon::BI__builtin_HEXAGON_V6_vabsw_sat_128B,
"v60,v62,v65,v66" },
2169 { Hexagon::BI__builtin_HEXAGON_V6_vaddb,
"v60,v62,v65,v66" },
2170 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_128B,
"v60,v62,v65,v66" },
2171 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_dv,
"v60,v62,v65,v66" },
2172 { Hexagon::BI__builtin_HEXAGON_V6_vaddb_dv_128B,
"v60,v62,v65,v66" },
2173 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat,
"v62,v65,v66" },
2174 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_128B,
"v62,v65,v66" },
2175 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_dv,
"v62,v65,v66" },
2176 { Hexagon::BI__builtin_HEXAGON_V6_vaddbsat_dv_128B,
"v62,v65,v66" },
2177 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarry,
"v62,v65,v66" },
2178 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarry_128B,
"v62,v65,v66" },
2179 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarrysat,
"v66" },
2180 { Hexagon::BI__builtin_HEXAGON_V6_vaddcarrysat_128B,
"v66" },
2181 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbh,
"v62,v65,v66" },
2182 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbh_128B,
"v62,v65,v66" },
2183 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbw,
"v62,v65,v66" },
2184 { Hexagon::BI__builtin_HEXAGON_V6_vaddclbw_128B,
"v62,v65,v66" },
2185 { Hexagon::BI__builtin_HEXAGON_V6_vaddh,
"v60,v62,v65,v66" },
2186 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_128B,
"v60,v62,v65,v66" },
2187 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_dv,
"v60,v62,v65,v66" },
2188 { Hexagon::BI__builtin_HEXAGON_V6_vaddh_dv_128B,
"v60,v62,v65,v66" },
2189 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat,
"v60,v62,v65,v66" },
2190 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_128B,
"v60,v62,v65,v66" },
2191 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_dv,
"v60,v62,v65,v66" },
2192 { Hexagon::BI__builtin_HEXAGON_V6_vaddhsat_dv_128B,
"v60,v62,v65,v66" },
2193 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw,
"v60,v62,v65,v66" },
2194 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_128B,
"v60,v62,v65,v66" },
2195 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_acc,
"v62,v65,v66" },
2196 { Hexagon::BI__builtin_HEXAGON_V6_vaddhw_acc_128B,
"v62,v65,v66" },
2197 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh,
"v60,v62,v65,v66" },
2198 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_128B,
"v60,v62,v65,v66" },
2199 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_acc,
"v62,v65,v66" },
2200 { Hexagon::BI__builtin_HEXAGON_V6_vaddubh_acc_128B,
"v62,v65,v66" },
2201 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat,
"v60,v62,v65,v66" },
2202 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_128B,
"v60,v62,v65,v66" },
2203 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_dv,
"v60,v62,v65,v66" },
2204 { Hexagon::BI__builtin_HEXAGON_V6_vaddubsat_dv_128B,
"v60,v62,v65,v66" },
2205 { Hexagon::BI__builtin_HEXAGON_V6_vaddububb_sat,
"v62,v65,v66" },
2206 { Hexagon::BI__builtin_HEXAGON_V6_vaddububb_sat_128B,
"v62,v65,v66" },
2207 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat,
"v60,v62,v65,v66" },
2208 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_128B,
"v60,v62,v65,v66" },
2209 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_dv,
"v60,v62,v65,v66" },
2210 { Hexagon::BI__builtin_HEXAGON_V6_vadduhsat_dv_128B,
"v60,v62,v65,v66" },
2211 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw,
"v60,v62,v65,v66" },
2212 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_128B,
"v60,v62,v65,v66" },
2213 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_acc,
"v62,v65,v66" },
2214 { Hexagon::BI__builtin_HEXAGON_V6_vadduhw_acc_128B,
"v62,v65,v66" },
2215 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat,
"v62,v65,v66" },
2216 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_128B,
"v62,v65,v66" },
2217 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_dv,
"v62,v65,v66" },
2218 { Hexagon::BI__builtin_HEXAGON_V6_vadduwsat_dv_128B,
"v62,v65,v66" },
2219 { Hexagon::BI__builtin_HEXAGON_V6_vaddw,
"v60,v62,v65,v66" },
2220 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_128B,
"v60,v62,v65,v66" },
2221 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_dv,
"v60,v62,v65,v66" },
2222 { Hexagon::BI__builtin_HEXAGON_V6_vaddw_dv_128B,
"v60,v62,v65,v66" },
2223 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat,
"v60,v62,v65,v66" },
2224 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_128B,
"v60,v62,v65,v66" },
2225 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_dv,
"v60,v62,v65,v66" },
2226 { Hexagon::BI__builtin_HEXAGON_V6_vaddwsat_dv_128B,
"v60,v62,v65,v66" },
2227 { Hexagon::BI__builtin_HEXAGON_V6_valignb,
"v60,v62,v65,v66" },
2228 { Hexagon::BI__builtin_HEXAGON_V6_valignb_128B,
"v60,v62,v65,v66" },
2229 { Hexagon::BI__builtin_HEXAGON_V6_valignbi,
"v60,v62,v65,v66" },
2230 { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B,
"v60,v62,v65,v66" },
2231 { Hexagon::BI__builtin_HEXAGON_V6_vand,
"v60,v62,v65,v66" },
2232 { Hexagon::BI__builtin_HEXAGON_V6_vand_128B,
"v60,v62,v65,v66" },
2233 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt,
"v62,v65,v66" },
2234 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_128B,
"v62,v65,v66" },
2235 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_acc,
"v62,v65,v66" },
2236 { Hexagon::BI__builtin_HEXAGON_V6_vandnqrt_acc_128B,
"v62,v65,v66" },
2237 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt,
"v60,v62,v65,v66" },
2238 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_128B,
"v60,v62,v65,v66" },
2239 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_acc,
"v60,v62,v65,v66" },
2240 { Hexagon::BI__builtin_HEXAGON_V6_vandqrt_acc_128B,
"v60,v62,v65,v66" },
2241 { Hexagon::BI__builtin_HEXAGON_V6_vandvnqv,
"v62,v65,v66" },
2242 { Hexagon::BI__builtin_HEXAGON_V6_vandvnqv_128B,
"v62,v65,v66" },
2243 { Hexagon::BI__builtin_HEXAGON_V6_vandvqv,
"v62,v65,v66" },
2244 { Hexagon::BI__builtin_HEXAGON_V6_vandvqv_128B,
"v62,v65,v66" },
2245 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt,
"v60,v62,v65,v66" },
2246 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_128B,
"v60,v62,v65,v66" },
2247 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_acc,
"v60,v62,v65,v66" },
2248 { Hexagon::BI__builtin_HEXAGON_V6_vandvrt_acc_128B,
"v60,v62,v65,v66" },
2249 { Hexagon::BI__builtin_HEXAGON_V6_vaslh,
"v60,v62,v65,v66" },
2250 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_128B,
"v60,v62,v65,v66" },
2251 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_acc,
"v65,v66" },
2252 { Hexagon::BI__builtin_HEXAGON_V6_vaslh_acc_128B,
"v65,v66" },
2253 { Hexagon::BI__builtin_HEXAGON_V6_vaslhv,
"v60,v62,v65,v66" },
2254 { Hexagon::BI__builtin_HEXAGON_V6_vaslhv_128B,
"v60,v62,v65,v66" },
2255 { Hexagon::BI__builtin_HEXAGON_V6_vaslw,
"v60,v62,v65,v66" },
2256 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_128B,
"v60,v62,v65,v66" },
2257 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_acc,
"v60,v62,v65,v66" },
2258 { Hexagon::BI__builtin_HEXAGON_V6_vaslw_acc_128B,
"v60,v62,v65,v66" },
2259 { Hexagon::BI__builtin_HEXAGON_V6_vaslwv,
"v60,v62,v65,v66" },
2260 { Hexagon::BI__builtin_HEXAGON_V6_vaslwv_128B,
"v60,v62,v65,v66" },
2261 { Hexagon::BI__builtin_HEXAGON_V6_vasrh,
"v60,v62,v65,v66" },
2262 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_128B,
"v60,v62,v65,v66" },
2263 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_acc,
"v65,v66" },
2264 { Hexagon::BI__builtin_HEXAGON_V6_vasrh_acc_128B,
"v65,v66" },
2265 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbrndsat,
"v60,v62,v65,v66" },
2266 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbrndsat_128B,
"v60,v62,v65,v66" },
2267 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbsat,
"v62,v65,v66" },
2268 { Hexagon::BI__builtin_HEXAGON_V6_vasrhbsat_128B,
"v62,v65,v66" },
2269 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubrndsat,
"v60,v62,v65,v66" },
2270 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubrndsat_128B,
"v60,v62,v65,v66" },
2271 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubsat,
"v60,v62,v65,v66" },
2272 { Hexagon::BI__builtin_HEXAGON_V6_vasrhubsat_128B,
"v60,v62,v65,v66" },
2273 { Hexagon::BI__builtin_HEXAGON_V6_vasrhv,
"v60,v62,v65,v66" },
2274 { Hexagon::BI__builtin_HEXAGON_V6_vasrhv_128B,
"v60,v62,v65,v66" },
2275 { Hexagon::BI__builtin_HEXAGON_V6_vasr_into,
"v66" },
2276 { Hexagon::BI__builtin_HEXAGON_V6_vasr_into_128B,
"v66" },
2277 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubrndsat,
"v65,v66" },
2278 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubrndsat_128B,
"v65,v66" },
2279 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubsat,
"v65,v66" },
2280 { Hexagon::BI__builtin_HEXAGON_V6_vasruhubsat_128B,
"v65,v66" },
2281 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhrndsat,
"v62,v65,v66" },
2282 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhrndsat_128B,
"v62,v65,v66" },
2283 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhsat,
"v65,v66" },
2284 { Hexagon::BI__builtin_HEXAGON_V6_vasruwuhsat_128B,
"v65,v66" },
2285 { Hexagon::BI__builtin_HEXAGON_V6_vasrw,
"v60,v62,v65,v66" },
2286 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_128B,
"v60,v62,v65,v66" },
2287 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_acc,
"v60,v62,v65,v66" },
2288 { Hexagon::BI__builtin_HEXAGON_V6_vasrw_acc_128B,
"v60,v62,v65,v66" },
2289 { Hexagon::BI__builtin_HEXAGON_V6_vasrwh,
"v60,v62,v65,v66" },
2290 { Hexagon::BI__builtin_HEXAGON_V6_vasrwh_128B,
"v60,v62,v65,v66" },
2291 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhrndsat,
"v60,v62,v65,v66" },
2292 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhrndsat_128B,
"v60,v62,v65,v66" },
2293 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhsat,
"v60,v62,v65,v66" },
2294 { Hexagon::BI__builtin_HEXAGON_V6_vasrwhsat_128B,
"v60,v62,v65,v66" },
2295 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhrndsat,
"v62,v65,v66" },
2296 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhrndsat_128B,
"v62,v65,v66" },
2297 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhsat,
"v60,v62,v65,v66" },
2298 { Hexagon::BI__builtin_HEXAGON_V6_vasrwuhsat_128B,
"v60,v62,v65,v66" },
2299 { Hexagon::BI__builtin_HEXAGON_V6_vasrwv,
"v60,v62,v65,v66" },
2300 { Hexagon::BI__builtin_HEXAGON_V6_vasrwv_128B,
"v60,v62,v65,v66" },
2301 { Hexagon::BI__builtin_HEXAGON_V6_vassign,
"v60,v62,v65,v66" },
2302 { Hexagon::BI__builtin_HEXAGON_V6_vassign_128B,
"v60,v62,v65,v66" },
2303 { Hexagon::BI__builtin_HEXAGON_V6_vassignp,
"v60,v62,v65,v66" },
2304 { Hexagon::BI__builtin_HEXAGON_V6_vassignp_128B,
"v60,v62,v65,v66" },
2305 { Hexagon::BI__builtin_HEXAGON_V6_vavgb,
"v65,v66" },
2306 { Hexagon::BI__builtin_HEXAGON_V6_vavgb_128B,
"v65,v66" },
2307 { Hexagon::BI__builtin_HEXAGON_V6_vavgbrnd,
"v65,v66" },
2308 { Hexagon::BI__builtin_HEXAGON_V6_vavgbrnd_128B,
"v65,v66" },
2309 { Hexagon::BI__builtin_HEXAGON_V6_vavgh,
"v60,v62,v65,v66" },
2310 { Hexagon::BI__builtin_HEXAGON_V6_vavgh_128B,
"v60,v62,v65,v66" },
2311 { Hexagon::BI__builtin_HEXAGON_V6_vavghrnd,
"v60,v62,v65,v66" },
2312 { Hexagon::BI__builtin_HEXAGON_V6_vavghrnd_128B,
"v60,v62,v65,v66" },
2313 { Hexagon::BI__builtin_HEXAGON_V6_vavgub,
"v60,v62,v65,v66" },
2314 { Hexagon::BI__builtin_HEXAGON_V6_vavgub_128B,
"v60,v62,v65,v66" },
2315 { Hexagon::BI__builtin_HEXAGON_V6_vavgubrnd,
"v60,v62,v65,v66" },
2316 { Hexagon::BI__builtin_HEXAGON_V6_vavgubrnd_128B,
"v60,v62,v65,v66" },
2317 { Hexagon::BI__builtin_HEXAGON_V6_vavguh,
"v60,v62,v65,v66" },
2318 { Hexagon::BI__builtin_HEXAGON_V6_vavguh_128B,
"v60,v62,v65,v66" },
2319 { Hexagon::BI__builtin_HEXAGON_V6_vavguhrnd,
"v60,v62,v65,v66" },
2320 { Hexagon::BI__builtin_HEXAGON_V6_vavguhrnd_128B,
"v60,v62,v65,v66" },
2321 { Hexagon::BI__builtin_HEXAGON_V6_vavguw,
"v65,v66" },
2322 { Hexagon::BI__builtin_HEXAGON_V6_vavguw_128B,
"v65,v66" },
2323 { Hexagon::BI__builtin_HEXAGON_V6_vavguwrnd,
"v65,v66" },
2324 { Hexagon::BI__builtin_HEXAGON_V6_vavguwrnd_128B,
"v65,v66" },
2325 { Hexagon::BI__builtin_HEXAGON_V6_vavgw,
"v60,v62,v65,v66" },
2326 { Hexagon::BI__builtin_HEXAGON_V6_vavgw_128B,
"v60,v62,v65,v66" },
2327 { Hexagon::BI__builtin_HEXAGON_V6_vavgwrnd,
"v60,v62,v65,v66" },
2328 { Hexagon::BI__builtin_HEXAGON_V6_vavgwrnd_128B,
"v60,v62,v65,v66" },
2329 { Hexagon::BI__builtin_HEXAGON_V6_vcl0h,
"v60,v62,v65,v66" },
2330 { Hexagon::BI__builtin_HEXAGON_V6_vcl0h_128B,
"v60,v62,v65,v66" },
2331 { Hexagon::BI__builtin_HEXAGON_V6_vcl0w,
"v60,v62,v65,v66" },
2332 { Hexagon::BI__builtin_HEXAGON_V6_vcl0w_128B,
"v60,v62,v65,v66" },
2333 { Hexagon::BI__builtin_HEXAGON_V6_vcombine,
"v60,v62,v65,v66" },
2334 { Hexagon::BI__builtin_HEXAGON_V6_vcombine_128B,
"v60,v62,v65,v66" },
2335 { Hexagon::BI__builtin_HEXAGON_V6_vd0,
"v60,v62,v65,v66" },
2336 { Hexagon::BI__builtin_HEXAGON_V6_vd0_128B,
"v60,v62,v65,v66" },
2337 { Hexagon::BI__builtin_HEXAGON_V6_vdd0,
"v65,v66" },
2338 { Hexagon::BI__builtin_HEXAGON_V6_vdd0_128B,
"v65,v66" },
2339 { Hexagon::BI__builtin_HEXAGON_V6_vdealb,
"v60,v62,v65,v66" },
2340 { Hexagon::BI__builtin_HEXAGON_V6_vdealb_128B,
"v60,v62,v65,v66" },
2341 { Hexagon::BI__builtin_HEXAGON_V6_vdealb4w,
"v60,v62,v65,v66" },
2342 { Hexagon::BI__builtin_HEXAGON_V6_vdealb4w_128B,
"v60,v62,v65,v66" },
2343 { Hexagon::BI__builtin_HEXAGON_V6_vdealh,
"v60,v62,v65,v66" },
2344 { Hexagon::BI__builtin_HEXAGON_V6_vdealh_128B,
"v60,v62,v65,v66" },
2345 { Hexagon::BI__builtin_HEXAGON_V6_vdealvdd,
"v60,v62,v65,v66" },
2346 { Hexagon::BI__builtin_HEXAGON_V6_vdealvdd_128B,
"v60,v62,v65,v66" },
2347 { Hexagon::BI__builtin_HEXAGON_V6_vdelta,
"v60,v62,v65,v66" },
2348 { Hexagon::BI__builtin_HEXAGON_V6_vdelta_128B,
"v60,v62,v65,v66" },
2349 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus,
"v60,v62,v65,v66" },
2350 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_128B,
"v60,v62,v65,v66" },
2351 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_acc,
"v60,v62,v65,v66" },
2352 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_acc_128B,
"v60,v62,v65,v66" },
2353 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv,
"v60,v62,v65,v66" },
2354 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_128B,
"v60,v62,v65,v66" },
2355 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_acc,
"v60,v62,v65,v66" },
2356 { Hexagon::BI__builtin_HEXAGON_V6_vdmpybus_dv_acc_128B,
"v60,v62,v65,v66" },
2357 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb,
"v60,v62,v65,v66" },
2358 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_128B,
"v60,v62,v65,v66" },
2359 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_acc,
"v60,v62,v65,v66" },
2360 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_acc_128B,
"v60,v62,v65,v66" },
2361 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv,
"v60,v62,v65,v66" },
2362 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_128B,
"v60,v62,v65,v66" },
2363 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_acc,
"v60,v62,v65,v66" },
2364 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhb_dv_acc_128B,
"v60,v62,v65,v66" },
2365 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat,
"v60,v62,v65,v66" },
2366 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_128B,
"v60,v62,v65,v66" },
2367 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_acc,
"v60,v62,v65,v66" },
2368 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhisat_acc_128B,
"v60,v62,v65,v66" },
2369 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat,
"v60,v62,v65,v66" },
2370 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_128B,
"v60,v62,v65,v66" },
2371 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_acc,
"v60,v62,v65,v66" },
2372 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsat_acc_128B,
"v60,v62,v65,v66" },
2373 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat,
"v60,v62,v65,v66" },
2374 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_128B,
"v60,v62,v65,v66" },
2375 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_acc,
"v60,v62,v65,v66" },
2376 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsuisat_acc_128B,
"v60,v62,v65,v66" },
2377 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat,
"v60,v62,v65,v66" },
2378 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_128B,
"v60,v62,v65,v66" },
2379 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_acc,
"v60,v62,v65,v66" },
2380 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhsusat_acc_128B,
"v60,v62,v65,v66" },
2381 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat,
"v60,v62,v65,v66" },
2382 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_128B,
"v60,v62,v65,v66" },
2383 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_acc,
"v60,v62,v65,v66" },
2384 { Hexagon::BI__builtin_HEXAGON_V6_vdmpyhvsat_acc_128B,
"v60,v62,v65,v66" },
2385 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh,
"v60,v62,v65,v66" },
2386 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_128B,
"v60,v62,v65,v66" },
2387 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_acc,
"v60,v62,v65,v66" },
2388 { Hexagon::BI__builtin_HEXAGON_V6_vdsaduh_acc_128B,
"v60,v62,v65,v66" },
2389 { Hexagon::BI__builtin_HEXAGON_V6_veqb,
"v60,v62,v65,v66" },
2390 { Hexagon::BI__builtin_HEXAGON_V6_veqb_128B,
"v60,v62,v65,v66" },
2391 { Hexagon::BI__builtin_HEXAGON_V6_veqb_and,
"v60,v62,v65,v66" },
2392 { Hexagon::BI__builtin_HEXAGON_V6_veqb_and_128B,
"v60,v62,v65,v66" },
2393 { Hexagon::BI__builtin_HEXAGON_V6_veqb_or,
"v60,v62,v65,v66" },
2394 { Hexagon::BI__builtin_HEXAGON_V6_veqb_or_128B,
"v60,v62,v65,v66" },
2395 { Hexagon::BI__builtin_HEXAGON_V6_veqb_xor,
"v60,v62,v65,v66" },
2396 { Hexagon::BI__builtin_HEXAGON_V6_veqb_xor_128B,
"v60,v62,v65,v66" },
2397 { Hexagon::BI__builtin_HEXAGON_V6_veqh,
"v60,v62,v65,v66" },
2398 { Hexagon::BI__builtin_HEXAGON_V6_veqh_128B,
"v60,v62,v65,v66" },
2399 { Hexagon::BI__builtin_HEXAGON_V6_veqh_and,
"v60,v62,v65,v66" },
2400 { Hexagon::BI__builtin_HEXAGON_V6_veqh_and_128B,
"v60,v62,v65,v66" },
2401 { Hexagon::BI__builtin_HEXAGON_V6_veqh_or,
"v60,v62,v65,v66" },
2402 { Hexagon::BI__builtin_HEXAGON_V6_veqh_or_128B,
"v60,v62,v65,v66" },
2403 { Hexagon::BI__builtin_HEXAGON_V6_veqh_xor,
"v60,v62,v65,v66" },
2404 { Hexagon::BI__builtin_HEXAGON_V6_veqh_xor_128B,
"v60,v62,v65,v66" },
2405 { Hexagon::BI__builtin_HEXAGON_V6_veqw,
"v60,v62,v65,v66" },
2406 { Hexagon::BI__builtin_HEXAGON_V6_veqw_128B,
"v60,v62,v65,v66" },
2407 { Hexagon::BI__builtin_HEXAGON_V6_veqw_and,
"v60,v62,v65,v66" },
2408 { Hexagon::BI__builtin_HEXAGON_V6_veqw_and_128B,
"v60,v62,v65,v66" },
2409 { Hexagon::BI__builtin_HEXAGON_V6_veqw_or,
"v60,v62,v65,v66" },
2410 { Hexagon::BI__builtin_HEXAGON_V6_veqw_or_128B,
"v60,v62,v65,v66" },
2411 { Hexagon::BI__builtin_HEXAGON_V6_veqw_xor,
"v60,v62,v65,v66" },
2412 { Hexagon::BI__builtin_HEXAGON_V6_veqw_xor_128B,
"v60,v62,v65,v66" },
2413 { Hexagon::BI__builtin_HEXAGON_V6_vgtb,
"v60,v62,v65,v66" },
2414 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_128B,
"v60,v62,v65,v66" },
2415 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_and,
"v60,v62,v65,v66" },
2416 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_and_128B,
"v60,v62,v65,v66" },
2417 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_or,
"v60,v62,v65,v66" },
2418 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_or_128B,
"v60,v62,v65,v66" },
2419 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_xor,
"v60,v62,v65,v66" },
2420 { Hexagon::BI__builtin_HEXAGON_V6_vgtb_xor_128B,
"v60,v62,v65,v66" },
2421 { Hexagon::BI__builtin_HEXAGON_V6_vgth,
"v60,v62,v65,v66" },
2422 { Hexagon::BI__builtin_HEXAGON_V6_vgth_128B,
"v60,v62,v65,v66" },
2423 { Hexagon::BI__builtin_HEXAGON_V6_vgth_and,
"v60,v62,v65,v66" },
2424 { Hexagon::BI__builtin_HEXAGON_V6_vgth_and_128B,
"v60,v62,v65,v66" },
2425 { Hexagon::BI__builtin_HEXAGON_V6_vgth_or,
"v60,v62,v65,v66" },
2426 { Hexagon::BI__builtin_HEXAGON_V6_vgth_or_128B,
"v60,v62,v65,v66" },
2427 { Hexagon::BI__builtin_HEXAGON_V6_vgth_xor,
"v60,v62,v65,v66" },
2428 { Hexagon::BI__builtin_HEXAGON_V6_vgth_xor_128B,
"v60,v62,v65,v66" },
2429 { Hexagon::BI__builtin_HEXAGON_V6_vgtub,
"v60,v62,v65,v66" },
2430 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_128B,
"v60,v62,v65,v66" },
2431 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_and,
"v60,v62,v65,v66" },
2432 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_and_128B,
"v60,v62,v65,v66" },
2433 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_or,
"v60,v62,v65,v66" },
2434 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_or_128B,
"v60,v62,v65,v66" },
2435 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_xor,
"v60,v62,v65,v66" },
2436 { Hexagon::BI__builtin_HEXAGON_V6_vgtub_xor_128B,
"v60,v62,v65,v66" },
2437 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh,
"v60,v62,v65,v66" },
2438 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_128B,
"v60,v62,v65,v66" },
2439 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_and,
"v60,v62,v65,v66" },
2440 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_and_128B,
"v60,v62,v65,v66" },
2441 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_or,
"v60,v62,v65,v66" },
2442 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_or_128B,
"v60,v62,v65,v66" },
2443 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_xor,
"v60,v62,v65,v66" },
2444 { Hexagon::BI__builtin_HEXAGON_V6_vgtuh_xor_128B,
"v60,v62,v65,v66" },
2445 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw,
"v60,v62,v65,v66" },
2446 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_128B,
"v60,v62,v65,v66" },
2447 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_and,
"v60,v62,v65,v66" },
2448 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_and_128B,
"v60,v62,v65,v66" },
2449 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_or,
"v60,v62,v65,v66" },
2450 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_or_128B,
"v60,v62,v65,v66" },
2451 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_xor,
"v60,v62,v65,v66" },
2452 { Hexagon::BI__builtin_HEXAGON_V6_vgtuw_xor_128B,
"v60,v62,v65,v66" },
2453 { Hexagon::BI__builtin_HEXAGON_V6_vgtw,
"v60,v62,v65,v66" },
2454 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_128B,
"v60,v62,v65,v66" },
2455 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_and,
"v60,v62,v65,v66" },
2456 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_and_128B,
"v60,v62,v65,v66" },
2457 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_or,
"v60,v62,v65,v66" },
2458 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_or_128B,
"v60,v62,v65,v66" },
2459 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_xor,
"v60,v62,v65,v66" },
2460 { Hexagon::BI__builtin_HEXAGON_V6_vgtw_xor_128B,
"v60,v62,v65,v66" },
2461 { Hexagon::BI__builtin_HEXAGON_V6_vinsertwr,
"v60,v62,v65,v66" },
2462 { Hexagon::BI__builtin_HEXAGON_V6_vinsertwr_128B,
"v60,v62,v65,v66" },
2463 { Hexagon::BI__builtin_HEXAGON_V6_vlalignb,
"v60,v62,v65,v66" },
2464 { Hexagon::BI__builtin_HEXAGON_V6_vlalignb_128B,
"v60,v62,v65,v66" },
2465 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi,
"v60,v62,v65,v66" },
2466 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B,
"v60,v62,v65,v66" },
2467 { Hexagon::BI__builtin_HEXAGON_V6_vlsrb,
"v62,v65,v66" },
2468 { Hexagon::BI__builtin_HEXAGON_V6_vlsrb_128B,
"v62,v65,v66" },
2469 { Hexagon::BI__builtin_HEXAGON_V6_vlsrh,
"v60,v62,v65,v66" },
2470 { Hexagon::BI__builtin_HEXAGON_V6_vlsrh_128B,
"v60,v62,v65,v66" },
2471 { Hexagon::BI__builtin_HEXAGON_V6_vlsrhv,
"v60,v62,v65,v66" },
2472 { Hexagon::BI__builtin_HEXAGON_V6_vlsrhv_128B,
"v60,v62,v65,v66" },
2473 { Hexagon::BI__builtin_HEXAGON_V6_vlsrw,
"v60,v62,v65,v66" },
2474 { Hexagon::BI__builtin_HEXAGON_V6_vlsrw_128B,
"v60,v62,v65,v66" },
2475 { Hexagon::BI__builtin_HEXAGON_V6_vlsrwv,
"v60,v62,v65,v66" },
2476 { Hexagon::BI__builtin_HEXAGON_V6_vlsrwv_128B,
"v60,v62,v65,v66" },
2477 { Hexagon::BI__builtin_HEXAGON_V6_vlut4,
"v65,v66" },
2478 { Hexagon::BI__builtin_HEXAGON_V6_vlut4_128B,
"v65,v66" },
2479 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb,
"v60,v62,v65,v66" },
2480 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_128B,
"v60,v62,v65,v66" },
2481 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi,
"v62,v65,v66" },
2482 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi_128B,
"v62,v65,v66" },
2483 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_nm,
"v62,v65,v66" },
2484 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_nm_128B,
"v62,v65,v66" },
2485 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracc,
"v60,v62,v65,v66" },
2486 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracc_128B,
"v60,v62,v65,v66" },
2487 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci,
"v62,v65,v66" },
2488 { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci_128B,
"v62,v65,v66" },
2489 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh,
"v60,v62,v65,v66" },
2490 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_128B,
"v60,v62,v65,v66" },
2491 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi,
"v62,v65,v66" },
2492 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi_128B,
"v62,v65,v66" },
2493 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_nm,
"v62,v65,v66" },
2494 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_nm_128B,
"v62,v65,v66" },
2495 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracc,
"v60,v62,v65,v66" },
2496 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracc_128B,
"v60,v62,v65,v66" },
2497 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci,
"v62,v65,v66" },
2498 { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci_128B,
"v62,v65,v66" },
2499 { Hexagon::BI__builtin_HEXAGON_V6_vmaxb,
"v62,v65,v66" },
2500 { Hexagon::BI__builtin_HEXAGON_V6_vmaxb_128B,
"v62,v65,v66" },
2501 { Hexagon::BI__builtin_HEXAGON_V6_vmaxh,
"v60,v62,v65,v66" },
2502 { Hexagon::BI__builtin_HEXAGON_V6_vmaxh_128B,
"v60,v62,v65,v66" },
2503 { Hexagon::BI__builtin_HEXAGON_V6_vmaxub,
"v60,v62,v65,v66" },
2504 { Hexagon::BI__builtin_HEXAGON_V6_vmaxub_128B,
"v60,v62,v65,v66" },
2505 { Hexagon::BI__builtin_HEXAGON_V6_vmaxuh,
"v60,v62,v65,v66" },
2506 { Hexagon::BI__builtin_HEXAGON_V6_vmaxuh_128B,
"v60,v62,v65,v66" },
2507 { Hexagon::BI__builtin_HEXAGON_V6_vmaxw,
"v60,v62,v65,v66" },
2508 { Hexagon::BI__builtin_HEXAGON_V6_vmaxw_128B,
"v60,v62,v65,v66" },
2509 { Hexagon::BI__builtin_HEXAGON_V6_vminb,
"v62,v65,v66" },
2510 { Hexagon::BI__builtin_HEXAGON_V6_vminb_128B,
"v62,v65,v66" },
2511 { Hexagon::BI__builtin_HEXAGON_V6_vminh,
"v60,v62,v65,v66" },
2512 { Hexagon::BI__builtin_HEXAGON_V6_vminh_128B,
"v60,v62,v65,v66" },
2513 { Hexagon::BI__builtin_HEXAGON_V6_vminub,
"v60,v62,v65,v66" },
2514 { Hexagon::BI__builtin_HEXAGON_V6_vminub_128B,
"v60,v62,v65,v66" },
2515 { Hexagon::BI__builtin_HEXAGON_V6_vminuh,
"v60,v62,v65,v66" },
2516 { Hexagon::BI__builtin_HEXAGON_V6_vminuh_128B,
"v60,v62,v65,v66" },
2517 { Hexagon::BI__builtin_HEXAGON_V6_vminw,
"v60,v62,v65,v66" },
2518 { Hexagon::BI__builtin_HEXAGON_V6_vminw_128B,
"v60,v62,v65,v66" },
2519 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus,
"v60,v62,v65,v66" },
2520 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_128B,
"v60,v62,v65,v66" },
2521 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_acc,
"v60,v62,v65,v66" },
2522 { Hexagon::BI__builtin_HEXAGON_V6_vmpabus_acc_128B,
"v60,v62,v65,v66" },
2523 { Hexagon::BI__builtin_HEXAGON_V6_vmpabusv,
"v60,v62,v65,v66" },
2524 { Hexagon::BI__builtin_HEXAGON_V6_vmpabusv_128B,
"v60,v62,v65,v66" },
2525 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu,
"v65,v66" },
2526 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_128B,
"v65,v66" },
2527 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_acc,
"v65,v66" },
2528 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuu_acc_128B,
"v65,v66" },
2529 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuuv,
"v60,v62,v65,v66" },
2530 { Hexagon::BI__builtin_HEXAGON_V6_vmpabuuv_128B,
"v60,v62,v65,v66" },
2531 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb,
"v60,v62,v65,v66" },
2532 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_128B,
"v60,v62,v65,v66" },
2533 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_acc,
"v60,v62,v65,v66" },
2534 { Hexagon::BI__builtin_HEXAGON_V6_vmpahb_acc_128B,
"v60,v62,v65,v66" },
2535 { Hexagon::BI__builtin_HEXAGON_V6_vmpahhsat,
"v65,v66" },
2536 { Hexagon::BI__builtin_HEXAGON_V6_vmpahhsat_128B,
"v65,v66" },
2537 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb,
"v62,v65,v66" },
2538 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_128B,
"v62,v65,v66" },
2539 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_acc,
"v62,v65,v66" },
2540 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhb_acc_128B,
"v62,v65,v66" },
2541 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhuhsat,
"v65,v66" },
2542 { Hexagon::BI__builtin_HEXAGON_V6_vmpauhuhsat_128B,
"v65,v66" },
2543 { Hexagon::BI__builtin_HEXAGON_V6_vmpsuhuhsat,
"v65,v66" },
2544 { Hexagon::BI__builtin_HEXAGON_V6_vmpsuhuhsat_128B,
"v65,v66" },
2545 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus,
"v60,v62,v65,v66" },
2546 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_128B,
"v60,v62,v65,v66" },
2547 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_acc,
"v60,v62,v65,v66" },
2548 { Hexagon::BI__builtin_HEXAGON_V6_vmpybus_acc_128B,
"v60,v62,v65,v66" },
2549 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv,
"v60,v62,v65,v66" },
2550 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_128B,
"v60,v62,v65,v66" },
2551 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_acc,
"v60,v62,v65,v66" },
2552 { Hexagon::BI__builtin_HEXAGON_V6_vmpybusv_acc_128B,
"v60,v62,v65,v66" },
2553 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv,
"v60,v62,v65,v66" },
2554 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_128B,
"v60,v62,v65,v66" },
2555 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_acc,
"v60,v62,v65,v66" },
2556 { Hexagon::BI__builtin_HEXAGON_V6_vmpybv_acc_128B,
"v60,v62,v65,v66" },
2557 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh,
"v60,v62,v65,v66" },
2558 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_128B,
"v60,v62,v65,v66" },
2559 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_64,
"v62,v65,v66" },
2560 { Hexagon::BI__builtin_HEXAGON_V6_vmpyewuh_64_128B,
"v62,v65,v66" },
2561 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh,
"v60,v62,v65,v66" },
2562 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_128B,
"v60,v62,v65,v66" },
2563 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_acc,
"v65,v66" },
2564 { Hexagon::BI__builtin_HEXAGON_V6_vmpyh_acc_128B,
"v65,v66" },
2565 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsat_acc,
"v60,v62,v65,v66" },
2566 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsat_acc_128B,
"v60,v62,v65,v66" },
2567 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsrs,
"v60,v62,v65,v66" },
2568 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhsrs_128B,
"v60,v62,v65,v66" },
2569 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhss,
"v60,v62,v65,v66" },
2570 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhss_128B,
"v60,v62,v65,v66" },
2571 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus,
"v60,v62,v65,v66" },
2572 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_128B,
"v60,v62,v65,v66" },
2573 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_acc,
"v60,v62,v65,v66" },
2574 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhus_acc_128B,
"v60,v62,v65,v66" },
2575 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv,
"v60,v62,v65,v66" },
2576 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_128B,
"v60,v62,v65,v66" },
2577 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_acc,
"v60,v62,v65,v66" },
2578 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhv_acc_128B,
"v60,v62,v65,v66" },
2579 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhvsrs,
"v60,v62,v65,v66" },
2580 { Hexagon::BI__builtin_HEXAGON_V6_vmpyhvsrs_128B,
"v60,v62,v65,v66" },
2581 { Hexagon::BI__builtin_HEXAGON_V6_vmpyieoh,
"v60,v62,v65,v66" },
2582 { Hexagon::BI__builtin_HEXAGON_V6_vmpyieoh_128B,
"v60,v62,v65,v66" },
2583 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewh_acc,
"v60,v62,v65,v66" },
2584 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewh_acc_128B,
"v60,v62,v65,v66" },
2585 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh,
"v60,v62,v65,v66" },
2586 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_128B,
"v60,v62,v65,v66" },
2587 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_acc,
"v60,v62,v65,v66" },
2588 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiewuh_acc_128B,
"v60,v62,v65,v66" },
2589 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih,
"v60,v62,v65,v66" },
2590 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_128B,
"v60,v62,v65,v66" },
2591 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_acc,
"v60,v62,v65,v66" },
2592 { Hexagon::BI__builtin_HEXAGON_V6_vmpyih_acc_128B,
"v60,v62,v65,v66" },
2593 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb,
"v60,v62,v65,v66" },
2594 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_128B,
"v60,v62,v65,v66" },
2595 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_acc,
"v60,v62,v65,v66" },
2596 { Hexagon::BI__builtin_HEXAGON_V6_vmpyihb_acc_128B,
"v60,v62,v65,v66" },
2597 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiowh,
"v60,v62,v65,v66" },
2598 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiowh_128B,
"v60,v62,v65,v66" },
2599 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb,
"v60,v62,v65,v66" },
2600 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_128B,
"v60,v62,v65,v66" },
2601 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_acc,
"v60,v62,v65,v66" },
2602 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwb_acc_128B,
"v60,v62,v65,v66" },
2603 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh,
"v60,v62,v65,v66" },
2604 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_128B,
"v60,v62,v65,v66" },
2605 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_acc,
"v60,v62,v65,v66" },
2606 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwh_acc_128B,
"v60,v62,v65,v66" },
2607 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub,
"v62,v65,v66" },
2608 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_128B,
"v62,v65,v66" },
2609 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_acc,
"v62,v65,v66" },
2610 { Hexagon::BI__builtin_HEXAGON_V6_vmpyiwub_acc_128B,
"v62,v65,v66" },
2611 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh,
"v60,v62,v65,v66" },
2612 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_128B,
"v60,v62,v65,v66" },
2613 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_64_acc,
"v62,v65,v66" },
2614 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_64_acc_128B,
"v62,v65,v66" },
2615 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd,
"v60,v62,v65,v66" },
2616 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_128B,
"v60,v62,v65,v66" },
2617 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_sacc,
"v60,v62,v65,v66" },
2618 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_rnd_sacc_128B,
"v60,v62,v65,v66" },
2619 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_sacc,
"v60,v62,v65,v66" },
2620 { Hexagon::BI__builtin_HEXAGON_V6_vmpyowh_sacc_128B,
"v60,v62,v65,v66" },
2621 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub,
"v60,v62,v65,v66" },
2622 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_128B,
"v60,v62,v65,v66" },
2623 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_acc,
"v60,v62,v65,v66" },
2624 { Hexagon::BI__builtin_HEXAGON_V6_vmpyub_acc_128B,
"v60,v62,v65,v66" },
2625 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv,
"v60,v62,v65,v66" },
2626 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_128B,
"v60,v62,v65,v66" },
2627 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_acc,
"v60,v62,v65,v66" },
2628 { Hexagon::BI__builtin_HEXAGON_V6_vmpyubv_acc_128B,
"v60,v62,v65,v66" },
2629 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh,
"v60,v62,v65,v66" },
2630 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_128B,
"v60,v62,v65,v66" },
2631 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_acc,
"v60,v62,v65,v66" },
2632 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuh_acc_128B,
"v60,v62,v65,v66" },
2633 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe,
"v65,v66" },
2634 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_128B,
"v65,v66" },
2635 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_acc,
"v65,v66" },
2636 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhe_acc_128B,
"v65,v66" },
2637 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv,
"v60,v62,v65,v66" },
2638 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_128B,
"v60,v62,v65,v66" },
2639 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_acc,
"v60,v62,v65,v66" },
2640 { Hexagon::BI__builtin_HEXAGON_V6_vmpyuhv_acc_128B,
"v60,v62,v65,v66" },
2641 { Hexagon::BI__builtin_HEXAGON_V6_vmux,
"v60,v62,v65,v66" },
2642 { Hexagon::BI__builtin_HEXAGON_V6_vmux_128B,
"v60,v62,v65,v66" },
2643 { Hexagon::BI__builtin_HEXAGON_V6_vnavgb,
"v65,v66" },
2644 { Hexagon::BI__builtin_HEXAGON_V6_vnavgb_128B,
"v65,v66" },
2645 { Hexagon::BI__builtin_HEXAGON_V6_vnavgh,
"v60,v62,v65,v66" },
2646 { Hexagon::BI__builtin_HEXAGON_V6_vnavgh_128B,
"v60,v62,v65,v66" },
2647 { Hexagon::BI__builtin_HEXAGON_V6_vnavgub,
"v60,v62,v65,v66" },
2648 { Hexagon::BI__builtin_HEXAGON_V6_vnavgub_128B,
"v60,v62,v65,v66" },
2649 { Hexagon::BI__builtin_HEXAGON_V6_vnavgw,
"v60,v62,v65,v66" },
2650 { Hexagon::BI__builtin_HEXAGON_V6_vnavgw_128B,
"v60,v62,v65,v66" },
2651 { Hexagon::BI__builtin_HEXAGON_V6_vnormamth,
"v60,v62,v65,v66" },
2652 { Hexagon::BI__builtin_HEXAGON_V6_vnormamth_128B,
"v60,v62,v65,v66" },
2653 { Hexagon::BI__builtin_HEXAGON_V6_vnormamtw,
"v60,v62,v65,v66" },
2654 { Hexagon::BI__builtin_HEXAGON_V6_vnormamtw_128B,
"v60,v62,v65,v66" },
2655 { Hexagon::BI__builtin_HEXAGON_V6_vnot,
"v60,v62,v65,v66" },
2656 { Hexagon::BI__builtin_HEXAGON_V6_vnot_128B,
"v60,v62,v65,v66" },
2657 { Hexagon::BI__builtin_HEXAGON_V6_vor,
"v60,v62,v65,v66" },
2658 { Hexagon::BI__builtin_HEXAGON_V6_vor_128B,
"v60,v62,v65,v66" },
2659 { Hexagon::BI__builtin_HEXAGON_V6_vpackeb,
"v60,v62,v65,v66" },
2660 { Hexagon::BI__builtin_HEXAGON_V6_vpackeb_128B,
"v60,v62,v65,v66" },
2661 { Hexagon::BI__builtin_HEXAGON_V6_vpackeh,
"v60,v62,v65,v66" },
2662 { Hexagon::BI__builtin_HEXAGON_V6_vpackeh_128B,
"v60,v62,v65,v66" },
2663 { Hexagon::BI__builtin_HEXAGON_V6_vpackhb_sat,
"v60,v62,v65,v66" },
2664 { Hexagon::BI__builtin_HEXAGON_V6_vpackhb_sat_128B,
"v60,v62,v65,v66" },
2665 { Hexagon::BI__builtin_HEXAGON_V6_vpackhub_sat,
"v60,v62,v65,v66" },
2666 { Hexagon::BI__builtin_HEXAGON_V6_vpackhub_sat_128B,
"v60,v62,v65,v66" },
2667 { Hexagon::BI__builtin_HEXAGON_V6_vpackob,
"v60,v62,v65,v66" },
2668 { Hexagon::BI__builtin_HEXAGON_V6_vpackob_128B,
"v60,v62,v65,v66" },
2669 { Hexagon::BI__builtin_HEXAGON_V6_vpackoh,
"v60,v62,v65,v66" },
2670 { Hexagon::BI__builtin_HEXAGON_V6_vpackoh_128B,
"v60,v62,v65,v66" },
2671 { Hexagon::BI__builtin_HEXAGON_V6_vpackwh_sat,
"v60,v62,v65,v66" },
2672 { Hexagon::BI__builtin_HEXAGON_V6_vpackwh_sat_128B,
"v60,v62,v65,v66" },
2673 { Hexagon::BI__builtin_HEXAGON_V6_vpackwuh_sat,
"v60,v62,v65,v66" },
2674 { Hexagon::BI__builtin_HEXAGON_V6_vpackwuh_sat_128B,
"v60,v62,v65,v66" },
2675 { Hexagon::BI__builtin_HEXAGON_V6_vpopcounth,
"v60,v62,v65,v66" },
2676 { Hexagon::BI__builtin_HEXAGON_V6_vpopcounth_128B,
"v60,v62,v65,v66" },
2677 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqb,
"v65,v66" },
2678 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqb_128B,
"v65,v66" },
2679 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqh,
"v65,v66" },
2680 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqh_128B,
"v65,v66" },
2681 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqw,
"v65,v66" },
2682 { Hexagon::BI__builtin_HEXAGON_V6_vprefixqw_128B,
"v65,v66" },
2683 { Hexagon::BI__builtin_HEXAGON_V6_vrdelta,
"v60,v62,v65,v66" },
2684 { Hexagon::BI__builtin_HEXAGON_V6_vrdelta_128B,
"v60,v62,v65,v66" },
2685 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt,
"v65" },
2686 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_128B,
"v65" },
2687 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_acc,
"v65" },
2688 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybub_rtt_acc_128B,
"v65" },
2689 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus,
"v60,v62,v65,v66" },
2690 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_128B,
"v60,v62,v65,v66" },
2691 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_acc,
"v60,v62,v65,v66" },
2692 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybus_acc_128B,
"v60,v62,v65,v66" },
2693 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi,
"v60,v62,v65,v66" },
2694 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B,
"v60,v62,v65,v66" },
2695 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc,
"v60,v62,v65,v66" },
2696 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B,
"v60,v62,v65,v66" },
2697 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv,
"v60,v62,v65,v66" },
2698 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_128B,
"v60,v62,v65,v66" },
2699 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_acc,
"v60,v62,v65,v66" },
2700 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusv_acc_128B,
"v60,v62,v65,v66" },
2701 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv,
"v60,v62,v65,v66" },
2702 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_128B,
"v60,v62,v65,v66" },
2703 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_acc,
"v60,v62,v65,v66" },
2704 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybv_acc_128B,
"v60,v62,v65,v66" },
2705 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub,
"v60,v62,v65,v66" },
2706 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_128B,
"v60,v62,v65,v66" },
2707 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_acc,
"v60,v62,v65,v66" },
2708 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_acc_128B,
"v60,v62,v65,v66" },
2709 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi,
"v60,v62,v65,v66" },
2710 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B,
"v60,v62,v65,v66" },
2711 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc,
"v60,v62,v65,v66" },
2712 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B,
"v60,v62,v65,v66" },
2713 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt,
"v65" },
2714 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_128B,
"v65" },
2715 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_acc,
"v65" },
2716 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,
"v65" },
2717 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv,
"v60,v62,v65,v66" },
2718 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_128B,
"v60,v62,v65,v66" },
2719 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_acc,
"v60,v62,v65,v66" },
2720 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubv_acc_128B,
"v60,v62,v65,v66" },
2721 { Hexagon::BI__builtin_HEXAGON_V6_vror,
"v60,v62,v65,v66" },
2722 { Hexagon::BI__builtin_HEXAGON_V6_vror_128B,
"v60,v62,v65,v66" },
2723 { Hexagon::BI__builtin_HEXAGON_V6_vrotr,
"v66" },
2724 { Hexagon::BI__builtin_HEXAGON_V6_vrotr_128B,
"v66" },
2725 { Hexagon::BI__builtin_HEXAGON_V6_vroundhb,
"v60,v62,v65,v66" },
2726 { Hexagon::BI__builtin_HEXAGON_V6_vroundhb_128B,
"v60,v62,v65,v66" },
2727 { Hexagon::BI__builtin_HEXAGON_V6_vroundhub,
"v60,v62,v65,v66" },
2728 { Hexagon::BI__builtin_HEXAGON_V6_vroundhub_128B,
"v60,v62,v65,v66" },
2729 { Hexagon::BI__builtin_HEXAGON_V6_vrounduhub,
"v62,v65,v66" },
2730 { Hexagon::BI__builtin_HEXAGON_V6_vrounduhub_128B,
"v62,v65,v66" },
2731 { Hexagon::BI__builtin_HEXAGON_V6_vrounduwuh,
"v62,v65,v66" },
2732 { Hexagon::BI__builtin_HEXAGON_V6_vrounduwuh_128B,
"v62,v65,v66" },
2733 { Hexagon::BI__builtin_HEXAGON_V6_vroundwh,
"v60,v62,v65,v66" },
2734 { Hexagon::BI__builtin_HEXAGON_V6_vroundwh_128B,
"v60,v62,v65,v66" },
2735 { Hexagon::BI__builtin_HEXAGON_V6_vroundwuh,
"v60,v62,v65,v66" },
2736 { Hexagon::BI__builtin_HEXAGON_V6_vroundwuh_128B,
"v60,v62,v65,v66" },
2737 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi,
"v60,v62,v65,v66" },
2738 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B,
"v60,v62,v65,v66" },
2739 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc,
"v60,v62,v65,v66" },
2740 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B,
"v60,v62,v65,v66" },
2741 { Hexagon::BI__builtin_HEXAGON_V6_vsatdw,
"v66" },
2742 { Hexagon::BI__builtin_HEXAGON_V6_vsatdw_128B,
"v66" },
2743 { Hexagon::BI__builtin_HEXAGON_V6_vsathub,
"v60,v62,v65,v66" },
2744 { Hexagon::BI__builtin_HEXAGON_V6_vsathub_128B,
"v60,v62,v65,v66" },
2745 { Hexagon::BI__builtin_HEXAGON_V6_vsatuwuh,
"v62,v65,v66" },
2746 { Hexagon::BI__builtin_HEXAGON_V6_vsatuwuh_128B,
"v62,v65,v66" },
2747 { Hexagon::BI__builtin_HEXAGON_V6_vsatwh,
"v60,v62,v65,v66" },
2748 { Hexagon::BI__builtin_HEXAGON_V6_vsatwh_128B,
"v60,v62,v65,v66" },
2749 { Hexagon::BI__builtin_HEXAGON_V6_vsb,
"v60,v62,v65,v66" },
2750 { Hexagon::BI__builtin_HEXAGON_V6_vsb_128B,
"v60,v62,v65,v66" },
2751 { Hexagon::BI__builtin_HEXAGON_V6_vsh,
"v60,v62,v65,v66" },
2752 { Hexagon::BI__builtin_HEXAGON_V6_vsh_128B,
"v60,v62,v65,v66" },
2753 { Hexagon::BI__builtin_HEXAGON_V6_vshufeh,
"v60,v62,v65,v66" },
2754 { Hexagon::BI__builtin_HEXAGON_V6_vshufeh_128B,
"v60,v62,v65,v66" },
2755 { Hexagon::BI__builtin_HEXAGON_V6_vshuffb,
"v60,v62,v65,v66" },
2756 { Hexagon::BI__builtin_HEXAGON_V6_vshuffb_128B,
"v60,v62,v65,v66" },
2757 { Hexagon::BI__builtin_HEXAGON_V6_vshuffeb,
"v60,v62,v65,v66" },
2758 { Hexagon::BI__builtin_HEXAGON_V6_vshuffeb_128B,
"v60,v62,v65,v66" },
2759 { Hexagon::BI__builtin_HEXAGON_V6_vshuffh,
"v60,v62,v65,v66" },
2760 { Hexagon::BI__builtin_HEXAGON_V6_vshuffh_128B,
"v60,v62,v65,v66" },
2761 { Hexagon::BI__builtin_HEXAGON_V6_vshuffob,
"v60,v62,v65,v66" },
2762 { Hexagon::BI__builtin_HEXAGON_V6_vshuffob_128B,
"v60,v62,v65,v66" },
2763 { Hexagon::BI__builtin_HEXAGON_V6_vshuffvdd,
"v60,v62,v65,v66" },
2764 { Hexagon::BI__builtin_HEXAGON_V6_vshuffvdd_128B,
"v60,v62,v65,v66" },
2765 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeb,
"v60,v62,v65,v66" },
2766 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeb_128B,
"v60,v62,v65,v66" },
2767 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeh,
"v60,v62,v65,v66" },
2768 { Hexagon::BI__builtin_HEXAGON_V6_vshufoeh_128B,
"v60,v62,v65,v66" },
2769 { Hexagon::BI__builtin_HEXAGON_V6_vshufoh,
"v60,v62,v65,v66" },
2770 { Hexagon::BI__builtin_HEXAGON_V6_vshufoh_128B,
"v60,v62,v65,v66" },
2771 { Hexagon::BI__builtin_HEXAGON_V6_vsubb,
"v60,v62,v65,v66" },
2772 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_128B,
"v60,v62,v65,v66" },
2773 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_dv,
"v60,v62,v65,v66" },
2774 { Hexagon::BI__builtin_HEXAGON_V6_vsubb_dv_128B,
"v60,v62,v65,v66" },
2775 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat,
"v62,v65,v66" },
2776 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_128B,
"v62,v65,v66" },
2777 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_dv,
"v62,v65,v66" },
2778 { Hexagon::BI__builtin_HEXAGON_V6_vsubbsat_dv_128B,
"v62,v65,v66" },
2779 { Hexagon::BI__builtin_HEXAGON_V6_vsubcarry,
"v62,v65,v66" },
2780 { Hexagon::BI__builtin_HEXAGON_V6_vsubcarry_128B,
"v62,v65,v66" },
2781 { Hexagon::BI__builtin_HEXAGON_V6_vsubh,
"v60,v62,v65,v66" },
2782 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_128B,
"v60,v62,v65,v66" },
2783 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_dv,
"v60,v62,v65,v66" },
2784 { Hexagon::BI__builtin_HEXAGON_V6_vsubh_dv_128B,
"v60,v62,v65,v66" },
2785 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat,
"v60,v62,v65,v66" },
2786 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_128B,
"v60,v62,v65,v66" },
2787 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_dv,
"v60,v62,v65,v66" },
2788 { Hexagon::BI__builtin_HEXAGON_V6_vsubhsat_dv_128B,
"v60,v62,v65,v66" },
2789 { Hexagon::BI__builtin_HEXAGON_V6_vsubhw,
"v60,v62,v65,v66" },
2790 { Hexagon::BI__builtin_HEXAGON_V6_vsubhw_128B,
"v60,v62,v65,v66" },
2791 { Hexagon::BI__builtin_HEXAGON_V6_vsububh,
"v60,v62,v65,v66" },
2792 { Hexagon::BI__builtin_HEXAGON_V6_vsububh_128B,
"v60,v62,v65,v66" },
2793 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat,
"v60,v62,v65,v66" },
2794 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_128B,
"v60,v62,v65,v66" },
2795 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_dv,
"v60,v62,v65,v66" },
2796 { Hexagon::BI__builtin_HEXAGON_V6_vsububsat_dv_128B,
"v60,v62,v65,v66" },
2797 { Hexagon::BI__builtin_HEXAGON_V6_vsubububb_sat,
"v62,v65,v66" },
2798 { Hexagon::BI__builtin_HEXAGON_V6_vsubububb_sat_128B,
"v62,v65,v66" },
2799 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat,
"v60,v62,v65,v66" },
2800 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_128B,
"v60,v62,v65,v66" },
2801 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_dv,
"v60,v62,v65,v66" },
2802 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhsat_dv_128B,
"v60,v62,v65,v66" },
2803 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhw,
"v60,v62,v65,v66" },
2804 { Hexagon::BI__builtin_HEXAGON_V6_vsubuhw_128B,
"v60,v62,v65,v66" },
2805 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat,
"v62,v65,v66" },
2806 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_128B,
"v62,v65,v66" },
2807 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_dv,
"v62,v65,v66" },
2808 { Hexagon::BI__builtin_HEXAGON_V6_vsubuwsat_dv_128B,
"v62,v65,v66" },
2809 { Hexagon::BI__builtin_HEXAGON_V6_vsubw,
"v60,v62,v65,v66" },
2810 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_128B,
"v60,v62,v65,v66" },
2811 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_dv,
"v60,v62,v65,v66" },
2812 { Hexagon::BI__builtin_HEXAGON_V6_vsubw_dv_128B,
"v60,v62,v65,v66" },
2813 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat,
"v60,v62,v65,v66" },
2814 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_128B,
"v60,v62,v65,v66" },
2815 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_dv,
"v60,v62,v65,v66" },
2816 { Hexagon::BI__builtin_HEXAGON_V6_vsubwsat_dv_128B,
"v60,v62,v65,v66" },
2817 { Hexagon::BI__builtin_HEXAGON_V6_vswap,
"v60,v62,v65,v66" },
2818 { Hexagon::BI__builtin_HEXAGON_V6_vswap_128B,
"v60,v62,v65,v66" },
2819 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb,
"v60,v62,v65,v66" },
2820 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_128B,
"v60,v62,v65,v66" },
2821 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_acc,
"v60,v62,v65,v66" },
2822 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyb_acc_128B,
"v60,v62,v65,v66" },
2823 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus,
"v60,v62,v65,v66" },
2824 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_128B,
"v60,v62,v65,v66" },
2825 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_acc,
"v60,v62,v65,v66" },
2826 { Hexagon::BI__builtin_HEXAGON_V6_vtmpybus_acc_128B,
"v60,v62,v65,v66" },
2827 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb,
"v60,v62,v65,v66" },
2828 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_128B,
"v60,v62,v65,v66" },
2829 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_acc,
"v60,v62,v65,v66" },
2830 { Hexagon::BI__builtin_HEXAGON_V6_vtmpyhb_acc_128B,
"v60,v62,v65,v66" },
2831 { Hexagon::BI__builtin_HEXAGON_V6_vunpackb,
"v60,v62,v65,v66" },
2832 { Hexagon::BI__builtin_HEXAGON_V6_vunpackb_128B,
"v60,v62,v65,v66" },
2833 { Hexagon::BI__builtin_HEXAGON_V6_vunpackh,
"v60,v62,v65,v66" },
2834 { Hexagon::BI__builtin_HEXAGON_V6_vunpackh_128B,
"v60,v62,v65,v66" },
2835 { Hexagon::BI__builtin_HEXAGON_V6_vunpackob,
"v60,v62,v65,v66" },
2836 { Hexagon::BI__builtin_HEXAGON_V6_vunpackob_128B,
"v60,v62,v65,v66" },
2837 { Hexagon::BI__builtin_HEXAGON_V6_vunpackoh,
"v60,v62,v65,v66" },
2838 { Hexagon::BI__builtin_HEXAGON_V6_vunpackoh_128B,
"v60,v62,v65,v66" },
2839 { Hexagon::BI__builtin_HEXAGON_V6_vunpackub,
"v60,v62,v65,v66" },
2840 { Hexagon::BI__builtin_HEXAGON_V6_vunpackub_128B,
"v60,v62,v65,v66" },
2841 { Hexagon::BI__builtin_HEXAGON_V6_vunpackuh,
"v60,v62,v65,v66" },
2842 { Hexagon::BI__builtin_HEXAGON_V6_vunpackuh_128B,
"v60,v62,v65,v66" },
2843 { Hexagon::BI__builtin_HEXAGON_V6_vxor,
"v60,v62,v65,v66" },
2844 { Hexagon::BI__builtin_HEXAGON_V6_vxor_128B,
"v60,v62,v65,v66" },
2845 { Hexagon::BI__builtin_HEXAGON_V6_vzb,
"v60,v62,v65,v66" },
2846 { Hexagon::BI__builtin_HEXAGON_V6_vzb_128B,
"v60,v62,v65,v66" },
2847 { Hexagon::BI__builtin_HEXAGON_V6_vzh,
"v60,v62,v65,v66" },
2848 { Hexagon::BI__builtin_HEXAGON_V6_vzh_128B,
"v60,v62,v65,v66" },
2852 auto SortCmp = [](
const BuiltinAndString &LHS,
const BuiltinAndString &RHS) {
2853 return LHS.BuiltinID < RHS.BuiltinID;
2855 static const bool SortOnce =
2856 (llvm::sort(ValidCPU, SortCmp),
2857 llvm::sort(ValidHVX, SortCmp),
true);
2859 auto LowerBoundCmp = [](
const BuiltinAndString &BI,
unsigned BuiltinID) {
2860 return BI.BuiltinID < BuiltinID;
2865 const BuiltinAndString *FC =
2866 llvm::lower_bound(ValidCPU, BuiltinID, LowerBoundCmp);
2867 if (FC != std::end(ValidCPU) && FC->BuiltinID == BuiltinID) {
2869 StringRef CPU = Opts.
CPU;
2871 assert(CPU.startswith(
"hexagon") &&
"Unexpected CPU name");
2872 CPU.consume_front(
"hexagon");
2874 StringRef(FC->Str).split(CPUs,
',');
2875 if (llvm::none_of(CPUs, [CPU](StringRef S) {
return S == CPU; }))
2877 diag::err_hexagon_builtin_unsupported_cpu);
2881 const BuiltinAndString *FH =
2882 llvm::lower_bound(ValidHVX, BuiltinID, LowerBoundCmp);
2883 if (FH != std::end(ValidHVX) && FH->BuiltinID == BuiltinID) {
2886 diag::err_hexagon_builtin_requires_hvx);
2889 StringRef(FH->Str).split(HVXs,
',');
2890 bool IsValid = llvm::any_of(HVXs,
2891 [&TI] (StringRef
V) {
2892 std::string F =
"hvx" + V.str();
2897 diag::err_hexagon_builtin_unsupported_hvx);
2903 bool Sema::CheckHexagonBuiltinArgument(
unsigned BuiltinID,
CallExpr *TheCall) {
2916 { Hexagon::BI__builtin_circ_ldd, {{ 3,
true, 4, 3 }} },
2917 { Hexagon::BI__builtin_circ_ldw, {{ 3,
true, 4, 2 }} },
2918 { Hexagon::BI__builtin_circ_ldh, {{ 3,
true, 4, 1 }} },
2919 { Hexagon::BI__builtin_circ_lduh, {{ 3,
true, 4, 0 }} },
2920 { Hexagon::BI__builtin_circ_ldb, {{ 3,
true, 4, 0 }} },
2921 { Hexagon::BI__builtin_circ_ldub, {{ 3,
true, 4, 0 }} },
2922 { Hexagon::BI__builtin_circ_std, {{ 3,
true, 4, 3 }} },
2923 { Hexagon::BI__builtin_circ_stw, {{ 3,
true, 4, 2 }} },
2924 { Hexagon::BI__builtin_circ_sth, {{ 3,
true, 4, 1 }} },
2925 { Hexagon::BI__builtin_circ_sthhi, {{ 3,
true, 4, 1 }} },
2926 { Hexagon::BI__builtin_circ_stb, {{ 3,
true, 4, 0 }} },
2928 { Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{ 1,
true, 4, 0 }} },
2929 { Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{ 1,
true, 4, 0 }} },
2930 { Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{ 1,
true, 4, 1 }} },
2931 { Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{ 1,
true, 4, 1 }} },
2932 { Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{ 1,
true, 4, 2 }} },
2933 { Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{ 1,
true, 4, 3 }} },
2934 { Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{ 1,
true, 4, 0 }} },
2935 { Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{ 1,
true, 4, 1 }} },
2936 { Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{ 1,
true, 4, 1 }} },
2937 { Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{ 1,
true, 4, 2 }} },
2938 { Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{ 1,
true, 4, 3 }} },
2940 { Hexagon::BI__builtin_HEXAGON_A2_combineii, {{ 1,
true, 8, 0 }} },
2941 { Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{ 1,
false, 16, 0 }} },
2942 { Hexagon::BI__builtin_HEXAGON_A2_tfril, {{ 1,
false, 16, 0 }} },
2943 { Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{ 0,
true, 8, 0 }} },
2944 { Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{ 1,
false, 5, 0 }} },
2945 { Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{ 1,
false, 8, 0 }} },
2946 { Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{ 1,
true, 8, 0 }} },
2947 { Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{ 1,
false, 5, 0 }} },
2948 { Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{ 1,
false, 5, 0 }} },
2949 { Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{ 1,
false, 5, 0 }} },
2950 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{ 1,
false, 8, 0 }} },
2951 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{ 1,
true, 8, 0 }} },
2952 { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{ 1,
false, 7, 0 }} },
2953 { Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{ 1,
true, 8, 0 }} },
2954 { Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{ 1,
true, 8, 0 }} },
2955 { Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{ 1,
false, 7, 0 }} },
2956 { Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{ 1,
true, 8, 0 }} },
2957 { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{ 1,
true, 8, 0 }} },
2958 { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{ 1,
false, 7, 0 }} },
2959 { Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{ 1,
false, 6, 0 }} },
2960 { Hexagon::BI__builtin_HEXAGON_C2_muxii, {{ 2,
true, 8, 0 }} },
2961 { Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{ 1,
false, 6, 0 }} },
2962 { Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{ 1,
false, 5, 0 }} },
2963 { Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{ 0,
false, 10, 0 }} },
2964 { Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{ 0,
false, 10, 0 }} },
2965 { Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{ 1,
false, 5, 0 }} },
2966 { Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{ 0,
false, 10, 0 }} },
2967 { Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{ 0,
false, 10, 0 }} },
2968 { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{ 2,
false, 6, 0 }} },
2969 { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{ 1,
false, 6, 2 }} },
2970 { Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{ 2,
false, 3, 0 }} },
2971 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{ 2,
false, 6, 0 }} },
2972 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{ 2,
false, 6, 0 }} },
2973 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{ 1,
false, 6, 0 }} },
2974 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{ 2,
false, 6, 0 }} },
2975 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{ 2,
false, 6, 0 }} },
2976 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{ 2,
false, 6, 0 }} },
2977 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{ 2,
false, 5, 0 }} },
2978 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{ 2,
false, 5, 0 }} },
2979 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{ 1,
false, 5, 0 }} },
2980 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{ 2,
false, 5, 0 }} },
2981 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{ 2,
false, 5, 0 }} },
2982 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{ 1,
false, 5, 0 }} },
2983 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{ 2,
false, 5, 0 }} },
2984 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{ 1,
false, 4, 0 }} },
2985 { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{ 1,
false, 5, 0 }} },
2986 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{ 2,
false, 6, 0 }} },
2987 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{ 2,
false, 6, 0 }} },
2988 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{ 1,
false, 6, 0 }} },
2989 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{ 2,
false, 6, 0 }} },
2990 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{ 2,
false, 6, 0 }} },
2991 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax,
2992 {{ 1,
false, 6, 0 }} },
2993 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{ 1,
false, 6, 0 }} },
2994 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{ 2,
false, 5, 0 }} },
2995 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{ 2,
false, 5, 0 }} },
2996 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{ 1,
false, 5, 0 }} },
2997 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{ 2,
false, 5, 0 }} },
2998 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{ 2,
false, 5, 0 }} },
2999 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax,
3000 {{ 1,
false, 5, 0 }} },
3001 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{ 1,
false, 5, 0 }} },
3002 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{ 1,
false, 5, 0 }} },
3003 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{ 1,
false, 4, 0 }} },
3004 { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{ 1,
false, 5, 0 }} },
3005 { Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{ 1,
false, 5, 0 }} },
3006 { Hexagon::BI__builtin_HEXAGON_S2_extractu, {{ 1,
false, 5, 0 },
3007 { 2,
false, 5, 0 }} },
3008 { Hexagon::BI__builtin_HEXAGON_S2_extractup, {{ 1,
false, 6, 0 },
3009 { 2,
false, 6, 0 }} },
3010 { Hexagon::BI__builtin_HEXAGON_S2_insert, {{ 2,
false, 5, 0 },
3011 { 3,
false, 5, 0 }} },
3012 { Hexagon::BI__builtin_HEXAGON_S2_insertp, {{ 2,
false, 6, 0 },
3013 { 3,
false, 6, 0 }} },
3014 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{ 2,
false, 6, 0 }} },
3015 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{ 2,
false, 6, 0 }} },
3016 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{ 1,
false, 6, 0 }} },
3017 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{ 2,
false, 6, 0 }} },
3018 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{ 2,
false, 6, 0 }} },
3019 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{ 2,
false, 6, 0 }} },
3020 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{ 2,
false, 5, 0 }} },
3021 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{ 2,
false, 5, 0 }} },
3022 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{ 1,
false, 5, 0 }} },
3023 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{ 2,
false, 5, 0 }} },
3024 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{ 2,
false, 5, 0 }} },
3025 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{ 2,
false, 5, 0 }} },
3026 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{ 1,
false, 4, 0 }} },
3027 { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{ 1,
false, 5, 0 }} },
3028 { Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{ 1,
false, 5, 0 }} },
3029 { Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax,
3030 {{ 2,
false, 4, 0 },
3031 { 3,
false, 5, 0 }} },
3032 { Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax,
3033 {{ 2,
false, 4, 0 },
3034 { 3,
false, 5, 0 }} },
3035 { Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax,
3036 {{ 2,
false, 4, 0 },
3037 { 3,
false, 5, 0 }} },
3038 { Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax,
3039 {{ 2,
false, 4, 0 },
3040 { 3,
false, 5, 0 }} },
3041 { Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{ 1,
false, 5, 0 }} },
3042 { Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{ 1,
false, 5, 0 }} },
3043 { Hexagon::BI__builtin_HEXAGON_S2_valignib, {{ 2,
false, 3, 0 }} },
3044 { Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{ 2,
false, 3, 0 }} },
3045 { Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{ 2,
false, 5, 0 }} },
3046 { Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{ 2,
false, 5, 0 }} },
3047 { Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{ 2,
false, 5, 0 }} },
3048 { Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{ 2,
false, 5, 0 }} },
3049 { Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{ 1,
true , 6, 0 }} },
3050 { Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{ 1,
true, 6, 0 }} },
3051 { Hexagon::BI__builtin_HEXAGON_S4_extract, {{ 1,
false, 5, 0 },
3052 { 2,
false, 5, 0 }} },
3053 { Hexagon::BI__builtin_HEXAGON_S4_extractp, {{ 1,
false, 6, 0 },
3054 { 2,
false, 6, 0 }} },
3055 { Hexagon::BI__builtin_HEXAGON_S4_lsli, {{ 0,
true, 6, 0 }} },
3056 { Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{ 1,
false, 5, 0 }} },
3057 { Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{ 2,
false, 5, 0 }} },
3058 { Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{ 2,
false, 5, 0 }} },
3059 { Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{ 2,
false, 5, 0 }} },
3060 { Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{ 2,
false, 5, 0 }} },
3061 { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{ 3,
false, 2, 0 }} },
3062 { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{ 2,
false, 2, 0 }} },
3063 { Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax,
3064 {{ 1,
false, 4, 0 }} },
3065 { Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{ 1,
false, 4, 0 }} },
3066 { Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax,
3067 {{ 1,
false, 4, 0 }} },
3068 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{ 1,
false, 6, 0 }} },
3069 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{ 2,
false, 6, 0 }} },
3070 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{ 2,
false, 6, 0 }} },
3071 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{ 2,
false, 6, 0 }} },
3072 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{ 2,
false, 6, 0 }} },
3073 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{ 2,
false, 6, 0 }} },
3074 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{ 1,
false, 5, 0 }} },
3075 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{ 2,
false, 5, 0 }} },
3076 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{ 2,
false, 5, 0 }} },
3077 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{ 2,
false, 5, 0 }} },
3078 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{ 2,
false, 5, 0 }} },
3079 { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{ 2,
false, 5, 0 }} },
3080 { Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{ 2,
false, 3, 0 }} },
3081 { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{ 2,
false, 3, 0 }} },
3082 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{ 2,
false, 3, 0 }} },
3083 { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{ 2,
false, 3, 0 }} },
3084 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{ 2,
false, 1, 0 }} },
3085 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{ 2,
false, 1, 0 }} },
3086 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{ 3,
false, 1, 0 }} },
3087 { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B,
3088 {{ 3,
false, 1, 0 }} },
3089 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{ 2,
false, 1, 0 }} },
3090 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{ 2,
false, 1, 0 }} },
3091 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{ 3,
false, 1, 0 }} },
3092 { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B,
3093 {{ 3,
false, 1, 0 }} },
3094 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{ 2,
false, 1, 0 }} },
3095 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{ 2,
false, 1, 0 }} },
3096 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{ 3,
false, 1, 0 }} },
3097 { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B,
3098 {{ 3,
false, 1, 0 }} },
3103 static const bool SortOnce =
3106 return LHS.BuiltinID < RHS.BuiltinID;
3112 Infos, [=](
const BuiltinInfo &BI) {
return BI.BuiltinID < BuiltinID; });
3113 if (F == std::end(Infos) || F->BuiltinID != BuiltinID)
3118 for (
const ArgInfo &A : F->Infos) {
3120 if (A.BitWidth == 0)
3123 int32_t Min = A.IsSigned ? -(1 << (A.BitWidth - 1)) : 0;
3124 int32_t Max = (1 << (A.IsSigned ? A.BitWidth - 1 : A.BitWidth)) - 1;
3126 Error |= SemaBuiltinConstantArgRange(TheCall, A.OpNum, Min, Max);
3128 unsigned M = 1 << A.Align;
3131 Error |= SemaBuiltinConstantArgRange(TheCall, A.OpNum, Min, Max) |
3132 SemaBuiltinConstantArgMultiple(TheCall, A.OpNum, M);
3138 bool Sema::CheckHexagonBuiltinFunctionCall(
unsigned BuiltinID,
3140 return CheckHexagonBuiltinCpu(BuiltinID, TheCall) ||
3141 CheckHexagonBuiltinArgument(BuiltinID, TheCall);
3144 bool Sema::CheckMipsBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
3145 return CheckMipsBuiltinCpu(BuiltinID, TheCall) ||
3146 CheckMipsBuiltinArgument(BuiltinID, TheCall);
3149 bool Sema::CheckMipsBuiltinCpu(
unsigned BuiltinID,
CallExpr *TheCall) {
3152 if (Mips::BI__builtin_mips_addu_qb <= BuiltinID &&
3153 BuiltinID <= Mips::BI__builtin_mips_lwx) {
3155 return Diag(TheCall->
getBeginLoc(), diag::err_mips_builtin_requires_dsp);
3158 if (Mips::BI__builtin_mips_absq_s_qb <= BuiltinID &&
3159 BuiltinID <= Mips::BI__builtin_mips_subuh_r_qb) {
3162 diag::err_mips_builtin_requires_dspr2);
3165 if (Mips::BI__builtin_msa_add_a_b <= BuiltinID &&
3166 BuiltinID <= Mips::BI__builtin_msa_xori_b) {
3168 return Diag(TheCall->
getBeginLoc(), diag::err_mips_builtin_requires_msa);
3183 bool Sema::CheckMipsBuiltinArgument(
unsigned BuiltinID,
CallExpr *TheCall) {
3184 unsigned i = 0, l = 0, u = 0, m = 0;
3185 switch (BuiltinID) {
3186 default:
return false;
3187 case Mips::BI__builtin_mips_wrdsp: i = 1; l = 0; u = 63;
break;
3188 case Mips::BI__builtin_mips_rddsp: i = 0; l = 0; u = 63;
break;
3189 case Mips::BI__builtin_mips_append: i = 2; l = 0; u = 31;
break;
3190 case Mips::BI__builtin_mips_balign: i = 2; l = 0; u = 3;
break;
3191 case Mips::BI__builtin_mips_precr_sra_ph_w: i = 2; l = 0; u = 31;
break;
3192 case Mips::BI__builtin_mips_precr_sra_r_ph_w: i = 2; l = 0; u = 31;
break;
3193 case Mips::BI__builtin_mips_prepend: i = 2; l = 0; u = 31;
break;
3197 case Mips::BI__builtin_msa_bclri_b:
3198 case Mips::BI__builtin_msa_bnegi_b:
3199 case Mips::BI__builtin_msa_bseti_b:
3200 case Mips::BI__builtin_msa_sat_s_b:
3201 case Mips::BI__builtin_msa_sat_u_b:
3202 case Mips::BI__builtin_msa_slli_b:
3203 case Mips::BI__builtin_msa_srai_b:
3204 case Mips::BI__builtin_msa_srari_b:
3205 case Mips::BI__builtin_msa_srli_b:
3206 case Mips::BI__builtin_msa_srlri_b: i = 1; l = 0; u = 7;
break;
3207 case Mips::BI__builtin_msa_binsli_b:
3208 case Mips::BI__builtin_msa_binsri_b: i = 2; l = 0; u = 7;
break;
3210 case Mips::BI__builtin_msa_bclri_h:
3211 case Mips::BI__builtin_msa_bnegi_h:
3212 case Mips::BI__builtin_msa_bseti_h:
3213 case Mips::BI__builtin_msa_sat_s_h:
3214 case Mips::BI__builtin_msa_sat_u_h:
3215 case Mips::BI__builtin_msa_slli_h:
3216 case Mips::BI__builtin_msa_srai_h:
3217 case Mips::BI__builtin_msa_srari_h:
3218 case Mips::BI__builtin_msa_srli_h:
3219 case Mips::BI__builtin_msa_srlri_h: i = 1; l = 0; u = 15;
break;
3220 case Mips::BI__builtin_msa_binsli_h:
3221 case Mips::BI__builtin_msa_binsri_h: i = 2; l = 0; u = 15;
break;
3225 case Mips::BI__builtin_msa_cfcmsa:
3226 case Mips::BI__builtin_msa_ctcmsa: i = 0; l = 0; u = 31;
break;
3227 case Mips::BI__builtin_msa_clei_u_b:
3228 case Mips::BI__builtin_msa_clei_u_h:
3229 case Mips::BI__builtin_msa_clei_u_w:
3230 case Mips::BI__builtin_msa_clei_u_d:
3231 case Mips::BI__builtin_msa_clti_u_b:
3232 case Mips::BI__builtin_msa_clti_u_h:
3233 case Mips::BI__builtin_msa_clti_u_w:
3234 case Mips::BI__builtin_msa_clti_u_d:
3235 case Mips::BI__builtin_msa_maxi_u_b:
3236 case Mips::BI__builtin_msa_maxi_u_h:
3237 case Mips::BI__builtin_msa_maxi_u_w:
3238 case Mips::BI__builtin_msa_maxi_u_d:
3239 case Mips::BI__builtin_msa_mini_u_b:
3240 case Mips::BI__builtin_msa_mini_u_h:
3241 case Mips::BI__builtin_msa_mini_u_w:
3242 case Mips::BI__builtin_msa_mini_u_d:
3243 case Mips::BI__builtin_msa_addvi_b:
3244 case Mips::BI__builtin_msa_addvi_h:
3245 case Mips::BI__builtin_msa_addvi_w:
3246 case Mips::BI__builtin_msa_addvi_d:
3247 case Mips::BI__builtin_msa_bclri_w:
3248 case Mips::BI__builtin_msa_bnegi_w:
3249 case Mips::BI__builtin_msa_bseti_w:
3250 case Mips::BI__builtin_msa_sat_s_w:
3251 case Mips::BI__builtin_msa_sat_u_w:
3252 case Mips::BI__builtin_msa_slli_w:
3253 case Mips::BI__builtin_msa_srai_w:
3254 case Mips::BI__builtin_msa_srari_w:
3255 case Mips::BI__builtin_msa_srli_w:
3256 case Mips::BI__builtin_msa_srlri_w:
3257 case Mips::BI__builtin_msa_subvi_b:
3258 case Mips::BI__builtin_msa_subvi_h:
3259 case Mips::BI__builtin_msa_subvi_w:
3260 case Mips::BI__builtin_msa_subvi_d: i = 1; l = 0; u = 31;
break;
3261 case Mips::BI__builtin_msa_binsli_w:
3262 case Mips::BI__builtin_msa_binsri_w: i = 2; l = 0; u = 31;
break;
3264 case Mips::BI__builtin_msa_bclri_d:
3265 case Mips::BI__builtin_msa_bnegi_d:
3266 case Mips::BI__builtin_msa_bseti_d:
3267 case Mips::BI__builtin_msa_sat_s_d:
3268 case Mips::BI__builtin_msa_sat_u_d:
3269 case Mips::BI__builtin_msa_slli_d:
3270 case Mips::BI__builtin_msa_srai_d:
3271 case Mips::BI__builtin_msa_srari_d:
3272 case Mips::BI__builtin_msa_srli_d:
3273 case Mips::BI__builtin_msa_srlri_d: i = 1; l = 0; u = 63;
break;
3274 case Mips::BI__builtin_msa_binsli_d:
3275 case Mips::BI__builtin_msa_binsri_d: i = 2; l = 0; u = 63;
break;
3277 case Mips::BI__builtin_msa_ceqi_b:
3278 case Mips::BI__builtin_msa_ceqi_h:
3279 case Mips::BI__builtin_msa_ceqi_w:
3280 case Mips::BI__builtin_msa_ceqi_d:
3281 case Mips::BI__builtin_msa_clti_s_b:
3282 case Mips::BI__builtin_msa_clti_s_h:
3283 case Mips::BI__builtin_msa_clti_s_w:
3284 case Mips::BI__builtin_msa_clti_s_d:
3285 case Mips::BI__builtin_msa_clei_s_b:
3286 case Mips::BI__builtin_msa_clei_s_h:
3287 case Mips::BI__builtin_msa_clei_s_w:
3288 case Mips::BI__builtin_msa_clei_s_d:
3289 case Mips::BI__builtin_msa_maxi_s_b:
3290 case Mips::BI__builtin_msa_maxi_s_h:
3291 case Mips::BI__builtin_msa_maxi_s_w:
3292 case Mips::BI__builtin_msa_maxi_s_d:
3293 case Mips::BI__builtin_msa_mini_s_b:
3294 case Mips::BI__builtin_msa_mini_s_h:
3295 case Mips::BI__builtin_msa_mini_s_w:
3296 case Mips::BI__builtin_msa_mini_s_d: i = 1; l = -16; u = 15;
break;
3298 case Mips::BI__builtin_msa_andi_b:
3299 case Mips::BI__builtin_msa_nori_b:
3300 case Mips::BI__builtin_msa_ori_b:
3301 case Mips::BI__builtin_msa_shf_b:
3302 case Mips::BI__builtin_msa_shf_h:
3303 case Mips::BI__builtin_msa_shf_w:
3304 case Mips::BI__builtin_msa_xori_b: i = 1; l = 0; u = 255;
break;
3305 case Mips::BI__builtin_msa_bseli_b:
3306 case Mips::BI__builtin_msa_bmnzi_b:
3307 case Mips::BI__builtin_msa_bmzi_b: i = 2; l = 0; u = 255;
break;
3310 case Mips::BI__builtin_msa_copy_s_b:
3311 case Mips::BI__builtin_msa_copy_u_b:
3312 case Mips::BI__builtin_msa_insve_b:
3313 case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15;
break;
3314 case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15;
break;
3316 case Mips::BI__builtin_msa_copy_s_h:
3317 case Mips::BI__builtin_msa_copy_u_h:
3318 case Mips::BI__builtin_msa_insve_h:
3319 case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7;
break;
3320 case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7;
break;
3322 case Mips::BI__builtin_msa_copy_s_w:
3323 case Mips::BI__builtin_msa_copy_u_w:
3324 case Mips::BI__builtin_msa_insve_w:
3325 case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3;
break;
3326 case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3;
break;
3328 case Mips::BI__builtin_msa_copy_s_d:
3329 case Mips::BI__builtin_msa_copy_u_d:
3330 case Mips::BI__builtin_msa_insve_d:
3331 case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1;
break;
3332 case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1;
break;
3335 case Mips::BI__builtin_msa_ldi_b: i = 0; l = -128; u = 255;
break;
3336 case Mips::BI__builtin_msa_ldi_h:
3337 case Mips::BI__builtin_msa_ldi_w:
3338 case Mips::BI__builtin_msa_ldi_d: i = 0; l = -512; u = 511;
break;
3339 case Mips::BI__builtin_msa_ld_b: i = 1; l = -512; u = 511; m = 1;
break;
3340 case Mips::BI__builtin_msa_ld_h: i = 1; l = -1024; u = 1022; m = 2;
break;
3341 case Mips::BI__builtin_msa_ld_w: i = 1; l = -2048; u = 2044; m = 4;
break;
3342 case Mips::BI__builtin_msa_ld_d: i = 1; l = -4096; u = 4088; m = 8;
break;
3343 case Mips::BI__builtin_msa_st_b: i = 2; l = -512; u = 511; m = 1;
break;
3344 case Mips::BI__builtin_msa_st_h: i = 2; l = -1024; u = 1022; m = 2;
break;
3345 case Mips::BI__builtin_msa_st_w: i = 2; l = -2048; u = 2044; m = 4;
break;
3346 case Mips::BI__builtin_msa_st_d: i = 2; l = -4096; u = 4088; m = 8;
break;
3350 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3352 return SemaBuiltinConstantArgRange(TheCall, i, l, u) ||
3353 SemaBuiltinConstantArgMultiple(TheCall, i, m);
3356 bool Sema::CheckPPCBuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
3357 unsigned i = 0, l = 0, u = 0;
3358 bool Is64BitBltin = BuiltinID == PPC::BI__builtin_divde ||
3359 BuiltinID == PPC::BI__builtin_divdeu ||
3360 BuiltinID == PPC::BI__builtin_bpermd;
3364 .getIntPtrType()) == 64;
3365 bool IsBltinExtDiv = BuiltinID == PPC::BI__builtin_divwe ||
3366 BuiltinID == PPC::BI__builtin_divweu ||
3367 BuiltinID == PPC::BI__builtin_divde ||
3368 BuiltinID == PPC::BI__builtin_divdeu;
3370 if (Is64BitBltin && !IsTarget64Bit)
3371 return Diag(TheCall->
getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
3375 (BuiltinID == PPC::BI__builtin_bpermd &&
3377 return Diag(TheCall->
getBeginLoc(), diag::err_ppc_builtin_only_on_pwr7)
3380 auto SemaVSXCheck = [&](
CallExpr *TheCall) ->
bool {
3382 return Diag(TheCall->
getBeginLoc(), diag::err_ppc_builtin_only_on_pwr7)
3387 switch (BuiltinID) {
3388 default:
return false;
3389 case PPC::BI__builtin_altivec_crypto_vshasigmaw:
3390 case PPC::BI__builtin_altivec_crypto_vshasigmad:
3391 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
3392 SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
3393 case PPC::BI__builtin_altivec_dss:
3394 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3);
3395 case PPC::BI__builtin_tbegin:
3396 case PPC::BI__builtin_tend: i = 0; l = 0; u = 1;
break;
3397 case PPC::BI__builtin_tsr: i = 0; l = 0; u = 7;
break;
3398 case PPC::BI__builtin_tabortwc:
3399 case PPC::BI__builtin_tabortdc: i = 0; l = 0; u = 31;
break;
3400 case PPC::BI__builtin_tabortwci:
3401 case PPC::BI__builtin_tabortdci:
3402 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
3403 SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
3404 case PPC::BI__builtin_altivec_dst:
3405 case PPC::BI__builtin_altivec_dstt:
3406 case PPC::BI__builtin_altivec_dstst:
3407 case PPC::BI__builtin_altivec_dststt:
3408 return SemaBuiltinConstantArgRange(TheCall, 2, 0, 3);
3409 case PPC::BI__builtin_vsx_xxpermdi:
3410 case PPC::BI__builtin_vsx_xxsldwi:
3411 return SemaBuiltinVSX(TheCall);
3412 case PPC::BI__builtin_unpack_vector_int128:
3413 return SemaVSXCheck(TheCall) ||
3414 SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
3415 case PPC::BI__builtin_pack_vector_int128:
3416 return SemaVSXCheck(TheCall);
3418 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3421 bool Sema::CheckSystemZBuiltinFunctionCall(
unsigned BuiltinID,
3423 if (BuiltinID == SystemZ::BI__builtin_tabort) {
3427 AbortCode.getSExtValue() >= 0 && AbortCode.getSExtValue() < 256)
3428 return Diag(Arg->
getBeginLoc(), diag::err_systemz_invalid_tabort_code)
3434 unsigned i = 0, l = 0, u = 0;
3435 switch (BuiltinID) {
3436 default:
return false;
3437 case SystemZ::BI__builtin_s390_lcbb: i = 1; l = 0; u = 15;
break;
3438 case SystemZ::BI__builtin_s390_verimb:
3439 case SystemZ::BI__builtin_s390_verimh:
3440 case SystemZ::BI__builtin_s390_verimf:
3441 case SystemZ::BI__builtin_s390_verimg: i = 3; l = 0; u = 255;
break;
3442 case SystemZ::BI__builtin_s390_vfaeb:
3443 case SystemZ::BI__builtin_s390_vfaeh:
3444 case SystemZ::BI__builtin_s390_vfaef:
3445 case SystemZ::BI__builtin_s390_vfaebs:
3446 case SystemZ::BI__builtin_s390_vfaehs:
3447 case SystemZ::BI__builtin_s390_vfaefs:
3448 case SystemZ::BI__builtin_s390_vfaezb:
3449 case SystemZ::BI__builtin_s390_vfaezh:
3450 case SystemZ::BI__builtin_s390_vfaezf:
3451 case SystemZ::BI__builtin_s390_vfaezbs:
3452 case SystemZ::BI__builtin_s390_vfaezhs:
3453 case SystemZ::BI__builtin_s390_vfaezfs: i = 2; l = 0; u = 15;
break;
3454 case SystemZ::BI__builtin_s390_vfisb:
3455 case SystemZ::BI__builtin_s390_vfidb:
3456 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15) ||
3457 SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
3458 case SystemZ::BI__builtin_s390_vftcisb:
3459 case SystemZ::BI__builtin_s390_vftcidb: i = 1; l = 0; u = 4095;
break;
3460 case SystemZ::BI__builtin_s390_vlbb: i = 1; l = 0; u = 15;
break;
3461 case SystemZ::BI__builtin_s390_vpdi: i = 2; l = 0; u = 15;
break;
3462 case SystemZ::BI__builtin_s390_vsldb: i = 2; l = 0; u = 15;
break;
3463 case SystemZ::BI__builtin_s390_vstrcb:
3464 case SystemZ::BI__builtin_s390_vstrch:
3465 case SystemZ::BI__builtin_s390_vstrcf:
3466 case SystemZ::BI__builtin_s390_vstrczb:
3467 case SystemZ::BI__builtin_s390_vstrczh:
3468 case SystemZ::BI__builtin_s390_vstrczf:
3469 case SystemZ::BI__builtin_s390_vstrcbs:
3470 case SystemZ::BI__builtin_s390_vstrchs:
3471 case SystemZ::BI__builtin_s390_vstrcfs:
3472 case SystemZ::BI__builtin_s390_vstrczbs:
3473 case SystemZ::BI__builtin_s390_vstrczhs:
3474 case SystemZ::BI__builtin_s390_vstrczfs: i = 3; l = 0; u = 15;
break;
3475 case SystemZ::BI__builtin_s390_vmslg: i = 3; l = 0; u = 15;
break;
3476 case SystemZ::BI__builtin_s390_vfminsb:
3477 case SystemZ::BI__builtin_s390_vfmaxsb:
3478 case SystemZ::BI__builtin_s390_vfmindb:
3479 case SystemZ::BI__builtin_s390_vfmaxdb: i = 2; l = 0; u = 15;
break;
3480 case SystemZ::BI__builtin_s390_vsld: i = 2; l = 0; u = 7;
break;
3481 case SystemZ::BI__builtin_s390_vsrd: i = 2; l = 0; u = 7;
break;
3483 return SemaBuiltinConstantArgRange(TheCall, i, l, u);
3494 return S.
Diag(TheCall->
getBeginLoc(), diag::err_expr_not_string_literal)
3514 return S.
Diag(TheCall->
getBeginLoc(), diag::err_expr_not_string_literal)
3527 bool Sema::CheckX86BuiltinRoundingOrSAE(
unsigned BuiltinID,
CallExpr *TheCall) {
3531 unsigned ArgNum = 0;
3532 switch (BuiltinID) {
3535 case X86::BI__builtin_ia32_vcvttsd2si32:
3536 case X86::BI__builtin_ia32_vcvttsd2si64:
3537 case X86::BI__builtin_ia32_vcvttsd2usi32:
3538 case X86::BI__builtin_ia32_vcvttsd2usi64:
3539 case X86::BI__builtin_ia32_vcvttss2si32:
3540 case X86::BI__builtin_ia32_vcvttss2si64:
3541 case X86::BI__builtin_ia32_vcvttss2usi32:
3542 case X86::BI__builtin_ia32_vcvttss2usi64:
3545 case X86::BI__builtin_ia32_maxpd512:
3546 case X86::BI__builtin_ia32_maxps512:
3547 case X86::BI__builtin_ia32_minpd512:
3548 case X86::BI__builtin_ia32_minps512:
3551 case X86::BI__builtin_ia32_cvtps2pd512_mask:
3552 case X86::BI__builtin_ia32_cvttpd2dq512_mask:
3553 case X86::BI__builtin_ia32_cvttpd2qq512_mask:
3554 case X86::BI__builtin_ia32_cvttpd2udq512_mask:
3555 case X86::BI__builtin_ia32_cvttpd2uqq512_mask:
3556 case X86::BI__builtin_ia32_cvttps2dq512_mask:
3557 case X86::BI__builtin_ia32_cvttps2qq512_mask:
3558 case X86::BI__builtin_ia32_cvttps2udq512_mask:
3559 case X86::BI__builtin_ia32_cvttps2uqq512_mask:
3560 case X86::BI__builtin_ia32_exp2pd_mask:
3561 case X86::BI__builtin_ia32_exp2ps_mask:
3562 case X86::BI__builtin_ia32_getexppd512_mask:
3563 case X86::BI__builtin_ia32_getexpps512_mask:
3564 case X86::BI__builtin_ia32_rcp28pd_mask:
3565 case X86::BI__builtin_ia32_rcp28ps_mask:
3566 case X86::BI__builtin_ia32_rsqrt28pd_mask:
3567 case X86::BI__builtin_ia32_rsqrt28ps_mask:
3568 case X86::BI__builtin_ia32_vcomisd:
3569 case X86::BI__builtin_ia32_vcomiss:
3570 case X86::BI__builtin_ia32_vcvtph2ps512_mask:
3573 case X86::BI__builtin_ia32_cmppd512_mask:
3574 case X86::BI__builtin_ia32_cmpps512_mask:
3575 case X86::BI__builtin_ia32_cmpsd_mask:
3576 case X86::BI__builtin_ia32_cmpss_mask:
3577 case X86::BI__builtin_ia32_cvtss2sd_round_mask:
3578 case X86::BI__builtin_ia32_getexpsd128_round_mask:
3579 case X86::BI__builtin_ia32_getexpss128_round_mask:
3580 case X86::BI__builtin_ia32_getmantpd512_mask:
3581 case X86::BI__builtin_ia32_getmantps512_mask:
3582 case X86::BI__builtin_ia32_maxsd_round_mask:
3583 case X86::BI__builtin_ia32_maxss_round_mask:
3584 case X86::BI__builtin_ia32_minsd_round_mask:
3585 case X86::BI__builtin_ia32_minss_round_mask:
3586 case X86::BI__builtin_ia32_rcp28sd_round_mask:
3587 case X86::BI__builtin_ia32_rcp28ss_round_mask:
3588 case X86::BI__builtin_ia32_reducepd512_mask:
3589 case X86::BI__builtin_ia32_reduceps512_mask:
3590 case X86::BI__builtin_ia32_rndscalepd_mask:
3591 case X86::BI__builtin_ia32_rndscaleps_mask:
3592 case X86::BI__builtin_ia32_rsqrt28sd_round_mask:
3593 case X86::BI__builtin_ia32_rsqrt28ss_round_mask:
3596 case X86::BI__builtin_ia32_fixupimmpd512_mask:
3597 case X86::BI__builtin_ia32_fixupimmpd512_maskz:
3598 case X86::BI__builtin_ia32_fixupimmps512_mask:
3599 case X86::BI__builtin_ia32_fixupimmps512_maskz:
3600 case X86::BI__builtin_ia32_fixupimmsd_mask:
3601 case X86::BI__builtin_ia32_fixupimmsd_maskz:
3602 case X86::BI__builtin_ia32_fixupimmss_mask:
3603 case X86::BI__builtin_ia32_fixupimmss_maskz:
3604 case X86::BI__builtin_ia32_getmantsd_round_mask:
3605 case X86::BI__builtin_ia32_getmantss_round_mask:
3606 case X86::BI__builtin_ia32_rangepd512_mask:
3607 case X86::BI__builtin_ia32_rangeps512_mask:
3608 case X86::BI__builtin_ia32_rangesd128_round_mask:
3609 case X86::BI__builtin_ia32_rangess128_round_mask:
3610 case X86::BI__builtin_ia32_reducesd_mask:
3611 case X86::BI__builtin_ia32_reducess_mask:
3612 case X86::BI__builtin_ia32_rndscalesd_round_mask:
3613 case X86::BI__builtin_ia32_rndscaless_round_mask:
3616 case X86::BI__builtin_ia32_vcvtsd2si64:
3617 case X86::BI__builtin_ia32_vcvtsd2si32:
3618 case X86::BI__builtin_ia32_vcvtsd2usi32:
3619 case X86::BI__builtin_ia32_vcvtsd2usi64:
3620 case X86::BI__builtin_ia32_vcvtss2si32:
3621 case X86::BI__builtin_ia32_vcvtss2si64:
3622 case X86::BI__builtin_ia32_vcvtss2usi32:
3623 case X86::BI__builtin_ia32_vcvtss2usi64:
3624 case X86::BI__builtin_ia32_sqrtpd512:
3625 case X86::BI__builtin_ia32_sqrtps512:
3629 case X86::BI__builtin_ia32_addpd512:
3630 case X86::BI__builtin_ia32_addps512:
3631 case X86::BI__builtin_ia32_divpd512:
3632 case X86::BI__builtin_ia32_divps512:
3633 case X86::BI__builtin_ia32_mulpd512:
3634 case X86::BI__builtin_ia32_mulps512:
3635 case X86::BI__builtin_ia32_subpd512:
3636 case X86::BI__builtin_ia32_subps512:
3637 case X86::BI__builtin_ia32_cvtsi2sd64:
3638 case X86::BI__builtin_ia32_cvtsi2ss32:
3639 case X86::BI__builtin_ia32_cvtsi2ss64:
3640 case X86::BI__builtin_ia32_cvtusi2sd64:
3641 case X86::BI__builtin_ia32_cvtusi2ss32:
3642 case X86::BI__builtin_ia32_cvtusi2ss64:
3646 case X86::BI__builtin_ia32_cvtdq2ps512_mask:
3647 case X86::BI__builtin_ia32_cvtudq2ps512_mask:
3648 case X86::BI__builtin_ia32_cvtpd2ps512_mask:
3649 case X86::BI__builtin_ia32_cvtpd2dq512_mask:
3650 case X86::BI__builtin_ia32_cvtpd2qq512_mask:
3651 case X86::BI__builtin_ia32_cvtpd2udq512_mask:
3652 case X86::BI__builtin_ia32_cvtpd2uqq512_mask:
3653 case X86::BI__builtin_ia32_cvtps2dq512_mask:
3654 case X86::BI__builtin_ia32_cvtps2qq512_mask:
3655 case X86::BI__builtin_ia32_cvtps2udq512_mask:
3656 case X86::BI__builtin_ia32_cvtps2uqq512_mask:
3657 case X86::BI__builtin_ia32_cvtqq2pd512_mask:
3658 case X86::BI__builtin_ia32_cvtqq2ps512_mask:
3659 case X86::BI__builtin_ia32_cvtuqq2pd512_mask:
3660 case X86::BI__builtin_ia32_cvtuqq2ps512_mask:
3664 case X86::BI__builtin_ia32_addss_round_mask:
3665 case X86::BI__builtin_ia32_addsd_round_mask:
3666 case X86::BI__builtin_ia32_divss_round_mask:
3667 case X86::BI__builtin_ia32_divsd_round_mask:
3668 case X86::BI__builtin_ia32_mulss_round_mask:
3669 case X86::BI__builtin_ia32_mulsd_round_mask:
3670 case X86::BI__builtin_ia32_subss_round_mask:
3671 case X86::BI__builtin_ia32_subsd_round_mask:
3672 case X86::BI__builtin_ia32_scalefpd512_mask:
3673 case X86::BI__builtin_ia32_scalefps512_mask:
3674 case X86::BI__builtin_ia32_scalefsd_round_mask:
3675 case X86::BI__builtin_ia32_scalefss_round_mask:
3676 case X86::BI__builtin_ia32_cvtsd2ss_round_mask:
3677 case X86::BI__builtin_ia32_sqrtsd_round_mask:
3678 case X86::BI__builtin_ia32_sqrtss_round_mask:
3679 case X86::BI__builtin_ia32_vfmaddsd3_mask:
3680 case X86::BI__builtin_ia32_vfmaddsd3_maskz:
3681 case X86::BI__builtin_ia32_vfmaddsd3_mask3:
3682 case X86::BI__builtin_ia32_vfmaddss3_mask:
3683 case X86::BI__builtin_ia32_vfmaddss3_maskz:
3684 case X86::BI__builtin_ia32_vfmaddss3_mask3:
3685 case X86::BI__builtin_ia32_vfmaddpd512_mask:
3686 case X86::BI__builtin_ia32_vfmaddpd512_maskz:
3687 case X86::BI__builtin_ia32_vfmaddpd512_mask3:
3688 case X86::BI__builtin_ia32_vfmsubpd512_mask3:
3689 case X86::BI__builtin_ia32_vfmaddps512_mask:
3690 case X86::BI__builtin_ia32_vfmaddps512_maskz:
3691 case X86::BI__builtin_ia32_vfmaddps512_mask3:
3692 case X86::BI__builtin_ia32_vfmsubps512_mask3:
3693 case X86::BI__builtin_ia32_vfmaddsubpd512_mask:
3694 case X86::BI__builtin_ia32_vfmaddsubpd512_maskz:
3695 case X86::BI__builtin_ia32_vfmaddsubpd512_mask3:
3696 case X86::BI__builtin_ia32_vfmsubaddpd512_mask3:
3697 case X86::BI__builtin_ia32_vfmaddsubps512_mask:
3698 case X86::BI__builtin_ia32_vfmaddsubps512_maskz:
3699 case X86::BI__builtin_ia32_vfmaddsubps512_mask3:
3700 case X86::BI__builtin_ia32_vfmsubaddps512_mask3:
3714 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
3723 (!HasRC && Result == 12) ||
3724 (HasRC && Result.getZExtValue() >= 8 && Result.getZExtValue() <= 11))
3727 return Diag(TheCall->
getBeginLoc(), diag::err_x86_builtin_invalid_rounding)
3732 bool Sema::CheckX86BuiltinGatherScatterScale(
unsigned BuiltinID,
3734 unsigned ArgNum = 0;
3735 switch (BuiltinID) {
3738 case X86::BI__builtin_ia32_gatherpfdpd:
3739 case X86::BI__builtin_ia32_gatherpfdps:
3740 case X86::BI__builtin_ia32_gatherpfqpd:
3741 case X86::BI__builtin_ia32_gatherpfqps:
3742 case X86::BI__builtin_ia32_scatterpfdpd:
3743 case X86::BI__builtin_ia32_scatterpfdps:
3744 case X86::BI__builtin_ia32_scatterpfqpd:
3745 case X86::BI__builtin_ia32_scatterpfqps:
3748 case X86::BI__builtin_ia32_gatherd_pd:
3749 case X86::BI__builtin_ia32_gatherd_pd256:
3750 case X86::BI__builtin_ia32_gatherq_pd:
3751 case X86::BI__builtin_ia32_gatherq_pd256:
3752 case X86::BI__builtin_ia32_gatherd_ps:
3753 case X86::BI__builtin_ia32_gatherd_ps256:
3754 case X86::BI__builtin_ia32_gatherq_ps:
3755 case X86::BI__builtin_ia32_gatherq_ps256:
3756 case X86::BI__builtin_ia32_gatherd_q:
3757 case X86::BI__builtin_ia32_gatherd_q256:
3758 case X86::BI__builtin_ia32_gatherq_q:
3759 case X86::BI__builtin_ia32_gatherq_q256:
3760 case X86::BI__builtin_ia32_gatherd_d:
3761 case X86::BI__builtin_ia32_gatherd_d256:
3762 case X86::BI__builtin_ia32_gatherq_d:
3763 case X86::BI__builtin_ia32_gatherq_d256:
3764 case X86::BI__builtin_ia32_gather3div2df:
3765 case X86::BI__builtin_ia32_gather3div2di:
3766 case X86::BI__builtin_ia32_gather3div4df:
3767 case X86::BI__builtin_ia32_gather3div4di:
3768 case X86::BI__builtin_ia32_gather3div4sf:
3769 case X86::BI__builtin_ia32_gather3div4si:
3770 case X86::BI__builtin_ia32_gather3div8sf:
3771 case X86::BI__builtin_ia32_gather3div8si:
3772 case X86::BI__builtin_ia32_gather3siv2df:
3773 case X86::BI__builtin_ia32_gather3siv2di:
3774 case X86::BI__builtin_ia32_gather3siv4df:
3775 case X86::BI__builtin_ia32_gather3siv4di:
3776 case X86::BI__builtin_ia32_gather3siv4sf:
3777 case X86::BI__builtin_ia32_gather3siv4si:
3778 case X86::BI__builtin_ia32_gather3siv8sf:
3779 case X86::BI__builtin_ia32_gather3siv8si:
3780 case X86::BI__builtin_ia32_gathersiv8df:
3781 case X86::BI__builtin_ia32_gathersiv16sf:
3782 case X86::BI__builtin_ia32_gatherdiv8df:
3783 case X86::BI__builtin_ia32_gatherdiv16sf:
3784 case X86::BI__builtin_ia32_gathersiv8di:
3785 case X86::BI__builtin_ia32_gathersiv16si:
3786 case X86::BI__builtin_ia32_gatherdiv8di:
3787 case X86::BI__builtin_ia32_gatherdiv16si:
3788 case X86::BI__builtin_ia32_scatterdiv2df:
3789 case X86::BI__builtin_ia32_scatterdiv2di:
3790 case X86::BI__builtin_ia32_scatterdiv4df:
3791 case X86::BI__builtin_ia32_scatterdiv4di:
3792 case X86::BI__builtin_ia32_scatterdiv4sf:
3793 case X86::BI__builtin_ia32_scatterdiv4si:
3794 case X86::BI__builtin_ia32_scatterdiv8sf:
3795 case X86::BI__builtin_ia32_scatterdiv8si:
3796 case X86::BI__builtin_ia32_scattersiv2df:
3797 case X86::BI__builtin_ia32_scattersiv2di:
3798 case X86::BI__builtin_ia32_scattersiv4df:
3799 case X86::BI__builtin_ia32_scattersiv4di:
3800 case X86::BI__builtin_ia32_scattersiv4sf:
3801 case X86::BI__builtin_ia32_scattersiv4si:
3802 case X86::BI__builtin_ia32_scattersiv8sf:
3803 case X86::BI__builtin_ia32_scattersiv8si:
3804 case X86::BI__builtin_ia32_scattersiv8df:
3805 case X86::BI__builtin_ia32_scattersiv16sf:
3806 case X86::BI__builtin_ia32_scatterdiv8df:
3807 case X86::BI__builtin_ia32_scatterdiv16sf:
3808 case X86::BI__builtin_ia32_scattersiv8di:
3809 case X86::BI__builtin_ia32_scattersiv16si:
3810 case X86::BI__builtin_ia32_scatterdiv8di:
3811 case X86::BI__builtin_ia32_scatterdiv16si:
3824 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
3827 if (Result == 1 || Result == 2 || Result == 4 || Result == 8)
3830 return Diag(TheCall->
getBeginLoc(), diag::err_x86_builtin_invalid_scale)
3836 switch (BuiltinID) {
3837 case X86::BI__builtin_ia32_readeflags_u32:
3838 case X86::BI__builtin_ia32_writeeflags_u32:
3845 bool Sema::CheckX86BuiltinFunctionCall(
unsigned BuiltinID,
CallExpr *TheCall) {
3846 if (BuiltinID == X86::BI__builtin_cpu_supports)
3849 if (BuiltinID == X86::BI__builtin_cpu_is)
3856 diag::err_32_bit_builtin_64_bit_tgt);
3859 if (CheckX86BuiltinRoundingOrSAE(BuiltinID, TheCall))
3863 if (CheckX86BuiltinGatherScatterScale(BuiltinID, TheCall))
3868 int i = 0, l = 0, u = 0;
3869 switch (BuiltinID) {
3872 case X86::BI__builtin_ia32_vec_ext_v2si:
3873 case X86::BI__builtin_ia32_vec_ext_v2di:
3874 case X86::BI__builtin_ia32_vextractf128_pd256:
3875 case X86::BI__builtin_ia32_vextractf128_ps256:
3876 case X86::BI__builtin_ia32_vextractf128_si256:
3877 case X86::BI__builtin_ia32_extract128i256:
3878 case X86::BI__builtin_ia32_extractf64x4_mask:
3879 case X86::BI__builtin_ia32_extracti64x4_mask:
3880 case X86::BI__builtin_ia32_extractf32x8_mask:
3881 case X86::BI__builtin_ia32_extracti32x8_mask:
3882 case X86::BI__builtin_ia32_extractf64x2_256_mask:
3883 case X86::BI__builtin_ia32_extracti64x2_256_mask:
3884 case X86::BI__builtin_ia32_extractf32x4_256_mask:
3885 case X86::BI__builtin_ia32_extracti32x4_256_mask:
3886 i = 1; l = 0; u = 1;
3888 case X86::BI__builtin_ia32_vec_set_v2di:
3889 case X86::BI__builtin_ia32_vinsertf128_pd256:
3890 case X86::BI__builtin_ia32_vinsertf128_ps256:
3891 case X86::BI__builtin_ia32_vinsertf128_si256:
3892 case X86::BI__builtin_ia32_insert128i256:
3893 case X86::BI__builtin_ia32_insertf32x8:
3894 case X86::BI__builtin_ia32_inserti32x8:
3895 case X86::BI__builtin_ia32_insertf64x4:
3896 case X86::BI__builtin_ia32_inserti64x4:
3897 case X86::BI__builtin_ia32_insertf64x2_256:
3898 case X86::BI__builtin_ia32_inserti64x2_256:
3899 case X86::BI__builtin_ia32_insertf32x4_256:
3900 case X86::BI__builtin_ia32_inserti32x4_256:
3901 i = 2; l = 0; u = 1;
3903 case X86::BI__builtin_ia32_vpermilpd:
3904 case X86::BI__builtin_ia32_vec_ext_v4hi:
3905 case X86::BI__builtin_ia32_vec_ext_v4si:
3906 case X86::BI__builtin_ia32_vec_ext_v4sf:
3907 case X86::BI__builtin_ia32_vec_ext_v4di:
3908 case X86::BI__builtin_ia32_extractf32x4_mask:
3909 case X86::BI__builtin_ia32_extracti32x4_mask:
3910 case X86::BI__builtin_ia32_extractf64x2_512_mask:
3911 case X86::BI__builtin_ia32_extracti64x2_512_mask:
3912 i = 1; l = 0; u = 3;
3914 case X86::BI_mm_prefetch:
3915 case X86::BI__builtin_ia32_vec_ext_v8hi:
3916 case X86::BI__builtin_ia32_vec_ext_v8si:
3917 i = 1; l = 0; u = 7;
3919 case X86::BI__builtin_ia32_sha1rnds4:
3920 case X86::BI__builtin_ia32_blendpd:
3921 case X86::BI__builtin_ia32_shufpd:
3922 case X86::BI__builtin_ia32_vec_set_v4hi:
3923 case X86::BI__builtin_ia32_vec_set_v4si:
3924 case X86::BI__builtin_ia32_vec_set_v4di:
3925 case X86::BI__builtin_ia32_shuf_f32x4_256:
3926 case X86::BI__builtin_ia32_shuf_f64x2_256:
3927 case X86::BI__builtin_ia32_shuf_i32x4_256:
3928 case X86::BI__builtin_ia32_shuf_i64x2_256:
3929 case X86::BI__builtin_ia32_insertf64x2_512:
3930 case X86::BI__builtin_ia32_inserti64x2_512:
3931 case X86::BI__builtin_ia32_insertf32x4:
3932 case X86::BI__builtin_ia32_inserti32x4:
3933 i = 2; l = 0; u = 3;
3935 case X86::BI__builtin_ia32_vpermil2pd:
3936 case X86::BI__builtin_ia32_vpermil2pd256:
3937 case X86::BI__builtin_ia32_vpermil2ps:
3938 case X86::BI__builtin_ia32_vpermil2ps256:
3939 i = 3; l = 0; u = 3;
3941 case X86::BI__builtin_ia32_cmpb128_mask:
3942 case X86::BI__builtin_ia32_cmpw128_mask:
3943 case X86::BI__builtin_ia32_cmpd128_mask:
3944 case X86::BI__builtin_ia32_cmpq128_mask:
3945 case X86::BI__builtin_ia32_cmpb256_mask:
3946 case X86::BI__builtin_ia32_cmpw256_mask:
3947 case X86::BI__builtin_ia32_cmpd256_mask:
3948 case X86::BI__builtin_ia32_cmpq256_mask:
3949 case X86::BI__builtin_ia32_cmpb512_mask:
3950 case X86::BI__builtin_ia32_cmpw512_mask:
3951 case X86::BI__builtin_ia32_cmpd512_mask:
3952 case X86::BI__builtin_ia32_cmpq512_mask:
3953 case X86::BI__builtin_ia32_ucmpb128_mask:
3954 case X86::BI__builtin_ia32_ucmpw128_mask:
3955 case X86::BI__builtin_ia32_ucmpd128_mask:
3956 case X86::BI__builtin_ia32_ucmpq128_mask:
3957 case X86::BI__builtin_ia32_ucmpb256_mask:
3958 case X86::BI__builtin_ia32_ucmpw256_mask:
3959 case X86::BI__builtin_ia32_ucmpd256_mask:
3960 case X86::BI__builtin_ia32_ucmpq256_mask:
3961 case X86::BI__builtin_ia32_ucmpb512_mask:
3962 case X86::BI__builtin_ia32_ucmpw512_mask:
3963 case X86::BI__builtin_ia32_ucmpd512_mask:
3964 case X86::BI__builtin_ia32_ucmpq512_mask:
3965 case X86::BI__builtin_ia32_vpcomub:
3966 case X86::BI__builtin_ia32_vpcomuw:
3967 case X86::BI__builtin_ia32_vpcomud:
3968 case X86::BI__builtin_ia32_vpcomuq:
3969 case X86::BI__builtin_ia32_vpcomb:
3970 case X86::BI__builtin_ia32_vpcomw:
3971 case X86::BI__builtin_ia32_vpcomd:
3972 case X86::BI__builtin_ia32_vpcomq:
3973 case X86::BI__builtin_ia32_vec_set_v8hi:
3974 case X86::BI__builtin_ia32_vec_set_v8si:
3975 i = 2; l = 0; u = 7;
3977 case X86::BI__builtin_ia32_vpermilpd256:
3978 case X86::BI__builtin_ia32_roundps:
3979 case X86::BI__builtin_ia32_roundpd:
3980 case X86::BI__builtin_ia32_roundps256:
3981 case X86::BI__builtin_ia32_roundpd256:
3982 case X86::BI__builtin_ia32_getmantpd128_mask:
3983 case X86::BI__builtin_ia32_getmantpd256_mask:
3984 case X86::BI__builtin_ia32_getmantps128_mask:
3985 case X86::BI__builtin_ia32_getmantps256_mask:
3986 case X86::BI__builtin_ia32_getmantpd512_mask:
3987 case X86::BI__builtin_ia32_getmantps512_mask:
3988 case X86::BI__builtin_ia32_vec_ext_v16qi:
3989 case X86::BI__builtin_ia32_vec_ext_v16hi:
3990 i = 1; l = 0; u = 15;
3992 case X86::BI__builtin_ia32_pblendd128:
3993 case X86::BI__builtin_ia32_blendps:
3994 case X86::BI__builtin_ia32_blendpd256:
3995 case X86::BI__builtin_ia32_shufpd256:
3996 case X86::BI__builtin_ia32_roundss:
3997 case X86::BI__builtin_ia32_roundsd:
3998 case X86::BI__builtin_ia32_rangepd128_mask:
3999 case X86::BI__builtin_ia32_rangepd256_mask:
4000 case X86::BI__builtin_ia32_rangepd512_mask:
4001 case X86::BI__builtin_ia32_rangeps128_mask:
4002 case X86::BI__builtin_ia32_rangeps256_mask:
4003 case X86::BI__builtin_ia32_rangeps512_mask:
4004 case X86::BI__builtin_ia32_getmantsd_round_mask:
4005 case X86::BI__builtin_ia32_getmantss_round_mask:
4006 case X86::BI__builtin_ia32_vec_set_v16qi:
4007 case X86::BI__builtin_ia32_vec_set_v16hi:
4008 i = 2; l = 0; u = 15;
4010 case X86::BI__builtin_ia32_vec_ext_v32qi:
4011 i = 1; l = 0; u = 31;
4013 case X86::BI__builtin_ia32_cmpps:
4014 case X86::BI__builtin_ia32_cmpss:
4015 case X86::BI__builtin_ia32_cmppd:
4016 case X86::BI__builtin_ia32_cmpsd:
4017 case X86::BI__builtin_ia32_cmpps256:
4018 case X86::BI__builtin_ia32_cmppd256:
4019 case X86::BI__builtin_ia32_cmpps128_mask:
4020 case X86::BI__builtin_ia32_cmppd128_mask:
4021 case X86::BI__builtin_ia32_cmpps256_mask:
4022 case X86::BI__builtin_ia32_cmppd256_mask:
4023 case X86::BI__builtin_ia32_cmpps512_mask:
4024 case X86::BI__builtin_ia32_cmppd512_mask:
4025 case X86::BI__builtin_ia32_cmpsd_mask:
4026 case X86::BI__builtin_ia32_cmpss_mask:
4027 case X86::BI__builtin_ia32_vec_set_v32qi:
4028 i = 2; l = 0; u = 31;
4030 case X86::BI__builtin_ia32_permdf256:
4031 case X86::BI__builtin_ia32_permdi256:
4032 case X86::BI__builtin_ia32_permdf512:
4033 case X86::BI__builtin_ia32_permdi512:
4034 case X86::BI__builtin_ia32_vpermilps:
4035 case X86::BI__builtin_ia32_vpermilps256:
4036 case X86::BI__builtin_ia32_vpermilpd512:
4037 case X86::BI__builtin_ia32_vpermilps512:
4038 case X86::BI__builtin_ia32_pshufd:
4039 case X86::BI__builtin_ia32_pshufd256:
4040 case X86::BI__builtin_ia32_pshufd512:
4041 case X86::BI__builtin_ia32_pshufhw:
4042 case X86::BI__builtin_ia32_pshufhw256:
4043 case X86::BI__builtin_ia32_pshufhw512:
4044 case X86::BI__builtin_ia32_pshuflw:
4045 case X86::BI__builtin_ia32_pshuflw256:
4046 case X86::BI__builtin_ia32_pshuflw512:
4047 case X86::BI__builtin_ia32_vcvtps2ph:
4048 case X86::BI__builtin_ia32_vcvtps2ph_mask:
4049 case X86::BI__builtin_ia32_vcvtps2ph256:
4050 case X86::BI__builtin_ia32_vcvtps2ph256_mask:
4051 case X86::BI__builtin_ia32_vcvtps2ph512_mask:
4052 case X86::BI__builtin_ia32_rndscaleps_128_mask:
4053 case X86::BI__builtin_ia32_rndscalepd_128_mask:
4054 case X86::BI__builtin_ia32_rndscaleps_256_mask:
4055 case X86::BI__builtin_ia32_rndscalepd_256_mask:
4056 case X86::BI__builtin_ia32_rndscaleps_mask:
4057 case X86::BI__builtin_ia32_rndscalepd_mask:
4058 case X86::BI__builtin_ia32_reducepd128_mask:
4059 case X86::BI__builtin_ia32_reducepd256_mask:
4060 case X86::BI__builtin_ia32_reducepd512_mask:
4061 case X86::BI__builtin_ia32_reduceps128_mask:
4062 case X86::BI__builtin_ia32_reduceps256_mask:
4063 case X86::BI__builtin_ia32_reduceps512_mask:
4064 case X86::BI__builtin_ia32_prold512:
4065 case X86::BI__builtin_ia32_prolq512:
4066 case X86::BI__builtin_ia32_prold128:
4067 case X86::BI__builtin_ia32_prold256:
4068 case X86::BI__builtin_ia32_prolq128:
4069 case X86::BI__builtin_ia32_prolq256:
4070 case X86::BI__builtin_ia32_prord512:
4071 case X86::BI__builtin_ia32_prorq512:
4072 case X86::BI__builtin_ia32_prord128:
4073 case X86::BI__builtin_ia32_prord256:
4074 case X86::BI__builtin_ia32_prorq128:
4075 case X86::BI__builtin_ia32_prorq256:
4076 case X86::BI__builtin_ia32_fpclasspd128_mask:
4077 case X86::BI__builtin_ia32_fpclasspd256_mask:
4078 case X86::BI__builtin_ia32_fpclassps128_mask:
4079 case X86::BI__builtin_ia32_fpclassps256_mask:
4080 case X86::BI__builtin_ia32_fpclassps512_mask:
4081 case X86::BI__builtin_ia32_fpclasspd512_mask:
4082 case X86::BI__builtin_ia32_fpclasssd_mask:
4083 case X86::BI__builtin_ia32_fpclassss_mask:
4084 case X86::BI__builtin_ia32_pslldqi128_byteshift:
4085 case X86::BI__builtin_ia32_pslldqi256_byteshift:
4086 case X86::BI__builtin_ia32_pslldqi512_byteshift:
4087 case X86::BI__builtin_ia32_psrldqi128_byteshift:
4088 case X86::BI__builtin_ia32_psrldqi256_byteshift:
4089 case X86::BI__builtin_ia32_psrldqi512_byteshift:
4090 case X86::BI__builtin_ia32_kshiftliqi:
4091 case X86::BI__builtin_ia32_kshiftlihi:
4092 case X86::BI__builtin_ia32_kshiftlisi:
4093 case X86::BI__builtin_ia32_kshiftlidi:
4094 case X86::BI__builtin_ia32_kshiftriqi:
4095 case X86::BI__builtin_ia32_kshiftrihi:
4096 case X86::BI__builtin_ia32_kshiftrisi:
4097 case X86::BI__builtin_ia32_kshiftridi:
4098 i = 1; l = 0; u = 255;
4100 case X86::BI__builtin_ia32_vperm2f128_pd256:
4101 case X86::BI__builtin_ia32_vperm2f128_ps256:
4102 case X86::BI__builtin_ia32_vperm2f128_si256:
4103 case X86::BI__builtin_ia32_permti256:
4104 case X86::BI__builtin_ia32_pblendw128:
4105 case X86::BI__builtin_ia32_pblendw256:
4106 case X86::BI__builtin_ia32_blendps256:
4107 case X86::BI__builtin_ia32_pblendd256:
4108 case X86::BI__builtin_ia32_palignr128:
4109 case X86::BI__builtin_ia32_palignr256:
4110 case X86::BI__builtin_ia32_palignr512:
4111 case X86::BI__builtin_ia32_alignq512:
4112 case X86::BI__builtin_ia32_alignd512:
4113 case X86::BI__builtin_ia32_alignd128:
4114 case X86::BI__builtin_ia32_alignd256:
4115 case X86::BI__builtin_ia32_alignq128:
4116 case X86::BI__builtin_ia32_alignq256:
4117 case X86::BI__builtin_ia32_vcomisd:
4118 case X86::BI__builtin_ia32_vcomiss:
4119 case X86::BI__builtin_ia32_shuf_f32x4:
4120 case X86::BI__builtin_ia32_shuf_f64x2:
4121 case X86::BI__builtin_ia32_shuf_i32x4:
4122 case X86::BI__builtin_ia32_shuf_i64x2:
4123 case X86::BI__builtin_ia32_shufpd512:
4124 case X86::BI__builtin_ia32_shufps:
4125 case X86::BI__builtin_ia32_shufps256:
4126 case X86::BI__builtin_ia32_shufps512:
4127 case X86::BI__builtin_ia32_dbpsadbw128:
4128 case X86::BI__builtin_ia32_dbpsadbw256:
4129 case X86::BI__builtin_ia32_dbpsadbw512:
4130 case X86::BI__builtin_ia32_vpshldd128:
4131 case X86::BI__builtin_ia32_vpshldd256:
4132 case X86::BI__builtin_ia32_vpshldd512:
4133 case X86::BI__builtin_ia32_vpshldq128:
4134 case X86::BI__builtin_ia32_vpshldq256:
4135 case X86::BI__builtin_ia32_vpshldq512:
4136 case X86::BI__builtin_ia32_vpshldw128:
4137 case X86::BI__builtin_ia32_vpshldw256:
4138 case X86::BI__builtin_ia32_vpshldw512:
4139 case X86::BI__builtin_ia32_vpshrdd128:
4140 case X86::BI__builtin_ia32_vpshrdd256:
4141 case X86::BI__builtin_ia32_vpshrdd512:
4142 case X86::BI__builtin_ia32_vpshrdq128:
4143 case X86::BI__builtin_ia32_vpshrdq256:
4144 case X86::BI__builtin_ia32_vpshrdq512:
4145 case X86::BI__builtin_ia32_vpshrdw128:
4146 case X86::BI__builtin_ia32_vpshrdw256:
4147 case X86::BI__builtin_ia32_vpshrdw512:
4148 i = 2; l = 0; u = 255;
4150 case X86::BI__builtin_ia32_fixupimmpd512_mask:
4151 case X86::BI__builtin_ia32_fixupimmpd512_maskz:
4152 case X86::BI__builtin_ia32_fixupimmps512_mask:
4153 case X86::BI__builtin_ia32_fixupimmps512_maskz:
4154 case X86::BI__builtin_ia32_fixupimmsd_mask:
4155 case X86::BI__builtin_ia32_fixupimmsd_maskz:
4156 case X86::BI__builtin_ia32_fixupimmss_mask:
4157 case X86::BI__builtin_ia32_fixupimmss_maskz:
4158 case X86::BI__builtin_ia32_fixupimmpd128_mask:
4159 case X86::BI__builtin_ia32_fixupimmpd128_maskz:
4160 case X86::BI__builtin_ia32_fixupimmpd256_mask:
4161 case X86::BI__builtin_ia32_fixupimmpd256_maskz:
4162 case X86::BI__builtin_ia32_fixupimmps128_mask:
4163 case X86::BI__builtin_ia32_fixupimmps128_maskz:
4164 case X86::BI__builtin_ia32_fixupimmps256_mask:
4165 case X86::BI__builtin_ia32_fixupimmps256_maskz:
4166 case X86::BI__builtin_ia32_pternlogd512_mask:
4167 case X86::BI__builtin_ia32_pternlogd512_maskz:
4168 case X86::BI__builtin_ia32_pternlogq512_mask:
4169 case X86::BI__builtin_ia32_pternlogq512_maskz:
4170 case X86::BI__builtin_ia32_pternlogd128_mask:
4171 case X86::BI__builtin_ia32_pternlogd128_maskz:
4172 case X86::BI__builtin_ia32_pternlogd256_mask:
4173 case X86::BI__builtin_ia32_pternlogd256_maskz:
4174 case X86::BI__builtin_ia32_pternlogq128_mask:
4175 case X86::BI__builtin_ia32_pternlogq128_maskz:
4176 case X86::BI__builtin_ia32_pternlogq256_mask:
4177 case X86::BI__builtin_ia32_pternlogq256_maskz:
4178 i = 3; l = 0; u = 255;
4180 case X86::BI__builtin_ia32_gatherpfdpd:
4181 case X86::BI__builtin_ia32_gatherpfdps:
4182 case X86::BI__builtin_ia32_gatherpfqpd:
4183 case X86::BI__builtin_ia32_gatherpfqps:
4184 case X86::BI__builtin_ia32_scatterpfdpd:
4185 case X86::BI__builtin_ia32_scatterpfdps:
4186 case X86::BI__builtin_ia32_scatterpfqpd:
4187 case X86::BI__builtin_ia32_scatterpfqps:
4188 i = 4; l = 2; u = 3;
4190 case X86::BI__builtin_ia32_reducesd_mask:
4191 case X86::BI__builtin_ia32_reducess_mask:
4192 case X86::BI__builtin_ia32_rndscalesd_round_mask:
4193 case X86::BI__builtin_ia32_rndscaless_round_mask:
4194 i = 4; l = 0; u = 255;
4202 return SemaBuiltinConstantArgRange(TheCall, i, l, u,
false);
4209 bool Sema::getFormatStringInfo(
const FormatAttr *Format,
bool IsCXXMember,
4210 FormatStringInfo *FSI) {
4211 FSI->HasVAListArg = Format->getFirstArg() == 0;
4212 FSI->FormatIdx = Format->getFormatIdx() - 1;
4213 FSI->FirstDataArg = FSI->HasVAListArg ? 0 : Format->getFirstArg() - 1;
4219 if(FSI->FormatIdx == 0)
4222 if (FSI->FirstDataArg != 0)
4223 --FSI->FirstDataArg;
4233 if (
auto nullability
4242 if (UT->getDecl()->hasAttr<TransparentUnionAttr>())
4244 dyn_cast<CompoundLiteralExpr>(Expr))
4246 dyn_cast<InitListExpr>(CLE->getInitializer()))
4247 Expr = ILE->getInit(0);
4257 const Expr *ArgExpr,
4261 S.
PDiag(diag::warn_null_arg)
4266 FormatStringInfo FSI;
4267 if ((GetFormatStringType(Format) == FST_NSString) &&
4268 getFormatStringInfo(Format,
false, &FSI)) {
4269 Idx = FSI.FormatIdx;
4283 bool Format =
false;
4296 if (!Format || NumArgs <= Idx)
4298 const Expr *FormatExpr = Args[Idx];
4299 if (
const CStyleCastExpr *CSCE = dyn_cast<CStyleCastExpr>(FormatExpr))
4300 FormatExpr = CSCE->getSubExpr();
4310 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
4328 ArrayRef<const Expr *> Args,
4330 assert((FDecl || Proto) &&
"Need a function declaration or prototype");
4336 llvm::SmallBitVector NonNullArgs;
4342 for (
const auto *Arg : Args)
4349 unsigned IdxAST = Idx.getASTIndex();
4350 if (IdxAST >= Args.size())
4352 if (NonNullArgs.empty())
4353 NonNullArgs.resize(Args.size());
4354 NonNullArgs.set(IdxAST);
4359 if (FDecl && (isa<FunctionDecl>(FDecl) || isa<ObjCMethodDecl>(FDecl))) {
4362 ArrayRef<ParmVarDecl*> parms;
4363 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(FDecl))
4366 parms = cast<ObjCMethodDecl>(FDecl)->parameters();
4368 unsigned ParamIndex = 0;
4369 for (ArrayRef<ParmVarDecl*>::iterator I = parms.begin(), E = parms.end();
4370 I != E; ++I, ++ParamIndex) {
4372 if (PVD->
hasAttr<NonNullAttr>() ||
4374 if (NonNullArgs.empty())
4375 NonNullArgs.resize(Args.size());
4377 NonNullArgs.set(ParamIndex);
4384 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(FDecl)) {
4403 if (NonNullArgs.empty())
4404 NonNullArgs.resize(Args.size());
4406 NonNullArgs.set(Index);
4415 for (
unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
4416 ArgIndex != ArgIndexEnd; ++ArgIndex) {
4417 if (NonNullArgs[ArgIndex])
4426 const Expr *ThisArg, ArrayRef<const Expr *> Args,
4430 if (CurContext->isDependentContext())
4434 llvm::SmallBitVector CheckedVarArgs;
4438 CheckedVarArgs.resize(Args.size());
4440 CheckFormatArguments(I, Args, IsMemberFunction, CallType, Loc, Range,
4447 auto *FD = dyn_cast_or_null<FunctionDecl>(FDecl);
4448 if (CallType != VariadicDoesNotApply &&
4451 : FDecl && isa<FunctionDecl>(FDecl)
4452 ? cast<FunctionDecl>(FDecl)->getNumParams()
4453 : FDecl && isa<ObjCMethodDecl>(FDecl)
4454 ? cast<ObjCMethodDecl>(FDecl)->param_size()
4457 for (
unsigned ArgIdx = NumParams; ArgIdx < Args.size(); ++ArgIdx) {
4459 if (
const Expr *Arg = Args[ArgIdx]) {
4460 if (CheckedVarArgs.empty() || !CheckedVarArgs[ArgIdx])
4461 checkVariadicArgument(Arg, CallType);
4466 if (FDecl || Proto) {
4471 for (
const auto *I : FDecl->
specific_attrs<ArgumentWithTypeTagAttr>())
4472 CheckArgumentWithTypeTag(I, Args, Loc);
4477 diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc);
4483 ArrayRef<const Expr *> Args,
4486 VariadicCallType CallType =
4487 Proto->
isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
4488 checkCall(FDecl, Proto,
nullptr, Args,
true,
4496 bool IsMemberOperatorCall = isa<CXXOperatorCallExpr>(TheCall) &&
4497 isa<CXXMethodDecl>(FDecl);
4498 bool IsMemberFunction = isa<CXXMemberCallExpr>(TheCall) ||
4499 IsMemberOperatorCall;
4500 VariadicCallType CallType = getVariadicCallType(FDecl, Proto,
4505 Expr *ImplicitThis =
nullptr;
4506 if (IsMemberOperatorCall) {
4510 ImplicitThis = Args[0];
4513 }
else if (IsMemberFunction)
4515 cast<CXXMemberCallExpr>(TheCall)->getImplicitObjectArgument();
4517 checkCall(FDecl, Proto, ImplicitThis, llvm::makeArrayRef(Args, NumArgs),
4527 CheckAbsoluteValueFunction(TheCall, FDecl);
4528 CheckMaxUnsignedZero(TheCall, FDecl);
4530 if (getLangOpts().ObjC)
4538 if (CMId == Builtin::BIstrlcpy || CMId == Builtin::BIstrlcat)
4539 CheckStrlcpycatArguments(TheCall, FnInfo);
4540 else if (CMId == Builtin::BIstrncat)
4541 CheckStrncatArguments(TheCall, FnInfo);
4543 CheckMemaccessArguments(TheCall, CMId, FnInfo);
4549 ArrayRef<const Expr *> Args) {
4550 VariadicCallType CallType =
4551 Method->
isVariadic() ? VariadicMethod : VariadicDoesNotApply;
4553 checkCall(Method,
nullptr,
nullptr, Args,
4563 if (
const auto *
V = dyn_cast<VarDecl>(NDecl))
4564 Ty =
V->getType().getNonReferenceType();
4565 else if (
const auto *F = dyn_cast<FieldDecl>(NDecl))
4566 Ty = F->getType().getNonReferenceType();
4574 VariadicCallType CallType;
4576 CallType = VariadicDoesNotApply;
4578 CallType = VariadicBlock;
4580 CallType = VariadicFunction;
4583 checkCall(NDecl, Proto,
nullptr,
4594 VariadicCallType CallType = getVariadicCallType(
nullptr, Proto,
4596 checkCall(
nullptr, Proto,
nullptr,
4605 if (!llvm::isValidAtomicOrderingCABI(Ordering))
4608 auto OrderingCABI = (llvm::AtomicOrderingCABI)Ordering;
4610 case AtomicExpr::AO__c11_atomic_init:
4611 case AtomicExpr::AO__opencl_atomic_init:
4612 llvm_unreachable(
"There is no ordering argument for an init");
4614 case AtomicExpr::AO__c11_atomic_load:
4615 case AtomicExpr::AO__opencl_atomic_load:
4616 case AtomicExpr::AO__atomic_load_n:
4617 case AtomicExpr::AO__atomic_load:
4618 return OrderingCABI != llvm::AtomicOrderingCABI::release &&
4619 OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
4621 case AtomicExpr::AO__c11_atomic_store:
4622 case AtomicExpr::AO__opencl_atomic_store:
4623 case AtomicExpr::AO__atomic_store:
4624 case AtomicExpr::AO__atomic_store_n:
4625 return OrderingCABI != llvm::AtomicOrderingCABI::consume &&
4626 OrderingCABI != llvm::AtomicOrderingCABI::acquire &&
4627 OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
4636 CallExpr *TheCall = cast<CallExpr>(TheCallResult.
get());
4680 const unsigned NumForm = GNUCmpXchg + 1;
4681 const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 3, 4, 5, 6 };
4682 const unsigned NumVals[] = { 1, 0, 1, 1, 1, 1, 2, 2, 3 };
4690 static_assert(
sizeof(NumArgs)/
sizeof(NumArgs[0]) == NumForm
4691 &&
sizeof(NumVals)/
sizeof(NumVals[0]) == NumForm,
4692 "need to update code for modified forms");
4693 static_assert(AtomicExpr::AO__c11_atomic_init == 0 &&
4694 AtomicExpr::AO__c11_atomic_fetch_min + 1 ==
4695 AtomicExpr::AO__atomic_load,
4696 "need to update code for modified C11 atomics");
4697 bool IsOpenCL = Op >= AtomicExpr::AO__opencl_atomic_init &&
4698 Op <= AtomicExpr::AO__opencl_atomic_fetch_max;
4699 bool IsC11 = (Op >= AtomicExpr::AO__c11_atomic_init &&
4700 Op <= AtomicExpr::AO__c11_atomic_fetch_min) ||
4702 bool IsN = Op == AtomicExpr::AO__atomic_load_n ||
4703 Op == AtomicExpr::AO__atomic_store_n ||
4704 Op == AtomicExpr::AO__atomic_exchange_n ||
4705 Op == AtomicExpr::AO__atomic_compare_exchange_n;
4706 bool IsAddSub =
false;
4709 case AtomicExpr::AO__c11_atomic_init:
4710 case AtomicExpr::AO__opencl_atomic_init:
4714 case AtomicExpr::AO__c11_atomic_load:
4715 case AtomicExpr::AO__opencl_atomic_load:
4716 case AtomicExpr::AO__atomic_load_n:
4720 case AtomicExpr::AO__atomic_load:
4724 case AtomicExpr::AO__c11_atomic_store:
4725 case AtomicExpr::AO__opencl_atomic_store:
4726 case AtomicExpr::AO__atomic_store:
4727 case AtomicExpr::AO__atomic_store_n:
4731 case AtomicExpr::AO__c11_atomic_fetch_add:
4732 case AtomicExpr::AO__c11_atomic_fetch_sub:
4733 case AtomicExpr::AO__opencl_atomic_fetch_add:
4734 case AtomicExpr::AO__opencl_atomic_fetch_sub:
4735 case AtomicExpr::AO__atomic_fetch_add:
4736 case AtomicExpr::AO__atomic_fetch_sub:
4737 case AtomicExpr::AO__atomic_add_fetch:
4738 case AtomicExpr::AO__atomic_sub_fetch:
4741 case AtomicExpr::AO__c11_atomic_fetch_and:
4742 case AtomicExpr::AO__c11_atomic_fetch_or:
4743 case AtomicExpr::AO__c11_atomic_fetch_xor:
4744 case AtomicExpr::AO__opencl_atomic_fetch_and:
4745 case AtomicExpr::AO__opencl_atomic_fetch_or:
4746 case AtomicExpr::AO__opencl_atomic_fetch_xor:
4747 case AtomicExpr::AO__atomic_fetch_and:
4748 case AtomicExpr::AO__atomic_fetch_or:
4749 case AtomicExpr::AO__atomic_fetch_xor:
4750 case AtomicExpr::AO__atomic_fetch_nand:
4751 case AtomicExpr::AO__atomic_and_fetch:
4752 case AtomicExpr::AO__atomic_or_fetch:
4753 case AtomicExpr::AO__atomic_xor_fetch:
4754 case AtomicExpr::AO__atomic_nand_fetch:
4755 case AtomicExpr::AO__c11_atomic_fetch_min:
4756 case AtomicExpr::AO__c11_atomic_fetch_max:
4757 case AtomicExpr::AO__opencl_atomic_fetch_min:
4758 case AtomicExpr::AO__opencl_atomic_fetch_max:
4759 case AtomicExpr::AO__atomic_min_fetch:
4760 case AtomicExpr::AO__atomic_max_fetch:
4761 case AtomicExpr::AO__atomic_fetch_min:
4762 case AtomicExpr::AO__atomic_fetch_max:
4766 case AtomicExpr::AO__c11_atomic_exchange:
4767 case AtomicExpr::AO__opencl_atomic_exchange:
4768 case AtomicExpr::AO__atomic_exchange_n:
4772 case AtomicExpr::AO__atomic_exchange:
4776 case AtomicExpr::AO__c11_atomic_compare_exchange_strong:
4777 case AtomicExpr::AO__c11_atomic_compare_exchange_weak:
4778 case AtomicExpr::AO__opencl_atomic_compare_exchange_strong:
4779 case AtomicExpr::AO__opencl_atomic_compare_exchange_weak:
4783 case AtomicExpr::AO__atomic_compare_exchange:
4784 case AtomicExpr::AO__atomic_compare_exchange_n:
4789 unsigned AdjustedNumArgs = NumArgs[Form];
4790 if (IsOpenCL && Op != AtomicExpr::AO__opencl_atomic_init)
4793 if (Args.size() < AdjustedNumArgs) {
4794 Diag(CallRange.
getEnd(), diag::err_typecheck_call_too_few_args)
4795 << 0 << AdjustedNumArgs << static_cast<unsigned>(Args.size())
4798 }
else if (Args.size() > AdjustedNumArgs) {
4799 Diag(Args[AdjustedNumArgs]->getBeginLoc(),
4800 diag::err_typecheck_call_too_many_args)
4801 << 0 << AdjustedNumArgs << static_cast<unsigned>(Args.size())
4807 Expr *Ptr = Args[0];
4808 ExprResult ConvertedPtr = DefaultFunctionArrayLvalueConversion(Ptr);
4812 Ptr = ConvertedPtr.
get();
4815 Diag(ExprRange.
getBegin(), diag::err_atomic_builtin_must_be_pointer)
4825 Diag(ExprRange.
getBegin(), diag::err_atomic_op_needs_atomic)
4831 Diag(ExprRange.
getBegin(), diag::err_atomic_op_needs_non_const_atomic)
4837 }
else if (Form !=
Load && Form != LoadCopy) {
4839 Diag(ExprRange.
getBegin(), diag::err_atomic_op_needs_non_const_pointer)
4846 if (Form == Arithmetic) {
4850 Diag(ExprRange.
getBegin(), diag::err_atomic_op_needs_atomic_int_or_ptr)
4855 Diag(ExprRange.
getBegin(), diag::err_atomic_op_needs_atomic_int)
4861 diag::err_incomplete_type)) {
4867 Diag(ExprRange.
getBegin(), diag::err_atomic_op_needs_atomic_int_or_ptr)
4876 Diag(ExprRange.
getBegin(), diag::err_atomic_op_needs_trivial_copy)
4892 Diag(ExprRange.
getBegin(), diag::err_arc_atomic_ownership)
4904 if (Form == Copy || Form == LoadCopy || Form == GNUXchg ||
4906 ResultType = Context.
VoidTy;
4907 else if (Form == C11CmpXchg || Form == GNUCmpXchg)
4908 ResultType = Context.
BoolTy;
4913 bool IsPassedByAddress =
false;
4914 if (!IsC11 && !IsN) {
4916 IsPassedByAddress =
true;
4921 APIOrderedArgs.push_back(Args[0]);
4925 APIOrderedArgs.push_back(Args[1]);
4931 APIOrderedArgs.push_back(Args[2]);
4932 APIOrderedArgs.push_back(Args[1]);
4935 APIOrderedArgs.push_back(Args[2]);
4936 APIOrderedArgs.push_back(Args[3]);
4937 APIOrderedArgs.push_back(Args[1]);
4940 APIOrderedArgs.push_back(Args[2]);
4941 APIOrderedArgs.push_back(Args[4]);
4942 APIOrderedArgs.push_back(Args[1]);
4943 APIOrderedArgs.push_back(Args[3]);
4946 APIOrderedArgs.push_back(Args[2]);
4947 APIOrderedArgs.push_back(Args[4]);
4948 APIOrderedArgs.push_back(Args[5]);
4949 APIOrderedArgs.push_back(Args[1]);
4950 APIOrderedArgs.push_back(Args[3]);
4954 APIOrderedArgs.append(Args.begin(), Args.end());
4961 for (
unsigned i = 0; i != APIOrderedArgs.size(); ++i) {
4963 if (i < NumVals[Form] + 1) {
4976 assert(Form !=
Load);
4977 if (Form == Init || (Form == Arithmetic && ValType->
isIntegerType()))
4979 else if (Form == Copy || Form == Xchg) {
4980 if (IsPassedByAddress) {
4986 }
else if (Form == Arithmetic)
4989 Expr *ValArg = APIOrderedArgs[i];
4996 AS = PtrTy->getPointeeType().getAddressSpace();
5005 if (IsPassedByAddress)
5025 APIOrderedArgs[i] = Arg.
get();
5030 SubExprs.push_back(Ptr);
5034 SubExprs.push_back(APIOrderedArgs[1]);
5037 SubExprs.push_back(APIOrderedArgs[1]);
5043 SubExprs.push_back(APIOrderedArgs[2]);
5044 SubExprs.push_back(APIOrderedArgs[1]);
5048 SubExprs.push_back(APIOrderedArgs[3]);
5049 SubExprs.push_back(APIOrderedArgs[1]);
5050 SubExprs.push_back(APIOrderedArgs[2]);
5053 SubExprs.push_back(APIOrderedArgs[3]);
5054 SubExprs.push_back(APIOrderedArgs[1]);
5055 SubExprs.push_back(APIOrderedArgs[4]);
5056 SubExprs.push_back(APIOrderedArgs[2]);
5059 SubExprs.push_back(APIOrderedArgs[4]);
5060 SubExprs.push_back(APIOrderedArgs[1]);
5061 SubExprs.push_back(APIOrderedArgs[5]);
5062 SubExprs.push_back(APIOrderedArgs[2]);
5063 SubExprs.push_back(APIOrderedArgs[3]);
5067 if (SubExprs.size() >= 2 && Form != Init) {
5069 if (SubExprs[1]->isIntegerConstantExpr(Result, Context) &&
5071 Diag(SubExprs[1]->getBeginLoc(),
5072 diag::warn_atomic_op_has_invalid_memory_order)
5073 << SubExprs[1]->getSourceRange();
5077 auto *
Scope = Args[Args.size() - 1];
5079 if (
Scope->isIntegerConstantExpr(Result, Context) &&
5080 !ScopeModel->isValid(Result.getZExtValue())) {
5081 Diag(
Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_synch_scope)
5082 <<
Scope->getSourceRange();
5084 SubExprs.push_back(
Scope);
5090 if ((Op == AtomicExpr::AO__c11_atomic_load ||
5091 Op == AtomicExpr::AO__c11_atomic_store ||
5092 Op == AtomicExpr::AO__opencl_atomic_load ||
5093 Op == AtomicExpr::AO__opencl_atomic_store ) &&
5096 << ((Op == AtomicExpr::AO__c11_atomic_load ||
5097 Op == AtomicExpr::AO__opencl_atomic_load)
5113 assert(Fn &&
"builtin call without direct callee!");
5136 Sema::SemaBuiltinAtomicOverloaded(
ExprResult TheCallResult) {
5144 Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args_at_least)
5155 ExprResult FirstArgResult = DefaultFunctionArrayLvalueConversion(FirstArg);
5158 FirstArg = FirstArgResult.
get();
5159 TheCall->
setArg(0, FirstArg);
5171 Diag(DRE->
getBeginLoc(), diag::err_atomic_builtin_must_be_pointer_intptr)
5206 #define BUILTIN_ROW(x) \ 5207 { Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \ 5208 Builtin::BI##x##_8, Builtin::BI##x##_16 } 5210 static const unsigned BuiltinIndices[][5] = {
5236 case 1: SizeIndex = 0;
break;
5237 case 2: SizeIndex = 1;
break;
5238 case 4: SizeIndex = 2;
break;
5239 case 8: SizeIndex = 3;
break;
5240 case 16: SizeIndex = 4;
break;
5251 unsigned BuiltinID = FDecl->getBuiltinID();
5252 unsigned BuiltinIndex, NumFixed = 1;
5253 bool WarnAboutSemanticsChange =
false;
5254 switch (BuiltinID) {
5255 default: llvm_unreachable(
"Unknown overloaded atomic builtin!");
5256 case Builtin::BI__sync_fetch_and_add:
5257 case Builtin::BI__sync_fetch_and_add_1:
5258 case Builtin::BI__sync_fetch_and_add_2:
5259 case Builtin::BI__sync_fetch_and_add_4:
5260 case Builtin::BI__sync_fetch_and_add_8:
5261 case Builtin::BI__sync_fetch_and_add_16:
5265 case Builtin::BI__sync_fetch_and_sub:
5266 case Builtin::BI__sync_fetch_and_sub_1:
5267 case Builtin::BI__sync_fetch_and_sub_2:
5268 case Builtin::BI__sync_fetch_and_sub_4:
5269 case Builtin::BI__sync_fetch_and_sub_8:
5270 case Builtin::BI__sync_fetch_and_sub_16:
5274 case Builtin::BI__sync_fetch_and_or:
5275 case Builtin::BI__sync_fetch_and_or_1:
5276 case Builtin::BI__sync_fetch_and_or_2:
5277 case Builtin::BI__sync_fetch_and_or_4:
5278 case Builtin::BI__sync_fetch_and_or_8:
5279 case Builtin::BI__sync_fetch_and_or_16:
5283 case Builtin::BI__sync_fetch_and_and:
5284 case Builtin::BI__sync_fetch_and_and_1:
5285 case Builtin::BI__sync_fetch_and_and_2:
5286 case Builtin::BI__sync_fetch_and_and_4:
5287 case Builtin::BI__sync_fetch_and_and_8:
5288 case Builtin::BI__sync_fetch_and_and_16:
5292 case Builtin::BI__sync_fetch_and_xor:
5293 case Builtin::BI__sync_fetch_and_xor_1:
5294 case Builtin::BI__sync_fetch_and_xor_2:
5295 case Builtin::BI__sync_fetch_and_xor_4:
5296 case Builtin::BI__sync_fetch_and_xor_8:
5297 case Builtin::BI__sync_fetch_and_xor_16:
5301 case Builtin::BI__sync_fetch_and_nand:
5302 case Builtin::BI__sync_fetch_and_nand_1:
5303 case Builtin::BI__sync_fetch_and_nand_2:
5304 case Builtin::BI__sync_fetch_and_nand_4:
5305 case Builtin::BI__sync_fetch_and_nand_8:
5306 case Builtin::BI__sync_fetch_and_nand_16:
5308 WarnAboutSemanticsChange =
true;
5311 case Builtin::BI__sync_add_and_fetch:
5312 case Builtin::BI__sync_add_and_fetch_1:
5313 case Builtin::BI__sync_add_and_fetch_2:
5314 case Builtin::BI__sync_add_and_fetch_4:
5315 case Builtin::BI__sync_add_and_fetch_8:
5316 case Builtin::BI__sync_add_and_fetch_16:
5320 case Builtin::BI__sync_sub_and_fetch:
5321 case Builtin::BI__sync_sub_and_fetch_1:
5322 case Builtin::BI__sync_sub_and_fetch_2:
5323 case Builtin::BI__sync_sub_and_fetch_4:
5324 case Builtin::BI__sync_sub_and_fetch_8:
5325 case Builtin::BI__sync_sub_and_fetch_16:
5329 case Builtin::BI__sync_and_and_fetch:
5330 case Builtin::BI__sync_and_and_fetch_1:
5331 case Builtin::BI__sync_and_and_fetch_2:
5332 case Builtin::BI__sync_and_and_fetch_4:
5333 case Builtin::BI__sync_and_and_fetch_8:
5334 case Builtin::BI__sync_and_and_fetch_16:
5338 case Builtin::BI__sync_or_and_fetch:
5339 case Builtin::BI__sync_or_and_fetch_1:
5340 case Builtin::BI__sync_or_and_fetch_2:
5341 case Builtin::BI__sync_or_and_fetch_4:
5342 case Builtin::BI__sync_or_and_fetch_8:
5343 case Builtin::BI__sync_or_and_fetch_16:
5347 case Builtin::BI__sync_xor_and_fetch:
5348 case Builtin::BI__sync_xor_and_fetch_1:
5349 case Builtin::BI__sync_xor_and_fetch_2:
5350 case Builtin::BI__sync_xor_and_fetch_4:
5351 case Builtin::BI__sync_xor_and_fetch_8:
5352 case Builtin::BI__sync_xor_and_fetch_16:
5356 case Builtin::BI__sync_nand_and_fetch:
5357 case Builtin::BI__sync_nand_and_fetch_1:
5358 case Builtin::BI__sync_nand_and_fetch_2:
5359 case Builtin::BI__sync_nand_and_fetch_4:
5360 case Builtin::BI__sync_nand_and_fetch_8:
5361 case Builtin::BI__sync_nand_and_fetch_16:
5363 WarnAboutSemanticsChange =
true;
5366 case Builtin::BI__sync_val_compare_and_swap:
5367 case Builtin::BI__sync_val_compare_and_swap_1:
5368 case Builtin::BI__sync_val_compare_and_swap_2:
5369 case Builtin::BI__sync_val_compare_and_swap_4:
5370 case Builtin::BI__sync_val_compare_and_swap_8:
5371 case Builtin::BI__sync_val_compare_and_swap_16:
5376 case Builtin::BI__sync_bool_compare_and_swap:
5377 case Builtin::BI__sync_bool_compare_and_swap_1:
5378 case Builtin::BI__sync_bool_compare_and_swap_2:
5379 case Builtin::BI__sync_bool_compare_and_swap_4:
5380 case Builtin::BI__sync_bool_compare_and_swap_8:
5381 case Builtin::BI__sync_bool_compare_and_swap_16:
5384 ResultType = Context.
BoolTy;
5387 case Builtin::BI__sync_lock_test_and_set:
5388 case Builtin::BI__sync_lock_test_and_set_1:
5389 case Builtin::BI__sync_lock_test_and_set_2:
5390 case Builtin::BI__sync_lock_test_and_set_4:
5391 case Builtin::BI__sync_lock_test_and_set_8:
5392 case Builtin::BI__sync_lock_test_and_set_16:
5396 case Builtin::BI__sync_lock_release:
5397 case Builtin::BI__sync_lock_release_1:
5398 case Builtin::BI__sync_lock_release_2:
5399 case Builtin::BI__sync_lock_release_4:
5400 case Builtin::BI__sync_lock_release_8:
5401 case Builtin::BI__sync_lock_release_16:
5404 ResultType = Context.
VoidTy;
5407 case Builtin::BI__sync_swap:
5408 case Builtin::BI__sync_swap_1:
5409 case Builtin::BI__sync_swap_2:
5410 case Builtin::BI__sync_swap_4:
5411 case Builtin::BI__sync_swap_8:
5412 case Builtin::BI__sync_swap_16:
5420 Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args_at_least)
5421 << 0 << 1 + NumFixed << TheCall->
getNumArgs()
5426 Diag(TheCall->
getEndLoc(), diag::warn_atomic_implicit_seq_cst)
5429 if (WarnAboutSemanticsChange) {
5430 Diag(TheCall->
getEndLoc(), diag::warn_sync_fetch_and_nand_semantics_change)
5436 unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
5439 if (NewBuiltinID == BuiltinID)
5440 NewBuiltinDecl = FDecl;
5445 LookupName(Res, TUScope,
true);
5446 assert(Res.getFoundDecl());
5447 NewBuiltinDecl = dyn_cast<
FunctionDecl>(Res.getFoundDecl());
5448 if (!NewBuiltinDecl)
5455 for (
unsigned i = 0; i != NumFixed; ++i) {
5485 ExprResult PromotedCall = ImpCastExprToType(NewDRE, CalleePtrTy,
5486 CK_BuiltinFnToFnPtr);
5494 return TheCallResult;
5509 assert((BuiltinID == Builtin::BI__builtin_nontemporal_store ||
5510 BuiltinID == Builtin::BI__builtin_nontemporal_load) &&
5511 "Unexpected nontemporal load/store builtin!");
5512 bool isStore = BuiltinID == Builtin::BI__builtin_nontemporal_store;
5513 unsigned numArgs = isStore ? 2 : 1;
5523 Expr *PointerArg = TheCall->
getArg(numArgs - 1);
5525 DefaultFunctionArrayLvalueConversion(PointerArg);
5529 PointerArg = PointerArgResult.
get();
5530 TheCall->
setArg(numArgs - 1, PointerArg);
5534 Diag(DRE->
getBeginLoc(), diag::err_nontemporal_builtin_must_be_pointer)
5547 diag::err_nontemporal_builtin_must_be_pointer_intfltptr_or_vector)
5554 return TheCallResult;
5559 Context, ValType,
false);
5560 ValArg = PerformCopyInitialization(Entity,
SourceLocation(), ValArg);
5566 return TheCallResult;
5573 bool Sema::CheckObjCString(
Expr *Arg) {
5577 if (!Literal || !Literal->
isAscii()) {
5578 Diag(Arg->
getBeginLoc(), diag::err_cfstring_literal_not_string_constant)
5584 StringRef String = Literal->
getString();
5585 unsigned NumBytes = String.size();
5587 const llvm::UTF8 *FromPtr = (
const llvm::UTF8 *)String.data();
5588 llvm::UTF16 *ToPtr = &ToBuf[0];
5590 llvm::ConversionResult Result =
5591 llvm::ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes, &ToPtr,
5592 ToPtr + NumBytes, llvm::strictConversion);
5594 if (Result != llvm::conversionOK)
5607 if (
auto *ObjcLiteral = dyn_cast<ObjCStringLiteral>(Arg)) {
5612 if (!Literal || (!Literal->isAscii() && !Literal->isUTF8())) {
5622 Result = PerformCopyInitialization(Entity,
SourceLocation(), Result);
5630 bool IsX64 = TT.getArch() == llvm::Triple::x86_64;
5631 bool IsAArch64 = (TT.getArch() == llvm::Triple::aarch64 ||
5632 TT.getArch() == llvm::Triple::aarch64_32);
5633 bool IsWindows = TT.isOSWindows();
5634 bool IsMSVAStart = BuiltinID == Builtin::BI__builtin_ms_va_start;
5635 if (IsX64 || IsAArch64) {
5643 diag::err_ms_va_start_used_in_sysv_function);
5652 diag::err_va_start_used_in_wrong_abi_function)
5667 bool IsVariadic =
false;
5668 ArrayRef<ParmVarDecl *> Params;
5670 if (
auto *Block = dyn_cast<BlockDecl>(Caller)) {
5671 IsVariadic = Block->isVariadic();
5672 Params = Block->parameters();
5673 }
else if (
auto *FD = dyn_cast<FunctionDecl>(Caller)) {
5676 }
else if (
auto *MD = dyn_cast<ObjCMethodDecl>(Caller)) {
5677 IsVariadic = MD->isVariadic();
5679 Params = MD->parameters();
5680 }
else if (isa<CapturedDecl>(Caller)) {
5696 *LastParam = Params.empty() ? nullptr : Params.back();
5704 bool Sema::SemaBuiltinVAStart(
unsigned BuiltinID,
CallExpr *TheCall) {
5712 diag::err_typecheck_call_too_many_args)
5716 (*(TheCall->
arg_end() - 1))->getEndLoc());
5722 diag::err_typecheck_call_too_few_args_at_least)
5737 bool SecondArgIsLastNamedArgument =
false;
5744 bool IsCRegister =
false;
5746 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Arg)) {
5747 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {
5748 SecondArgIsLastNamedArgument = PV == LastParam;
5750 Type = PV->getType();
5751 ParamLoc = PV->getLocation();
5753 PV->getStorageClass() ==
SC_Register && !getLangOpts().CPlusPlus;
5757 if (!SecondArgIsLastNamedArgument)
5759 diag::warn_second_arg_of_va_start_not_last_named_param);
5772 unsigned Reason = 0;
5774 else if (IsCRegister) Reason = 2;
5775 Diag(Arg->
getBeginLoc(), diag::warn_va_start_type_is_undefined) << Reason;
5776 Diag(ParamLoc, diag::note_parameter_type) << Type;
5783 bool Sema::SemaBuiltinVAStartARMMicrosoft(
CallExpr *Call) {
5791 diag::err_typecheck_call_too_few_args_at_least)
5815 << Arg1->
getType() << ConstCharPtrTy << 1
5818 << 2 << Arg1->
getType() << ConstCharPtrTy;
5823 << Arg2->
getType() << SizeTy << 1
5826 << 3 << Arg2->
getType() << SizeTy;
5833 bool Sema::SemaBuiltinUnorderedCompare(
CallExpr *TheCall) {
5835 return Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
5839 diag::err_typecheck_call_too_many_args)
5842 (*(TheCall->
arg_end() - 1))->getEndLoc());
5849 QualType Res = UsualArithmeticConversions(
5850 OrigArg0, OrigArg1, TheCall->
getExprLoc(), ACK_Comparison);
5851 if (OrigArg0.isInvalid() || OrigArg1.
isInvalid())
5857 TheCall->
setArg(0, OrigArg0.get());
5860 if (OrigArg0.get()->isTypeDependent() || OrigArg1.
get()->isTypeDependent())
5866 return Diag(OrigArg0.get()->getBeginLoc(),
5867 diag::err_typecheck_call_invalid_ordered_compare)
5868 << OrigArg0.get()->getType() << OrigArg1.
get()->getType()
5870 OrigArg1.
get()->getEndLoc());
5879 bool Sema::SemaBuiltinFPClassification(
CallExpr *TheCall,
unsigned NumArgs) {
5881 return Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
5885 diag::err_typecheck_call_too_many_args)
5888 (*(TheCall->
arg_end() - 1))->getEndLoc());
5892 for (
unsigned i = 0; i < NumArgs - 1; ++i) {
5898 ExprResult Res = PerformImplicitConversion(Arg, Context.
IntTy, AA_Passing);
5914 OrigArg = UsualUnaryConversions(OrigArg).get();
5916 OrigArg = DefaultFunctionArrayLvalueConversion(OrigArg).get();
5917 TheCall->
setArg(NumArgs - 1, OrigArg);
5922 diag::err_typecheck_call_invalid_unary_fp)
5935 bool Sema::SemaBuiltinVSX(
CallExpr *TheCall) {
5936 unsigned ExpectedNumArgs = 3;
5939 diag::err_typecheck_call_too_few_args_at_least)
5940 << 0 << ExpectedNumArgs << TheCall->
getNumArgs()
5945 diag::err_typecheck_call_too_many_args_at_most)
5946 << 0 << ExpectedNumArgs << TheCall->
getNumArgs()
5953 diag::err_vsx_builtin_nonconstant_argument)
5963 if ((!Arg1Ty->isVectorType() && !Arg1Ty->isDependentType()) ||
5965 return Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
5973 return Diag(BuiltinLoc, diag::err_vec_builtin_incompatible_vector)
5992 diag::err_typecheck_call_too_few_args_at_least)
6000 unsigned numElements = 0;
6015 unsigned numResElements = TheCall->
getNumArgs() - 2;
6024 diag::err_vec_builtin_incompatible_vector)
6030 diag::err_vec_builtin_incompatible_vector)
6034 }
else if (numElements != numResElements) {
6041 for (
unsigned i = 2; i < TheCall->
getNumArgs(); i++) {
6049 diag::err_shufflevector_nonconstant_argument)
6053 if (Result.isSigned() && Result.isAllOnesValue())
6056 if (Result.getActiveBits() > 64 || Result.getZExtValue() >= numElements*2)
6058 diag::err_shufflevector_argument_too_large)
6064 for (
unsigned i = 0, e = TheCall->
getNumArgs(); i != e; i++) {
6065 exprs.push_back(TheCall->
getArg(i));
6066 TheCall->
setArg(i,
nullptr);
6085 diag::err_convertvector_non_vector)
6089 diag::err_convertvector_non_vector_type));
6094 if (SrcElts != DstElts)
6096 diag::err_convertvector_incompatible_vector)
6100 return new (Context)
6107 bool Sema::SemaBuiltinPrefetch(
CallExpr *TheCall) {
6112 diag::err_typecheck_call_too_many_args_at_most)
6117 for (
unsigned i = 1; i != NumArgs; ++i)
6118 if (SemaBuiltinConstantArgRange(TheCall, i, 0, i == 1 ? 1 : 3))
6127 bool Sema::SemaBuiltinAssume(
CallExpr *TheCall) {
6142 bool Sema::SemaBuiltinAllocaWithAlign(
CallExpr *TheCall) {
6148 if (
const auto *UE =
6157 if (!Result.isPowerOf2())
6158 return Diag(TheCall->
getBeginLoc(), diag::err_alignment_not_power_of_two)
6175 bool Sema::SemaBuiltinAssumeAligned(
CallExpr *TheCall) {
6180 diag::err_typecheck_call_too_many_args_at_most)
6189 if (SemaBuiltinConstantArg(TheCall, 1, Result))
6192 if (!Result.isPowerOf2())
6193 return Diag(TheCall->
getBeginLoc(), diag::err_alignment_not_power_of_two)
6197 unsigned MaximumAlignment = 536870912;
6198 if (Result > MaximumAlignment)
6208 if (Arg.isInvalid())
return true;
6209 TheCall->
setArg(2, Arg.get());
6215 bool Sema::SemaBuiltinOSLogFormat(
CallExpr *TheCall) {
6216 unsigned BuiltinID =
6217 cast<FunctionDecl>(TheCall->
getCalleeDecl())->getBuiltinID();
6218 bool IsSizeCall = BuiltinID == Builtin::BI__builtin_os_log_format_buffer_size;
6221 unsigned NumRequiredArgs = IsSizeCall ? 1 : 2;
6222 if (NumArgs < NumRequiredArgs) {
6223 return Diag(TheCall->
getEndLoc(), diag::err_typecheck_call_too_few_args)
6224 << 0 << NumRequiredArgs << NumArgs
6227 if (NumArgs >= NumRequiredArgs + 0x100) {
6229 diag::err_typecheck_call_too_many_args_at_most)
6230 << 0 << (NumRequiredArgs + 0xff) << NumArgs
6241 if (Arg.isInvalid())
6243 TheCall->
setArg(i, Arg.get());
6248 unsigned FormatIdx = i;
6258 unsigned FirstDataArg = i;
6259 while (i < NumArgs) {
6260 ExprResult Arg = DefaultVariadicArgumentPromotion(
6261 TheCall->
getArg(i), VariadicFunction,
nullptr);
6266 return Diag(Arg.
get()->getEndLoc(), diag::err_os_log_argument_too_big)
6277 llvm::SmallBitVector CheckedVarArgs(NumArgs,
false);
6279 bool Success = CheckFormatArguments(
6280 Args,
false, FormatIdx, FirstDataArg, FST_OSLog,
6297 bool Sema::SemaBuiltinConstantArg(
CallExpr *TheCall,
int ArgNum,
6306 return Diag(TheCall->
getBeginLoc(), diag::err_constant_integer_arg_type)
6314 bool Sema::SemaBuiltinConstantArgRange(
CallExpr *TheCall,
int ArgNum,
6315 int Low,
int High,
bool RangeIsError) {
6316 if (isConstantEvaluated())
6326 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
6329 if (Result.getSExtValue() < Low || Result.getSExtValue() > High) {
6336 DiagRuntimeBehavior(TheCall->
getBeginLoc(), TheCall,
6337 PDiag(diag::warn_argument_invalid_range)
6338 << Result.toString(10) << Low << High
6347 bool Sema::SemaBuiltinConstantArgMultiple(
CallExpr *TheCall,
int ArgNum,
6357 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
6360 if (Result.getSExtValue() % Num != 0)
6369 bool Sema::SemaBuiltinConstantArgPower2(
CallExpr *TheCall,
int ArgNum) {
6378 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
6383 if (Result.isStrictlyPositive() && (Result & (Result - 1)) == 0)
6386 return Diag(TheCall->
getBeginLoc(), diag::err_argument_not_power_of_2)
6391 if (Value.isNegative())
6402 if ((Value & 0xFF) != 0)
6415 bool Sema::SemaBuiltinConstantArgShiftedByte(
CallExpr *TheCall,
int ArgNum) {
6424 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
6430 return Diag(TheCall->
getBeginLoc(), diag::err_argument_not_shifted_byte)
6439 bool Sema::SemaBuiltinConstantArgShiftedByteOrXXFF(
CallExpr *TheCall,
6449 if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
6454 (Result > 0 && Result < 0x10000 && (Result & 0xFF) == 0xFF))
6458 diag::err_argument_not_shifted_byte_or_xxff)
6463 bool Sema::SemaBuiltinARMMemoryTaggingCall(
unsigned BuiltinID,
CallExpr *TheCall) {
6464 if (BuiltinID == AArch64::BI__builtin_arm_irg) {
6470 ExprResult FirstArg = DefaultFunctionArrayLvalueConversion(Arg0);
6473 QualType FirstArgType = FirstArg.
get()->getType();
6475 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
6479 ExprResult SecArg = DefaultLvalueConversion(Arg1);
6484 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_integer)
6488 TheCall->
setType(FirstArgType);
6492 if (BuiltinID == AArch64::BI__builtin_arm_addg) {
6497 ExprResult FirstArg = DefaultFunctionArrayLvalueConversion(Arg0);
6500 QualType FirstArgType = FirstArg.
get()->getType();
6502 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
6507 TheCall->
setType(FirstArgType);
6510 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
6513 if (BuiltinID == AArch64::BI__builtin_arm_gmi) {
6519 ExprResult FirstArg = DefaultFunctionArrayLvalueConversion(Arg0);
6522 QualType FirstArgType = FirstArg.
get()->getType();
6524 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
6529 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_integer)
6535 if (BuiltinID == AArch64::BI__builtin_arm_ldg ||
6536 BuiltinID == AArch64::BI__builtin_arm_stg) {
6540 ExprResult FirstArg = DefaultFunctionArrayLvalueConversion(Arg0);
6544 QualType FirstArgType = FirstArg.
get()->getType();
6546 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
6551 if (BuiltinID == AArch64::BI__builtin_arm_ldg)
6552 TheCall->
setType(FirstArgType);
6556 if (BuiltinID == AArch64::BI__builtin_arm_subp) {
6560 ExprResult ArgExprA = DefaultFunctionArrayLvalueConversion(ArgA);
6561 ExprResult ArgExprB = DefaultFunctionArrayLvalueConversion(ArgB);
6569 auto isNull = [&] (
Expr *E) ->
bool {
6575 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_null_or_pointer)
6579 return Diag(TheCall->
getBeginLoc(), diag::err_memtag_arg_null_or_pointer)
6590 return Diag(TheCall->
getBeginLoc(), diag::err_typecheck_sub_ptr_compatible)
6602 ArgExprA = ImpCastExprToType(ArgExprA.
get(), ArgTypeB, CK_NullToPointer);
6605 ArgExprB = ImpCastExprToType(ArgExprB.
get(), ArgTypeA, CK_NullToPointer);
6612 assert(
false &&
"Unhandled ARM MTE intrinsic");
6618 bool Sema::SemaBuiltinARMSpecialReg(
unsigned BuiltinID,
CallExpr *TheCall,
6619 int ArgNum,
unsigned ExpectedFieldNum,
6621 bool IsARMBuiltin = BuiltinID == ARM::BI__builtin_arm_rsr64 ||
6622 BuiltinID == ARM::BI__builtin_arm_wsr64 ||
6623 BuiltinID == ARM::BI__builtin_arm_rsr ||
6624 BuiltinID == ARM::BI__builtin_arm_rsrp ||
6625 BuiltinID == ARM::BI__builtin_arm_wsr ||
6626 BuiltinID == ARM::BI__builtin_arm_wsrp;
6627 bool IsAArch64Builtin = BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
6628 BuiltinID == AArch64::BI__builtin_arm_wsr64 ||
6629 BuiltinID == AArch64::BI__builtin_arm_rsr ||
6630 BuiltinID == AArch64::BI__builtin_arm_rsrp ||
6631 BuiltinID == AArch64::BI__builtin_arm_wsr ||
6632 BuiltinID == AArch64::BI__builtin_arm_wsrp;
6633 assert((IsARMBuiltin || IsAArch64Builtin) &&
"Unexpected ARM builtin.");
6642 return Diag(TheCall->
getBeginLoc(), diag::err_expr_not_string_literal)
6648 Reg.split(Fields,
":");
6650 if (Fields.size() != ExpectedFieldNum && !(AllowName && Fields.size() == 1))
6658 if (Fields.size() > 1) {
6659 bool FiveFields = Fields.size() == 5;
6661 bool ValidString =
true;
6663 ValidString &= Fields[0].startswith_lower(
"cp") ||
6664 Fields[0].startswith_lower(
"p");
6667 Fields[0].drop_front(Fields[0].startswith_lower(
"cp") ? 2 : 1);
6669 ValidString &= Fields[2].startswith_lower(
"c");
6671 Fields[2] = Fields[2].drop_front(1);
6674 ValidString &= Fields[3].startswith_lower(
"c");
6676 Fields[3] = Fields[3].drop_front(1);
6682 Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 15, 15, 7});
6684 Ranges.append({15, 7, 15});
6686 for (
unsigned i=0; i<Fields.size(); ++i) {
6688 ValidString &= !Fields[i].getAsInteger(10, IntField);
6689 ValidString &= (IntField >= 0 && IntField <= Ranges[i]);
6695 }
else if (IsAArch64Builtin && Fields.size() == 1) {
6705 std::string RegLower = Reg.lower();
6706 if (RegLower !=
"spsel" && RegLower !=
"daifset" && RegLower !=
"daifclr" &&
6707 RegLower !=
"pan" && RegLower !=
"uao")
6710 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15);
6719 bool Sema::SemaBuiltinLongjmp(
CallExpr *TheCall) {
6721 return Diag(TheCall->
getBeginLoc(), diag::err_builtin_longjmp_unsupported)
6728 if (SemaBuiltinConstantArg(TheCall, 1, Result))
6732 return Diag(TheCall->
getBeginLoc(), diag::err_builtin_longjmp_invalid_val)
6740 bool Sema::SemaBuiltinSetjmp(
CallExpr *TheCall) {
6742 return Diag(TheCall->
getBeginLoc(), diag::err_builtin_setjmp_unsupported)
6749 class UncoveredArgHandler {
6750 enum { Unknown = -1, AllCovered = -2 };
6752 signed FirstUncoveredArg = Unknown;
6756 UncoveredArgHandler() =
default;
6758 bool hasUncoveredArg()
const {
6759 return (FirstUncoveredArg >= 0);
6762 unsigned getUncoveredArg()
const {
6763 assert(hasUncoveredArg() &&
"no uncovered argument");
6764 return FirstUncoveredArg;
6767 void setAllCovered() {
6770 DiagnosticExprs.clear();
6771 FirstUncoveredArg = AllCovered;
6774 void Update(
signed NewFirstUncoveredArg,
const Expr *StrExpr) {
6775 assert(NewFirstUncoveredArg >= 0 &&
"Outside range");
6778 if (FirstUncoveredArg == AllCovered)
6783 if (NewFirstUncoveredArg == FirstUncoveredArg)
6784 DiagnosticExprs.push_back(StrExpr);
6785 else if (NewFirstUncoveredArg > FirstUncoveredArg) {
6786 DiagnosticExprs.clear();
6787 DiagnosticExprs.push_back(StrExpr);
6788 FirstUncoveredArg = NewFirstUncoveredArg;
6792 void Diagnose(
Sema &S,
bool IsFunctionCall,
const Expr *ArgExpr);
6797 SLCT_UncheckedLiteral,
6805 bool AddendIsRight) {
6806 unsigned BitWidth = Offset.getBitWidth();
6807 unsigned AddendBitWidth = Addend.getBitWidth();
6809 if (Addend.isUnsigned()) {
6810 Addend = Addend.zext(++AddendBitWidth);
6811 Addend.setIsSigned(
true);
6814 if (AddendBitWidth > BitWidth) {
6815 Offset = Offset.sext(AddendBitWidth);
6816 BitWidth = AddendBitWidth;
6817 }
else if (BitWidth > AddendBitWidth) {
6818 Addend = Addend.sext(BitWidth);
6823 if (BinOpKind == BO_Add)
6824 ResOffset = Offset.sadd_ov(Addend, Ov);
6826 assert(AddendIsRight && BinOpKind == BO_Sub &&
6827 "operator must be add or sub with addend on the right");
6828 ResOffset = Offset.ssub_ov(Addend, Ov);
6835 "index (intermediate) result too big");
6836 Offset = Offset.sext(2 * BitWidth);
6837 sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
6849 class FormatStringLiteral {
6854 FormatStringLiteral(
const StringLiteral *fexpr, int64_t Offset = 0)
6855 : FExpr(fexpr),
Offset(Offset) {}
6857 StringRef getString()
const {
6858 return FExpr->
getString().drop_front(Offset);
6861 unsigned getByteLength()
const {
6872 bool isAscii()
const {
return FExpr->
isAscii(); }
6873 bool isWide()
const {
return FExpr->
isWide(); }
6874 bool isUTF8()
const {
return FExpr->
isUTF8(); }
6875 bool isUTF16()
const {
return FExpr->
isUTF16(); }
6876 bool isUTF32()
const {
return FExpr->
isUTF32(); }
6877 bool isPascal()
const {
return FExpr->
isPascal(); }
6882 unsigned *StartTokenByteOffset =
nullptr)
const {
6884 StartToken, StartTokenByteOffset);
6897 const Expr *OrigFormatExpr,
6898 ArrayRef<const Expr *> Args,
6899 bool HasVAListArg,
unsigned format_idx,
6900 unsigned firstDataArg,
6902 bool inFunctionCall,
6904 llvm::SmallBitVector &CheckedVarArgs,
6905 UncoveredArgHandler &UncoveredArg,
6906 bool IgnoreStringsWithoutSpecifiers);
6914 bool HasVAListArg,
unsigned format_idx,
6917 llvm::SmallBitVector &CheckedVarArgs,
6918 UncoveredArgHandler &UncoveredArg,
6920 bool IgnoreStringsWithoutSpecifiers =
false) {
6922 return SLCT_NotALiteral;
6924 assert(Offset.isSigned() &&
"invalid offset");
6927 return SLCT_NotALiteral;
6936 return SLCT_UncheckedLiteral;
6939 case Stmt::BinaryConditionalOperatorClass:
6940 case Stmt::ConditionalOperatorClass: {
6944 cast<AbstractConditionalOperator>(E);
6949 bool CheckLeft =
true, CheckRight =
true;
6966 Left = SLCT_UncheckedLiteral;
6969 HasVAListArg, format_idx, firstDataArg,
6970 Type, CallType, InFunctionCall,
6971 CheckedVarArgs, UncoveredArg,
Offset,
6972 IgnoreStringsWithoutSpecifiers);
6973 if (Left == SLCT_NotALiteral || !CheckRight) {
6979 S, C->
getFalseExpr(), Args, HasVAListArg, format_idx, firstDataArg,
6980 Type, CallType, InFunctionCall, CheckedVarArgs, UncoveredArg,
Offset,
6981 IgnoreStringsWithoutSpecifiers);
6983 return (CheckLeft && Left < Right) ? Left : Right;
6986 case Stmt::ImplicitCastExprClass:
6987 E = cast<ImplicitCastExpr>(E)->getSubExpr();
6990 case Stmt::OpaqueValueExprClass:
6991 if (
const Expr *src = cast<OpaqueValueExpr>(E)->getSourceExpr()) {
6995 return SLCT_NotALiteral;
6997 case Stmt::PredefinedExprClass:
7001 return SLCT_UncheckedLiteral;
7003 case Stmt::DeclRefExprClass: {
7009 bool isConstant =
false;
7013 isConstant = AT->getElementType().isConstant(S.
Context);
7016 PT->getPointeeType().isConstant(S.
Context);
7024 if (
const Expr *Init = VD->getAnyInitializer()) {
7026 if (
const InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
7027 if (InitList->isStringLiteralInit())
7028 Init = InitList->getInit(0)->IgnoreParenImpCasts();
7031 HasVAListArg, format_idx,
7032 firstDataArg, Type, CallType,
7033 false, CheckedVarArgs,
7034 UncoveredArg, Offset);
7053 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(VD)) {
7054 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(PV->getDeclContext())) {
7055 int PVIndex = PV->getFunctionScopeIndex() + 1;
7056 for (
const auto *PVFormat : ND->specific_attrs<FormatAttr>()) {
7059 if (MD->isInstance())
7063 if (PVIndex == PVFormat->getFormatIdx() &&
7065 return SLCT_UncheckedLiteral;
7072 return SLCT_NotALiteral;
7075 case Stmt::CallExprClass:
7076 case Stmt::CXXMemberCallExprClass: {
7077 const CallExpr *CE = cast<CallExpr>(E);
7079 bool IsFirst =
true;
7081 for (
const auto *FA : ND->specific_attrs<FormatArgAttr>()) {
7082 const Expr *Arg = CE->
getArg(FA->getFormatIdx().getASTIndex());
7084 S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
7085 CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset,
7086 IgnoreStringsWithoutSpecifiers);
7088 CommonResult = Result;
7093 return CommonResult;
7095 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
7097 if (BuiltinID == Builtin::BI__builtin___CFStringMakeConstantString ||
7098 BuiltinID == Builtin::BI__builtin___NSStringMakeConstantString) {
7101 HasVAListArg, format_idx,
7102 firstDataArg, Type, CallType,
7103 InFunctionCall, CheckedVarArgs,
7104 UncoveredArg, Offset,
7105 IgnoreStringsWithoutSpecifiers);
7110 return SLCT_NotALiteral;
7112 case Stmt::ObjCMessageExprClass: {
7113 const auto *ME = cast<ObjCMessageExpr>(E);
7114 if (
const auto *MD = ME->getMethodDecl()) {
7115 if (
const auto *FA = MD->getAttr<FormatArgAttr>()) {
7124 if (MD->isInstanceMethod() && (IFace = MD->getClassInterface()) &&
7126 MD->getSelector().isKeywordSelector(
7127 {
"localizedStringForKey",
"value",
"table"})) {
7128 IgnoreStringsWithoutSpecifiers =
true;
7131 const Expr *Arg = ME->getArg(FA->getFormatIdx().getASTIndex());
7133 S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
7134 CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset,
7135 IgnoreStringsWithoutSpecifiers);
7139 return SLCT_NotALiteral;
7141 case Stmt::ObjCStringLiteralClass:
7142 case Stmt::StringLiteralClass: {
7148 StrE = cast<StringLiteral>(E);
7151 if (Offset.isNegative() || Offset > StrE->
getLength()) {
7154 return SLCT_NotALiteral;
7156 FormatStringLiteral FStr(StrE, Offset.sextOrTrunc(64).getSExtValue());
7158 firstDataArg, Type, InFunctionCall, CallType,
7159 CheckedVarArgs, UncoveredArg,
7160 IgnoreStringsWithoutSpecifiers);
7161 return SLCT_CheckedLiteral;
7164 return SLCT_NotALiteral;
7166 case Stmt::BinaryOperatorClass: {
7178 if (LIsInt != RIsInt) {
7182 if (BinOpKind == BO_Add) {
7195 return SLCT_NotALiteral;
7197 case Stmt::UnaryOperatorClass: {
7200 if (UnaOp->
getOpcode() == UO_AddrOf && ASE) {
7202 if (ASE->getRHS()->EvaluateAsInt(IndexResult, S.
Context,
7212 return SLCT_NotALiteral;
7216 return SLCT_NotALiteral;
7221 return llvm::StringSwitch<FormatStringType>(Format->getType()->getName())
7222 .Case(
"scanf", FST_Scanf)
7223 .Cases(
"printf",
"printf0", FST_Printf)
7224 .Cases(
"NSString",
"CFString", FST_NSString)
7225 .Case(
"strftime", FST_Strftime)
7226 .Case(
"strfmon", FST_Strfmon)
7227 .Cases(
"kprintf",
"cmn_err",
"vcmn_err",
"zcmn_err", FST_Kprintf)
7228 .Case(
"freebsd_kprintf", FST_FreeBSDKPrintf)
7229 .Case(
"os_trace", FST_OSLog)
7230 .Case(
"os_log", FST_OSLog)
7231 .Default(FST_Unknown);
7237 bool Sema::CheckFormatArguments(
const FormatAttr *Format,
7242 llvm::SmallBitVector &CheckedVarArgs) {
7243 FormatStringInfo FSI;
7244 if (getFormatStringInfo(Format, IsCXXMember, &FSI))
7245 return CheckFormatArguments(Args, FSI.HasVAListArg, FSI.FormatIdx,
7246 FSI.FirstDataArg, GetFormatStringType(Format),
7247 CallType, Loc, Range, CheckedVarArgs);
7252 bool HasVAListArg,
unsigned format_idx,
7256 llvm::SmallBitVector &CheckedVarArgs) {
7258 if (format_idx >= Args.size()) {
7259 Diag(Loc, diag::warn_missing_format_string) << Range;
7263 const Expr *OrigFormatExpr = Args[format_idx]->IgnoreParenCasts();
7277 UncoveredArgHandler UncoveredArg;
7280 format_idx, firstDataArg,
Type, CallType,
7281 true, CheckedVarArgs,
7286 if (UncoveredArg.hasUncoveredArg()) {
7287 unsigned ArgIdx = UncoveredArg.getUncoveredArg() + firstDataArg;
7288 assert(ArgIdx < Args.size() &&
"ArgIdx outside bounds");
7289 UncoveredArg.Diagnose(*
this,
true, Args[ArgIdx]);
7292 if (CT != SLCT_NotALiteral)
7294 return CT == SLCT_CheckedLiteral;
7298 if (
Type == FST_Strftime)
7306 if (
Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
7311 if (Args.size() == firstDataArg) {
7312 Diag(FormatLoc, diag::warn_format_nonliteral_noargs)
7318 case FST_FreeBSDKPrintf:
7320 Diag(FormatLoc, diag::note_format_security_fixit)
7324 Diag(FormatLoc, diag::note_format_security_fixit)
7329 Diag(FormatLoc, diag::warn_format_nonliteral)
7340 const FormatStringLiteral *FExpr;
7341 const Expr *OrigFormatExpr;
7343 const unsigned FirstDataArg;
7344 const unsigned NumDataArgs;
7346 const bool HasVAListArg;
7349 llvm::SmallBitVector CoveredArgs;
7350 bool usesPositionalArgs =
false;
7351 bool atFirstArg =
true;
7352 bool inFunctionCall;
7354 llvm::SmallBitVector &CheckedVarArgs;
7355 UncoveredArgHandler &UncoveredArg;
7358 CheckFormatHandler(
Sema &s,
const FormatStringLiteral *fexpr,
7359 const Expr *origFormatExpr,
7361 unsigned numDataArgs,
const char *beg,
bool hasVAListArg,
7364 llvm::SmallBitVector &CheckedVarArgs,
7365 UncoveredArgHandler &UncoveredArg)
7366 : S(s), FExpr(fexpr), OrigFormatExpr(origFormatExpr), FSType(type),
7367 FirstDataArg(firstDataArg), NumDataArgs(numDataArgs), Beg(beg),
7368 HasVAListArg(hasVAListArg), Args(Args), FormatIdx(formatIdx),
7369 inFunctionCall(inFunctionCall), CallType(callType),
7370 CheckedVarArgs(CheckedVarArgs), UncoveredArg(UncoveredArg) {
7371 CoveredArgs.resize(numDataArgs);
7372 CoveredArgs.reset();
7375 void DoneProcessing();
7377 void HandleIncompleteSpecifier(
const char *startSpecifier,
7378 unsigned specifierLen)
override;
7380 void HandleInvalidLengthModifier(
7383 const char *startSpecifier,
unsigned specifierLen,
7386 void HandleNonStandardLengthModifier(
7388 const char *startSpecifier,
unsigned specifierLen);
7390 void HandleNonStandardConversionSpecifier(
7392 const char *startSpecifier,
unsigned specifierLen);
7394 void HandlePosition(
const char *startPos,
unsigned posLen)
override;
7396 void HandleInvalidPosition(
const char *startSpecifier,
7397 unsigned specifierLen,
7400 void HandleZeroPosition(
const char *startPos,
unsigned posLen)
override;
7402 void HandleNullChar(
const char *nullCharacter)
override;
7404 template <
typename Range>
7406 EmitFormatDiagnostic(
Sema &S,
bool inFunctionCall,
const Expr *ArgumentExpr,
7408 bool IsStringLocation, Range StringRange,
7412 bool HandleInvalidConversionSpecifier(
unsigned argIndex,
SourceLocation Loc,
7413 const char *startSpec,
7414 unsigned specifierLen,
7415 const char *csStart,
unsigned csLen);
7418 const char *startSpec,
7419 unsigned specifierLen);
7423 unsigned specifierLen);
7426 const Expr *getDataArg(
unsigned i)
const;
7430 const char *startSpecifier,
unsigned specifierLen,
7433 template <
typename Range>
7435 bool IsStringLocation, Range StringRange,
7441 SourceRange CheckFormatHandler::getFormatStringRange() {
7446 getSpecifierRange(
const char *startSpecifier,
unsigned specifierLen) {
7456 SourceLocation CheckFormatHandler::getLocationOfByte(
const char *x) {
7461 void CheckFormatHandler::HandleIncompleteSpecifier(
const char *startSpecifier,
7462 unsigned specifierLen){
7463 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_incomplete_specifier),
7464 getLocationOfByte(startSpecifier),
7466 getSpecifierRange(startSpecifier, specifierLen));
7469 void CheckFormatHandler::HandleInvalidLengthModifier(
7472 const char *startSpecifier,
unsigned specifierLen,
unsigned DiagID) {
7473 using namespace analyze_format_string;
7476 CharSourceRange LMRange = getSpecifierRange(LM.getStart(), LM.getLength());
7481 EmitFormatDiagnostic(S.
PDiag(DiagID) << LM.toString() << CS.
toString(),
7482 getLocationOfByte(LM.getStart()),
7484 getSpecifierRange(startSpecifier, specifierLen));
7486 S.
Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
7487 << FixedLM->toString()
7492 if (DiagID == diag::warn_format_nonsensical_length)
7495 EmitFormatDiagnostic(S.
PDiag(DiagID) << LM.toString() << CS.
toString(),
7496 getLocationOfByte(LM.getStart()),
7498 getSpecifierRange(startSpecifier, specifierLen),
7503 void CheckFormatHandler::HandleNonStandardLengthModifier(
7505 const char *startSpecifier,
unsigned specifierLen) {
7506 using namespace analyze_format_string;
7509 CharSourceRange LMRange = getSpecifierRange(LM.getStart(), LM.getLength());
7514 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
7515 << LM.toString() << 0,
7516 getLocationOfByte(LM.getStart()),
7518 getSpecifierRange(startSpecifier, specifierLen));
7520 S.
Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
7521 << FixedLM->toString()
7525 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
7526 << LM.toString() << 0,
7527 getLocationOfByte(LM.getStart()),
7529 getSpecifierRange(startSpecifier, specifierLen));
7533 void CheckFormatHandler::HandleNonStandardConversionSpecifier(
7535 const char *startSpecifier,
unsigned specifierLen) {
7536 using namespace analyze_format_string;
7541 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
7545 getSpecifierRange(startSpecifier, specifierLen));
7548 S.
Diag(getLocationOfByte(CS.
getStart()), diag::note_format_fix_specifier)
7549 << FixedCS->toString()
7552 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard)
7556 getSpecifierRange(startSpecifier, specifierLen));
7560 void CheckFormatHandler::HandlePosition(
const char *startPos,
7562 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_non_standard_positional_arg),
7563 getLocationOfByte(startPos),
7565 getSpecifierRange(startPos, posLen));
7569 CheckFormatHandler::HandleInvalidPosition(
const char *startPos,
unsigned posLen,
7571 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_positional_specifier)
7573 getLocationOfByte(startPos),
true,
7574 getSpecifierRange(startPos, posLen));
7577 void CheckFormatHandler::HandleZeroPosition(
const char *startPos,
7579 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_zero_positional_specifier),
7580 getLocationOfByte(startPos),
7582 getSpecifierRange(startPos, posLen));
7585 void CheckFormatHandler::HandleNullChar(
const char *nullCharacter) {
7586 if (!isa<ObjCStringLiteral>(OrigFormatExpr)) {
7588 EmitFormatDiagnostic(
7589 S.
PDiag(diag::warn_printf_format_string_contains_null_char),
7590 getLocationOfByte(nullCharacter),
true,
7591 getFormatStringRange());
7597 const Expr *CheckFormatHandler::getDataArg(
unsigned i)
const {
7598 return Args[FirstDataArg + i];
7601 void CheckFormatHandler::DoneProcessing() {
7604 if (!HasVAListArg) {
7607 signed notCoveredArg = CoveredArgs.find_first();
7608 if (notCoveredArg >= 0) {
7609 assert((
unsigned)notCoveredArg < NumDataArgs);
7610 UncoveredArg.Update(notCoveredArg, OrigFormatExpr);
7612 UncoveredArg.setAllCovered();
7617 void UncoveredArgHandler::Diagnose(
Sema &S,
bool IsFunctionCall,
7618 const Expr *ArgExpr) {
7619 assert(hasUncoveredArg() && DiagnosticExprs.size() > 0 &&
7631 for (
auto E : DiagnosticExprs)
7634 CheckFormatHandler::EmitFormatDiagnostic(
7635 S, IsFunctionCall, DiagnosticExprs[0],
7641 CheckFormatHandler::HandleInvalidConversionSpecifier(
unsigned argIndex,
7643 const char *startSpec,
7644 unsigned specifierLen,
7645 const char *csStart,
7647 bool keepGoing =
true;
7648 if (argIndex < NumDataArgs) {
7651 CoveredArgs.set(argIndex);
7667 std::string CodePointStr;
7668 if (!llvm::sys::locale::isPrint(*csStart)) {
7669 llvm::UTF32 CodePoint;
7670 const llvm::UTF8 **B =
reinterpret_cast<const llvm::UTF8 **
>(&csStart);
7671 const llvm::UTF8 *E =
7672 reinterpret_cast<const llvm::UTF8 *
>(csStart + csLen);
7673 llvm::ConversionResult Result =
7674 llvm::convertUTF8Sequence(B, E, &CodePoint, llvm::strictConversion);
7676 if (Result != llvm::conversionOK) {
7677 unsigned char FirstChar = *csStart;
7678 CodePoint = (llvm::UTF32)FirstChar;
7681 llvm::raw_string_ostream OS(CodePointStr);
7682 if (CodePoint < 256)
7683 OS <<
"\\x" << llvm::format(
"%02x", CodePoint);
7684 else if (CodePoint <= 0xFFFF)
7685 OS <<
"\\u" << llvm::format(
"%04x", CodePoint);
7687 OS <<
"\\U" << llvm::format(
"%08x", CodePoint);
7689 Specifier = CodePointStr;
7692 EmitFormatDiagnostic(
7694 true, getSpecifierRange(startSpec, specifierLen));
7700 CheckFormatHandler::HandlePositionalNonpositionalArgs(
SourceLocation Loc,
7701 const char *startSpec,
7702 unsigned specifierLen) {
7703 EmitFormatDiagnostic(
7704 S.
PDiag(diag::warn_format_mix_positional_nonpositional_args),
7705 Loc,
true, getSpecifierRange(startSpec, specifierLen));
7709 CheckFormatHandler::CheckNumArgs(
7712 const char *startSpecifier,
unsigned specifierLen,
unsigned argIndex) {
7714 if (argIndex >= NumDataArgs) {
7716 ? (S.
PDiag(diag::warn_printf_positional_arg_exceeds_data_args)
7717 << (argIndex+1) << NumDataArgs)
7718 : S.
PDiag(diag::warn_printf_insufficient_data_args);
7719 EmitFormatDiagnostic(
7720 PDiag, getLocationOfByte(CS.
getStart()),
true,
7721 getSpecifierRange(startSpecifier, specifierLen));
7725 UncoveredArg.setAllCovered();
7731 template<
typename Range>
7734 bool IsStringLocation,
7737 EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag,
7738 Loc, IsStringLocation, StringRange, FixIt);
7768 template <
typename Range>
7769 void CheckFormatHandler::EmitFormatDiagnostic(
7770 Sema &S,
bool InFunctionCall,
const Expr *ArgumentExpr,
7773 if (InFunctionCall) {
7778 S.
Diag(IsStringLocation ? ArgumentExpr->
getExprLoc() : Loc, PDiag)
7782 S.
Diag(IsStringLocation ? Loc : StringRange.getBegin(),
7783 diag::note_format_string_defined);
7785 Note << StringRange;
7794 class CheckPrintfHandler :
public CheckFormatHandler {
7796 CheckPrintfHandler(
Sema &s,
const FormatStringLiteral *fexpr,
7797 const Expr *origFormatExpr,
7799 unsigned numDataArgs,
bool isObjC,
const char *beg,
7801 unsigned formatIdx,
bool inFunctionCall,
7803 llvm::SmallBitVector &CheckedVarArgs,
7804 UncoveredArgHandler &UncoveredArg)
7805 : CheckFormatHandler(s, fexpr, origFormatExpr, type, firstDataArg,
7806 numDataArgs, beg, hasVAListArg, Args, formatIdx,
7807 inFunctionCall, CallType, CheckedVarArgs,
7813 bool allowsObjCArg()
const {
7818 bool HandleInvalidPrintfConversionSpecifier(
7820 const char *startSpecifier,
7821 unsigned specifierLen)
override;
7823 void handleInvalidMaskType(StringRef MaskType)
override;
7826 const char *startSpecifier,
7827 unsigned specifierLen)
override;
7829 const char *StartSpecifier,
7830 unsigned SpecifierLen,
7834 const char *startSpecifier,
unsigned specifierLen);
7838 const char *startSpecifier,
unsigned specifierLen);
7841 const char *startSpecifier,
unsigned specifierLen);
7845 const char *startSpecifier,
unsigned specifierLen);
7849 void HandleEmptyObjCModifierFlag(
const char *startFlag,
7850 unsigned flagLen)
override;
7852 void HandleInvalidObjCModifierFlag(
const char *startFlag,
7853 unsigned flagLen)
override;
7855 void HandleObjCFlagsWithNonObjCConversion(
const char *flagsStart,
7856 const char *flagsEnd,
7857 const char *conversionPosition)
7863 bool CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier(
7865 const char *startSpecifier,
7866 unsigned specifierLen) {
7870 return HandleInvalidConversionSpecifier(FS.
getArgIndex(),
7872 startSpecifier, specifierLen,
7876 void CheckPrintfHandler::handleInvalidMaskType(StringRef MaskType) {
7877 S.
Diag(getLocationOfByte(MaskType.data()), diag::err_invalid_mask_type_size);
7880 bool CheckPrintfHandler::HandleAmount(
7882 unsigned k,
const char *startSpecifier,
7883 unsigned specifierLen) {
7885 if (!HasVAListArg) {
7887 if (argIndex >= NumDataArgs) {
7888 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_asterisk_missing_arg)
7892 getSpecifierRange(startSpecifier, specifierLen));
7902 CoveredArgs.set(argIndex);
7903 const Expr *Arg = getDataArg(argIndex);
7913 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_asterisk_wrong_type)
7918 getSpecifierRange(startSpecifier, specifierLen));
7928 void CheckPrintfHandler::HandleInvalidAmount(
7932 const char *startSpecifier,
7933 unsigned specifierLen) {
7943 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_nonsensical_optional_amount)
7947 getSpecifierRange(startSpecifier, specifierLen),
7953 const char *startSpecifier,
7954 unsigned specifierLen) {
7958 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_nonsensical_flag)
7962 getSpecifierRange(startSpecifier, specifierLen),
7967 void CheckPrintfHandler::HandleIgnoredFlag(
7971 const char *startSpecifier,
7972 unsigned specifierLen) {
7974 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_ignored_flag)
7978 getSpecifierRange(startSpecifier, specifierLen),
7980 getSpecifierRange(ignoredFlag.
getPosition(), 1)));
7983 void CheckPrintfHandler::HandleEmptyObjCModifierFlag(
const char *startFlag,
7986 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_empty_objc_flag),
7987 getLocationOfByte(startFlag),
7989 getSpecifierRange(startFlag, flagLen));
7992 void CheckPrintfHandler::HandleInvalidObjCModifierFlag(
const char *startFlag,
7995 auto Range = getSpecifierRange(startFlag, flagLen);
7996 StringRef flag(startFlag, flagLen);
7997 EmitFormatDiagnostic(S.
PDiag(diag::warn_printf_invalid_objc_flag) << flag,
7998 getLocationOfByte(startFlag),
8003 void CheckPrintfHandler::HandleObjCFlagsWithNonObjCConversion(
8004 const char *flagsStart,
const char *flagsEnd,
const char *conversionPosition) {
8006 auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1);
8007 auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion;
8008 EmitFormatDiagnostic(S.
PDiag(diag) << StringRef(conversionPosition, 1),
8009 getLocationOfByte(conversionPosition),
8017 template<
typename MemberKind>
8018 static llvm::SmallPtrSet<MemberKind*, 1>
8021 llvm::SmallPtrSet<MemberKind*, 1> Results;
8038 if (MemberKind *FK = dyn_cast<MemberKind>(decl))
8049 using MethodSet = llvm::SmallPtrSet<CXXMethodDecl *, 1>;
8052 CXXRecordMembersNamed<CXXMethodDecl>(
"c_str", *
this, E->
getType());
8053 for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
8055 if ((*MI)->getMinRequiredArguments() == 0)
8063 bool CheckPrintfHandler::checkForCStrMembers(
8065 using MethodSet = llvm::SmallPtrSet<CXXMethodDecl *, 1>;
8068 CXXRecordMembersNamed<CXXMethodDecl>(
"c_str", S, E->
getType());
8070 for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
8089 const char *startSpecifier,
8090 unsigned specifierLen) {
8091 using namespace analyze_format_string;
8092 using namespace analyze_printf;
8102 HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
8103 startSpecifier, specifierLen);
8111 startSpecifier, specifierLen)) {
8116 startSpecifier, specifierLen)) {
8120 if (!CS.consumesDataArgument()) {
8128 if (argIndex < NumDataArgs) {
8132 CoveredArgs.set(argIndex);
8136 if (CS.getKind() == ConversionSpecifier::FreeBSDbArg ||
8137 CS.getKind() == ConversionSpecifier::FreeBSDDArg) {
8139 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex + 1))
8143 CoveredArgs.set(argIndex + 1);
8146 const Expr *Ex = getDataArg(argIndex);
8148 (CS.getKind() == ConversionSpecifier::FreeBSDbArg) ?
8151 EmitFormatDiagnostic(
8152 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
8156 getSpecifierRange(startSpecifier, specifierLen));
8159 Ex = getDataArg(argIndex + 1);
8162 EmitFormatDiagnostic(
8163 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
8165 <<
false << Ex->getSourceRange(),
8166 Ex->getBeginLoc(),
false,
8167 getSpecifierRange(startSpecifier, specifierLen));
8174 if (!allowsObjCArg() && CS.isObjCArg()) {
8175 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
8180 if (FSType !=
Sema::FST_OSLog && CS.getKind() == ConversionSpecifier::PArg) {
8181 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
8186 if (FSType ==
Sema::FST_OSLog && CS.getKind() == ConversionSpecifier::nArg) {
8187 EmitFormatDiagnostic(S.
PDiag(diag::warn_os_log_format_narg),
8188 getLocationOfByte(CS.getStart()),
8190 getSpecifierRange(startSpecifier, specifierLen));
8197 (CS.getKind() == ConversionSpecifier::PArg ||
8198 CS.getKind() == ConversionSpecifier::sArg ||
8199 CS.getKind() == ConversionSpecifier::ObjCObjArg)) {
8200 return HandleInvalidPrintfConversionSpecifier(FS, startSpecifier,
8207 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_annotation)
8211 getSpecifierRange(startSpecifier, specifierLen));
8214 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_invalid_annotation)
8218 getSpecifierRange(startSpecifier, specifierLen));
8225 startSpecifier, specifierLen);
8231 startSpecifier, specifierLen);
8235 if (CS.getKind() == ConversionSpecifier::PArg &&
8237 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_P_no_precision),
8238 getLocationOfByte(startSpecifier),
8240 getSpecifierRange(startSpecifier, specifierLen));
8249 HandleFlag(FS, FS.
hasPlusPrefix(), startSpecifier, specifierLen);
8251 HandleFlag(FS, FS.
hasSpacePrefix(), startSpecifier, specifierLen);
8260 startSpecifier, specifierLen);
8263 startSpecifier, specifierLen);
8268 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
8269 diag::warn_format_nonsensical_length);
8271 HandleNonStandardLengthModifier(FS, startSpecifier, specifierLen);
8273 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
8274 diag::warn_format_non_standard_conversion_spec);
8277 HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
8283 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex))
8286 const Expr *Arg = getDataArg(argIndex);
8290 return checkFormatExpr(FS, startSpecifier, specifierLen, Arg);
8302 case Stmt::ArraySubscriptExprClass:
8303 case Stmt::CallExprClass:
8304 case Stmt::CharacterLiteralClass:
8305 case Stmt::CXXBoolLiteralExprClass:
8306 case Stmt::DeclRefExprClass:
8307 case Stmt::FloatingLiteralClass:
8308 case Stmt::IntegerLiteralClass:
8309 case Stmt::MemberExprClass:
8310 case Stmt::ObjCArrayLiteralClass:
8311 case Stmt::ObjCBoolLiteralExprClass:
8312 case Stmt::ObjCBoxedExprClass:
8313 case Stmt::ObjCDictionaryLiteralClass:
8314 case Stmt::ObjCEncodeExprClass:
8315 case Stmt::ObjCIvarRefExprClass:
8316 case Stmt::ObjCMessageExprClass:
8317 case Stmt::ObjCPropertyRefExprClass:
8318 case Stmt::ObjCStringLiteralClass:
8319 case Stmt::ObjCSubscriptRefExprClass:
8320 case Stmt::ParenExprClass:
8321 case Stmt::StringLiteralClass:
8322 case Stmt::UnaryOperatorClass:
8329 static std::pair<QualType, StringRef>
8336 StringRef Name = UserTy->getDecl()->getName();
8337 QualType CastTy = llvm::StringSwitch<QualType>(Name)
8341 .Case(
"SInt32", Context.
IntTy)
8346 return std::make_pair(CastTy, Name);
8348 TyTy = UserTy->desugar();
8352 if (
const ParenExpr *PE = dyn_cast<ParenExpr>(E))
8354 PE->getSubExpr()->getType(),
8363 StringRef TrueName, FalseName;
8365 std::tie(TrueTy, TrueName) =
8367 CO->getTrueExpr()->getType(),
8369 std::tie(FalseTy, FalseName) =
8371 CO->getFalseExpr()->getType(),
8372 CO->getFalseExpr());
8374 if (TrueTy == FalseTy)
8375 return std::make_pair(TrueTy, TrueName);
8376 else if (TrueTy.
isNull())
8377 return std::make_pair(FalseTy, FalseName);
8378 else if (FalseTy.
isNull())
8379 return std::make_pair(TrueTy, TrueName);
8382 return std::make_pair(
QualType(), StringRef());
8401 From = VecTy->getElementType();
8403 To = VecTy->getElementType();
8411 const char *StartSpecifier,
8412 unsigned SpecifierLen,
8414 using namespace analyze_format_string;
8415 using namespace analyze_printf;
8424 while (
const TypeOfExprType *TET = dyn_cast<TypeOfExprType>(ExprTy)) {
8425 ExprTy = TET->getUnderlyingExpr()->getType();
8434 getSpecifierRange(StartSpecifier, SpecifierLen);
8436 llvm::raw_svector_ostream os(FSString);
8438 EmitFormatDiagnostic(S.
PDiag(diag::warn_format_bool_as_character)
8455 E = ICE->getSubExpr();
8465 AT.matchesType(S.
Context, ExprTy);
8468 if (ImplicitMatch == ArgType::NoMatchPedantic ||
8469 ImplicitMatch == ArgType::NoMatchTypeConfusion)
8470 Match = ImplicitMatch;
8483 bool IsEnum =
false;
8485 ExprTy = EnumTy->getDecl()->getIntegerType();
8493 if (isObjCContext() &&
8514 if (TD->getUnderlyingType() == IntendedTy)
8522 bool ShouldNotPrintDirectly =
false; StringRef CastTyName;
8529 if ((CastTyName ==
"NSInteger" || CastTyName ==
"NSUInteger") &&
8530 (AT.isSizeT() || AT.isPtrdiffT()) &&
8531 AT.matchesType(S.
Context, CastTy))
8532 Match = ArgType::NoMatchPedantic;
8533 IntendedTy = CastTy;
8534 ShouldNotPrintDirectly =
true;
8539 PrintfSpecifier fixedFS = FS;
8546 llvm::raw_svector_ostream os(buf);
8547 fixedFS.toString(os);
8549 CharSourceRange SpecRange = getSpecifierRange(StartSpecifier, SpecifierLen);
8551 if (IntendedTy == ExprTy && !ShouldNotPrintDirectly) {
8554 case ArgType::Match: llvm_unreachable(
"expected non-matching");
8555 case ArgType::NoMatchPedantic:
8556 Diag = diag::warn_format_conversion_argument_type_mismatch_pedantic;
8558 case ArgType::NoMatchTypeConfusion:
8559 Diag = diag::warn_format_conversion_argument_type_mismatch_confusion;
8561 case ArgType::NoMatch:
8562 Diag = diag::warn_format_conversion_argument_type_mismatch;
8568 EmitFormatDiagnostic(S.
PDiag(Diag)
8569 << AT.getRepresentativeTypeName(S.
Context)
8583 llvm::raw_svector_ostream CastFix(CastBuf);
8589 if (!AT.matchesType(S.
Context, IntendedTy) || ShouldNotPrintDirectly)
8594 SourceRange CastRange(CCast->getLParenLoc(), CCast->getRParenLoc());
8612 if (ShouldNotPrintDirectly) {
8617 if (
const TypedefType *TypedefTy = dyn_cast<TypedefType>(ExprTy))
8618 Name = TypedefTy->getDecl()->getName();
8621 unsigned Diag = Match == ArgType::NoMatchPedantic
8622 ? diag::warn_format_argument_needs_cast_pedantic
8623 : diag::warn_format_argument_needs_cast;
8624 EmitFormatDiagnostic(S.
PDiag(Diag) << Name << IntendedTy << IsEnum
8632 EmitFormatDiagnostic(
8633 S.
PDiag(diag::warn_format_conversion_argument_type_mismatch)
8634 << AT.getRepresentativeTypeName(S.
Context) << ExprTy << IsEnum
8650 case ArgType::Match: llvm_unreachable(
"expected non-matching");
8651 case ArgType::NoMatchPedantic:
8652 Diag = diag::warn_format_conversion_argument_type_mismatch_pedantic;
8654 case ArgType::NoMatchTypeConfusion:
8655 Diag = diag::warn_format_conversion_argument_type_mismatch_confusion;
8657 case ArgType::NoMatch:
8658 Diag = diag::warn_format_conversion_argument_type_mismatch;
8662 EmitFormatDiagnostic(
8663 S.
PDiag(Diag) << AT.getRepresentativeTypeName(S.
Context) << ExprTy
8670 EmitFormatDiagnostic(S.
PDiag(diag::warn_non_pod_vararg_with_format_string)
8673 << AT.getRepresentativeTypeName(S.
Context) << CSR
8676 checkForCStrMembers(AT, E);
8681 EmitFormatDiagnostic(
8682 S.
PDiag(diag::err_cannot_pass_objc_interface_to_vararg_format)
8683 << S.
getLangOpts().CPlusPlus11 << ExprTy << CallType
8684 << AT.getRepresentativeTypeName(S.
Context) << CSR
8691 << isa<InitListExpr>(E) << ExprTy << CallType
8696 assert(FirstDataArg + FS.
getArgIndex() < CheckedVarArgs.size() &&
8697 "format string specifier index out of range");
8698 CheckedVarArgs[FirstDataArg + FS.
getArgIndex()] =
true;
8708 class CheckScanfHandler :
public CheckFormatHandler {
8710 CheckScanfHandler(
Sema &s,
const FormatStringLiteral *fexpr,
8712 unsigned firstDataArg,
unsigned numDataArgs,
8713 const char *beg,
bool hasVAListArg,
8714 ArrayRef<const Expr *> Args,
unsigned formatIdx,
8716 llvm::SmallBitVector &CheckedVarArgs,
8717 UncoveredArgHandler &UncoveredArg)
8718 : CheckFormatHandler(s, fexpr, origFormatExpr, type, firstDataArg,
8719 numDataArgs, beg, hasVAListArg, Args, formatIdx,
8720 inFunctionCall, CallType, CheckedVarArgs,
8724 const char *startSpecifier,
8725 unsigned specifierLen)
override;
8727 bool HandleInvalidScanfConversionSpecifier(
8729 const char *startSpecifier,
8730 unsigned specifierLen)
override;
8732 void HandleIncompleteScanList(
const char *start,
const char *end)
override;
8737 void CheckScanfHandler::HandleIncompleteScanList(
const char *start,
8739 EmitFormatDiagnostic(S.
PDiag(diag::warn_scanf_scanlist_incomplete),
8740 getLocationOfByte(end),
true,
8741 getSpecifierRange(start, end - start));
8744 bool CheckScanfHandler::HandleInvalidScanfConversionSpecifier(
8746 const char *startSpecifier,
8747 unsigned specifierLen) {
8751 return HandleInvalidConversionSpecifier(FS.
getArgIndex(),
8753 startSpecifier, specifierLen,
8757 bool CheckScanfHandler::HandleScanfSpecifier(
8759 const char *startSpecifier,
8760 unsigned specifierLen) {
8761 using namespace analyze_scanf;
8762 using namespace analyze_format_string;
8774 HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
8775 startSpecifier, specifierLen);
8782 if (Amt.getHowSpecified() == OptionalAmount::Constant) {
8783 if (Amt.getConstantAmount() == 0) {
8785 Amt.getConstantLength());
8786 EmitFormatDiagnostic(S.
PDiag(diag::warn_scanf_nonzero_width),
8787 getLocationOfByte(Amt.getStart()),
8801 if (argIndex < NumDataArgs) {
8805 CoveredArgs.set(argIndex);
8811 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
8812 diag::warn_format_nonsensical_length);
8814 HandleNonStandardLengthModifier(FS, startSpecifier, specifierLen);
8816 HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
8817 diag::warn_format_non_standard_conversion_spec);
8820 HandleNonStandardConversionSpecifier(CS, startSpecifier, specifierLen);
8826 if (!CheckNumArgs(FS, CS, startSpecifier, specifierLen, argIndex))
8830 const Expr *Ex = getDataArg(argIndex);
8846 ScanfSpecifier fixedFS = FS;
8851 Pedantic ? diag::warn_format_conversion_argument_type_mismatch_pedantic
8852 : diag::warn_format_conversion_argument_type_mismatch;
8857 llvm::raw_svector_ostream os(buf);
8858 fixedFS.toString(os);
8860 EmitFormatDiagnostic(
8865 getSpecifierRange(startSpecifier, specifierLen),
8867 getSpecifierRange(startSpecifier, specifierLen), os.str()));
8869 EmitFormatDiagnostic(S.
PDiag(Diag)
8874 getSpecifierRange(startSpecifier, specifierLen));
8881 const Expr *OrigFormatExpr,
8882 ArrayRef<const Expr *> Args,
8883 bool HasVAListArg,
unsigned format_idx,
8884 unsigned firstDataArg,
8886 bool inFunctionCall,
8888 llvm::SmallBitVector &CheckedVarArgs,
8889 UncoveredArgHandler &UncoveredArg,
8890 bool IgnoreStringsWithoutSpecifiers) {
8892 if (!FExpr->isAscii() && !FExpr->isUTF8()) {
8893 CheckFormatHandler::EmitFormatDiagnostic(
8894 S, inFunctionCall, Args[format_idx],
8895 S.
PDiag(diag::warn_format_string_is_wide_literal), FExpr->getBeginLoc(),
8901 StringRef StrRef = FExpr->getString();
8902 const char *Str = StrRef.data();
8906 assert(T &&
"String literal not of constant array type!");
8907 size_t TypeSize = T->
getSize().getZExtValue();
8908 size_t StrLen =
std::min(
std::max(TypeSize,
size_t(1)) - 1, StrRef.size());
8909 const unsigned numDataArgs = Args.size() - firstDataArg;
8911 if (IgnoreStringsWithoutSpecifiers &&
8918 if (TypeSize <= StrRef.size() &&
8919 StrRef.substr(0, TypeSize).find(
'\0') == StringRef::npos) {
8920 CheckFormatHandler::EmitFormatDiagnostic(
8921 S, inFunctionCall, Args[format_idx],
8922 S.
PDiag(diag::warn_printf_format_string_not_null_terminated),
8923 FExpr->getBeginLoc(),
8929 if (StrLen == 0 && numDataArgs > 0) {
8930 CheckFormatHandler::EmitFormatDiagnostic(
8931 S, inFunctionCall, Args[format_idx],
8932 S.
PDiag(diag::warn_empty_format_string), FExpr->getBeginLoc(),
8940 CheckPrintfHandler H(
8941 S, FExpr, OrigFormatExpr, Type, firstDataArg, numDataArgs,
8943 HasVAListArg, Args, format_idx, inFunctionCall, CallType,
8944 CheckedVarArgs, UncoveredArg);
8952 CheckScanfHandler H(S, FExpr, OrigFormatExpr, Type, firstDataArg,
8953 numDataArgs, Str, HasVAListArg, Args, format_idx,
8954 inFunctionCall, CallType, CheckedVarArgs, UncoveredArg);
8966 const char *Str = StrRef.data();
8969 assert(T &&
"String literal not of constant array type!");
8970 size_t TypeSize = T->
getSize().getZExtValue();
8971 size_t StrLen =
std::min(
std::max(TypeSize,
size_t(1)) - 1, StrRef.size());
8982 switch (AbsFunction) {
8986 case Builtin::BI__builtin_abs:
8987 return Builtin::BI__builtin_labs;
8988 case Builtin::BI__builtin_labs:
8989 return Builtin::BI__builtin_llabs;
8990 case Builtin::BI__builtin_llabs:
8993 case Builtin::BI__builtin_fabsf:
8994 return Builtin::BI__builtin_fabs;
8995 case Builtin::BI__builtin_fabs:
8996 return Builtin::BI__builtin_fabsl;
8997 case Builtin::BI__builtin_fabsl:
9000 case Builtin::BI__builtin_cabsf:
9001 return Builtin::BI__builtin_cabs;
9002 case Builtin::BI__builtin_cabs:
9003 return Builtin::BI__builtin_cabsl;
9004 case Builtin::BI__builtin_cabsl:
9007 case Builtin::BIabs:
9008 return Builtin::BIlabs;
9009 case Builtin::BIlabs:
9010 return Builtin::BIllabs;
9011 case Builtin::BIllabs:
9014 case Builtin::BIfabsf:
9015 return Builtin::BIfabs;
9016 case Builtin::BIfabs:
9017 return Builtin::BIfabsl;
9018 case Builtin::BIfabsl:
9021 case Builtin::BIcabsf:
9022 return Builtin::BIcabs;
9023 case Builtin::BIcabs:
9024 return Builtin::BIcabsl;
9025 case Builtin::BIcabsl:
9054 unsigned AbsFunctionKind) {
9055 unsigned BestKind = 0;
9057 for (
unsigned Kind = AbsFunctionKind;
Kind != 0;
9063 else if (Context.
hasSameType(ParamType, ArgType)) {
9086 llvm_unreachable(
"Type not integer, floating, or complex");
9093 switch (ValueKind) {
9098 case Builtin::BI__builtin_fabsf:
9099 case Builtin::BI__builtin_fabs:
9100 case Builtin::BI__builtin_fabsl:
9101 case Builtin::BI__builtin_cabsf:
9102 case Builtin::BI__builtin_cabs:
9103 case Builtin::BI__builtin_cabsl:
9104 return Builtin::BI__builtin_abs;
9105 case Builtin::BIfabsf:
9106 case Builtin::BIfabs:
9107 case Builtin::BIfabsl:
9108 case Builtin::BIcabsf:
9109 case Builtin::BIcabs:
9110 case Builtin::BIcabsl:
9111 return Builtin::BIabs;
9117 case Builtin::BI__builtin_abs:
9118 case Builtin::BI__builtin_labs:
9119 case Builtin::BI__builtin_llabs:
9120 case Builtin::BI__builtin_cabsf:
9121 case Builtin::BI__builtin_cabs:
9122 case Builtin::BI__builtin_cabsl:
9123 return Builtin::BI__builtin_fabsf;
9124 case Builtin::BIabs:
9125 case Builtin::BIlabs:
9126 case Builtin::BIllabs:
9127 case Builtin::BIcabsf:
9128 case Builtin::BIcabs:
9129 case Builtin::BIcabsl:
9130 return Builtin::BIfabsf;
9136 case Builtin::BI__builtin_abs:
9137 case Builtin::BI__builtin_labs:
9138 case Builtin::BI__builtin_llabs:
9139 case Builtin::BI__builtin_fabsf:
9140 case Builtin::BI__builtin_fabs:
9141 case Builtin::BI__builtin_fabsl:
9142 return Builtin::BI__builtin_cabsf;
9143 case Builtin::BIabs:
9144 case Builtin::BIlabs:
9145 case Builtin::BIllabs:
9146 case Builtin::BIfabsf:
9147 case Builtin::BIfabs:
9148 case Builtin::BIfabsl:
9149 return Builtin::BIcabsf;
9152 llvm_unreachable(
"Unable to convert function");
9163 case Builtin::BI__builtin_abs:
9164 case Builtin::BI__builtin_fabs:
9165 case Builtin::BI__builtin_fabsf:
9166 case Builtin::BI__builtin_fabsl:
9167 case Builtin::BI__builtin_labs:
9168 case Builtin::BI__builtin_llabs:
9169 case Builtin::BI__builtin_cabs:
9170 case Builtin::BI__builtin_cabsf:
9171 case Builtin::BI__builtin_cabsl:
9172 case Builtin::BIabs:
9173 case Builtin::BIlabs:
9174 case Builtin::BIllabs:
9175 case Builtin::BIfabs:
9176 case Builtin::BIfabsf:
9177 case Builtin::BIfabsl:
9178 case Builtin::BIcabs:
9179 case Builtin::BIcabsf:
9180 case Builtin::BIcabsl:
9183 llvm_unreachable(
"Unknown Builtin type");
9189 unsigned AbsKind,
QualType ArgType) {
9190 bool EmitHeaderHint =
true;
9191 const char *HeaderName =
nullptr;
9192 const char *FunctionName =
nullptr;
9194 FunctionName =
"std::abs";
9196 HeaderName =
"cstdlib";
9198 HeaderName =
"cmath";
9200 llvm_unreachable(
"Invalid Type");
9209 for (
const auto *I : R) {
9212 FDecl = dyn_cast<
FunctionDecl>(UsingD->getTargetDecl());
9229 EmitHeaderHint =
false;
9241 R.suppressDiagnostics();
9244 if (R.isSingleResult()) {
9247 EmitHeaderHint =
false;
9251 }
else if (!R.empty()) {
9257 S.
Diag(Loc, diag::note_replace_abs_function)
9263 if (!EmitHeaderHint)
9266 S.
Diag(Loc, diag::note_include_header_or_declare) << HeaderName
9270 template <std::
size_t StrLen>
9272 const char (&Str)[StrLen]) {
9284 void Sema::CheckAbsoluteValueFunction(
const CallExpr *Call,
9291 if (AbsKind == 0 && !IsStdAbs)
9300 const char *FunctionName =
9302 Diag(Call->
getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType;
9312 unsigned DiagType = 0;
9318 Diag(Call->
getExprLoc(), diag::warn_pointer_abs) << DiagType << ArgType;
9332 if (ArgValueKind == ParamValueKind) {
9338 << FDecl << ArgType << ParamType;
9340 if (NewAbsKind == 0)
9353 if (NewAbsKind == 0)
9357 << FDecl << ParamValueKind << ArgValueKind;
9364 void Sema::CheckMaxUnsignedZero(
const CallExpr *Call,
9366 if (!Call || !FDecl)
return;
9369 if (inTemplateInstantiation())
return;
9376 if (!ArgList)
return;
9377 if (ArgList->size() != 1)
return;
9380 const auto& TA = ArgList->
get(0);
9386 auto IsLiteralZeroArg = [](
const Expr* E) ->
bool {
9388 if (!MTE)
return false;
9390 if (!Num)
return false;
9391 if (Num->getValue() != 0)
return false;
9397 const bool IsFirstArgZero = IsLiteralZeroArg(FirstArg);
9398 const bool IsSecondArgZero = IsLiteralZeroArg(SecondArg);
9401 if (IsFirstArgZero == IsSecondArgZero)
return;
9406 SourceRange ZeroRange = IsFirstArgZero ? FirstRange : SecondRange;
9413 if (IsFirstArgZero) {
9446 << SizeRange << FnName;
9447 S.
Diag(FnLoc, diag::note_memsize_comparison_paren)
9452 S.
Diag(SizeRange.
getBegin(), diag::note_memsize_comparison_cast_silence)
9463 bool &IsContained) {
9466 IsContained =
false;
9479 for (
auto *FD : RD->
fields()) {
9492 if (
const auto *Unary = dyn_cast<UnaryExprOrTypeTraitExpr>(E))
9502 if (!SizeOf->isArgumentType())
9510 return SizeOf->getTypeOfArgument();
9516 struct SearchNonTrivialToInitializeField
9521 SearchNonTrivialToInitializeField(
const Expr *E,
Sema &S) : E(E), S(S) {}
9525 if (
const auto *AT = asDerived().getContext().getAsArrayType(FT)) {
9526 asDerived().visitArray(PDIK, AT, SL);
9530 Super::visitWithKind(PDIK, FT, SL);
9545 visit(getContext().getBaseElementType(AT), SL);
9550 SearchNonTrivialToInitializeField(E, S).visitStruct(RT,
SourceLocation());
9559 struct SearchNonTrivialToCopyField
9563 SearchNonTrivialToCopyField(
const Expr *E,
Sema &S) : E(E), S(S) {}
9567 if (
const auto *AT = asDerived().getContext().getAsArrayType(FT)) {
9568 asDerived().visitArray(PCK, AT, SL);
9572 Super::visitWithKind(PCK, FT, SL);
9587 visit(getContext().getBaseElementType(AT), SL);
9595 SearchNonTrivialToCopyField(E, S).visitStruct(RT,
SourceLocation());
9610 if (
const auto *BO = dyn_cast<BinaryOperator>(SizeofExpr)) {
9611 if (BO->getOpcode() != BO_Mul && BO->getOpcode() != BO_Add)
9644 if (BId != Builtin::BImemset && BId != Builtin::BIbzero)
9647 const Expr *SizeArg =
9650 auto isLiteralZero = [](
const Expr *E) {
9651 return isa<IntegerLiteral>(E) && cast<IntegerLiteral>(E)->getValue() == 0;
9657 if (isLiteralZero(SizeArg) &&
9664 if (BId == Builtin::BIbzero ||
9667 S.
Diag(DiagLoc, diag::warn_suspicious_bzero_size);
9668 S.
Diag(DiagLoc, diag::note_suspicious_bzero_size_silence);
9670 S.
Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 0;
9671 S.
Diag(DiagLoc, diag::note_suspicious_sizeof_memset_silence) << 0;
9679 if (BId == Builtin::BImemset &&
9683 S.
Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 1;
9684 S.
Diag(DiagLoc, diag::note_suspicious_sizeof_memset_silence) << 1;
9696 void Sema::CheckMemaccessArguments(
const CallExpr *Call,
9703 unsigned ExpectedNumArgs =
9704 (BId == Builtin::BIstrndup || BId == Builtin::BIbzero ? 2 : 3);
9708 unsigned LastArg = (BId == Builtin::BImemset || BId == Builtin::BIbzero ||
9709 BId == Builtin::BIstrndup ? 1 : 2);
9711 (BId == Builtin::BIbzero || BId == Builtin::BIstrndup ? 1 : 2);
9724 llvm::FoldingSetNodeID SizeOfArgID;
9733 for (
unsigned ArgIdx = 0; ArgIdx != LastArg; ++ArgIdx) {
9752 !Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess,
9756 if (SizeOfArgID == llvm::FoldingSetNodeID())
9757 SizeOfArg->
Profile(SizeOfArgID, Context,
true);
9758 llvm::FoldingSetNodeID DestID;
9759 Dest->
Profile(DestID, Context,
true);
9760 if (DestID == SizeOfArgID) {
9763 unsigned ActionIdx = 0;
9764 StringRef ReadableName = FnName->
getName();
9766 if (
const UnaryOperator *UnaryOp = dyn_cast<UnaryOperator>(Dest))
9767 if (UnaryOp->getOpcode() == UO_AddrOf)
9790 DiagRuntimeBehavior(SL, SizeOfArg,
9791 PDiag(diag::warn_sizeof_pointer_expr_memaccess)
9797 DiagRuntimeBehavior(SL, SizeOfArg,
9798 PDiag(diag::warn_sizeof_pointer_expr_memaccess_note)
9812 DiagRuntimeBehavior(LenExpr->
getExprLoc(), Dest,
9813 PDiag(diag::warn_sizeof_pointer_type_memaccess)
9814 << FnName << SizeOfArgTy << ArgIdx
9832 unsigned OperationType = 0;
9833 const bool IsCmp = BId == Builtin::BImemcmp || BId == Builtin::BIbcmp;
9836 if (ArgIdx != 0 || IsCmp) {
9837 if (BId == Builtin::BImemcpy)
9839 else if(BId == Builtin::BImemmove)
9845 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9846 PDiag(diag::warn_dyn_class_memaccess)
9847 << (IsCmp ? ArgIdx + 2 : ArgIdx) << FnName
9848 << IsContained << ContainedRD << OperationType
9851 BId != Builtin::BImemset)
9852 DiagRuntimeBehavior(
9854 PDiag(diag::warn_arc_object_memaccess)
9855 << ArgIdx << FnName << PointeeTy
9858 if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
9859 RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize()) {
9860 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9861 PDiag(diag::warn_cstruct_memaccess)
9862 << ArgIdx << FnName << PointeeTy << 0);
9863 SearchNonTrivialToInitializeField::diag(PointeeTy, Dest, *
this);
9864 }
else if ((BId == Builtin::BImemcpy || BId == Builtin::BImemmove) &&
9865 RT->getDecl()->isNonTrivialToPrimitiveCopy()) {
9866 DiagRuntimeBehavior(Dest->
getExprLoc(), Dest,
9867 PDiag(diag::warn_cstruct_memaccess)
9868 << ArgIdx << FnName << PointeeTy << 1);
9869 SearchNonTrivialToCopyField::diag(PointeeTy, Dest, *
this);
9876 DiagRuntimeBehavior(
9878 PDiag(diag::note_bad_memaccess_silence)
9898 if (isa<IntegerLiteral>(RHS))
9900 else if (isa<IntegerLiteral>(LHS))
9914 if (CAT->getSize().getSExtValue() <= 1)
9924 void Sema::CheckStrlcpycatArguments(
const CallExpr *Call,
9929 if ((NumArgs != 3) && (NumArgs != 4))
9934 const Expr *CompareWithSrc =
nullptr;
9942 CompareWithSrc = Ex;
9945 if (
const CallExpr *SizeCall = dyn_cast<CallExpr>(SizeArg)) {
9946 if (SizeCall->getBuiltinCallee() == Builtin::BIstrlen &&
9947 SizeCall->getNumArgs() == 1)
9952 if (!CompareWithSrc)
9964 if (!CompareWithSrcDRE ||
9968 const Expr *OriginalSizeArg = Call->
getArg(2);
9969 Diag(CompareWithSrcDRE->
getBeginLoc(), diag::warn_strlcpycat_wrong_size)
9981 llvm::raw_svector_ostream OS(sizeString);
9983 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
9986 Diag(OriginalSizeArg->
getBeginLoc(), diag::note_strlcpycat_wrong_size)
9993 if (
const DeclRefExpr *D1 = dyn_cast_or_null<DeclRefExpr>(E1))
9994 if (
const DeclRefExpr *D2 = dyn_cast_or_null<DeclRefExpr>(E2))
9995 return D1->getDecl() == D2->getDecl();
10000 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
10004 return CE->getArg(0)->IgnoreParenCasts();
10012 void Sema::CheckStrncatArguments(
const CallExpr *CE,
10027 unsigned PatternType = 0;
10035 }
else if (
const BinaryOperator *BE = dyn_cast<BinaryOperator>(LenArg)) {
10036 if (BE->getOpcode() == BO_Sub) {
10049 if (PatternType == 0)
10068 if (!isKnownSizeArray) {
10069 if (PatternType == 1)
10070 Diag(SL, diag::warn_strncat_wrong_size) << SR;
10072 Diag(SL, diag::warn_strncat_src_size) << SR;
10076 if (PatternType == 1)
10077 Diag(SL, diag::warn_strncat_large_size) << SR;
10079 Diag(SL, diag::warn_strncat_src_size) << SR;
10082 llvm::raw_svector_ostream OS(sizeString);
10084 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
10087 DstArg->
printPretty(OS,
nullptr, getPrintingPolicy());
10090 Diag(SL, diag::note_strncat_wrong_size)
10095 Sema::CheckReturnValExpr(
Expr *RetValExp,
QualType lhsType,
10101 if (((Attrs && hasSpecificAttr<ReturnsNonNullAttr>(*Attrs)) ||
10104 Diag(ReturnLoc, diag::warn_null_ret)
10114 if (Op == OO_New || Op == OO_Array_New) {
10119 Diag(ReturnLoc, diag::warn_operator_new_returns_null)
10120 << FD << getLangOpts().CPlusPlus11;
10136 if (
DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(LeftExprSansParen))
10137 if (
DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(RightExprSansParen))
10138 if (DRL->getDecl() == DRR->getDecl())
10146 if (
FloatingLiteral* FLL = dyn_cast<FloatingLiteral>(LeftExprSansParen)) {
10147 if (FLL->isExact())
10150 if (
FloatingLiteral* FLR = dyn_cast<FloatingLiteral>(RightExprSansParen))
10151 if (FLR->isExact())
10155 if (
CallExpr* CL = dyn_cast<CallExpr>(LeftExprSansParen))
10156 if (CL->getBuiltinCallee())
10159 if (
CallExpr* CR = dyn_cast<CallExpr>(RightExprSansParen))
10160 if (CR->getBuiltinCallee())
10164 Diag(Loc, diag::warn_floatingpoint_eq)
10182 IntRange(
unsigned Width,
bool NonNegative)
10183 : Width(Width), NonNegative(NonNegative) {}
10186 static IntRange forBoolType() {
10187 return IntRange(1,
true);
10192 return forValueOfCanonicalType(C,
10197 static IntRange forValueOfCanonicalType(
ASTContext &C,
const Type *T) {
10200 if (
const VectorType *VT = dyn_cast<VectorType>(T))
10201 T = VT->getElementType().getTypePtr();
10202 if (
const ComplexType *CT = dyn_cast<ComplexType>(T))
10203 T = CT->getElementType().getTypePtr();
10204 if (
const AtomicType *AT = dyn_cast<AtomicType>(T))
10205 T = AT->getValueType().getTypePtr();
10209 if (
const EnumType *ET = dyn_cast<EnumType>(T))
10210 T = ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
10211 }
else if (
const EnumType *ET = dyn_cast<EnumType>(T)) {
10218 !ET->isSignedIntegerOrEnumerationType());
10224 if (NumNegative == 0)
10225 return IntRange(NumPositive,
true);
10227 return IntRange(
std::max(NumPositive + 1, NumNegative),
10242 static IntRange forTargetOfCanonicalType(
ASTContext &C,
const Type *T) {
10245 if (
const VectorType *VT = dyn_cast<VectorType>(T))
10246 T = VT->getElementType().getTypePtr();
10247 if (
const ComplexType *CT = dyn_cast<ComplexType>(T))
10248 T = CT->getElementType().getTypePtr();
10249 if (
const AtomicType *AT = dyn_cast<AtomicType>(T))
10250 T = AT->getValueType().getTypePtr();
10251 if (
const EnumType *ET = dyn_cast<EnumType>(T))
10261 static IntRange join(IntRange L, IntRange R) {
10262 return IntRange(
std::max(L.Width, R.Width),
10263 L.NonNegative && R.NonNegative);
10267 static IntRange meet(IntRange L, IntRange R) {
10268 return IntRange(
std::min(L.Width, R.Width),
10269 L.NonNegative || R.NonNegative);
10276 unsigned MaxWidth) {
10277 if (value.isSigned() && value.isNegative())
10278 return IntRange(value.getMinSignedBits(),
false);
10280 if (value.getBitWidth() > MaxWidth)
10281 value = value.trunc(MaxWidth);
10285 return IntRange(value.getActiveBits(),
true);
10289 unsigned MaxWidth) {
10290 if (result.
isInt())
10297 R = IntRange::join(R, El);
10305 return IntRange::join(R, I);
10320 Ty = AtomicRHS->getValueType();
10329 bool InConstantContext) {
10340 if (
const auto *CE = dyn_cast<ImplicitCastExpr>(E)) {
10341 if (CE->getCastKind() == CK_NoOp || CE->getCastKind() == CK_LValueToRValue)
10342 return GetExprRange(C, CE->getSubExpr(), MaxWidth, InConstantContext);
10344 IntRange OutputTypeRange = IntRange::forValueOfType(C,
GetExprType(CE));
10346 bool isIntegerCast = CE->getCastKind() == CK_IntegralCast ||
10347 CE->getCastKind() == CK_BooleanToSignedIntegral;
10350 if (!isIntegerCast)
10351 return OutputTypeRange;
10354 std::min(MaxWidth, OutputTypeRange.Width),
10355 InConstantContext);
10358 if (SubRange.Width >= OutputTypeRange.Width)
10359 return OutputTypeRange;
10363 return IntRange(SubRange.Width,
10364 SubRange.NonNegative || OutputTypeRange.NonNegative);
10367 if (
const auto *CO = dyn_cast<ConditionalOperator>(E)) {
10370 if (CO->getCond()->EvaluateAsBooleanCondition(CondResult, C))
10372 CondResult ? CO->getTrueExpr() : CO->getFalseExpr(),
10373 MaxWidth, InConstantContext);
10377 GetExprRange(C, CO->getTrueExpr(), MaxWidth, InConstantContext);
10379 GetExprRange(C, CO->getFalseExpr(), MaxWidth, InConstantContext);
10380 return IntRange::join(L, R);
10383 if (
const auto *BO = dyn_cast<BinaryOperator>(E)) {
10384 switch (BO->getOpcode()) {
10386 llvm_unreachable(
"builtin <=> should have class type");
10397 return IntRange::forBoolType();
10409 return IntRange::forValueOfType(C,
GetExprType(E));
10415 return GetExprRange(C, BO->getRHS(), MaxWidth, InConstantContext);
10420 return IntRange::forValueOfType(C,
GetExprType(E));
10425 return IntRange::meet(
10426 GetExprRange(C, BO->getLHS(), MaxWidth, InConstantContext),
10427 GetExprRange(C, BO->getRHS(), MaxWidth, InConstantContext));
10434 = dyn_cast<IntegerLiteral>(BO->getLHS()->IgnoreParenCasts())) {
10435 if (I->getValue() == 1) {
10436 IntRange R = IntRange::forValueOfType(C,
GetExprType(E));
10437 return IntRange(R.Width,
true);
10443 return IntRange::forValueOfType(C,
GetExprType(E));
10447 case BO_ShrAssign: {
10448 IntRange L =
GetExprRange(C, BO->getLHS(), MaxWidth, InConstantContext);
10453 if (BO->getRHS()->isIntegerConstantExpr(shift, C) &&
10454 shift.isNonNegative()) {
10455 unsigned zext = shift.getZExtValue();
10456 if (zext >= L.Width)
10457 L.Width = (L.NonNegative ? 0 : 1);
10467 return GetExprRange(C, BO->getRHS(), MaxWidth, InConstantContext);
10471 if (BO->getLHS()->getType()->isPointerType())
10472 return IntRange::forValueOfType(C,
GetExprType(E));
10480 IntRange L =
GetExprRange(C, BO->getLHS(), opWidth, InConstantContext);
10484 if (BO->getRHS()->isIntegerConstantExpr(divisor, C)) {
10485 unsigned log2 = divisor.logBase2();
10486 if (log2 >= L.Width)
10487 L.Width = (L.NonNegative ? 0 : 1);
10489 L.Width =
std::min(L.Width - log2, MaxWidth);
10494 IntRange R =
GetExprRange(C, BO->getRHS(), opWidth, InConstantContext);
10495 return IntRange(L.Width, L.NonNegative && R.NonNegative);
10503 IntRange L =
GetExprRange(C, BO->getLHS(), opWidth, InConstantContext);
10504 IntRange R =
GetExprRange(C, BO->getRHS(), opWidth, InConstantContext);
10506 IntRange meet = IntRange::meet(L, R);
10507 meet.Width =
std::min(meet.Width, MaxWidth);
10521 IntRange L =
GetExprRange(C, BO->getLHS(), MaxWidth, InConstantContext);
10522 IntRange R =
GetExprRange(C, BO->getRHS(), MaxWidth, InConstantContext);
10523 return IntRange::join(L, R);
10526 if (
const auto *UO = dyn_cast<UnaryOperator>(E)) {
10527 switch (UO->getOpcode()) {
10530 return IntRange::forBoolType();
10535 return IntRange::forValueOfType(C,
GetExprType(E));
10538 return GetExprRange(C, UO->getSubExpr(), MaxWidth, InConstantContext);
10542 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
10543 return GetExprRange(C, OVE->getSourceExpr(), MaxWidth, InConstantContext);
10546 return IntRange(BitField->getBitWidthValue(C),
10547 BitField->getType()->isUnsignedIntegerOrEnumerationType());
10549 return IntRange::forValueOfType(C,
GetExprType(E));
10553 bool InConstantContext) {
10561 const llvm::fltSemantics &Src,
10562 const llvm::fltSemantics &Tgt) {
10563 llvm::APFloat truncated = value;
10566 truncated.convert(Src, llvm::APFloat::rmNearestTiesToEven, &ignored);
10567 truncated.convert(Tgt, llvm::APFloat::rmNearestTiesToEven, &ignored);
10569 return truncated.bitwiseIsEqual(value);
10578 const llvm::fltSemantics &Src,
10579 const llvm::fltSemantics &Tgt) {
10596 bool IsListInit =
false);
10602 if (isa<EnumConstantDecl>(DR->getDecl()))
10612 return MacroName !=
"YES" && MacroName !=
"NO" &&
10613 MacroName !=
"true" && MacroName !=
"false";
10636 struct PromotedRange {
10642 PromotedRange(IntRange R,
unsigned BitWidth,
bool Unsigned) {
10644 PromotedMin = PromotedMax =
llvm::APSInt(BitWidth, Unsigned);
10645 else if (R.Width >= BitWidth && !Unsigned) {
10649 PromotedMin = llvm::APSInt::getMinValue(BitWidth, Unsigned);
10650 PromotedMax = llvm::APSInt::getMaxValue(BitWidth, Unsigned);
10652 PromotedMin = llvm::APSInt::getMinValue(R.Width, R.NonNegative)
10653 .extOrTrunc(BitWidth);
10654 PromotedMin.setIsUnsigned(Unsigned);
10656 PromotedMax = llvm::APSInt::getMaxValue(R.Width, R.NonNegative)
10657 .extOrTrunc(BitWidth);
10658 PromotedMax.setIsUnsigned(Unsigned);
10663 bool isContiguous()
const {
return PromotedMin <= PromotedMax; }
10666 enum ComparisonResult {
10673 InRangeFlag = 0x40,
10676 Min =
LE | InRangeFlag,
10678 Max =
GE | InRangeFlag,
10681 OnlyValue =
LE |
GE |
EQ | InRangeFlag,
10686 assert(Value.getBitWidth() == PromotedMin.getBitWidth() &&
10687 Value.isUnsigned() == PromotedMin.isUnsigned());
10688 if (!isContiguous()) {
10689 assert(Value.isUnsigned() &&
"discontiguous range for signed compare");
10690 if (Value.isMinValue())
return Min;
10691 if (Value.isMaxValue())
return Max;
10692 if (Value >= PromotedMin)
return InRange;
10693 if (Value <= PromotedMax)
return InRange;
10697 switch (llvm::APSInt::compareValues(Value, PromotedMin)) {
10698 case -1:
return Less;
10699 case 0:
return PromotedMin == PromotedMax ? OnlyValue : Min;
10701 switch (llvm::APSInt::compareValues(Value, PromotedMax)) {
10703 case 0:
return Max;
10708 llvm_unreachable(
"impossible compare result");
10713 if (Op == BO_Cmp) {
10714 ComparisonResult LTFlag =
LT, GTFlag =
GT;
10715 if (ConstantOnRHS) std::swap(LTFlag, GTFlag);
10717 if (R &
EQ)
return StringRef(
"'std::strong_ordering::equal'");
10718 if (R & LTFlag)
return StringRef(
"'std::strong_ordering::less'");
10719 if (R & GTFlag)
return StringRef(
"'std::strong_ordering::greater'");
10723 ComparisonResult TrueFlag, FalseFlag;
10727 }
else if (Op == BO_NE) {
10731 if ((Op == BO_LT || Op == BO_GE) ^ ConstantOnRHS) {
10738 if (Op == BO_GE || Op == BO_LE)
10739 std::swap(TrueFlag, FalseFlag);
10742 return StringRef(
"true");
10744 return StringRef(
"false");
10753 if (ICE->getCastKind() != CK_IntegralCast &&
10754 ICE->getCastKind() != CK_NoOp)
10756 E = ICE->getSubExpr();
10765 enum ConstantValueKind {
10770 if (
auto *BL = dyn_cast<CXXBoolLiteralExpr>(Constant))
10771 return BL->getValue() ? ConstantValueKind::LiteralTrue
10772 : ConstantValueKind::LiteralFalse;
10773 return ConstantValueKind::Miscellaneous;
10779 bool RhsConstant) {
10783 Expr *OriginalOther = Other;
10803 OtherT = AT->getValueType();
10804 IntRange OtherRange = IntRange::forValueOfType(S.
Context, OtherT);
10808 bool IsObjCSignedCharBool = S.
getLangOpts().ObjC &&
10809 S.
NSAPIObj->isObjCBOOLType(OtherT) &&
10814 bool OtherIsBooleanDespiteType =
10816 if (OtherIsBooleanDespiteType || IsObjCSignedCharBool)
10817 OtherRange = IntRange::forBoolType();
10821 PromotedRange OtherPromotedRange(OtherRange, Value.getBitWidth(),
10822 Value.isUnsigned());
10823 auto Cmp = OtherPromotedRange.compare(Value);
10824 auto Result = PromotedRange::constantValue(E->
getOpcode(), Cmp, RhsConstant);
10834 bool InRange = Cmp & PromotedRange::InRangeFlag;
10841 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Constant))
10842 ED = dyn_cast<EnumConstantDecl>(DR->getDecl());
10846 llvm::raw_svector_ostream OS(PrettySourceValue);
10848 OS <<
'\'' << *ED <<
"' (" << Value <<
")";
10849 }
else if (
auto *BL = dyn_cast<ObjCBoolLiteralExpr>(
10851 OS << (BL->getValue() ?
"YES" :
"NO");
10856 if (IsObjCSignedCharBool) {
10858 S.
PDiag(diag::warn_tautological_compare_objc_bool)
10859 << OS.str() << *Result);
10870 S.
PDiag(!InRange ? diag::warn_out_of_range_compare
10871 : diag::warn_tautological_bool_compare)
10873 << OtherIsBooleanDespiteType << *Result
10878 ? diag::warn_unsigned_enum_always_true_comparison
10879 : diag::warn_unsigned_always_true_comparison)
10880 : diag::warn_tautological_constant_compare;
10883 << RhsConstant << OtherT << E->
getOpcodeStr() << OS.str() << *Result
10924 if (IsRHSIntegralLiteral && IsLHSIntegralLiteral)
10928 if (IsRHSIntegralLiteral ^ IsLHSIntegralLiteral) {
10930 const bool RhsConstant = IsRHSIntegralLiteral;
10932 Expr *Other = RhsConstant ? LHS : RHS;
10956 if (
const auto *TET = dyn_cast<TypeOfExprType>(LHS->
getType()))
10958 if (
const auto *TET = dyn_cast<TypeOfExprType>(RHS->
getType()))
10964 Expr *signedOperand, *unsignedOperand;
10967 "unsigned comparison between two signed integer expressions?");
10968 signedOperand = LHS;
10969 unsignedOperand = RHS;
10971 signedOperand = RHS;
10972 unsignedOperand = LHS;
10978 IntRange signedRange =
10987 if (signedRange.NonNegative)
10996 IntRange unsignedRange =
11001 assert(unsignedRange.NonNegative &&
"unsigned range includes negative?");
11003 if (unsignedRange.Width < comparisonWidth)
11008 S.
PDiag(diag::warn_mixed_sign_comparison)
11036 S.
Diag(InitLoc, diag::warn_no_underlying_type_specified_for_enum_bitfield)
11074 unsigned DiagID = 0;
11075 if (SignedEnum && !SignedBitfield) {
11076 DiagID = diag::warn_unsigned_bitfield_assigned_signed_enum;
11077 }
else if (SignedBitfield && !SignedEnum &&
11079 DiagID = diag::warn_signed_bitfield_enum_conversion;
11083 S.
Diag(InitLoc, DiagID) << Bitfield << ED;
11088 << SignedEnum << TypeRange;
11099 if (BitsNeeded > FieldWidth) {
11101 S.
Diag(InitLoc, diag::warn_bitfield_too_small_for_enum)
11113 unsigned OriginalWidth = Value.getBitWidth();
11115 if (!Value.isSigned() || Value.isNegative())
11116 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(OriginalInit))
11117 if (UO->getOpcode() == UO_Minus || UO->getOpcode() == UO_Not)
11118 OriginalWidth = Value.getMinSignedBits();
11120 if (OriginalWidth <= FieldWidth)
11124 llvm::APSInt TruncatedValue = Value.trunc(FieldWidth);
11128 TruncatedValue = TruncatedValue.extend(OriginalWidth);
11129 if (llvm::APSInt::isSameValue(Value, TruncatedValue))
11134 if (FieldWidth == 1 && Value == 1)
11137 std::string PrettyValue = Value.toString(10);
11138 std::string PrettyTrunc = TruncatedValue.toString(10);
11140 S.
Diag(InitLoc, diag::warn_impcast_bitfield_precision_constant)
11141 << PrettyValue << PrettyTrunc << OriginalInit->
getType()
11174 bool pruneControlFlow =
false) {
11175 if (pruneControlFlow) {
11189 unsigned diag,
bool pruneControlFlow =
false) {
11201 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(Ignored))
11202 Ignored = OVE->getSourceExpr();
11203 bool NeedsParens = isa<AbstractConditionalOperator>(Ignored) ||
11204 isa<BinaryOperator>(Ignored) ||
11205 isa<CXXOperatorCallExpr>(Ignored);
11222 if (UOp->getOpcode() == UO_Minus || UOp->getOpcode() == UO_Plus)
11225 const bool IsLiteral =
11226 isa<FloatingLiteral>(E) || isa<FloatingLiteral>(InnerE);
11228 llvm::APFloat
Value(0.0);
11235 S.
Diag(CContext, diag::warn_impcast_float_to_objc_signed_char_bool)
11240 diag::warn_impcast_float_integer, PruneWarnings);
11243 bool isExact =
false;
11247 llvm::APFloat::opStatus Result = Value.convertToInteger(
11248 IntegerValue, llvm::APFloat::rmTowardZero, &isExact);
11256 unsigned precision = llvm::APFloat::semanticsPrecision(Value.getSemantics());
11257 precision = (precision * 59 + 195) / 196;
11258 Value.toString(PrettySourceValue, precision);
11263 S.
Diag(CContext, diag::warn_impcast_constant_value_to_objc_bool)
11264 << PrettySourceValue);
11267 if (Result == llvm::APFloat::opOK && isExact) {
11268 if (IsLiteral)
return;
11269 return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer,
11275 if (!IsBool && Result == llvm::APFloat::opInvalidOp)
11278 IsLiteral ? diag::warn_impcast_literal_float_to_integer_out_of_range
11279 : diag::warn_impcast_float_to_integer_out_of_range,
11282 unsigned DiagID = 0;
11285 DiagID = diag::warn_impcast_literal_float_to_integer;
11286 }
else if (IntegerValue == 0) {
11287 if (Value.isZero()) {
11289 diag::warn_impcast_float_integer, PruneWarnings);
11292 DiagID = diag::warn_impcast_float_to_integer_zero;
11294 if (IntegerValue.isUnsigned()) {
11295 if (!IntegerValue.isMaxValue()) {
11297 diag::warn_impcast_float_integer, PruneWarnings);
11300 if (!IntegerValue.isMaxSignedValue() &&
11301 !IntegerValue.isMinSignedValue()) {
11303 diag::warn_impcast_float_integer, PruneWarnings);
11307 DiagID = diag::warn_impcast_float_to_integer;
11312 PrettyTargetValue = Value.isZero() ?
"false" :
"true";
11314 IntegerValue.toString(PrettyTargetValue);
11316 if (PruneWarnings) {
11320 << PrettySourceValue << PrettyTargetValue
11332 assert(isa<CompoundAssignOperator>(E) &&
11333 "Must be compound assignment operation");
11343 const auto *RBT = cast<CompoundAssignOperator>(E)
11344 ->getComputationResultType()
11351 if (ResultBT->isInteger())
11353 E->
getExprLoc(), diag::warn_impcast_float_integer);
11355 if (!ResultBT->isFloatingPoint())
11364 diag::warn_impcast_float_result_precision);
11369 if (!Range.Width)
return "0";
11372 ValueInRange.setIsSigned(!Range.NonNegative);
11373 ValueInRange = ValueInRange.trunc(Range.Width);
11374 return ValueInRange.toString(10);
11378 if (!isa<ImplicitCastExpr>(Ex))
11383 const Type *Source =
11390 const Type *BoolCandidateType = ToBool ? Target : Source;
11392 return (BoolCandidateType->isSpecificBuiltinType(BuiltinType::Bool) &&
11399 for (
unsigned i = 0; i < NumArgs; ++i) {
11404 bool IsSwapped = ((i > 0) &&
11406 IsSwapped |= ((i < (NumArgs - 1)) &&
11412 diag::warn_impcast_floating_point_to_bool);
11419 if (S.
Diags.
isIgnored(diag::warn_impcast_null_pointer_to_integer,
11424 if (isa<CallExpr>(E))
11450 if (MacroName ==
"NULL")
11458 S.
Diag(Loc, diag::warn_impcast_null_pointer_to_integer)
11476 unsigned ElementKind) {
11478 if (
auto ICE = dyn_cast<ImplicitCastExpr>(Element)) {
11479 if (ICE->getCastKind() == CK_BitCast &&
11481 Element = ICE->getSubExpr();
11491 S.
Diag(Element->
getBeginLoc(), diag::warn_objc_collection_literal_element)
11492 << ElementType << ElementKind << TargetElementType
11496 if (
auto ArrayLiteral = dyn_cast<ObjCArrayLiteral>(Element))
11498 else if (
auto DictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(Element))
11510 if (!TargetObjCPtr)
11513 if (TargetObjCPtr->isUnspecialized() ||
11514 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
11519 if (TypeArgs.size() != 1)
11522 QualType TargetElementType = TypeArgs[0];
11523 for (
unsigned I = 0, N = ArrayLiteral->
getNumElements(); I != N; ++I) {
11539 if (!TargetObjCPtr)
11542 if (TargetObjCPtr->isUnspecialized() ||
11543 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
11548 if (TypeArgs.size() != 2)
11551 QualType TargetKeyType = TypeArgs[0];
11552 QualType TargetObjectType = TypeArgs[1];
11553 for (
unsigned I = 0, N = DictionaryLiteral->
getNumElements(); I != N; ++I) {
11568 const char FirstLiteralCharacter =
11570 if (FirstLiteralCharacter ==
'0')
11577 const char FirstContextCharacter =
11579 if (FirstContextCharacter ==
'{')
11589 if (
auto *UO = dyn_cast<UnaryOperator>(E)) {
11590 if (UO->getOpcode() == UO_Minus)
11591 return dyn_cast<IntegerLiteral>(UO->getSubExpr());
11602 if (
const auto *BO = dyn_cast<BinaryOperator>(E)) {
11606 if (Opc == BO_Shl) {
11609 if (LHS && LHS->getValue() == 0)
11610 S.
Diag(ExprLoc, diag::warn_left_shift_always) << 0;
11612 RHS->getValue().isNonNegative() &&
11614 S.
Diag(ExprLoc, diag::warn_left_shift_always)
11617 S.
Diag(ExprLoc, diag::warn_left_shift_in_bool_context) << E;
11621 if (
const auto *CO = dyn_cast<ConditionalOperator>(E)) {
11626 if ((LHS->getValue() == 0 || LHS->getValue() == 1) &&
11627 (RHS->getValue() == 0 || RHS->getValue() == 1))
11630 if (LHS->getValue() != 0 && RHS->getValue() != 0)
11631 S.
Diag(ExprLoc, diag::warn_integer_constants_in_conditional_always_true);
11637 bool *ICContext =
nullptr,
11638 bool IsListInit =
false) {
11643 if (Source == Target)
return;
11659 if (isa<StringLiteral>(E))
11664 diag::warn_impcast_string_literal_to_bool);
11665 if (isa<ObjCStringLiteral>(E) || isa<ObjCArrayLiteral>(E) ||
11666 isa<ObjCDictionaryLiteral>(E) || isa<ObjCBoxedExpr>(E)) {
11670 diag::warn_impcast_objective_c_literal_to_bool);
11689 S.
Diag(CC, diag::warn_impcast_constant_value_to_objc_bool)
11698 if (
auto *ArrayLiteral = dyn_cast<ObjCArrayLiteral>(E))
11700 else if (
auto *DictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(E))
11704 if (isa<VectorType>(Source)) {
11705 if (!isa<VectorType>(Target)) {
11708 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_vector_scalar);
11716 Source = cast<VectorType>(Source)->getElementType().getTypePtr();
11717 Target = cast<VectorType>(Target)->getElementType().getTypePtr();
11719 if (
auto VecTy = dyn_cast<VectorType>(Target))
11720 Target = VecTy->getElementType().getTypePtr();
11723 if (isa<ComplexType>(Source)) {
11724 if (!isa<ComplexType>(Target)) {
11730 ? diag::err_impcast_complex_scalar
11731 : diag::warn_impcast_complex_scalar);
11734 Source = cast<ComplexType>(Source)->getElementType().getTypePtr();
11735 Target = cast<ComplexType>(Target)->getElementType().getTypePtr();
11744 if (TargetBT && TargetBT->isFloatingPoint()) {
11767 else if (Order < 0) {
11777 if (TargetBT && TargetBT->isInteger()) {
11796 CallExpr *CEx = cast<CallExpr>(E);
11800 if (isa<ImplicitCastExpr>(LastA) &&
11804 diag::warn_impcast_floating_point_to_bool);
11820 if (Value > MaxVal || Value < MinVal) {
11822 S.
PDiag(diag::warn_impcast_fixed_point_range)
11843 S.
PDiag(diag::warn_impcast_fixed_point_range)
11864 S.
PDiag(diag::warn_impcast_fixed_point_range)
11865 << Value.toString(10) << T
11878 TargetBT->isFloatingType() && !IsListInit) {
11881 unsigned int SourcePrecision = SourceRange.Width;
11885 unsigned int TargetPrecision = llvm::APFloatBase::semanticsPrecision(
11888 if (SourcePrecision > 0 && TargetPrecision > 0 &&
11889 SourcePrecision > TargetPrecision) {
11896 llvm::APFloat TargetFloatValue(
11898 llvm::APFloat::opStatus ConversionStatus =
11899 TargetFloatValue.convertFromAPInt(
11901 llvm::APFloat::rmNearestTiesToEven);
11903 if (ConversionStatus != llvm::APFloat::opOK) {
11904 std::string PrettySourceValue = SourceInt.toString(10);
11906 TargetFloatValue.toString(PrettyTargetValue, TargetPrecision);
11910 S.
PDiag(diag::warn_impcast_integer_float_precision_constant)
11911 << PrettySourceValue << PrettyTargetValue << E->
getType() << T
11917 diag::warn_impcast_integer_float_precision);
11941 S.
Diag(CC, diag::warn_impcast_int_to_objc_signed_char_bool)
11946 IntRange TargetRange = IntRange::forTargetOfCanonicalType(S.
Context, Target);
11948 if (SourceRange.Width > TargetRange.Width) {
11960 std::string PrettySourceValue = Value.toString(10);
11965 S.
PDiag(diag::warn_impcast_integer_precision_constant)
11966 << PrettySourceValue << PrettyTargetValue << E->
getType() << T
11976 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_64_32,
11978 return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_integer_precision);
11981 if (TargetRange.Width > SourceRange.Width) {
11982 if (
auto *UO = dyn_cast<UnaryOperator>(E))
11983 if (UO->getOpcode() == UO_Minus)
11987 diag::warn_impcast_high_order_zero_bits);
11990 diag::warn_impcast_nonnegative_result);
11994 if (TargetRange.Width == SourceRange.Width && !TargetRange.NonNegative &&
12005 std::string PrettySourceValue = Value.toString(10);
12010 S.
PDiag(diag::warn_impcast_integer_precision_constant)
12011 << PrettySourceValue << PrettyTargetValue << E->
getType() << T
12020 if ((TargetRange.NonNegative && !SourceRange.NonNegative) ||
12021 (!TargetRange.NonNegative && SourceRange.NonNegative &&
12022 SourceRange.Width == TargetRange.Width)) {
12026 unsigned DiagID = diag::warn_impcast_integer_sign;
12034 DiagID = diag::warn_impcast_integer_sign_conditional;
12048 EnumDecl *Enum = cast<EnumDecl>(ECD->getDeclContext());
12056 if (SourceEnum->getDecl()->hasNameForLinkage() &&
12057 TargetEnum->getDecl()->hasNameForLinkage() &&
12058 SourceEnum != TargetEnum) {
12063 diag::warn_impcast_different_enum_types);
12074 if (isa<ConditionalOperator>(E))
12086 bool Suspicious =
false;
12095 if (!Suspicious)
return;
12098 if (!S.
Diags.
isIgnored(diag::warn_impcast_integer_sign_conditional, CC))
12103 if (E->
getType() == T)
return;
12105 Suspicious =
false;
12107 E->
getType(), CC, &Suspicious);
12110 E->
getType(), CC, &Suspicious);
12135 IsListInit || (isa<InitListExpr>(OrigE) && S.
getLangOpts().CPlusPlus);
12140 if (
const auto *UO = dyn_cast<UnaryOperator>(E))
12141 if (UO->getOpcode() == UO_Not &&
12142 UO->getSubExpr()->isKnownToHaveBooleanValue())
12143 S.
Diag(UO->getBeginLoc(), diag::warn_bitwise_negation_bool)
12149 if (isa<ConditionalOperator>(E)) {
12156 if (
CallExpr *Call = dyn_cast<CallExpr>(E))
12171 for (
auto *SE : POE->semantics())
12172 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(SE))
12177 if (
auto *CE = dyn_cast<ExplicitCastExpr>(E)) {
12186 if (BO->isComparisonOp())
12190 if (BO->getOpcode() == BO_Assign)
12193 if (BO->isAssignmentOp())
12201 if (isa<StmtExpr>(E))
return;
12204 if (isa<UnaryExprOrTypeTraitExpr>(E))
return;
12209 bool IsLogicalAndOperator = BO && BO->
getOpcode() == BO_LAnd;
12211 Expr *ChildExpr = dyn_cast_or_null<Expr>(SubStmt);
12215 if (IsLogicalAndOperator &&
12225 if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
12229 if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
12234 if (U->getOpcode() == UO_LNot) {
12236 }
else if (U->getOpcode() != UO_AddrOf) {
12237 if (U->getSubExpr()->getType()->isAtomicType())
12238 S.
Diag(U->getSubExpr()->getBeginLoc(),
12239 diag::warn_atomic_implicit_seq_cst);
12250 diag::err_opencl_enqueue_kernel_invalid_local_size_type);
12267 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
12268 if (!DRE->getDecl()->getType()->isReferenceType())
12270 }
else if (
const MemberExpr *M = dyn_cast<MemberExpr>(E)) {
12271 if (!M->getMemberDecl()->getType()->isReferenceType())
12273 }
else if (
const CallExpr *Call = dyn_cast<CallExpr>(E)) {
12285 SemaRef.
Diag(FD->
getLocation(), diag::note_reference_is_return_value) << FD;
12330 if (isa<CXXThisExpr>(E)) {
12331 unsigned DiagID = IsCompare ? diag::warn_this_null_compare
12332 : diag::warn_this_bool_conversion;
12337 bool IsAddressOf =
false;
12340 if (UO->getOpcode() != UO_AddrOf)
12342 IsAddressOf =
true;
12343 E = UO->getSubExpr();
12347 unsigned DiagID = IsCompare
12348 ? diag::warn_address_of_reference_null_compare
12349 : diag::warn_address_of_reference_bool_conversion;
12357 auto ComplainAboutNonnullParamOrCall = [&](
const Attr *NonnullAttr) {
12358 bool IsParam = isa<NonNullAttr>(NonnullAttr);
12360 llvm::raw_string_ostream S(Str);
12362 unsigned DiagID = IsCompare ? diag::warn_nonnull_expr_compare
12363 : diag::warn_cast_nonnull_to_bool;
12366 Diag(NonnullAttr->getLocation(), diag::note_declared_nonnull) << IsParam;
12372 if (
const Attr *A = Callee->getAttr<ReturnsNonNullAttr>()) {
12373 ComplainAboutNonnullParamOrCall(A);
12383 }
else if (
MemberExpr *M = dyn_cast<MemberExpr>(E)) {
12384 D = M->getMemberDecl();
12392 if (
const auto* PV = dyn_cast<ParmVarDecl>(D)) {
12393 if (getCurFunction() &&
12394 !getCurFunction()->ModifiedNonNullParams.count(PV)) {
12395 if (
const Attr *A = PV->getAttr<NonNullAttr>()) {
12396 ComplainAboutNonnullParamOrCall(A);
12400 if (
const auto *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
12404 auto ParamIter = llvm::find(FD->
parameters(), PV);
12410 ComplainAboutNonnullParamOrCall(
NonNull);
12415 if (ArgNo.getASTIndex() == ParamNo) {
12416 ComplainAboutNonnullParamOrCall(
NonNull);
12430 if (IsAddressOf && IsFunction) {
12435 if (!IsAddressOf && !IsFunction && !IsArray)
12440 llvm::raw_string_ostream S(Str);
12443 unsigned DiagID = IsCompare ? diag::warn_null_pointer_compare
12444 : diag::warn_impcast_pointer_to_bool;
12451 DiagType = AddressOf;
12452 else if (IsFunction)
12453 DiagType = FunctionPointer;
12455 DiagType = ArrayPointer;
12457 llvm_unreachable(
"Could not determine diagnostic.");
12459 << Range << IsEqual;
12471 tryExprAsCall(*E, ReturnType, NonTemplateOverloads);
12472 if (ReturnType.isNull())
12479 if (!ReturnType->isPointerType()) {
12482 if (!ReturnType->isIntegerType())
12491 if (!ReturnType->isSpecificBuiltinType(BuiltinType::Bool))
12507 if (isUnevaluatedContext())
12517 CheckArrayAccess(E);
12531 void Sema::CheckForIntOverflow (
Expr *E) {
12536 Expr *OriginalE = Exprs.pop_back_val();
12539 if (isa<BinaryOperator>(E)) {
12544 if (
auto InitList = dyn_cast<InitListExpr>(OriginalE))
12545 Exprs.append(InitList->inits().begin(), InitList->inits().end());
12546 else if (isa<ObjCBoxedExpr>(OriginalE))
12548 else if (
auto Call = dyn_cast<CallExpr>(E))
12550 else if (
auto Message = dyn_cast<ObjCMessageExpr>(E))
12551 Exprs.append(Message->arg_begin(), Message->arg_end());
12552 }
while (!Exprs.empty());
12567 class SequenceTree {
12571 unsigned Merged : 1;
12579 friend class SequenceTree;
12583 explicit Seq(
unsigned N) : Index(N) {}
12586 Seq() : Index(0) {}
12589 SequenceTree() { Values.push_back(
Value(0)); }
12590 Seq root()
const {
return Seq(0); }
12595 Seq allocate(Seq
Parent) {
12596 Values.push_back(
Value(Parent.Index));
12597 return Seq(Values.size() - 1);
12601 void merge(Seq S) {
12602 Values[S.Index].Merged =
true;
12608 bool isUnsequenced(Seq Cur, Seq Old) {
12609 unsigned C = representative(Cur.Index);
12610 unsigned Target = representative(Old.Index);
12611 while (C >= Target) {
12614 C = Values[
C].Parent;
12621 unsigned representative(
unsigned K) {
12622 if (Values[K].Merged)
12624 return Values[K].Parent = representative(Values[K].Parent);
12644 UK_ModAsSideEffect,
12646 UK_Count = UK_ModAsSideEffect + 1
12652 const Expr *UsageExpr;
12653 SequenceTree::Seq Seq;
12655 Usage() : UsageExpr(
nullptr), Seq() {}
12659 Usage Uses[UK_Count];
12664 UsageInfo() : Uses(), Diagnosed(
false) {}
12666 using UsageInfoMap = llvm::SmallDenseMap<Object, UsageInfo, 16>;
12674 UsageInfoMap UsageMap;
12677 SequenceTree::Seq Region;
12692 struct SequencedSubexpression {
12693 SequencedSubexpression(SequenceChecker &Self)
12694 : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) {
12695 Self.ModAsSideEffect = &ModAsSideEffect;
12698 ~SequencedSubexpression() {
12699 for (
const std::pair<Object, Usage> &M : llvm::reverse(ModAsSideEffect)) {
12703 UsageInfo &UI = Self.UsageMap[M.first];
12704 auto &SideEffectUsage = UI.Uses[UK_ModAsSideEffect];
12705 Self.addUsage(M.first, UI, SideEffectUsage.UsageExpr, UK_ModAsValue);
12706 SideEffectUsage = M.second;
12708 Self.ModAsSideEffect = OldModAsSideEffect;
12711 SequenceChecker &Self;
12720 class EvaluationTracker {
12722 EvaluationTracker(SequenceChecker &Self)
12723 : Self(Self), Prev(Self.EvalTracker) {
12724 Self.EvalTracker =
this;
12727 ~EvaluationTracker() {
12728 Self.EvalTracker = Prev;
12730 Prev->EvalOK &= EvalOK;
12733 bool evaluate(
const Expr *E,
bool &Result) {
12737 Result, Self.SemaRef.Context, Self.SemaRef.isConstantEvaluated());
12742 SequenceChecker &Self;
12743 EvaluationTracker *Prev;
12744 bool EvalOK =
true;
12745 } *EvalTracker =
nullptr;
12749 Object getObject(
const Expr *E,
bool Mod)
const {
12751 if (
const UnaryOperator *UO = dyn_cast<UnaryOperator>(E)) {
12752 if (Mod && (UO->getOpcode() == UO_PreInc || UO->getOpcode() == UO_PreDec))
12753 return getObject(UO->getSubExpr(), Mod);
12754 }
else if (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
12755 if (BO->getOpcode() == BO_Comma)
12756 return getObject(BO->getRHS(), Mod);
12757 if (Mod && BO->isAssignmentOp())
12758 return getObject(BO->getLHS(), Mod);
12759 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
12761 if (isa<CXXThisExpr>(ME->getBase()->IgnoreParenCasts()))
12762 return ME->getMemberDecl();
12763 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
12765 return DRE->getDecl();
12772 void addUsage(Object O, UsageInfo &UI,
const Expr *UsageExpr, UsageKind UK) {
12774 Usage &U = UI.Uses[UK];
12775 if (!U.UsageExpr || !Tree.isUnsequenced(Region, U.Seq)) {
12779 if (UK == UK_ModAsSideEffect && ModAsSideEffect)
12780 ModAsSideEffect->push_back(std::make_pair(O, U));
12782 U.UsageExpr = UsageExpr;
12792 void checkUsage(Object O, UsageInfo &UI,
const Expr *UsageExpr,
12793 UsageKind OtherKind,
bool IsModMod) {
12797 const Usage &U = UI.Uses[OtherKind];
12798 if (!U.UsageExpr || !Tree.isUnsequenced(Region, U.Seq))
12801 const Expr *Mod = U.UsageExpr;
12802 const Expr *ModOrUse = UsageExpr;
12803 if (OtherKind == UK_Use)
12804 std::swap(Mod, ModOrUse);
12808 SemaRef.
PDiag(IsModMod ? diag::warn_unsequenced_mod_mod
12809 : diag::warn_unsequenced_mod_use)
12811 UI.Diagnosed =
true;
12840 void notePreUse(Object O,
const Expr *UseExpr) {
12841 UsageInfo &UI = UsageMap[O];
12843 checkUsage(O, UI, UseExpr, UK_ModAsValue,
false);
12846 void notePostUse(Object O,
const Expr *UseExpr) {
12847 UsageInfo &UI = UsageMap[O];
12848 checkUsage(O, UI, UseExpr, UK_ModAsSideEffect,
12850 addUsage(O, UI, UseExpr, UK_Use);
12853 void notePreMod(Object O,
const Expr *ModExpr) {
12854 UsageInfo &UI = UsageMap[O];
12856 checkUsage(O, UI, ModExpr, UK_ModAsValue,
true);
12857 checkUsage(O, UI, ModExpr, UK_Use,
false);
12860 void notePostMod(Object O,
const Expr *ModExpr, UsageKind UK) {
12861 UsageInfo &UI = UsageMap[O];
12862 checkUsage(O, UI, ModExpr, UK_ModAsSideEffect,
12864 addUsage(O, UI, ModExpr, UK);
12868 SequenceChecker(
Sema &S,
const Expr *E,
12870 :
Base(S.
Context), SemaRef(S), Region(Tree.root()), WorkList(WorkList) {
12874 (void)this->WorkList;
12877 void VisitStmt(
const Stmt *S) {
12881 void VisitExpr(
const Expr *E) {
12883 Base::VisitStmt(E);
12886 void VisitCastExpr(
const CastExpr *E) {
12887 Object O = Object();
12898 void VisitSequencedExpressions(
const Expr *SequencedBefore,
12899 const Expr *SequencedAfter) {
12900 SequenceTree::Seq BeforeRegion = Tree.allocate(Region);
12901 SequenceTree::Seq AfterRegion = Tree.allocate(Region);
12902 SequenceTree::Seq OldRegion = Region;
12905 SequencedSubexpression SeqBefore(*
this);
12906 Region = BeforeRegion;
12907 Visit(SequencedBefore);
12910 Region = AfterRegion;
12911 Visit(SequencedAfter);
12913 Region = OldRegion;
12915 Tree.merge(BeforeRegion);
12916 Tree.merge(AfterRegion);
12924 VisitSequencedExpressions(ASE->
getLHS(), ASE->
getRHS());
12931 void VisitBinPtrMemD(
const BinaryOperator *BO) { VisitBinPtrMem(BO); }
12932 void VisitBinPtrMemI(
const BinaryOperator *BO) { VisitBinPtrMem(BO); }
12938 VisitSequencedExpressions(BO->
getLHS(), BO->
getRHS());
12945 void VisitBinShl(
const BinaryOperator *BO) { VisitBinShlShr(BO); }
12946 void VisitBinShr(
const BinaryOperator *BO) { VisitBinShlShr(BO); }
12951 VisitSequencedExpressions(BO->
getLHS(), BO->
getRHS());
12963 VisitSequencedExpressions(BO->
getLHS(), BO->
getRHS());
12967 SequenceTree::Seq RHSRegion;
12968 SequenceTree::Seq LHSRegion;
12970 RHSRegion = Tree.allocate(Region);
12971 LHSRegion = Tree.allocate(Region);
12973 RHSRegion = Region;
12974 LHSRegion = Region;
12976 SequenceTree::Seq OldRegion = Region;
12984 Object O = getObject(BO->
getLHS(),
true);
12992 SequencedSubexpression SeqBefore(*
this);
12993 Region = RHSRegion;
12997 Region = LHSRegion;
13000 if (O && isa<CompoundAssignOperator>(BO))
13001 notePostUse(O, BO);
13005 Region = LHSRegion;
13008 if (O && isa<CompoundAssignOperator>(BO))
13009 notePostUse(O, BO);
13011 Region = RHSRegion;
13019 Region = OldRegion;
13023 : UK_ModAsSideEffect);
13025 Tree.merge(RHSRegion);
13026 Tree.merge(LHSRegion);
13031 VisitBinAssign(CAO);
13034 void VisitUnaryPreInc(
const UnaryOperator *UO) { VisitUnaryPreIncDec(UO); }
13035 void VisitUnaryPreDec(
const UnaryOperator *UO) { VisitUnaryPreIncDec(UO); }
13037 Object O = getObject(UO->
getSubExpr(),
true);
13039 return VisitExpr(UO);
13047 : UK_ModAsSideEffect);
13050 void VisitUnaryPostInc(
const UnaryOperator *UO) { VisitUnaryPostIncDec(UO); }
13051 void VisitUnaryPostDec(
const UnaryOperator *UO) { VisitUnaryPostIncDec(UO); }
13053 Object O = getObject(UO->
getSubExpr(),
true);
13055 return VisitExpr(UO);
13059 notePostMod(O, UO, UK_ModAsSideEffect);
13068 SequenceTree::Seq LHSRegion = Tree.allocate(Region);
13069 SequenceTree::Seq RHSRegion = Tree.allocate(Region);
13070 SequenceTree::Seq OldRegion = Region;
13072 EvaluationTracker Eval(*
this);
13074 SequencedSubexpression Sequenced(*
this);
13075 Region = LHSRegion;
13082 bool EvalResult =
false;
13083 bool EvalOK = Eval.evaluate(BO->
getLHS(), EvalResult);
13084 bool ShouldVisitRHS = !EvalOK || (EvalOK && !EvalResult);
13085 if (ShouldVisitRHS) {
13086 Region = RHSRegion;
13090 Region = OldRegion;
13091 Tree.merge(LHSRegion);
13092 Tree.merge(RHSRegion);
13101 SequenceTree::Seq LHSRegion = Tree.allocate(Region);
13102 SequenceTree::Seq RHSRegion = Tree.allocate(Region);
13103 SequenceTree::Seq OldRegion = Region;
13105 EvaluationTracker Eval(*
this);
13107 SequencedSubexpression Sequenced(*
this);
13108 Region = LHSRegion;
13114 bool EvalResult =
false;
13115 bool EvalOK = Eval.evaluate(BO->
getLHS(), EvalResult);
13116 bool ShouldVisitRHS = !EvalOK || (EvalOK && EvalResult);
13117 if (ShouldVisitRHS) {
13118 Region = RHSRegion;
13122 Region = OldRegion;
13123 Tree.merge(LHSRegion);
13124 Tree.merge(RHSRegion);
13132 SequenceTree::Seq ConditionRegion = Tree.allocate(Region);
13148 SequenceTree::Seq TrueRegion = Tree.allocate(Region);
13149 SequenceTree::Seq FalseRegion = Tree.allocate(Region);
13150 SequenceTree::Seq OldRegion = Region;
13152 EvaluationTracker Eval(*
this);
13154 SequencedSubexpression Sequenced(*
this);
13155 Region = ConditionRegion;
13165 bool EvalResult =
false;
13166 bool EvalOK = Eval.evaluate(CO->
getCond(), EvalResult);
13167 bool ShouldVisitTrueExpr = !EvalOK || (EvalOK && EvalResult);
13168 bool ShouldVisitFalseExpr = !EvalOK || (EvalOK && !EvalResult);
13169 if (ShouldVisitTrueExpr) {
13170 Region = TrueRegion;
13173 if (ShouldVisitFalseExpr) {
13174 Region = FalseRegion;
13178 Region = OldRegion;
13179 Tree.merge(ConditionRegion);
13180 Tree.merge(TrueRegion);
13181 Tree.merge(FalseRegion);
13184 void VisitCallExpr(
const CallExpr *CE) {
13191 SequencedSubexpression Sequenced(*
this);
13193 [&] { Base::VisitCallExpr(CE); });
13200 SequencedSubexpression Sequenced(*
this);
13203 return VisitExpr(CCE);
13207 SequenceTree::Seq
Parent = Region;
13211 Region = Tree.allocate(Parent);
13212 Elts.push_back(Region);
13218 for (
unsigned I = 0; I < Elts.size(); ++I)
13219 Tree.merge(Elts[I]);
13224 return VisitExpr(ILE);
13228 SequenceTree::Seq
Parent = Region;
13229 for (
unsigned I = 0; I < ILE->
getNumInits(); ++I) {
13233 Region = Tree.allocate(Parent);
13234 Elts.push_back(Region);
13240 for (
unsigned I = 0; I < Elts.size(); ++I)
13241 Tree.merge(Elts[I]);
13247 void Sema::CheckUnsequencedOperations(
const Expr *E) {
13249 WorkList.push_back(E);
13250 while (!WorkList.empty()) {
13251 const Expr *Item = WorkList.pop_back_val();
13252 SequenceChecker(*
this, Item, WorkList);
13257 bool IsConstexpr) {
13259 isConstantEvaluatedOverride, IsConstexpr || isa<ConstantExpr>(E));
13260 CheckImplicitConversions(E, CheckLoc);
13262 CheckUnsequencedOperations(E);
13264 CheckForIntOverflow(E);
13265 DiagnoseMisalignedMembers();
13278 if (
const auto *PointerTy = dyn_cast<PointerType>(PType)) {
13282 if (
const auto *ReferenceTy = dyn_cast<ReferenceType>(PType)) {
13286 if (
const auto *ParenTy = dyn_cast<ParenType>(PType)) {
13300 S.
Diag(Loc, diag::err_array_star_in_function_definition);
13309 bool CheckParameterNames) {
13310 bool HasInvalidParm =
false;
13317 if (!Param->isInvalidDecl() &&
13318 RequireCompleteType(Param->getLocation(), Param->getType(),
13319 diag::err_typecheck_decl_incomplete_type)) {
13320 Param->setInvalidDecl();
13321 HasInvalidParm =
true;
13326 if (CheckParameterNames &&
13327 Param->getIdentifier() ==
nullptr &&
13328 !Param->isImplicit() &&
13329 !getLangOpts().CPlusPlus)
13330 Diag(Param->getLocation(), diag::err_parameter_name_omitted);
13337 QualType PType = Param->getOriginalType();
13345 if (!Param->isInvalidDecl()) {
13346 if (
CXXRecordDecl *ClassDecl = Param->getType()->getAsCXXRecordDecl()) {
13347 if (!ClassDecl->isInvalidDecl() &&
13348 !ClassDecl->hasIrrelevantDestructor() &&
13349 !ClassDecl->isDependentContext() &&
13350 ClassDecl->isParamDestroyedInCallee()) {
13352 MarkFunctionReferenced(Param->getLocation(), Destructor);
13353 DiagnoseUseOfDecl(Destructor, Param->
getLocation());
13362 if (
const auto *
Attr = Param->getAttr<PassObjectSizeAttr>())
13363 if (!Param->getType().isConstQualified())
13364 Diag(Param->getLocation(), diag::err_attribute_pointers_only)
13368 if (LangOpts.CPlusPlus && !Param->isInvalidDecl()) {
13373 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC->
getParent()))
13374 CheckShadowInheritedFields(Param->getLocation(), Param->getDeclName(),
13380 return HasInvalidParm;
13387 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
13390 if (
const auto *ME = dyn_cast<MemberExpr>(E))
13401 if (getDiagnostics().isIgnored(diag::warn_cast_align, TRange.
getBegin()))
13410 if (!DestPtr)
return;
13416 if (DestAlign.
isOne())
return;
13420 if (!SrcPtr)
return;
13431 if (
auto *CE = dyn_cast<CastExpr>(Op)) {
13432 if (CE->getCastKind() == CK_ArrayToPointerDecay)
13433 SrcAlign =
getDeclAlign(CE->getSubExpr(), SrcAlign, Context);
13434 }
else if (
auto *UO = dyn_cast<UnaryOperator>(Op)) {
13435 if (UO->getOpcode() == UO_AddrOf)
13436 SrcAlign =
getDeclAlign(UO->getSubExpr(), SrcAlign, Context);
13439 if (SrcAlign >= DestAlign)
return;
13444 << static_cast<unsigned>(DestAlign.
getQuantity())
13455 if (Size != 1 || !ND)
return false;
13458 if (!FD)
return false;
13481 if (!RD)
return false;
13482 if (RD->
isUnion())
return false;
13483 if (
const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
13484 if (!CRD->isStandardLayout())
return false;
13488 const Decl *D = FD;
13490 if (isa<FieldDecl>(D))
13495 void Sema::CheckArrayAccess(
const Expr *BaseExpr,
const Expr *IndexExpr,
13497 bool AllowOnePastEnd,
bool IndexNegated) {
13499 if (isConstantEvaluated())
13506 const Type *EffectiveType =
13528 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr))
13529 ND = DRE->getDecl();
13530 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr))
13531 ND = ME->getMemberDecl();
13533 if (index.isUnsigned() || !index.isNegative()) {
13544 if (!size.isStrictlyPositive())
13547 if (BaseType != EffectiveType) {
13549 uint64_t ptrarith_typesize = Context.
getTypeSize(EffectiveType);
13550 uint64_t array_typesize = Context.
getTypeSize(BaseType);
13552 if (!ptrarith_typesize) ptrarith_typesize = 1;
13553 if (ptrarith_typesize != array_typesize) {
13555 uint64_t ratio = array_typesize / ptrarith_typesize;
13558 if (ptrarith_typesize * ratio == array_typesize)
13563 if (size.getBitWidth() > index.getBitWidth())
13564 index = index.zext(size.getBitWidth());
13565 else if (size.getBitWidth() < index.getBitWidth())
13566 size = size.zext(index.getBitWidth());
13572 if (AllowOnePastEnd ? index.ule(size) : index.ult(size))
13587 if (SourceMgr.isInSystemHeader(RBracketLoc)) {
13589 SourceMgr.getSpellingLoc(IndexExpr->
getBeginLoc());
13590 if (SourceMgr.isWrittenInSameFile(RBracketLoc, IndexLoc))
13595 unsigned DiagID = diag::warn_ptr_arith_exceeds_bounds;
13597 DiagID = diag::warn_array_index_exceeds_bounds;
13599 DiagRuntimeBehavior(BaseExpr->
getBeginLoc(), BaseExpr,
13600 PDiag(DiagID) << index.toString(10,
true)
13601 << size.toString(10,
true)
13602 << (unsigned)size.getLimitedValue(~0U)
13605 unsigned DiagID = diag::warn_array_index_precedes_bounds;
13607 DiagID = diag::warn_ptr_arith_precedes_bounds;
13608 if (index.isNegative()) index = -index;
13611 DiagRuntimeBehavior(BaseExpr->
getBeginLoc(), BaseExpr,
13612 PDiag(DiagID) << index.toString(10,
true)
13619 dyn_cast<ArraySubscriptExpr>(BaseExpr))
13621 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr))
13622 ND = DRE->getDecl();
13623 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr))
13624 ND = ME->getMemberDecl();
13629 PDiag(diag::note_array_declared_here)
13633 void Sema::CheckArrayAccess(
const Expr *
expr) {
13634 int AllowOnePastEnd = 0;
13638 case Stmt::ArraySubscriptExprClass: {
13641 AllowOnePastEnd > 0);
13645 case Stmt::MemberExprClass: {
13646 expr = cast<MemberExpr>(
expr)->getBase();
13649 case Stmt::OMPArraySectionExprClass: {
13653 nullptr, AllowOnePastEnd > 0);
13656 case Stmt::UnaryOperatorClass: {
13672 case Stmt::ConditionalOperatorClass: {
13675 CheckArrayAccess(lhs);
13677 CheckArrayAccess(rhs);
13680 case Stmt::CXXOperatorCallExprClass: {
13681 const auto *OCE = cast<CXXOperatorCallExpr>(
expr);
13682 for (
const auto *Arg : OCE->arguments())
13683 CheckArrayAccess(Arg);
13696 struct RetainCycleOwner {
13700 bool Indirect =
false;
13702 RetainCycleOwner() =
default;
13704 void setLocsFrom(
Expr *e) {
13721 owner.Variable = var;
13723 owner.setLocsFrom(ref);
13731 switch (
cast->getCastKind()) {
13733 case CK_LValueBitCast:
13734 case CK_LValueToRValue:
13735 case CK_ARCReclaimReturnedObject:
13736 e =
cast->getSubExpr();
13753 if (ref->isFreeIvar()) owner.setLocsFrom(ref);
13754 owner.Indirect =
true;
13758 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(e)) {
13760 if (!var)
return false;
13765 if (
member->isArrow())
return false;
13777 if (!pre)
return false;
13780 if (!property->isRetaining() &&
13781 !(
property->getPropertyIvarDecl() &&
13782 property->getPropertyIvarDecl()->getType()
13786 owner.Indirect =
true;
13789 if (!owner.Variable)
13795 e =
const_cast<Expr*
>(cast<OpaqueValueExpr>(pre->
getBase())
13796 ->getSourceExpr());
13811 Expr *Capturer =
nullptr;
13812 bool VarWillBeReased =
false;
13816 Context(Context), Variable(variable) {}
13819 if (ref->
getDecl() == Variable && !Capturer)
13824 if (Capturer)
return;
13830 void VisitBlockExpr(
BlockExpr *block) {
13837 if (Capturer)
return;
13843 if (!Variable || VarWillBeReased || BinOp->
getOpcode() != BO_Assign)
13846 if (
const DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(LHS)) {
13847 if (DRE->getDecl() != Variable)
13853 (RHS && RHS->isIntegerConstantExpr(Value, Context) && Value == 0);
13864 assert(owner.Variable && owner.Loc.isValid());
13872 e = ME->getInstanceReceiver();
13875 e = e->IgnoreParenCasts();
13877 }
else if (
CallExpr *CE = dyn_cast<CallExpr>(e)) {
13882 if (FnI && FnI->
isStr(
"_Block_copy")) {
13893 FindCaptureVisitor visitor(S.
Context, owner.Variable);
13895 return visitor.VarWillBeReased ? nullptr : visitor.Capturer;
13899 RetainCycleOwner &owner) {
13901 assert(owner.Variable && owner.Loc.isValid());
13905 S.
Diag(owner.Loc, diag::note_arc_retain_cycle_owner)
13906 << owner.Indirect << owner.Range;
13915 while (!str.empty() && str.front() ==
'_') str = str.substr(1);
13916 if (str.startswith(
"set"))
13917 str = str.substr(3);
13918 else if (str.startswith(
"add")) {
13920 if (sel.
getNumArgs() == 1 && str.startswith(
"addOperationWithBlock"))
13922 str = str.substr(3);
13927 if (str.empty())
return true;
13933 bool IsMutableArray = S.
NSAPIObj->isSubclassOfNSClass(
13936 if (!IsMutableArray) {
13943 S.
NSAPIObj->getNSArrayMethodKind(Sel);
13968 bool IsMutableDictionary = S.
NSAPIObj->isSubclassOfNSClass(
13971 if (!IsMutableDictionary) {
13978 S.
NSAPIObj->getNSDictionaryMethodKind(Sel);
13999 bool IsMutableSet = S.
NSAPIObj->isSubclassOfNSClass(
14003 bool IsMutableOrderedSet = S.
NSAPIObj->isSubclassOfNSClass(
14006 if (!IsMutableSet && !IsMutableOrderedSet) {
14045 int ArgIndex = *ArgOpt;
14053 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
14054 if (ArgRE->isObjCSelfExpr()) {
14056 diag::warn_objc_circular_container)
14057 << ArgRE->getDecl() << StringRef(
"'super'");
14067 if (
DeclRefExpr *ReceiverRE = dyn_cast<DeclRefExpr>(Receiver)) {
14068 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
14069 if (ReceiverRE->getDecl() == ArgRE->getDecl()) {
14072 diag::warn_objc_circular_container)
14074 if (!ArgRE->isObjCSelfExpr()) {
14076 diag::note_objc_circular_container_declared_here)
14081 }
else if (
ObjCIvarRefExpr *IvarRE = dyn_cast<ObjCIvarRefExpr>(Receiver)) {
14083 if (IvarRE->getDecl() == IvarArgRE->getDecl()) {
14086 diag::warn_objc_circular_container)
14089 diag::note_objc_circular_container_declared_here)
14104 RetainCycleOwner owner;
14110 owner.Variable = getCurMethodDecl()->getSelfDecl();
14117 for (
unsigned i = 0, e = msg->
getNumArgs(); i != e; ++i) {
14120 if (MD && MD->
parameters()[i]->hasAttr<NoEscapeAttr>())
14129 RetainCycleOwner owner;
14138 RetainCycleOwner Owner;
14152 Expr *RHS,
bool isProperty) {
14164 S.
Diag(Loc, diag::warn_arc_literal_assign)
14166 << (isProperty ? 0 : 1)
14174 Expr *RHS,
bool isProperty) {
14177 if (
cast->getCastKind() == CK_ARCConsumeObject) {
14178 S.
Diag(Loc, diag::warn_arc_retained_assign)
14180 << (isProperty ? 0 : 1)
14184 RHS =
cast->getSubExpr();
14226 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
14227 getCurFunction()->markSafeWeakUse(LHS);
14230 if (checkUnsafeAssigns(Loc, LHSType, RHS))
14250 if (!(AsWrittenAttr & ObjCPropertyDecl::OBJC_PR_assign) &&
14255 if (
cast->getCastKind() == CK_ARCConsumeObject) {
14256 Diag(Loc, diag::warn_arc_retained_property_assign)
14260 RHS =
cast->getSubExpr();
14284 bool StmtLineInvalid;
14287 if (StmtLineInvalid)
14290 bool BodyLineInvalid;
14293 if (BodyLineInvalid)
14297 if (StmtLine != BodyLine)
14308 if (CurrentInstantiationScope)
14321 Diag(NBody->
getSemiLoc(), diag::note_empty_body_on_separate_line);
14325 const Stmt *PossibleBody) {
14326 assert(!CurrentInstantiationScope);
14331 if (
const ForStmt *FS = dyn_cast<ForStmt>(S)) {
14332 StmtLoc = FS->getRParenLoc();
14333 Body = FS->getBody();
14334 DiagID = diag::warn_empty_for_body;
14335 }
else if (
const WhileStmt *WS = dyn_cast<WhileStmt>(S)) {
14336 StmtLoc = WS->getCond()->getSourceRange().getEnd();
14337 Body = WS->getBody();
14338 DiagID = diag::warn_empty_while_body;
14348 if (Diags.isIgnored(DiagID, NBody->
getSemiLoc()))
14366 bool ProbableTypo = isa<CompoundStmt>(PossibleBody);
14367 if (!ProbableTypo) {
14368 bool BodyColInvalid;
14369 unsigned BodyCol = SourceMgr.getPresumedColumnNumber(
14371 if (BodyColInvalid)
14374 bool StmtColInvalid;
14376 SourceMgr.getPresumedColumnNumber(S->
getBeginLoc(), &StmtColInvalid);
14377 if (StmtColInvalid)
14380 if (BodyCol > StmtCol)
14381 ProbableTypo =
true;
14384 if (ProbableTypo) {
14386 Diag(NBody->
getSemiLoc(), diag::note_empty_body_on_separate_line);
14395 if (Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess, OpLoc))
14398 if (inTemplateInstantiation())
14415 RHSExpr = CE->
getArg(0);
14421 if (LHSDeclRef && RHSDeclRef) {
14422 if (!LHSDeclRef->
getDecl() || !RHSDeclRef->getDecl())
14428 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
14438 const Expr *LHSBase = LHSExpr;
14439 const Expr *RHSBase = RHSExpr;
14442 if (!LHSME || !RHSME)
14445 while (LHSME && RHSME) {
14451 RHSBase = RHSME->getBase();
14458 if (LHSDeclRef && RHSDeclRef) {
14459 if (!LHSDeclRef->getDecl() || !RHSDeclRef->getDecl())
14461 if (LHSDeclRef->getDecl()->getCanonicalDecl() !=
14462 RHSDeclRef->getDecl()->getCanonicalDecl())
14465 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
14471 if (isa<CXXThisExpr>(LHSBase) && isa<CXXThisExpr>(RHSBase))
14472 Diag(OpLoc, diag::warn_self_move) << LHSExpr->
getType()
14504 if (Bits1 != Bits2)
14516 if (
const CXXRecordDecl *D1CXX = dyn_cast<CXXRecordDecl>(RD1)) {
14521 if (D1CXX->getNumBases() != D2CXX->
getNumBases())
14526 Base1 = D1CXX->bases_begin(),
14527 BaseEnd1 = D1CXX->bases_end(),
14530 ++Base1, ++Base2) {
14534 }
else if (
const CXXRecordDecl *D2CXX = dyn_cast<CXXRecordDecl>(RD2)) {
14536 if (D2CXX->getNumBases() > 0)
14545 for ( ; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) {
14549 if (Field1 != Field1End || Field2 != Field2End)
14559 llvm::SmallPtrSet<FieldDecl *, 8> UnmatchedFields;
14560 for (
auto *Field2 : RD2->
fields())
14561 UnmatchedFields.insert(Field2);
14563 for (
auto *Field1 : RD1->
fields()) {
14564 llvm::SmallPtrSet<FieldDecl *, 8>::iterator
14565 I = UnmatchedFields.begin(),
14566 E = UnmatchedFields.end();
14568 for ( ; I != E; ++I) {
14570 bool Result = UnmatchedFields.erase(*I);
14580 return UnmatchedFields.empty();
14614 if (TC1 == Type::Enum) {
14616 cast<EnumType>(T1)->getDecl(),
14617 cast<EnumType>(T2)->getDecl());
14618 }
else if (TC1 == Type::Record) {
14623 cast<RecordType>(T1)->getDecl(),
14624 cast<RecordType>(T2)->getDecl());
14644 const ValueDecl **VD, uint64_t *MagicValue,
14645 bool isConstantEvaluated) {
14653 case Stmt::UnaryOperatorClass: {
14662 case Stmt::DeclRefExprClass: {
14663 const DeclRefExpr *DRE = cast<DeclRefExpr>(TypeExpr);
14668 case Stmt::IntegerLiteralClass: {
14671 if (MagicValueAPInt.getActiveBits() <= 64) {
14672 *MagicValue = MagicValueAPInt.getZExtValue();
14678 case Stmt::BinaryConditionalOperatorClass:
14679 case Stmt::ConditionalOperatorClass: {
14681 cast<AbstractConditionalOperator>(TypeExpr);
14684 isConstantEvaluated)) {
14694 case Stmt::BinaryOperatorClass: {
14697 TypeExpr = BO->
getRHS();
14727 const llvm::DenseMap<Sema::TypeTagMagicValue, Sema::TypeTagData>
14730 bool isConstantEvaluated) {
14731 FoundWrongKind =
false;
14736 uint64_t MagicValue;
14738 if (!
FindTypeTagExpr(TypeExpr, Ctx, &VD, &MagicValue, isConstantEvaluated))
14742 if (TypeTagForDatatypeAttr *I = VD->
getAttr<TypeTagForDatatypeAttr>()) {
14743 if (I->getArgumentKind() != ArgumentKind) {
14744 FoundWrongKind =
true;
14747 TypeInfo.
Type = I->getMatchingCType();
14760 MagicValues->find(std::make_pair(ArgumentKind, MagicValue));
14761 if (I == MagicValues->end())
14764 TypeInfo = I->second;
14770 bool LayoutCompatible,
14772 if (!TypeTagForDatatypeMagicValues)
14773 TypeTagForDatatypeMagicValues.reset(
14774 new llvm::DenseMap<TypeTagMagicValue, TypeTagData>);
14777 (*TypeTagForDatatypeMagicValues)[Magic] =
14793 return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) ||
14794 (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) ||
14795 (T1Kind == BuiltinType::Char_U && T2Kind == BuiltinType::UChar) ||
14796 (T1Kind == BuiltinType::Char_S && T2Kind == BuiltinType::SChar);
14799 void Sema::CheckArgumentWithTypeTag(
const ArgumentWithTypeTagAttr *
Attr,
14800 const ArrayRef<const Expr *> ExprArgs,
14803 bool IsPointerAttr = Attr->getIsPointer();
14806 unsigned TypeTagIdxAST = Attr->getTypeTagIdx().getASTIndex();
14807 if (TypeTagIdxAST >= ExprArgs.size()) {
14808 Diag(CallSiteLoc, diag::err_tag_index_out_of_range)
14809 << 0 << Attr->getTypeTagIdx().getSourceIndex();
14812 const Expr *TypeTagExpr = ExprArgs[TypeTagIdxAST];
14813 bool FoundWrongKind;
14816 TypeTagForDatatypeMagicValues.get(), FoundWrongKind,
14817 TypeInfo, isConstantEvaluated())) {
14818 if (FoundWrongKind)
14820 diag::warn_type_tag_for_datatype_wrong_kind)
14826 unsigned ArgumentIdxAST = Attr->getArgumentIdx().getASTIndex();
14827 if (ArgumentIdxAST >= ExprArgs.size()) {
14828 Diag(CallSiteLoc, diag::err_tag_index_out_of_range)
14829 << 1 << Attr->getArgumentIdx().getSourceIndex();
14832 const Expr *ArgumentExpr = ExprArgs[ArgumentIdxAST];
14833 if (IsPointerAttr) {
14835 if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(ArgumentExpr))
14836 if (ICE->getType()->isVoidPointerType() &&
14837 ICE->getCastKind() == CK_BitCast)
14838 ArgumentExpr = ICE->getSubExpr();
14846 if (TypeInfo.MustBeNull) {
14851 diag::warn_type_safety_null_pointer_required)
14859 QualType RequiredType = TypeInfo.Type;
14863 bool mismatch =
false;
14864 if (!TypeInfo.LayoutCompatible) {
14865 mismatch = !Context.
hasSameType(ArgumentType, RequiredType);
14886 Diag(ArgumentExpr->
getExprLoc(), diag::warn_type_safety_type_mismatch)
14887 << ArgumentType << ArgumentKind
14888 << TypeInfo.LayoutCompatible << RequiredType
14895 MisalignedMembers.emplace_back(E, RD, MD, Alignment);
14899 for (MisalignedMember &m : MisalignedMembers) {
14905 Diag(m.E->getBeginLoc(), diag::warn_taking_address_of_packed_member)
14908 MisalignedMembers.clear();
14915 if (isa<UnaryOperator>(E) &&
14916 cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf) {
14917 auto *Op = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
14918 if (isa<MemberExpr>(Op)) {
14919 auto MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
14920 if (MA != MisalignedMembers.end() &&
14925 MisalignedMembers.erase(MA);
14946 bool AnyIsPacked =
false;
14948 QualType BaseType = ME->getBase()->getType();
14964 AnyIsPacked || (RD->
hasAttr<PackedAttr>() || MD->
hasAttr<PackedAttr>());
14965 ReverseMemberChain.push_back(FD);
14968 ME = dyn_cast<
MemberExpr>(ME->getBase()->IgnoreParens());
14970 assert(TopME &&
"We did not compute a topmost MemberExpr!");
14977 const auto *DRE = dyn_cast<
DeclRefExpr>(TopBase);
14981 if (!DRE && !isa<CXXThisExpr>(TopBase))
14988 if (ExpectedAlignment.
isOne())
14993 for (
auto I = ReverseMemberChain.rbegin(); I != ReverseMemberChain.rend();
15000 ReverseMemberChain.back()->getParent()->getTypeForDecl());
15004 if (DRE && !TopME->
isArrow()) {
15007 CompleteObjectAlignment =
15012 if (Offset % ExpectedAlignment != 0 ||
15015 CompleteObjectAlignment < ExpectedAlignment) {
15026 for (
FieldDecl *FDI : ReverseMemberChain) {
15027 if (FDI->hasAttr<PackedAttr>() ||
15028 FDI->getParent()->hasAttr<PackedAttr>()) {
15036 assert(FD &&
"We did not find a packed FieldDecl!");
15037 Action(E, FD->
getParent(), FD, Alignment);
15041 void Sema::CheckAddressOfPackedMember(
Expr *rhs) {
15044 RefersToMemberWithReducedAlignment(
15045 rhs, std::bind(&Sema::AddPotentialMisalignedMembers, std::ref(*
this), _1,
ArgType getArgType(ASTContext &Ctx, bool IsObjCLiteral) const
Returns the builtin type that a data argument paired with this format specifier should have...
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
The receiver is the instance of the superclass object.
static void diagnoseArrayStarInParamType(Sema &S, QualType PType, SourceLocation Loc)
static FormatStringType GetFormatStringType(const FormatAttr *Format)
bool isFloatingPoint() const
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
const BlockDecl * getBlockDecl() const
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
SourceLocation getBeginLoc() const LLVM_READONLY
TargetOptions & getTargetOpts() const
Retrieve the target options.
bool isCallToStdMove() const
static std::pair< QualType, StringRef > shouldNotPrintDirectly(const ASTContext &Context, QualType IntendedTy, const Expr *E)
IntType getInt64Type() const
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name...
static APFixedPoint getFromIntValue(const llvm::APSInt &Value, const FixedPointSemantics &DstFXSema, bool *Overflow=nullptr)
Create an APFixedPoint with a value equal to that of the provided integer, and in the same semantics ...
const OptionalFlag & hasAlternativeForm() const
QualType withConst() const
Retrieves a version of this type with const applied.
Represents a function declaration or definition.
static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E)
Analyze the given compound assignment for the possible losing of floating-point precision.
NamespaceDecl * getStdNamespace() const
const char * getSpelling() const
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
Expr ** getArgs()
Retrieve the call arguments.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
The receiver is an object instance.
unsigned getMemoryFunctionKind() const
Identify a memory copying or setting function.
static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E, Expr *Constant, Expr *Other, const llvm::APSInt &Value, bool RhsConstant)
SourceLocation getRParenLoc() const
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Smart pointer class that efficiently represents Objective-C method names.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getElementType() const
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
static llvm::SmallPtrSet< MemberKind *, 1 > CXXRecordMembersNamed(StringRef Name, Sema &S, QualType Ty)
A (possibly-)qualified type.
bool isBlockPointerType() const
StringKind getKind() const
bool isMemberPointerType() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
static bool CheckForReference(Sema &SemaRef, const Expr *E, const PartialDiagnostic &PD)
static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall)
OpenCL C v2.0, s6.13.17 - Enqueue kernel function contains four different overload formats specified ...
const ScanfConversionSpecifier & getConversionSpecifier() const
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getExprLoc() const
bool hasValidThousandsGroupingPrefix() const
Selector getSelector() const
static bool SemaOpenCLBuiltinNDRangeAndBlock(Sema &S, CallExpr *TheCall)
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2)
Check if two types are layout-compatible in C++11 sense.
static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, SourceLocation CC, bool *ICContext=nullptr, bool IsListInit=false)
Defines enumerations for the type traits support.
bool isSuperReceiver() const
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
const Expr * getInit(unsigned Init) const
bool containsNonAsciiOrNull() const
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
Stmt - This represents one statement.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
static Optional< int > GetNSMutableArrayArgumentIndex(Sema &S, ObjCMessageExpr *Message)
Expr * getBitWidth() const
bool consumesDataArgument() const
FunctionType - C99 6.7.5.3 - Function Declarators.
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken=nullptr, unsigned *StartTokenByteOffset=nullptr) const
getLocationOfByte - Return a source location that points to the specified byte of this string literal...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
An instance of this object exists for each enum constant that is defined.
bool isRealFloatingType() const
Floating point categories.
C Language Family Type Representation.
Defines the SourceManager interface.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
static const Builtin::Info BuiltinInfo[]
void addConst()
Add the const type qualifier to this QualType.
bool isRecordType() const
static void AnalyzeAssignment(Sema &S, BinaryOperator *E)
Analyze the given simple or compound assignment for warning-worthy operations.
static ExprResult SemaBuiltinLaunder(Sema &S, CallExpr *TheCall)
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
bool hasLeadingEmptyMacro() const
bool isVariadic() const
Whether this function prototype is variadic.
SourceLocation getBeginLoc() const LLVM_READONLY
static bool referToTheSameDecl(const Expr *E1, const Expr *E2)
Check if two expressions refer to the same declaration.
ParenExpr - This represents a parethesized expression, e.g.
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
Expr * getFalseExpr() const
Strictly evaluate the expression.
Expr * getLowerBound()
Get lower bound of array section.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CanQualType getNSUIntegerType() const
NSDictionaryMethodKind
Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some c...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represent a C++ namespace.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
Wrapper for source info for typedefs.
static AbsoluteValueKind getAbsoluteValueKind(QualType T)
QualType withConst() const
static void AnalyzeComparison(Sema &S, BinaryOperator *E)
Implements -Wsign-compare.
const TargetInfo & getTargetInfo() const
const NestedNameSpecifier * Specifier
A container of type source information.
static bool checkOpenCLPipeArg(Sema &S, CallExpr *Call)
Returns true if pipe element type is different from the pointer.
bool EvaluateAsFixedPoint(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsFloat - Return true if this is a constant which we can fold and convert to a fixed point va...
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
static bool checkArgCount(Sema &S, CallExpr *call, unsigned desiredArgCount)
Checks that a call expression's argument count is the desired number.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
QualType getElementType() const
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static unsigned changeAbsFunction(unsigned AbsKind, AbsoluteValueKind ValueKind)
bool usesPositionalArg() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
SourceLocation getImmediateMacroCallerLoc(SourceLocation Loc) const
Gets the location of the immediate macro caller, one level up the stack toward the initial macro type...
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
QualType getReturnType() const
ScopeFlags
ScopeFlags - These are bitfields that are or'd together when creating a scope, which defines the sort...
DiagnosticsEngine & Diags
CompoundLiteralExpr - [C99 6.5.2.5].
unsigned getNumParams() const
bool isEnumeralType() const
APFixedPoint getFixedPointMax(QualType Ty) const
Options for controlling the target.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const AstTypeMatcher< PointerType > pointerType
Matches pointer types, but does not match Objective-C object pointer types.
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
APFloat & getComplexFloatReal()
const T * getAs() const
Member-template getAs<specific type>'.
Extra information about a function prototype.
const OptionalFlag & hasThousandsGrouping() const
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
ObjCMethodDecl - Represents an instance or class method declaration.
bool isInvalidDecl() const
Like System, but searched after the system directories.
bool isAddrLabelDiff() const
Represents a parameter to a function.
static bool SemaBuiltinAlignment(Sema &S, CallExpr *TheCall, unsigned ID)
Check that the value argument for __builtin_is_aligned(value, alignment) and __builtin_aligned_{up,down}(value, alignment) is an integer or a pointer type (but not a function pointer) and that the alignment is a power-of-two.
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
ObjCInterfaceDecl * NSDictionaryDecl
The declaration of the Objective-C NSDictionary class.
static bool CheckMemorySizeofForComparison(Sema &S, const Expr *E, IdentifierInfo *FnName, SourceLocation FnLoc, SourceLocation RParenLoc)
Takes the expression passed to the size_t parameter of functions such as memcmp, strncat, etc and warns if it's a comparison.
static bool CheckBuiltinTargetSupport(Sema &S, unsigned BuiltinID, CallExpr *TheCall, ArrayRef< llvm::Triple::ArchType > SupportedArchs)
Parse and apply any fixits to the source.
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
bool isVariableArrayType() const
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc, Qualifiers::ObjCLifetime LT, Expr *RHS, bool isProperty)
ObjCPropertyDecl * getExplicitProperty() const
static bool requiresParensToAddCast(const Expr *E)
ArgType getArgType(ASTContext &Ctx) const
static bool checkOpenCLEnqueueVariadicArgs(Sema &S, CallExpr *TheCall, Expr *BlockArg, unsigned NumNonVarArgs)
OpenCL v2.0, s6.13.17.1 - Check that sizes are provided for all 'local void*' parameter of passed blo...
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
Represents a struct/union/class.
static bool checkVAStartIsInVariadicFunction(Sema &S, Expr *Fn, ParmVarDecl **LastParam=nullptr)
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
bool isComplete() const
Returns true if this can be considered a complete type.
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
Expr * getFalseExpr() const
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
SourceLocation getBegin() const
bool isNothrow(bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
QualType getPointeeType() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
ArrayRef< QualType > getParamTypes() const
Used for GCC's __alignof.
field_range fields() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a member of a struct/union/class.
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
static bool isValidOrderingForOp(int64_t Ordering, AtomicExpr::AtomicOp Op)
static int classifyConstantValue(Expr *Constant)
bool isReferenceType() const
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
The iterator over UnresolvedSets.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
IntType getSizeType() const
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
__DEVICE__ int max(int __a, int __b)
bool hasValidLeftJustified() const
std::unique_ptr< AtomicScopeModel > getScopeModel() const
Get atomic scope model.
CanQualType OCLReserveIDTy
SourceLocation getBeginLoc() const LLVM_READONLY
static bool isLayoutCompatibleUnion(ASTContext &C, RecordDecl *RD1, RecordDecl *RD2)
Check if two standard-layout unions are layout-compatible.
SourceLocation getQuestionLoc() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
unsigned getCharByteWidth() const
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody)
Warn if a for/while loop statement S, which is followed by PossibleBody, has a suspicious null statem...
bool isConstantEvaluated()
static Optional< int > GetNSSetArgumentIndex(Sema &S, ObjCMessageExpr *Message)
bool GE(InterpState &S, CodePtr OpPC)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
ArrayRef< ParmVarDecl * > parameters() const
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
bool isUnarySelector() const
bool hasValidPlusPrefix() const
void toString(raw_ostream &os) const
Describes an C or C++ initializer list.
static bool checkOpenCLEnqueueLocalSizeArgs(Sema &S, CallExpr *TheCall, unsigned Start, unsigned End)
static bool isArithmeticArgumentPromotion(Sema &S, const ImplicitCastExpr *ICE)
Return true if ICE is an implicit argument promotion of an arithmetic type.
bool isBitField() const
Determines whether this field is a bitfield.
ForStmt - This represents a 'for (init;cond;inc)' stmt.
unsigned getLength() const
static bool isEqualityOp(Opcode Opc)
Represents the results of name lookup.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
CharUnits - This is an opaque type for sizes expressed in character units.
APValue Val
Val - This is the value the expression can be folded to.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS)
Check for comparisons of floating point operands using != and ==.
bool hasValidPrecision() const
bool isOne() const
isOne - Test whether the quantity equals one.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
static bool isNonNullType(ASTContext &ctx, QualType type)
Determine whether the given type has a non-null nullability annotation.
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
PropertyAttributeKind getPropertyAttributes() const
Represents a typeof (or typeof) expression (a GCC extension).
const clang::PrintingPolicy & getPrintingPolicy() const
A builtin binary operation expression such as "x + y" or "x <= y".
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
bool isComplexFloat() const
QualType getExceptionObjectType(QualType T) const
unsigned getSpellingLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
bool isComplexInt() const
Defines the Diagnostic-related interfaces.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
ObjCStringLiteral, used for Objective-C string literals i.e.
Values of this type can never be null.
Scope - A scope is a transient data structure that is used while parsing the program.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
StringKind
StringLiteral is followed by several trailing objects.
field_iterator field_begin() const
unsigned getBitWidthValue(const ASTContext &Ctx) const
NSSetMethodKind
Enumerates the NSMutableSet/NSOrderedSet methods used to apply some checks.
static QualType GetExprType(const Expr *E)
bool isMacroBodyExpansion(SourceLocation Loc) const
Tests whether the given source location represents the expansion of a macro body. ...
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
base_class_iterator bases_begin()
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
const LangOptions & getLangOpts() const
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
bool isScalarType() const
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
An ordinary object is located at an address in memory.
bool Const(InterpState &S, CodePtr OpPC, const T &Arg)
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)...
Represents an ObjC class declaration.
static bool SemaOpenCLBuiltinKernelWorkGroupSize(Sema &S, CallExpr *TheCall)
OpenCL C v2.0, s6.13.17.6 - Check the argument to the get_kernel_work_group_size and get_kernel_prefe...
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
Member name lookup, which finds the names of class/struct/union members.
SourceLocation getTypeSpecStartLoc() const
Expression is a GNU-style __null constant.
static void diagnoseRetainCycle(Sema &S, Expr *capturer, RetainCycleOwner &owner)
static void AnalyzeImpConvsInComparison(Sema &S, BinaryOperator *E)
Analyze the operands of the given comparison.
PrimitiveDefaultInitializeKind
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
APSInt & getComplexIntReal()
CanQualType UnsignedCharTy
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
static bool SemaBuiltinMSVCAnnotation(Sema &S, CallExpr *TheCall)
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
const OptionalFlag & hasLeadingZeros() const
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const
This object can be modified without requiring retains or releases.
param_iterator param_begin()
bool tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx, unsigned Type) const
If the current Expr is a pointer, this will try to statically determine the number of bytes available...
APValue & getVectorElt(unsigned I)
The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a s...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
unsigned getFlags() const
getFlags - Return the flags for this scope.
Provides definitions for the various language-specific address spaces.
Decl * getNextDeclInContext()
OpenMP 4.0 [2.4, Array Sections].
const OptionalFlag & hasPlusPrefix() const
ConditionalOperator - The ?: ternary operator.
Sema - This implements semantic analysis and AST building for C.
StringRef getString() const
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
bool isDynamicClass() const
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
CastKind
CastKind - The kind of operation required for a conversion.
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
static bool checkOpenCLPipePacketType(Sema &S, CallExpr *Call, unsigned Idx)
Returns true if pipe element type is different from the pointer.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
const char * getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
SourceLocation getLocation() const
bool isEnabled(llvm::StringRef Ext) const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
TypeSourceInfo * getTypeSourceInfo() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
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, bool IgnoreStringsWithoutSpecifiers)
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
static bool IsShiftedByte(llvm::APSInt Value)
ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, AtomicExpr::AtomicOp Op, AtomicArgumentOrder ArgOrder=AtomicArgumentOrder::API)
Scope * getCurScope() const
Retrieve the parser's current scope.
static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, SourceLocation CContext)
Diagnose an implicit cast from a floating point value to an integer value.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Exposes information about the current target.
NSArrayMethodKind
Enumerates the NSArray/NSMutableArray methods used to generate literals and to apply some checks...
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting...
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
static const IntegerLiteral * getIntegerLiteral(Expr *E)
Defines the clang::LangOptions interface.
const OptionalFlag & isLeftJustified() const
Allow any unmodeled side effect.
Represents a character-granular source range.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isVariadic() const
Whether this function is variadic.
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
void EvaluateForOverflow(const ASTContext &Ctx) const
static void CheckImplicitArgumentConversions(Sema &S, CallExpr *TheCall, SourceLocation CC)
virtual bool hasSjLjLowering() const
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm...
const T * castAs() const
Member-template castAs<specific type>.
bool isObjCRetainableType() const
ObjCStringFormatFamily getObjCFStringFormattingFamily() const
static bool checkOpenCLBlockArgs(Sema &S, Expr *BlockArg)
OpenCL C v2.0, s6.13.17.2 - Checks that the block parameters are all local void*, which is a requirem...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
unsigned getNumInits() const
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
This scope corresponds to an SEH except.
bool isSignedInteger() const
Defines an enumeration for C++ overloaded operators.
bool isNullPtrType() const
bool hasValidLeadingZeros() const
field_iterator field_end() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
bool isAnyComplexType() const
void setObjectKind(ExprObjectKind Cat)
setObjectKind - Set the object kind produced by this expression.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void removeLocalVolatile()
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isFunctionOrMethod() const
CharSourceRange getImmediateExpansionRange(SourceLocation Loc) const
Return the start/end of the expansion information for an expansion location.
Expr * getElement(unsigned Index)
getElement - Return the Element at the specified index.
static void CheckNonNullArguments(Sema &S, const NamedDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< const Expr *> Args, SourceLocation CallSiteLoc)
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
virtual bool validateCpuSupports(StringRef Name) const
static bool SemaBuiltinPipePackets(Sema &S, CallExpr *Call)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
An expression that sends a message to the given Objective-C object or class.
SourceLocation getRBracketLoc() const
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
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
const BuiltinType * getAsPlaceholderType() const
Expr * getTrueExpr() const
APSInt & getComplexIntImag()
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
unsigned getPresumedLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T, SourceLocation CContext, unsigned diag, bool pruneControlFlow=false)
Diagnose an implicit cast; purely a helper for CheckImplicitConversion.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
QualType withoutLocalFastQualifiers() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
ImplicitParamDecl * getSelfDecl() const
static bool IsTailPaddedMemberArray(Sema &S, const llvm::APInt &Size, const NamedDecl *ND)
Check whether this array fits the idiom of a size-one tail padded array member of a struct...
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
static StringRef getIdentifier(const Token &Tok)
static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, bool IsPolyUnsigned, bool IsInt64Long)
getNeonEltType - Return the QualType corresponding to the elements of the vector type specified by th...
CanQualType getNSIntegerType() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static const Expr * getStrlenExprArg(const Expr *E)
static bool SemaBuiltinCpuSupports(Sema &S, CallExpr *TheCall)
SemaBuiltinCpuSupports - Handle __builtin_cpu_supports(char *).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static bool isConstantSizeArrayWithMoreThanOneElement(QualType Ty, ASTContext &Context)
SourceLocation getEndLoc() const LLVM_READONLY
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
static CharSourceRange getCharRange(SourceRange R)
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isVoidPointerType() const
std::string CPU
If given, the name of the target CPU to generate code for.
RecordDecl * getDecl() const
void toString(llvm::SmallVectorImpl< char > &Str) const
static void adornObjCBoolConversionDiagWithTernaryFixit(Sema &S, Expr *SourceExpr, const Sema::SemaDiagnosticBuilder &Builder)
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)
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
EltType getEltType() const
Defines the clang::OpenCLOptions class.
static bool IsStdFunction(const FunctionDecl *FDecl, const char(&Str)[StrLen])
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
There is no lifetime qualification on this type.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Enumerates target-specific builtins in their own namespaces within namespace clang.
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
bool isImplicitProperty() const
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
void DiagnoseMisalignedMembers()
Diagnoses the current set of gathered accesses.
static bool isLayoutCompatibleStruct(ASTContext &C, RecordDecl *RD1, RecordDecl *RD2)
Check if two standard-layout structs are layout-compatible.
void RefersToMemberWithReducedAlignment(Expr *E, llvm::function_ref< void(Expr *, RecordDecl *, FieldDecl *, CharUnits)> Action)
This function calls Action when it determines that E designates a misaligned member due to the packed...
ASTContext & getASTContext() const
static bool considerVariable(VarDecl *var, Expr *ref, RetainCycleOwner &owner)
Consider whether capturing the given variable can possibly lead to a retain cycle.
static void checkObjCCollectionLiteralElement(Sema &S, QualType TargetElementType, Expr *Element, unsigned ElementKind)
Check a single element within a collection literal against the target element type.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
SourceLocation getEndLoc() const LLVM_READONLY
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static void CheckConditionalOperator(Sema &S, ConditionalOperator *E, SourceLocation CC, QualType T)
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl *> Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
static const Expr * getSizeOfExprArg(const Expr *E)
If E is a sizeof expression, returns its argument expression, otherwise returns NULL.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
SourceLocation getOperatorLoc() const
static bool doesExprLikelyComputeSize(const Expr *SizeofExpr)
Detect if SizeofExpr is likely to calculate the sizeof an object.
LangAS getAddressSpace() const
Return the address space of this type.
Expression is not a Null pointer constant.
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Expr * getSubExpr() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle...
bool hasValidSpacePrefix() const
static const Expr * ignoreLiteralAdditions(const Expr *Ex, ASTContext &Ctx)
bool InRange(InterpState &S, CodePtr OpPC)
CastKind getCastKind() const
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
static bool IsImplicitBoolFloatConversion(Sema &S, Expr *Ex, bool ToBool)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall)
SemaBuiltinShuffleVector - Handle __builtin_shufflevector.
static bool CheckNonNullExpr(Sema &S, const Expr *Expr)
Checks if a the given expression evaluates to null.
SourceLocation getSuperLoc() const
Retrieve the location of the 'super' keyword for a class or instance message to 'super', otherwise an invalid source location.
const ParmVarDecl * getParamDecl(unsigned i) const
static void checkObjCArrayLiteral(Sema &S, QualType TargetType, ObjCArrayLiteral *ArrayLiteral)
Check an Objective-C array literal being converted to the given target type.
static void DiagnoseCStringFormatDirectiveInCFAPI(Sema &S, const NamedDecl *FDecl, Expr **Args, unsigned NumArgs)
Diagnose use of s directive in an NSString which is being passed as formatting string to formatting m...
static void CheckConditionalOperand(Sema &S, Expr *E, QualType T, SourceLocation CC, bool &ICContext)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
Check conversion of given expression to boolean.
SourceLocation getEndLoc() const LLVM_READONLY
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Look up any declaration with any name.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
static std::string PrettyPrintInRange(const llvm::APSInt &Value, IntRange Range)
static bool isBlockPointer(Expr *Arg)
bool FormatStringHasSArg(const StringLiteral *FExpr)
Represents one property declaration in an Objective-C interface.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool isFunctionProtoType() const
void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, uint64_t MagicValue, QualType Type, bool LayoutCompatible, bool MustBeNull)
Register a magic integral constant to be used as a type tag.
TypeClass getTypeClass() const
Used for C's _Alignof and C++'s alignof.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static bool isLogicalOp(Opcode Opc)
bool hasCStrMethod(const Expr *E)
Check to see if a given expression could have '.c_str()' called on it.
const ObjCMethodDecl * getMethodDecl() const
static bool IsEnumConstOrFromMacro(Sema &S, Expr *E)
DeclarationNameInfo getNameInfo() const
bool isVectorType() const
virtual bool validateCpuIs(StringRef Name) const
Assigning into this object requires a lifetime extension.
FixedPointSemantics getFixedPointSemantics(QualType Ty) const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static bool SemaBuiltinRWPipe(Sema &S, CallExpr *Call)
static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call)
Diagnose cases like 'memset(buf, sizeof(buf), 0)', which should have the last two arguments transpose...
We are currently in the filter expression of an SEH except block.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
LLVM_READONLY bool isLowercase(unsigned char c)
Return true if this character is a lowercase ASCII letter: [a-z].
static StringRef getImmediateMacroName(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
static StringRef getImmediateMacroNameForDiagnostics(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
const PrintfConversionSpecifier & getConversionSpecifier() const
CompoundAssignOperator - For compound assignments (e.g.
static bool isObjCSignedCharBool(Sema &S, QualType Ty)
Defines various enumerations that describe declaration and type specifiers.
StringRef getName() const
Return the actual identifier string.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
CanQualType UnsignedShortTy
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Canon=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
Base class for declarations which introduce a typedef-name.
QualType withVolatile() const
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
NullStmt - This is the null statement ";": C99 6.8.3p3.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
bool isKnownToHaveBooleanValue(bool Semantic=true) const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
Dataflow Directional Tag Classes.
bool isUnsaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
std::string getAsString() const
getAsString - Retrieve the human-readable string for this name.
bool isValid() const
Return true if this is a valid SourceLocation object.
static const UnaryExprOrTypeTraitExpr * getAsSizeOfExpr(const Expr *E)
bool GT(InterpState &S, CodePtr OpPC)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getLocation() const
EvalResult is a struct with detailed info about an evaluated expression.
PropertyAttributeKind getPropertyAttributesAsWritten() const
static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx)
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments for this type.
APFixedPoint getFixedPointMin(QualType Ty) const
bool isSEHExceptScope() const
Determine whether this scope is a SEH '__except' block.
static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, SourceLocation InitLoc)
Analyzes an attempt to assign the given value to a bitfield.
bool NE(InterpState &S, CodePtr OpPC)
static bool isX86_32Builtin(unsigned BuiltinID)
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
CanQualType UnsignedLongLongTy
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static QualType getAbsoluteValueArgumentType(ASTContext &Context, unsigned AbsType)
SourceLocation getSemiLoc() const
The name of a declaration.
StmtClass getStmtClass() const
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isBooleanType() const
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
U cast(CodeGen::Address addr)
static bool isSetterLikeSelector(Selector sel)
Check for a keyword selector that starts with the word 'add' or 'set'.
A set of unresolved declarations.
Expression is a C++11 nullptr.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
const OptionalFlag & isPrivate() const
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, bool IgnoreStringsWithoutSpecifiers=false)
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...
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner)
static bool IsSameCharType(QualType T1, QualType T2)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
SemaConvertVectorExpr - Handle __builtin_convertvector.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
param_iterator param_end()
static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall)
llvm::APInt getValue() const
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
bool hasValidAlternativeForm() const
unsigned getByteLength() const
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
unsigned getIntWidth(QualType T) const
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point...
static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID, CallExpr *Call)
static unsigned getBestAbsFunction(ASTContext &Context, QualType ArgType, unsigned AbsFunctionKind)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
bool isMacroArgExpansion(SourceLocation Loc, SourceLocation *StartLoc=nullptr) const
Tests whether the given source location represents a macro argument's expansion into the function-lik...
Iterator for iterating over Stmt * arrays that contain only T *.
static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call)
bool hasValidFieldWidth() const
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
QualType getCanonicalTypeInternal() const
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
bool isReserveIDT() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
static bool checkOpenCLEnqueueIntType(Sema &S, Expr *E, const QualType &IntType)
Diagnose integer type and any valid implicit conversion to it.
CanQualType UnsignedLongTy
static bool SemaBuiltinReserveRWPipe(Sema &S, CallExpr *Call)
bool hasNonTrivialObjCLifetime() const
const llvm::APInt & getSize() const
uint64_t getCharWidth() const
Return the size of the character type, in bits.
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
bool isAtomicType() const
static bool isKnownToHaveUnsignedValue(Expr *E)
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
bool isFunctionType() const
static unsigned RFT(unsigned t, bool shift=false, bool ForceQuad=false)
TypeSourceInfo * getTypeSourceInfo() const
static void checkObjCDictionaryLiteral(Sema &S, QualType TargetType, ObjCDictionaryLiteral *DictionaryLiteral)
Check an Objective-C dictionary literal being converted to the given target type. ...
ExtVectorType - Extended vector type.
const OptionalAmount & getPrecision() const
static bool isAdditiveOp(Opcode Opc)
static bool IsSameFloatAfterCast(const llvm::APFloat &value, const llvm::fltSemantics &Src, const llvm::fltSemantics &Tgt)
Checks whether the given value, which currently has the given source semantics, has the same value wh...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const
Compare the rank of two floating point types as above, but compare equal if both types have the same ...
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
The template argument is a type.
static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend, BinaryOperatorKind BinOpKind, bool AddendIsRight)
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
const OptionalFlag & isPublic() const
ObjCInterfaceDecl * NSArrayDecl
The declaration of the Objective-C NSArray class.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
const Expr * getBase() const
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, unsigned AbsKind, QualType ArgType)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
static bool isSameWidthConstantConversion(Sema &S, Expr *E, QualType T, SourceLocation CC)
Represents a base class of a C++ class.
A bitfield object is a bitfield on a C or C++ record.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
bool isObjectType() const
Determine whether this type is an object type.
static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex)
checkBuiltinArgument - Given a call to a builtin function, perform normal type-checking on the given ...
ObjCIvarRefExpr - A reference to an ObjC instance variable.
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
const OptionalFlag & hasSpacePrefix() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
static void DiagnoseIntInBoolContext(Sema &S, Expr *E)
uint64_t getFieldOffset(const ValueDecl *FD) const
Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Reading or writing from this object requires a barrier call.
static void DiagnoseNullConversion(Sema &S, Expr *E, QualType T, SourceLocation CC)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
Expression is a Null pointer constant built from a literal zero.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
static bool SemaBuiltinSEHScopeCheck(Sema &SemaRef, CallExpr *TheCall, Scope::ScopeFlags NeededScopeFlags, unsigned DiagID)
void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, unsigned DiagID)
Emit DiagID if statement located on StmtLoc has a suspicious null statement as a Body, and it is located on the same line.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static bool HasEnumType(Expr *E)
Defines the clang::SourceLocation class and associated facilities.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Provides definitions for the atomic synchronization scopes.
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, unsigned ByteNo) const
bool hasUnaligned() const
APFloat & getComplexFloatImag()
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
Expr * getTrueExpr() const
bool LE(InterpState &S, CodePtr OpPC)
static void CheckNonNullArgument(Sema &S, const Expr *ArgExpr, SourceLocation CallSiteLoc)
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
bool consumesDataArgument() const
ObjCIvarDecl - Represents an ObjC instance variable.
static bool isArgumentExpandedFromMacro(SourceManager &SM, SourceLocation CallLoc, SourceLocation ArgLoc)
Check if the ArgLoc originated from a macro passed to the call at CallLoc.
WhileStmt - This represents a 'while' stmt.
static bool SemaBuiltinCpuIs(Sema &S, CallExpr *TheCall)
SemaBuiltinCpuIs - Handle __builtin_cpu_is(char *).
ASTImporterLookupTable & LT
Builtin::Context & BuiltinInfo
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
static QualType getSizeOfArgType(const Expr *E)
If E is a sizeof expression, returns its argument type.
SourceManager & getSourceManager() const
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
__DEVICE__ int min(int __a, int __b)
static bool SemaBuiltinPreserveAI(Sema &S, CallExpr *TheCall)
Check the number of arguments and set the result type to the argument type.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
static bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx, const ValueDecl **VD, uint64_t *MagicValue, bool isConstantEvaluated)
Given a type tag expression find the type tag itself.
static Decl::Kind getKind(const Decl *D)
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
Warn if a value is moved to itself.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
static bool GetMatchingCType(const IdentifierInfo *ArgumentKind, const Expr *TypeExpr, const ASTContext &Ctx, const llvm::DenseMap< Sema::TypeTagMagicValue, Sema::TypeTagData > *MagicValues, bool &FoundWrongKind, Sema::TypeTagData &TypeInfo, bool isConstantEvaluated)
Retrieve the C type corresponding to type tag TypeExpr.
A reference to a declared variable, function, enum, etc.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
static unsigned getAbsoluteValueFunctionKind(const FunctionDecl *FDecl)
static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall)
Check that the argument to __builtin_addressof is a glvalue, and set the result type to the correspon...
bool isPointerType() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
SourceManager & SourceMgr
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
llvm::APSInt convertToInt(unsigned DstWidth, bool DstSign, bool *Overflow=nullptr) const
Return the integral part of this fixed point number, rounded towards zero.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
checkUnsafeExprAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained expressi...
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS)
checkUnsafeAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained type...
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static bool IsInAnyMacroBody(const SourceManager &SM, SourceLocation Loc)
bool isFloatingType() const
bool Load(InterpState &S, CodePtr OpPC)
const Expr * getBase() const
A trivial tuple used to represent a source range.
SourceLocation getBeginLoc() const LLVM_READONLY
This represents a decl that may have a name.
static void AnalyzeImplicitConversions(Sema &S, Expr *E, SourceLocation CC, bool IsListInit=false)
AnalyzeImplicitConversions - Find and report any interesting implicit conversions in the given expres...
static unsigned getLargerAbsoluteValueFunction(unsigned AbsFunction)
void DiagnoseAlwaysNonNullPointer(Expr *E, Expr::NullPointerConstantKind NullType, bool IsEqual, SourceRange Range)
Diagnose pointers that are always non-null.
static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, Expr *RHS, bool isProperty)
bool isConstant(const ASTContext &Ctx) const
static IntRange GetValueRange(ASTContext &C, llvm::APSInt &value, unsigned MaxWidth)
static bool SemaBuiltinAnnotation(Sema &S, CallExpr *TheCall)
Check that the first argument to __builtin_annotation is an integer and the second argument is a non-...
Describes an entity that is being initialized.
bool isFunctionPointerType() const
bool isInStdNamespace() const
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
static bool isComparisonOp(Opcode Opc)
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
static Expr * findCapturingExpr(Sema &S, Expr *e, RetainCycleOwner &owner)
Check whether the given argument is a block which captures a variable.
static Optional< int > GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message)
static bool SemaBuiltinCallWithStaticChain(Sema &S, CallExpr *BuiltinCall)
bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const
Represents the canonical version of C arrays with a specified constant size.
This class handles loading and caching of source files into memory.
bool isUnsignedInteger() const
bool isObjC(ID Id)
isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).
APFixedPoint & getFixedPoint()
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
Attr - This represents one attribute.
SourceLocation getLocation() const
bool EQ(InterpState &S, CodePtr OpPC)
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
QualType getType() const
Return the type wrapped by this type source info.
CanQualType OCLClkEventTy
static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, bool InConstantContext)
Pseudo-evaluate the given integer expression, estimating the range of values it might take...
ArrayRef< ParmVarDecl * > parameters() const
bool EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsFloat - Return true if this is a constant which we can fold and convert to a floating point...
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr, SourceLocation StmtLoc, const NullStmt *Body)
CanQualType UnsignedIntTy
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign, ASTContext &Context)
A helper function to get the alignment of a Decl referred to by DeclRefExpr or MemberExpr.
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
SourceLocation getTopMacroCallerLoc(SourceLocation Loc) const
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
unsigned getVectorLength() const