Merge llvm-project main llvmorg-13-init-16847-g88e66fa60ae5

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13-init-16847-g88e66fa60ae5, the last commit before
the upstream release/13.x branch was created.

PR:		258209
MFC after:	2 weeks
This commit is contained in:
Dimitry Andric
2021-08-22 21:00:43 +02:00
5472 changed files with 393662 additions and 203435 deletions
+291
View File
@@ -40,6 +40,297 @@
# xargs -n1 | sort | uniq -d;
# done
# 20211113: new clang import which bumps version from 12.0.1 to 13.0.0.
OLD_FILES+=usr/lib/clang/12.0.1/include/cuda_wrappers/algorithm
OLD_FILES+=usr/lib/clang/12.0.1/include/cuda_wrappers/complex
OLD_FILES+=usr/lib/clang/12.0.1/include/cuda_wrappers/new
OLD_DIRS+=usr/lib/clang/12.0.1/include/cuda_wrappers
OLD_FILES+=usr/lib/clang/12.0.1/include/fuzzer/FuzzedDataProvider.h
OLD_DIRS+=usr/lib/clang/12.0.1/include/fuzzer
OLD_FILES+=usr/lib/clang/12.0.1/include/openmp_wrappers/__clang_openmp_device_functions.h
OLD_FILES+=usr/lib/clang/12.0.1/include/openmp_wrappers/cmath
OLD_FILES+=usr/lib/clang/12.0.1/include/openmp_wrappers/complex
OLD_FILES+=usr/lib/clang/12.0.1/include/openmp_wrappers/complex.h
OLD_FILES+=usr/lib/clang/12.0.1/include/openmp_wrappers/complex_cmath.h
OLD_FILES+=usr/lib/clang/12.0.1/include/openmp_wrappers/math.h
OLD_FILES+=usr/lib/clang/12.0.1/include/openmp_wrappers/new
OLD_DIRS+=usr/lib/clang/12.0.1/include/openmp_wrappers
OLD_FILES+=usr/lib/clang/12.0.1/include/ppc_wrappers/emmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ppc_wrappers/mm_malloc.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ppc_wrappers/mmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ppc_wrappers/pmmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ppc_wrappers/smmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ppc_wrappers/tmmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ppc_wrappers/xmmintrin.h
OLD_DIRS+=usr/lib/clang/12.0.1/include/ppc_wrappers
OLD_FILES+=usr/lib/clang/12.0.1/include/profile/InstrProfData.inc
OLD_DIRS+=usr/lib/clang/12.0.1/include/profile
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/allocator_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/asan_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/common_interface_defs.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/coverage_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/dfsan_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/hwasan_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/linux_syscall_hooks.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/lsan_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/msan_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/netbsd_syscall_hooks.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/scudo_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/tsan_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/tsan_interface_atomic.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sanitizer/ubsan_interface.h
OLD_DIRS+=usr/lib/clang/12.0.1/include/sanitizer
OLD_FILES+=usr/lib/clang/12.0.1/include/xray/xray_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/xray/xray_log_interface.h
OLD_FILES+=usr/lib/clang/12.0.1/include/xray/xray_records.h
OLD_DIRS+=usr/lib/clang/12.0.1/include/xray
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_cuda_builtin_vars.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_cuda_cmath.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_cuda_complex_builtins.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_cuda_device_functions.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_cuda_intrinsics.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_cuda_libdevice_declares.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_cuda_math.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_cuda_math_forward_declares.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_cuda_runtime_wrapper.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_hip_cmath.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_hip_libdevice_declares.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_hip_math.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__clang_hip_runtime_wrapper.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__stddef_max_align_t.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__wmmintrin_aes.h
OLD_FILES+=usr/lib/clang/12.0.1/include/__wmmintrin_pclmul.h
OLD_FILES+=usr/lib/clang/12.0.1/include/adxintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/altivec.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ammintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/amxintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/arm64intr.h
OLD_FILES+=usr/lib/clang/12.0.1/include/arm_acle.h
OLD_FILES+=usr/lib/clang/12.0.1/include/arm_bf16.h
OLD_FILES+=usr/lib/clang/12.0.1/include/arm_cde.h
OLD_FILES+=usr/lib/clang/12.0.1/include/arm_cmse.h
OLD_FILES+=usr/lib/clang/12.0.1/include/arm_fp16.h
OLD_FILES+=usr/lib/clang/12.0.1/include/arm_mve.h
OLD_FILES+=usr/lib/clang/12.0.1/include/arm_neon.h
OLD_FILES+=usr/lib/clang/12.0.1/include/arm_sve.h
OLD_FILES+=usr/lib/clang/12.0.1/include/armintr.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx2intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512bf16intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512bitalgintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512bwintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512cdintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512dqintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512erintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512fintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512ifmaintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512ifmavlintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512pfintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vbmi2intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vbmiintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vbmivlintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vlbf16intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vlbitalgintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vlbwintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vlcdintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vldqintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vlintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vlvbmi2intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vlvnniintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vlvp2intersectintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vnniintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vp2intersectintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vpopcntdqintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avx512vpopcntdqvlintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avxintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/avxvnniintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/bmi2intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/bmiintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/cet.h
OLD_FILES+=usr/lib/clang/12.0.1/include/cetintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/cldemoteintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/clflushoptintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/clwbintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/clzerointrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/cpuid.h
OLD_FILES+=usr/lib/clang/12.0.1/include/emmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/enqcmdintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/f16cintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/float.h
OLD_FILES+=usr/lib/clang/12.0.1/include/fma4intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/fmaintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/fxsrintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/gfniintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/hresetintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/htmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/htmxlintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ia32intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/immintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/inttypes.h
OLD_FILES+=usr/lib/clang/12.0.1/include/invpcidintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/iso646.h
OLD_FILES+=usr/lib/clang/12.0.1/include/keylockerintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/limits.h
OLD_FILES+=usr/lib/clang/12.0.1/include/lwpintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/lzcntintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/mm3dnow.h
OLD_FILES+=usr/lib/clang/12.0.1/include/mm_malloc.h
OLD_FILES+=usr/lib/clang/12.0.1/include/mmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/module.modulemap
OLD_FILES+=usr/lib/clang/12.0.1/include/movdirintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/msa.h
OLD_FILES+=usr/lib/clang/12.0.1/include/mwaitxintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/nmmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/omp-tools.h
OLD_FILES+=usr/lib/clang/12.0.1/include/omp.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ompt.h
OLD_FILES+=usr/lib/clang/12.0.1/include/opencl-c-base.h
OLD_FILES+=usr/lib/clang/12.0.1/include/opencl-c.h
OLD_FILES+=usr/lib/clang/12.0.1/include/pconfigintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/pkuintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/pmmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/popcntintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/prfchwintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/ptwriteintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/rdseedintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/rtmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/s390intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/serializeintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/sgxintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/shaintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/smmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/stdalign.h
OLD_FILES+=usr/lib/clang/12.0.1/include/stdarg.h
OLD_FILES+=usr/lib/clang/12.0.1/include/stdatomic.h
OLD_FILES+=usr/lib/clang/12.0.1/include/stdbool.h
OLD_FILES+=usr/lib/clang/12.0.1/include/stddef.h
OLD_FILES+=usr/lib/clang/12.0.1/include/stdint.h
OLD_FILES+=usr/lib/clang/12.0.1/include/stdnoreturn.h
OLD_FILES+=usr/lib/clang/12.0.1/include/tbmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/tgmath.h
OLD_FILES+=usr/lib/clang/12.0.1/include/tmmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/tsxldtrkintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/uintrintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/unwind.h
OLD_FILES+=usr/lib/clang/12.0.1/include/vadefs.h
OLD_FILES+=usr/lib/clang/12.0.1/include/vaesintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/varargs.h
OLD_FILES+=usr/lib/clang/12.0.1/include/vecintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/vpclmulqdqintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/waitpkgintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/wasm_simd128.h
OLD_FILES+=usr/lib/clang/12.0.1/include/wbnoinvdintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/wmmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/x86gprintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/x86intrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/xmmintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/xopintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/xsavecintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/xsaveintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/xsaveoptintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/xsavesintrin.h
OLD_FILES+=usr/lib/clang/12.0.1/include/xtestintrin.h
OLD_DIRS+=usr/lib/clang/12.0.1/include
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-aarch64.so
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-arm.so
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-armhf.so
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-i386.so
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-preinit-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-preinit-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-preinit-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-preinit-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-preinit-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan-x86_64.so
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan_cxx-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan_cxx-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan_cxx-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan_cxx-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.asan_cxx-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi_diag-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi_diag-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi_diag-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi_diag-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.cfi_diag-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.dd-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.dd-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.fuzzer-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.fuzzer-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.fuzzer_no_main-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.fuzzer_no_main-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.msan-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.msan-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.msan_cxx-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.msan_cxx-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.profile-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.profile-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.profile-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.profile-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.profile-powerpc.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.profile-powerpc64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.profile-powerpc64le.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.profile-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.safestack-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.safestack-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.safestack-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats_client-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats_client-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats_client-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats_client-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.stats_client-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.tsan-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.tsan-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.tsan_cxx-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.tsan_cxx-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_minimal-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_minimal-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_minimal-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_minimal-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_minimal-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-i386.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-basic-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-basic-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-basic-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-basic-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-fdr-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-fdr-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-fdr-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-fdr-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-profiling-aarch64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-profiling-arm.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-profiling-armhf.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-profiling-x86_64.a
OLD_FILES+=usr/lib/clang/12.0.1/lib/freebsd/libclang_rt.xray-x86_64.a
OLD_DIRS+=usr/lib/clang/12.0.1/lib/freebsd
OLD_DIRS+=usr/lib/clang/12.0.1/lib
OLD_DIRS+=usr/lib/clang/12.0.1
# 20211027: libdialog shlib bumped to version 10 for dialog 1.3
OLD_LIBS+=usr/lib/libdialog.so.9
OLD_LIBS+=usr/lib/libdpv.so.2
@@ -33,7 +33,7 @@
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
*/
#define CINDEX_VERSION_MAJOR 0
#define CINDEX_VERSION_MINOR 61
#define CINDEX_VERSION_MINOR 62
#define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
@@ -2568,7 +2568,31 @@ enum CXCursorKind {
*/
CXCursor_OMPScanDirective = 287,
CXCursor_LastStmt = CXCursor_OMPScanDirective,
/** OpenMP tile directive.
*/
CXCursor_OMPTileDirective = 288,
/** OpenMP canonical loop.
*/
CXCursor_OMPCanonicalLoop = 289,
/** OpenMP interop directive.
*/
CXCursor_OMPInteropDirective = 290,
/** OpenMP dispatch directive.
*/
CXCursor_OMPDispatchDirective = 291,
/** OpenMP masked directive.
*/
CXCursor_OMPMaskedDirective = 292,
/** OpenMP unroll directive.
*/
CXCursor_OMPUnrollDirective = 293,
CXCursor_LastStmt = CXCursor_OMPUnrollDirective,
/**
* Cursor that represents the translation unit itself.
@@ -3394,6 +3418,7 @@ enum CXCallingConv {
CXCallingConv_PreserveMost = 14,
CXCallingConv_PreserveAll = 15,
CXCallingConv_AArch64VectorCall = 16,
CXCallingConv_SwiftAsync = 17,
CXCallingConv_Invalid = 100,
CXCallingConv_Unexposed = 200
@@ -14,12 +14,13 @@
#ifndef LLVM_CLANG_AST_ASTCONCEPT_H
#define LLVM_CLANG_AST_ASTCONCEPT_H
#include "clang/AST/Expr.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/SmallVector.h"
#include <string>
#include <utility>
namespace clang {
class ConceptDecl;
class ConceptSpecializationExpr;
@@ -34,12 +34,13 @@
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/Linkage.h"
#include "clang/Basic/NoSanitizeList.h"
#include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/PartialDiagnostic.h"
#include "clang/Basic/ProfileList.h"
#include "clang/Basic/SanitizerBlacklist.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Basic/TargetCXXABI.h"
#include "clang/Basic/XRayLists.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/ArrayRef.h"
@@ -102,6 +103,7 @@ class DynTypedNode;
class DynTypedNodeList;
class Expr;
class GlobalDecl;
class ItaniumMangleContext;
class MangleContext;
class MangleNumberingContext;
class MaterializeTemporaryExpr;
@@ -299,6 +301,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// This is lazily created. This is intentionally not serialized.
mutable llvm::StringMap<StringLiteral *> StringLiteralCache;
/// MD5 hash of CUID. It is calculated when first used and cached by this
/// data member.
mutable std::string CUIDHash;
/// Representation of a "canonical" template template parameter that
/// is used in canonical template names.
class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
@@ -453,6 +459,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
friend class ASTWriter;
template <class> friend class serialization::AbstractTypeReader;
friend class CXXRecordDecl;
friend class IncrementalParser;
/// A mapping to contain the template or declaration that
/// a variable declaration describes or was instantiated from,
@@ -512,6 +519,17 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// B<int> to the UnresolvedUsingDecl in B<T>.
llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingDecl;
/// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps
/// from the instantiated using-enum to the templated decl from whence it
/// came.
/// Note that using-enum-declarations cannot be dependent and
/// thus will never be instantiated from an "unresolved"
/// version thereof (as with using-declarations), so each mapping is from
/// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl.
llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
InstantiatedFromUsingEnumDecl;
/// Simlarly maps instantiated UsingShadowDecls to their origin.
llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
InstantiatedFromUsingShadowDecl;
@@ -550,7 +568,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
ImportDecl *FirstLocalImport = nullptr;
ImportDecl *LastLocalImport = nullptr;
TranslationUnitDecl *TUDecl;
TranslationUnitDecl *TUDecl = nullptr;
mutable ExternCContextDecl *ExternCContext = nullptr;
mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr;
mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr;
@@ -562,9 +580,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// this ASTContext object.
LangOptions &LangOpts;
/// Blacklist object that is used by sanitizers to decide which
/// NoSanitizeList object that is used by sanitizers to decide which
/// entities should not be instrumented.
std::unique_ptr<SanitizerBlacklist> SanitizerBL;
std::unique_ptr<NoSanitizeList> NoSanitizeL;
/// Function filtering mechanism to determine whether a given function
/// should be imbued with the XRay "always" or "never" attributes.
@@ -600,10 +618,14 @@ class ASTContext : public RefCountedBase<ASTContext> {
std::unique_ptr<interp::Context> InterpContext;
std::unique_ptr<ParentMapContext> ParentMapCtx;
/// Keeps track of the deallocated DeclListNodes for future reuse.
DeclListNode *ListNodeFreeList = nullptr;
public:
IdentifierTable &Idents;
SelectorTable &Selectors;
Builtin::Context &BuiltinInfo;
const TranslationUnitKind TUKind;
mutable DeclarationNameTable DeclarationNames;
IntrusiveRefCntPtr<ExternalASTSource> ExternalSource;
ASTMutationListener *Listener = nullptr;
@@ -615,11 +637,22 @@ class ASTContext : public RefCountedBase<ASTContext> {
ParentMapContext &getParentMapContext();
// A traversal scope limits the parts of the AST visible to certain analyses.
// RecursiveASTVisitor::TraverseAST will only visit reachable nodes, and
// RecursiveASTVisitor only visits specified children of TranslationUnitDecl.
// getParents() will only observe reachable parent edges.
//
// The scope is defined by a set of "top-level" declarations.
// Initially, it is the entire TU: {getTranslationUnitDecl()}.
// The scope is defined by a set of "top-level" declarations which will be
// visible under the TranslationUnitDecl.
// Initially, it is the entire TU, represented by {getTranslationUnitDecl()}.
//
// After setTraversalScope({foo, bar}), the exposed AST looks like:
// TranslationUnitDecl
// - foo
// - ...
// - bar
// - ...
// All other siblings of foo and bar are pruned from the tree.
// (However they are still accessible via TranslationUnitDecl->decls())
//
// Changing the scope clears the parent cache, which is expensive to rebuild.
std::vector<Decl *> getTraversalScope() const { return TraversalScope; }
void setTraversalScope(const std::vector<Decl *> &);
@@ -651,6 +684,24 @@ class ASTContext : public RefCountedBase<ASTContext> {
}
void Deallocate(void *Ptr) const {}
/// Allocates a \c DeclListNode or returns one from the \c ListNodeFreeList
/// pool.
DeclListNode *AllocateDeclListNode(clang::NamedDecl *ND) {
if (DeclListNode *Alloc = ListNodeFreeList) {
ListNodeFreeList = Alloc->Rest.dyn_cast<DeclListNode*>();
Alloc->D = ND;
Alloc->Rest = nullptr;
return Alloc;
}
return new (*this) DeclListNode(ND);
}
/// Deallcates a \c DeclListNode by returning it to the \c ListNodeFreeList
/// pool.
void DeallocateDeclListNode(DeclListNode *N) {
N->Rest = ListNodeFreeList;
ListNodeFreeList = N;
}
/// Return the total amount of physical memory allocated for representing
/// AST nodes and type information.
size_t getASTAllocatedMemory() const {
@@ -691,9 +742,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
}
const SanitizerBlacklist &getSanitizerBlacklist() const {
return *SanitizerBL;
}
const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; }
const XRayFunctionFilter &getXRayFilter() const {
return *XRayFilter;
@@ -707,6 +756,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
return FullSourceLoc(Loc,SourceMgr);
}
/// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
/// at compile time with `-fc++-abi=`. If this is not provided, we instead use
/// the default ABI set by the target.
TargetCXXABI::Kind getCXXABIKind() const;
/// All comments in this translation unit.
RawCommentList Comments;
@@ -856,30 +910,38 @@ class ASTContext : public RefCountedBase<ASTContext> {
MemberSpecializationInfo *getInstantiatedFromStaticDataMember(
const VarDecl *Var);
TemplateOrSpecializationInfo
getTemplateOrSpecializationInfo(const VarDecl *Var);
/// Note that the static data member \p Inst is an instantiation of
/// the static data member template \p Tmpl of a class template.
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl,
TemplateSpecializationKind TSK,
SourceLocation PointOfInstantiation = SourceLocation());
TemplateOrSpecializationInfo
getTemplateOrSpecializationInfo(const VarDecl *Var);
void setTemplateOrSpecializationInfo(VarDecl *Inst,
TemplateOrSpecializationInfo TSI);
/// If the given using decl \p Inst is an instantiation of a
/// (possibly unresolved) using decl from a template instantiation,
/// return it.
/// If the given using decl \p Inst is an instantiation of
/// another (possibly unresolved) using decl, return it.
NamedDecl *getInstantiatedFromUsingDecl(NamedDecl *Inst);
/// Remember that the using decl \p Inst is an instantiation
/// of the using decl \p Pattern of a class template.
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern);
/// If the given using-enum decl \p Inst is an instantiation of
/// another using-enum decl, return it.
UsingEnumDecl *getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst);
/// Remember that the using enum decl \p Inst is an instantiation
/// of the using enum decl \p Pattern of a class template.
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst,
UsingEnumDecl *Pattern);
UsingShadowDecl *getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst);
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst,
UsingShadowDecl *Pattern);
UsingShadowDecl *getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst);
FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field);
@@ -962,7 +1024,18 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// Get the initializations to perform when importing a module, if any.
ArrayRef<Decl*> getModuleInitializers(Module *M);
TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
TranslationUnitDecl *getTranslationUnitDecl() const {
return TUDecl->getMostRecentDecl();
}
void addTranslationUnitDecl() {
assert(!TUDecl || TUKind == TU_Incremental);
TranslationUnitDecl *NewTUDecl = TranslationUnitDecl::Create(*this);
if (TraversalScope.empty() || TraversalScope.back() == TUDecl)
TraversalScope = {NewTUDecl};
if (TUDecl)
NewTUDecl->setPreviousDecl(TUDecl);
TUDecl = NewTUDecl;
}
ExternCContextDecl *getExternCContextDecl() const;
BuiltinTemplateDecl *getMakeIntegerSeqDecl() const;
@@ -1020,6 +1093,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
#define PPC_VECTOR_TYPE(Name, Id, Size) \
CanQualType Id##Ty;
#include "clang/Basic/PPCTypes.def"
#define RVV_TYPE(Name, Id, SingletonId) \
CanQualType SingletonId;
#include "clang/Basic/RISCVVTypes.def"
// Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
mutable QualType AutoDeductTy; // Deduction against 'auto'.
@@ -1032,11 +1108,12 @@ class ASTContext : public RefCountedBase<ASTContext> {
// Implicitly-declared type 'struct _GUID'.
mutable TagDecl *MSGuidTagDecl = nullptr;
/// Keep track of CUDA/HIP static device variables referenced by host code.
llvm::DenseSet<const VarDecl *> CUDAStaticDeviceVarReferencedByHost;
/// Keep track of CUDA/HIP device-side variables ODR-used by host code.
llvm::DenseSet<const VarDecl *> CUDADeviceVarODRUsedByHost;
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents,
SelectorTable &sels, Builtin::Context &builtins);
SelectorTable &sels, Builtin::Context &builtins,
TranslationUnitKind TUKind);
ASTContext(const ASTContext &) = delete;
ASTContext &operator=(const ASTContext &) = delete;
~ASTContext();
@@ -2323,6 +2400,12 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// If \p T is null pointer, assume the target in ASTContext.
MangleContext *createMangleContext(const TargetInfo *T = nullptr);
/// Creates a device mangle context to correctly mangle lambdas in a mixed
/// architecture compile by setting the lambda mangling number source to the
/// DeviceLambdaManglingNumber. Currently this asserts that the TargetInfo
/// (from the AuxTargetInfo) is a an itanium target.
MangleContext *createDeviceMangleContext(const TargetInfo &T);
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
SmallVectorImpl<const ObjCIvarDecl*> &Ivars) const;
@@ -2423,7 +2506,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
const ObjCMethodDecl *MethodImp);
bool UnwrapSimilarTypes(QualType &T1, QualType &T2);
bool UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
/// Determine if two types are similar, according to the C++ rules. That is,
/// determine if they are the same other than qualifiers on the initial
@@ -2722,6 +2805,14 @@ class ASTContext : public RefCountedBase<ASTContext> {
// a given fixed point type.
QualType getCorrespondingUnsignedType(QualType T) const;
// Per C99 6.2.5p6, for every signed integer type, there is a corresponding
// unsigned integer type. This method takes an unsigned type, and returns the
// corresponding signed integer type.
// With the introduction of fixed point types in ISO N1169, this method also
// accepts fixed point types and returns the corresponding signed type for
// a given fixed point type.
QualType getCorrespondingSignedType(QualType T) const;
// Per ISO N1169, this method accepts fixed point types and returns the
// corresponding saturated type for a given fixed point type.
QualType getCorrespondingSaturatedType(QualType Ty) const;
@@ -3116,10 +3207,33 @@ OPT_LIST(V)
/// Whether a C++ static variable should be externalized.
bool shouldExternalizeStaticVar(const Decl *D) const;
StringRef getCUIDHash() const;
void AddSYCLKernelNamingDecl(const CXXRecordDecl *RD);
bool IsSYCLKernelNamingDecl(const NamedDecl *RD) const;
unsigned GetSYCLKernelNamingIndex(const NamedDecl *RD);
/// A SourceLocation to store whether we have evaluated a kernel name already,
/// and where it happened. If so, we need to diagnose an illegal use of the
/// builtin.
llvm::MapVector<const SYCLUniqueStableNameExpr *, std::string>
SYCLUniqueStableNameEvaluatedValues;
private:
/// All OMPTraitInfo objects live in this collection, one per
/// `pragma omp [begin] declare variant` directive.
SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector;
/// A list of the (right now just lambda decls) declarations required to
/// name all the SYCL kernels in the translation unit, so that we can get the
/// correct kernel name, as well as implement
/// __builtin_sycl_unique_stable_name.
llvm::DenseMap<const DeclContext *,
llvm::SmallPtrSet<const CXXRecordDecl *, 4>>
SYCLKernelNamingTypes;
std::unique_ptr<ItaniumMangleContext> SYCLKernelFilterContext;
void FilterSYCLKernelNamingDecls(
const CXXRecordDecl *RD,
llvm::SmallVectorImpl<const CXXRecordDecl *> &Decls);
};
/// Insertion operator for diagnostics.
@@ -93,8 +93,6 @@ class TypeSourceInfo;
using NonEquivalentDeclSet = llvm::DenseSet<std::pair<Decl *, Decl *>>;
using ImportedCXXBaseSpecifierMap =
llvm::DenseMap<const CXXBaseSpecifier *, CXXBaseSpecifier *>;
using FileIDImportHandlerType =
std::function<void(FileID /*ToID*/, FileID /*FromID*/)>;
enum class ODRHandlingType { Conservative, Liberal };
@@ -220,8 +218,6 @@ class TypeSourceInfo;
};
private:
FileIDImportHandlerType FileIDImportHandler;
std::shared_ptr<ASTImporterSharedState> SharedState = nullptr;
/// The path which we go through during the import of a given AST node.
@@ -324,14 +320,6 @@ class TypeSourceInfo;
virtual ~ASTImporter();
/// Set a callback function for FileID import handling.
/// The function is invoked when a FileID is imported from the From context.
/// The imported FileID in the To context and the original FileID in the
/// From context is passed to it.
void setFileIDImportHandler(FileIDImportHandlerType H) {
FileIDImportHandler = H;
}
/// Whether the importer will perform a minimal import, creating
/// to-be-completed forward declarations when possible.
bool isMinimalImport() const { return Minimal; }
@@ -356,6 +344,12 @@ class TypeSourceInfo;
Import(ExprWithCleanups::CleanupObject From);
/// Import the given type from the "from" context into the "to"
/// context.
///
/// \returns The equivalent type in the "to" context, or the import error.
llvm::Expected<const Type *> Import(const Type *FromT);
/// Import the given qualified type from the "from" context into the "to"
/// context. A null type is imported as a null type (no error).
///
/// \returns The equivalent type in the "to" context, or the import error.
@@ -63,8 +63,24 @@ class ASTImporterLookupTable {
ASTImporterLookupTable(TranslationUnitDecl &TU);
void add(NamedDecl *ND);
void remove(NamedDecl *ND);
// Sometimes a declaration is created first with a temporarily value of decl
// context (often the translation unit) and later moved to the final context.
// This happens for declarations that are created before the final declaration
// context. In such cases the lookup table needs to be updated.
// (The declaration is in these cases not added to the temporary decl context,
// only its parent is set.)
// FIXME: It would be better to not add the declaration to the temporary
// context at all in the lookup table, but this requires big change in
// ASTImporter.
// The function should be called when the old context is definitely different
// from the new.
void update(NamedDecl *ND, DeclContext *OldDC);
using LookupResult = DeclList;
LookupResult lookup(DeclContext *DC, DeclarationName Name) const;
// Check if the `ND` is within the lookup table (with its current name) in
// context `DC`. This is intended for debug purposes when the DeclContext of a
// NamedDecl is changed.
bool contains(DeclContext *DC, NamedDecl *ND) const;
void dump(DeclContext *DC) const;
void dump() const;
};
@@ -53,6 +53,7 @@ struct {
void Visit(const OMPClause *C);
void Visit(const BlockDecl::Capture &C);
void Visit(const GenericSelectionExpr::ConstAssociation &A);
void Visit(const concepts::Requirement *R);
void Visit(const APValue &Value, QualType Ty);
};
*/
@@ -141,7 +142,8 @@ class ASTNodeTraverser
ConstStmtVisitor<Derived>::Visit(S);
// Some statements have custom mechanisms for dumping their children.
if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S))
if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S) ||
isa<RequiresExpr>(S))
return;
if (Traversal == TK_IgnoreUnlessSpelledInSource &&
@@ -228,6 +230,28 @@ class ASTNodeTraverser
});
}
void Visit(const concepts::Requirement *R) {
getNodeDelegate().AddChild([=] {
getNodeDelegate().Visit(R);
if (!R)
return;
if (auto *TR = dyn_cast<concepts::TypeRequirement>(R)) {
if (!TR->isSubstitutionFailure())
Visit(TR->getType()->getType().getTypePtr());
} else if (auto *ER = dyn_cast<concepts::ExprRequirement>(R)) {
if (!ER->isExprSubstitutionFailure())
Visit(ER->getExpr());
if (!ER->getReturnTypeRequirement().isEmpty())
Visit(ER->getReturnTypeRequirement()
.getTypeConstraint()
->getImmediatelyDeclaredConstraint());
} else if (auto *NR = dyn_cast<concepts::NestedRequirement>(R)) {
if (!NR->isSubstitutionFailure())
Visit(NR->getConstraintExpr());
}
});
}
void Visit(const APValue &Value, QualType Ty) {
getNodeDelegate().AddChild([=] { getNodeDelegate().Visit(Value, Ty); });
}
@@ -438,6 +462,8 @@ class ASTNodeTraverser
}
void VisitBindingDecl(const BindingDecl *D) {
if (Traversal == TK_IgnoreUnlessSpelledInSource)
return;
if (const auto *E = D->getBinding())
Visit(E);
}
@@ -687,6 +713,13 @@ class ASTNodeTraverser
}
}
void VisitRequiresExpr(const RequiresExpr *E) {
for (auto *D : E->getLocalParameters())
Visit(D);
for (auto *R : E->getRequirements())
Visit(R);
}
void VisitLambdaExpr(const LambdaExpr *Node) {
if (Traversal == TK_IgnoreUnlessSpelledInSource) {
for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
@@ -208,6 +208,8 @@ class ParameterABIAttr : public InheritableParamAttr {
switch (getKind()) {
case attr::SwiftContext:
return ParameterABI::SwiftContext;
case attr::SwiftAsyncContext:
return ParameterABI::SwiftAsyncContext;
case attr::SwiftErrorResult:
return ParameterABI::SwiftErrorResult;
case attr::SwiftIndirectResult:
@@ -76,9 +76,8 @@ class CXXBasePath : public SmallVector<CXXBasePathElement, 4> {
CXXBasePath() = default;
/// The set of declarations found inside this base class
/// subobject.
DeclContext::lookup_result Decls;
/// The declarations found inside this base class subobject.
DeclContext::lookup_iterator Decls;
void clear() {
SmallVectorImpl<CXXBasePathElement>::clear();
@@ -242,4 +242,8 @@ FIELD(HasDeclaredCopyConstructorWithConstParam, 1, MERGE_OR)
/// const-qualified reference parameter or a non-reference parameter.
FIELD(HasDeclaredCopyAssignmentWithConstParam, 1, MERGE_OR)
/// Whether the destructor is no-return. Either explicitly, or if any
/// base classes or fields have a no-return destructor
FIELD(IsAnyDestructorNoReturn, 1, NO_MERGE)
#undef FIELD
@@ -19,6 +19,7 @@
#include "llvm/ADT/DenseMap.h"
#include <array>
#include <cassert>
#include <vector>
namespace llvm {
class StringRef;
@@ -71,6 +71,7 @@ class OverloadExpr;
class DependentScopeDeclRefExpr;
class CXXConstructExpr;
class CXXDefaultInitExpr;
class CXXDefaultArgExpr;
class LambdaExpr;
class CXXUnresolvedConstructExpr;
class CXXDependentScopeMemberExpr;
@@ -78,6 +79,7 @@ class MaterializeTemporaryExpr;
class CXXFoldExpr;
class TypeTraitExpr;
class ConceptSpecializationExpr;
class SYCLUniqueStableNameExpr;
class PredefinedExpr;
class CallExpr;
class OffsetOfExpr;
@@ -155,6 +157,7 @@ ExprDependence computeDependence(OverloadExpr *E, bool KnownDependent,
ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
ExprDependence computeDependence(CXXConstructExpr *E);
ExprDependence computeDependence(CXXDefaultInitExpr *E);
ExprDependence computeDependence(CXXDefaultArgExpr *E);
ExprDependence computeDependence(LambdaExpr *E,
bool ContainsUnexpandedParameterPack);
ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);
@@ -165,6 +168,7 @@ ExprDependence computeDependence(TypeTraitExpr *E);
ExprDependence computeDependence(ConceptSpecializationExpr *E,
bool ValueDependent);
ExprDependence computeDependence(SYCLUniqueStableNameExpr *E);
ExprDependence computeDependence(PredefinedExpr *E);
ExprDependence computeDependence(CallExpr *E, llvm::ArrayRef<Expr *> PreArgs);
ExprDependence computeDependence(OffsetOfExpr *E);
@@ -79,7 +79,23 @@ class UnresolvedSetImpl;
class VarTemplateDecl;
/// The top declaration context.
class TranslationUnitDecl : public Decl, public DeclContext {
class TranslationUnitDecl : public Decl,
public DeclContext,
public Redeclarable<TranslationUnitDecl> {
using redeclarable_base = Redeclarable<TranslationUnitDecl>;
TranslationUnitDecl *getNextRedeclarationImpl() override {
return getNextRedeclaration();
}
TranslationUnitDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
}
TranslationUnitDecl *getMostRecentDeclImpl() override {
return getMostRecentDecl();
}
ASTContext &Ctx;
/// The (most recently entered) anonymous namespace for this
@@ -91,6 +107,16 @@ class TranslationUnitDecl : public Decl, public DeclContext {
virtual void anchor();
public:
using redecl_range = redeclarable_base::redecl_range;
using redecl_iterator = redeclarable_base::redecl_iterator;
using redeclarable_base::getMostRecentDecl;
using redeclarable_base::getPreviousDecl;
using redeclarable_base::isFirstDecl;
using redeclarable_base::redecls;
using redeclarable_base::redecls_begin;
using redeclarable_base::redecls_end;
ASTContext &getASTContext() const { return Ctx; }
NamespaceDecl *getAnonymousNamespace() const { return AnonymousNamespace; }
@@ -356,6 +382,10 @@ class NamedDecl : public Decl {
/// a C++ class.
bool isCXXInstanceMember() const;
/// Determine if the declaration obeys the reserved identifier rules of the
/// given language.
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const;
/// Determine what kind of linkage this entity has.
///
/// This is not the linkage as defined by the standard or the codegen notion
@@ -579,6 +609,16 @@ class NamespaceDecl : public NamedDecl, public DeclContext,
AnonOrFirstNamespaceAndInline.setInt(Inline);
}
/// Returns true if the inline qualifier for \c Name is redundant.
bool isRedundantInlineQualifierFor(DeclarationName Name) const {
if (!isInline())
return false;
auto X = lookup(Name);
auto Y = getParent()->lookup(Name);
return std::distance(X.begin(), X.end()) ==
std::distance(Y.begin(), Y.end());
}
/// Get the original (first) namespace declaration.
NamespaceDecl *getOriginalNamespace();
@@ -1477,6 +1517,9 @@ class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> {
NonParmVarDeclBits.EscapingByref = true;
}
/// Determines if this variable's alignment is dependent.
bool hasDependentAlignment() const;
/// Retrieve the variable declaration from which this variable could
/// be instantiated, if it is an instantiation (rather than a non-template).
VarDecl *getTemplateInstantiationPattern() const;
@@ -1220,65 +1220,110 @@ class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry {
void print(raw_ostream &OS) const override;
};
} // namespace clang
/// The results of name lookup within a DeclContext. This is either a
/// single result (with no stable storage) or a collection of results (with
/// stable storage provided by the lookup table).
// Required to determine the layout of the PointerUnion<NamedDecl*> before
// seeing the NamedDecl definition being first used in DeclListNode::operator*.
namespace llvm {
template <> struct PointerLikeTypeTraits<::clang::NamedDecl *> {
static inline void *getAsVoidPointer(::clang::NamedDecl *P) { return P; }
static inline ::clang::NamedDecl *getFromVoidPointer(void *P) {
return static_cast<::clang::NamedDecl *>(P);
}
static constexpr int NumLowBitsAvailable = 3;
};
}
namespace clang {
/// A list storing NamedDecls in the lookup tables.
class DeclListNode {
friend class ASTContext; // allocate, deallocate nodes.
friend class StoredDeclsList;
public:
using Decls = llvm::PointerUnion<NamedDecl*, DeclListNode*>;
class iterator {
friend class DeclContextLookupResult;
friend class StoredDeclsList;
Decls Ptr;
iterator(Decls Node) : Ptr(Node) { }
public:
using difference_type = ptrdiff_t;
using value_type = NamedDecl*;
using pointer = void;
using reference = value_type;
using iterator_category = std::forward_iterator_tag;
iterator() = default;
reference operator*() const {
assert(Ptr && "dereferencing end() iterator");
if (DeclListNode *CurNode = Ptr.dyn_cast<DeclListNode*>())
return CurNode->D;
return Ptr.get<NamedDecl*>();
}
void operator->() const { } // Unsupported.
bool operator==(const iterator &X) const { return Ptr == X.Ptr; }
bool operator!=(const iterator &X) const { return Ptr != X.Ptr; }
inline iterator &operator++() { // ++It
assert(!Ptr.isNull() && "Advancing empty iterator");
if (DeclListNode *CurNode = Ptr.dyn_cast<DeclListNode*>())
Ptr = CurNode->Rest;
else
Ptr = nullptr;
return *this;
}
iterator operator++(int) { // It++
iterator temp = *this;
++(*this);
return temp;
}
// Enables the pattern for (iterator I =..., E = I.end(); I != E; ++I)
iterator end() { return iterator(); }
};
private:
NamedDecl *D = nullptr;
Decls Rest = nullptr;
DeclListNode(NamedDecl *ND) : D(ND) {}
};
/// The results of name lookup within a DeclContext.
class DeclContextLookupResult {
using ResultTy = ArrayRef<NamedDecl *>;
using Decls = DeclListNode::Decls;
ResultTy Result;
// If there is only one lookup result, it would be invalidated by
// reallocations of the name table, so store it separately.
NamedDecl *Single = nullptr;
static NamedDecl *const SingleElementDummyList;
/// When in collection form, this is what the Data pointer points to.
Decls Result;
public:
DeclContextLookupResult() = default;
DeclContextLookupResult(ArrayRef<NamedDecl *> Result)
: Result(Result) {}
DeclContextLookupResult(NamedDecl *Single)
: Result(SingleElementDummyList), Single(Single) {}
class iterator;
using IteratorBase =
llvm::iterator_adaptor_base<iterator, ResultTy::iterator,
std::random_access_iterator_tag, NamedDecl *>;
class iterator : public IteratorBase {
value_type SingleElement;
public:
explicit iterator(pointer Pos, value_type Single = nullptr)
: IteratorBase(Pos), SingleElement(Single) {}
reference operator*() const {
return SingleElement ? SingleElement : IteratorBase::operator*();
}
};
DeclContextLookupResult(Decls Result) : Result(Result) {}
using iterator = DeclListNode::iterator;
using const_iterator = iterator;
using pointer = iterator::pointer;
using reference = iterator::reference;
iterator begin() const { return iterator(Result.begin(), Single); }
iterator end() const { return iterator(Result.end(), Single); }
iterator begin() { return iterator(Result); }
iterator end() { return iterator(); }
const_iterator begin() const {
return const_cast<DeclContextLookupResult*>(this)->begin();
}
const_iterator end() const { return iterator(); }
bool empty() const { return Result.empty(); }
pointer data() const { return Single ? &Single : Result.data(); }
size_t size() const { return Single ? 1 : Result.size(); }
reference front() const { return Single ? Single : Result.front(); }
reference back() const { return Single ? Single : Result.back(); }
reference operator[](size_t N) const { return Single ? Single : Result[N]; }
bool empty() const { return Result.isNull(); }
bool isSingleResult() const { return Result.dyn_cast<NamedDecl*>(); }
reference front() const { return *begin(); }
// FIXME: Remove this from the interface
DeclContextLookupResult slice(size_t N) const {
DeclContextLookupResult Sliced = Result.slice(N);
Sliced.Single = Single;
return Sliced;
// Find the first declaration of the given type in the list. Note that this
// is not in general the earliest-declared declaration, and should only be
// used when it's not possible for there to be more than one match or where
// it doesn't matter which one is found.
template<class T> T *find_first() const {
for (auto *D : *this)
if (T *Decl = dyn_cast<T>(D))
return Decl;
return nullptr;
}
};
@@ -2333,7 +2378,7 @@ class DeclContext {
using udir_iterator_base =
llvm::iterator_adaptor_base<udir_iterator, lookup_iterator,
std::random_access_iterator_tag,
typename lookup_iterator::iterator_category,
UsingDirectiveDecl *>;
struct udir_iterator : udir_iterator_base {
@@ -69,6 +69,7 @@ class FriendDecl;
class FunctionTemplateDecl;
class IdentifierInfo;
class MemberSpecializationInfo;
class BaseUsingDecl;
class TemplateDecl;
class TemplateParameterList;
class UsingDecl;
@@ -1479,7 +1480,7 @@ class CXXRecordDecl : public RecordDecl {
/// Returns true if the class destructor, or any implicitly invoked
/// destructors are marked noreturn.
bool isAnyDestructorNoReturn() const;
bool isAnyDestructorNoReturn() const { return data().IsAnyDestructorNoReturn; }
/// If the class is a local class [class.local], returns
/// the enclosing function declaration.
@@ -1786,6 +1787,7 @@ class CXXRecordDecl : public RecordDecl {
static bool classofKind(Kind K) {
return K >= firstCXXRecord && K <= lastCXXRecord;
}
void markAbstract() { data().Abstract = true; }
};
/// Store information needed for an explicit specifier.
@@ -1852,15 +1854,17 @@ class CXXDeductionGuideDecl : public FunctionDecl {
CXXDeductionGuideDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
ExplicitSpecifier ES,
const DeclarationNameInfo &NameInfo, QualType T,
TypeSourceInfo *TInfo, SourceLocation EndLocation)
TypeSourceInfo *TInfo, SourceLocation EndLocation,
CXXConstructorDecl *Ctor)
: FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
SC_None, false, ConstexprSpecKind::Unspecified),
ExplicitSpec(ES) {
Ctor(Ctor), ExplicitSpec(ES) {
if (EndLocation.isValid())
setRangeEnd(EndLocation);
setIsCopyDeductionCandidate(false);
}
CXXConstructorDecl *Ctor;
ExplicitSpecifier ExplicitSpec;
void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
@@ -1871,7 +1875,8 @@ class CXXDeductionGuideDecl : public FunctionDecl {
static CXXDeductionGuideDecl *
Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T,
TypeSourceInfo *TInfo, SourceLocation EndLocation);
TypeSourceInfo *TInfo, SourceLocation EndLocation,
CXXConstructorDecl *Ctor = nullptr);
static CXXDeductionGuideDecl *CreateDeserialized(ASTContext &C, unsigned ID);
@@ -1886,6 +1891,12 @@ class CXXDeductionGuideDecl : public FunctionDecl {
return getDeclName().getCXXDeductionGuideTemplate();
}
/// Get the constructor from which this deduction guide was generated, if
/// this is an implicit deduction guide.
CXXConstructorDecl *getCorrespondingConstructor() const {
return Ctor;
}
void setIsCopyDeductionCandidate(bool isCDC = true) {
FunctionDeclBits.IsCopyDeductionCandidate = isCDC;
}
@@ -2166,6 +2177,10 @@ class CXXCtorInitializer final {
llvm::PointerUnion<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *>
Initializee;
/// The argument used to initialize the base or member, which may
/// end up constructing an object (when multiple arguments are involved).
Stmt *Init;
/// The source location for the field name or, for a base initializer
/// pack expansion, the location of the ellipsis.
///
@@ -2174,10 +2189,6 @@ class CXXCtorInitializer final {
/// Initializee points to the CXXConstructorDecl (to allow loop detection).
SourceLocation MemberOrEllipsisLocation;
/// The argument used to initialize the base or member, which may
/// end up constructing an object (when multiple arguments are involved).
Stmt *Init;
/// Location of the left paren of the ctor-initializer.
SourceLocation LParenLoc;
@@ -2267,7 +2278,8 @@ class CXXCtorInitializer final {
// For a pack expansion, returns the location of the ellipsis.
SourceLocation getEllipsisLoc() const {
assert(isPackExpansion() && "Initializer is not a pack expansion");
if (!isPackExpansion())
return {};
return MemberOrEllipsisLocation;
}
@@ -2424,12 +2436,12 @@ class CXXConstructorDecl final
: ExplicitSpecKind::ResolvedFalse);
}
enum TraillingAllocKind {
enum TrailingAllocKind {
TAKInheritsConstructor = 1,
TAKHasTailExplicit = 1 << 1,
};
uint64_t getTraillingAllocKind() const {
uint64_t getTrailingAllocKind() const {
return numTrailingObjects(OverloadToken<InheritedConstructor>()) |
(numTrailingObjects(OverloadToken<ExplicitSpecifier>()) << 1);
}
@@ -3152,21 +3164,27 @@ class LifetimeExtendedTemporaryDecl final
}
};
/// Represents a shadow declaration introduced into a scope by a
/// (resolved) using declaration.
/// Represents a shadow declaration implicitly introduced into a scope by a
/// (resolved) using-declaration or using-enum-declaration to achieve
/// the desired lookup semantics.
///
/// For example,
/// For example:
/// \code
/// namespace A {
/// void foo();
/// void foo(int);
/// struct foo {};
/// enum bar { bar1, bar2 };
/// }
/// namespace B {
/// using A::foo; // <- a UsingDecl
/// // Also creates a UsingShadowDecl for A::foo() in B
/// // add a UsingDecl and three UsingShadowDecls (named foo) to B.
/// using A::foo;
/// // adds UsingEnumDecl and two UsingShadowDecls (named bar1 and bar2) to B.
/// using enum A::bar;
/// }
/// \endcode
class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> {
friend class UsingDecl;
friend class BaseUsingDecl;
/// The referenced declaration.
NamedDecl *Underlying = nullptr;
@@ -3193,7 +3211,8 @@ class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> {
protected:
UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, SourceLocation Loc,
UsingDecl *Using, NamedDecl *Target);
DeclarationName Name, BaseUsingDecl *Introducer,
NamedDecl *Target);
UsingShadowDecl(Kind K, ASTContext &C, EmptyShell);
public:
@@ -3201,9 +3220,10 @@ class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> {
friend class ASTDeclWriter;
static UsingShadowDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation Loc, UsingDecl *Using,
NamedDecl *Target) {
return new (C, DC) UsingShadowDecl(UsingShadow, C, DC, Loc, Using, Target);
SourceLocation Loc, DeclarationName Name,
BaseUsingDecl *Introducer, NamedDecl *Target) {
return new (C, DC)
UsingShadowDecl(UsingShadow, C, DC, Loc, Name, Introducer, Target);
}
static UsingShadowDecl *CreateDeserialized(ASTContext &C, unsigned ID);
@@ -3241,8 +3261,9 @@ class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> {
~(IDNS_OrdinaryFriend | IDNS_TagFriend | IDNS_LocalExtern);
}
/// Gets the using declaration to which this declaration is tied.
UsingDecl *getUsingDecl() const;
/// Gets the (written or instantiated) using declaration that introduced this
/// declaration.
BaseUsingDecl *getIntroducer() const;
/// The next using shadow declaration contained in the shadow decl
/// chain of the using declaration which introduced this decl.
@@ -3256,6 +3277,180 @@ class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> {
}
};
/// Represents a C++ declaration that introduces decls from somewhere else. It
/// provides a set of the shadow decls so introduced.
class BaseUsingDecl : public NamedDecl {
/// The first shadow declaration of the shadow decl chain associated
/// with this using declaration.
///
/// The bool member of the pair is a bool flag a derived type may use
/// (UsingDecl makes use of it).
llvm::PointerIntPair<UsingShadowDecl *, 1, bool> FirstUsingShadow;
protected:
BaseUsingDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
: NamedDecl(DK, DC, L, N), FirstUsingShadow(nullptr, 0) {}
private:
void anchor() override;
protected:
/// A bool flag for use by a derived type
bool getShadowFlag() const { return FirstUsingShadow.getInt(); }
/// A bool flag a derived type may set
void setShadowFlag(bool V) { FirstUsingShadow.setInt(V); }
public:
friend class ASTDeclReader;
friend class ASTDeclWriter;
/// Iterates through the using shadow declarations associated with
/// this using declaration.
class shadow_iterator {
/// The current using shadow declaration.
UsingShadowDecl *Current = nullptr;
public:
using value_type = UsingShadowDecl *;
using reference = UsingShadowDecl *;
using pointer = UsingShadowDecl *;
using iterator_category = std::forward_iterator_tag;
using difference_type = std::ptrdiff_t;
shadow_iterator() = default;
explicit shadow_iterator(UsingShadowDecl *C) : Current(C) {}
reference operator*() const { return Current; }
pointer operator->() const { return Current; }
shadow_iterator &operator++() {
Current = Current->getNextUsingShadowDecl();
return *this;
}
shadow_iterator operator++(int) {
shadow_iterator tmp(*this);
++(*this);
return tmp;
}
friend bool operator==(shadow_iterator x, shadow_iterator y) {
return x.Current == y.Current;
}
friend bool operator!=(shadow_iterator x, shadow_iterator y) {
return x.Current != y.Current;
}
};
using shadow_range = llvm::iterator_range<shadow_iterator>;
shadow_range shadows() const {
return shadow_range(shadow_begin(), shadow_end());
}
shadow_iterator shadow_begin() const {
return shadow_iterator(FirstUsingShadow.getPointer());
}
shadow_iterator shadow_end() const { return shadow_iterator(); }
/// Return the number of shadowed declarations associated with this
/// using declaration.
unsigned shadow_size() const {
return std::distance(shadow_begin(), shadow_end());
}
void addShadowDecl(UsingShadowDecl *S);
void removeShadowDecl(UsingShadowDecl *S);
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == Using || K == UsingEnum; }
};
/// Represents a C++ using-declaration.
///
/// For example:
/// \code
/// using someNameSpace::someIdentifier;
/// \endcode
class UsingDecl : public BaseUsingDecl, public Mergeable<UsingDecl> {
/// The source location of the 'using' keyword itself.
SourceLocation UsingLocation;
/// The nested-name-specifier that precedes the name.
NestedNameSpecifierLoc QualifierLoc;
/// Provides source/type location info for the declaration name
/// embedded in the ValueDecl base class.
DeclarationNameLoc DNLoc;
UsingDecl(DeclContext *DC, SourceLocation UL,
NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
: BaseUsingDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()),
UsingLocation(UL), QualifierLoc(QualifierLoc),
DNLoc(NameInfo.getInfo()) {
setShadowFlag(HasTypenameKeyword);
}
void anchor() override;
public:
friend class ASTDeclReader;
friend class ASTDeclWriter;
/// Return the source location of the 'using' keyword.
SourceLocation getUsingLoc() const { return UsingLocation; }
/// Set the source location of the 'using' keyword.
void setUsingLoc(SourceLocation L) { UsingLocation = L; }
/// Retrieve the nested-name-specifier that qualifies the name,
/// with source-location information.
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// Retrieve the nested-name-specifier that qualifies the name.
NestedNameSpecifier *getQualifier() const {
return QualifierLoc.getNestedNameSpecifier();
}
DeclarationNameInfo getNameInfo() const {
return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
}
/// Return true if it is a C++03 access declaration (no 'using').
bool isAccessDeclaration() const { return UsingLocation.isInvalid(); }
/// Return true if the using declaration has 'typename'.
bool hasTypename() const { return getShadowFlag(); }
/// Sets whether the using declaration has 'typename'.
void setTypename(bool TN) { setShadowFlag(TN); }
static UsingDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation UsingL,
NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo,
bool HasTypenameKeyword);
static UsingDecl *CreateDeserialized(ASTContext &C, unsigned ID);
SourceRange getSourceRange() const override LLVM_READONLY;
/// Retrieves the canonical declaration of this declaration.
UsingDecl *getCanonicalDecl() override {
return cast<UsingDecl>(getFirstDecl());
}
const UsingDecl *getCanonicalDecl() const {
return cast<UsingDecl>(getFirstDecl());
}
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == Using; }
};
/// Represents a shadow constructor declaration introduced into a
/// class by a C++11 using-declaration that names a constructor.
///
@@ -3286,7 +3481,8 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl {
ConstructorUsingShadowDecl(ASTContext &C, DeclContext *DC, SourceLocation Loc,
UsingDecl *Using, NamedDecl *Target,
bool TargetInVirtualBase)
: UsingShadowDecl(ConstructorUsingShadow, C, DC, Loc, Using,
: UsingShadowDecl(ConstructorUsingShadow, C, DC, Loc,
Using->getDeclName(), Using,
Target->getUnderlyingDecl()),
NominatedBaseClassShadowDecl(
dyn_cast<ConstructorUsingShadowDecl>(Target)),
@@ -3319,6 +3515,12 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl {
static ConstructorUsingShadowDecl *CreateDeserialized(ASTContext &C,
unsigned ID);
/// Override the UsingShadowDecl's getIntroducer, returning the UsingDecl that
/// introduced this.
UsingDecl *getIntroducer() const {
return cast<UsingDecl>(UsingShadowDecl::getIntroducer());
}
/// Returns the parent of this using shadow declaration, which
/// is the class in which this is declared.
//@{
@@ -3366,37 +3568,27 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl {
static bool classofKind(Kind K) { return K == ConstructorUsingShadow; }
};
/// Represents a C++ using-declaration.
/// Represents a C++ using-enum-declaration.
///
/// For example:
/// \code
/// using someNameSpace::someIdentifier;
/// using enum SomeEnumTag ;
/// \endcode
class UsingDecl : public NamedDecl, public Mergeable<UsingDecl> {
class UsingEnumDecl : public BaseUsingDecl, public Mergeable<UsingEnumDecl> {
/// The source location of the 'using' keyword itself.
SourceLocation UsingLocation;
/// The nested-name-specifier that precedes the name.
NestedNameSpecifierLoc QualifierLoc;
/// Location of the 'enum' keyword.
SourceLocation EnumLocation;
/// Provides source/type location info for the declaration name
/// embedded in the ValueDecl base class.
DeclarationNameLoc DNLoc;
/// The enum
EnumDecl *Enum;
/// The first shadow declaration of the shadow decl chain associated
/// with this using declaration.
///
/// The bool member of the pair store whether this decl has the \c typename
/// keyword.
llvm::PointerIntPair<UsingShadowDecl *, 1, bool> FirstUsingShadow;
UsingDecl(DeclContext *DC, SourceLocation UL,
NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
: NamedDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()),
UsingLocation(UL), QualifierLoc(QualifierLoc),
DNLoc(NameInfo.getInfo()), FirstUsingShadow(nullptr, HasTypenameKeyword) {
}
UsingEnumDecl(DeclContext *DC, DeclarationName DN, SourceLocation UL,
SourceLocation EL, SourceLocation NL, EnumDecl *ED)
: BaseUsingDecl(UsingEnum, DC, NL, DN), UsingLocation(UL),
EnumLocation(EL), Enum(ED) {}
void anchor() override;
@@ -3404,109 +3596,35 @@ class UsingDecl : public NamedDecl, public Mergeable<UsingDecl> {
friend class ASTDeclReader;
friend class ASTDeclWriter;
/// Return the source location of the 'using' keyword.
/// The source location of the 'using' keyword.
SourceLocation getUsingLoc() const { return UsingLocation; }
/// Set the source location of the 'using' keyword.
void setUsingLoc(SourceLocation L) { UsingLocation = L; }
/// Retrieve the nested-name-specifier that qualifies the name,
/// with source-location information.
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// The source location of the 'enum' keyword.
SourceLocation getEnumLoc() const { return EnumLocation; }
void setEnumLoc(SourceLocation L) { EnumLocation = L; }
/// Retrieve the nested-name-specifier that qualifies the name.
NestedNameSpecifier *getQualifier() const {
return QualifierLoc.getNestedNameSpecifier();
}
public:
EnumDecl *getEnumDecl() const { return Enum; }
DeclarationNameInfo getNameInfo() const {
return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
}
static UsingEnumDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation UsingL, SourceLocation EnumL,
SourceLocation NameL, EnumDecl *ED);
/// Return true if it is a C++03 access declaration (no 'using').
bool isAccessDeclaration() const { return UsingLocation.isInvalid(); }
/// Return true if the using declaration has 'typename'.
bool hasTypename() const { return FirstUsingShadow.getInt(); }
/// Sets whether the using declaration has 'typename'.
void setTypename(bool TN) { FirstUsingShadow.setInt(TN); }
/// Iterates through the using shadow declarations associated with
/// this using declaration.
class shadow_iterator {
/// The current using shadow declaration.
UsingShadowDecl *Current = nullptr;
public:
using value_type = UsingShadowDecl *;
using reference = UsingShadowDecl *;
using pointer = UsingShadowDecl *;
using iterator_category = std::forward_iterator_tag;
using difference_type = std::ptrdiff_t;
shadow_iterator() = default;
explicit shadow_iterator(UsingShadowDecl *C) : Current(C) {}
reference operator*() const { return Current; }
pointer operator->() const { return Current; }
shadow_iterator& operator++() {
Current = Current->getNextUsingShadowDecl();
return *this;
}
shadow_iterator operator++(int) {
shadow_iterator tmp(*this);
++(*this);
return tmp;
}
friend bool operator==(shadow_iterator x, shadow_iterator y) {
return x.Current == y.Current;
}
friend bool operator!=(shadow_iterator x, shadow_iterator y) {
return x.Current != y.Current;
}
};
using shadow_range = llvm::iterator_range<shadow_iterator>;
shadow_range shadows() const {
return shadow_range(shadow_begin(), shadow_end());
}
shadow_iterator shadow_begin() const {
return shadow_iterator(FirstUsingShadow.getPointer());
}
shadow_iterator shadow_end() const { return shadow_iterator(); }
/// Return the number of shadowed declarations associated with this
/// using declaration.
unsigned shadow_size() const {
return std::distance(shadow_begin(), shadow_end());
}
void addShadowDecl(UsingShadowDecl *S);
void removeShadowDecl(UsingShadowDecl *S);
static UsingDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation UsingL,
NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo,
bool HasTypenameKeyword);
static UsingDecl *CreateDeserialized(ASTContext &C, unsigned ID);
static UsingEnumDecl *CreateDeserialized(ASTContext &C, unsigned ID);
SourceRange getSourceRange() const override LLVM_READONLY;
/// Retrieves the canonical declaration of this declaration.
UsingDecl *getCanonicalDecl() override { return getFirstDecl(); }
const UsingDecl *getCanonicalDecl() const { return getFirstDecl(); }
UsingEnumDecl *getCanonicalDecl() override {
return cast<UsingEnumDecl>(getFirstDecl());
}
const UsingEnumDecl *getCanonicalDecl() const {
return cast<UsingEnumDecl>(getFirstDecl());
}
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == Using; }
static bool classofKind(Kind K) { return K == UsingEnum; }
};
/// Represents a pack of using declarations that a single
@@ -3765,6 +3883,28 @@ class UnresolvedUsingTypenameDecl
static bool classofKind(Kind K) { return K == UnresolvedUsingTypename; }
};
/// This node is generated when a using-declaration that was annotated with
/// __attribute__((using_if_exists)) failed to resolve to a known declaration.
/// In that case, Sema builds a UsingShadowDecl whose target is an instance of
/// this declaration, adding it to the current scope. Referring to this
/// declaration in any way is an error.
class UnresolvedUsingIfExistsDecl final : public NamedDecl {
UnresolvedUsingIfExistsDecl(DeclContext *DC, SourceLocation Loc,
DeclarationName Name);
void anchor() override;
public:
static UnresolvedUsingIfExistsDecl *Create(ASTContext &Ctx, DeclContext *DC,
SourceLocation Loc,
DeclarationName Name);
static UnresolvedUsingIfExistsDecl *CreateDeserialized(ASTContext &Ctx,
unsigned ID);
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == Decl::UnresolvedUsingIfExists; }
};
/// Represents a C++11 static_assert declaration.
class StaticAssertDecl : public Decl {
llvm::PointerIntPair<Expr *, 1, bool> AssertExprAndFailed;
@@ -3817,7 +3957,7 @@ class StaticAssertDecl : public Decl {
/// DecompositionDecl of type 'int (&)[3]'.
class BindingDecl : public ValueDecl {
/// The declaration that this binding binds to part of.
LazyDeclPtr Decomp;
ValueDecl *Decomp;
/// The binding represented by this declaration. References to this
/// declaration are effectively equivalent to this expression (except
/// that it is only evaluated once at the point of declaration of the
@@ -3843,7 +3983,7 @@ class BindingDecl : public ValueDecl {
/// Get the decomposition declaration that this binding represents a
/// decomposition of.
ValueDecl *getDecomposedDecl() const;
ValueDecl *getDecomposedDecl() const { return Decomp; }
/// Get the variable (if any) that holds the value of evaluating the binding.
/// Only present for user-defined bindings for tuple-like types.
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
#define LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclCXX.h"
@@ -21,8 +22,6 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/SmallVector.h"
#include <algorithm>
#include <cassert>
namespace clang {
@@ -31,231 +30,287 @@ class DependentDiagnostic;
/// An array of decls optimized for the common case of only containing
/// one entry.
struct StoredDeclsList {
/// When in vector form, this is what the Data pointer points to.
using DeclsTy = SmallVector<NamedDecl *, 4>;
class StoredDeclsList {
using Decls = DeclListNode::Decls;
/// A collection of declarations, with a flag to indicate if we have
/// further external declarations.
using DeclsAndHasExternalTy = llvm::PointerIntPair<DeclsTy *, 1, bool>;
using DeclsAndHasExternalTy = llvm::PointerIntPair<Decls, 1, bool>;
/// The stored data, which will be either a pointer to a NamedDecl,
/// or a pointer to a vector with a flag to indicate if there are further
/// or a pointer to a list with a flag to indicate if there are further
/// external declarations.
llvm::PointerUnion<NamedDecl *, DeclsAndHasExternalTy> Data;
DeclsAndHasExternalTy Data;
template<typename Fn>
void erase_if(Fn ShouldErase) {
Decls List = Data.getPointer();
if (!List)
return;
ASTContext &C = getASTContext();
DeclListNode::Decls NewHead = nullptr;
DeclListNode::Decls *NewLast = nullptr;
DeclListNode::Decls *NewTail = &NewHead;
while (true) {
if (!ShouldErase(*DeclListNode::iterator(List))) {
NewLast = NewTail;
*NewTail = List;
if (auto *Node = List.dyn_cast<DeclListNode*>()) {
NewTail = &Node->Rest;
List = Node->Rest;
} else {
break;
}
} else if (DeclListNode *N = List.dyn_cast<DeclListNode*>()) {
List = N->Rest;
C.DeallocateDeclListNode(N);
} else {
// We're discarding the last declaration in the list. The last node we
// want to keep (if any) will be of the form DeclListNode(D, <rest>);
// replace it with just D.
if (NewLast) {
DeclListNode *Node = NewLast->get<DeclListNode*>();
*NewLast = Node->D;
C.DeallocateDeclListNode(Node);
}
break;
}
}
Data.setPointer(NewHead);
assert(llvm::find_if(getLookupResult(), ShouldErase) ==
getLookupResult().end() && "Still exists!");
}
void erase(NamedDecl *ND) {
erase_if([ND](NamedDecl *D) { return D == ND; });
}
public:
StoredDeclsList() = default;
StoredDeclsList(StoredDeclsList &&RHS) : Data(RHS.Data) {
RHS.Data = (NamedDecl *)nullptr;
RHS.Data.setPointer(nullptr);
RHS.Data.setInt(0);
}
~StoredDeclsList() {
// If this is a vector-form, free the vector.
if (DeclsTy *Vector = getAsVector())
delete Vector;
}
StoredDeclsList &operator=(StoredDeclsList &&RHS) {
if (DeclsTy *Vector = getAsVector())
delete Vector;
Data = RHS.Data;
RHS.Data = (NamedDecl *)nullptr;
return *this;
}
bool isNull() const { return Data.isNull(); }
NamedDecl *getAsDecl() const {
return Data.dyn_cast<NamedDecl *>();
}
DeclsAndHasExternalTy getAsVectorAndHasExternal() const {
return Data.dyn_cast<DeclsAndHasExternalTy>();
}
DeclsTy *getAsVector() const {
return getAsVectorAndHasExternal().getPointer();
}
bool hasExternalDecls() const {
return getAsVectorAndHasExternal().getInt();
}
void setHasExternalDecls() {
if (DeclsTy *Vec = getAsVector())
Data = DeclsAndHasExternalTy(Vec, true);
else {
DeclsTy *VT = new DeclsTy();
if (NamedDecl *OldD = getAsDecl())
VT->push_back(OldD);
Data = DeclsAndHasExternalTy(VT, true);
void MaybeDeallocList() {
if (isNull())
return;
// If this is a list-form, free the list.
ASTContext &C = getASTContext();
Decls List = Data.getPointer();
while (DeclListNode *ToDealloc = List.dyn_cast<DeclListNode *>()) {
List = ToDealloc->Rest;
C.DeallocateDeclListNode(ToDealloc);
}
}
void setOnlyValue(NamedDecl *ND) {
assert(!getAsVector() && "Not inline");
Data = ND;
// Make sure that Data is a plain NamedDecl* so we can use its address
// at getLookupResult.
assert(*(NamedDecl **)&Data == ND &&
"PointerUnion mangles the NamedDecl pointer!");
~StoredDeclsList() {
MaybeDeallocList();
}
StoredDeclsList &operator=(StoredDeclsList &&RHS) {
MaybeDeallocList();
Data = RHS.Data;
RHS.Data.setPointer(nullptr);
RHS.Data.setInt(0);
return *this;
}
bool isNull() const { return Data.getPointer().isNull(); }
ASTContext &getASTContext() {
assert(!isNull() && "No ASTContext.");
if (NamedDecl *ND = getAsDecl())
return ND->getASTContext();
return getAsList()->D->getASTContext();
}
DeclsAndHasExternalTy getAsListAndHasExternal() const { return Data; }
NamedDecl *getAsDecl() const {
return getAsListAndHasExternal().getPointer().dyn_cast<NamedDecl *>();
}
DeclListNode *getAsList() const {
return getAsListAndHasExternal().getPointer().dyn_cast<DeclListNode*>();
}
bool hasExternalDecls() const {
return getAsListAndHasExternal().getInt();
}
void setHasExternalDecls() {
Data.setInt(1);
}
void remove(NamedDecl *D) {
assert(!isNull() && "removing from empty list");
if (NamedDecl *Singleton = getAsDecl()) {
assert(Singleton == D && "list is different singleton");
(void)Singleton;
Data = (NamedDecl *)nullptr;
erase(D);
}
/// Remove any declarations which were imported from an external AST source.
void removeExternalDecls() {
erase_if([](NamedDecl *ND) { return ND->isFromASTFile(); });
// Don't have any pending external decls any more.
Data.setInt(0);
}
void replaceExternalDecls(ArrayRef<NamedDecl*> Decls) {
// Remove all declarations that are either external or are replaced with
// external declarations.
erase_if([Decls](NamedDecl *ND) {
if (ND->isFromASTFile())
return true;
for (NamedDecl *D : Decls)
if (D->declarationReplaces(ND, /*IsKnownNewer=*/false))
return true;
return false;
});
// Don't have any pending external decls any more.
Data.setInt(0);
if (Decls.empty())
return;
// Convert Decls into a list, in order.
ASTContext &C = Decls.front()->getASTContext();
DeclListNode::Decls DeclsAsList = Decls.back();
for (size_t I = Decls.size() - 1; I != 0; --I) {
DeclListNode *Node = C.AllocateDeclListNode(Decls[I - 1]);
Node->Rest = DeclsAsList;
DeclsAsList = Node;
}
DeclListNode::Decls Head = Data.getPointer();
if (Head.isNull()) {
Data.setPointer(DeclsAsList);
return;
}
DeclsTy &Vec = *getAsVector();
DeclsTy::iterator I = llvm::find(Vec, D);
assert(I != Vec.end() && "list does not contain decl");
Vec.erase(I);
// Find the end of the existing list.
// FIXME: It would be possible to preserve information from erase_if to
// avoid this rescan looking for the end of the list.
DeclListNode::Decls *Tail = &Head;
while (DeclListNode *Node = Tail->dyn_cast<DeclListNode *>())
Tail = &Node->Rest;
assert(llvm::find(Vec, D) == Vec.end() && "list still contains decl");
// Append the Decls.
DeclListNode *Node = C.AllocateDeclListNode(Tail->get<NamedDecl *>());
Node->Rest = DeclsAsList;
*Tail = Node;
Data.setPointer(Head);
}
/// Remove any declarations which were imported from an external
/// AST source.
void removeExternalDecls() {
/// Return an array of all the decls that this list represents.
DeclContext::lookup_result getLookupResult() const {
return DeclContext::lookup_result(Data.getPointer());
}
/// If this is a redeclaration of an existing decl, replace the old one with
/// D. Otherwise, append D.
void addOrReplaceDecl(NamedDecl *D) {
const bool IsKnownNewer = true;
if (isNull()) {
// Nothing to do.
} else if (NamedDecl *Singleton = getAsDecl()) {
if (Singleton->isFromASTFile())
*this = StoredDeclsList();
} else {
DeclsTy &Vec = *getAsVector();
Vec.erase(std::remove_if(Vec.begin(), Vec.end(),
[](Decl *D) { return D->isFromASTFile(); }),
Vec.end());
// Don't have any external decls any more.
Data = DeclsAndHasExternalTy(&Vec, false);
}
}
/// getLookupResult - Return an array of all the decls that this list
/// represents.
DeclContext::lookup_result getLookupResult() {
if (isNull())
return DeclContext::lookup_result();
// If we have a single NamedDecl, return it.
if (NamedDecl *ND = getAsDecl()) {
assert(!isNull() && "Empty list isn't allowed");
// Data is a raw pointer to a NamedDecl*, return it.
return DeclContext::lookup_result(ND);
Data.setPointer(D);
return;
}
assert(getAsVector() && "Must have a vector at this point");
DeclsTy &Vector = *getAsVector();
// Otherwise, we have a range result.
return DeclContext::lookup_result(Vector);
}
/// HandleRedeclaration - If this is a redeclaration of an existing decl,
/// replace the old one with D and return true. Otherwise return false.
bool HandleRedeclaration(NamedDecl *D, bool IsKnownNewer) {
// Most decls only have one entry in their list, special case it.
if (NamedDecl *OldD = getAsDecl()) {
if (!D->declarationReplaces(OldD, IsKnownNewer))
return false;
setOnlyValue(D);
return true;
if (D->declarationReplaces(OldD, IsKnownNewer)) {
Data.setPointer(D);
return;
}
// Add D after OldD.
ASTContext &C = D->getASTContext();
DeclListNode *Node = C.AllocateDeclListNode(OldD);
Node->Rest = D;
Data.setPointer(Node);
return;
}
// FIXME: Move the assert before the single decl case when we fix the
// duplication coming from the ASTReader reading builtin types.
assert(!llvm::is_contained(getLookupResult(), D) && "Already exists!");
// Determine if this declaration is actually a redeclaration.
DeclsTy &Vec = *getAsVector();
for (DeclsTy::iterator OD = Vec.begin(), ODEnd = Vec.end();
OD != ODEnd; ++OD) {
NamedDecl *OldD = *OD;
if (D->declarationReplaces(OldD, IsKnownNewer)) {
*OD = D;
return true;
for (DeclListNode *N = getAsList(); /*return in loop*/;
N = N->Rest.dyn_cast<DeclListNode *>()) {
if (D->declarationReplaces(N->D, IsKnownNewer)) {
N->D = D;
return;
}
if (auto *ND = N->Rest.dyn_cast<NamedDecl *>()) {
if (D->declarationReplaces(ND, IsKnownNewer)) {
N->Rest = D;
return;
}
// Add D after ND.
ASTContext &C = D->getASTContext();
DeclListNode *Node = C.AllocateDeclListNode(ND);
N->Rest = Node;
Node->Rest = D;
return;
}
}
return false;
}
/// AddSubsequentDecl - This is called on the second and later decl when it is
/// not a redeclaration to merge it into the appropriate place in our list.
void AddSubsequentDecl(NamedDecl *D) {
assert(!isNull() && "don't AddSubsequentDecl when we have no decls");
// If this is the second decl added to the list, convert this to vector
// form.
if (NamedDecl *OldD = getAsDecl()) {
DeclsTy *VT = new DeclsTy();
VT->push_back(OldD);
Data = DeclsAndHasExternalTy(VT, false);
/// Add a declaration to the list without checking if it replaces anything.
void prependDeclNoReplace(NamedDecl *D) {
if (isNull()) {
Data.setPointer(D);
return;
}
DeclsTy &Vec = *getAsVector();
ASTContext &C = D->getASTContext();
DeclListNode *Node = C.AllocateDeclListNode(D);
Node->Rest = Data.getPointer();
Data.setPointer(Node);
}
// Using directives end up in a special entry which contains only
// other using directives, so all this logic is wasted for them.
// But avoiding the logic wastes time in the far-more-common case
// that we're *not* adding a new using directive.
LLVM_DUMP_METHOD void dump() const {
Decls D = Data.getPointer();
if (!D) {
llvm::errs() << "<null>\n";
return;
}
// Tag declarations always go at the end of the list so that an
// iterator which points at the first tag will start a span of
// decls that only contains tags.
if (D->hasTagIdentifierNamespace())
Vec.push_back(D);
// Resolved using declarations go at the front of the list so that
// they won't show up in other lookup results. Unresolved using
// declarations (which are always in IDNS_Using | IDNS_Ordinary)
// follow that so that the using declarations will be contiguous.
else if (D->getIdentifierNamespace() & Decl::IDNS_Using) {
DeclsTy::iterator I = Vec.begin();
if (D->getIdentifierNamespace() != Decl::IDNS_Using) {
while (I != Vec.end() &&
(*I)->getIdentifierNamespace() == Decl::IDNS_Using)
++I;
while (true) {
if (auto *Node = D.dyn_cast<DeclListNode*>()) {
llvm::errs() << '[' << Node->D << "] -> ";
D = Node->Rest;
} else {
llvm::errs() << '[' << D.get<NamedDecl*>() << "]\n";
return;
}
Vec.insert(I, D);
// All other declarations go at the end of the list, but before any
// tag declarations. But we can be clever about tag declarations
// because there can only ever be one in a scope.
} else if (!Vec.empty() && Vec.back()->hasTagIdentifierNamespace()) {
NamedDecl *TagD = Vec.back();
Vec.back() = D;
Vec.push_back(TagD);
} else
Vec.push_back(D);
}
}
};
class StoredDeclsMap
: public llvm::SmallDenseMap<DeclarationName, StoredDeclsList, 4> {
public:
static void DestroyAll(StoredDeclsMap *Map, bool Dependent);
private:
friend class ASTContext; // walks the chain deleting these
friend class DeclContext;
llvm::PointerIntPair<StoredDeclsMap*, 1> Previous;
public:
static void DestroyAll(StoredDeclsMap *Map, bool Dependent);
};
class DependentStoredDeclsMap : public StoredDeclsMap {
public:
DependentStoredDeclsMap() = default;
private:
friend class DeclContext; // iterates over diagnostics
friend class DependentDiagnostic;
DependentDiagnostic *FirstDiagnostic = nullptr;
public:
DependentStoredDeclsMap() = default;
};
} // namespace clang
@@ -852,9 +852,7 @@ class ObjCPropertyDecl : public NamedDecl {
bool isClassProperty() const {
return PropertyAttributes & ObjCPropertyAttribute::kind_class;
}
bool isDirectProperty() const {
return PropertyAttributes & ObjCPropertyAttribute::kind_direct;
}
bool isDirectProperty() const;
ObjCPropertyQueryKind getQueryKind() const {
return isClassProperty() ? ObjCPropertyQueryKind::OBJC_PR_query_class :
@@ -160,9 +160,7 @@ class TemplateParameterList final
/// Determine whether this template parameter list contains an
/// unexpanded parameter pack.
bool containsUnexpandedParameterPack() const {
return ContainsUnexpandedParameterPack;
}
bool containsUnexpandedParameterPack() const;
/// Determine whether this template parameter list contains a parameter pack.
bool hasParameterPack() const {
@@ -204,6 +202,9 @@ class TemplateParameterList final
bool OmitTemplateKW = false) const;
void print(raw_ostream &Out, const ASTContext &Context,
const PrintingPolicy &Policy, bool OmitTemplateKW = false) const;
static bool shouldIncludeTypeForArgument(const TemplateParameterList *TPL,
unsigned Idx);
};
/// Stores a list of template parameters and the associated
@@ -647,7 +647,7 @@ class DeclarationNameTable {
/// DeclarationNameLoc - Additional source/type location info
/// for a declaration name. Needs a DeclarationName in order
/// to be interpreted correctly.
struct DeclarationNameLoc {
class DeclarationNameLoc {
// The source location for identifier stored elsewhere.
// struct {} Identifier;
@@ -660,13 +660,13 @@ struct DeclarationNameLoc {
// The location (if any) of the operator keyword is stored elsewhere.
struct CXXOpName {
unsigned BeginOpNameLoc;
unsigned EndOpNameLoc;
SourceLocation::UIntTy BeginOpNameLoc;
SourceLocation::UIntTy EndOpNameLoc;
};
// The location (if any) of the operator keyword is stored elsewhere.
struct CXXLitOpName {
unsigned OpNameLoc;
SourceLocation::UIntTy OpNameLoc;
};
// struct {} CXXUsingDirective;
@@ -679,10 +679,78 @@ struct DeclarationNameLoc {
struct CXXLitOpName CXXLiteralOperatorName;
};
DeclarationNameLoc(DeclarationName Name);
void setNamedTypeLoc(TypeSourceInfo *TInfo) { NamedType.TInfo = TInfo; }
void setCXXOperatorNameRange(SourceRange Range) {
CXXOperatorName.BeginOpNameLoc = Range.getBegin().getRawEncoding();
CXXOperatorName.EndOpNameLoc = Range.getEnd().getRawEncoding();
}
void setCXXLiteralOperatorNameLoc(SourceLocation Loc) {
CXXLiteralOperatorName.OpNameLoc = Loc.getRawEncoding();
}
public:
DeclarationNameLoc(DeclarationName Name);
// FIXME: this should go away once all DNLocs are properly initialized.
DeclarationNameLoc() { memset((void*) this, 0, sizeof(*this)); }
/// Returns the source type info. Assumes that the object stores location
/// information of a constructor, destructor or conversion operator.
TypeSourceInfo *getNamedTypeInfo() const { return NamedType.TInfo; }
/// Return the beginning location of the getCXXOperatorNameRange() range.
SourceLocation getCXXOperatorNameBeginLoc() const {
return SourceLocation::getFromRawEncoding(CXXOperatorName.BeginOpNameLoc);
}
/// Return the end location of the getCXXOperatorNameRange() range.
SourceLocation getCXXOperatorNameEndLoc() const {
return SourceLocation::getFromRawEncoding(CXXOperatorName.EndOpNameLoc);
}
/// Return the range of the operator name (without the operator keyword).
/// Assumes that the object stores location information of a (non-literal)
/// operator.
SourceRange getCXXOperatorNameRange() const {
return SourceRange(getCXXOperatorNameBeginLoc(),
getCXXOperatorNameEndLoc());
}
/// Return the location of the literal operator name (without the operator
/// keyword). Assumes that the object stores location information of a literal
/// operator.
SourceLocation getCXXLiteralOperatorNameLoc() const {
return SourceLocation::getFromRawEncoding(CXXLiteralOperatorName.OpNameLoc);
}
/// Construct location information for a constructor, destructor or conversion
/// operator.
static DeclarationNameLoc makeNamedTypeLoc(TypeSourceInfo *TInfo) {
DeclarationNameLoc DNL;
DNL.setNamedTypeLoc(TInfo);
return DNL;
}
/// Construct location information for a non-literal C++ operator.
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc,
SourceLocation EndLoc) {
return makeCXXOperatorNameLoc(SourceRange(BeginLoc, EndLoc));
}
/// Construct location information for a non-literal C++ operator.
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceRange Range) {
DeclarationNameLoc DNL;
DNL.setCXXOperatorNameRange(Range);
return DNL;
}
/// Construct location information for a literal C++ operator.
static DeclarationNameLoc makeCXXLiteralOperatorNameLoc(SourceLocation Loc) {
DeclarationNameLoc DNL;
DNL.setCXXLiteralOperatorNameLoc(Loc);
return DNL;
}
};
/// DeclarationNameInfo - A collector data type for bundling together
@@ -722,7 +790,6 @@ struct DeclarationNameInfo {
void setLoc(SourceLocation L) { NameLoc = L; }
const DeclarationNameLoc &getInfo() const { return LocInfo; }
DeclarationNameLoc &getInfo() { return LocInfo; }
void setInfo(const DeclarationNameLoc &Info) { LocInfo = Info; }
/// getNamedTypeInfo - Returns the source type info associated to
@@ -732,7 +799,7 @@ struct DeclarationNameInfo {
Name.getNameKind() != DeclarationName::CXXDestructorName &&
Name.getNameKind() != DeclarationName::CXXConversionFunctionName)
return nullptr;
return LocInfo.NamedType.TInfo;
return LocInfo.getNamedTypeInfo();
}
/// setNamedTypeInfo - Sets the source type info associated to
@@ -741,7 +808,7 @@ struct DeclarationNameInfo {
assert(Name.getNameKind() == DeclarationName::CXXConstructorName ||
Name.getNameKind() == DeclarationName::CXXDestructorName ||
Name.getNameKind() == DeclarationName::CXXConversionFunctionName);
LocInfo.NamedType.TInfo = TInfo;
LocInfo = DeclarationNameLoc::makeNamedTypeLoc(TInfo);
}
/// getCXXOperatorNameRange - Gets the range of the operator name
@@ -749,18 +816,14 @@ struct DeclarationNameInfo {
SourceRange getCXXOperatorNameRange() const {
if (Name.getNameKind() != DeclarationName::CXXOperatorName)
return SourceRange();
return SourceRange(
SourceLocation::getFromRawEncoding(LocInfo.CXXOperatorName.BeginOpNameLoc),
SourceLocation::getFromRawEncoding(LocInfo.CXXOperatorName.EndOpNameLoc)
);
return LocInfo.getCXXOperatorNameRange();
}
/// setCXXOperatorNameRange - Sets the range of the operator name
/// (without the operator keyword). Assumes it is a C++ operator.
void setCXXOperatorNameRange(SourceRange R) {
assert(Name.getNameKind() == DeclarationName::CXXOperatorName);
LocInfo.CXXOperatorName.BeginOpNameLoc = R.getBegin().getRawEncoding();
LocInfo.CXXOperatorName.EndOpNameLoc = R.getEnd().getRawEncoding();
LocInfo = DeclarationNameLoc::makeCXXOperatorNameLoc(R);
}
/// getCXXLiteralOperatorNameLoc - Returns the location of the literal
@@ -769,8 +832,7 @@ struct DeclarationNameInfo {
SourceLocation getCXXLiteralOperatorNameLoc() const {
if (Name.getNameKind() != DeclarationName::CXXLiteralOperatorName)
return SourceLocation();
return SourceLocation::
getFromRawEncoding(LocInfo.CXXLiteralOperatorName.OpNameLoc);
return LocInfo.getCXXLiteralOperatorNameLoc();
}
/// setCXXLiteralOperatorNameLoc - Sets the location of the literal
@@ -778,7 +840,7 @@ struct DeclarationNameInfo {
/// Assumes it is a literal operator.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc) {
assert(Name.getNameKind() == DeclarationName::CXXLiteralOperatorName);
LocInfo.CXXLiteralOperatorName.OpNameLoc = Loc.getRawEncoding();
LocInfo = DeclarationNameLoc::makeCXXLiteralOperatorNameLoc(Loc);
}
/// Determine whether this name involves a template parameter.
@@ -128,6 +128,9 @@ class Dependence {
// Type depends on a runtime value (variable-length array).
VariablyModified = 32,
// Dependence that is propagated syntactically, regardless of semantics.
Syntactic = UnexpandedPack | Instantiation | Error,
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/VariablyModified)
};
@@ -165,6 +168,13 @@ class Dependence {
translate(D, TNDependence::Dependent, Dependent) |
translate(D, TNDependence::Error, Error)) {}
/// Extract only the syntactic portions of this type's dependence.
Dependence syntactic() {
Dependence Result = *this;
Result.V &= Syntactic;
return Result;
}
TypeDependence type() const {
return translate(V, UnexpandedPack, TypeDependence::UnexpandedPack) |
translate(V, Instantiation, TypeDependence::Instantiation) |
@@ -256,6 +266,10 @@ inline TypeDependence toTypeDependence(TemplateArgumentDependence D) {
return Dependence(D).type();
}
inline TypeDependence toSyntacticDependence(TypeDependence D) {
return Dependence(D).syntactic().type();
}
inline NestedNameSpecifierDependence
toNestedNameSpecifierDependendence(TypeDependence D) {
return Dependence(D).nestedNameSpecifier();
@@ -32,6 +32,9 @@ class EvaluatedExprVisitorBase : public StmtVisitorBase<Ptr, ImplClass, void> {
const ASTContext &Context;
public:
// Return whether this visitor should recurse into discarded statements for a
// 'constexpr-if'.
bool shouldVisitDiscardedStmt() const { return true; }
#define PTR(CLASS) typename Ptr<CLASS>::type
explicit EvaluatedExprVisitorBase(const ASTContext &Context) : Context(Context) { }
@@ -83,7 +86,7 @@ class EvaluatedExprVisitorBase : public StmtVisitorBase<Ptr, ImplClass, void> {
void VisitCallExpr(PTR(CallExpr) CE) {
if (!CE->isUnevaluatedBuiltinCall(Context))
return static_cast<ImplClass*>(this)->VisitExpr(CE);
return getDerived().VisitExpr(CE);
}
void VisitLambdaExpr(PTR(LambdaExpr) LE) {
@@ -103,6 +106,20 @@ class EvaluatedExprVisitorBase : public StmtVisitorBase<Ptr, ImplClass, void> {
this->Visit(SubStmt);
}
void VisitIfStmt(PTR(IfStmt) If) {
if (!getDerived().shouldVisitDiscardedStmt()) {
if (auto SubStmt = If->getNondiscardedCase(Context)) {
if (*SubStmt)
this->Visit(*SubStmt);
return;
}
}
getDerived().VisitStmt(If);
}
ImplClass &getDerived() { return *static_cast<ImplClass *>(this); }
#undef PTR
};
@@ -266,13 +266,11 @@ class Expr : public ValueStmt {
/// C++11 divides the concept of "r-value" into pure r-values
/// ("pr-values") and so-called expiring values ("x-values"), which
/// identify specific objects that can be safely cannibalized for
/// their resources. This is an unfortunate abuse of terminology on
/// the part of the C++ committee. In Clang, when we say "r-value",
/// we generally mean a pr-value.
/// their resources.
bool isLValue() const { return getValueKind() == VK_LValue; }
bool isRValue() const { return getValueKind() == VK_RValue; }
bool isPRValue() const { return getValueKind() == VK_PRValue; }
bool isXValue() const { return getValueKind() == VK_XValue; }
bool isGLValue() const { return getValueKind() != VK_RValue; }
bool isGLValue() const { return getValueKind() != VK_PRValue; }
enum LValueClassification {
LV_Valid,
@@ -425,7 +423,7 @@ class Expr : public ValueStmt {
? VK_LValue
: (RT->getPointeeType()->isFunctionType()
? VK_LValue : VK_XValue));
return VK_RValue;
return VK_PRValue;
}
/// getValueKind - The value kind that this expression produces.
@@ -1587,8 +1585,8 @@ class CharacterLiteral : public Expr {
// type should be IntTy
CharacterLiteral(unsigned value, CharacterKind kind, QualType type,
SourceLocation l)
: Expr(CharacterLiteralClass, type, VK_RValue, OK_Ordinary), Value(value),
Loc(l) {
: Expr(CharacterLiteralClass, type, VK_PRValue, OK_Ordinary),
Value(value), Loc(l) {
CharacterLiteralBits.Kind = kind;
setDependence(ExprDependence::None);
}
@@ -1614,6 +1612,8 @@ class CharacterLiteral : public Expr {
return T->getStmtClass() == CharacterLiteralClass;
}
static void print(unsigned val, CharacterKind Kind, raw_ostream &OS);
// Iterators
child_range children() {
return child_range(child_iterator(), child_iterator());
@@ -1706,7 +1706,7 @@ class ImaginaryLiteral : public Expr {
Stmt *Val;
public:
ImaginaryLiteral(Expr *val, QualType Ty)
: Expr(ImaginaryLiteralClass, Ty, VK_RValue, OK_Ordinary), Val(val) {
: Expr(ImaginaryLiteralClass, Ty, VK_PRValue, OK_Ordinary), Val(val) {
setDependence(ExprDependence::None);
}
@@ -2036,6 +2036,64 @@ class PredefinedExpr final
}
};
// This represents a use of the __builtin_sycl_unique_stable_name, which takes a
// type-id, and at CodeGen time emits a unique string representation of the
// type in a way that permits us to properly encode information about the SYCL
// kernels.
class SYCLUniqueStableNameExpr final : public Expr {
friend class ASTStmtReader;
SourceLocation OpLoc, LParen, RParen;
TypeSourceInfo *TypeInfo;
SYCLUniqueStableNameExpr(EmptyShell Empty, QualType ResultTy);
SYCLUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen,
SourceLocation RParen, QualType ResultTy,
TypeSourceInfo *TSI);
void setTypeSourceInfo(TypeSourceInfo *Ty) { TypeInfo = Ty; }
void setLocation(SourceLocation L) { OpLoc = L; }
void setLParenLocation(SourceLocation L) { LParen = L; }
void setRParenLocation(SourceLocation L) { RParen = L; }
public:
TypeSourceInfo *getTypeSourceInfo() { return TypeInfo; }
const TypeSourceInfo *getTypeSourceInfo() const { return TypeInfo; }
static SYCLUniqueStableNameExpr *
Create(const ASTContext &Ctx, SourceLocation OpLoc, SourceLocation LParen,
SourceLocation RParen, TypeSourceInfo *TSI);
static SYCLUniqueStableNameExpr *CreateEmpty(const ASTContext &Ctx);
SourceLocation getBeginLoc() const { return getLocation(); }
SourceLocation getEndLoc() const { return RParen; }
SourceLocation getLocation() const { return OpLoc; }
SourceLocation getLParenLocation() const { return LParen; }
SourceLocation getRParenLocation() const { return RParen; }
static bool classof(const Stmt *T) {
return T->getStmtClass() == SYCLUniqueStableNameExprClass;
}
// Iterators
child_range children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}
// Convenience function to generate the name of the currently stored type.
std::string ComputeName(ASTContext &Context) const;
// Get the generated name of the type. Note that this only works after all
// kernels have been instantiated.
static std::string ComputeName(ASTContext &Context, QualType Ty);
};
/// ParenExpr - This represents a parethesized expression, e.g. "(1)". This
/// AST node is only formed if full location information is requested.
class ParenExpr : public Expr {
@@ -2486,7 +2544,8 @@ class UnaryExprOrTypeTraitExpr : public Expr {
UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo,
QualType resultType, SourceLocation op,
SourceLocation rp)
: Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary),
: Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_PRValue,
OK_Ordinary),
OpLoc(op), RParenLoc(rp) {
assert(ExprKind <= UETT_Last && "invalid enum value!");
UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
@@ -2927,11 +2986,22 @@ class CallExpr : public Expr {
}
/// setArg - Set the specified argument.
/// ! the dependence bits might be stale after calling this setter, it is
/// *caller*'s responsibility to recompute them by calling
/// computeDependence().
void setArg(unsigned Arg, Expr *ArgExpr) {
assert(Arg < getNumArgs() && "Arg access out of range!");
getArgs()[Arg] = ArgExpr;
}
/// Compute and set dependence bits.
void computeDependence() {
setDependence(clang::computeDependence(
this, llvm::makeArrayRef(
reinterpret_cast<Expr **>(getTrailingStmts() + PREARGS_START),
getNumPreArgs())));
}
/// Reduce the number of arguments in this call expression. This is used for
/// example during error recovery to drop extra arguments. There is no way
/// to perform the opposite because: 1.) We don't track how much storage
@@ -4226,7 +4296,7 @@ class AddrLabelExpr : public Expr {
public:
AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelDecl *L,
QualType t)
: Expr(AddrLabelExprClass, t, VK_RValue, OK_Ordinary), AmpAmpLoc(AALoc),
: Expr(AddrLabelExprClass, t, VK_PRValue, OK_Ordinary), AmpAmpLoc(AALoc),
LabelLoc(LLoc), Label(L) {
setDependence(ExprDependence::None);
}
@@ -4271,7 +4341,7 @@ class StmtExpr : public Expr {
public:
StmtExpr(CompoundStmt *SubStmt, QualType T, SourceLocation LParenLoc,
SourceLocation RParenLoc, unsigned TemplateDepth)
: Expr(StmtExprClass, T, VK_RValue, OK_Ordinary), SubStmt(SubStmt),
: Expr(StmtExprClass, T, VK_PRValue, OK_Ordinary), SubStmt(SubStmt),
LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
setDependence(computeDependence(this, TemplateDepth));
// FIXME: A templated statement expression should have an associated
@@ -4521,7 +4591,7 @@ class GNUNullExpr : public Expr {
public:
GNUNullExpr(QualType Ty, SourceLocation Loc)
: Expr(GNUNullExprClass, Ty, VK_RValue, OK_Ordinary), TokenLoc(Loc) {
: Expr(GNUNullExprClass, Ty, VK_PRValue, OK_Ordinary), TokenLoc(Loc) {
setDependence(ExprDependence::None);
}
@@ -4556,7 +4626,7 @@ class VAArgExpr : public Expr {
public:
VAArgExpr(SourceLocation BLoc, Expr *e, TypeSourceInfo *TInfo,
SourceLocation RPLoc, QualType t, bool IsMS)
: Expr(VAArgExprClass, t, VK_RValue, OK_Ordinary), Val(e),
: Expr(VAArgExprClass, t, VK_PRValue, OK_Ordinary), Val(e),
TInfo(TInfo, IsMS), BuiltinLoc(BLoc), RParenLoc(RPLoc) {
setDependence(computeDependence(this));
}
@@ -5248,7 +5318,7 @@ class DesignatedInitExpr final
class NoInitExpr : public Expr {
public:
explicit NoInitExpr(QualType ty)
: Expr(NoInitExprClass, ty, VK_RValue, OK_Ordinary) {
: Expr(NoInitExprClass, ty, VK_PRValue, OK_Ordinary) {
setDependence(computeDependence(this));
}
@@ -5344,7 +5414,7 @@ class ArrayInitLoopExpr : public Expr {
public:
explicit ArrayInitLoopExpr(QualType T, Expr *CommonInit, Expr *ElementInit)
: Expr(ArrayInitLoopExprClass, T, VK_RValue, OK_Ordinary),
: Expr(ArrayInitLoopExprClass, T, VK_PRValue, OK_Ordinary),
SubExprs{CommonInit, ElementInit} {
setDependence(computeDependence(this));
}
@@ -5395,7 +5465,7 @@ class ArrayInitIndexExpr : public Expr {
public:
explicit ArrayInitIndexExpr(QualType T)
: Expr(ArrayInitIndexExprClass, T, VK_RValue, OK_Ordinary) {
: Expr(ArrayInitIndexExprClass, T, VK_PRValue, OK_Ordinary) {
setDependence(ExprDependence::None);
}
@@ -5428,7 +5498,7 @@ class ArrayInitIndexExpr : public Expr {
class ImplicitValueInitExpr : public Expr {
public:
explicit ImplicitValueInitExpr(QualType ty)
: Expr(ImplicitValueInitExprClass, ty, VK_RValue, OK_Ordinary) {
: Expr(ImplicitValueInitExprClass, ty, VK_PRValue, OK_Ordinary) {
setDependence(computeDependence(this));
}
@@ -5833,7 +5903,7 @@ class ExtVectorElementExpr : public Expr {
ExtVectorElementExpr(QualType ty, ExprValueKind VK, Expr *base,
IdentifierInfo &accessor, SourceLocation loc)
: Expr(ExtVectorElementExprClass, ty, VK,
(VK == VK_RValue ? OK_Ordinary : OK_VectorComponent)),
(VK == VK_PRValue ? OK_Ordinary : OK_VectorComponent)),
Base(base), Accessor(&accessor), AccessorLoc(loc) {
setDependence(computeDependence(this));
}
@@ -5890,7 +5960,7 @@ class BlockExpr : public Expr {
BlockDecl *TheBlock;
public:
BlockExpr(BlockDecl *BD, QualType ty)
: Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary), TheBlock(BD) {
: Expr(BlockExprClass, ty, VK_PRValue, OK_Ordinary), TheBlock(BD) {
setDependence(computeDependence(this));
}
@@ -721,7 +721,7 @@ class UserDefinedLiteral final : public CallExpr {
class CXXBoolLiteralExpr : public Expr {
public:
CXXBoolLiteralExpr(bool Val, QualType Ty, SourceLocation Loc)
: Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary) {
: Expr(CXXBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) {
CXXBoolLiteralExprBits.Value = Val;
CXXBoolLiteralExprBits.Loc = Loc;
setDependence(ExprDependence::None);
@@ -759,7 +759,7 @@ class CXXBoolLiteralExpr : public Expr {
class CXXNullPtrLiteralExpr : public Expr {
public:
CXXNullPtrLiteralExpr(QualType Ty, SourceLocation Loc)
: Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary) {
: Expr(CXXNullPtrLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) {
CXXNullPtrLiteralExprBits.Loc = Loc;
setDependence(ExprDependence::None);
}
@@ -799,7 +799,7 @@ class CXXStdInitializerListExpr : public Expr {
friend class ASTStmtReader;
CXXStdInitializerListExpr(QualType Ty, Expr *SubExpr)
: Expr(CXXStdInitializerListExprClass, Ty, VK_RValue, OK_Ordinary),
: Expr(CXXStdInitializerListExprClass, Ty, VK_PRValue, OK_Ordinary),
SubExpr(SubExpr) {
setDependence(computeDependence(this));
}
@@ -1142,7 +1142,7 @@ class CXXUuidofExpr : public Expr {
class CXXThisExpr : public Expr {
public:
CXXThisExpr(SourceLocation L, QualType Ty, bool IsImplicit)
: Expr(CXXThisExprClass, Ty, VK_RValue, OK_Ordinary) {
: Expr(CXXThisExprClass, Ty, VK_PRValue, OK_Ordinary) {
CXXThisExprBits.IsImplicit = IsImplicit;
CXXThisExprBits.Loc = L;
setDependence(computeDependence(this));
@@ -1191,7 +1191,7 @@ class CXXThrowExpr : public Expr {
// null if not present.
CXXThrowExpr(Expr *Operand, QualType Ty, SourceLocation Loc,
bool IsThrownVariableInScope)
: Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary), Operand(Operand) {
: Expr(CXXThrowExprClass, Ty, VK_PRValue, OK_Ordinary), Operand(Operand) {
CXXThrowExprBits.ThrowLoc = Loc;
CXXThrowExprBits.IsThrownVariableInScope = IsThrownVariableInScope;
setDependence(computeDependence(this));
@@ -1257,7 +1257,7 @@ class CXXDefaultArgExpr final : public Expr {
Param->getDefaultArg()->getObjectKind()),
Param(Param), UsedContext(UsedContext) {
CXXDefaultArgExprBits.Loc = Loc;
setDependence(ExprDependence::None);
setDependence(computeDependence(this));
}
public:
@@ -1414,7 +1414,7 @@ class CXXBindTemporaryExpr : public Expr {
Stmt *SubExpr = nullptr;
CXXBindTemporaryExpr(CXXTemporary *temp, Expr *SubExpr)
: Expr(CXXBindTemporaryExprClass, SubExpr->getType(), VK_RValue,
: Expr(CXXBindTemporaryExprClass, SubExpr->getType(), VK_PRValue,
OK_Ordinary),
Temp(temp), SubExpr(SubExpr) {
setDependence(computeDependence(this));
@@ -1669,7 +1669,7 @@ class CXXInheritedCtorInitExpr : public Expr {
CXXInheritedCtorInitExpr(SourceLocation Loc, QualType T,
CXXConstructorDecl *Ctor, bool ConstructsVirtualBase,
bool InheritedFromVirtualBase)
: Expr(CXXInheritedCtorInitExprClass, T, VK_RValue, OK_Ordinary),
: Expr(CXXInheritedCtorInitExprClass, T, VK_PRValue, OK_Ordinary),
Constructor(Ctor), Loc(Loc),
ConstructsVirtualBase(ConstructsVirtualBase),
InheritedFromVirtualBase(InheritedFromVirtualBase) {
@@ -2100,7 +2100,7 @@ class CXXScalarValueInitExpr : public Expr {
/// expression.
CXXScalarValueInitExpr(QualType Type, TypeSourceInfo *TypeInfo,
SourceLocation RParenLoc)
: Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary),
: Expr(CXXScalarValueInitExprClass, Type, VK_PRValue, OK_Ordinary),
TypeInfo(TypeInfo) {
CXXScalarValueInitExprBits.RParenLoc = RParenLoc;
setDependence(computeDependence(this));
@@ -2408,7 +2408,7 @@ class CXXDeleteExpr : public Expr {
CXXDeleteExpr(QualType Ty, bool GlobalDelete, bool ArrayForm,
bool ArrayFormAsWritten, bool UsualArrayDeleteWantsSize,
FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc)
: Expr(CXXDeleteExprClass, Ty, VK_RValue, OK_Ordinary),
: Expr(CXXDeleteExprClass, Ty, VK_PRValue, OK_Ordinary),
OperatorDelete(OperatorDelete), Argument(Arg) {
CXXDeleteExprBits.GlobalDelete = GlobalDelete;
CXXDeleteExprBits.ArrayForm = ArrayForm;
@@ -2775,7 +2775,7 @@ class ArrayTypeTraitExpr : public Expr {
ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att,
TypeSourceInfo *queried, uint64_t value, Expr *dimension,
SourceLocation rparen, QualType ty)
: Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary), ATT(att),
: Expr(ArrayTypeTraitExprClass, ty, VK_PRValue, OK_Ordinary), ATT(att),
Value(value), Dimension(dimension), Loc(loc), RParen(rparen),
QueriedType(queried) {
assert(att <= ATT_Last && "invalid enum value!");
@@ -2841,7 +2841,7 @@ class ExpressionTraitExpr : public Expr {
ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, Expr *queried,
bool value, SourceLocation rparen, QualType resultType)
: Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary),
: Expr(ExpressionTraitExprClass, resultType, VK_PRValue, OK_Ordinary),
ET(et), Value(value), Loc(loc), RParen(rparen),
QueriedExpression(queried) {
assert(et <= ET_Last && "invalid enum value!");
@@ -4003,7 +4003,7 @@ class CXXNoexceptExpr : public Expr {
public:
CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val,
SourceLocation Keyword, SourceLocation RParen)
: Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary),
: Expr(CXXNoexceptExprClass, Ty, VK_PRValue, OK_Ordinary),
Operand(Operand), Range(Keyword, RParen) {
CXXNoexceptExprBits.Value = Val == CT_Cannot;
setDependence(computeDependence(this, Val));
@@ -4161,7 +4161,7 @@ class SizeOfPackExpr final
SourceLocation PackLoc, SourceLocation RParenLoc,
Optional<unsigned> Length,
ArrayRef<TemplateArgument> PartialArgs)
: Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary),
: Expr(SizeOfPackExprClass, SizeType, VK_PRValue, OK_Ordinary),
OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
Length(Length ? *Length : PartialArgs.size()), Pack(Pack) {
assert((!Length || PartialArgs.empty()) &&
@@ -4528,9 +4528,7 @@ class MaterializeTemporaryExpr : public Expr {
/// Determine whether this materialized temporary is bound to an
/// lvalue reference; otherwise, it's bound to an rvalue reference.
bool isBoundToLvalueReference() const {
return getValueKind() == VK_LValue;
}
bool isBoundToLvalueReference() const { return isLValue(); }
/// Determine whether this temporary object is usable in constant
/// expressions, as specified in C++20 [expr.const]p4.
@@ -4593,8 +4591,8 @@ class CXXFoldExpr : public Expr {
SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode,
SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc,
Optional<unsigned> NumExpansions)
: Expr(CXXFoldExprClass, T, VK_RValue, OK_Ordinary), LParenLoc(LParenLoc),
EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
: Expr(CXXFoldExprClass, T, VK_PRValue, OK_Ordinary),
LParenLoc(LParenLoc), EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
NumExpansions(NumExpansions ? *NumExpansions + 1 : 0), Opcode(Opcode) {
SubExprs[SubExpr::Callee] = Callee;
SubExprs[SubExpr::LHS] = LHS;
@@ -4704,7 +4702,7 @@ class CoroutineSuspendExpr : public Expr {
CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty,
Expr *Common)
: Expr(SC, Ty, VK_RValue, OK_Ordinary), KeywordLoc(KeywordLoc) {
: Expr(SC, Ty, VK_PRValue, OK_Ordinary), KeywordLoc(KeywordLoc) {
assert(Common->isTypeDependent() && Ty->isDependentType() &&
"wrong constructor for non-dependent co_await/co_yield expression");
SubExprs[SubExpr::Common] = Common;
@@ -4808,7 +4806,7 @@ class DependentCoawaitExpr : public Expr {
public:
DependentCoawaitExpr(SourceLocation KeywordLoc, QualType Ty, Expr *Op,
UnresolvedLookupExpr *OpCoawait)
: Expr(DependentCoawaitExprClass, Ty, VK_RValue, OK_Ordinary),
: Expr(DependentCoawaitExprClass, Ty, VK_PRValue, OK_Ordinary),
KeywordLoc(KeywordLoc) {
// NOTE: A co_await expression is dependent on the coroutines promise
// type and may be dependent even when the `Op` expression is not.
@@ -55,7 +55,7 @@ class ObjCStringLiteral : public Expr {
public:
ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
: Expr(ObjCStringLiteralClass, T, VK_RValue, OK_Ordinary), String(SL),
: Expr(ObjCStringLiteralClass, T, VK_PRValue, OK_Ordinary), String(SL),
AtLoc(L) {
setDependence(ExprDependence::None);
}
@@ -91,7 +91,7 @@ class ObjCBoolLiteralExpr : public Expr {
public:
ObjCBoolLiteralExpr(bool val, QualType Ty, SourceLocation l)
: Expr(ObjCBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary), Value(val),
: Expr(ObjCBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary), Value(val),
Loc(l) {
setDependence(ExprDependence::None);
}
@@ -134,7 +134,7 @@ class ObjCBoxedExpr : public Expr {
friend class ASTStmtReader;
ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, SourceRange R)
: Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary), SubExpr(E),
: Expr(ObjCBoxedExprClass, T, VK_PRValue, OK_Ordinary), SubExpr(E),
BoxingMethod(method), Range(R) {
setDependence(computeDependence(this));
}
@@ -458,7 +458,7 @@ class ObjCSelectorExpr : public Expr {
public:
ObjCSelectorExpr(QualType T, Selector selInfo, SourceLocation at,
SourceLocation rp)
: Expr(ObjCSelectorExprClass, T, VK_RValue, OK_Ordinary),
: Expr(ObjCSelectorExprClass, T, VK_PRValue, OK_Ordinary),
SelName(selInfo), AtLoc(at), RParenLoc(rp) {
setDependence(ExprDependence::None);
}
@@ -511,7 +511,7 @@ class ObjCProtocolExpr : public Expr {
ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, SourceLocation at,
SourceLocation protoLoc, SourceLocation rp)
: Expr(ObjCProtocolExprClass, T, VK_RValue, OK_Ordinary),
: Expr(ObjCProtocolExprClass, T, VK_PRValue, OK_Ordinary),
TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) {
setDependence(ExprDependence::None);
}
@@ -1638,8 +1638,8 @@ class ObjCBridgedCastExpr final
ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind,
CastKind CK, SourceLocation BridgeKeywordLoc,
TypeSourceInfo *TSInfo, Expr *Operand)
: ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), VK_RValue,
CK, Operand, 0, false, TSInfo),
: ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(),
VK_PRValue, CK, Operand, 0, false, TSInfo),
LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {}
/// Construct an empty Objective-C bridged cast.
@@ -1692,7 +1692,7 @@ class ObjCAvailabilityCheckExpr : public Expr {
public:
ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc,
SourceLocation RParen, QualType Ty)
: Expr(ObjCAvailabilityCheckExprClass, Ty, VK_RValue, OK_Ordinary),
: Expr(ObjCAvailabilityCheckExprClass, Ty, VK_PRValue, OK_Ordinary),
VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) {
setDependence(ExprDependence::None);
}
@@ -24,14 +24,12 @@
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator.h"
#include "llvm/Support/PointerLikeTypeTraits.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <string>
#include <utility>
namespace clang {
@@ -462,10 +460,10 @@ struct LazyGenerationalUpdatePtr {
} // namespace clang
/// Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be
/// placed into a PointerUnion.
namespace llvm {
/// Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be
/// placed into a PointerUnion.
template<typename Owner, typename T,
void (clang::ExternalASTSource::*Update)(Owner)>
struct PointerLikeTypeTraits<
@@ -41,7 +41,7 @@ template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
template <typename... FnTys>
const Expr *IgnoreExprNodes(const Expr *E, FnTys &&...Fns) {
return const_cast<Expr *>(IgnoreExprNodes(E, std::forward<FnTys>(Fns)...));
return IgnoreExprNodes(const_cast<Expr *>(E), std::forward<FnTys>(Fns)...);
}
inline Expr *IgnoreImplicitCastsSingleStep(Expr *E) {
@@ -121,6 +121,18 @@ inline Expr *IgnoreImplicitSingleStep(Expr *E) {
return E;
}
inline Expr *IgnoreElidableImplicitConstructorSingleStep(Expr *E) {
auto *CCE = dyn_cast<CXXConstructExpr>(E);
if (CCE && CCE->isElidable() && !isa<CXXTemporaryObjectExpr>(CCE)) {
unsigned NumArgs = CCE->getNumArgs();
if ((NumArgs == 1 ||
(NumArgs > 1 && CCE->getArg(1)->isDefaultArgument())) &&
!CCE->getArg(0)->isDefaultArgument() && !CCE->isListInitialization())
return CCE->getArg(0);
}
return E;
}
inline Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) {
if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
return ICE->getSubExprAsWritten();
@@ -21,6 +21,7 @@
#include "clang/AST/AttrVisitor.h"
#include "clang/AST/CommentCommandTraits.h"
#include "clang/AST/CommentVisitor.h"
#include "clang/AST/ExprConcepts.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/Type.h"
@@ -204,6 +205,7 @@ class JSONNodeDumper
void Visit(const OMPClause *C);
void Visit(const BlockDecl::Capture &C);
void Visit(const GenericSelectionExpr::ConstAssociation &A);
void Visit(const concepts::Requirement *R);
void Visit(const APValue &Value, QualType Ty);
void VisitTypedefType(const TypedefType *TT);
@@ -234,6 +236,7 @@ class JSONNodeDumper
void VisitUsingDirectiveDecl(const UsingDirectiveDecl *UDD);
void VisitNamespaceAliasDecl(const NamespaceAliasDecl *NAD);
void VisitUsingDecl(const UsingDecl *UD);
void VisitUsingEnumDecl(const UsingEnumDecl *UED);
void VisitUsingShadowDecl(const UsingShadowDecl *USD);
void VisitVarDecl(const VarDecl *VD);
void VisitFieldDecl(const FieldDecl *FD);
@@ -263,6 +266,7 @@ class JSONNodeDumper
void VisitBlockDecl(const BlockDecl *D);
void VisitDeclRefExpr(const DeclRefExpr *DRE);
void VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E);
void VisitPredefinedExpr(const PredefinedExpr *PE);
void VisitUnaryOperator(const UnaryOperator *UO);
void VisitBinaryOperator(const BinaryOperator *BO);
@@ -288,6 +292,7 @@ class JSONNodeDumper
void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *BTE);
void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *MTE);
void VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *ME);
void VisitRequiresExpr(const RequiresExpr *RE);
void VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE);
void VisitObjCMessageExpr(const ObjCMessageExpr *OME);
@@ -89,6 +89,17 @@ class MangleContext {
return Result.first->second;
}
uint64_t getAnonymousStructIdForDebugInfo(const NamedDecl *D) {
llvm::DenseMap<const NamedDecl *, uint64_t>::iterator Result =
AnonStructIds.find(D);
// The decl should already be inserted, but return 0 in case it is not.
if (Result == AnonStructIds.end())
return 0;
return Result->second;
}
virtual std::string getLambdaString(const CXXRecordDecl *Lambda) = 0;
/// @name Mangler Entry Points
/// @{
@@ -96,8 +107,11 @@ class MangleContext {
virtual bool shouldMangleCXXName(const NamedDecl *D) = 0;
virtual bool shouldMangleStringLiteral(const StringLiteral *SL) = 0;
virtual bool isDeviceMangleContext() const { return false; }
virtual void setDeviceMangleContext(bool) {}
virtual bool isUniqueInternalLinkageDecl(const NamedDecl *ND) {
return false;
}
virtual void needsUniqueInternalLinkageNames() { }
// FIXME: consider replacing raw_ostream & with something like SmallString &.
void mangleName(GlobalDecl GD, raw_ostream &);
@@ -156,6 +170,8 @@ class MangleContext {
class ItaniumMangleContext : public MangleContext {
public:
using DiscriminatorOverrideTy =
llvm::Optional<unsigned> (*)(ASTContext &, const NamedDecl *);
explicit ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D)
: MangleContext(C, D, MK_Itanium) {}
@@ -178,12 +194,18 @@ class ItaniumMangleContext : public MangleContext {
virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &) = 0;
// This has to live here, otherwise the CXXNameMangler won't have access to
// it.
virtual DiscriminatorOverrideTy getDiscriminatorOverride() const = 0;
static bool classof(const MangleContext *C) {
return C->getKind() == MK_Itanium;
}
static ItaniumMangleContext *create(ASTContext &Context,
DiagnosticsEngine &Diags);
static ItaniumMangleContext *create(ASTContext &Context,
DiagnosticsEngine &Diags,
DiscriminatorOverrideTy Discriminator);
};
class MicrosoftMangleContext : public MangleContext {
@@ -794,6 +794,208 @@ class OMPSimdlenClause : public OMPClause {
}
};
/// This represents the 'sizes' clause in the '#pragma omp tile' directive.
///
/// \code
/// #pragma omp tile sizes(5,5)
/// for (int i = 0; i < 64; ++i)
/// for (int j = 0; j < 64; ++j)
/// \endcode
class OMPSizesClause final
: public OMPClause,
private llvm::TrailingObjects<OMPSizesClause, Expr *> {
friend class OMPClauseReader;
friend class llvm::TrailingObjects<OMPSizesClause, Expr *>;
/// Location of '('.
SourceLocation LParenLoc;
/// Number of tile sizes in the clause.
unsigned NumSizes;
/// Build an empty clause.
explicit OMPSizesClause(int NumSizes)
: OMPClause(llvm::omp::OMPC_sizes, SourceLocation(), SourceLocation()),
NumSizes(NumSizes) {}
public:
/// Build a 'sizes' AST node.
///
/// \param C Context of the AST.
/// \param StartLoc Location of the 'sizes' identifier.
/// \param LParenLoc Location of '('.
/// \param EndLoc Location of ')'.
/// \param Sizes Content of the clause.
static OMPSizesClause *Create(const ASTContext &C, SourceLocation StartLoc,
SourceLocation LParenLoc, SourceLocation EndLoc,
ArrayRef<Expr *> Sizes);
/// Build an empty 'sizes' AST node for deserialization.
///
/// \param C Context of the AST.
/// \param NumSizes Number of items in the clause.
static OMPSizesClause *CreateEmpty(const ASTContext &C, unsigned NumSizes);
/// Sets the location of '('.
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
/// Returns the location of '('.
SourceLocation getLParenLoc() const { return LParenLoc; }
/// Returns the number of list items.
unsigned getNumSizes() const { return NumSizes; }
/// Returns the tile size expressions.
MutableArrayRef<Expr *> getSizesRefs() {
return MutableArrayRef<Expr *>(static_cast<OMPSizesClause *>(this)
->template getTrailingObjects<Expr *>(),
NumSizes);
}
ArrayRef<Expr *> getSizesRefs() const {
return ArrayRef<Expr *>(static_cast<const OMPSizesClause *>(this)
->template getTrailingObjects<Expr *>(),
NumSizes);
}
/// Sets the tile size expressions.
void setSizesRefs(ArrayRef<Expr *> VL) {
assert(VL.size() == NumSizes);
std::copy(VL.begin(), VL.end(),
static_cast<OMPSizesClause *>(this)
->template getTrailingObjects<Expr *>());
}
child_range children() {
MutableArrayRef<Expr *> Sizes = getSizesRefs();
return child_range(reinterpret_cast<Stmt **>(Sizes.begin()),
reinterpret_cast<Stmt **>(Sizes.end()));
}
const_child_range children() const {
ArrayRef<Expr *> Sizes = getSizesRefs();
return const_child_range(reinterpret_cast<Stmt *const *>(Sizes.begin()),
reinterpret_cast<Stmt *const *>(Sizes.end()));
}
child_range used_children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range used_children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}
static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_sizes;
}
};
/// Representation of the 'full' clause of the '#pragma omp unroll' directive.
///
/// \code
/// #pragma omp unroll full
/// for (int i = 0; i < 64; ++i)
/// \endcode
class OMPFullClause final : public OMPClause {
friend class OMPClauseReader;
/// Build an empty clause.
explicit OMPFullClause() : OMPClause(llvm::omp::OMPC_full, {}, {}) {}
public:
/// Build an AST node for a 'full' clause.
///
/// \param C Context of the AST.
/// \param StartLoc Starting location of the clause.
/// \param EndLoc Ending location of the clause.
static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc,
SourceLocation EndLoc);
/// Build an empty 'full' AST node for deserialization.
///
/// \param C Context of the AST.
static OMPFullClause *CreateEmpty(const ASTContext &C);
child_range children() { return {child_iterator(), child_iterator()}; }
const_child_range children() const {
return {const_child_iterator(), const_child_iterator()};
}
child_range used_children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range used_children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}
static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_full;
}
};
/// Representation of the 'partial' clause of the '#pragma omp unroll'
/// directive.
///
/// \code
/// #pragma omp unroll partial(4)
/// for (int i = start; i < end; ++i)
/// \endcode
class OMPPartialClause final : public OMPClause {
friend class OMPClauseReader;
/// Location of '('.
SourceLocation LParenLoc;
/// Optional argument to the clause (unroll factor).
Stmt *Factor;
/// Build an empty clause.
explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {}
/// Set the unroll factor.
void setFactor(Expr *E) { Factor = E; }
/// Sets the location of '('.
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
public:
/// Build an AST node for a 'partial' clause.
///
/// \param C Context of the AST.
/// \param StartLoc Location of the 'partial' identifier.
/// \param LParenLoc Location of '('.
/// \param EndLoc Location of ')'.
/// \param Factor Clause argument.
static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc,
SourceLocation LParenLoc,
SourceLocation EndLoc, Expr *Factor);
/// Build an empty 'partial' AST node for deserialization.
///
/// \param C Context of the AST.
static OMPPartialClause *CreateEmpty(const ASTContext &C);
/// Returns the location of '('.
SourceLocation getLParenLoc() const { return LParenLoc; }
/// Returns the argument of the clause or nullptr if not set.
Expr *getFactor() const { return cast_or_null<Expr>(Factor); }
child_range children() { return child_range(&Factor, &Factor + 1); }
const_child_range children() const {
return const_child_range(&Factor, &Factor + 1);
}
child_range used_children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range used_children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}
static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_partial;
}
};
/// This represents 'collapse' clause in the '#pragma omp ...'
/// directive.
///
@@ -5261,14 +5463,14 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
if (!(--RemainingLists)) {
++DeclCur;
++NumListsCur;
if (SupportsMapper)
++MapperCur;
RemainingLists = *NumListsCur;
assert(RemainingLists && "No lists in the following declaration??");
}
}
++ListSizeCur;
if (SupportsMapper)
++MapperCur;
return *this;
}
};
@@ -7272,15 +7474,244 @@ class OMPOrderClause final : public OMPClause {
}
};
/// This represents the 'init' clause in '#pragma omp ...' directives.
///
/// \code
/// #pragma omp interop init(target:obj)
/// \endcode
class OMPInitClause final
: public OMPVarListClause<OMPInitClause>,
private llvm::TrailingObjects<OMPInitClause, Expr *> {
friend class OMPClauseReader;
friend OMPVarListClause;
friend TrailingObjects;
/// Location of interop variable.
SourceLocation VarLoc;
bool IsTarget = false;
bool IsTargetSync = false;
void setInteropVar(Expr *E) { varlist_begin()[0] = E; }
void setIsTarget(bool V) { IsTarget = V; }
void setIsTargetSync(bool V) { IsTargetSync = V; }
/// Sets the location of the interop variable.
void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
/// Build 'init' clause.
///
/// \param IsTarget Uses the 'target' interop-type.
/// \param IsTargetSync Uses the 'targetsync' interop-type.
/// \param StartLoc Starting location of the clause.
/// \param LParenLoc Location of '('.
/// \param VarLoc Location of the interop variable.
/// \param EndLoc Ending location of the clause.
/// \param N Number of expressions.
OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc,
SourceLocation LParenLoc, SourceLocation VarLoc,
SourceLocation EndLoc, unsigned N)
: OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc,
LParenLoc, EndLoc, N),
VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {}
/// Build an empty clause.
OMPInitClause(unsigned N)
: OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(),
SourceLocation(), SourceLocation(), N) {
}
public:
/// Creates a fully specified clause.
///
/// \param C AST context.
/// \param InteropVar The interop variable.
/// \param PrefExprs The list of preference expressions.
/// \param IsTarget Uses the 'target' interop-type.
/// \param IsTargetSync Uses the 'targetsync' interop-type.
/// \param StartLoc Starting location of the clause.
/// \param LParenLoc Location of '('.
/// \param VarLoc Location of the interop variable.
/// \param EndLoc Ending location of the clause.
static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar,
ArrayRef<Expr *> PrefExprs, bool IsTarget,
bool IsTargetSync, SourceLocation StartLoc,
SourceLocation LParenLoc, SourceLocation VarLoc,
SourceLocation EndLoc);
/// Creates an empty clause with \a N expressions.
///
/// \param C AST context.
/// \param N Number of expression items.
static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N);
/// Returns the location of the interop variable.
SourceLocation getVarLoc() const { return VarLoc; }
/// Returns the interop variable.
Expr *getInteropVar() { return varlist_begin()[0]; }
const Expr *getInteropVar() const { return varlist_begin()[0]; }
/// Returns true is interop-type 'target' is used.
bool getIsTarget() const { return IsTarget; }
/// Returns true is interop-type 'targetsync' is used.
bool getIsTargetSync() const { return IsTargetSync; }
child_range children() {
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
reinterpret_cast<Stmt **>(varlist_end()));
}
const_child_range children() const {
auto Children = const_cast<OMPInitClause *>(this)->children();
return const_child_range(Children.begin(), Children.end());
}
child_range used_children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range used_children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}
using prefs_iterator = MutableArrayRef<Expr *>::iterator;
using const_prefs_iterator = ArrayRef<const Expr *>::iterator;
using prefs_range = llvm::iterator_range<prefs_iterator>;
using const_prefs_range = llvm::iterator_range<const_prefs_iterator>;
prefs_range prefs() {
return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())),
reinterpret_cast<Expr **>(varlist_end()));
}
const_prefs_range prefs() const {
auto Prefs = const_cast<OMPInitClause *>(this)->prefs();
return const_prefs_range(Prefs.begin(), Prefs.end());
}
static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_init;
}
};
/// This represents the 'use' clause in '#pragma omp ...' directives.
///
/// \code
/// #pragma omp interop use(obj)
/// \endcode
class OMPUseClause final : public OMPClause {
friend class OMPClauseReader;
/// Location of '('.
SourceLocation LParenLoc;
/// Location of interop variable.
SourceLocation VarLoc;
/// The interop variable.
Stmt *InteropVar = nullptr;
/// Set the interop variable.
void setInteropVar(Expr *E) { InteropVar = E; }
/// Sets the location of '('.
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
/// Sets the location of the interop variable.
void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
public:
/// Build 'use' clause with and interop variable expression \a InteropVar.
///
/// \param InteropVar The interop variable.
/// \param StartLoc Starting location of the clause.
/// \param LParenLoc Location of '('.
/// \param VarLoc Location of the interop variable.
/// \param EndLoc Ending location of the clause.
OMPUseClause(Expr *InteropVar, SourceLocation StartLoc,
SourceLocation LParenLoc, SourceLocation VarLoc,
SourceLocation EndLoc)
: OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc),
VarLoc(VarLoc), InteropVar(InteropVar) {}
/// Build an empty clause.
OMPUseClause()
: OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {}
/// Returns the location of '('.
SourceLocation getLParenLoc() const { return LParenLoc; }
/// Returns the location of the interop variable.
SourceLocation getVarLoc() const { return VarLoc; }
/// Returns the interop variable.
Expr *getInteropVar() const { return cast<Expr>(InteropVar); }
child_range children() { return child_range(&InteropVar, &InteropVar + 1); }
const_child_range children() const {
return const_child_range(&InteropVar, &InteropVar + 1);
}
child_range used_children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range used_children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}
static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_use;
}
};
/// This represents 'destroy' clause in the '#pragma omp depobj'
/// directive.
/// directive or the '#pragma omp interop' directive..
///
/// \code
/// #pragma omp depobj(a) destroy
/// #pragma omp interop destroy(obj)
/// \endcode
/// In this example directive '#pragma omp depobj' has 'destroy' clause.
/// In these examples directive '#pragma omp depobj' and '#pragma omp interop'
/// have a 'destroy' clause. The 'interop' directive includes an object.
class OMPDestroyClause final : public OMPClause {
friend class OMPClauseReader;
/// Location of '('.
SourceLocation LParenLoc;
/// Location of interop variable.
SourceLocation VarLoc;
/// The interop variable.
Stmt *InteropVar = nullptr;
/// Set the interop variable.
void setInteropVar(Expr *E) { InteropVar = E; }
/// Sets the location of '('.
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
/// Sets the location of the interop variable.
void setVarLoc(SourceLocation Loc) { VarLoc = Loc; }
public:
/// Build 'destroy' clause with an interop variable expression \a InteropVar.
///
/// \param InteropVar The interop variable.
/// \param StartLoc Starting location of the clause.
/// \param LParenLoc Location of '('.
/// \param VarLoc Location of the interop variable.
/// \param EndLoc Ending location of the clause.
OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc,
SourceLocation LParenLoc, SourceLocation VarLoc,
SourceLocation EndLoc)
: OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc),
LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {}
/// Build 'destroy' clause.
///
/// \param StartLoc Starting location of the clause.
@@ -7293,11 +7724,24 @@ class OMPDestroyClause final : public OMPClause {
: OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) {
}
/// Returns the location of '('.
SourceLocation getLParenLoc() const { return LParenLoc; }
/// Returns the location of the interop variable.
SourceLocation getVarLoc() const { return VarLoc; }
/// Returns the interop variable.
Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); }
child_range children() {
if (InteropVar)
return child_range(&InteropVar, &InteropVar + 1);
return child_range(child_iterator(), child_iterator());
}
const_child_range children() const {
if (InteropVar)
return const_child_range(&InteropVar, &InteropVar + 1);
return const_child_range(const_child_iterator(), const_child_iterator());
}
@@ -7313,6 +7757,146 @@ class OMPDestroyClause final : public OMPClause {
}
};
/// This represents 'novariants' clause in the '#pragma omp ...' directive.
///
/// \code
/// #pragma omp dispatch novariants(a > 5)
/// \endcode
/// In this example directive '#pragma omp dispatch' has simple 'novariants'
/// clause with condition 'a > 5'.
class OMPNovariantsClause final : public OMPClause,
public OMPClauseWithPreInit {
friend class OMPClauseReader;
/// Location of '('.
SourceLocation LParenLoc;
/// Condition of the 'if' clause.
Stmt *Condition = nullptr;
/// Set condition.
void setCondition(Expr *Cond) { Condition = Cond; }
/// Sets the location of '('.
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
public:
/// Build 'novariants' clause with condition \a Cond.
///
/// \param Cond Condition of the clause.
/// \param HelperCond Helper condition for the construct.
/// \param CaptureRegion Innermost OpenMP region where expressions in this
/// clause must be captured.
/// \param StartLoc Starting location of the clause.
/// \param LParenLoc Location of '('.
/// \param EndLoc Ending location of the clause.
OMPNovariantsClause(Expr *Cond, Stmt *HelperCond,
OpenMPDirectiveKind CaptureRegion,
SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation EndLoc)
: OMPClause(llvm::omp::OMPC_novariants, StartLoc, EndLoc),
OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond) {
setPreInitStmt(HelperCond, CaptureRegion);
}
/// Build an empty clause.
OMPNovariantsClause()
: OMPClause(llvm::omp::OMPC_novariants, SourceLocation(),
SourceLocation()),
OMPClauseWithPreInit(this) {}
/// Returns the location of '('.
SourceLocation getLParenLoc() const { return LParenLoc; }
/// Returns condition.
Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
child_range children() { return child_range(&Condition, &Condition + 1); }
const_child_range children() const {
return const_child_range(&Condition, &Condition + 1);
}
child_range used_children();
const_child_range used_children() const {
auto Children = const_cast<OMPNovariantsClause *>(this)->used_children();
return const_child_range(Children.begin(), Children.end());
}
static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_novariants;
}
};
/// This represents 'nocontext' clause in the '#pragma omp ...' directive.
///
/// \code
/// #pragma omp dispatch nocontext(a > 5)
/// \endcode
/// In this example directive '#pragma omp dispatch' has simple 'nocontext'
/// clause with condition 'a > 5'.
class OMPNocontextClause final : public OMPClause, public OMPClauseWithPreInit {
friend class OMPClauseReader;
/// Location of '('.
SourceLocation LParenLoc;
/// Condition of the 'if' clause.
Stmt *Condition = nullptr;
/// Set condition.
void setCondition(Expr *Cond) { Condition = Cond; }
/// Sets the location of '('.
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
public:
/// Build 'nocontext' clause with condition \a Cond.
///
/// \param Cond Condition of the clause.
/// \param HelperCond Helper condition for the construct.
/// \param CaptureRegion Innermost OpenMP region where expressions in this
/// clause must be captured.
/// \param StartLoc Starting location of the clause.
/// \param LParenLoc Location of '('.
/// \param EndLoc Ending location of the clause.
OMPNocontextClause(Expr *Cond, Stmt *HelperCond,
OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
SourceLocation LParenLoc, SourceLocation EndLoc)
: OMPClause(llvm::omp::OMPC_nocontext, StartLoc, EndLoc),
OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond) {
setPreInitStmt(HelperCond, CaptureRegion);
}
/// Build an empty clause.
OMPNocontextClause()
: OMPClause(llvm::omp::OMPC_nocontext, SourceLocation(),
SourceLocation()),
OMPClauseWithPreInit(this) {}
/// Returns the location of '('.
SourceLocation getLParenLoc() const { return LParenLoc; }
/// Returns condition.
Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
child_range children() { return child_range(&Condition, &Condition + 1); }
const_child_range children() const {
return const_child_range(&Condition, &Condition + 1);
}
child_range used_children();
const_child_range used_children() const {
auto Children = const_cast<OMPNocontextClause *>(this)->used_children();
return const_child_range(Children.begin(), Children.end());
}
static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_nocontext;
}
};
/// This represents 'detach' clause in the '#pragma omp task' directive.
///
/// \code
@@ -7749,6 +8333,77 @@ class OMPAffinityClause final
}
};
/// This represents 'filter' clause in the '#pragma omp ...' directive.
///
/// \code
/// #pragma omp masked filter(tid)
/// \endcode
/// In this example directive '#pragma omp masked' has 'filter' clause with
/// thread id.
class OMPFilterClause final : public OMPClause, public OMPClauseWithPreInit {
friend class OMPClauseReader;
/// Location of '('.
SourceLocation LParenLoc;
/// Express of the 'filter' clause.
Stmt *ThreadID = nullptr;
/// Sets the thread identifier.
void setThreadID(Expr *TID) { ThreadID = TID; }
/// Sets the location of '('.
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
public:
/// Build 'filter' clause with thread-id \a ThreadID.
///
/// \param ThreadID Thread identifier.
/// \param HelperE Helper expression associated with this clause.
/// \param CaptureRegion Innermost OpenMP region where expressions in this
/// clause must be captured.
/// \param StartLoc Starting location of the clause.
/// \param LParenLoc Location of '('.
/// \param EndLoc Ending location of the clause.
OMPFilterClause(Expr *ThreadID, Stmt *HelperE,
OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
SourceLocation LParenLoc, SourceLocation EndLoc)
: OMPClause(llvm::omp::OMPC_filter, StartLoc, EndLoc),
OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadID(ThreadID) {
setPreInitStmt(HelperE, CaptureRegion);
}
/// Build an empty clause.
OMPFilterClause()
: OMPClause(llvm::omp::OMPC_filter, SourceLocation(), SourceLocation()),
OMPClauseWithPreInit(this) {}
/// Returns the location of '('.
SourceLocation getLParenLoc() const { return LParenLoc; }
/// Return thread identifier.
Expr *getThreadID() { return cast<Expr>(ThreadID); }
/// Return thread identifier.
Expr *getThreadID() const { return cast<Expr>(ThreadID); }
child_range children() { return child_range(&ThreadID, &ThreadID + 1); }
const_child_range children() const {
return const_child_range(&ThreadID, &ThreadID + 1);
}
child_range used_children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range used_children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}
static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_filter;
}
};
/// This class implements a simple visitor for OMPClause
/// subclasses.
template<class ImplClass, template <typename> class Ptr, typename RetTy>
@@ -181,6 +181,9 @@ CAST_OPERATION(PointerToBoolean)
/// (void) malloc(2048)
CAST_OPERATION(ToVoid)
/// CK_MatrixCast - A cast between matrix types of the same dimensions.
CAST_OPERATION(MatrixCast)
/// CK_VectorSplat - A conversion from an arithmetic type to a
/// vector of that element type. Fills all elements ("splats") with
/// the source value.
@@ -64,9 +64,10 @@ class ParentMapContext {
Expr *traverseIgnored(Expr *E) const;
DynTypedNode traverseIgnored(const DynTypedNode &N) const;
class ParentMap;
private:
ASTContext &ASTCtx;
class ParentMap;
TraversalKind Traversal = TK_AsIs;
std::unique_ptr<ParentMap> Parents;
};
@@ -192,14 +192,12 @@ template <typename Derived> class RecursiveASTVisitor {
/// Return whether this visitor should traverse post-order.
bool shouldTraversePostOrder() const { return false; }
/// Recursively visits an entire AST, starting from the top-level Decls
/// in the AST traversal scope (by default, the TranslationUnitDecl).
/// Recursively visits an entire AST, starting from the TranslationUnitDecl.
/// \returns false if visitation was terminated early.
bool TraverseAST(ASTContext &AST) {
for (Decl *D : AST.getTraversalScope())
if (!getDerived().TraverseDecl(D))
return false;
return true;
// Currently just an alias for TraverseDecl(TUDecl), but kept in case
// we change the implementation again.
return getDerived().TraverseDecl(AST.getTranslationUnitDecl());
}
/// Recursively visit a statement or expression, by
@@ -481,6 +479,8 @@ template <typename Derived> class RecursiveASTVisitor {
template <typename T>
bool TraverseDeclTemplateParameterLists(T *D);
bool TraverseTemplateTypeParamDeclConstraints(const TemplateTypeParmDecl *D);
bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL,
unsigned Count);
bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
@@ -658,8 +658,14 @@ bool RecursiveASTVisitor<Derived>::TraverseDecl(Decl *D) {
// As a syntax visitor, by default we want to ignore declarations for
// implicit declarations (ones not typed explicitly by the user).
if (!getDerived().shouldVisitImplicitCode() && D->isImplicit())
if (!getDerived().shouldVisitImplicitCode() && D->isImplicit()) {
// For an implicit template type parameter, its type constraints are not
// implicit and are not represented anywhere else. We still need to visit
// them.
if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(D))
return TraverseTemplateTypeParamDeclConstraints(TTPD);
return true;
}
switch (D->getKind()) {
#define ABSTRACT_DECL(DECL)
@@ -1487,12 +1493,24 @@ DEF_TRAVERSE_DECL(StaticAssertDecl, {
TRY_TO(TraverseStmt(D->getMessage()));
})
DEF_TRAVERSE_DECL(
TranslationUnitDecl,
{// Code in an unnamed namespace shows up automatically in
// decls_begin()/decls_end(). Thus we don't need to recurse on
// D->getAnonymousNamespace().
})
DEF_TRAVERSE_DECL(TranslationUnitDecl, {
// Code in an unnamed namespace shows up automatically in
// decls_begin()/decls_end(). Thus we don't need to recurse on
// D->getAnonymousNamespace().
// If the traversal scope is set, then consider them to be the children of
// the TUDecl, rather than traversing (and loading?) all top-level decls.
auto Scope = D->getASTContext().getTraversalScope();
bool HasLimitedScope =
Scope.size() != 1 || !isa<TranslationUnitDecl>(Scope.front());
if (HasLimitedScope) {
ShouldVisitChildren = false; // we'll do that here instead
for (auto *Child : Scope) {
if (!canIgnoreChildDeclWhileTraversingDeclContext(Child))
TRY_TO(TraverseDecl(Child));
}
}
})
DEF_TRAVERSE_DECL(PragmaCommentDecl, {})
@@ -1585,6 +1603,8 @@ DEF_TRAVERSE_DECL(UsingDecl, {
TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
})
DEF_TRAVERSE_DECL(UsingEnumDecl, {})
DEF_TRAVERSE_DECL(UsingPackDecl, {})
DEF_TRAVERSE_DECL(UsingDirectiveDecl, {
@@ -1779,10 +1799,9 @@ DEF_TRAVERSE_DECL(BuiltinTemplateDecl, {
TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
})
DEF_TRAVERSE_DECL(TemplateTypeParmDecl, {
// D is the "T" in something like "template<typename T> class vector;"
if (D->getTypeForDecl())
TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseTemplateTypeParamDeclConstraints(
const TemplateTypeParmDecl *D) {
if (const auto *TC = D->getTypeConstraint()) {
if (Expr *IDC = TC->getImmediatelyDeclaredConstraint()) {
TRY_TO(TraverseStmt(IDC));
@@ -1794,6 +1813,14 @@ DEF_TRAVERSE_DECL(TemplateTypeParmDecl, {
TRY_TO(TraverseConceptReference(*TC));
}
}
return true;
}
DEF_TRAVERSE_DECL(TemplateTypeParmDecl, {
// D is the "T" in something like "template<typename T> class vector;"
if (D->getTypeForDecl())
TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
TRY_TO(TraverseTemplateTypeParamDeclConstraints(D));
if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc()));
})
@@ -1831,6 +1858,8 @@ DEF_TRAVERSE_DECL(UnresolvedUsingTypenameDecl, {
// source.
})
DEF_TRAVERSE_DECL(UnresolvedUsingIfExistsDecl, {})
DEF_TRAVERSE_DECL(EnumDecl, {
TRY_TO(TraverseDeclTemplateParameterLists(D));
@@ -2623,7 +2652,16 @@ DEF_TRAVERSE_STMT(ObjCMessageExpr, {
TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
})
DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, {})
DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, {
if (S->isClassReceiver()) {
ObjCInterfaceDecl *IDecl = S->getClassReceiver();
QualType Type = IDecl->getASTContext().getObjCInterfaceType(IDecl);
ObjCInterfaceLocInfo Data;
Data.NameLoc = S->getReceiverLocation();
Data.NameEndLoc = Data.NameLoc;
TRY_TO(TraverseTypeLoc(TypeLoc(Type, &Data)));
}
})
DEF_TRAVERSE_STMT(ObjCSubscriptRefExpr, {})
DEF_TRAVERSE_STMT(ObjCProtocolExpr, {})
DEF_TRAVERSE_STMT(ObjCSelectorExpr, {})
@@ -2636,6 +2674,9 @@ DEF_TRAVERSE_STMT(ObjCBridgedCastExpr, {
DEF_TRAVERSE_STMT(ObjCAvailabilityCheckExpr, {})
DEF_TRAVERSE_STMT(ParenExpr, {})
DEF_TRAVERSE_STMT(ParenListExpr, {})
DEF_TRAVERSE_STMT(SYCLUniqueStableNameExpr, {
TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
})
DEF_TRAVERSE_STMT(PredefinedExpr, {})
DEF_TRAVERSE_STMT(ShuffleVectorExpr, {})
DEF_TRAVERSE_STMT(ConvertVectorExpr, {})
@@ -2787,6 +2828,14 @@ bool RecursiveASTVisitor<Derived>::TraverseOMPExecutableDirective(
return true;
}
DEF_TRAVERSE_STMT(OMPCanonicalLoop, {
if (!getDerived().shouldVisitImplicitCode()) {
// Visit only the syntactical loop.
TRY_TO(TraverseStmt(S->getLoopStmt()));
ShouldVisitChildren = false;
}
})
template <typename Derived>
bool
RecursiveASTVisitor<Derived>::TraverseOMPLoopDirective(OMPLoopDirective *S) {
@@ -2799,6 +2848,12 @@ DEF_TRAVERSE_STMT(OMPParallelDirective,
DEF_TRAVERSE_STMT(OMPSimdDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
DEF_TRAVERSE_STMT(OMPTileDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
DEF_TRAVERSE_STMT(OMPUnrollDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
DEF_TRAVERSE_STMT(OMPForDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
@@ -2957,6 +3012,15 @@ DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForSimdDirective,
DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeSimdDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
DEF_TRAVERSE_STMT(OMPInteropDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
DEF_TRAVERSE_STMT(OMPDispatchDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
DEF_TRAVERSE_STMT(OMPMaskedDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
@@ -3039,6 +3103,24 @@ bool RecursiveASTVisitor<Derived>::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
return true;
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPSizesClause(OMPSizesClause *C) {
for (Expr *E : C->getSizesRefs())
TRY_TO(TraverseStmt(E));
return true;
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPFullClause(OMPFullClause *C) {
return true;
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPPartialClause(OMPPartialClause *C) {
TRY_TO(TraverseStmt(C->getFactor()));
return true;
}
template <typename Derived>
bool
RecursiveASTVisitor<Derived>::VisitOMPCollapseClause(OMPCollapseClause *C) {
@@ -3177,7 +3259,36 @@ bool RecursiveASTVisitor<Derived>::VisitOMPNogroupClause(OMPNogroupClause *) {
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPDestroyClause(OMPDestroyClause *) {
bool RecursiveASTVisitor<Derived>::VisitOMPInitClause(OMPInitClause *C) {
TRY_TO(VisitOMPClauseList(C));
return true;
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPUseClause(OMPUseClause *C) {
TRY_TO(TraverseStmt(C->getInteropVar()));
return true;
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPDestroyClause(OMPDestroyClause *C) {
TRY_TO(TraverseStmt(C->getInteropVar()));
return true;
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPNovariantsClause(
OMPNovariantsClause *C) {
TRY_TO(VisitOMPClauseWithPreInit(C));
TRY_TO(TraverseStmt(C->getCondition()));
return true;
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPNocontextClause(
OMPNocontextClause *C) {
TRY_TO(VisitOMPClauseWithPreInit(C));
TRY_TO(TraverseStmt(C->getCondition()));
return true;
}
@@ -3556,6 +3667,13 @@ bool RecursiveASTVisitor<Derived>::VisitOMPAffinityClause(
return true;
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPFilterClause(OMPFilterClause *C) {
TRY_TO(VisitOMPClauseWithPreInit(C));
TRY_TO(TraverseStmt(C->getThreadID()));
return true;
}
// FIXME: look at the following tricky-seeming exprs to see if we
// need to recurse on anything. These are ones that have methods
// returning decls or qualtypes or nestednamespecifier -- though I'm
@@ -193,6 +193,7 @@ class Redeclarable {
public:
friend class ASTDeclReader;
friend class ASTDeclWriter;
friend class IncrementalParser;
Redeclarable(const ASTContext &Ctx)
: RedeclLink(LatestDeclLink(Ctx)),
@@ -518,7 +518,7 @@ class alignas(void *) Stmt {
unsigned : NumExprBits;
unsigned Kind : 6;
unsigned Kind : 7;
unsigned PartOfExplicitCast : 1; // Only set for ImplicitCastExpr.
/// True if the call expression has some floating-point features.
@@ -1798,6 +1798,7 @@ class ValueStmt : public Stmt {
class LabelStmt : public ValueStmt {
LabelDecl *TheDecl;
Stmt *SubStmt;
bool SideEntry = false;
public:
/// Build a label statement.
@@ -1833,6 +1834,8 @@ class LabelStmt : public ValueStmt {
static bool classof(const Stmt *T) {
return T->getStmtClass() == LabelStmtClass;
}
bool isSideEntry() const { return SideEntry; }
void setSideEntry(bool SE) { SideEntry = SE; }
};
/// Represents an attribute applied to a statement.
@@ -2080,6 +2083,7 @@ class IfStmt final
/// If this is an 'if constexpr', determine which substatement will be taken.
/// Otherwise, or if the condition is value-dependent, returns None.
Optional<const Stmt*> getNondiscardedCase(const ASTContext &Ctx) const;
Optional<Stmt *> getNondiscardedCase(const ASTContext &Ctx);
bool isObjCAvailabilityCheck() const;
@@ -2119,7 +2123,7 @@ class SwitchStmt final : public Stmt,
friend TrailingObjects;
/// Points to a linked list of case and default statements.
SwitchCase *FirstCase;
SwitchCase *FirstCase = nullptr;
// SwitchStmt is followed by several trailing objects,
// some of which optional. Note that it would be more convenient to
@@ -51,7 +51,7 @@ class CallExpr {
// Print all template arguments into ArgString
llvm::raw_string_ostream OS(ArgString);
for (unsigned i = 0; i < Args->size(); ++i) {
Args->get(i).print(Context.getLangOpts(), OS);
Args->get(i).print(Context.getLangOpts(), OS, /*IncludeType*/ true);
// Add a padding character so that 'foo<X, XX>()' != 'foo<XX, X>()'.
OS << '\n';
}
@@ -74,14 +74,17 @@ class StmtIteratorBase {
};
template <typename DERIVED, typename REFERENCE>
class StmtIteratorImpl : public StmtIteratorBase,
public std::iterator<std::forward_iterator_tag,
REFERENCE, ptrdiff_t,
REFERENCE, REFERENCE> {
class StmtIteratorImpl : public StmtIteratorBase {
protected:
StmtIteratorImpl(const StmtIteratorBase& RHS) : StmtIteratorBase(RHS) {}
public:
using iterator_category = std::forward_iterator_tag;
using value_type = REFERENCE;
using difference_type = std::ptrdiff_t;
using pointer = REFERENCE;
using reference = REFERENCE;
StmtIteratorImpl() = default;
StmtIteratorImpl(Stmt **s) : StmtIteratorBase(s) {}
StmtIteratorImpl(Decl **dgi, Decl **dge) : StmtIteratorBase(dgi, dge) {}
File diff suppressed because it is too large Load Diff
@@ -389,7 +389,8 @@ class TemplateArgument {
TemplateArgument getPackExpansionPattern() const;
/// Print this template argument to the given output stream.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const;
void print(const PrintingPolicy &Policy, raw_ostream &Out,
bool IncludeType) const;
/// Debugging aid that dumps the template argument.
void dump(raw_ostream &Out) const;
@@ -512,7 +513,8 @@ class TemplateArgumentLoc {
}
TypeSourceInfo *getTypeSourceInfo() const {
assert(Argument.getKind() == TemplateArgument::Type);
if (Argument.getKind() != TemplateArgument::Type)
return nullptr;
return LocInfo.getAsTypeSourceInfo();
}
@@ -19,6 +19,7 @@
#include "clang/AST/CommentCommandTraits.h"
#include "clang/AST/CommentVisitor.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/AST/ExprConcepts.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/TemplateArgumentVisitor.h"
@@ -69,10 +70,8 @@ class TextTreeStructure {
return;
}
// We need to capture an owning-string in the lambda because the lambda
// is invoked in a deferred manner.
std::string LabelStr(Label);
auto DumpWithIndent = [this, DoAddChild, LabelStr](bool IsLastChild) {
auto DumpWithIndent = [this, DoAddChild,
Label(Label.str())](bool IsLastChild) {
// Print out the appropriate tree structure and work out the prefix for
// children of this node. For instance:
//
@@ -89,8 +88,8 @@ class TextTreeStructure {
OS << '\n';
ColorScope Color(OS, ShowColors, IndentColor);
OS << Prefix << (IsLastChild ? '`' : '|') << '-';
if (!LabelStr.empty())
OS << LabelStr << ": ";
if (!Label.empty())
OS << Label << ": ";
this->Prefix.push_back(IsLastChild ? ' ' : '|');
this->Prefix.push_back(' ');
@@ -190,6 +189,8 @@ class TextNodeDumper
void Visit(const GenericSelectionExpr::ConstAssociation &A);
void Visit(const concepts::Requirement *R);
void Visit(const APValue &Value, QualType Ty);
void dumpPointer(const void *Ptr);
@@ -251,6 +252,7 @@ class TextNodeDumper
void VisitCastExpr(const CastExpr *Node);
void VisitImplicitCastExpr(const ImplicitCastExpr *Node);
void VisitDeclRefExpr(const DeclRefExpr *Node);
void VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *Node);
void VisitPredefinedExpr(const PredefinedExpr *Node);
void VisitCharacterLiteral(const CharacterLiteral *Node);
void VisitIntegerLiteral(const IntegerLiteral *Node);
@@ -297,6 +299,7 @@ class TextNodeDumper
void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node);
void VisitOMPIteratorExpr(const OMPIteratorExpr *Node);
void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *Node);
void VisitRequiresExpr(const RequiresExpr *Node);
void VisitRValueReferenceType(const ReferenceType *T);
void VisitArrayType(const ArrayType *T);
@@ -352,6 +355,7 @@ class TextNodeDumper
void VisitUsingDecl(const UsingDecl *D);
void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D);
void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
void VisitUsingEnumDecl(const UsingEnumDecl *D);
void VisitUsingShadowDecl(const UsingShadowDecl *D);
void VisitConstructorUsingShadowDecl(const ConstructorUsingShadowDecl *D);
void VisitLinkageSpecDecl(const LinkageSpecDecl *D);
@@ -486,9 +486,16 @@ class Qualifiers {
// allocated on device, which are a subset of __global.
(A == LangAS::opencl_global && (B == LangAS::opencl_global_device ||
B == LangAS::opencl_global_host)) ||
(A == LangAS::sycl_global && (B == LangAS::sycl_global_device ||
B == LangAS::sycl_global_host)) ||
// Consider pointer size address spaces to be equivalent to default.
((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
(isPtrSizeAddressSpace(B) || B == LangAS::Default));
(isPtrSizeAddressSpace(B) || B == LangAS::Default)) ||
// Default is a superset of SYCL address spaces.
(A == LangAS::Default &&
(B == LangAS::sycl_private || B == LangAS::sycl_local ||
B == LangAS::sycl_global || B == LangAS::sycl_global_device ||
B == LangAS::sycl_global_host));
}
/// Returns true if the address space in these qualifiers is equal to or
@@ -2526,6 +2533,9 @@ class BuiltinType : public Type {
// PPC MMA Types
#define PPC_VECTOR_TYPE(Name, Id, Size) Id,
#include "clang/Basic/PPCTypes.def"
// RVV Types
#define RVV_TYPE(Name, Id, SingletonId) Id,
#include "clang/Basic/RISCVVTypes.def"
// All other builtin types
#define BUILTIN_TYPE(Id, SingletonId) Id,
#define LAST_BUILTIN_TYPE(Id) LastKind = Id
@@ -5446,8 +5456,13 @@ class ElaboratedType final
ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
QualType NamedType, QualType CanonType, TagDecl *OwnedTagDecl)
: TypeWithKeyword(Keyword, Elaborated, CanonType,
// Any semantic dependence on the qualifier will have
// been incorporated into NamedType. We still need to
// track syntactic (instantiation / error / pack)
// dependence on the qualifier.
NamedType->getDependence() |
(NNS ? toTypeDependence(NNS->getDependence())
(NNS ? toSyntacticDependence(
toTypeDependence(NNS->getDependence()))
: TypeDependence::None)),
NNS(NNS), NamedType(NamedType) {
ElaboratedTypeBits.HasOwnedTagDecl = false;
@@ -769,6 +769,10 @@ let Class = BuiltinType in {
case BuiltinType::ID: return ctx.ID##Ty;
#include "clang/Basic/PPCTypes.def"
#define RVV_TYPE(NAME, ID, SINGLETON_ID) \
case BuiltinType::ID: return ctx.SINGLETON_ID;
#include "clang/Basic/RISCVVTypes.def"
#define BUILTIN_TYPE(ID, SINGLETON_ID) \
case BuiltinType::ID: return ctx.SINGLETON_ID;
#include "clang/AST/BuiltinTypes.def"
@@ -18,6 +18,7 @@
#include "clang/AST/GlobalDecl.h"
#include "clang/AST/RecordLayout.h"
#include "clang/Basic/ABI.h"
#include "clang/Basic/Thunk.h"
#include "llvm/ADT/DenseMap.h"
#include <memory>
#include <utility>
@@ -110,6 +110,12 @@ class MatchFinder {
/// This id is used, for example, for the profiling output.
/// It defaults to "<unknown>".
virtual StringRef getID() const;
/// TraversalKind to use while matching and processing
/// the result nodes. This API is temporary to facilitate
/// third parties porting existing code to the default
/// behavior of clang-tidy.
virtual llvm::Optional<TraversalKind> getCheckTraversalKind() const;
};
/// Called when parsing is finished. Intended for testing only.
@@ -280,6 +286,11 @@ class CollectMatchesCallback : public MatchFinder::MatchCallback {
void run(const MatchFinder::MatchResult &Result) override {
Nodes.push_back(Result.Nodes);
}
llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
return llvm::None;
}
SmallVector<BoundNodes, 1> Nodes;
};
}
@@ -144,6 +144,7 @@ using TypeMatcher = internal::Matcher<QualType>;
using TypeLocMatcher = internal::Matcher<TypeLoc>;
using NestedNameSpecifierMatcher = internal::Matcher<NestedNameSpecifier>;
using NestedNameSpecifierLocMatcher = internal::Matcher<NestedNameSpecifierLoc>;
using CXXBaseSpecifierMatcher = internal::Matcher<CXXBaseSpecifier>;
using CXXCtorInitializerMatcher = internal::Matcher<CXXCtorInitializer>;
using TemplateArgumentMatcher = internal::Matcher<TemplateArgument>;
using TemplateArgumentLocMatcher = internal::Matcher<TemplateArgumentLoc>;
@@ -347,6 +348,16 @@ extern const internal::VariadicAllOfMatcher<Decl> decl;
extern const internal::VariadicDynCastAllOfMatcher<Decl, DecompositionDecl>
decompositionDecl;
/// Matches binding declarations
/// Example matches \c foo and \c bar
/// (matcher = bindingDecl()
///
/// \code
/// auto [foo, bar] = std::make_pair{42, 42};
/// \endcode
extern const internal::VariadicDynCastAllOfMatcher<Decl, BindingDecl>
bindingDecl;
/// Matches a declaration of a linkage specification.
///
/// Given
@@ -506,6 +517,15 @@ extern const internal::VariadicDynCastAllOfMatcher<Decl, ParmVarDecl>
extern const internal::VariadicDynCastAllOfMatcher<Decl, AccessSpecDecl>
accessSpecDecl;
/// Matches class bases.
///
/// Examples matches \c public virtual B.
/// \code
/// class B {};
/// class C : public virtual B {};
/// \endcode
extern const internal::VariadicAllOfMatcher<CXXBaseSpecifier> cxxBaseSpecifier;
/// Matches constructor initializers.
///
/// Examples matches \c i(42).
@@ -825,26 +845,16 @@ traverse(TraversalKind TK, const internal::ArgumentAdaptingMatcherFuncAdaptor<
ToTypes>>(TK, InnerMatcher);
}
template <template <typename T, typename P1> class MatcherT, typename P1,
template <template <typename T, typename... P> class MatcherT, typename... P,
typename ReturnTypesF>
internal::TraversalWrapper<
internal::PolymorphicMatcherWithParam1<MatcherT, P1, ReturnTypesF>>
traverse(TraversalKind TK, const internal::PolymorphicMatcherWithParam1<
MatcherT, P1, ReturnTypesF> &InnerMatcher) {
internal::PolymorphicMatcher<MatcherT, ReturnTypesF, P...>>
traverse(TraversalKind TK,
const internal::PolymorphicMatcher<MatcherT, ReturnTypesF, P...>
&InnerMatcher) {
return internal::TraversalWrapper<
internal::PolymorphicMatcherWithParam1<MatcherT, P1, ReturnTypesF>>(
TK, InnerMatcher);
}
template <template <typename T, typename P1, typename P2> class MatcherT,
typename P1, typename P2, typename ReturnTypesF>
internal::TraversalWrapper<
internal::PolymorphicMatcherWithParam2<MatcherT, P1, P2, ReturnTypesF>>
traverse(TraversalKind TK, const internal::PolymorphicMatcherWithParam2<
MatcherT, P1, P2, ReturnTypesF> &InnerMatcher) {
return internal::TraversalWrapper<
internal::PolymorphicMatcherWithParam2<MatcherT, P1, P2, ReturnTypesF>>(
TK, InnerMatcher);
internal::PolymorphicMatcher<MatcherT, ReturnTypesF, P...>>(TK,
InnerMatcher);
}
template <typename... T>
@@ -903,7 +913,7 @@ AST_MATCHER_P(Expr, ignoringImplicit, internal::Matcher<Expr>,
/// varDecl(hasInitializer(integerLiteral()))
/// varDecl(hasInitializer(declRefExpr()))
/// \endcode
/// only match the declarations for b, c, and d.
/// only match the declarations for a.
AST_MATCHER_P(Expr, ignoringImpCasts,
internal::Matcher<Expr>, InnerMatcher) {
return InnerMatcher.matches(*Node.IgnoreImpCasts(), Finder, Builder);
@@ -1203,7 +1213,7 @@ AST_MATCHER_P(TemplateArgument, equalsIntegralValue,
std::string, Value) {
if (Node.getKind() != TemplateArgument::Integral)
return false;
return Node.getAsIntegral().toString(10) == Value;
return toString(Node.getAsIntegral(), 10) == Value;
}
/// Matches an Objective-C autorelease pool statement.
@@ -1742,6 +1752,18 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt,
/// matches \code using X::x \endcode
extern const internal::VariadicDynCastAllOfMatcher<Decl, UsingDecl> usingDecl;
/// Matches using-enum declarations.
///
/// Given
/// \code
/// namespace X { enum x {...}; }
/// using enum X::x;
/// \endcode
/// usingEnumDecl()
/// matches \code using enum X::x \endcode
extern const internal::VariadicDynCastAllOfMatcher<Decl, UsingEnumDecl>
usingEnumDecl;
/// Matches using namespace declarations.
///
/// Given
@@ -2162,6 +2184,17 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, BreakStmt> breakStmt;
extern const internal::VariadicDynCastAllOfMatcher<Stmt, ContinueStmt>
continueStmt;
/// Matches co_return statements.
///
/// Given
/// \code
/// while (true) { co_return; }
/// \endcode
/// coreturnStmt()
/// matches 'co_return'
extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoreturnStmt>
coreturnStmt;
/// Matches return statements.
///
/// Given
@@ -2379,6 +2412,30 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, UserDefinedLiteral>
extern const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundLiteralExpr>
compoundLiteralExpr;
/// Matches co_await expressions.
///
/// Given
/// \code
/// co_await 1;
/// \endcode
/// coawaitExpr()
/// matches 'co_await 1'
extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoawaitExpr>
coawaitExpr;
/// Matches co_await expressions where the type of the promise is dependent
extern const internal::VariadicDynCastAllOfMatcher<Stmt, DependentCoawaitExpr>
dependentCoawaitExpr;
/// Matches co_yield expressions.
///
/// Given
/// \code
/// co_yield 1;
/// \endcode
/// coyieldExpr()
/// matches 'co_yield 1'
extern const internal::VariadicDynCastAllOfMatcher<Stmt, CoyieldExpr>
coyieldExpr;
/// Matches nullptr literal.
extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNullPtrLiteralExpr>
cxxNullPtrLiteralExpr;
@@ -2829,6 +2886,42 @@ extern const internal::MapAnyOfMatcher<BinaryOperator, CXXOperatorCallExpr,
CXXRewrittenBinaryOperator>
binaryOperation;
/// Matches function calls and constructor calls
///
/// Because CallExpr and CXXConstructExpr do not share a common
/// base class with API accessing arguments etc, AST Matchers for code
/// which should match both are typically duplicated. This matcher
/// removes the need for duplication.
///
/// Given code
/// \code
/// struct ConstructorTakesInt
/// {
/// ConstructorTakesInt(int i) {}
/// };
///
/// void callTakesInt(int i)
/// {
/// }
///
/// void doCall()
/// {
/// callTakesInt(42);
/// }
///
/// void doConstruct()
/// {
/// ConstructorTakesInt cti(42);
/// }
/// \endcode
///
/// The matcher
/// \code
/// invocation(hasArgument(0, integerLiteral(equals(42))))
/// \endcode
/// matches the expression in both doCall and doConstruct
extern const internal::MapAnyOfMatcher<CallExpr, CXXConstructExpr> invocation;
/// Matches unary expressions that have a specific type of argument.
///
/// Given
@@ -2950,14 +3043,15 @@ AST_MATCHER_REGEX(NamedDecl, matchesName, RegExp) {
/// matches the declaration of \c A.
///
/// Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>
inline internal::PolymorphicMatcherWithParam1<
internal::HasOverloadedOperatorNameMatcher, std::vector<std::string>,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>
inline internal::PolymorphicMatcher<
internal::HasOverloadedOperatorNameMatcher,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl),
std::vector<std::string>>
hasOverloadedOperatorName(StringRef Name) {
return internal::PolymorphicMatcherWithParam1<
internal::HasOverloadedOperatorNameMatcher, std::vector<std::string>,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>(
{std::string(Name)});
return internal::PolymorphicMatcher<
internal::HasOverloadedOperatorNameMatcher,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl),
std::vector<std::string>>({std::string(Name)});
}
/// Matches overloaded operator names.
@@ -2969,9 +3063,10 @@ hasOverloadedOperatorName(StringRef Name) {
/// Is equivalent to
/// anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
extern const internal::VariadicFunction<
internal::PolymorphicMatcherWithParam1<
internal::HasOverloadedOperatorNameMatcher, std::vector<std::string>,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>,
internal::PolymorphicMatcher<internal::HasOverloadedOperatorNameMatcher,
AST_POLYMORPHIC_SUPPORTED_TYPES(
CXXOperatorCallExpr, FunctionDecl),
std::vector<std::string>>,
StringRef, internal::hasAnyOverloadedOperatorNameFunc>
hasAnyOverloadedOperatorName;
@@ -3460,13 +3555,14 @@ extern const internal::VariadicOperatorMatcherFunc<1, 1> unless;
/// Matcher<TagType>, Matcher<TemplateSpecializationType>,
/// Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
/// Matcher<UnresolvedUsingType>
inline internal::PolymorphicMatcherWithParam1<
internal::HasDeclarationMatcher, internal::Matcher<Decl>,
void(internal::HasDeclarationSupportedTypes)>
inline internal::PolymorphicMatcher<
internal::HasDeclarationMatcher,
void(internal::HasDeclarationSupportedTypes), internal::Matcher<Decl>>
hasDeclaration(const internal::Matcher<Decl> &InnerMatcher) {
return internal::PolymorphicMatcherWithParam1<
internal::HasDeclarationMatcher, internal::Matcher<Decl>,
void(internal::HasDeclarationSupportedTypes)>(InnerMatcher);
return internal::PolymorphicMatcher<
internal::HasDeclarationMatcher,
void(internal::HasDeclarationSupportedTypes), internal::Matcher<Decl>>(
InnerMatcher);
}
/// Matches a \c NamedDecl whose underlying declaration matches the given
@@ -3751,16 +3847,19 @@ AST_MATCHER_P_OVERLOAD(CallExpr, callee, internal::Matcher<Decl>, InnerMatcher,
/// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
/// and U (matcher = typedefDecl(hasType(asString("int")))
/// and friend class X (matcher = friendDecl(hasType("X"))
/// and public virtual X (matcher = cxxBaseSpecifier(hasType(
/// asString("class X")))
/// \code
/// class X {};
/// void y(X &x) { x; X z; }
/// typedef int U;
/// class Y { friend class X; };
/// class Z : public virtual X {};
/// \endcode
AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
hasType,
AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, TypedefNameDecl,
ValueDecl),
ValueDecl, CXXBaseSpecifier),
internal::Matcher<QualType>, InnerMatcher, 0) {
QualType QT = internal::getUnderlyingType(Node);
if (!QT.isNull())
@@ -3780,10 +3879,13 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
/// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
/// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
/// and friend class X (matcher = friendDecl(hasType("X"))
/// and public virtual X (matcher = cxxBaseSpecifier(hasType(
/// cxxRecordDecl(hasName("X"))))
/// \code
/// class X {};
/// void y(X &x) { x; X z; }
/// class Y { friend class X; };
/// class Z : public virtual X {};
/// \endcode
///
/// Example matches class Derived
@@ -3806,20 +3908,51 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
return false;
}
/// Matches if the type location of the declarator decl's type matches
/// the inner matcher.
/// Matches if the type location of a node matches the inner matcher.
///
/// Given
/// Examples:
/// \code
/// int x;
/// \endcode
/// declaratorDecl(hasTypeLoc(loc(asString("int"))))
/// matches int x
AST_MATCHER_P(DeclaratorDecl, hasTypeLoc, internal::Matcher<TypeLoc>, Inner) {
if (!Node.getTypeSourceInfo())
///
/// \code
/// auto x = int(3);
/// \code
/// cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
/// matches int(3)
///
/// \code
/// struct Foo { Foo(int, int); };
/// auto x = Foo(1, 2);
/// \code
/// cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
/// matches Foo(1, 2)
///
/// Usable as: Matcher<BlockDecl>, Matcher<CXXBaseSpecifier>,
/// Matcher<CXXCtorInitializer>, Matcher<CXXFunctionalCastExpr>,
/// Matcher<CXXNewExpr>, Matcher<CXXTemporaryObjectExpr>,
/// Matcher<CXXUnresolvedConstructExpr>,
/// Matcher<ClassTemplateSpecializationDecl>, Matcher<CompoundLiteralExpr>,
/// Matcher<DeclaratorDecl>, Matcher<ExplicitCastExpr>,
/// Matcher<ObjCPropertyDecl>, Matcher<TemplateArgumentLoc>,
/// Matcher<TypedefNameDecl>
AST_POLYMORPHIC_MATCHER_P(
hasTypeLoc,
AST_POLYMORPHIC_SUPPORTED_TYPES(
BlockDecl, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr,
CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr,
ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl,
ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc,
TypedefNameDecl),
internal::Matcher<TypeLoc>, Inner) {
TypeSourceInfo *source = internal::GetTypeSourceInfo(Node);
if (source == nullptr) {
// This happens for example for implicit destructors.
return false;
return Inner.matches(Node.getTypeSourceInfo()->getTypeLoc(), Finder, Builder);
}
return Inner.matches(source->getTypeLoc(), Finder, Builder);
}
/// Matches if the matched type is represented by the given string.
@@ -4667,8 +4800,11 @@ AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParamType,
int ParamIndex = 0;
bool Matched = false;
unsigned NumArgs = Node.getNumArgs();
if (FProto && FProto->isVariadic())
NumArgs = std::min(NumArgs, FProto->getNumParams());
for (; ArgIndex < Node.getNumArgs(); ++ArgIndex, ++ParamIndex) {
for (; ArgIndex < NumArgs; ++ArgIndex, ++ParamIndex) {
BoundNodesTreeBuilder ArgMatches(*Builder);
if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()), Finder,
&ArgMatches)) {
@@ -5178,7 +5314,7 @@ AST_POLYMORPHIC_MATCHER_P(hasBody,
/// void f() {}
/// void g();
/// \endcode
/// hasAnyBody(functionDecl())
/// functionDecl(hasAnyBody(compoundStmt()))
/// matches both 'void f();'
/// and 'void f() {}'
/// with compoundStmt()
@@ -5253,11 +5389,12 @@ AST_MATCHER_P(CompoundStmt, statementCountIs, unsigned, N) {
/// Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
/// Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
template <typename ValueT>
internal::PolymorphicMatcherWithParam1<internal::ValueEqualsMatcher, ValueT>
internal::PolymorphicMatcher<internal::ValueEqualsMatcher,
void(internal::AllNodeBaseTypes), ValueT>
equals(const ValueT &Value) {
return internal::PolymorphicMatcherWithParam1<
internal::ValueEqualsMatcher,
ValueT>(Value);
return internal::PolymorphicMatcher<internal::ValueEqualsMatcher,
void(internal::AllNodeBaseTypes), ValueT>(
Value);
}
AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals,
@@ -5312,11 +5449,11 @@ AST_POLYMORPHIC_MATCHER_P(
/// Is equivalent to
/// anyOf(hasOperatorName("+"), hasOperatorName("-"))
extern const internal::VariadicFunction<
internal::PolymorphicMatcherWithParam1<
internal::HasAnyOperatorNameMatcher, std::vector<std::string>,
AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr,
CXXRewrittenBinaryOperator,
UnaryOperator)>,
internal::PolymorphicMatcher<internal::HasAnyOperatorNameMatcher,
AST_POLYMORPHIC_SUPPORTED_TYPES(
BinaryOperator, CXXOperatorCallExpr,
CXXRewrittenBinaryOperator, UnaryOperator),
std::vector<std::string>>,
StringRef, internal::hasAnyOperatorNameFunc>
hasAnyOperatorName;
@@ -6072,7 +6209,7 @@ AST_POLYMORPHIC_MATCHER_P(
/// \endcode
/// usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
/// matches \code using X::b \endcode
AST_MATCHER_P(UsingDecl, hasAnyUsingShadowDecl,
AST_MATCHER_P(BaseUsingDecl, hasAnyUsingShadowDecl,
internal::Matcher<UsingShadowDecl>, InnerMatcher) {
return matchesFirstInPointerRange(InnerMatcher, Node.shadow_begin(),
Node.shadow_end(), Finder,
@@ -7338,12 +7475,92 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr>
/// expr(nullPointerConstant())
/// matches the initializer for v1, v2, v3, cp, and ip. Does not match the
/// initializer for i.
AST_MATCHER(Expr, nullPointerConstant) {
return Node.isNullPointerConstant(Finder->getASTContext(),
Expr::NPC_ValueDependentIsNull);
AST_MATCHER_FUNCTION(internal::Matcher<Expr>, nullPointerConstant) {
return anyOf(
gnuNullExpr(), cxxNullPtrLiteralExpr(),
integerLiteral(equals(0), hasParent(expr(hasType(pointerType())))));
}
/// Matches declaration of the function the statement belongs to
/// Matches the DecompositionDecl the binding belongs to.
///
/// For example, in:
/// \code
/// void foo()
/// {
/// int arr[3];
/// auto &[f, s, t] = arr;
///
/// f = 42;
/// }
/// \endcode
/// The matcher:
/// \code
/// bindingDecl(hasName("f"),
/// forDecomposition(decompositionDecl())
/// \endcode
/// matches 'f' in 'auto &[f, s, t]'.
AST_MATCHER_P(BindingDecl, forDecomposition, internal::Matcher<ValueDecl>,
InnerMatcher) {
if (const ValueDecl *VD = Node.getDecomposedDecl())
return InnerMatcher.matches(*VD, Finder, Builder);
return false;
}
/// Matches the Nth binding of a DecompositionDecl.
///
/// For example, in:
/// \code
/// void foo()
/// {
/// int arr[3];
/// auto &[f, s, t] = arr;
///
/// f = 42;
/// }
/// \endcode
/// The matcher:
/// \code
/// decompositionDecl(hasBinding(0,
/// bindingDecl(hasName("f").bind("fBinding"))))
/// \endcode
/// matches the decomposition decl with 'f' bound to "fBinding".
AST_MATCHER_P2(DecompositionDecl, hasBinding, unsigned, N,
internal::Matcher<BindingDecl>, InnerMatcher) {
if (Node.bindings().size() <= N)
return false;
return InnerMatcher.matches(*Node.bindings()[N], Finder, Builder);
}
/// Matches any binding of a DecompositionDecl.
///
/// For example, in:
/// \code
/// void foo()
/// {
/// int arr[3];
/// auto &[f, s, t] = arr;
///
/// f = 42;
/// }
/// \endcode
/// The matcher:
/// \code
/// decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding"))))
/// \endcode
/// matches the decomposition decl with 'f' bound to "fBinding".
AST_MATCHER_P(DecompositionDecl, hasAnyBinding, internal::Matcher<BindingDecl>,
InnerMatcher) {
return llvm::any_of(Node.bindings(), [&](const auto *Binding) {
return InnerMatcher.matches(*Binding, Finder, Builder);
});
}
/// Matches declaration of the function the statement belongs to.
///
/// Deprecated. Use forCallable() to correctly handle the situation when
/// the declaration is not a function (but a block or an Objective-C method).
/// forFunction() not only fails to take non-functions into account but also
/// may match the wrong declaration in their presence.
///
/// Given:
/// \code
@@ -7360,20 +7577,79 @@ AST_MATCHER_P(Stmt, forFunction, internal::Matcher<FunctionDecl>,
const auto &Parents = Finder->getASTContext().getParents(Node);
llvm::SmallVector<DynTypedNode, 8> Stack(Parents.begin(), Parents.end());
while(!Stack.empty()) {
while (!Stack.empty()) {
const auto &CurNode = Stack.back();
Stack.pop_back();
if(const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) {
if(InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
if (const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) {
if (InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
return true;
}
} else if(const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) {
if(InnerMatcher.matches(*LambdaExprNode->getCallOperator(),
Finder, Builder)) {
} else if (const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) {
if (InnerMatcher.matches(*LambdaExprNode->getCallOperator(), Finder,
Builder)) {
return true;
}
} else {
for(const auto &Parent: Finder->getASTContext().getParents(CurNode))
for (const auto &Parent : Finder->getASTContext().getParents(CurNode))
Stack.push_back(Parent);
}
}
return false;
}
/// Matches declaration of the function, method, or block the statement
/// belongs to.
///
/// Given:
/// \code
/// F& operator=(const F& o) {
/// std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
/// return *this;
/// }
/// \endcode
/// returnStmt(forCallable(functionDecl(hasName("operator="))))
/// matches 'return *this'
/// but does not match 'return v > 0'
///
/// Given:
/// \code
/// -(void) foo {
/// int x = 1;
/// dispatch_sync(queue, ^{ int y = 2; });
/// }
/// \endcode
/// declStmt(forCallable(objcMethodDecl()))
/// matches 'int x = 1'
/// but does not match 'int y = 2'.
/// whereas declStmt(forCallable(blockDecl()))
/// matches 'int y = 2'
/// but does not match 'int x = 1'.
AST_MATCHER_P(Stmt, forCallable, internal::Matcher<Decl>, InnerMatcher) {
const auto &Parents = Finder->getASTContext().getParents(Node);
llvm::SmallVector<DynTypedNode, 8> Stack(Parents.begin(), Parents.end());
while (!Stack.empty()) {
const auto &CurNode = Stack.back();
Stack.pop_back();
if (const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) {
if (InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
return true;
}
} else if (const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) {
if (InnerMatcher.matches(*LambdaExprNode->getCallOperator(), Finder,
Builder)) {
return true;
}
} else if (const auto *ObjCMethodDeclNode = CurNode.get<ObjCMethodDecl>()) {
if (InnerMatcher.matches(*ObjCMethodDeclNode, Finder, Builder)) {
return true;
}
} else if (const auto *BlockDeclNode = CurNode.get<BlockDecl>()) {
if (InnerMatcher.matches(*BlockDeclNode, Finder, Builder)) {
return true;
}
} else {
for (const auto &Parent : Finder->getASTContext().getParents(CurNode))
Stack.push_back(Parent);
}
}
@@ -83,6 +83,37 @@ class BoundNodes;
namespace internal {
/// A type-list implementation.
///
/// A "linked list" of types, accessible by using the ::head and ::tail
/// typedefs.
template <typename... Ts> struct TypeList {}; // Empty sentinel type list.
template <typename T1, typename... Ts> struct TypeList<T1, Ts...> {
/// The first type on the list.
using head = T1;
/// A sublist with the tail. ie everything but the head.
///
/// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the
/// end of the list.
using tail = TypeList<Ts...>;
};
/// The empty type list.
using EmptyTypeList = TypeList<>;
/// Helper meta-function to determine if some type \c T is present or
/// a parent type in the list.
template <typename AnyTypeList, typename T> struct TypeListContainsSuperOf {
static const bool value =
std::is_base_of<typename AnyTypeList::head, T>::value ||
TypeListContainsSuperOf<typename AnyTypeList::tail, T>::value;
};
template <typename T> struct TypeListContainsSuperOf<EmptyTypeList, T> {
static const bool value = false;
};
/// Variadic function object.
///
/// Most of the functions below that use VariadicFunction could be implemented
@@ -135,6 +166,35 @@ inline QualType getUnderlyingType(const CXXBaseSpecifier &Node) {
return Node.getType();
}
/// Unifies obtaining a `TypeSourceInfo` from different node types.
template <typename T,
std::enable_if_t<TypeListContainsSuperOf<
TypeList<CXXBaseSpecifier, CXXCtorInitializer,
CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr,
CompoundLiteralExpr, DeclaratorDecl, ObjCPropertyDecl,
TemplateArgumentLoc, TypedefNameDecl>,
T>::value> * = nullptr>
inline TypeSourceInfo *GetTypeSourceInfo(const T &Node) {
return Node.getTypeSourceInfo();
}
template <typename T,
std::enable_if_t<TypeListContainsSuperOf<
TypeList<CXXFunctionalCastExpr, ExplicitCastExpr>, T>::value> * =
nullptr>
inline TypeSourceInfo *GetTypeSourceInfo(const T &Node) {
return Node.getTypeInfoAsWritten();
}
inline TypeSourceInfo *GetTypeSourceInfo(const BlockDecl &Node) {
return Node.getSignatureAsWritten();
}
inline TypeSourceInfo *GetTypeSourceInfo(const CXXNewExpr &Node) {
return Node.getAllocatedTypeSourceInfo();
}
inline TypeSourceInfo *
GetTypeSourceInfo(const ClassTemplateSpecializationDecl &Node) {
return Node.getTypeAsWritten();
}
/// Unifies obtaining the FunctionProtoType pointer from both
/// FunctionProtoType and FunctionDecl nodes..
inline const FunctionProtoType *
@@ -541,12 +601,18 @@ class Matcher {
/// Convert \c this into a \c Matcher<T> by applying dyn_cast<> to the
/// argument.
/// \c To must be a base class of \c T.
template <typename To>
Matcher<To> dynCastTo() const {
template <typename To> Matcher<To> dynCastTo() const LLVM_LVALUE_FUNCTION {
static_assert(std::is_base_of<To, T>::value, "Invalid dynCast call.");
return Matcher<To>(Implementation);
}
#if LLVM_HAS_RVALUE_REFERENCE_THIS
template <typename To> Matcher<To> dynCastTo() && {
static_assert(std::is_base_of<To, T>::value, "Invalid dynCast call.");
return Matcher<To>(std::move(Implementation));
}
#endif
/// Forwards the call to the underlying MatcherInterface<T> pointer.
bool matches(const T &Node,
ASTMatchFinder *Finder,
@@ -563,7 +629,13 @@ class Matcher {
///
/// The returned matcher keeps the same restrictions as \c this and remembers
/// that it is meant to support nodes of type \c T.
operator DynTypedMatcher() const { return Implementation; }
operator DynTypedMatcher() const LLVM_LVALUE_FUNCTION {
return Implementation;
}
#if LLVM_HAS_RVALUE_REFERENCE_THIS
operator DynTypedMatcher() && { return std::move(Implementation); }
#endif
/// Allows the conversion of a \c Matcher<Type> to a \c
/// Matcher<QualType>.
@@ -836,7 +908,7 @@ class has_getDecl {
/// Matches overloaded operators with a specific name.
///
/// The type argument ArgT is not used by this matcher but is used by
/// PolymorphicMatcherWithParam1 and should be StringRef.
/// PolymorphicMatcher and should be StringRef.
template <typename T, typename ArgT>
class HasOverloadedOperatorNameMatcher : public SingleNodeMatcherInterface<T> {
static_assert(std::is_same<T, CXXOperatorCallExpr>::value ||
@@ -870,7 +942,7 @@ class HasOverloadedOperatorNameMatcher : public SingleNodeMatcherInterface<T> {
Names, getOperatorSpelling(Node.getOverloadedOperator()));
}
const std::vector<std::string> Names;
std::vector<std::string> Names;
};
/// Matches named declarations with a specific name.
@@ -904,8 +976,8 @@ class HasNameMatcher : public SingleNodeMatcherInterface<NamedDecl> {
/// It is slower but simple and works on all cases.
bool matchesNodeFullSlow(const NamedDecl &Node) const;
const bool UseUnqualifiedMatch;
const std::vector<std::string> Names;
bool UseUnqualifiedMatch;
std::vector<std::string> Names;
};
/// Trampoline function to use VariadicFunction<> to construct a
@@ -919,14 +991,14 @@ Matcher<ObjCMessageExpr> hasAnySelectorFunc(
/// Matches declarations for QualType and CallExpr.
///
/// Type argument DeclMatcherT is required by PolymorphicMatcherWithParam1 but
/// Type argument DeclMatcherT is required by PolymorphicMatcher but
/// not actually used.
template <typename T, typename DeclMatcherT>
class HasDeclarationMatcher : public MatcherInterface<T> {
static_assert(std::is_same<DeclMatcherT, Matcher<Decl>>::value,
"instantiated with wrong types");
const DynTypedMatcher InnerMatcher;
DynTypedMatcher InnerMatcher;
public:
explicit HasDeclarationMatcher(const Matcher<Decl> &InnerMatcher)
@@ -1108,39 +1180,6 @@ struct IsBaseType {
template <typename T>
const bool IsBaseType<T>::value;
/// A type-list implementation.
///
/// A "linked list" of types, accessible by using the ::head and ::tail
/// typedefs.
template <typename... Ts> struct TypeList {}; // Empty sentinel type list.
template <typename T1, typename... Ts> struct TypeList<T1, Ts...> {
/// The first type on the list.
using head = T1;
/// A sublist with the tail. ie everything but the head.
///
/// This type is used to do recursion. TypeList<>/EmptyTypeList indicates the
/// end of the list.
using tail = TypeList<Ts...>;
};
/// The empty type list.
using EmptyTypeList = TypeList<>;
/// Helper meta-function to determine if some type \c T is present or
/// a parent type in the list.
template <typename AnyTypeList, typename T>
struct TypeListContainsSuperOf {
static const bool value =
std::is_base_of<typename AnyTypeList::head, T>::value ||
TypeListContainsSuperOf<typename AnyTypeList::tail, T>::value;
};
template <typename T>
struct TypeListContainsSuperOf<EmptyTypeList, T> {
static const bool value = false;
};
/// A "type list" that contains all types.
///
/// Useful for matchers like \c anything and \c unless.
@@ -1157,6 +1196,18 @@ template <class T> struct ExtractFunctionArgMeta<void(T)> {
using type = T;
};
template <class T, class Tuple, std::size_t... I>
constexpr T *new_from_tuple_impl(Tuple &&t, std::index_sequence<I...>) {
return new T(std::get<I>(std::forward<Tuple>(t))...);
}
template <class T, class Tuple> constexpr T *new_from_tuple(Tuple &&t) {
return new_from_tuple_impl<T>(
std::forward<Tuple>(t),
std::make_index_sequence<
std::tuple_size<std::remove_reference_t<Tuple>>::value>{});
}
/// Default type lists for ArgumentAdaptingMatcher matchers.
using AdaptativeDefaultFromTypes = AllNodeBaseTypes;
using AdaptativeDefaultToTypes =
@@ -1303,20 +1354,36 @@ template <typename... Ps> class VariadicOperatorMatcher {
VariadicOperatorMatcher(DynTypedMatcher::VariadicOperator Op, Ps &&... Params)
: Op(Op), Params(std::forward<Ps>(Params)...) {}
template <typename T> operator Matcher<T>() const {
template <typename T> operator Matcher<T>() const LLVM_LVALUE_FUNCTION {
return DynTypedMatcher::constructVariadic(
Op, ASTNodeKind::getFromNodeKind<T>(),
getMatchers<T>(std::index_sequence_for<Ps...>()))
.template unconditionalConvertTo<T>();
}
#if LLVM_HAS_RVALUE_REFERENCE_THIS
template <typename T> operator Matcher<T>() && {
return DynTypedMatcher::constructVariadic(
Op, ASTNodeKind::getFromNodeKind<T>(),
getMatchers<T>(std::index_sequence_for<Ps...>()))
.template unconditionalConvertTo<T>();
}
#endif
private:
// Helper method to unpack the tuple into a vector.
template <typename T, std::size_t... Is>
std::vector<DynTypedMatcher> getMatchers(std::index_sequence<Is...>) const {
std::vector<DynTypedMatcher>
getMatchers(std::index_sequence<Is...>) const LLVM_LVALUE_FUNCTION {
return {Matcher<T>(std::get<Is>(Params))...};
}
#if LLVM_HAS_RVALUE_REFERENCE_THIS
template <typename T, std::size_t... Is>
std::vector<DynTypedMatcher> getMatchers(std::index_sequence<Is...>) && {
return {Matcher<T>(std::get<Is>(std::move(Params)))...};
}
#endif
const DynTypedMatcher::VariadicOperator Op;
std::tuple<Ps...> Params;
};
@@ -1374,8 +1441,7 @@ struct MapAnyOfMatcherImpl {
internal::DynTypedMatcher::VO_AnyOf},
applyMatcher(
[&](auto... Matcher) {
return std::make_tuple(Matcher(
std::forward<decltype(InnerMatcher)>(InnerMatcher)...)...);
return std::make_tuple(Matcher(InnerMatcher...)...);
},
std::tuple<
VariadicDynCastAllOfMatcher<CladeType, MatcherTypes>...>())));
@@ -1406,12 +1472,18 @@ class ArgumentAdaptingMatcherFuncAdaptor {
using ReturnTypes = ToTypes;
template <typename To> operator Matcher<To>() const {
template <typename To> operator Matcher<To>() const LLVM_LVALUE_FUNCTION {
return Matcher<To>(new ArgumentAdapterT<To, T>(InnerMatcher));
}
#if LLVM_HAS_RVALUE_REFERENCE_THIS
template <typename To> operator Matcher<To>() && {
return Matcher<To>(new ArgumentAdapterT<To, T>(std::move(InnerMatcher)));
}
#endif
private:
const Matcher<T> InnerMatcher;
Matcher<T> InnerMatcher;
};
/// Converts a \c Matcher<T> to a matcher of desired type \c To by
@@ -1426,7 +1498,7 @@ class ArgumentAdaptingMatcherFuncAdaptor {
/// \c HasMatcher<To, T>(InnerMatcher).
///
/// If a matcher does not need knowledge about the inner type, prefer to use
/// PolymorphicMatcherWithParam1.
/// PolymorphicMatcher.
template <template <typename ToArg, typename FromArg> class ArgumentAdapterT,
typename FromTypes = AdaptativeDefaultFromTypes,
typename ToTypes = AdaptativeDefaultToTypes>
@@ -1453,7 +1525,7 @@ struct ArgumentAdaptingMatcherFunc {
};
template <typename T> class TraversalMatcher : public MatcherInterface<T> {
const DynTypedMatcher InnerMatcher;
DynTypedMatcher InnerMatcher;
clang::TraversalKind Traversal;
public:
@@ -1479,85 +1551,64 @@ template <typename MatcherType> class TraversalWrapper {
TraversalWrapper(TraversalKind TK, const MatcherType &InnerMatcher)
: TK(TK), InnerMatcher(InnerMatcher) {}
template <typename T> operator Matcher<T>() const {
template <typename T> operator Matcher<T>() const LLVM_LVALUE_FUNCTION {
return internal::DynTypedMatcher::constructRestrictedWrapper(
new internal::TraversalMatcher<T>(TK, InnerMatcher),
ASTNodeKind::getFromNodeKind<T>())
.template unconditionalConvertTo<T>();
}
#if LLVM_HAS_RVALUE_REFERENCE_THIS
template <typename T> operator Matcher<T>() && {
return internal::DynTypedMatcher::constructRestrictedWrapper(
new internal::TraversalMatcher<T>(TK, std::move(InnerMatcher)),
ASTNodeKind::getFromNodeKind<T>())
.template unconditionalConvertTo<T>();
}
#endif
private:
TraversalKind TK;
MatcherType InnerMatcher;
};
/// A PolymorphicMatcherWithParamN<MatcherT, P1, ..., PN> object can be
/// A PolymorphicMatcher<MatcherT, P1, ..., PN> object can be
/// created from N parameters p1, ..., pN (of type P1, ..., PN) and
/// used as a Matcher<T> where a MatcherT<T, P1, ..., PN>(p1, ..., pN)
/// can be constructed.
///
/// For example:
/// - PolymorphicMatcherWithParam0<IsDefinitionMatcher>()
/// - PolymorphicMatcher<IsDefinitionMatcher>()
/// creates an object that can be used as a Matcher<T> for any type T
/// where an IsDefinitionMatcher<T>() can be constructed.
/// - PolymorphicMatcherWithParam1<ValueEqualsMatcher, int>(42)
/// - PolymorphicMatcher<ValueEqualsMatcher, int>(42)
/// creates an object that can be used as a Matcher<T> for any type T
/// where a ValueEqualsMatcher<T, int>(42) can be constructed.
template <template <typename T> class MatcherT,
typename ReturnTypesF = void(AllNodeBaseTypes)>
class PolymorphicMatcherWithParam0 {
template <template <typename T, typename... Params> class MatcherT,
typename ReturnTypesF, typename... ParamTypes>
class PolymorphicMatcher {
public:
using ReturnTypes = typename ExtractFunctionArgMeta<ReturnTypesF>::type;
template <typename T>
operator Matcher<T>() const {
static_assert(TypeListContainsSuperOf<ReturnTypes, T>::value,
"right polymorphic conversion");
return Matcher<T>(new MatcherT<T>());
}
};
template <template <typename T, typename P1> class MatcherT,
typename P1,
typename ReturnTypesF = void(AllNodeBaseTypes)>
class PolymorphicMatcherWithParam1 {
public:
explicit PolymorphicMatcherWithParam1(const P1 &Param1)
: Param1(Param1) {}
PolymorphicMatcher(const ParamTypes &... Params) : Params(Params...) {}
using ReturnTypes = typename ExtractFunctionArgMeta<ReturnTypesF>::type;
template <typename T>
operator Matcher<T>() const {
template <typename T> operator Matcher<T>() const LLVM_LVALUE_FUNCTION {
static_assert(TypeListContainsSuperOf<ReturnTypes, T>::value,
"right polymorphic conversion");
return Matcher<T>(new MatcherT<T, P1>(Param1));
return Matcher<T>(new_from_tuple<MatcherT<T, ParamTypes...>>(Params));
}
#if LLVM_HAS_RVALUE_REFERENCE_THIS
template <typename T> operator Matcher<T>() && {
static_assert(TypeListContainsSuperOf<ReturnTypes, T>::value,
"right polymorphic conversion");
return Matcher<T>(
new_from_tuple<MatcherT<T, ParamTypes...>>(std::move(Params)));
}
#endif
private:
const P1 Param1;
};
template <template <typename T, typename P1, typename P2> class MatcherT,
typename P1, typename P2,
typename ReturnTypesF = void(AllNodeBaseTypes)>
class PolymorphicMatcherWithParam2 {
public:
PolymorphicMatcherWithParam2(const P1 &Param1, const P2 &Param2)
: Param1(Param1), Param2(Param2) {}
using ReturnTypes = typename ExtractFunctionArgMeta<ReturnTypesF>::type;
template <typename T>
operator Matcher<T>() const {
static_assert(TypeListContainsSuperOf<ReturnTypes, T>::value,
"right polymorphic conversion");
return Matcher<T>(new MatcherT<T, P1, P2>(Param1, Param2));
}
private:
const P1 Param1;
const P2 Param2;
std::tuple<ParamTypes...> Params;
};
/// Matches nodes of type T that have child nodes of type ChildT for
@@ -1566,7 +1617,7 @@ class PolymorphicMatcherWithParam2 {
/// ChildT must be an AST base type.
template <typename T, typename ChildT>
class HasMatcher : public MatcherInterface<T> {
const DynTypedMatcher InnerMatcher;
DynTypedMatcher InnerMatcher;
public:
explicit HasMatcher(const Matcher<ChildT> &InnerMatcher)
@@ -1589,7 +1640,7 @@ class ForEachMatcher : public MatcherInterface<T> {
static_assert(IsBaseType<ChildT>::value,
"for each only accepts base type matcher");
const DynTypedMatcher InnerMatcher;
DynTypedMatcher InnerMatcher;
public:
explicit ForEachMatcher(const Matcher<ChildT> &InnerMatcher)
@@ -1619,7 +1670,7 @@ class HasDescendantMatcher : public MatcherInterface<T> {
static_assert(IsBaseType<DescendantT>::value,
"has descendant only accepts base type matcher");
const DynTypedMatcher DescendantMatcher;
DynTypedMatcher DescendantMatcher;
public:
explicit HasDescendantMatcher(const Matcher<DescendantT> &DescendantMatcher)
@@ -1641,7 +1692,7 @@ class HasParentMatcher : public MatcherInterface<T> {
static_assert(IsBaseType<ParentT>::value,
"has parent only accepts base type matcher");
const DynTypedMatcher ParentMatcher;
DynTypedMatcher ParentMatcher;
public:
explicit HasParentMatcher(const Matcher<ParentT> &ParentMatcher)
@@ -1663,7 +1714,7 @@ class HasAncestorMatcher : public MatcherInterface<T> {
static_assert(IsBaseType<AncestorT>::value,
"has ancestor only accepts base type matcher");
const DynTypedMatcher AncestorMatcher;
DynTypedMatcher AncestorMatcher;
public:
explicit HasAncestorMatcher(const Matcher<AncestorT> &AncestorMatcher)
@@ -1687,7 +1738,7 @@ class ForEachDescendantMatcher : public MatcherInterface<T> {
static_assert(IsBaseType<DescendantT>::value,
"for each descendant only accepts base type matcher");
const DynTypedMatcher DescendantMatcher;
DynTypedMatcher DescendantMatcher;
public:
explicit ForEachDescendantMatcher(
@@ -1720,7 +1771,7 @@ class ValueEqualsMatcher : public SingleNodeMatcherInterface<T> {
}
private:
const ValueT ExpectedValue;
ValueT ExpectedValue;
};
/// Template specializations to easily write matchers for floating point
@@ -1753,7 +1804,7 @@ inline bool ValueEqualsMatcher<FloatingLiteral, llvm::APFloat>::matchesNode(
/// \c Matcher<T> matches.
template <typename TLoc, typename T>
class LocMatcher : public MatcherInterface<TLoc> {
const DynTypedMatcher InnerMatcher;
DynTypedMatcher InnerMatcher;
public:
explicit LocMatcher(const Matcher<T> &InnerMatcher)
@@ -1777,7 +1828,7 @@ class LocMatcher : public MatcherInterface<TLoc> {
///
/// Used to implement the \c loc() matcher.
class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> {
const DynTypedMatcher InnerMatcher;
DynTypedMatcher InnerMatcher;
public:
explicit TypeLocTypeMatcher(const Matcher<QualType> &InnerMatcher)
@@ -1796,7 +1847,7 @@ class TypeLocTypeMatcher : public MatcherInterface<TypeLoc> {
/// another node of type \c T that can be reached using a given traverse
/// function.
template <typename T> class TypeTraverseMatcher : public MatcherInterface<T> {
const DynTypedMatcher InnerMatcher;
DynTypedMatcher InnerMatcher;
public:
explicit TypeTraverseMatcher(const Matcher<QualType> &InnerMatcher,
@@ -1821,7 +1872,7 @@ template <typename T> class TypeTraverseMatcher : public MatcherInterface<T> {
/// given traverse function.
template <typename T>
class TypeLocTraverseMatcher : public MatcherInterface<T> {
const DynTypedMatcher InnerMatcher;
DynTypedMatcher InnerMatcher;
public:
explicit TypeLocTraverseMatcher(const Matcher<TypeLoc> &InnerMatcher,
@@ -1876,7 +1927,7 @@ class TypeTraversePolymorphicMatcher {
};
private:
const Matcher<InnerTBase> InnerMatcher;
Matcher<InnerTBase> InnerMatcher;
};
/// A simple memoizer of T(*)() functions.
@@ -2039,7 +2090,8 @@ equivalentUnaryOperator(const NodeType &Node) {
template <>
inline Optional<UnaryOperatorKind>
equivalentUnaryOperator<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
if (Node.getNumArgs() != 1)
if (Node.getNumArgs() != 1 && Node.getOperator() != OO_PlusPlus &&
Node.getOperator() != OO_MinusMinus)
return None;
switch (Node.getOperator()) {
default:
@@ -2050,6 +2102,8 @@ equivalentUnaryOperator<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
return UO_Minus;
case OO_Amp:
return UO_AddrOf;
case OO_Star:
return UO_Deref;
case OO_Tilde:
return UO_Not;
case OO_Exclaim:
@@ -2173,7 +2227,7 @@ inline Optional<StringRef> getOpName(const CXXOperatorCallExpr &Node) {
/// Matches overloaded operators with a specific name.
///
/// The type argument ArgT is not used by this matcher but is used by
/// PolymorphicMatcherWithParam1 and should be std::vector<std::string>>.
/// PolymorphicMatcher and should be std::vector<std::string>>.
template <typename T, typename ArgT = std::vector<std::string>>
class HasAnyOperatorNameMatcher : public SingleNodeMatcherInterface<T> {
static_assert(std::is_same<T, BinaryOperator>::value ||
@@ -2219,19 +2273,22 @@ class HasAnyOperatorNameMatcher : public SingleNodeMatcherInterface<T> {
return BinaryOperator::getOpcodeStr(*optBinaryOpcode);
}
const std::vector<std::string> Names;
std::vector<std::string> Names;
};
using HasOpNameMatcher = PolymorphicMatcherWithParam1<
HasAnyOperatorNameMatcher, std::vector<std::string>,
void(TypeList<BinaryOperator, CXXOperatorCallExpr,
CXXRewrittenBinaryOperator, UnaryOperator>)>;
using HasOpNameMatcher =
PolymorphicMatcher<HasAnyOperatorNameMatcher,
void(
TypeList<BinaryOperator, CXXOperatorCallExpr,
CXXRewrittenBinaryOperator, UnaryOperator>),
std::vector<std::string>>;
HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef<const StringRef *> NameRefs);
using HasOverloadOpNameMatcher = PolymorphicMatcherWithParam1<
HasOverloadedOperatorNameMatcher, std::vector<std::string>,
void(TypeList<CXXOperatorCallExpr, FunctionDecl>)>;
using HasOverloadOpNameMatcher =
PolymorphicMatcher<HasOverloadedOperatorNameMatcher,
void(TypeList<CXXOperatorCallExpr, FunctionDecl>),
std::vector<std::string>>;
HasOverloadOpNameMatcher
hasAnyOverloadedOperatorNameFunc(ArrayRef<const StringRef *> NameRefs);
@@ -143,7 +143,7 @@
*Builder) const override; \
\
private: \
ParamType const Param; \
ParamType Param; \
}; \
} \
inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \
@@ -151,7 +151,7 @@
return ::clang::ast_matchers::internal::makeMatcher( \
new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param)); \
} \
typedef ::clang::ast_matchers::internal::Matcher<Type>( \
typedef ::clang::ast_matchers::internal::Matcher<Type> ( \
&DefineMatcher##_Type##OverloadId)(ParamType const &Param); \
inline bool internal::matcher_##DefineMatcher##OverloadId##Matcher::matches( \
const Type &Node, \
@@ -192,8 +192,8 @@
*Builder) const override; \
\
private: \
ParamType1 const Param1; \
ParamType2 const Param2; \
ParamType1 Param1; \
ParamType2 Param2; \
}; \
} \
inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \
@@ -202,7 +202,7 @@
new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param1, \
Param2)); \
} \
typedef ::clang::ast_matchers::internal::Matcher<Type>( \
typedef ::clang::ast_matchers::internal::Matcher<Type> ( \
&DefineMatcher##_Type##OverloadId)(ParamType1 const &Param1, \
ParamType2 const &Param2); \
inline bool internal::matcher_##DefineMatcher##OverloadId##Matcher::matches( \
@@ -239,10 +239,10 @@
*Builder) const override; \
}; \
} \
inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam0< \
inline ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##Matcher, ReturnTypesF> \
DefineMatcher() { \
return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam0< \
return ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##Matcher, ReturnTypesF>(); \
} \
template <typename NodeType> \
@@ -281,21 +281,20 @@
*Builder) const override; \
\
private: \
ParamType const Param; \
ParamType Param; \
}; \
} \
inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \
ReturnTypesF> \
inline ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
ParamType> \
DefineMatcher(ParamType const &Param) { \
return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \
ReturnTypesF>(Param); \
return ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
ParamType>(Param); \
} \
typedef ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \
ReturnTypesF>(&DefineMatcher##_Type##OverloadId)( \
ParamType const &Param); \
typedef ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
ParamType> (&DefineMatcher##_Type##OverloadId)(ParamType const &Param); \
template <typename NodeType, typename ParamT> \
bool internal:: \
matcher_##DefineMatcher##OverloadId##Matcher<NodeType, ParamT>::matches( \
@@ -334,21 +333,21 @@
*Builder) const override; \
\
private: \
ParamType1 const Param1; \
ParamType2 const Param2; \
ParamType1 Param1; \
ParamType2 Param2; \
}; \
} \
inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam2< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1, \
ParamType2, ReturnTypesF> \
inline ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
ParamType1, ParamType2> \
DefineMatcher(ParamType1 const &Param1, ParamType2 const &Param2) { \
return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam2< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1, \
ParamType2, ReturnTypesF>(Param1, Param2); \
return ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
ParamType1, ParamType2>(Param1, Param2); \
} \
typedef ::clang::ast_matchers::internal::PolymorphicMatcherWithParam2< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1, \
ParamType2, ReturnTypesF>(&DefineMatcher##_Type##OverloadId)( \
typedef ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
ParamType1, ParamType2> (&DefineMatcher##_Type##OverloadId)( \
ParamType1 const &Param1, ParamType2 const &Param2); \
template <typename NodeType, typename ParamT1, typename ParamT2> \
bool internal::matcher_##DefineMatcher##OverloadId##Matcher< \
@@ -470,7 +469,7 @@
*Builder) const override; \
\
private: \
std::shared_ptr<llvm::Regex> const Param; \
std::shared_ptr<llvm::Regex> Param; \
}; \
} \
inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \
@@ -522,34 +521,34 @@
*Builder) const override; \
\
private: \
std::shared_ptr<llvm::Regex> const Param; \
std::shared_ptr<llvm::Regex> Param; \
}; \
} \
inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, \
std::shared_ptr<llvm::Regex>, ReturnTypesF> \
inline ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
std::shared_ptr<llvm::Regex>> \
DefineMatcher(llvm::StringRef Param, llvm::Regex::RegexFlags RegexFlags) { \
return ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, \
std::shared_ptr<llvm::Regex>, ReturnTypesF>( \
return ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
std::shared_ptr<llvm::Regex>>( \
::clang::ast_matchers::internal::createAndVerifyRegex( \
Param, RegexFlags, #DefineMatcher)); \
} \
inline ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, \
std::shared_ptr<llvm::Regex>, ReturnTypesF> \
inline ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
std::shared_ptr<llvm::Regex>> \
DefineMatcher(llvm::StringRef Param) { \
return DefineMatcher(Param, llvm::Regex::NoFlags); \
} \
typedef ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, \
std::shared_ptr<llvm::Regex>, ReturnTypesF> ( \
typedef ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
std::shared_ptr<llvm::Regex>> ( \
&DefineMatcher##_Type##OverloadId##Flags)( \
llvm::StringRef Param, llvm::Regex::RegexFlags RegexFlags); \
typedef ::clang::ast_matchers::internal::PolymorphicMatcherWithParam1< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, \
std::shared_ptr<llvm::Regex>, ReturnTypesF> ( \
&DefineMatcher##_Type##OverloadId)(llvm::StringRef Param); \
typedef ::clang::ast_matchers::internal::PolymorphicMatcher< \
internal::matcher_##DefineMatcher##OverloadId##Matcher, ReturnTypesF, \
std::shared_ptr<llvm::Regex>> (&DefineMatcher##_Type##OverloadId)( \
llvm::StringRef Param); \
template <typename NodeType, typename ParamT> \
bool internal:: \
matcher_##DefineMatcher##OverloadId##Matcher<NodeType, ParamT>::matches( \
@@ -66,6 +66,8 @@ class Diagnostics {
ET_RegistryAmbiguousOverload = 5,
ET_RegistryValueNotFound = 6,
ET_RegistryUnknownEnumWithReplace = 7,
ET_RegistryNonNodeMatcher = 8,
ET_RegistryMatcherNoWithSupport = 9,
ET_ParserStringError = 100,
ET_ParserNoOpenParen = 101,
@@ -77,7 +79,9 @@ class Diagnostics {
ET_ParserMalformedBindExpr = 107,
ET_ParserTrailingCode = 108,
ET_ParserNumberError = 109,
ET_ParserOverloadedType = 110
ET_ParserOverloadedType = 110,
ET_ParserMalformedChainedExpr = 111,
ET_ParserFailedToBuildMatcher = 112
};
/// Helper stream class.
@@ -100,6 +100,14 @@ class Parser {
virtual llvm::Optional<MatcherCtor>
lookupMatcherCtor(StringRef MatcherName) = 0;
virtual bool isBuilderMatcher(MatcherCtor) const = 0;
virtual ASTNodeKind nodeMatcherType(MatcherCtor) const = 0;
virtual internal::MatcherDescriptorPtr
buildMatcherCtor(MatcherCtor, SourceRange NameRange,
ArrayRef<ParserValue> Args, Diagnostics *Error) const = 0;
/// Compute the list of completion types for \p Context.
///
/// Each element of \p Context represents a matcher invocation, going from
@@ -142,6 +150,15 @@ class Parser {
std::vector<ArgKind> getAcceptedCompletionTypes(
llvm::ArrayRef<std::pair<MatcherCtor, unsigned>> Context) override;
bool isBuilderMatcher(MatcherCtor Ctor) const override;
ASTNodeKind nodeMatcherType(MatcherCtor) const override;
internal::MatcherDescriptorPtr
buildMatcherCtor(MatcherCtor, SourceRange NameRange,
ArrayRef<ParserValue> Args,
Diagnostics *Error) const override;
std::vector<MatcherCompletion>
getMatcherCompletions(llvm::ArrayRef<ArgKind> AcceptedTypes) override;
};
@@ -233,7 +250,11 @@ class Parser {
bool parseBindID(std::string &BindID);
bool parseExpressionImpl(VariantValue *Value);
bool parseMatcherBuilder(MatcherCtor Ctor, const TokenInfo &NameToken,
const TokenInfo &OpenToken, VariantValue *Value);
bool parseMatcherExpressionImpl(const TokenInfo &NameToken,
const TokenInfo &OpenToken,
llvm::Optional<MatcherCtor> Ctor,
VariantValue *Value);
bool parseIdentifierPrefixImpl(VariantValue *Value);
@@ -33,6 +33,23 @@ namespace internal {
class MatcherDescriptor;
/// A smart (owning) pointer for MatcherDescriptor. We can't use unique_ptr
/// because MatcherDescriptor is forward declared
class MatcherDescriptorPtr {
public:
explicit MatcherDescriptorPtr(MatcherDescriptor *);
~MatcherDescriptorPtr();
MatcherDescriptorPtr(MatcherDescriptorPtr &&) = default;
MatcherDescriptorPtr &operator=(MatcherDescriptorPtr &&) = default;
MatcherDescriptorPtr(const MatcherDescriptorPtr &) = delete;
MatcherDescriptorPtr &operator=(const MatcherDescriptorPtr &) = delete;
MatcherDescriptor *get() { return Ptr; }
private:
MatcherDescriptor *Ptr;
};
} // namespace internal
using MatcherCtor = const internal::MatcherDescriptor *;
@@ -66,6 +83,14 @@ class Registry {
public:
Registry() = delete;
static ASTNodeKind nodeMatcherType(MatcherCtor);
static bool isBuilderMatcher(MatcherCtor Ctor);
static internal::MatcherDescriptorPtr
buildMatcherCtor(MatcherCtor, SourceRange NameRange,
ArrayRef<ParserValue> Args, Diagnostics *Error);
/// Look up a matcher in the registry by name,
///
/// \return An opaque value which may be used to refer to the matcher
@@ -35,6 +35,7 @@ class ArgKind {
public:
enum Kind {
AK_Matcher,
AK_Node,
AK_Boolean,
AK_Double,
AK_Unsigned,
@@ -44,12 +45,22 @@ class ArgKind {
ArgKind(Kind K) : K(K) { assert(K != AK_Matcher); }
/// Constructor for matcher types.
ArgKind(ASTNodeKind MatcherKind) : K(AK_Matcher), MatcherKind(MatcherKind) {}
static ArgKind MakeMatcherArg(ASTNodeKind MatcherKind) {
return ArgKind{AK_Matcher, MatcherKind};
}
static ArgKind MakeNodeArg(ASTNodeKind MatcherKind) {
return ArgKind{AK_Node, MatcherKind};
}
Kind getArgKind() const { return K; }
ASTNodeKind getMatcherKind() const {
assert(K == AK_Matcher);
return MatcherKind;
return NodeKind;
}
ASTNodeKind getNodeKind() const {
assert(K == AK_Node);
return NodeKind;
}
/// Determines if this type can be converted to \p To.
@@ -61,8 +72,9 @@ class ArgKind {
bool isConvertibleTo(ArgKind To, unsigned *Specificity) const;
bool operator<(const ArgKind &Other) const {
if (K == AK_Matcher && Other.K == AK_Matcher)
return MatcherKind < Other.MatcherKind;
if ((K == AK_Matcher && Other.K == AK_Matcher) ||
(K == AK_Node && Other.K == AK_Node))
return NodeKind < Other.NodeKind;
return K < Other.K;
}
@@ -70,8 +82,9 @@ class ArgKind {
std::string asString() const;
private:
ArgKind(Kind K, ASTNodeKind NK) : K(K), NodeKind(NK) {}
Kind K;
ASTNodeKind MatcherKind;
ASTNodeKind NodeKind;
};
using ast_matchers::internal::DynTypedMatcher;
@@ -16,6 +16,7 @@
#include "clang/AST/Stmt.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "llvm/ADT/StringRef.h"
namespace clang {
namespace ast_matchers {
@@ -30,14 +31,55 @@ enum class GtestCmp {
Lt,
};
/// Matcher for gtest's ASSERT_... macros.
/// This enum indicates whether the mock method in the matched ON_CALL or
/// EXPECT_CALL macro has arguments. For example, `None` can be used to match
/// `ON_CALL(mock, TwoParamMethod)` whereas `Some` can be used to match
/// `ON_CALL(mock, TwoParamMethod(m1, m2))`.
enum class MockArgs {
None,
Some,
};
/// Matcher for gtest's ASSERT comparison macros including ASSERT_EQ, ASSERT_NE,
/// ASSERT_GE, ASSERT_GT, ASSERT_LE and ASSERT_LT.
internal::BindableMatcher<Stmt> gtestAssert(GtestCmp Cmp, StatementMatcher Left,
StatementMatcher Right);
/// Matcher for gtest's EXPECT_... macros.
/// Matcher for gtest's ASSERT_THAT macro.
internal::BindableMatcher<Stmt> gtestAssertThat(StatementMatcher Actual,
StatementMatcher Matcher);
/// Matcher for gtest's EXPECT comparison macros including EXPECT_EQ, EXPECT_NE,
/// EXPECT_GE, EXPECT_GT, EXPECT_LE and EXPECT_LT.
internal::BindableMatcher<Stmt> gtestExpect(GtestCmp Cmp, StatementMatcher Left,
StatementMatcher Right);
/// Matcher for gtest's EXPECT_THAT macro.
internal::BindableMatcher<Stmt> gtestExpectThat(StatementMatcher Actual,
StatementMatcher Matcher);
/// Matcher for gtest's EXPECT_CALL macro. `MockObject` matches the mock
/// object and `MockMethodName` is the name of the method invoked on the mock
/// object.
internal::BindableMatcher<Stmt> gtestExpectCall(StatementMatcher MockObject,
llvm::StringRef MockMethodName,
MockArgs Args);
/// Matcher for gtest's EXPECT_CALL macro. `MockCall` matches the whole mock
/// member method call. This API is more flexible but requires more knowledge of
/// the AST structure of EXPECT_CALL macros.
internal::BindableMatcher<Stmt> gtestExpectCall(StatementMatcher MockCall,
MockArgs Args);
/// Like the first `gtestExpectCall` overload but for `ON_CALL`.
internal::BindableMatcher<Stmt> gtestOnCall(StatementMatcher MockObject,
llvm::StringRef MockMethodName,
MockArgs Args);
/// Like the second `gtestExpectCall` overload but for `ON_CALL`.
internal::BindableMatcher<Stmt> gtestOnCall(StatementMatcher MockCall,
MockArgs Args);
} // namespace ast_matchers
} // namespace clang
@@ -17,6 +17,7 @@
namespace clang {
class AnalysisDeclContext;
class BlockDecl;
class CFG;
class Decl;
class DeclContext;
@@ -79,6 +80,7 @@ class CalledOnceCheckHandler {
/// the path containing the call and not containing the call. This helps us
/// to pinpoint a bad path for the user.
/// \param Parameter -- parameter that should be called once.
/// \param Function -- function declaration where the problem occured.
/// \param Where -- the least common ancestor statement.
/// \param Reason -- a reason describing the path without a call.
/// \param IsCalledDirectly -- true, if parameter actually gets called on
@@ -86,9 +88,22 @@ class CalledOnceCheckHandler {
/// collection, passed as a parameter, etc.).
/// \param IsCompletionHandler -- true, if parameter is a completion handler.
virtual void handleNeverCalled(const ParmVarDecl *Parameter,
const Stmt *Where, NeverCalledReason Reason,
const Decl *Function, const Stmt *Where,
NeverCalledReason Reason,
bool IsCalledDirectly,
bool IsCompletionHandler) {}
/// Called when the block is guaranteed to be called exactly once.
/// It means that we can be stricter with what we report on that block.
/// \param Block -- block declaration that is known to be called exactly once.
virtual void
handleBlockThatIsGuaranteedToBeCalledOnce(const BlockDecl *Block) {}
/// Called when the block has no guarantees about how many times it can get
/// called.
/// It means that we should be more lenient with reporting warnings in it.
/// \param Block -- block declaration in question.
virtual void handleBlockWithNoGuarantees(const BlockDecl *Block) {}
};
/// Check given CFG for 'called once' parameter violations.
@@ -200,6 +200,8 @@ class AnalysisDeclContext {
/// \returns Whether the root namespace of \p D is the \c std C++ namespace.
static bool isInStdNamespace(const Decl *D);
static std::string getFunctionName(const Decl *D);
private:
std::unique_ptr<ManagedAnalysis> &getAnalysisImpl(const void *tag);
@@ -107,8 +107,8 @@ class AnyCall {
}
/// If {@code E} is a generic call (to ObjC method /function/block/etc),
/// return a constructed {@code AnyCall} object. Return None otherwise.
/// If @c E is a generic call (to ObjC method /function/block/etc),
/// return a constructed @c AnyCall object. Return None otherwise.
static Optional<AnyCall> forExpr(const Expr *E) {
if (const auto *ME = dyn_cast<ObjCMessageExpr>(E)) {
return AnyCall(ME);
@@ -127,8 +127,8 @@ class AnyCall {
}
}
/// If {@code D} is a callable (Objective-C method or a function), return
/// a constructed {@code AnyCall} object. Return None otherwise.
/// If @c D is a callable (Objective-C method or a function), return
/// a constructed @c AnyCall object. Return None otherwise.
// FIXME: block support.
static Optional<AnyCall> forDecl(const Decl *D) {
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
@@ -186,7 +186,7 @@ class AnyCall {
}
/// \returns Function identifier if it is a named declaration,
/// {@code nullptr} otherwise.
/// @c nullptr otherwise.
const IdentifierInfo *getIdentifier() const {
if (const auto *ND = dyn_cast_or_null<NamedDecl>(D))
return ND->getIdentifier();
@@ -1307,6 +1307,12 @@ class CFG {
iterator nodes_begin() { return iterator(Blocks.begin()); }
iterator nodes_end() { return iterator(Blocks.end()); }
llvm::iterator_range<iterator> nodes() { return {begin(), end()}; }
llvm::iterator_range<const_iterator> const_nodes() const {
return {begin(), end()};
}
const_iterator nodes_begin() const { return const_iterator(Blocks.begin()); }
const_iterator nodes_end() const { return const_iterator(Blocks.end()); }
@@ -1315,6 +1321,13 @@ class CFG {
const_reverse_iterator rbegin() const { return Blocks.rbegin(); }
const_reverse_iterator rend() const { return Blocks.rend(); }
llvm::iterator_range<reverse_iterator> reverse_nodes() {
return {rbegin(), rend()};
}
llvm::iterator_range<const_reverse_iterator> const_reverse_nodes() const {
return {rbegin(), rend()};
}
CFGBlock & getEntry() { return *Entry; }
const CFGBlock & getEntry() const { return *Entry; }
CFGBlock & getExit() { return *Exit; }
@@ -1376,13 +1389,12 @@ class CFG {
// Member templates useful for various batch operations over CFGs.
//===--------------------------------------------------------------------===//
template <typename CALLBACK>
void VisitBlockStmts(CALLBACK& O) const {
template <typename Callback> void VisitBlockStmts(Callback &O) const {
for (const_iterator I = begin(), E = end(); I != E; ++I)
for (CFGBlock::const_iterator BI = (*I)->begin(), BE = (*I)->end();
BI != BE; ++BI) {
if (Optional<CFGStmt> stmt = BI->getAs<CFGStmt>())
O(const_cast<Stmt*>(stmt->getStmt()));
O(const_cast<Stmt *>(stmt->getStmt()));
}
}
@@ -19,13 +19,14 @@
#include "clang/Analysis/ProgramPoint.h"
#include "llvm/ADT/DenseMap.h"
namespace clang {
//===----------------------------------------------------------------------===//
/// Dataflow Directional Tag Classes. These are used for tag dispatching
/// within the dataflow solver/transfer functions to determine what direction
/// a dataflow analysis flows.
//===----------------------------------------------------------------------===//
namespace clang {
namespace dataflow {
struct forward_analysis_tag {};
struct backward_analysis_tag {};
@@ -0,0 +1,127 @@
//===- MacroExpansionContext.h - Macro expansion information ----*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_ANALYSIS_MACROEXPANSIONCONTEXT_H
#define LLVM_CLANG_ANALYSIS_MACROEXPANSIONCONTEXT_H
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
namespace clang {
namespace detail {
class MacroExpansionRangeRecorder;
} // namespace detail
/// MacroExpansionContext tracks the macro expansions processed by the
/// Preprocessor. It means that it can track source locations from a single
/// translation unit. For every macro expansion it can tell you what text will
/// be substituted.
///
/// It was designed to deal with:
/// - regular macros
/// - macro functions
/// - variadic macros
/// - transitive macro expansions
/// - macro redefinition
/// - unbalanced parenthesis
///
/// \code{.c}
/// void bar();
/// #define retArg(x) x
/// #define retArgUnclosed retArg(bar()
/// #define BB CC
/// #define applyInt BB(int)
/// #define CC(x) retArgUnclosed
///
/// void unbalancedMacros() {
/// applyInt );
/// //^~~~~~~~~~^ is the substituted range
/// // Substituted text is "applyInt )"
/// // Expanded text is "bar()"
/// }
///
/// #define expandArgUnclosedCommaExpr(x) (x, bar(), 1
/// #define f expandArgUnclosedCommaExpr
///
/// void unbalancedMacros2() {
/// int x = f(f(1)) )); // Look at the parenthesis!
/// // ^~~~~~^ is the substituted range
/// // Substituted text is "f(f(1))"
/// // Expanded text is "((1,bar(),1,bar(),1"
/// }
/// \endcode
/// \remark Currently we don't respect the whitespaces between expanded tokens,
/// so the output for this example might differ from the -E compiler
/// invocation.
/// \remark All whitespaces are consumed while constructing the expansion.
/// After all identifier a single space inserted to produce a valid C
/// code even if identifier follows an other identifiers such as
/// variable declarations.
/// \remark MacroExpansionContext object must outlive the Preprocessor
/// parameter.
class MacroExpansionContext {
public:
/// Creates a MacroExpansionContext.
/// \remark You must call registerForPreprocessor to set the required
/// onTokenLexed callback and the PPCallbacks.
explicit MacroExpansionContext(const LangOptions &LangOpts);
/// Register the necessary callbacks to the Preprocessor to record the
/// expansion events and the generated tokens. Must ensure that this object
/// outlives the given Preprocessor.
void registerForPreprocessor(Preprocessor &PP);
/// \param MacroExpansionLoc Must be the expansion location of a macro.
/// \return The textual representation of the token sequence which was
/// substituted in place of the macro after the preprocessing.
/// If no macro was expanded at that location, returns llvm::None.
Optional<StringRef> getExpandedText(SourceLocation MacroExpansionLoc) const;
/// \param MacroExpansionLoc Must be the expansion location of a macro.
/// \return The text from the original source code which were substituted by
/// the macro expansion chain from the given location.
/// If no macro was expanded at that location, returns llvm::None.
Optional<StringRef> getOriginalText(SourceLocation MacroExpansionLoc) const;
LLVM_DUMP_METHOD void dumpExpansionRangesToStream(raw_ostream &OS) const;
LLVM_DUMP_METHOD void dumpExpandedTextsToStream(raw_ostream &OS) const;
LLVM_DUMP_METHOD void dumpExpansionRanges() const;
LLVM_DUMP_METHOD void dumpExpandedTexts() const;
private:
friend class detail::MacroExpansionRangeRecorder;
using MacroExpansionText = SmallString<40>;
using ExpansionMap = llvm::DenseMap<SourceLocation, MacroExpansionText>;
using ExpansionRangeMap = llvm::DenseMap<SourceLocation, SourceLocation>;
/// Associates the textual representation of the expanded tokens at the given
/// macro expansion location.
ExpansionMap ExpandedTokens;
/// Tracks which source location was the last affected by any macro
/// substitution starting from a given macro expansion location.
ExpansionRangeMap ExpansionRanges;
Preprocessor *PP = nullptr;
SourceManager *SM = nullptr;
const LangOptions &LangOpts;
/// This callback is called by the preprocessor.
/// It stores the textual representation of the expanded token sequence for a
/// macro expansion location.
void onTokenLexed(const Token &Tok);
};
} // end namespace clang
#endif // LLVM_CLANG_ANALYSIS_MACROEXPANSIONCONTEXT_H
@@ -613,8 +613,8 @@ class RetainSummaryManager {
const FunctionType *FT,
bool &AllowAnnotations);
/// Apply the annotation of {@code pd} in function {@code FD}
/// to the resulting summary stored in out-parameter {@code Template}.
/// Apply the annotation of @c pd in function @c FD
/// to the resulting summary stored in out-parameter @c Template.
/// \return whether an annotation was applied.
bool applyParamAnnotationEffect(const ParmVarDecl *pd, unsigned parm_idx,
const NamedDecl *FD,
@@ -715,8 +715,8 @@ class RetainSummaryManager {
/// Set argument types for arguments which are not doing anything.
void updateSummaryForArgumentTypes(const AnyCall &C, const RetainSummary *&RS);
/// Determine whether a declaration {@code D} of correspondent type (return
/// type for functions/methods) {@code QT} has any of the given attributes,
/// Determine whether a declaration @c D of correspondent type (return
/// type for functions/methods) @c QT has any of the given attributes,
/// provided they pass necessary validation checks AND tracking the given
/// attribute is enabled.
/// Returns the object kind corresponding to the present attribute, or None,
@@ -37,174 +37,6 @@ enum CXXDtorType {
Dtor_Comdat ///< The COMDAT used for dtors
};
/// A return adjustment.
struct ReturnAdjustment {
/// The non-virtual adjustment from the derived object to its
/// nearest virtual base.
int64_t NonVirtual;
/// Holds the ABI-specific information about the virtual return
/// adjustment, if needed.
union VirtualAdjustment {
// Itanium ABI
struct {
/// The offset (in bytes), relative to the address point
/// of the virtual base class offset.
int64_t VBaseOffsetOffset;
} Itanium;
// Microsoft ABI
struct {
/// The offset (in bytes) of the vbptr, relative to the beginning
/// of the derived class.
uint32_t VBPtrOffset;
/// Index of the virtual base in the vbtable.
uint32_t VBIndex;
} Microsoft;
VirtualAdjustment() {
memset(this, 0, sizeof(*this));
}
bool Equals(const VirtualAdjustment &Other) const {
return memcmp(this, &Other, sizeof(Other)) == 0;
}
bool isEmpty() const {
VirtualAdjustment Zero;
return Equals(Zero);
}
bool Less(const VirtualAdjustment &RHS) const {
return memcmp(this, &RHS, sizeof(RHS)) < 0;
}
} Virtual;
ReturnAdjustment() : NonVirtual(0) {}
bool isEmpty() const { return !NonVirtual && Virtual.isEmpty(); }
friend bool operator==(const ReturnAdjustment &LHS,
const ReturnAdjustment &RHS) {
return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Equals(RHS.Virtual);
}
friend bool operator!=(const ReturnAdjustment &LHS, const ReturnAdjustment &RHS) {
return !(LHS == RHS);
}
friend bool operator<(const ReturnAdjustment &LHS,
const ReturnAdjustment &RHS) {
if (LHS.NonVirtual < RHS.NonVirtual)
return true;
return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Less(RHS.Virtual);
}
};
/// A \c this pointer adjustment.
struct ThisAdjustment {
/// The non-virtual adjustment from the derived object to its
/// nearest virtual base.
int64_t NonVirtual;
/// Holds the ABI-specific information about the virtual this
/// adjustment, if needed.
union VirtualAdjustment {
// Itanium ABI
struct {
/// The offset (in bytes), relative to the address point,
/// of the virtual call offset.
int64_t VCallOffsetOffset;
} Itanium;
struct {
/// The offset of the vtordisp (in bytes), relative to the ECX.
int32_t VtordispOffset;
/// The offset of the vbptr of the derived class (in bytes),
/// relative to the ECX after vtordisp adjustment.
int32_t VBPtrOffset;
/// The offset (in bytes) of the vbase offset in the vbtable.
int32_t VBOffsetOffset;
} Microsoft;
VirtualAdjustment() {
memset(this, 0, sizeof(*this));
}
bool Equals(const VirtualAdjustment &Other) const {
return memcmp(this, &Other, sizeof(Other)) == 0;
}
bool isEmpty() const {
VirtualAdjustment Zero;
return Equals(Zero);
}
bool Less(const VirtualAdjustment &RHS) const {
return memcmp(this, &RHS, sizeof(RHS)) < 0;
}
} Virtual;
ThisAdjustment() : NonVirtual(0) { }
bool isEmpty() const { return !NonVirtual && Virtual.isEmpty(); }
friend bool operator==(const ThisAdjustment &LHS,
const ThisAdjustment &RHS) {
return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Equals(RHS.Virtual);
}
friend bool operator!=(const ThisAdjustment &LHS, const ThisAdjustment &RHS) {
return !(LHS == RHS);
}
friend bool operator<(const ThisAdjustment &LHS,
const ThisAdjustment &RHS) {
if (LHS.NonVirtual < RHS.NonVirtual)
return true;
return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Less(RHS.Virtual);
}
};
class CXXMethodDecl;
/// The \c this pointer adjustment as well as an optional return
/// adjustment for a thunk.
struct ThunkInfo {
/// The \c this pointer adjustment.
ThisAdjustment This;
/// The return adjustment.
ReturnAdjustment Return;
/// Holds a pointer to the overridden method this thunk is for,
/// if needed by the ABI to distinguish different thunks with equal
/// adjustments. Otherwise, null.
/// CAUTION: In the unlikely event you need to sort ThunkInfos, consider using
/// an ABI-specific comparator.
const CXXMethodDecl *Method;
ThunkInfo() : Method(nullptr) { }
ThunkInfo(const ThisAdjustment &This, const ReturnAdjustment &Return,
const CXXMethodDecl *Method = nullptr)
: This(This), Return(Return), Method(Method) {}
friend bool operator==(const ThunkInfo &LHS, const ThunkInfo &RHS) {
return LHS.This == RHS.This && LHS.Return == RHS.Return &&
LHS.Method == RHS.Method;
}
bool isEmpty() const {
return This.isEmpty() && Return.isEmpty() && Method == nullptr;
}
};
} // end namespace clang
#endif
@@ -44,6 +44,13 @@ enum class LangAS : unsigned {
cuda_constant,
cuda_shared,
// SYCL specific address spaces.
sycl_global,
sycl_global_device,
sycl_global_host,
sycl_local,
sycl_private,
// Pointer size and extension address spaces.
ptr32_sptr,
ptr32_uptr,
@@ -368,6 +368,7 @@ def TargetBPF : TargetArch<["bpfel", "bpfeb"]>;
def TargetMips32 : TargetArch<["mips", "mipsel"]>;
def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
def TargetMSP430 : TargetArch<["msp430"]>;
def TargetM68k : TargetArch<["m68k"]>;
def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
def TargetX86 : TargetArch<["x86"]>;
def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
@@ -553,6 +554,11 @@ class Attr {
list<Documentation> Documentation;
}
/// Used to define a set of mutually exclusive attributes.
class MutualExclusions<list<Attr> Ex> {
list<Attr> Exclusions = Ex;
}
/// A type attribute is not processed on a declaration or a statement.
class TypeAttr : Attr;
@@ -636,6 +642,15 @@ def Alias : Attr {
let Documentation = [Undocumented];
}
def BuiltinAlias : Attr {
let Spellings = [CXX11<"clang", "builtin_alias">,
C2x<"clang", "builtin_alias">,
GNU<"clang_builtin_alias">];
let Args = [IdentifierArgument<"BuiltinName">];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [BuiltinAliasDocs];
}
def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr<TargetAnyArm> {
let Spellings = [Clang<"__clang_arm_builtin_alias">];
let Args = [IdentifierArgument<"BuiltinName">];
@@ -729,7 +744,8 @@ def XRayLogArgs : InheritableAttr {
def PatchableFunctionEntry
: InheritableAttr,
TargetSpecificAttr<TargetArch<["aarch64", "aarch64_be", "x86", "x86_64"]>> {
TargetSpecificAttr<TargetArch<
["aarch64", "aarch64_be", "riscv32", "riscv64", "x86", "x86_64"]>> {
let Spellings = [GCC<"patchable_function_entry">];
let Subjects = SubjectList<[Function, ObjCMethod]>;
let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>];
@@ -772,8 +788,9 @@ def Annotate : InheritableParamAttr {
}
def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
// NOTE: If you add any additional spellings, MSP430Interrupt's,
// MipsInterrupt's and AnyX86Interrupt's spellings must match.
// NOTE: If you add any additional spellings, M68kInterrupt's,
// MSP430Interrupt's, MipsInterrupt's and AnyX86Interrupt's spellings
// must match.
let Spellings = [GCC<"interrupt">];
let Args = [EnumArgument<"Interrupt", "InterruptType",
["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
@@ -839,6 +856,8 @@ def Availability : InheritableAttr {
.Case("macos_app_extension", "macOS (App Extension)")
.Case("tvos_app_extension", "tvOS (App Extension)")
.Case("watchos_app_extension", "watchOS (App Extension)")
.Case("maccatalyst", "macCatalyst")
.Case("maccatalyst_app_extension", "macCatalyst (App Extension)")
.Case("swift", "Swift")
.Default(llvm::StringRef());
}
@@ -852,6 +871,8 @@ static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
.Case("macos_app_extension", "macOSApplicationExtension")
.Case("tvos_app_extension", "tvOSApplicationExtension")
.Case("watchos_app_extension", "watchOSApplicationExtension")
.Case("maccatalyst", "macCatalyst")
.Case("maccatalyst_app_extension", "macCatalystApplicationExtension")
.Case("zos", "z/OS")
.Default(Platform);
}
@@ -865,6 +886,8 @@ static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
.Case("macOSApplicationExtension", "macos_app_extension")
.Case("tvOSApplicationExtension", "tvos_app_extension")
.Case("watchOSApplicationExtension", "watchos_app_extension")
.Case("macCatalyst", "maccatalyst")
.Case("macCatalystApplicationExtension", "maccatalyst_app_extension")
.Default(Platform);
} }];
let HasCustomParsing = 1;
@@ -915,6 +938,7 @@ def CFAuditedTransfer : InheritableAttr {
let Spellings = [Clang<"cf_audited_transfer">];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [Undocumented];
let SimpleHandler = 1;
}
// cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
@@ -924,7 +948,9 @@ def CFUnknownTransfer : InheritableAttr {
let Spellings = [Clang<"cf_unknown_transfer">];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [Undocumented];
let SimpleHandler = 1;
}
def : MutualExclusions<[CFAuditedTransfer, CFUnknownTransfer]>;
def CFReturnsRetained : InheritableAttr {
let Spellings = [Clang<"cf_returns_retained">];
@@ -1006,6 +1032,7 @@ def Cold : InheritableAttr {
let Spellings = [GCC<"cold">];
let Subjects = SubjectList<[Function]>;
let Documentation = [Undocumented];
let SimpleHandler = 1;
}
def Common : InheritableAttr {
@@ -1091,6 +1118,7 @@ def CUDADeviceBuiltinSurfaceType : InheritableAttr {
let Subjects = SubjectList<[CXXRecord]>;
let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs];
let MeaningfulToClassTemplateDefinition = 1;
let SimpleHandler = 1;
}
def CUDADeviceBuiltinTextureType : InheritableAttr {
@@ -1100,7 +1128,10 @@ def CUDADeviceBuiltinTextureType : InheritableAttr {
let Subjects = SubjectList<[CXXRecord]>;
let Documentation = [CUDADeviceBuiltinTextureTypeDocs];
let MeaningfulToClassTemplateDefinition = 1;
let SimpleHandler = 1;
}
def : MutualExclusions<[CUDADeviceBuiltinSurfaceType,
CUDADeviceBuiltinTextureType]>;
def CUDAGlobal : InheritableAttr {
let Spellings = [GNU<"global">, Declspec<"__global__">];
@@ -1108,13 +1139,16 @@ def CUDAGlobal : InheritableAttr {
let LangOpts = [CUDA];
let Documentation = [Undocumented];
}
def : MutualExclusions<[CUDADevice, CUDAGlobal]>;
def CUDAHost : InheritableAttr {
let Spellings = [GNU<"host">, Declspec<"__host__">];
let Subjects = SubjectList<[Function]>;
let LangOpts = [CUDA];
let Documentation = [Undocumented];
let SimpleHandler = 1;
}
def : MutualExclusions<[CUDAGlobal, CUDAHost]>;
def HIPManaged : InheritableAttr {
let Spellings = [GNU<"managed">, Declspec<"__managed__">];
@@ -1147,6 +1181,7 @@ def CUDAShared : InheritableAttr {
let LangOpts = [CUDA];
let Documentation = [Undocumented];
}
def : MutualExclusions<[CUDAConstant, CUDAShared, HIPManaged]>;
def SYCLKernel : InheritableAttr {
let Spellings = [Clang<"sycl_kernel">];
@@ -1178,9 +1213,11 @@ def OpenCLKernel : InheritableAttr {
let SimpleHandler = 1;
}
def OpenCLUnrollHint : InheritableAttr {
def OpenCLUnrollHint : StmtAttr {
let Spellings = [GNU<"opencl_unroll_hint">];
let Args = [UnsignedArgument<"UnrollHint">];
let Subjects = SubjectList<[ForStmt, CXXForRangeStmt, WhileStmt, DoStmt],
ErrorDiag, "'for', 'while', and 'do' statements">;
let Args = [UnsignedArgument<"UnrollHint", /*opt*/1>];
let Documentation = [OpenCLUnrollHintDocs];
}
@@ -1286,7 +1323,7 @@ def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
def AllocSize : InheritableAttr {
let Spellings = [GCC<"alloc_size">];
let Subjects = SubjectList<[Function]>;
let Subjects = SubjectList<[HasFunctionProto]>;
let Args = [ParamIdxArgument<"ElemSizeParam">,
ParamIdxArgument<"NumElemsParam", /*opt*/ 1>];
let TemplateDependent = 1;
@@ -1321,7 +1358,10 @@ def FallThrough : StmtAttr {
let Spellings = [CXX11<"", "fallthrough", 201603>,
C2x<"", "fallthrough", 201904>,
CXX11<"clang", "fallthrough">, GCC<"fallthrough">];
// let Subjects = [NullStmt];
// The attribute only applies to a NullStmt, but we have special fix-it
// behavior if applied to a case label.
let Subjects = SubjectList<[NullStmt, SwitchCase], ErrorDiag,
"empty statements">;
let Documentation = [FallthroughDocs];
}
@@ -1334,15 +1374,23 @@ def Unlikely : StmtAttr {
let Spellings = [CXX11<"", "unlikely", 201803>, C2x<"clang", "unlikely">];
let Documentation = [LikelihoodDocs];
}
def : MutualExclusions<[Likely, Unlikely]>;
def NoMerge : DeclOrStmtAttr {
let Spellings = [Clang<"nomerge">];
let Documentation = [NoMergeDocs];
let InheritEvenIfAlreadyPresent = 1;
let Subjects = SubjectList<[Function], ErrorDiag, "functions and statements">;
let Subjects = SubjectList<[Function, Stmt], ErrorDiag,
"functions and statements">;
let SimpleHandler = 1;
}
def MustTail : StmtAttr {
let Spellings = [Clang<"musttail">];
let Documentation = [MustTailDocs];
let Subjects = SubjectList<[ReturnStmt], ErrorDiag, "return statements">;
}
def FastCall : DeclOrTypeAttr {
let Spellings = [GCC<"fastcall">, Keyword<"__fastcall">,
Keyword<"_fastcall">];
@@ -1424,7 +1472,9 @@ def Hot : InheritableAttr {
// An AST node is created for this attribute, but not actually used beyond
// semantic checking for mutual exclusion with the Cold attribute.
let Documentation = [Undocumented];
let SimpleHandler = 1;
}
def : MutualExclusions<[Hot, Cold]>;
def IBAction : InheritableAttr {
let Spellings = [Clang<"ibaction">];
@@ -1459,7 +1509,7 @@ def IFunc : Attr, TargetSpecificAttr<TargetELF> {
def Restrict : InheritableAttr {
let Spellings = [Declspec<"restrict">, GCC<"malloc">];
let Subjects = SubjectList<[Function]>;
let Documentation = [Undocumented];
let Documentation = [RestrictDocs];
}
def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
@@ -1522,8 +1572,8 @@ def MSABI : DeclOrTypeAttr {
}
def MSP430Interrupt : InheritableAttr, TargetSpecificAttr<TargetMSP430> {
// NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
// and AnyX86Interrupt's spellings must match.
// NOTE: If you add any additional spellings, ARMInterrupt's, M68kInterrupt's,
// MipsInterrupt's and AnyX86Interrupt's spellings must match.
let Spellings = [GCC<"interrupt">];
let Args = [UnsignedArgument<"Number">];
let ParseKind = "Interrupt";
@@ -1535,11 +1585,13 @@ def Mips16 : InheritableAttr, TargetSpecificAttr<TargetMips32> {
let Spellings = [GCC<"mips16">];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [Undocumented];
let SimpleHandler = 1;
}
def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
// NOTE: If you add any additional spellings, ARMInterrupt's,
// MSP430Interrupt's and AnyX86Interrupt's spellings must match.
// M68kInterrupt's, MSP430Interrupt's and AnyX86Interrupt's spellings
// must match.
let Spellings = [GCC<"interrupt">];
let Subjects = SubjectList<[Function]>;
let Args = [EnumArgument<"Interrupt", "InterruptType",
@@ -1552,23 +1604,39 @@ def MipsInterrupt : InheritableAttr, TargetSpecificAttr<TargetMips32> {
let ParseKind = "Interrupt";
let Documentation = [MipsInterruptDocs];
}
def : MutualExclusions<[Mips16, MipsInterrupt]>;
def MicroMips : InheritableAttr, TargetSpecificAttr<TargetMips32> {
let Spellings = [GCC<"micromips">];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [MicroMipsDocs];
let SimpleHandler = 1;
}
def : MutualExclusions<[Mips16, MicroMips]>;
def MipsLongCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
let Spellings = [GCC<"long_call">, GCC<"far">];
let Subjects = SubjectList<[Function]>;
let Documentation = [MipsLongCallStyleDocs];
let SimpleHandler = 1;
}
def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetAnyMips> {
let Spellings = [GCC<"short_call">, GCC<"near">];
let Subjects = SubjectList<[Function]>;
let Documentation = [MipsShortCallStyleDocs];
let SimpleHandler = 1;
}
def : MutualExclusions<[MipsLongCall, MipsShortCall]>;
def M68kInterrupt : InheritableAttr, TargetSpecificAttr<TargetM68k> {
// NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
// MSP430Interrupt's and AnyX86Interrupt's spellings must match.
let Spellings = [GNU<"interrupt">];
let Args = [UnsignedArgument<"Number">];
let ParseKind = "Interrupt";
let HasCustomParsing = 1;
let Documentation = [Undocumented];
}
def Mode : Attr {
@@ -1636,7 +1704,9 @@ def DisableTailCalls : InheritableAttr {
let Spellings = [Clang<"disable_tail_calls">];
let Subjects = SubjectList<[Function, ObjCMethod]>;
let Documentation = [DisableTailCallsDocs];
let SimpleHandler = 1;
}
def : MutualExclusions<[Naked, DisableTailCalls]>;
def NoAlias : InheritableAttr {
let Spellings = [Declspec<"noalias">];
@@ -1658,6 +1728,14 @@ def NoDebug : InheritableAttr {
let Documentation = [NoDebugDocs];
}
def StandaloneDebug : InheritableAttr {
let Spellings = [Clang<"standalone_debug", /*allowInC =*/0>];
let Subjects = SubjectList<[CXXRecord]>;
let Documentation = [StandaloneDebugDocs];
let SimpleHandler = 1;
let LangOpts = [CPlusPlus];
}
def NoDuplicate : InheritableAttr {
let Spellings = [Clang<"noduplicate">];
let Subjects = SubjectList<[Function]>;
@@ -1898,11 +1976,20 @@ def NoInstrumentFunction : InheritableAttr {
let SimpleHandler = 1;
}
def NoProfileFunction : InheritableAttr {
let Spellings = [GCC<"no_profile_instrument_function">];
let Subjects = SubjectList<[Function]>;
let Documentation = [NoProfileInstrumentFunctionDocs];
let SimpleHandler = 1;
}
def NotTailCalled : InheritableAttr {
let Spellings = [Clang<"not_tail_called">];
let Subjects = SubjectList<[Function]>;
let Documentation = [NotTailCalledDocs];
let SimpleHandler = 1;
}
def : MutualExclusions<[AlwaysInline, NotTailCalled]>;
def NoStackProtector : InheritableAttr {
let Spellings = [Clang<"no_stack_protector">];
@@ -2085,6 +2172,7 @@ def ObjCNonRuntimeProtocol : Attr {
let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
let LangOpts = [ObjC];
let Documentation = [ObjCNonRuntimeProtocolDocs];
let SimpleHandler = 1;
}
def ObjCRuntimeName : Attr {
@@ -2219,12 +2307,14 @@ def SwiftBridgedTypedef : InheritableAttr {
let Spellings = [GNU<"swift_bridged_typedef">];
let Subjects = SubjectList<[TypedefName], ErrorDiag>;
let Documentation = [SwiftBridgedTypedefDocs];
let SimpleHandler = 1;
}
def SwiftObjCMembers : Attr {
let Spellings = [GNU<"swift_objc_members">];
let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
let Documentation = [SwiftObjCMembersDocs];
let SimpleHandler = 1;
}
def SwiftError : InheritableAttr {
@@ -2256,6 +2346,7 @@ def SwiftNewType : InheritableAttr {
def SwiftPrivate : InheritableAttr {
let Spellings = [GNU<"swift_private">];
let Documentation = [SwiftPrivateDocs];
let SimpleHandler = 1;
}
def NoDeref : TypeAttr {
@@ -2374,11 +2465,21 @@ def SwiftCall : DeclOrTypeAttr {
let Documentation = [SwiftCallDocs];
}
def SwiftAsyncCall : DeclOrTypeAttr {
let Spellings = [Clang<"swiftasynccall">];
let Documentation = [SwiftAsyncCallDocs];
}
def SwiftContext : ParameterABIAttr {
let Spellings = [Clang<"swift_context">];
let Documentation = [SwiftContextDocs];
}
def SwiftAsyncContext : ParameterABIAttr {
let Spellings = [Clang<"swift_async_context">];
let Documentation = [SwiftAsyncContextDocs];
}
def SwiftErrorResult : ParameterABIAttr {
let Spellings = [Clang<"swift_error_result">];
let Documentation = [SwiftErrorResultDocs];
@@ -2399,6 +2500,16 @@ def SwiftAsync : InheritableAttr {
let Documentation = [SwiftAsyncDocs];
}
def SwiftAsyncError : InheritableAttr {
let Spellings = [Clang<"swift_async_error">];
let Subjects = SubjectList<[Function, ObjCMethod]>;
let Args = [EnumArgument<"Convention", "ConventionKind",
["none", "nonnull_error", "zero_argument", "nonzero_argument"],
["None", "NonNullError", "ZeroArgument", "NonZeroArgument"]>,
UnsignedArgument<"HandlerParamIdx", /*opt=*/1>];
let Documentation = [SwiftAsyncErrorDocs];
}
def Suppress : StmtAttr {
let Spellings = [CXX11<"gsl", "suppress">];
let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
@@ -2636,7 +2747,14 @@ def Unused : InheritableAttr {
def Used : InheritableAttr {
let Spellings = [GCC<"used">];
let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
let Documentation = [Undocumented];
let Documentation = [UsedDocs];
let SimpleHandler = 1;
}
def Retain : InheritableAttr {
let Spellings = [GCC<"retain">];
let Subjects = SubjectList<[NonLocalVar, Function, ObjCMethod]>;
let Documentation = [RetainDocs];
let SimpleHandler = 1;
}
@@ -2758,7 +2876,7 @@ def LTOVisibilityPublic : InheritableAttr {
def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
// NOTE: If you add any additional spellings, ARMInterrupt's,
// MSP430Interrupt's and MipsInterrupt's spellings must match.
// M68kInterrupt's, MSP430Interrupt's and MipsInterrupt's spellings must match.
let Spellings = [GCC<"interrupt">];
let Subjects = SubjectList<[HasFunctionProto]>;
let ParseKind = "Interrupt";
@@ -2802,6 +2920,10 @@ def NoSanitize : InheritableAttr {
}
return Mask;
}
bool hasCoverage() const {
return llvm::is_contained(sanitizers(), "coverage");
}
}];
}
@@ -3199,6 +3321,7 @@ def Pointer : InheritableAttr {
let Args = [TypeArgument<"DerefType", /*opt=*/1>];
let Documentation = [LifetimePointerDocs];
}
def : MutualExclusions<[Owner, Pointer]>;
// Microsoft-related attributes
@@ -3426,6 +3549,7 @@ def LoopHint : Attr {
}];
let Documentation = [LoopHintDocs, UnrollHintDocs];
let HasCustomParsing = 1;
}
def CapturedRecord : InheritableAttr {
@@ -3509,6 +3633,7 @@ def OMPDeclareTargetDecl : InheritableAttr {
void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const;
static llvm::Optional<MapTypeTy>
isDeclareTargetDeclaration(const ValueDecl *VD);
static llvm::Optional<OMPDeclareTargetDeclAttr*> getActiveAttr(const ValueDecl *VD);
static llvm::Optional<DevTypeTy> getDeviceType(const ValueDecl *VD);
static llvm::Optional<SourceLocation> getLocation(const ValueDecl *VD);
}];
@@ -3570,6 +3695,7 @@ def InternalLinkage : InheritableAttr {
let Subjects = SubjectList<[Var, Function, CXXRecord]>;
let Documentation = [InternalLinkageDocs];
}
def : MutualExclusions<[Common, InternalLinkage]>;
def ExcludeFromExplicitInstantiation : InheritableAttr {
let Spellings = [Clang<"exclude_from_explicit_instantiation">];
@@ -3597,18 +3723,22 @@ def AlwaysDestroy : InheritableAttr {
let Subjects = SubjectList<[Var]>;
let Documentation = [AlwaysDestroyDocs];
}
def : MutualExclusions<[NoDestroy, AlwaysDestroy]>;
def SpeculativeLoadHardening : InheritableAttr {
let Spellings = [Clang<"speculative_load_hardening">];
let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
let Documentation = [SpeculativeLoadHardeningDocs];
let SimpleHandler = 1;
}
def NoSpeculativeLoadHardening : InheritableAttr {
let Spellings = [Clang<"no_speculative_load_hardening">];
let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
let Documentation = [NoSpeculativeLoadHardeningDocs];
let SimpleHandler = 1;
}
def : MutualExclusions<[SpeculativeLoadHardening, NoSpeculativeLoadHardening]>;
def Uninitialized : InheritableAttr {
let Spellings = [Clang<"uninitialized", 0>];
@@ -3621,6 +3751,7 @@ def LoaderUninitialized : Attr {
let Spellings = [Clang<"loader_uninitialized">];
let Subjects = SubjectList<[GlobalVar]>;
let Documentation = [LoaderUninitializedDocs];
let SimpleHandler = 1;
}
def ObjCExternallyRetained : InheritableAttr {
@@ -3637,6 +3768,14 @@ def NoBuiltin : Attr {
let Documentation = [NoBuiltinDocs];
}
def UsingIfExists : InheritableAttr {
let Spellings = [Clang<"using_if_exists", 0>];
let Subjects = SubjectList<[Using,
UnresolvedUsingTypename,
UnresolvedUsingValue], ErrorDiag>;
let Documentation = [UsingIfExistsDocs];
}
// FIXME: This attribute is not inheritable, it will not be propagated to
// redecls. [[clang::lifetimebound]] has the same problems. This should be
// fixed in TableGen (by probably adding a new inheritable flag).
@@ -57,6 +57,55 @@ global variable or function should be in after translation.
let Heading = "section, __declspec(allocate)";
}
def UsedDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
This attribute, when attached to a function or variable definition, indicates
that there may be references to the entity which are not apparent in the source
code. For example, it may be referenced from inline ``asm``, or it may be
found through a dynamic symbol or section lookup.
The compiler must emit the definition even if it appears to be unused, and it
must not apply optimizations which depend on fully understanding how the entity
is used.
Whether this attribute has any effect on the linker depends on the target and
the linker. Most linkers support the feature of section garbage collection
(``--gc-sections``), also known as "dead stripping" (``ld64 -dead_strip``) or
discarding unreferenced sections (``link.exe /OPT:REF``). On COFF and Mach-O
targets (Windows and Apple platforms), the `used` attribute prevents symbols
from being removed by linker section GC. On ELF targets, it has no effect on its
own, and the linker may remove the definition if it is not otherwise referenced.
This linker GC can be avoided by also adding the ``retain`` attribute. Note
that ``retain`` requires special support from the linker; see that attribute's
documentation for further information.
}];
}
def RetainDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
This attribute, when attached to a function or variable definition, prevents
section garbage collection in the linker. It does not prevent other discard
mechanisms, such as archive member selection, and COMDAT group resolution.
If the compiler does not emit the definition, e.g. because it was not used in
the translation unit or the compiler was able to eliminate all of the uses,
this attribute has no effect. This attribute is typically combined with the
``used`` attribute to force the definition to be emitted and preserved into the
final linked image.
This attribute is only necessary on ELF targets; other targets prevent section
garbage collection by the linker when using the ``used`` attribute alone.
Using the attributes together should result in consistent behavior across
targets.
This attribute requires the linker to support the ``SHF_GNU_RETAIN`` extension.
This support is available in GNU ``ld`` and ``gold`` as of binutils 2.36, as
well as in ``ld.lld`` 13.
}];
}
def InitPriorityDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
@@ -394,6 +443,32 @@ calls.
}];
}
def MustTailDocs : Documentation {
let Category = DocCatStmt;
let Content = [{
If a ``return`` statement is marked ``musttail``, this indicates that the
compiler must generate a tail call for the program to be correct, even when
optimizations are disabled. This guarantees that the call will not cause
unbounded stack growth if it is part of a recursive cycle in the call graph.
If the callee is a virtual function that is implemented by a thunk, there is
no guarantee in general that the thunk tail-calls the implementation of the
virtual function, so such a call in a recursive cycle can still result in
unbounded stack growth.
``clang::musttail`` can only be applied to a ``return`` statement whose value
is the result of a function call (even functions returning void must use
``return``, although no value is returned). The target function must have the
same number of arguments as the caller. The types of the return value and all
arguments must be similar according to C++ rules (differing only in cv
qualifiers or array size), including the implicit "this" argument, if any.
Any variables in scope, including all arguments to the function and the
return value must be trivially destructible. The calling convention of the
caller and callee must match, and they must not be variadic functions or have
old style K&R C function declarations.
}];
}
def AssertCapabilityDocs : Documentation {
let Category = DocCatFunction;
let Heading = "assert_capability, assert_shared_capability";
@@ -1048,8 +1123,18 @@ def NoDebugDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
The ``nodebug`` attribute allows you to suppress debugging information for a
function or method, or for a variable that is not a parameter or a non-static
data member.
function or method, for a variable that is not a parameter or a non-static
data member, or for a typedef or using declaration.
}];
}
def StandaloneDebugDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
The ``standalone_debug`` attribute causes debug info to be emitted for a record
type regardless of the debug info optimizations that are enabled with
-fno-standalone-debug. This attribute only has an effect when debug info
optimizations are enabled (e.g. with -fno-standalone-debug), and is C++-only.
}];
}
@@ -2474,17 +2559,33 @@ This attribute accepts a single parameter that must be one of the following:
}];
}
def NoProfileInstrumentFunctionDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
Use the ``no_profile_instrument_function`` attribute on a function declaration
to denote that the compiler should not instrument the function with
profile-related instrumentation, such as via the
``-fprofile-generate`` / ``-fprofile-instr-generate`` /
``-fcs-profile-generate`` / ``-fprofile-arcs`` flags.
}];
}
def NoSanitizeDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
Use the ``no_sanitize`` attribute on a function or a global variable
declaration to specify that a particular instrumentation or set of
instrumentations should not be applied. The attribute takes a list of
string literals, which have the same meaning as values accepted by the
``-fno-sanitize=`` flag. For example,
``__attribute__((no_sanitize("address", "thread")))`` specifies that
AddressSanitizer and ThreadSanitizer should not be applied to the
function or variable.
instrumentations should not be applied.
The attribute takes a list of string literals with the following accepted
values:
* all values accepted by ``-fno-sanitize=``;
* ``coverage``, to disable SanitizerCoverage instrumentation.
For example, ``__attribute__((no_sanitize("address", "thread")))`` specifies
that AddressSanitizer and ThreadSanitizer should not be applied to the function
or variable. Using ``__attribute__((no_sanitize("coverage")))`` specifies that
SanitizerCoverage should not be applied to the function.
See :ref:`Controlling Code Generation <controlling-code-generation>` for a
full list of supported sanitizer flags.
@@ -2967,16 +3068,55 @@ It is only supported when using the Microsoft C++ ABI.
def LifetimeBoundDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
The ``lifetimebound`` attribute indicates that a resource owned by
a function parameter or implicit object parameter
is retained by the return value of the annotated function
(or, for a parameter of a constructor, in the value of the constructed object).
It is only supported in C++.
The ``lifetimebound`` attribute on a function parameter or implicit object
parameter indicates that objects that are referred to by that parameter may
also be referred to by the return value of the annotated function (or, for a
parameter of a constructor, by the value of the constructed object). It is only
supported in C++.
This attribute provides an experimental implementation of the facility
described in the C++ committee paper `P0936R0 <http://wg21.link/p0936r0>`_,
and is subject to change as the design of the corresponding functionality
changes.
By default, a reference is considered to refer to its referenced object, a
pointer is considered to refer to its pointee, a ``std::initializer_list<T>``
is considered to refer to its underlying array, and aggregates (arrays and
simple ``struct``\s) are considered to refer to all objects that their
transitive subobjects refer to.
Clang warns if it is able to detect that an object or reference refers to
another object with a shorter lifetime. For example, Clang will warn if a
function returns a reference to a local variable, or if a reference is bound to
a temporary object whose lifetime is not extended. By using the
``lifetimebound`` attribute, this determination can be extended to look through
user-declared functions. For example:
.. code-block:: c++
// Returns m[key] if key is present, or default_value if not.
template<typename T, typename U>
const U &get_or_default(const std::map<T, U> &m [[clang::lifetimebound]],
const T &key, /* note, not lifetimebound */
const U &default_value [[clang::lifetimebound]]);
std::map<std::string, std::string> m;
// warning: temporary "bar"s that might be bound to local reference 'val'
// will be destroyed at the end of the full-expression
const std::string &val = get_or_default(m, "foo"s, "bar"s);
// No warning in this case.
std::string def_val = "bar"s;
const std::string &val = get_or_default(m, "foo"s, def_val);
The attribute can be applied to the implicit ``this`` parameter of a member
function by writing the attribute after the function type:
.. code-block:: c++
struct string {
// The returned pointer should not outlive ``*this``.
const char *data() const [[clang::lifetimebound]];
};
This attribute is inspired by the C++ committee paper `P0936R0
<http://wg21.link/p0936r0>`_, but does not affect whether temporary objects
have their lifetimes extended.
}];
}
@@ -3119,7 +3259,9 @@ def UnrollHintDocs : Documentation {
let Content = [{
Loop unrolling optimization hints can be specified with ``#pragma unroll`` and
``#pragma nounroll``. The pragma is placed immediately before a for, while,
do-while, or c++11 range-based for loop.
do-while, or c++11 range-based for loop. GCC's loop unrolling hints
``#pragma GCC unroll`` and ``#pragma GCC nounroll`` are also supported and have
identical semantics to ``#pragma unroll`` and ``#pragma nounroll``.
Specifying ``#pragma unroll`` without a parameter directs the loop unroller to
attempt to fully unroll the loop if the trip count is known at compile time and
@@ -3586,6 +3728,16 @@ system) and does not imply undefined behavior, making it more widely applicable.
}];
}
def RestrictDocs : Documentation {
let Category = DocCatFunction;
let Heading = "malloc";
let Content = [{
The ``malloc`` attribute indicates that the function acts like a system memory
allocation function, returning a pointer to allocated storage disjoint from the
storage for any other object accessible to the caller.
}];
}
def ReturnsNonNullDocs : Documentation {
let Category = NullabilityDocs;
let Content = [{
@@ -4057,9 +4209,8 @@ def NotTailCalledDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
The ``not_tail_called`` attribute prevents tail-call optimization on statically
bound calls. It has no effect on indirect calls. Virtual functions, objective-c
methods, and functions marked as ``always_inline`` cannot be marked as
``not_tail_called``.
bound calls. Objective-c methods, and functions marked as ``always_inline``
cannot be marked as ``not_tail_called``.
For example, it prevents tail-call optimization in the following case:
@@ -4085,28 +4236,25 @@ However, it doesn't prevent tail-call optimization in this case:
return (*fn)(a);
}
Marking virtual functions as ``not_tail_called`` is an error:
Generally, marking an overriding virtual function as ``not_tail_called`` is
not useful, because this attribute is a property of the static type. Calls
made through a pointer or reference to the base class type will respect
the ``not_tail_called`` attribute of the base class's member function,
regardless of the runtime destination of the call:
.. code-block:: c++
class Base {
public:
// not_tail_called on a virtual function is an error.
[[clang::not_tail_called]] virtual int foo1();
virtual int foo2();
// Non-virtual functions can be marked ``not_tail_called``.
[[clang::not_tail_called]] int foo3();
};
class Derived1 : public Base {
public:
int foo1() override;
// not_tail_called on a virtual function is an error.
[[clang::not_tail_called]] int foo2() override;
struct Foo { virtual void f(); };
struct Bar : Foo {
[[clang::not_tail_called]] void f() override;
};
void callera(Bar& bar) {
Foo& foo = bar;
// not_tail_called has no effect on here, even though the
// underlying method is f from Bar.
foo.f();
bar.f(); // No tail-call optimization on here.
}
}];
}
@@ -4379,7 +4527,8 @@ def SwiftContextDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
The ``swift_context`` attribute marks a parameter of a ``swiftcall``
function as having the special context-parameter ABI treatment.
or ``swiftasynccall`` function as having the special context-parameter
ABI treatment.
This treatment generally passes the context value in a special register
which is normally callee-preserved.
@@ -4392,6 +4541,47 @@ A context parameter must have pointer or reference type.
}];
}
def SwiftAsyncCallDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
The ``swiftasynccall`` attribute indicates that a function is
compatible with the low-level conventions of Swift async functions,
provided it declares the right formal arguments.
In most respects, this is similar to the ``swiftcall`` attribute, except for
the following:
- A parameter may be marked ``swift_async_context``, ``swift_context``
or ``swift_indirect_result`` (with the same restrictions on parameter
ordering as ``swiftcall``) but the parameter attribute
``swift_error_result`` is not permitted.
- A ``swiftasynccall`` function must have return type ``void``.
- Within a ``swiftasynccall`` function, a call to a ``swiftasynccall``
function that is the immediate operand of a ``return`` statement is
guaranteed to be performed as a tail call. This syntax is allowed even
in C as an extension (a call to a void-returning function cannot be a
return operand in standard C). If something in the calling function would
semantically be performed after a guaranteed tail call, such as the
non-trivial destruction of a local variable or temporary,
then the program is ill-formed.
}];
}
def SwiftAsyncContextDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
The ``swift_async_context`` attribute marks a parameter of a ``swiftasynccall``
function as having the special asynchronous context-parameter ABI treatment.
If the function is not ``swiftasynccall``, this attribute only generates
extended frame information.
A context parameter must have pointer or reference type.
}];
}
def SwiftErrorResultDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
@@ -4431,7 +4621,8 @@ def SwiftIndirectResultDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
The ``swift_indirect_result`` attribute marks a parameter of a ``swiftcall``
function as having the special indirect-result ABI treatment.
or ``swiftasynccall`` function as having the special indirect-result ABI
treatment.
This treatment gives the parameter the target's normal indirect-result
ABI treatment, which may involve passing it differently from an ordinary
@@ -4486,6 +4677,47 @@ argument is the index of the completion handler parameter.
}];
}
def SwiftAsyncErrorDocs : Documentation {
let Category = SwiftDocs;
let Heading = "swift_async_error";
let Content = [{
The ``swift_async_error`` attribute specifies how an error state will be
represented in a swift async method. It's a bit analogous to the ``swift_error``
attribute for the generated async method. The ``swift_async_error`` attribute
can indicate a variety of different ways of representing an error.
- ``__attribute__((swift_async_error(zero_argument, N)))``, specifies that the
async method is considered to have failed if the Nth argument to the
completion handler is zero.
- ``__attribute__((swift_async_error(nonzero_argument, N)))``, specifies that
the async method is considered to have failed if the Nth argument to the
completion handler is non-zero.
- ``__attribute__((swift_async_error(nonnull_error)))``, specifies that the
async method is considered to have failed if the ``NSError *`` argument to the
completion handler is non-null.
- ``__attribute__((swift_async_error(none)))``, specifies that the async method
cannot fail.
For instance:
.. code-block:: objc
@interface MyClass : NSObject
-(void)asyncMethod:(void (^)(char, int, float))handler
__attribute__((swift_async(swift_private, 1)))
__attribute__((swift_async_error(zero_argument, 2)));
@end
Here, the ``swift_async`` attribute specifies that ``handler`` is the completion
handler for this method, and the ``swift_async_error`` attribute specifies that
the ``int`` parameter is the one that represents the error.
}];
}
def SuppressDocs : Documentation {
let Category = DocCatStmt;
let Content = [{
@@ -4526,6 +4758,26 @@ the old mangled name and the new code will use the new mangled name with tags.
}];
}
def BuiltinAliasDocs : Documentation {
let Category = DocCatFunction;
let Heading = "clang::builtin_alias, clang_builtin_alias";
let Content = [{
This attribute is used in the implementation of the C intrinsics.
It allows the C intrinsic functions to be declared using the names defined
in target builtins, and still be recognized as clang builtins equivalent to the
underlying name. For example, ``riscv_vector.h`` declares the function ``vadd``
with ``__attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))``.
This ensures that both functions are recognized as that clang builtin,
and in the latter case, the choice of which builtin to identify the
function as can be deferred until after overload resolution.
This attribute can only be used to set up the aliases for certain ARM/RISC-V
C intrinsic functions; it is intended for use only inside ``arm_*.h`` and
``riscv_*.h`` and is not a general mechanism for declaring arbitrary aliases
for clang builtin functions.
}];
}
def PreferredNameDocs : Documentation {
let Category = DocCatDecl;
let Content = [{
@@ -4714,6 +4966,9 @@ def PatchableFunctionEntryDocs : Documentation {
before the function entry and N-M NOPs after the function entry. This attribute
takes precedence over the command line option ``-fpatchable-function-entry=N,M``.
``M`` defaults to 0 if omitted.
This attribute is only supported on
aarch64/aarch64-be/riscv32/riscv64/i386/x86-64 targets.
}];
}
@@ -5517,6 +5772,10 @@ This attribute can only be used to set up the aliases for certain Arm
intrinsic functions; it is intended for use only inside ``arm_*.h``
and is not a general mechanism for declaring arbitrary aliases for
clang builtin functions.
In order to avoid duplicating the attribute definitions for similar
purpose for other architecture, there is a general form for the
attribute `clang_builtin_alias`.
}];
}
@@ -5557,6 +5816,31 @@ once.
}];
}
def UsingIfExistsDocs : Documentation {
let Category = DocCatDecl;
let Content = [{
The ``using_if_exists`` attribute applies to a using-declaration. It allows
programmers to import a declaration that potentially does not exist, instead
deferring any errors to the point of use. For instance:
.. code-block:: c++
namespace empty_namespace {};
__attribute__((using_if_exists))
using empty_namespace::does_not_exist; // no error!
does_not_exist x; // error: use of unresolved 'using_if_exists'
The C++ spelling of the attribte (`[[clang::using_if_exists]]`) is also
supported as a clang extension, since ISO C++ doesn't support attributes in this
position. If the entity referred to by the using-declaration is found by name
lookup, the attribute has no effect. This attribute is useful for libraries
(primarily, libc++) that wish to redeclare a set of declarations in another
namespace, when the availability of those declarations is difficult or
impossible to detect at compile time with the preprocessor.
}];
}
def HandleDocs : DocumentationCategory<"Handle Attributes"> {
let Content = [{
Handles are a way to identify resources like files, sockets, and processes.
@@ -155,6 +155,12 @@ class AttributeCommonInfo {
bool isC2xAttribute() const { return SyntaxUsed == AS_C2x; }
/// The attribute is spelled [[]] in either C or C++ mode, including standard
/// attributes spelled with a keyword, like alignas.
bool isStandardAttributeSyntax() const {
return isCXX11Attribute() || isC2xAttribute();
}
bool isKeywordAttribute() const {
return SyntaxUsed == AS_Keyword || SyntaxUsed == AS_ContextSensitiveKeyword;
}
@@ -24,7 +24,8 @@
// c -> char
// s -> short
// i -> int
// h -> half
// h -> half (__fp16, OpenCL)
// x -> half (_Float16)
// f -> float
// d -> double
// z -> size_t
@@ -529,6 +530,7 @@ BUILTIN(__builtin_rotateright32, "UZiUZiUZi", "nc")
BUILTIN(__builtin_rotateright64, "UWiUWiUWi", "nc")
// Random GCC builtins
BUILTIN(__builtin_calloc, "v*zz", "nF")
BUILTIN(__builtin_constant_p, "i.", "nctu")
BUILTIN(__builtin_classify_type, "i.", "nctu")
BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc")
@@ -542,6 +544,8 @@ BUILTIN(__builtin_bcmp, "ivC*vC*z", "Fn")
BUILTIN(__builtin_bcopy, "vv*v*z", "n")
BUILTIN(__builtin_bzero, "vv*z", "nF")
BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:")
BUILTIN(__builtin_free, "vv*", "nF")
BUILTIN(__builtin_malloc, "v*z", "nF")
BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
@@ -577,6 +581,7 @@ BUILTIN(__builtin_wmemchr, "w*wC*wz", "nF")
BUILTIN(__builtin_wmemcmp, "iwC*wC*z", "nF")
BUILTIN(__builtin_wmemcpy, "w*w*wC*z", "nF")
BUILTIN(__builtin_wmemmove, "w*w*wC*z", "nF")
BUILTIN(__builtin_realloc, "v*v*z", "nF")
BUILTIN(__builtin_return_address, "v*IUi", "n")
BUILTIN(__builtin_extract_return_addr, "v*v*", "n")
BUILTIN(__builtin_frame_address, "v*IUi", "n")
@@ -586,8 +591,9 @@ BUILTIN(__builtin_longjmp, "vv**i", "r")
BUILTIN(__builtin_unwind_init, "v", "")
BUILTIN(__builtin_eh_return_data_regno, "iIi", "nc")
BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
BUILTIN(__builtin_sprintf, "ic*cC*.", "nFP:1:")
BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
BUILTIN(__builtin_thread_pointer, "v*", "nc")
BUILTIN(__builtin_launder, "v*v*", "nt")
LANGBUILTIN(__builtin_is_constant_evaluated, "b", "n", CXX_LANG)
@@ -975,6 +981,8 @@ LIBBUILTIN(strtol, "LicC*c**i", "f", "stdlib.h", ALL_LANGUAGES)
LIBBUILTIN(strtoll, "LLicC*c**i", "f", "stdlib.h", ALL_LANGUAGES)
LIBBUILTIN(strtoul, "ULicC*c**i", "f", "stdlib.h", ALL_LANGUAGES)
LIBBUILTIN(strtoull, "ULLicC*c**i", "f", "stdlib.h", ALL_LANGUAGES)
// C11 stdlib.h
LIBBUILTIN(aligned_alloc, "v*zz", "f", "stdlib.h", ALL_LANGUAGES)
// C99 string.h
LIBBUILTIN(memcpy, "v*v*vC*z", "f", "string.h", ALL_LANGUAGES)
LIBBUILTIN(memcmp, "ivC*vC*z", "f", "string.h", ALL_LANGUAGES)
@@ -1056,6 +1064,8 @@ LIBBUILTIN(longjmp, "vJi", "frT", "setjmp.h", ALL_LANGUAGES)
// all languages, because losing this attribute would result in miscompilation
// when these functions are used in non-GNU mode. PR16138.
LIBBUILTIN(alloca, "v*z", "f", "stdlib.h", ALL_GNU_LANGUAGES)
// POSIX malloc.h
LIBBUILTIN(memalign, "v*zz", "f", "malloc.h", ALL_GNU_LANGUAGES)
// POSIX string.h
LIBBUILTIN(memccpy, "v*v*vC*iz", "f", "string.h", ALL_GNU_LANGUAGES)
LIBBUILTIN(mempcpy, "v*v*vC*z", "f", "string.h", ALL_GNU_LANGUAGES)
@@ -1568,22 +1578,22 @@ BUILTIN(__builtin_nontemporal_store, "v.", "t")
BUILTIN(__builtin_nontemporal_load, "v.", "t")
// Coroutine intrinsics.
BUILTIN(__builtin_coro_resume, "vv*", "")
BUILTIN(__builtin_coro_destroy, "vv*", "")
BUILTIN(__builtin_coro_done, "bv*", "n")
BUILTIN(__builtin_coro_promise, "v*v*IiIb", "n")
LANGBUILTIN(__builtin_coro_resume, "vv*", "", COR_LANG)
LANGBUILTIN(__builtin_coro_destroy, "vv*", "", COR_LANG)
LANGBUILTIN(__builtin_coro_done, "bv*", "n", COR_LANG)
LANGBUILTIN(__builtin_coro_promise, "v*v*IiIb", "n", COR_LANG)
BUILTIN(__builtin_coro_size, "z", "n")
BUILTIN(__builtin_coro_frame, "v*", "n")
BUILTIN(__builtin_coro_noop, "v*", "n")
BUILTIN(__builtin_coro_free, "v*v*", "n")
LANGBUILTIN(__builtin_coro_size, "z", "n", COR_LANG)
LANGBUILTIN(__builtin_coro_frame, "v*", "n", COR_LANG)
LANGBUILTIN(__builtin_coro_noop, "v*", "n", COR_LANG)
LANGBUILTIN(__builtin_coro_free, "v*v*", "n", COR_LANG)
BUILTIN(__builtin_coro_id, "v*Iiv*v*v*", "n")
BUILTIN(__builtin_coro_alloc, "b", "n")
BUILTIN(__builtin_coro_begin, "v*v*", "n")
BUILTIN(__builtin_coro_end, "bv*Ib", "n")
BUILTIN(__builtin_coro_suspend, "cIb", "n")
BUILTIN(__builtin_coro_param, "bv*v*", "n")
LANGBUILTIN(__builtin_coro_id, "v*Iiv*v*v*", "n", COR_LANG)
LANGBUILTIN(__builtin_coro_alloc, "b", "n", COR_LANG)
LANGBUILTIN(__builtin_coro_begin, "v*v*", "n", COR_LANG)
LANGBUILTIN(__builtin_coro_end, "bv*Ib", "n", COR_LANG)
LANGBUILTIN(__builtin_coro_suspend, "cIb", "n", COR_LANG)
LANGBUILTIN(__builtin_coro_param, "bv*v*", "n", COR_LANG)
// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
// We need the generic prototype, since the packet type could be anything.
@@ -1636,8 +1646,8 @@ LANGBUILTIN(__builtin_load_halff, "fhC*", "nc", ALL_OCLC_LANGUAGES)
BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
// OpenMP 4.0
LANGBUILTIN(omp_is_initial_device, "i", "nc", OMP_LANG)
// CUDA/HIP
LANGBUILTIN(__builtin_get_device_side_mangled_name, "cC*.", "ncT", CUDA_LANG)
// Builtins for XRay
BUILTIN(__xray_customevent, "vcC*z", "")
@@ -1648,6 +1658,9 @@ BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
BUILTIN(__builtin_ms_va_end, "vc*&", "n")
BUILTIN(__builtin_ms_va_copy, "vc*&c*&", "n")
// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
LANGBUILTIN(__arithmetic_fence, "v.", "t", ALL_LANGUAGES)
#undef BUILTIN
#undef LIBBUILTIN
#undef LANGBUILTIN
@@ -36,6 +36,8 @@ enum LanguageID {
OCLC20_LANG = 0x20, // builtin for OpenCL C 2.0 only.
OCLC1X_LANG = 0x40, // builtin for OpenCL C 1.x only.
OMP_LANG = 0x80, // builtin requires OpenMP.
CUDA_LANG = 0x100, // builtin requires CUDA.
COR_LANG = 0x200, // builtin requires use of 'fcoroutine-ts' option.
ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages.
ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG, // builtin requires GNU mode.
ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG, // builtin requires MS mode.
@@ -178,10 +180,6 @@ class Context {
strchr(getRecord(ID).Type, 'A') != nullptr;
}
/// Completely forget that the given ID was ever considered a builtin,
/// e.g., because the user provided a conflicting signature.
void forgetBuiltin(unsigned ID, IdentifierTable &Table);
/// If this is a library function that comes from a specific
/// header, retrieve that header name.
const char *getHeaderName(unsigned ID) const {
@@ -99,6 +99,20 @@ BUILTIN(__builtin_arm_tcommit, "v", "n")
BUILTIN(__builtin_arm_tcancel, "vWUIi", "n")
BUILTIN(__builtin_arm_ttest, "WUi", "nc")
// Armv8.5-A FP rounding intrinsics
BUILTIN(__builtin_arm_frint32zf, "ff", "")
BUILTIN(__builtin_arm_frint32z, "dd", "")
BUILTIN(__builtin_arm_frint64zf, "ff", "")
BUILTIN(__builtin_arm_frint64z, "dd", "")
BUILTIN(__builtin_arm_frint32xf, "ff", "")
BUILTIN(__builtin_arm_frint32x, "dd", "")
BUILTIN(__builtin_arm_frint64xf, "ff", "")
BUILTIN(__builtin_arm_frint64x, "dd", "")
// Armv8.5-A Random number generation intrinsics
BUILTIN(__builtin_arm_rndr, "iWUi*", "n")
BUILTIN(__builtin_arm_rndrrs, "iWUi*", "n")
// Armv8.7-A load/store 64-byte intrinsics
BUILTIN(__builtin_arm_ld64b, "vvC*WUi*", "n")
BUILTIN(__builtin_arm_st64b, "vv*WUiC*", "n")
@@ -9,6 +9,11 @@
// This file defines the AMDGPU-specific builtin function database. Users of
// this file must define the BUILTIN macro to make use of this information.
//
// Note: (unsigned) long int type should be avoided in builtin definitions
// since it has different size on Linux (64 bit) and Windows (32 bit).
// (unsigned) long long int type should also be avoided, which is 64 bit for
// C/C++/HIP but is 128 bit for OpenCL. Use `W` as width modifier in builtin
// definitions since it is fixed for 64 bit.
//===----------------------------------------------------------------------===//
// The format of this database matches clang/Basic/Builtins.def.
@@ -44,12 +49,14 @@ BUILTIN(__builtin_amdgcn_grid_size_z, "Ui", "nc")
BUILTIN(__builtin_amdgcn_mbcnt_hi, "UiUiUi", "nc")
BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc")
TARGET_BUILTIN(__builtin_amdgcn_s_memtime, "WUi", "n", "s-memtime-inst")
//===----------------------------------------------------------------------===//
// Instruction builtins.
//===----------------------------------------------------------------------===//
BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n")
BUILTIN(__builtin_amdgcn_s_setreg, "vIiUi", "n")
BUILTIN(__builtin_amdgcn_s_getpc, "LUi", "n")
BUILTIN(__builtin_amdgcn_s_getpc, "WUi", "n")
BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")
BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n")
@@ -63,6 +70,7 @@ BUILTIN(__builtin_amdgcn_ds_gws_sema_v, "vUi", "n")
BUILTIN(__builtin_amdgcn_ds_gws_sema_br, "vUiUi", "n")
BUILTIN(__builtin_amdgcn_ds_gws_sema_p, "vUi", "n")
BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n")
BUILTIN(__builtin_amdgcn_groupstaticsize, "Ui", "n")
BUILTIN(__builtin_amdgcn_atomic_inc32, "UZiUZiD*UZiUicC*", "n")
BUILTIN(__builtin_amdgcn_atomic_inc64, "UWiUWiD*UWiUicC*", "n")
@@ -105,16 +113,15 @@ BUILTIN(__builtin_amdgcn_cubeid, "ffff", "nc")
BUILTIN(__builtin_amdgcn_cubesc, "ffff", "nc")
BUILTIN(__builtin_amdgcn_cubetc, "ffff", "nc")
BUILTIN(__builtin_amdgcn_cubema, "ffff", "nc")
BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n")
BUILTIN(__builtin_amdgcn_s_sleep, "vIi", "n")
BUILTIN(__builtin_amdgcn_s_incperflevel, "vIi", "n")
BUILTIN(__builtin_amdgcn_s_decperflevel, "vIi", "n")
BUILTIN(__builtin_amdgcn_uicmp, "LUiUiUiIi", "nc")
BUILTIN(__builtin_amdgcn_uicmpl, "LUiLUiLUiIi", "nc")
BUILTIN(__builtin_amdgcn_sicmp, "LUiiiIi", "nc")
BUILTIN(__builtin_amdgcn_sicmpl, "LUiLiLiIi", "nc")
BUILTIN(__builtin_amdgcn_fcmp, "LUiddIi", "nc")
BUILTIN(__builtin_amdgcn_fcmpf, "LUiffIi", "nc")
BUILTIN(__builtin_amdgcn_uicmp, "WUiUiUiIi", "nc")
BUILTIN(__builtin_amdgcn_uicmpl, "WUiWUiWUiIi", "nc")
BUILTIN(__builtin_amdgcn_sicmp, "WUiiiIi", "nc")
BUILTIN(__builtin_amdgcn_sicmpl, "WUiWiWiIi", "nc")
BUILTIN(__builtin_amdgcn_fcmp, "WUiddIi", "nc")
BUILTIN(__builtin_amdgcn_fcmpf, "WUiffIi", "nc")
BUILTIN(__builtin_amdgcn_ds_swizzle, "iiIi", "nc")
BUILTIN(__builtin_amdgcn_ds_permute, "iii", "nc")
BUILTIN(__builtin_amdgcn_ds_bpermute, "iii", "nc")
@@ -140,9 +147,9 @@ BUILTIN(__builtin_amdgcn_sad_u8, "UiUiUiUi", "nc")
BUILTIN(__builtin_amdgcn_msad_u8, "UiUiUiUi", "nc")
BUILTIN(__builtin_amdgcn_sad_hi_u8, "UiUiUiUi", "nc")
BUILTIN(__builtin_amdgcn_sad_u16, "UiUiUiUi", "nc")
BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "LUiLUiUiLUi", "nc")
BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "LUiLUiUiLUi", "nc")
BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiLUiUiV4Ui", "nc")
BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "WUiWUiUiWUi", "nc")
BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc")
BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc")
//===----------------------------------------------------------------------===//
// CI+ only builtins.
@@ -177,10 +184,11 @@ TARGET_BUILTIN(__builtin_amdgcn_frexp_manth, "hh", "nc", "16-bit-insts")
TARGET_BUILTIN(__builtin_amdgcn_frexp_exph, "sh", "nc", "16-bit-insts")
TARGET_BUILTIN(__builtin_amdgcn_fracth, "hh", "nc", "16-bit-insts")
TARGET_BUILTIN(__builtin_amdgcn_classh, "bhi", "nc", "16-bit-insts")
TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime")
TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "WUi", "n", "s-memrealtime")
TARGET_BUILTIN(__builtin_amdgcn_mov_dpp, "iiIiIiIiIb", "nc", "dpp")
TARGET_BUILTIN(__builtin_amdgcn_update_dpp, "iiiIiIiIiIb", "nc", "dpp")
TARGET_BUILTIN(__builtin_amdgcn_s_dcache_wb, "v", "n", "gfx8-insts")
TARGET_BUILTIN(__builtin_amdgcn_perm, "UiUiUiUi", "nc", "gfx8-insts")
//===----------------------------------------------------------------------===//
// GFX9+ only builtins.
@@ -192,13 +200,13 @@ TARGET_BUILTIN(__builtin_amdgcn_fmed3h, "hhhh", "nc", "gfx9-insts")
// Deep learning builtins.
//===----------------------------------------------------------------------===//
TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot2-insts")
TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot7-insts")
TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dot2-insts")
TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dot2-insts")
TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dot1-insts")
TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dot2-insts")
TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dot7-insts")
TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dot1-insts")
TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dot2-insts")
TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dot7-insts")
//===----------------------------------------------------------------------===//
// GFX10+ only builtins.
@@ -207,10 +215,21 @@ TARGET_BUILTIN(__builtin_amdgcn_permlane16, "UiUiUiUiUiIbIb", "nc", "gfx10-insts
TARGET_BUILTIN(__builtin_amdgcn_permlanex16, "UiUiUiUiUiIbIb", "nc", "gfx10-insts")
TARGET_BUILTIN(__builtin_amdgcn_mov_dpp8, "UiUiIUi", "nc", "gfx10-insts")
//===----------------------------------------------------------------------===//
// Raytracing builtins.
// By default the 1st argument is i32 and the 4/5-th arguments are float4.
// Postfix l indicates the 1st argument is i64.
// Postfix h indicates the 4/5-th arguments are half4.
//===----------------------------------------------------------------------===//
TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray, "V4UiUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_h, "V4UiUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")
TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_l, "V4UiWUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_lh, "V4UiWUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")
//===----------------------------------------------------------------------===//
// Special builtins.
//===----------------------------------------------------------------------===//
BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc")
BUILTIN(__builtin_amdgcn_read_exec, "WUi", "nc")
BUILTIN(__builtin_amdgcn_read_exec_lo, "Ui", "nc")
BUILTIN(__builtin_amdgcn_read_exec_hi, "Ui", "nc")
@@ -258,5 +277,13 @@ TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x2bf16, "V4fV2sV2sV4fIiIiIi", "nc",
TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x4bf16, "V16fV2sV2sV16fIiIiIi", "nc", "mai-insts")
TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x8bf16, "V4fV2sV2sV4fIiIiIi", "nc", "mai-insts")
TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x4bf16_1k, "V32fV4sV4sV32fIiIiIi", "nc", "mai-insts")
TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x4bf16_1k, "V16fV4sV4sV16fIiIiIi", "nc", "mai-insts")
TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x4bf16_1k, "V4fV4sV4sV4fIiIiIi", "nc", "mai-insts")
TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x8bf16_1k, "V16fV4sV4sV16fIiIiIi", "nc", "mai-insts")
TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x16bf16_1k, "V4fV4sV4sV4fIiIiIi", "nc", "mai-insts")
TARGET_BUILTIN(__builtin_amdgcn_mfma_f64_16x16x4f64, "V4dddV4dIiIiIi", "nc", "mai-insts")
TARGET_BUILTIN(__builtin_amdgcn_mfma_f64_4x4x4f64, "ddddIiIiIi", "nc", "mai-insts")
#undef BUILTIN
#undef TARGET_BUILTIN
@@ -17,8 +17,10 @@
# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
#endif
#pragma push_macro("V68")
#define V68 "v68"
#pragma push_macro("V67")
#define V67 "v67"
#define V67 "v67|" V68
#pragma push_macro("V66")
#define V66 "v66|" V67
#pragma push_macro("V65")
@@ -32,8 +34,10 @@
#pragma push_macro("V5")
#define V5 "v5|" V55
#pragma push_macro("HVXV68")
#define HVXV68 "hvxv68"
#pragma push_macro("HVXV67")
#define HVXV67 "hvxv67"
#define HVXV67 "hvxv67|" HVXV68
#pragma push_macro("HVXV66")
#define HVXV66 "hvxv66|" HVXV67
#pragma push_macro("HVXV65")
@@ -123,6 +127,7 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", "
#pragma pop_macro("HVXV65")
#pragma pop_macro("HVXV66")
#pragma pop_macro("HVXV67")
#pragma pop_macro("HVXV68")
#pragma pop_macro("V5")
#pragma pop_macro("V55")
@@ -131,6 +136,7 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", "
#pragma pop_macro("V65")
#pragma pop_macro("V66")
#pragma pop_macro("V67")
#pragma pop_macro("V68")
#undef BUILTIN
#undef TARGET_BUILTIN
File diff suppressed because it is too large Load Diff
@@ -8,66 +8,68 @@
// Automatically generated file, do not edit!
//===----------------------------------------------------------------------===//
CUSTOM_BUILTIN_MAPPING(M2_mpysmi, 0)
CUSTOM_BUILTIN_MAPPING(A2_add, 0)
CUSTOM_BUILTIN_MAPPING(A2_addi, 0)
CUSTOM_BUILTIN_MAPPING(A2_addp, 0)
CUSTOM_BUILTIN_MAPPING(A2_and, 0)
CUSTOM_BUILTIN_MAPPING(A2_andir, 0)
CUSTOM_BUILTIN_MAPPING(A2_neg, 0)
CUSTOM_BUILTIN_MAPPING(A2_not, 0)
CUSTOM_BUILTIN_MAPPING(A2_or, 0)
CUSTOM_BUILTIN_MAPPING(A2_orir, 0)
CUSTOM_BUILTIN_MAPPING(A2_sub, 0)
CUSTOM_BUILTIN_MAPPING(A2_subp, 0)
CUSTOM_BUILTIN_MAPPING(A2_subri, 0)
CUSTOM_BUILTIN_MAPPING(A2_sxtb, 0)
CUSTOM_BUILTIN_MAPPING(A2_sxth, 0)
CUSTOM_BUILTIN_MAPPING(A2_xor, 0)
CUSTOM_BUILTIN_MAPPING(A2_zxtb, 0)
CUSTOM_BUILTIN_MAPPING(A2_zxth, 0)
CUSTOM_BUILTIN_MAPPING(M2_dpmpyss_s0, 0)
CUSTOM_BUILTIN_MAPPING(M2_dpmpyuu_s0, 0)
CUSTOM_BUILTIN_MAPPING(M2_mpyi, 0)
CUSTOM_BUILTIN_MAPPING(M2_mpysmi, 0)
CUSTOM_BUILTIN_MAPPING(M2_mpyui, 0)
CUSTOM_BUILTIN_MAPPING(A2_add, 0)
CUSTOM_BUILTIN_MAPPING(A2_sub, 0)
CUSTOM_BUILTIN_MAPPING(A2_addi, 0)
CUSTOM_BUILTIN_MAPPING(A2_addp, 0)
CUSTOM_BUILTIN_MAPPING(A2_subp, 0)
CUSTOM_BUILTIN_MAPPING(A2_neg, 0)
CUSTOM_BUILTIN_MAPPING(A2_zxtb, 0)
CUSTOM_BUILTIN_MAPPING(A2_sxtb, 0)
CUSTOM_BUILTIN_MAPPING(A2_zxth, 0)
CUSTOM_BUILTIN_MAPPING(A2_sxth, 0)
CUSTOM_BUILTIN_MAPPING(A2_and, 0)
CUSTOM_BUILTIN_MAPPING(A2_or, 0)
CUSTOM_BUILTIN_MAPPING(A2_xor, 0)
CUSTOM_BUILTIN_MAPPING(A2_not, 0)
CUSTOM_BUILTIN_MAPPING(A2_subri, 0)
CUSTOM_BUILTIN_MAPPING(A2_andir, 0)
CUSTOM_BUILTIN_MAPPING(A2_orir, 0)
CUSTOM_BUILTIN_MAPPING(S2_asr_i_r, 0)
CUSTOM_BUILTIN_MAPPING(S2_lsr_i_r, 0)
CUSTOM_BUILTIN_MAPPING(S2_asl_i_p, 0)
CUSTOM_BUILTIN_MAPPING(S2_asl_i_r, 0)
CUSTOM_BUILTIN_MAPPING(S2_asr_i_p, 0)
CUSTOM_BUILTIN_MAPPING(S2_asr_i_r, 0)
CUSTOM_BUILTIN_MAPPING(S2_lsr_i_p, 0)
CUSTOM_BUILTIN_MAPPING(S2_asl_i_p, 0)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai, 64)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai_128B, 128)
CUSTOM_BUILTIN_MAPPING(S2_lsr_i_r, 0)
CUSTOM_BUILTIN_MAPPING(V6_pred_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_and_n, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_and_n_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_not, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_not_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_or_n, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_or_n_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_nqpred_ai, 64)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_nqpred_ai_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai, 64)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_nqpred_ai, 64)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_nqpred_ai_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddbq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddbq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubbq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubbq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai, 64)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai, 64)
CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddbnq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddbnq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubbnq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubbnq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddhq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddhq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubhq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubhq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddbq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddbq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddhnq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddhnq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubhnq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubhnq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddhq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddhq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddwnq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddwnq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubwnq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubwnq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vandqrt, 64)
CUSTOM_BUILTIN_MAPPING(V6_vandqrt_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vandqrt_acc, 64)
@@ -76,46 +78,6 @@ CUSTOM_BUILTIN_MAPPING(V6_vandvrt, 64)
CUSTOM_BUILTIN_MAPPING(V6_vandvrt_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vandvrt_acc, 64)
CUSTOM_BUILTIN_MAPPING(V6_vandvrt_acc_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtw, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqw, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqw_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqw_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqw_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqw_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqw_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqw_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqw_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgth, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgth_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgth_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgth_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgth_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgth_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgth_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgth_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqh, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqh_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqh_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqh_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqh_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqh_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqh_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqh_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtb, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqb, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqb_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqb_and, 64)
@@ -124,22 +86,38 @@ CUSTOM_BUILTIN_MAPPING(V6_veqb_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqb_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqb_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqb_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqh, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqh_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqh_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqh_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqh_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqh_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqh_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqh_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqw, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqw_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqw_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqw_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqw_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqw_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_veqw_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_veqw_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtb, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtb_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgth, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgth_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgth_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgth_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgth_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgth_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgth_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgth_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtub, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtub_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtub_and, 64)
@@ -148,59 +126,81 @@ CUSTOM_BUILTIN_MAPPING(V6_vgtub_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtub_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtub_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtub_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_not, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_not_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_and_n, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_and_n_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_or_n, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_or_n_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtw, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_and, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_and_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_or, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_or_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vmux, 64)
CUSTOM_BUILTIN_MAPPING(V6_vmux_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubbnq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubbnq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubbq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubbq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubhnq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubhnq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubhq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubhq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubwnq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubwnq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vswap, 64)
CUSTOM_BUILTIN_MAPPING(V6_vswap_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_shuffeqh, 64)
CUSTOM_BUILTIN_MAPPING(V6_shuffeqh_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_shuffeqw, 64)
CUSTOM_BUILTIN_MAPPING(V6_shuffeqw_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddcarry, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddcarry_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubcarry, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubcarry_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vandnqrt, 64)
CUSTOM_BUILTIN_MAPPING(V6_vandnqrt_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vandnqrt_acc, 64)
CUSTOM_BUILTIN_MAPPING(V6_vandnqrt_acc_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vandvqv, 64)
CUSTOM_BUILTIN_MAPPING(V6_vandvqv_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vandvnqv, 64)
CUSTOM_BUILTIN_MAPPING(V6_vandvnqv_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2, 64)
CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_shuffeqw, 64)
CUSTOM_BUILTIN_MAPPING(V6_shuffeqw_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_shuffeqh, 64)
CUSTOM_BUILTIN_MAPPING(V6_shuffeqh_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgathermwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgathermwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vandvqv, 64)
CUSTOM_BUILTIN_MAPPING(V6_vandvqv_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vsubcarry, 64)
CUSTOM_BUILTIN_MAPPING(V6_vsubcarry_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgathermhq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgathermhq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgathermhwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgathermhwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vscattermwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vscattermwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vscattermhq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vscattermhq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vgathermwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vgathermwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vprefixqb, 64)
CUSTOM_BUILTIN_MAPPING(V6_vprefixqb_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vprefixqh, 64)
CUSTOM_BUILTIN_MAPPING(V6_vprefixqh_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vprefixqw, 64)
CUSTOM_BUILTIN_MAPPING(V6_vprefixqw_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vscattermhq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vscattermhq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vscattermwq, 64)
CUSTOM_BUILTIN_MAPPING(V6_vscattermwq_128B, 128)
CUSTOM_BUILTIN_MAPPING(V6_vaddcarrysat, 64)
CUSTOM_BUILTIN_MAPPING(V6_vaddcarrysat_128B, 128)
@@ -21,7 +21,9 @@
#pragma push_macro("SM_72")
#pragma push_macro("SM_75")
#pragma push_macro("SM_80")
#define SM_80 "sm_80"
#pragma push_macro("SM_86")
#define SM_86 "sm_86"
#define SM_80 "sm_80|" SM_86
#define SM_75 "sm_75|" SM_80
#define SM_72 "sm_72|" SM_75
#define SM_70 "sm_70|" SM_72
@@ -35,7 +37,11 @@
#pragma push_macro("PTX64")
#pragma push_macro("PTX65")
#pragma push_macro("PTX70")
#define PTX70 "ptx70"
#pragma push_macro("PTX71")
#pragma push_macro("PTX72")
#define PTX72 "ptx72"
#define PTX71 "ptx71|" PTX72
#define PTX70 "ptx70|" PTX71
#define PTX65 "ptx65|" PTX70
#define PTX64 "ptx64|" PTX65
#define PTX63 "ptx63|" PTX64
@@ -450,12 +456,45 @@ TARGET_BUILTIN(__nvvm_match_any_sync_i64, "WiUiWi", "", PTX60)
TARGET_BUILTIN(__nvvm_match_all_sync_i32p, "UiUiUii*", "", PTX60)
TARGET_BUILTIN(__nvvm_match_all_sync_i64p, "WiUiWii*", "", PTX60)
// Redux
TARGET_BUILTIN(__nvvm_redux_sync_add, "iii", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_redux_sync_min, "iii", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_redux_sync_max, "iii", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_redux_sync_umin, "UiUii", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_redux_sync_umax, "UiUii", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_redux_sync_and, "iii", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_redux_sync_xor, "iii", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_redux_sync_or, "iii", "", AND(SM_80,PTX70))
// Membar
BUILTIN(__nvvm_membar_cta, "v", "")
BUILTIN(__nvvm_membar_gl, "v", "")
BUILTIN(__nvvm_membar_sys, "v", "")
// mbarrier
TARGET_BUILTIN(__nvvm_mbarrier_init, "vWi*i", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_init_shared, "vWi*3i", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_inval, "vWi*", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_inval_shared, "vWi*3", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_arrive, "WiWi*", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_arrive_shared, "WiWi*3", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_arrive_noComplete, "WiWi*i", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_arrive_noComplete_shared, "WiWi*3i", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop, "WiWi*", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop_shared, "WiWi*3", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop_noComplete, "WiWi*i", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_arrive_drop_noComplete_shared, "WiWi*3i", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_test_wait, "bWi*Wi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_test_wait_shared, "bWi*3Wi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_mbarrier_pending_count, "iWi", "", AND(SM_80,PTX70))
// Memcpy, Memset
BUILTIN(__nvvm_memcpy, "vUc*Uc*zi","")
@@ -685,6 +724,7 @@ TARGET_BUILTIN(__hmma_m8n32k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX
TARGET_BUILTIN(__bmma_m8n8k128_ld_a_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63))
TARGET_BUILTIN(__bmma_m8n8k128_ld_b_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63))
TARGET_BUILTIN(__bmma_m8n8k128_ld_c, "vi*iC*UiIi", "", AND(SM_75,PTX63))
TARGET_BUILTIN(__bmma_m8n8k128_mma_and_popc_b1, "vi*iC*iC*iC*Ii", "", AND(SM_75,PTX71))
TARGET_BUILTIN(__bmma_m8n8k128_mma_xor_popc_b1, "vi*iC*iC*iC*Ii", "", AND(SM_75,PTX63))
TARGET_BUILTIN(__bmma_m8n8k128_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63))
TARGET_BUILTIN(__imma_m16n16k16_ld_a_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63))
@@ -720,6 +760,44 @@ TARGET_BUILTIN(__imma_m8n8k32_mma_s4, "vi*iC*iC*iC*IiIi", "", AND(SM_75,PTX63))
TARGET_BUILTIN(__imma_m8n8k32_mma_u4, "vi*iC*iC*iC*IiIi", "", AND(SM_75,PTX63))
TARGET_BUILTIN(__imma_m8n8k32_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63))
// Builtins to support double and alternate float WMMA instructions on sm_80
TARGET_BUILTIN(__dmma_m8n8k4_ld_a, "vd*dC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__dmma_m8n8k4_ld_b, "vd*dC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__dmma_m8n8k4_ld_c, "vd*dC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__dmma_m8n8k4_st_c_f64, "vd*dC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__dmma_m8n8k4_mma_f64, "vd*dC*dC*dC*IiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_bf16_m16n16k16_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_bf16_m16n16k16_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_bf16_m16n16k16_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_bf16_m8n32k16_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_bf16_m8n32k16_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_bf16_m8n32k16_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_bf16_m32n8k16_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_bf16_m32n8k16_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_bf16_m32n8k16_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_tf32_m16n16k8_ld_a, "vi*iC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_tf32_m16n16k8_ld_b, "vi*iC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_tf32_m16n16k8_ld_c, "vf*fC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_m16n16k8_st_c_f32, "vf*fC*UiIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__mma_tf32_m16n16k8_mma_f32, "vf*iC*iC*fC*IiIi", "", AND(SM_80,PTX70))
// Async Copy
TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive, "vWi*", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_shared, "vWi*3", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_noinc, "vWi*", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_noinc_shared, "vWi*3", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_4, "vv*3vC*1", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_8, "vv*3vC*1", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_16, "vv*3vC*1", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_cg_shared_global_16, "vv*3vC*1", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_commit_group, "v", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_wait_group, "vIi", "", AND(SM_80,PTX70))
TARGET_BUILTIN(__nvvm_cp_async_wait_all, "v", "", AND(SM_80,PTX70))
#undef BUILTIN
#undef TARGET_BUILTIN
#pragma pop_macro("AND")
@@ -728,9 +806,12 @@ TARGET_BUILTIN(__imma_m8n8k32_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63))
#pragma pop_macro("SM_72")
#pragma pop_macro("SM_75")
#pragma pop_macro("SM_80")
#pragma pop_macro("SM_86")
#pragma pop_macro("PTX60")
#pragma pop_macro("PTX61")
#pragma pop_macro("PTX63")
#pragma pop_macro("PTX64")
#pragma pop_macro("PTX65")
#pragma pop_macro("PTX70")
#pragma pop_macro("PTX71")
#pragma pop_macro("PTX72")
@@ -20,11 +20,131 @@
// MMA builtins that are using their own format documented below.
#if defined(BUILTIN) && !defined(CUSTOM_BUILTIN)
# define CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) BUILTIN(__builtin_##ID, "i.", "t")
# define CUSTOM_BUILTIN(ID, INTR, TYPES, ACCUMULATE) \
BUILTIN(__builtin_##ID, "i.", "t")
#elif defined(CUSTOM_BUILTIN) && !defined(BUILTIN)
# define BUILTIN(ID, TYPES, ATTRS)
#endif
#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) \
CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE)
// XL Compatibility built-ins
BUILTIN(__builtin_ppc_popcntb, "ULiULi", "")
BUILTIN(__builtin_ppc_poppar4, "iUi", "")
BUILTIN(__builtin_ppc_poppar8, "iULLi", "")
BUILTIN(__builtin_ppc_eieio, "v", "")
BUILTIN(__builtin_ppc_iospace_eieio, "v", "")
BUILTIN(__builtin_ppc_isync, "v", "")
BUILTIN(__builtin_ppc_lwsync, "v", "")
BUILTIN(__builtin_ppc_iospace_lwsync, "v", "")
BUILTIN(__builtin_ppc_sync, "v", "")
BUILTIN(__builtin_ppc_iospace_sync, "v", "")
BUILTIN(__builtin_ppc_dcbfl, "vvC*", "")
BUILTIN(__builtin_ppc_dcbflp, "vvC*", "")
BUILTIN(__builtin_ppc_dcbst, "vvC*", "")
BUILTIN(__builtin_ppc_dcbt, "vv*", "")
BUILTIN(__builtin_ppc_dcbtst, "vv*", "")
BUILTIN(__builtin_ppc_dcbz, "vv*", "")
BUILTIN(__builtin_ppc_icbt, "vv*", "")
BUILTIN(__builtin_ppc_fric, "dd", "")
BUILTIN(__builtin_ppc_frim, "dd", "")
BUILTIN(__builtin_ppc_frims, "ff", "")
BUILTIN(__builtin_ppc_frin, "dd", "")
BUILTIN(__builtin_ppc_frins, "ff", "")
BUILTIN(__builtin_ppc_frip, "dd", "")
BUILTIN(__builtin_ppc_frips, "ff", "")
BUILTIN(__builtin_ppc_friz, "dd", "")
BUILTIN(__builtin_ppc_frizs, "ff", "")
BUILTIN(__builtin_ppc_fsel, "dddd", "")
BUILTIN(__builtin_ppc_fsels, "ffff", "")
BUILTIN(__builtin_ppc_frsqrte, "dd", "")
BUILTIN(__builtin_ppc_frsqrtes, "ff", "")
BUILTIN(__builtin_ppc_fsqrt, "dd", "")
BUILTIN(__builtin_ppc_fsqrts, "ff", "")
BUILTIN(__builtin_ppc_compare_and_swap, "iiD*i*i", "")
BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "")
BUILTIN(__builtin_ppc_fetch_and_add, "iiD*i", "")
BUILTIN(__builtin_ppc_fetch_and_addlp, "LiLiD*Li", "")
BUILTIN(__builtin_ppc_fetch_and_and, "UiUiD*Ui", "")
BUILTIN(__builtin_ppc_fetch_and_andlp, "ULiULiD*ULi", "")
BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "")
BUILTIN(__builtin_ppc_fetch_and_orlp, "ULiULiD*ULi", "")
BUILTIN(__builtin_ppc_fetch_and_swap, "UiUiD*Ui", "")
BUILTIN(__builtin_ppc_fetch_and_swaplp, "ULiULiD*ULi", "")
BUILTIN(__builtin_ppc_ldarx, "LiLiD*", "")
BUILTIN(__builtin_ppc_lwarx, "iiD*", "")
BUILTIN(__builtin_ppc_lharx, "isD*", "")
BUILTIN(__builtin_ppc_lbarx, "UiUcD*", "")
BUILTIN(__builtin_ppc_stdcx, "iLiD*Li", "")
BUILTIN(__builtin_ppc_stwcx, "iiD*i", "")
BUILTIN(__builtin_ppc_sthcx, "isD*s", "")
BUILTIN(__builtin_ppc_stbcx, "icD*i", "")
BUILTIN(__builtin_ppc_tdw, "vLLiLLiIUi", "")
BUILTIN(__builtin_ppc_tw, "viiIUi", "")
BUILTIN(__builtin_ppc_trap, "vi", "")
BUILTIN(__builtin_ppc_trapd, "vLi", "")
BUILTIN(__builtin_ppc_fcfid, "dd", "")
BUILTIN(__builtin_ppc_fcfud, "dd", "")
BUILTIN(__builtin_ppc_fctid, "dd", "")
BUILTIN(__builtin_ppc_fctidz, "dd", "")
BUILTIN(__builtin_ppc_fctiw, "dd", "")
BUILTIN(__builtin_ppc_fctiwz, "dd", "")
BUILTIN(__builtin_ppc_fctudz, "dd", "")
BUILTIN(__builtin_ppc_fctuwz, "dd", "")
BUILTIN(__builtin_ppc_swdiv_nochk, "ddd", "")
BUILTIN(__builtin_ppc_swdivs_nochk, "fff", "")
BUILTIN(__builtin_ppc_alignx, "vIivC*", "nc")
BUILTIN(__builtin_ppc_rdlam, "UWiUWiUWiUWIi", "nc")
// Compare
BUILTIN(__builtin_ppc_cmpeqb, "LLiLLiLLi", "")
BUILTIN(__builtin_ppc_cmprb, "iCIiii", "")
BUILTIN(__builtin_ppc_setb, "LLiLLiLLi", "")
BUILTIN(__builtin_ppc_cmpb, "LLiLLiLLi", "")
// Multiply
BUILTIN(__builtin_ppc_mulhd, "LLiLiLi", "")
BUILTIN(__builtin_ppc_mulhdu, "ULLiULiULi", "")
BUILTIN(__builtin_ppc_mulhw, "iii", "")
BUILTIN(__builtin_ppc_mulhwu, "UiUiUi", "")
BUILTIN(__builtin_ppc_maddhd, "LLiLLiLLiLLi", "")
BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "")
BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "")
// Rotate
BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "")
BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "")
BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "")
// load
BUILTIN(__builtin_ppc_load2r, "UiUs*", "")
BUILTIN(__builtin_ppc_load4r, "UiUi*", "")
BUILTIN(__builtin_ppc_load8r, "ULLiULLi*", "")
// store
BUILTIN(__builtin_ppc_store2r, "vUiUs*", "")
BUILTIN(__builtin_ppc_store4r, "vUiUi*", "")
BUILTIN(__builtin_ppc_store8r, "vULLiULLi*", "")
BUILTIN(__builtin_ppc_extract_exp, "Uid", "")
BUILTIN(__builtin_ppc_extract_sig, "ULLid", "")
BUILTIN(__builtin_ppc_mtfsb0, "vUIi", "")
BUILTIN(__builtin_ppc_mtfsb1, "vUIi", "")
BUILTIN(__builtin_ppc_mtfsf, "vUIiUi", "")
BUILTIN(__builtin_ppc_mtfsfi, "vUIiUIi", "")
BUILTIN(__builtin_ppc_insert_exp, "ddULLi", "")
BUILTIN(__builtin_ppc_fmsub, "dddd", "")
BUILTIN(__builtin_ppc_fmsubs, "ffff", "")
BUILTIN(__builtin_ppc_fnmadd, "dddd", "")
BUILTIN(__builtin_ppc_fnmadds, "ffff", "")
BUILTIN(__builtin_ppc_fnmsub, "dddd", "")
BUILTIN(__builtin_ppc_fnmsubs, "ffff", "")
BUILTIN(__builtin_ppc_fre, "dd", "")
BUILTIN(__builtin_ppc_fres, "ff", "")
BUILTIN(__builtin_ppc_dcbtstt, "vv*", "")
BUILTIN(__builtin_ppc_dcbtt, "vv*", "")
BUILTIN(__builtin_ppc_mftbu, "Ui","")
BUILTIN(__builtin_ppc_mfmsr, "Ui", "")
BUILTIN(__builtin_ppc_mfspr, "ULiIi", "")
BUILTIN(__builtin_ppc_mtmsr, "vUi", "")
BUILTIN(__builtin_ppc_mtspr, "vIiULi", "")
BUILTIN(__builtin_ppc_stfiw, "viC*d", "")
BUILTIN(__builtin_ppc_get_timebase, "ULLi", "n")
// This is just a placeholder, the types and attributes are wrong.
@@ -39,6 +159,7 @@ BUILTIN(__builtin_altivec_vadduws, "V4UiV4UiV4Ui", "")
BUILTIN(__builtin_altivec_vaddeuqm, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","")
BUILTIN(__builtin_altivec_vaddcuq, "V1ULLLiV1ULLLiV1ULLLi","")
BUILTIN(__builtin_altivec_vaddecuq, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","")
BUILTIN(__builtin_altivec_vadduqm, "V1ULLLiV16UcV16Uc","")
BUILTIN(__builtin_altivec_vsubsbs, "V16ScV16ScV16Sc", "")
BUILTIN(__builtin_altivec_vsububs, "V16UcV16UcV16Uc", "")
@@ -49,6 +170,7 @@ BUILTIN(__builtin_altivec_vsubuws, "V4UiV4UiV4Ui", "")
BUILTIN(__builtin_altivec_vsubeuqm, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","")
BUILTIN(__builtin_altivec_vsubcuq, "V1ULLLiV1ULLLiV1ULLLi","")
BUILTIN(__builtin_altivec_vsubecuq, "V1ULLLiV1ULLLiV1ULLLiV1ULLLi","")
BUILTIN(__builtin_altivec_vsubuqm, "V1ULLLiV16UcV16Uc","")
BUILTIN(__builtin_altivec_vavgsb, "V16ScV16ScV16Sc", "")
BUILTIN(__builtin_altivec_vavgub, "V16UcV16UcV16Uc", "")
@@ -75,11 +197,11 @@ BUILTIN(__builtin_altivec_vexptefp, "V4fV4f", "")
BUILTIN(__builtin_altivec_vrfim, "V4fV4f", "")
BUILTIN(__builtin_altivec_lvx, "V4iivC*", "")
BUILTIN(__builtin_altivec_lvxl, "V4iivC*", "")
BUILTIN(__builtin_altivec_lvebx, "V16civC*", "")
BUILTIN(__builtin_altivec_lvehx, "V8sivC*", "")
BUILTIN(__builtin_altivec_lvewx, "V4iivC*", "")
BUILTIN(__builtin_altivec_lvx, "V4iLivC*", "")
BUILTIN(__builtin_altivec_lvxl, "V4iLivC*", "")
BUILTIN(__builtin_altivec_lvebx, "V16cLivC*", "")
BUILTIN(__builtin_altivec_lvehx, "V8sLivC*", "")
BUILTIN(__builtin_altivec_lvewx, "V4iLivC*", "")
BUILTIN(__builtin_altivec_vlogefp, "V4fV4f", "")
@@ -131,11 +253,11 @@ BUILTIN(__builtin_altivec_vpkudum, "V4UiV2ULLiV2ULLi", "")
BUILTIN(__builtin_altivec_vperm_4si, "V4iV4iV4iV16Uc", "")
BUILTIN(__builtin_altivec_stvx, "vV4iiv*", "")
BUILTIN(__builtin_altivec_stvxl, "vV4iiv*", "")
BUILTIN(__builtin_altivec_stvebx, "vV16civ*", "")
BUILTIN(__builtin_altivec_stvehx, "vV8siv*", "")
BUILTIN(__builtin_altivec_stvewx, "vV4iiv*", "")
BUILTIN(__builtin_altivec_stvx, "vV4iLiv*", "")
BUILTIN(__builtin_altivec_stvxl, "vV4iLiv*", "")
BUILTIN(__builtin_altivec_stvebx, "vV16cLiv*", "")
BUILTIN(__builtin_altivec_stvehx, "vV8sLiv*", "")
BUILTIN(__builtin_altivec_stvewx, "vV4iLiv*", "")
BUILTIN(__builtin_altivec_vcmpbfp, "V4iV4fV4f", "")
@@ -437,13 +559,13 @@ BUILTIN(__builtin_altivec_vrlqnm, "V1ULLLiV1ULLLiV1ULLLi", "")
// VSX built-ins.
BUILTIN(__builtin_vsx_lxvd2x, "V2divC*", "")
BUILTIN(__builtin_vsx_lxvw4x, "V4iivC*", "")
BUILTIN(__builtin_vsx_lxvd2x, "V2dLivC*", "")
BUILTIN(__builtin_vsx_lxvw4x, "V4iLivC*", "")
BUILTIN(__builtin_vsx_lxvd2x_be, "V2dSLLivC*", "")
BUILTIN(__builtin_vsx_lxvw4x_be, "V4iSLLivC*", "")
BUILTIN(__builtin_vsx_stxvd2x, "vV2div*", "")
BUILTIN(__builtin_vsx_stxvw4x, "vV4iiv*", "")
BUILTIN(__builtin_vsx_stxvd2x, "vV2dLiv*", "")
BUILTIN(__builtin_vsx_stxvw4x, "vV4iLiv*", "")
BUILTIN(__builtin_vsx_stxvd2x_be, "vV2dSLLivC*", "")
BUILTIN(__builtin_vsx_stxvw4x_be, "vV4iSLLivC*", "")
@@ -451,6 +573,8 @@ BUILTIN(__builtin_vsx_lxvl, "V4ivC*ULLi", "")
BUILTIN(__builtin_vsx_lxvll, "V4ivC*ULLi", "")
BUILTIN(__builtin_vsx_stxvl, "vV4iv*ULLi", "")
BUILTIN(__builtin_vsx_stxvll, "vV4iv*ULLi", "")
BUILTIN(__builtin_vsx_ldrmb, "V16UcCc*Ii", "")
BUILTIN(__builtin_vsx_strmb, "vCc*IiV16Uc", "")
BUILTIN(__builtin_vsx_xvmaxdp, "V2dV2dV2d", "")
BUILTIN(__builtin_vsx_xvmaxsp, "V4fV4fV4f", "")
@@ -544,6 +668,8 @@ BUILTIN(__builtin_vsx_xvxsigsp, "V4UiV4f", "")
// Conversion builtins
BUILTIN(__builtin_vsx_xvcvdpsxws, "V4SiV2d", "")
BUILTIN(__builtin_vsx_xvcvdpuxws, "V4UiV2d", "")
BUILTIN(__builtin_vsx_xvcvspsxds, "V2SLLiV4f", "")
BUILTIN(__builtin_vsx_xvcvspuxds, "V2ULLiV4f", "")
BUILTIN(__builtin_vsx_xvcvsxwdp, "V2dV4Si", "")
BUILTIN(__builtin_vsx_xvcvuxwdp, "V2dV4Ui", "")
BUILTIN(__builtin_vsx_xvcvspdp, "V2dV4f", "")
@@ -596,6 +722,12 @@ BUILTIN(__builtin_truncf128_round_to_odd, "dLLd", "")
BUILTIN(__builtin_vsx_scalar_extract_expq, "ULLiLLd", "")
BUILTIN(__builtin_vsx_scalar_insert_exp_qp, "LLdLLdULLi", "")
// Fastmath by default builtins
BUILTIN(__builtin_ppc_rsqrtf, "V4fV4f", "")
BUILTIN(__builtin_ppc_rsqrtd, "V2dV2d", "")
BUILTIN(__builtin_ppc_recipdivf, "V4fV4fV4f", "")
BUILTIN(__builtin_ppc_recipdivd, "V2dV2dV2d", "")
// HTM builtins
BUILTIN(__builtin_tbegin, "UiUIi", "")
BUILTIN(__builtin_tend, "UiUIi", "")
@@ -664,90 +796,103 @@ BUILTIN(__builtin_dcbf, "vvC*", "")
// Because these built-ins rely on target-dependent types and to avoid pervasive
// change, they are type checked manually in Sema using custom type descriptors.
// The first argument of the CUSTOM_BUILTIN macro is the name of the built-in
// with its prefix, the second argument specifies the type of the function
// with its prefix, the second argument is the name of the intrinsic this
// built-in generates, the third argument specifies the type of the function
// (result value, then each argument) as follows:
// i -> Unsigned integer followed by the greatest possible value for that
// argument or 0 if no constraint on the value.
// (e.g. i15 for a 4-bits value)
// V -> Vector type used with MMA builtins (vector unsigned char)
// V -> Vector type used with MMA built-ins (vector unsigned char)
// W -> PPC Vector type followed by the size of the vector type.
// (e.g. W512 for __vector_quad)
// any other descriptor -> Fall back to generic type descriptor decoding.
// The 'C' suffix can be used as a suffix to specify the const type.
// The '*' suffix can be used as a suffix to specify a pointer to a type.
// The third argument is set to true if the builtin accumulates its result into
// The fourth argument is set to true if the built-in accumulates its result into
// its given accumulator.
CUSTOM_BUILTIN(vsx_lxvp, "W256SLLiW256C*", false)
CUSTOM_BUILTIN(vsx_stxvp, "vW256SLLiW256C*", false)
CUSTOM_BUILTIN(vsx_assemble_pair, "vW256*VV", false)
CUSTOM_BUILTIN(vsx_disassemble_pair, "vv*W256*", false)
// Provided builtins with _mma_ prefix for compatibility.
CUSTOM_BUILTIN(mma_lxvp, vsx_lxvp, "W256SLLiW256C*", false)
CUSTOM_BUILTIN(mma_stxvp, vsx_stxvp, "vW256SLLiW256C*", false)
CUSTOM_BUILTIN(mma_assemble_pair, vsx_assemble_pair, "vW256*VV", false)
CUSTOM_BUILTIN(mma_disassemble_pair, vsx_disassemble_pair, "vv*W256*", false)
CUSTOM_BUILTIN(mma_assemble_acc, "vW512*VVVV", false)
CUSTOM_BUILTIN(mma_disassemble_acc, "vv*W512*", false)
CUSTOM_BUILTIN(mma_xxmtacc, "vW512*", true)
CUSTOM_BUILTIN(mma_xxmfacc, "vW512*", true)
CUSTOM_BUILTIN(mma_xxsetaccz, "vW512*", false)
CUSTOM_BUILTIN(mma_xvi4ger8, "vW512*VV", false)
CUSTOM_BUILTIN(mma_xvi8ger4, "vW512*VV", false)
CUSTOM_BUILTIN(mma_xvi16ger2, "vW512*VV", false)
CUSTOM_BUILTIN(mma_xvi16ger2s, "vW512*VV", false)
CUSTOM_BUILTIN(mma_xvf16ger2, "vW512*VV", false)
CUSTOM_BUILTIN(mma_xvf32ger, "vW512*VV", false)
CUSTOM_BUILTIN(mma_xvf64ger, "vW512*W256V", false)
CUSTOM_BUILTIN(mma_pmxvi4ger8, "vW512*VVi15i15i255", false)
CUSTOM_BUILTIN(mma_pmxvi8ger4, "vW512*VVi15i15i15", false)
CUSTOM_BUILTIN(mma_pmxvi16ger2, "vW512*VVi15i15i3", false)
CUSTOM_BUILTIN(mma_pmxvi16ger2s, "vW512*VVi15i15i3", false)
CUSTOM_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3", false)
CUSTOM_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15", false)
CUSTOM_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3", false)
CUSTOM_BUILTIN(mma_xvi4ger8pp, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvi8ger4pp, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvi8ger4spp, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvi16ger2pp, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvi16ger2spp, "vW512*VV", true)
CUSTOM_BUILTIN(mma_pmxvi4ger8pp, "vW512*VVi15i15i255", true)
CUSTOM_BUILTIN(mma_pmxvi8ger4pp, "vW512*VVi15i15i15", true)
CUSTOM_BUILTIN(mma_pmxvi8ger4spp, "vW512*VVi15i15i15", true)
CUSTOM_BUILTIN(mma_pmxvi16ger2pp, "vW512*VVi15i15i3", true)
CUSTOM_BUILTIN(mma_pmxvi16ger2spp, "vW512*VVi15i15i3", true)
CUSTOM_BUILTIN(mma_xvf16ger2pp, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvf16ger2pn, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvf16ger2np, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvf16ger2nn, "vW512*VV", true)
CUSTOM_BUILTIN(mma_pmxvf16ger2pp, "vW512*VVi15i15i3", true)
CUSTOM_BUILTIN(mma_pmxvf16ger2pn, "vW512*VVi15i15i3", true)
CUSTOM_BUILTIN(mma_pmxvf16ger2np, "vW512*VVi15i15i3", true)
CUSTOM_BUILTIN(mma_pmxvf16ger2nn, "vW512*VVi15i15i3", true)
CUSTOM_BUILTIN(mma_xvf32gerpp, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvf32gerpn, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvf32gernp, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvf32gernn, "vW512*VV", true)
CUSTOM_BUILTIN(mma_pmxvf32gerpp, "vW512*VVi15i15", true)
CUSTOM_BUILTIN(mma_pmxvf32gerpn, "vW512*VVi15i15", true)
CUSTOM_BUILTIN(mma_pmxvf32gernp, "vW512*VVi15i15", true)
CUSTOM_BUILTIN(mma_pmxvf32gernn, "vW512*VVi15i15", true)
CUSTOM_BUILTIN(mma_xvf64gerpp, "vW512*W256V", true)
CUSTOM_BUILTIN(mma_xvf64gerpn, "vW512*W256V", true)
CUSTOM_BUILTIN(mma_xvf64gernp, "vW512*W256V", true)
CUSTOM_BUILTIN(mma_xvf64gernn, "vW512*W256V", true)
CUSTOM_BUILTIN(mma_pmxvf64gerpp, "vW512*W256Vi15i3", true)
CUSTOM_BUILTIN(mma_pmxvf64gerpn, "vW512*W256Vi15i3", true)
CUSTOM_BUILTIN(mma_pmxvf64gernp, "vW512*W256Vi15i3", true)
CUSTOM_BUILTIN(mma_pmxvf64gernn, "vW512*W256Vi15i3", true)
CUSTOM_BUILTIN(mma_xvbf16ger2, "vW512*VV", false)
CUSTOM_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3", false)
CUSTOM_BUILTIN(mma_xvbf16ger2pp, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvbf16ger2pn, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvbf16ger2np, "vW512*VV", true)
CUSTOM_BUILTIN(mma_xvbf16ger2nn, "vW512*VV", true)
CUSTOM_BUILTIN(mma_pmxvbf16ger2pp, "vW512*VVi15i15i3", true)
CUSTOM_BUILTIN(mma_pmxvbf16ger2pn, "vW512*VVi15i15i3", true)
CUSTOM_BUILTIN(mma_pmxvbf16ger2np, "vW512*VVi15i15i3", true)
CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true)
// UNALIASED_CUSTOM_BUILTIN macro is used for built-ins that have
// the same name as that of the intrinsic they generate, i.e. the
// ID and INTR are the same.
// This avoids repeating the ID and INTR in the macro expression.
UNALIASED_CUSTOM_BUILTIN(vsx_lxvp, "W256SLLiW256C*", false)
UNALIASED_CUSTOM_BUILTIN(vsx_stxvp, "vW256SLLiW256C*", false)
UNALIASED_CUSTOM_BUILTIN(vsx_assemble_pair, "vW256*VV", false)
UNALIASED_CUSTOM_BUILTIN(vsx_disassemble_pair, "vv*W256*", false)
UNALIASED_CUSTOM_BUILTIN(mma_assemble_acc, "vW512*VVVV", false)
UNALIASED_CUSTOM_BUILTIN(mma_disassemble_acc, "vv*W512*", false)
UNALIASED_CUSTOM_BUILTIN(mma_xxmtacc, "vW512*", true)
UNALIASED_CUSTOM_BUILTIN(mma_xxmfacc, "vW512*", true)
UNALIASED_CUSTOM_BUILTIN(mma_xxsetaccz, "vW512*", false)
UNALIASED_CUSTOM_BUILTIN(mma_xvi4ger8, "vW512*VV", false)
UNALIASED_CUSTOM_BUILTIN(mma_xvi8ger4, "vW512*VV", false)
UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2, "vW512*VV", false)
UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2s, "vW512*VV", false)
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2, "vW512*VV", false)
UNALIASED_CUSTOM_BUILTIN(mma_xvf32ger, "vW512*VV", false)
UNALIASED_CUSTOM_BUILTIN(mma_xvf64ger, "vW512*W256V", false)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi4ger8, "vW512*VVi15i15i255", false)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi8ger4, "vW512*VVi15i15i15", false)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2, "vW512*VVi15i15i3", false)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2s, "vW512*VVi15i15i3", false)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3", false)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15", false)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3", false)
UNALIASED_CUSTOM_BUILTIN(mma_xvi4ger8pp, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvi8ger4pp, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvi8ger4spp, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2pp, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2spp, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi4ger8pp, "vW512*VVi15i15i255", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi8ger4pp, "vW512*VVi15i15i15", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi8ger4spp, "vW512*VVi15i15i15", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2pp, "vW512*VVi15i15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2spp, "vW512*VVi15i15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pp, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pn, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2np, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2nn, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pp, "vW512*VVi15i15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pn, "vW512*VVi15i15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2np, "vW512*VVi15i15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2nn, "vW512*VVi15i15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpp, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpn, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernp, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernn, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpp, "vW512*VVi15i15", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpn, "vW512*VVi15i15", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gernp, "vW512*VVi15i15", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gernn, "vW512*VVi15i15", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf64gerpp, "vW512*W256V", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf64gerpn, "vW512*W256V", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf64gernp, "vW512*W256V", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvf64gernn, "vW512*W256V", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gerpp, "vW512*W256Vi15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gerpn, "vW512*W256Vi15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gernp, "vW512*W256Vi15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gernn, "vW512*W256Vi15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2, "vW512*VV", false)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3", false)
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2pp, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2pn, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2np, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2nn, "vW512*VV", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pp, "vW512*VVi15i15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pn, "vW512*VVi15i15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2np, "vW512*VVi15i15i3", true)
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true)
// FIXME: Obviously incomplete.
#undef BUILTIN
#undef CUSTOM_BUILTIN
#undef UNALIASED_CUSTOM_BUILTIN
@@ -0,0 +1,63 @@
//==- BuiltinsRISCV.def - RISC-V Builtin function database -------*- C++ -*-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the RISC-V-specific builtin function database. Users of
// this file must define the BUILTIN macro to make use of this information.
//
//===----------------------------------------------------------------------===//
#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
#endif
#include "clang/Basic/riscv_vector_builtins.inc"
// Zbb extension
TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb,64bit")
// Zbc extension
TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "experimental-zbc")
TARGET_BUILTIN(__builtin_riscv_clmulh, "LiLiLi", "nc", "experimental-zbc")
TARGET_BUILTIN(__builtin_riscv_clmulr, "LiLiLi", "nc", "experimental-zbc")
// Zbe extension
TARGET_BUILTIN(__builtin_riscv_bcompress_32, "ZiZiZi", "nc", "experimental-zbe")
TARGET_BUILTIN(__builtin_riscv_bcompress_64, "WiWiWi", "nc",
"experimental-zbe,64bit")
TARGET_BUILTIN(__builtin_riscv_bdecompress_32, "ZiZiZi", "nc",
"experimental-zbe")
TARGET_BUILTIN(__builtin_riscv_bdecompress_64, "WiWiWi", "nc",
"experimental-zbe,64bit")
// Zbp extension
TARGET_BUILTIN(__builtin_riscv_grev_32, "ZiZiZi", "nc", "experimental-zbp")
TARGET_BUILTIN(__builtin_riscv_grev_64, "WiWiWi", "nc", "experimental-zbp,64bit")
TARGET_BUILTIN(__builtin_riscv_gorc_32, "ZiZiZi", "nc", "experimental-zbp")
TARGET_BUILTIN(__builtin_riscv_gorc_64, "WiWiWi", "nc", "experimental-zbp,64bit")
TARGET_BUILTIN(__builtin_riscv_shfl_32, "ZiZiZi", "nc", "experimental-zbp")
TARGET_BUILTIN(__builtin_riscv_shfl_64, "WiWiWi", "nc", "experimental-zbp,64bit")
TARGET_BUILTIN(__builtin_riscv_unshfl_32, "ZiZiZi", "nc", "experimental-zbp")
TARGET_BUILTIN(__builtin_riscv_unshfl_64, "WiWiWi", "nc", "experimental-zbp,64bit")
TARGET_BUILTIN(__builtin_riscv_xperm_n, "LiLiLi", "nc", "experimental-zbp")
TARGET_BUILTIN(__builtin_riscv_xperm_b, "LiLiLi", "nc", "experimental-zbp")
TARGET_BUILTIN(__builtin_riscv_xperm_h, "LiLiLi", "nc", "experimental-zbp")
TARGET_BUILTIN(__builtin_riscv_xperm_w, "WiWiWi", "nc", "experimental-zbp,64bit")
// Zbr extension
TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")
TARGET_BUILTIN(__builtin_riscv_crc32_w, "LiLi", "nc", "experimental-zbr")
TARGET_BUILTIN(__builtin_riscv_crc32c_b, "LiLi", "nc", "experimental-zbr")
TARGET_BUILTIN(__builtin_riscv_crc32c_h, "LiLi", "nc", "experimental-zbr")
TARGET_BUILTIN(__builtin_riscv_crc32c_w, "LiLi", "nc", "experimental-zbr")
TARGET_BUILTIN(__builtin_riscv_crc32_d, "LiLi", "nc", "experimental-zbr")
TARGET_BUILTIN(__builtin_riscv_crc32c_d, "LiLi", "nc", "experimental-zbr")
#undef BUILTIN
#undef TARGET_BUILTIN
@@ -291,5 +291,12 @@ TARGET_BUILTIN(__builtin_s390_vlbrh, "V8UsV8Us", "nc", "vector")
TARGET_BUILTIN(__builtin_s390_vlbrf, "V4UiV4Ui", "nc", "vector")
TARGET_BUILTIN(__builtin_s390_vlbrg, "V2ULLiV2ULLi", "nc", "vector")
// NNP-assist facility intrinsics.
TARGET_BUILTIN(__builtin_s390_vclfnhs, "V4fV8UsIi", "nc", "nnp-assist")
TARGET_BUILTIN(__builtin_s390_vclfnls, "V4fV8UsIi", "nc", "nnp-assist")
TARGET_BUILTIN(__builtin_s390_vcrnfs, "V8UsV4fV4fIi", "nc", "nnp-assist")
TARGET_BUILTIN(__builtin_s390_vcfn, "V8UsV8UsIi", "nc", "nnp-assist")
TARGET_BUILTIN(__builtin_s390_vcnf, "V8UsV8UsIi", "nc", "nnp-assist")
#undef BUILTIN
#undef TARGET_BUILTIN
@@ -66,37 +66,22 @@ TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f64, "LLid", "nc", "nontrappi
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, "LLid", "nc", "nontrapping-fptoint")
// SIMD builtins
TARGET_BUILTIN(__builtin_wasm_swizzle_v8x16, "V16ScV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_swizzle_i8x16, "V16ScV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i8x16, "iV16ScIi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_u_i8x16, "iV16UcIUi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i16x8, "iV8sIi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_u_i16x8, "iV8UsIUi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_i32x4, "iV4iIi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_i64x2, "LLiV2LLiIi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_f32x4, "fV4fIi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_f64x2, "dV2dIi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_add_sat_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_add_sat_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_add_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_add_sat_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_replace_lane_i8x16, "V16ScV16ScIii", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_replace_lane_i16x8, "V8sV8sIii", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_replace_lane_i32x4, "V4iV4iIii", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_replace_lane_i64x2, "V2LLiV2LLiIiLLi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_replace_lane_f32x4, "V4fV4fIif", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_replace_lane_f64x2, "V2dV2dIid", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_add_saturate_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_add_saturate_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_add_saturate_s_i16x8, "V8sV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_add_saturate_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i16x8, "V8sV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sub_sat_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sub_sat_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sub_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sub_sat_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_abs_i8x16, "V16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_abs_i16x8, "V8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_abs_i32x4, "V4iV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_abs_i64x2, "V2LLiV2LLi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_min_s_i8x16, "V16ScV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_min_u_i8x16, "V16UcV16UcV16Uc", "nc", "simd128")
@@ -116,22 +101,7 @@ TARGET_BUILTIN(__builtin_wasm_avgr_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_popcnt_i8x16, "V16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_q15mulr_saturate_s_i16x8, "V8sV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_low_i8x16_s_i16x8, "V8sV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_high_i8x16_s_i16x8, "V8sV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_low_i8x16_u_i16x8, "V8UsV16UcV16Uc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_high_i8x16_u_i16x8, "V8UsV16UcV16Uc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_low_i16x8_s_i32x4, "V4iV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_high_i16x8_s_i32x4, "V4iV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_low_i16x8_u_i32x4, "V4UiV8UsV8Us", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_high_i16x8_u_i32x4, "V4UiV8UsV8Us", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_low_i32x4_s_i64x2, "V2LLiV4iV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_high_i32x4_s_i64x2, "V2LLiV4iV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_low_i32x4_u_i64x2, "V2ULLiV4UiV4Ui", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extmul_high_i32x4_u_i64x2, "V2ULLiV4UiV4Ui", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_q15mulr_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i8x16_s_i16x8, "V8sV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i8x16_u_i16x8, "V8UsV16Uc", "nc", "simd128")
@@ -141,21 +111,13 @@ TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i16x8_u_i32x4, "V4UiV8Us", "nc", "
TARGET_BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_signselect_i8x16, "V16ScV16ScV16ScV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_signselect_i16x8, "V8sV8sV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_signselect_i32x4, "V4iV4iV4iV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_signselect_i64x2, "V2LLiV2LLiV2LLiV2LLi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_shuffle_i8x16, "V16ScV16ScV16ScIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_shuffle_v8x16, "V16ScV16ScV16ScIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_any_true_i8x16, "iV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_any_true_i16x8, "iV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_any_true_i32x4, "iV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_any_true_i64x2, "iV2LLi", "nc", "unimplemented-simd128")
TARGET_BUILTIN(__builtin_wasm_any_true_v128, "iV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_all_true_i8x16, "iV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_all_true_i16x8, "iV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_all_true_i32x4, "iV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_all_true_i64x2, "iV2LLi", "nc", "unimplemented-simd128")
TARGET_BUILTIN(__builtin_wasm_all_true_i64x2, "iV2LLi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_bitmask_i8x16, "iV16Sc", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_bitmask_i16x8, "iV8s", "nc", "simd128")
@@ -167,12 +129,8 @@ TARGET_BUILTIN(__builtin_wasm_abs_f64x2, "V2dV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_min_f32x4, "V4fV4fV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_max_f32x4, "V4fV4fV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_pmin_f32x4, "V4fV4fV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_pmax_f32x4, "V4fV4fV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_min_f64x2, "V2dV2dV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_max_f64x2, "V2dV2dV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_pmin_f64x2, "V2dV2dV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_pmax_f64x2, "V2dV2dV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_ceil_f32x4, "V4fV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_floor_f32x4, "V4fV4f", "nc", "simd128")
@@ -188,47 +146,16 @@ TARGET_BUILTIN(__builtin_wasm_dot_s_i32x4_i16x8, "V4iV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sqrt_f32x4, "V4fV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sqrt_f64x2, "V2dV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_qfma_f32x4, "V4fV4fV4fV4f", "nc", "unimplemented-simd128")
TARGET_BUILTIN(__builtin_wasm_qfms_f32x4, "V4fV4fV4fV4f", "nc", "unimplemented-simd128")
TARGET_BUILTIN(__builtin_wasm_qfma_f64x2, "V2dV2dV2dV2d", "nc", "unimplemented-simd128")
TARGET_BUILTIN(__builtin_wasm_qfms_f64x2, "V2dV2dV2dV2d", "nc", "unimplemented-simd128")
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32x4_f32x4, "V4iV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_narrow_s_i8x16_i16x8, "V16ScV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8UsV8Us", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4iV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_widen_low_s_i32x4_i64x2, "V2LLiV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_widen_high_s_i32x4_i64x2, "V2LLiV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_widen_low_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_widen_high_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_convert_low_s_i32x4_f64x2, "V2dV4i", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_convert_low_u_i32x4_f64x2, "V2dV4Ui", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_zero_u_f64x2_i32x4, "V4UiV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_demote_zero_f64x2_f32x4, "V4fV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_promote_low_f32x4_f64x2, "V2dV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_load8_lane, "V16ScSc*V16ScIi", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_load16_lane, "V8ss*V8sIi", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_load32_lane, "V4ii*V4iIi", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_load64_lane, "V2LLiLLi*V2LLiIi", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_store8_lane, "vSc*V16ScIi", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_store16_lane, "vs*V8sIi", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_store32_lane, "vi*V4iIi", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_store64_lane, "vLLi*V2LLiIi", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_eq_i64x2, "V2LLiV2LLiV2LLi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_prefetch_t, "vv*", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_prefetch_nt, "vv*", "n", "simd128")
TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", "simd128")
#undef BUILTIN
#undef TARGET_BUILTIN
@@ -1878,6 +1878,10 @@ TARGET_BUILTIN(__builtin_ia32_reduce_and_d512, "iV16i", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_and_q512, "OiV8Oi", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_fadd_pd512, "ddV8d", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_fadd_ps512, "ffV16f", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_fmax_pd512, "dV8d", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_fmax_ps512, "fV16f", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_fmin_pd512, "dV8d", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_fmin_ps512, "fV16f", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_fmul_pd512, "ddV8d", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_fmul_ps512, "ffV16f", "ncV:512:", "avx512f")
TARGET_BUILTIN(__builtin_ia32_reduce_mul_d512, "iV16i", "ncV:512:", "avx512f")
@@ -101,10 +101,16 @@ TARGET_BUILTIN(__builtin_ia32_testui, "Uc", "n", "uintr")
TARGET_BUILTIN(__builtin_ia32_senduipi, "vUWi", "n", "uintr")
// AMX internal builtin
TARGET_BUILTIN(__builtin_ia32_tile_loadconfig_internal, "vvC*", "n", "amx-tile")
TARGET_BUILTIN(__builtin_ia32_tileloadd64_internal, "V256iUsUsvC*z", "n", "amx-tile")
TARGET_BUILTIN(__builtin_ia32_tileloaddt164_internal, "V256iUsUsvC*z", "n", "amx-tile")
TARGET_BUILTIN(__builtin_ia32_tdpbssd_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-int8")
TARGET_BUILTIN(__builtin_ia32_tdpbsud_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-int8")
TARGET_BUILTIN(__builtin_ia32_tdpbusd_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-int8")
TARGET_BUILTIN(__builtin_ia32_tdpbuud_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-int8")
TARGET_BUILTIN(__builtin_ia32_tilestored64_internal, "vUsUsv*zV256i", "n", "amx-tile")
TARGET_BUILTIN(__builtin_ia32_tilezero_internal, "V256iUsUs", "n", "amx-tile")
TARGET_BUILTIN(__builtin_ia32_tdpbf16ps_internal, "V256iUsUsUsV256iV256iV256i", "n", "amx-bf16")
// AMX
TARGET_BUILTIN(__builtin_ia32_tile_loadconfig, "vvC*", "n", "amx-tile")
TARGET_BUILTIN(__builtin_ia32_tile_storeconfig, "vvC*", "n", "amx-tile")
@@ -39,9 +39,9 @@ CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) o
CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink
CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe.
CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
CODEGENOPT(IgnoreXCOFFVisibility , 1, 0) ///< -mignore-xcoff-visibility
CODEGENOPT(ControlFlowGuardNoChecks , 1, 0) ///< -cfguard-no-checks
CODEGENOPT(ControlFlowGuard , 1, 0) ///< -cfguard
CODEGENOPT(EHContGuard , 1, 0) ///< -ehcontguard
CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling destructors.
CODEGENOPT(RegisterGlobalDtorsWithAtExit, 1, 1) ///< Use atexit or __cxa_atexit to register global destructors.
CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker
@@ -63,12 +63,17 @@ CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with optnone at O0
CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0) ///< Enables the new, experimental
///< strict floating point.
CODEGENOPT(EnableNoundefAttrs, 1, 0) ///< Enable emitting `noundef` attributes on IR call arguments and return values
CODEGENOPT(LegacyPassManager, 1, 0) ///< Use the legacy pass manager.
CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
CODEGENOPT(DisableRedZone , 1, 0) ///< Set when -mno-red-zone is enabled.
CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
///< each (it means check
///< the original debug info
///< metadata preservation).
CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
///< is specified.
CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls.
@@ -167,7 +172,8 @@ CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain
CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection is enabled.
CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled.
CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is defined.
CODEGENOPT(CorrectlyRoundedDivSqrt, 1, 0) ///< -cl-fp32-correctly-rounded-divide-sqrt
CODEGENOPT(OpenCLCorrectlyRoundedDivSqrt, 1, 0) ///< -cl-fp32-correctly-rounded-divide-sqrt
CODEGENOPT(HIPCorrectlyRoundedDivSqrt, 1, 1) ///< -fno-hip-fp32-correctly-rounded-divide-sqrt
CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal Linkage symbols get unique names.
CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using profile information.
@@ -206,6 +212,10 @@ CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced struct-
CODEGENOPT(SaveTempLabels , 1, 0) ///< Save temporary labels.
CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope detection
///< in AddressSanitizer
ENUM_CODEGENOPT(SanitizeAddressUseAfterReturn,
llvm::AsanDetectStackUseAfterReturnMode, 2,
llvm::AsanDetectStackUseAfterReturnMode::Runtime
) ///< Set detection mode for stack-use-after-return.
CODEGENOPT(SanitizeAddressPoisonCustomArrayCookie, 1,
0) ///< Enable poisoning operator new[] which is not a replaceable
///< global allocation function in AddressSanitizer
@@ -214,6 +224,9 @@ CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead st
CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0) ///< Enable ODR indicator globals
CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
///< MemorySanitizer
ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
llvm::AsanDtorKind::Global) ///< Set how ASan global
///< destructors are emitted.
CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete detection
///< in MemorySanitizer
CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.
@@ -284,7 +297,9 @@ VALUE_CODEGENOPT(StackAlignment , 32, 0) ///< Overrides default stack
///< alignment, if not 0.
VALUE_CODEGENOPT(StackProbeSize , 32, 4096) ///< Overrides default stack
///< probe size, even if 0.
VALUE_CODEGENOPT(WarnStackSize , 32, UINT_MAX) ///< Set via -fwarn-stack-size.
CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
CODEGENOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF info.
CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
///< in debug info.
@@ -332,7 +347,7 @@ ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 4, codegenoptions::NoD
CODEGENOPT(MacroDebugInfo, 1, 0)
/// Tune the debug info for this debugger.
ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 2,
ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 3,
llvm::DebuggerKind::Default)
/// Dwarf version. Version zero indicates to LLVM that no DWARF should be
@@ -362,7 +377,7 @@ ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
VALUE_CODEGENOPT(TLSSize, 8, 0)
/// The default stack protector guard offset to use.
VALUE_CODEGENOPT(StackProtectorGuardOffset, 32, (unsigned)-1)
VALUE_CODEGENOPT(StackProtectorGuardOffset, 32, INT_MAX)
/// Number of path components to strip when emitting checks. (0 == full
/// filename)
@@ -417,6 +432,11 @@ CODEGENOPT(PassByValueIsNoAlias, 1, 0)
/// according to the field declaring type width.
CODEGENOPT(AAPCSBitfieldWidth, 1, 1)
/// Sets the IEEE bit in the expected default floating point mode register.
/// Floating point opcodes that support exception flag gathering quiet and
/// propagate signaling NaN inputs per IEEE 754-2008 (AMDGPU Only)
CODEGENOPT(EmitIEEENaNCompliantInsts, 1, 1)
#undef CODEGENOPT
#undef ENUM_CODEGENOPT
#undef VALUE_CODEGENOPT
@@ -20,6 +20,7 @@
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Regex.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
#include <map>
#include <memory>
#include <string>
@@ -54,11 +55,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
};
enum VectorLibrary {
NoLibrary, // Don't use any vector library.
Accelerate, // Use the Accelerate framework.
LIBMVEC, // GLIBC vector math library.
MASSV, // IBM MASS vector library.
SVML // Intel short vector math library.
NoLibrary, // Don't use any vector library.
Accelerate, // Use the Accelerate framework.
LIBMVEC, // GLIBC vector math library.
MASSV, // IBM MASS vector library.
SVML, // Intel short vector math library.
Darwin_libsystem_m // Use Darwin's libsytem_m vector functions.
};
enum ObjCDispatchMethodKind {
@@ -74,23 +76,6 @@ class CodeGenOptions : public CodeGenOptionsBase {
LocalExecTLSModel
};
/// Clang versions with different platform ABI conformance.
enum class ClangABI {
/// Attempt to be ABI-compatible with code generated by Clang 3.8.x
/// (SVN r257626). This causes <1 x long long> to be passed in an
/// integer register instead of an SSE register on x64_64.
Ver3_8,
/// Attempt to be ABI-compatible with code generated by Clang 4.0.x
/// (SVN r291814). This causes move operations to be ignored when
/// determining whether a class type can be passed or returned directly.
Ver4,
/// Conform to the underlying platform's C and C++ ABIs as closely
/// as we can.
Latest
};
enum StructReturnConventionKind {
SRCK_Default, // No special option was passed.
SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
@@ -172,6 +157,9 @@ class CodeGenOptions : public CodeGenOptionsBase {
/// The string to embed in debug information as the current working directory.
std::string DebugCompilationDir;
/// The string to embed in coverage mapping as the current working directory.
std::string CoverageCompilationDir;
/// The string to embed in the debug information for the compile unit, if
/// non-empty.
std::string DwarfDebugFlags;
@@ -181,11 +169,15 @@ class CodeGenOptions : public CodeGenOptionsBase {
std::string RecordCommandLine;
std::map<std::string, std::string> DebugPrefixMap;
std::map<std::string, std::string> ProfilePrefixMap;
std::map<std::string, std::string> CoveragePrefixMap;
/// The ABI to use for passing floating point arguments.
std::string FloatABI;
/// The file to use for dumping bug report by `Debugify` for original
/// debug info.
std::string DIBugsReportFilePath;
/// The floating-point denormal mode to use.
llvm::DenormalMode FPDenormalMode = llvm::DenormalMode::getIEEE();
@@ -284,27 +276,52 @@ class CodeGenOptions : public CodeGenOptionsBase {
/// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
std::string SymbolPartition;
/// Regular expression to select optimizations for which we should enable
/// optimization remarks. Transformation passes whose name matches this
/// expression (and support this feature), will emit a diagnostic
/// whenever they perform a transformation. This is enabled by the
/// -Rpass=regexp flag.
std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
enum RemarkKind {
RK_Missing, // Remark argument not present on the command line.
RK_Enabled, // Remark enabled via '-Rgroup'.
RK_EnabledEverything, // Remark enabled via '-Reverything'.
RK_Disabled, // Remark disabled via '-Rno-group'.
RK_DisabledEverything, // Remark disabled via '-Rno-everything'.
RK_WithPattern, // Remark pattern specified via '-Rgroup=regexp'.
};
/// Regular expression to select optimizations for which we should enable
/// missed optimization remarks. Transformation passes whose name matches this
/// expression (and support this feature), will emit a diagnostic
/// whenever they tried but failed to perform a transformation. This is
/// enabled by the -Rpass-missed=regexp flag.
std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
/// Optimization remark with an optional regular expression pattern.
struct OptRemark {
RemarkKind Kind;
std::string Pattern;
std::shared_ptr<llvm::Regex> Regex;
/// Regular expression to select optimizations for which we should enable
/// optimization analyses. Transformation passes whose name matches this
/// expression (and support this feature), will emit a diagnostic
/// whenever they want to explain why they decided to apply or not apply
/// a given transformation. This is enabled by the -Rpass-analysis=regexp
/// flag.
std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
/// By default, optimization remark is missing.
OptRemark() : Kind(RK_Missing), Pattern(""), Regex(nullptr) {}
/// Returns true iff the optimization remark holds a valid regular
/// expression.
bool hasValidPattern() const { return Regex != nullptr; }
/// Matches the given string against the regex, if there is some.
bool patternMatches(StringRef String) const {
return hasValidPattern() && Regex->match(String);
}
};
/// Selected optimizations for which we should enable optimization remarks.
/// Transformation passes whose name matches the contained (optional) regular
/// expression (and support this feature), will emit a diagnostic whenever
/// they perform a transformation.
OptRemark OptimizationRemark;
/// Selected optimizations for which we should enable missed optimization
/// remarks. Transformation passes whose name matches the contained (optional)
/// regular expression (and support this feature), will emit a diagnostic
/// whenever they tried but failed to perform a transformation.
OptRemark OptimizationRemarkMissed;
/// Selected optimizations for which we should enable optimization analyses.
/// Transformation passes whose name matches the contained (optional) regular
/// expression (and support this feature), will emit a diagnostic whenever
/// they want to explain why they decided to apply or not apply a given
/// transformation.
OptRemark OptimizationRemarkAnalysis;
/// Set of files defining the rules for the symbol rewriting.
std::vector<std::string> RewriteMapFiles;
@@ -347,14 +364,21 @@ class CodeGenOptions : public CodeGenOptionsBase {
/// other styles we may implement in the future.
std::string StackProtectorGuard;
/// The TLS base register when StackProtectorGuard is "tls".
/// The TLS base register when StackProtectorGuard is "tls", or register used
/// to store the stack canary for "sysreg".
/// On x86 this can be "fs" or "gs".
/// On AArch64 this can only be "sp_el0".
std::string StackProtectorGuardReg;
/// Path to blocklist file specifying which objects
/// Path to ignorelist file specifying which objects
/// (files, functions) listed for instrumentation by sanitizer
/// coverage pass should actually not be instrumented.
std::vector<std::string> SanitizeCoverageBlocklistFiles;
std::vector<std::string> SanitizeCoverageIgnorelistFiles;
/// Name of the stack usage file (i.e., .su file) if user passes
/// -fstack-usage. If empty, it can be implied that -fstack-usage is not
/// passed on the command line.
std::string StackUsageOutput;
/// Executable and command-line used to create a given CompilerInvocation.
/// Most of the time this will be the full -cc1 command.
@@ -386,10 +410,6 @@ class CodeGenOptions : public CodeGenOptionsBase {
CodeGenOptions();
/// Is this a libc/libm function that is no longer recognized as a
/// builtin because a -fno-builtin-* option has been specified?
bool isNoBuiltinFunc(const char *Name) const;
const std::vector<std::string> &getNoBuiltinFuncs() const {
return NoBuiltinFuncs;
}
@@ -432,6 +452,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
bool hasMaybeUnusedDebugInfo() const {
return getDebugInfo() >= codegenoptions::UnusedTypeInfo;
}
// Check if any one of SanitizeCoverage* is enabled.
bool hasSanitizeCoverage() const {
return SanitizeCoverageType || SanitizeCoverageIndirectCalls ||
SanitizeCoverageTraceCmp;
}
};
} // end namespace clang
@@ -29,7 +29,9 @@ enum class CudaVersion {
CUDA_101,
CUDA_102,
CUDA_110,
LATEST = CUDA_110,
CUDA_111,
CUDA_112,
LATEST = CUDA_112,
LATEST_SUPPORTED = CUDA_101,
};
const char *CudaVersionToString(CudaVersion V);
@@ -55,6 +57,7 @@ enum class CudaArch {
SM_72,
SM_75,
SM_80,
SM_86,
GFX600,
GFX601,
GFX602,
@@ -75,14 +78,18 @@ enum class CudaArch {
GFX906,
GFX908,
GFX909,
GFX90a,
GFX90c,
GFX1010,
GFX1011,
GFX1012,
GFX1013,
GFX1030,
GFX1031,
GFX1032,
GFX1033,
GFX1034,
GFX1035,
LAST,
};
@@ -0,0 +1,157 @@
//===--- DarwinSDKInfo.h - SDK Information parser for darwin ----*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_BASIC_DARWIN_SDK_INFO_H
#define LLVM_CLANG_BASIC_DARWIN_SDK_INFO_H
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/Support/VirtualFileSystem.h"
namespace llvm {
namespace json {
class Object;
} // end namespace json
} // end namespace llvm
namespace clang {
/// The information about the darwin SDK that was used during this compilation.
class DarwinSDKInfo {
public:
/// A value that describes two os-environment pairs that can be used as a key
/// to the version map in the SDK.
struct OSEnvPair {
public:
using StorageType = uint64_t;
constexpr OSEnvPair(llvm::Triple::OSType FromOS,
llvm::Triple::EnvironmentType FromEnv,
llvm::Triple::OSType ToOS,
llvm::Triple::EnvironmentType ToEnv)
: Value(((StorageType(FromOS) * StorageType(llvm::Triple::LastOSType) +
StorageType(FromEnv))
<< 32ull) |
(StorageType(ToOS) * StorageType(llvm::Triple::LastOSType) +
StorageType(ToEnv))) {}
/// Returns the os-environment mapping pair that's used to represent the
/// macOS -> Mac Catalyst version mapping.
static inline constexpr OSEnvPair macOStoMacCatalystPair() {
return OSEnvPair(llvm::Triple::MacOSX, llvm::Triple::UnknownEnvironment,
llvm::Triple::IOS, llvm::Triple::MacABI);
}
/// Returns the os-environment mapping pair that's used to represent the
/// Mac Catalyst -> macOS version mapping.
static inline constexpr OSEnvPair macCatalystToMacOSPair() {
return OSEnvPair(llvm::Triple::IOS, llvm::Triple::MacABI,
llvm::Triple::MacOSX, llvm::Triple::UnknownEnvironment);
}
private:
StorageType Value;
friend class DarwinSDKInfo;
};
/// Represents a version mapping that maps from a version of one target to a
/// version of a related target.
///
/// e.g. "macOS_iOSMac":{"10.15":"13.1"} is an example of a macOS -> Mac
/// Catalyst version map.
class RelatedTargetVersionMapping {
public:
RelatedTargetVersionMapping(
VersionTuple MinimumKeyVersion, VersionTuple MaximumKeyVersion,
VersionTuple MinimumValue, VersionTuple MaximumValue,
llvm::DenseMap<VersionTuple, VersionTuple> Mapping)
: MinimumKeyVersion(MinimumKeyVersion),
MaximumKeyVersion(MaximumKeyVersion), MinimumValue(MinimumValue),
MaximumValue(MaximumValue), Mapping(Mapping) {
assert(!this->Mapping.empty() && "unexpected empty mapping");
}
/// Returns the value with the lowest version in the mapping.
const VersionTuple &getMinimumValue() const { return MinimumValue; }
/// Returns the mapped key, or the appropriate Minimum / MaximumValue if
/// they key is outside of the mapping bounds. If they key isn't mapped, but
/// within the minimum and maximum bounds, None is returned.
Optional<VersionTuple> map(const VersionTuple &Key,
const VersionTuple &MinimumValue,
Optional<VersionTuple> MaximumValue) const;
static Optional<RelatedTargetVersionMapping>
parseJSON(const llvm::json::Object &Obj,
VersionTuple MaximumDeploymentTarget);
private:
VersionTuple MinimumKeyVersion;
VersionTuple MaximumKeyVersion;
VersionTuple MinimumValue;
VersionTuple MaximumValue;
llvm::DenseMap<VersionTuple, VersionTuple> Mapping;
};
DarwinSDKInfo(VersionTuple Version, VersionTuple MaximumDeploymentTarget,
llvm::DenseMap<OSEnvPair::StorageType,
Optional<RelatedTargetVersionMapping>>
VersionMappings =
llvm::DenseMap<OSEnvPair::StorageType,
Optional<RelatedTargetVersionMapping>>())
: Version(Version), MaximumDeploymentTarget(MaximumDeploymentTarget),
VersionMappings(std::move(VersionMappings)) {}
const llvm::VersionTuple &getVersion() const { return Version; }
// Returns the optional, target-specific version mapping that maps from one
// target to another target.
//
// This mapping is constructed from an appropriate mapping in the SDKSettings,
// for instance, when building for Mac Catalyst, the mapping would contain the
// "macOS_iOSMac" mapping as it maps the macOS versions to the Mac Catalyst
// versions.
//
// This mapping does not exist when the target doesn't have an appropriate
// related version mapping, or when there was an error reading the mapping
// from the SDKSettings, or when it's missing in the SDKSettings.
const RelatedTargetVersionMapping *getVersionMapping(OSEnvPair Kind) const {
auto Mapping = VersionMappings.find(Kind.Value);
if (Mapping == VersionMappings.end())
return nullptr;
return Mapping->getSecond().hasValue() ? Mapping->getSecond().getPointer()
: nullptr;
}
static Optional<DarwinSDKInfo>
parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj);
private:
VersionTuple Version;
VersionTuple MaximumDeploymentTarget;
// Need to wrap the value in an optional here as the value has to be default
// constructible, and std::unique_ptr doesn't like DarwinSDKInfo being
// Optional as Optional is trying to copy it in emplace.
llvm::DenseMap<OSEnvPair::StorageType, Optional<RelatedTargetVersionMapping>>
VersionMappings;
};
/// Parse the SDK information from the SDKSettings.json file.
///
/// \returns an error if the SDKSettings.json file is invalid, None if the
/// SDK has no SDKSettings.json, or a valid \c DarwinSDKInfo otherwise.
Expected<Optional<DarwinSDKInfo>> parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS,
StringRef SDKRootPath);
} // end namespace clang
#endif // LLVM_CLANG_BASIC_DARWIN_SDK_INFO_H
@@ -37,6 +37,7 @@ enum DebugInfoKind {
/// Limit generated debug info for classes to reduce size. This emits class
/// type info only where the constructor is emitted, if it is a class that
/// has a constructor.
/// FIXME: Consider combining this with LimitedDebugInfo.
DebugInfoConstructor,
/// Limit generated debug info to reduce size (-fno-standalone-debug). This
@@ -71,10 +71,13 @@ def Named : DeclNode<Decl, "named declarations", 1>;
def TemplateTemplateParm : DeclNode<Template>;
def BuiltinTemplate : DeclNode<Template>;
def Concept : DeclNode<Template>;
def Using : DeclNode<Named>;
def BaseUsing : DeclNode<Named, "", 1>;
def Using : DeclNode<BaseUsing>;
def UsingEnum : DeclNode<BaseUsing>;
def UsingPack : DeclNode<Named>;
def UsingShadow : DeclNode<Named>;
def ConstructorUsingShadow : DeclNode<UsingShadow>;
def UnresolvedUsingIfExists : DeclNode<Named>;
def ObjCMethod : DeclNode<Named, "Objective-C methods">, DeclContext;
def ObjCContainer : DeclNode<Named, "Objective-C containers", 1>, DeclContext;
def ObjCCategory : DeclNode<ObjCContainer>;
@@ -273,6 +273,13 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
// Which overload candidates to show.
OverloadsShown ShowOverloads = Ovl_All;
// With Ovl_Best, the number of overload candidates to show when we encounter
// an error.
//
// The value here is the number of candidates to show in the first nontrivial
// error. Future errors may show a different number of candidates.
unsigned NumOverloadsToShow = 32;
// Cap of # errors emitted, 0 -> no limit.
unsigned ErrorLimit = 0;
@@ -707,6 +714,37 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
}
OverloadsShown getShowOverloads() const { return ShowOverloads; }
/// When a call or operator fails, print out up to this many candidate
/// overloads as suggestions.
///
/// With Ovl_Best, we set a high limit for the first nontrivial overload set
/// we print, and a lower limit for later sets. This way the user has a
/// chance of diagnosing at least one callsite in their program without
/// having to recompile with -fshow-overloads=all.
unsigned getNumOverloadCandidatesToShow() const {
switch (getShowOverloads()) {
case Ovl_All:
// INT_MAX rather than UINT_MAX so that we don't have to think about the
// effect of implicit conversions on this value. In practice we'll never
// hit 2^31 candidates anyway.
return std::numeric_limits<int>::max();
case Ovl_Best:
return NumOverloadsToShow;
}
llvm_unreachable("invalid OverloadsShown kind");
}
/// Call this after showing N overload candidates. This influences the value
/// returned by later calls to getNumOverloadCandidatesToShow().
void overloadCandidatesShown(unsigned N) {
// Current heuristic: Start out with a large value for NumOverloadsToShow,
// and then once we print one nontrivially-large overload set, decrease it
// for future calls.
if (N > 4) {
NumOverloadsToShow = 4;
}
}
/// Pretend that the last diagnostic issued was ignored, so any
/// subsequent notes will be suppressed, or restore a prior ignoring
/// state after ignoring some diagnostics and their notes, possibly in
@@ -806,6 +844,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
return FatalErrorOccurred || UnrecoverableErrorOccurred;
}
unsigned getNumErrors() const { return NumErrors; }
unsigned getNumWarnings() const { return NumWarnings; }
void setNumWarnings(unsigned NumWarnings) {
@@ -349,6 +349,8 @@ def note_constexpr_new_delete_mismatch : Note<
"used to delete pointer to "
"%select{array object of type %2|non-array object of type %2|"
"object allocated with 'new'}0}1">;
def note_constexpr_deallocate_null : Note<
"'std::allocator<...>::deallocate' used to delete a null pointer">;
def note_constexpr_delete_subobject : Note<
"delete of pointer%select{ to subobject|}1 '%0' "
"%select{|that does not point to complete object}1">;
@@ -7,4 +7,5 @@
//===----------------------------------------------------------------------===//
class CatInlineAsm : DiagCategory<"Inline Assembly Issue">;
class CatSourceMgr : DiagCategory<"SourceMgr Reported Issue">;
class CatBackend : DiagCategory<"Backend Issue">;
@@ -111,6 +111,8 @@ def err_module_cycle : Error<"cyclic dependency in module '%0': %1">,
DefaultFatal;
def err_module_prebuilt : Error<
"error in loading module '%0' from prebuilt module path">, DefaultFatal;
def err_module_rebuild_finalized : Error<
"cannot rebuild module '%0' as it is already finalized">, DefaultFatal;
def note_pragma_entered_here : Note<"#pragma entered here">;
def note_decl_hiding_tag_type : Note<
"%1 %0 is hidden by a non-type declaration of %0 here">;
@@ -187,6 +189,17 @@ def ext_cxx11_longlong : Extension<
def warn_cxx98_compat_longlong : Warning<
"'long long' is incompatible with C++98">,
InGroup<CXX98CompatPedantic>, DefaultIgnore;
def ext_cxx2b_size_t_suffix : ExtWarn<
"'size_t' suffix for literals is a C++2b extension">,
InGroup<CXX2b>;
def warn_cxx20_compat_size_t_suffix : Warning<
"'size_t' suffix for literals is incompatible with C++ standards before "
"C++2b">, InGroup<CXXPre2bCompat>, DefaultIgnore;
def err_cxx2b_size_t_suffix: Error<
"'size_t' suffix for literals is a C++2b feature">;
def err_size_t_literal_too_large: Error<
"%select{signed |}0'size_t' literal is out of range of possible "
"%select{signed |}0'size_t' values">;
def err_integer_literal_too_large : Error<
"integer literal is too large to be represented in any %select{signed |}0"
"integer type">;
@@ -336,6 +349,8 @@ def warn_ignored_hip_only_option : Warning<
// OpenMP
def err_omp_more_one_clause : Error<
"directive '#pragma omp %0' cannot contain more than one '%1' clause%select{| with '%3' name modifier| with 'source' dependence}2">;
def err_omp_required_clause : Error<
"directive '#pragma omp %0' requires the '%1' clause">;
// Static Analyzer Core
def err_unknown_analyzer_checker_or_package : Error<
@@ -347,4 +362,13 @@ def note_suggest_disabling_all_checkers : Note<
def warn_poison_system_directories : Warning <
"include location '%0' is unsafe for cross-compilation">,
InGroup<DiagGroup<"poison-system-directories">>, DefaultIgnore;
def warn_opencl_unsupported_core_feature : Warning<
"%0 is a core feature in %select{OpenCL C|C++ for OpenCL}1 version %2 but not supported on this target">,
InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore;
def err_opencl_extension_and_feature_differs : Error<
"options %0 and %1 are set to different values">;
def err_opencl_feature_requires : Error<
"feature %0 requires support of %1 feature">;
}
@@ -67,6 +67,8 @@ def err_drv_no_hip_runtime : Error<
"cannot find HIP runtime. Provide its path via --rocm-path, or pass "
"-nogpuinc to build without HIP runtime.">;
def err_drv_undetermined_amdgpu_arch : Error<
"Cannot determine AMDGPU architecture: %0. Consider passing it via --march.">;
def err_drv_cuda_version_unsupported : Error<
"GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), "
"but installation at %3 is %4. Use --cuda-path to specify a different CUDA "
@@ -127,6 +129,10 @@ def err_drv_invalid_Xopenmp_target_with_args : Error<
"invalid -Xopenmp-target argument: '%0', options requiring arguments are unsupported">;
def err_drv_argument_only_allowed_with : Error<
"invalid argument '%0' only allowed with '%1'">;
def err_drv_minws_unsupported_input_type : Error<
"'-fminimize-whitespace' invalid for input of type %0">;
def err_drv_amdgpu_ieee_without_no_honor_nans : Error<
"invalid argument '-mno-amdgpu-ieee' only allowed with relaxed NaN handling">;
def err_drv_argument_not_allowed_with : Error<
"invalid argument '%0' not allowed with '%1'">;
def err_drv_invalid_version_number : Error<
@@ -163,12 +169,12 @@ def err_drv_invalid_libcxx_deployment : Error<
"invalid deployment target for -stdlib=libc++ (requires %0 or later)">;
def err_drv_invalid_argument_to_option : Error<
"invalid argument '%0' to -%1">;
def err_drv_malformed_sanitizer_blacklist : Error<
"malformed sanitizer blacklist: '%0'">;
def err_drv_malformed_sanitizer_ignorelist : Error<
"malformed sanitizer ignorelist: '%0'">;
def err_drv_malformed_sanitizer_coverage_whitelist : Error<
"malformed sanitizer coverage whitelist: '%0'">;
def err_drv_malformed_sanitizer_coverage_blacklist : Error<
"malformed sanitizer coverage blacklist: '%0'">;
def err_drv_malformed_sanitizer_coverage_ignorelist : Error<
"malformed sanitizer coverage ignorelist: '%0'">;
def err_drv_duplicate_config : Error<
"no more than one option '--config' is allowed">;
def err_drv_config_file_not_exist : Error<
@@ -210,12 +216,10 @@ def warn_drv_yc_multiple_inputs_clang_cl : Warning<
"support for '/Yc' with more than one source file not implemented yet; flag ignored">,
InGroup<ClangClPch>;
def err_drv_dllexport_inlines_and_fallback : Error<
"option '/Zc:dllexportInlines-' is ABI-changing and not compatible with '/fallback'">;
def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;
def err_drv_invalid_value_with_suggestion : Error<"invalid value '%1' in '%0','%2'">;
def err_drv_invalid_value_with_suggestion : Error<
"invalid value '%1' in '%0', expected one of: %2">;
def err_drv_invalid_remap_file : Error<
"invalid option '%0' not of the form <from-file>;<to-file>">;
def err_drv_invalid_gcc_output_type : Error<
@@ -229,6 +233,8 @@ def warn_invalid_ios_deployment_target : Warning<
"invalid iOS deployment version '%0', iOS 10 is the maximum deployment "
"target for 32-bit targets">, InGroup<InvalidIOSDeploymentTarget>,
DefaultError;
def err_invalid_macos_32bit_deployment_target : Error<
"32-bit targets are not supported when building for Mac Catalyst">;
def err_drv_conflicting_deployment_targets : Error<
"conflicting deployment targets, both '%0' and '%1' are present in environment">;
def err_arc_unsupported_on_runtime : Error<
@@ -264,8 +270,9 @@ def err_drv_omp_host_target_not_supported : Error<
def err_drv_expecting_fopenmp_with_fopenmp_targets : Error<
"The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading, please use -fopenmp=libomp or -fopenmp=libiomp5.">;
def err_drv_omp_offload_target_missingbcruntime : Error<
"No library '%0' found in the default clang lib directory or in LIBRARY_PATH. Please use --libomptarget-nvptx-bc-path to specify nvptx bitcode library.">;
"No library '%0' found in the default clang lib directory or in LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode library.">;
def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library '%0' does not exist.">;
def err_drv_omp_offload_target_cuda_version_not_support : Error<"NVPTX target requires CUDA 9.2 or above. CUDA %0 is detected.">;
def warn_drv_omp_offload_target_duplicate : Warning<
"The OpenMP offloading target '%0' is similar to target '%1' already specified - will be ignored.">,
InGroup<OpenMPTarget>;
@@ -273,6 +280,10 @@ def err_drv_unsupported_embed_bitcode
: Error<"%0 is not supported with -fembed-bitcode">;
def err_drv_bitcode_unsupported_on_toolchain : Error<
"-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
def err_drv_negative_columns : Error<
"invalid value '%1' in '%0', value must be 'none' or a positive integer">;
def err_drv_small_columns : Error<
"invalid value '%1' in '%0', value must be '%2' or greater">;
def err_drv_invalid_malign_branch_EQ : Error<
"invalid argument '%0' to -malign-branch=; each element must be one of: %1">;
@@ -344,6 +355,10 @@ def warn_drv_disabling_vptr_no_rtti_default : Warning<
def warn_drv_object_size_disabled_O0 : Warning<
"the object size sanitizer has no effect at -O0, but is explicitly enabled: %0">,
InGroup<InvalidCommandLineArgument>, DefaultWarnNoWerror;
def warn_ignoring_verify_debuginfo_preserve_export : Warning<
"ignoring -fverify-debuginfo-preserve-export=%0 because "
"-fverify-debuginfo-preserve wasn't enabled">,
InGroup<UnusedCommandLineArgument>;
def err_invalid_branch_protection: Error <
"invalid branch protection option '%0' in '%1'">;
def err_invalid_sls_hardening : Error<
@@ -392,9 +407,6 @@ def err_test_module_file_extension_format : Error<
"-ftest-module-file-extension argument '%0' is not of the required form "
"'blockname:major:minor:hashed:user info'">;
def warn_drv_invoking_fallback : Warning<"falling back to %0">,
InGroup<Fallback>;
def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
InGroup<DiagGroup<"slash-u-filename">>;
def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as filenames">;
@@ -534,6 +546,15 @@ def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;
def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognized and is not a valid setting.">;
def err_aix_default_altivec_abi : Error<
"The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' for the extended Altivec ABI">;
def err_aix_unsupported_tls_model : Error<"TLS model '%0' is not yet supported on AIX">;
def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">;
def err_unsupported_cxx_abi : Error<"C++ ABI '%0' is not supported on target triple '%1'">;
def note_cc1_round_trip_original : Note<"Original arguments in round-trip: %0">;
def note_cc1_round_trip_generated : Note<"Generated arguments #%0 in round-trip: %1">;
def remark_cc1_round_trip_generated : Remark<"Generated arguments #%0 in round-trip: %1">, InGroup<RoundTripCC1Args>;
def err_cc1_round_trip_fail_then_ok : Error<"Original arguments parse failed, then succeeded in round-trip">;
def err_cc1_round_trip_ok_then_fail : Error<"Generated arguments parse failed in round-trip">;
def err_cc1_round_trip_mismatch : Error<"Generated arguments do not match in round-trip">;
}
@@ -19,13 +19,16 @@ def err_fe_inline_asm : Error<"%0">, CatInlineAsm;
def warn_fe_inline_asm : Warning<"%0">, CatInlineAsm, InGroup<BackendInlineAsm>;
def note_fe_inline_asm : Note<"%0">, CatInlineAsm;
def note_fe_inline_asm_here : Note<"instantiated into assembly here">;
def err_fe_source_mgr : Error<"%0">, CatSourceMgr;
def warn_fe_source_mgr : Warning<"%0">, CatSourceMgr, InGroup<BackendSourceMgr>;
def note_fe_source_mgr : Note<"%0">, CatSourceMgr;
def err_fe_cannot_link_module : Error<"cannot link module '%0': %1">,
DefaultFatal;
def warn_fe_frame_larger_than : Warning<"stack frame size of %0 bytes in %q1">,
BackendInfo, InGroup<BackendFrameLargerThanEQ>;
def warn_fe_frame_larger_than : Warning<"stack frame size (%0) exceeds limit (%1) in %q2">,
BackendInfo, InGroup<BackendFrameLargerThan>;
def warn_fe_backend_frame_larger_than: Warning<"%0">,
BackendInfo, InGroup<BackendFrameLargerThanEQ>;
BackendInfo, InGroup<BackendFrameLargerThan>;
def err_fe_backend_frame_larger_than: Error<"%0">, BackendInfo;
def note_fe_backend_frame_larger_than: Note<"%0">, BackendInfo;
@@ -109,7 +112,7 @@ def err_fe_action_not_available : Error<
def err_fe_invalid_alignment : Error<
"invalid value '%1' in '%0'; alignment must be a power of 2">;
def err_fe_invalid_exception_model
: Error<"invalid exception model '%select{none|dwarf|sjlj|arm|seh|wasm|aix}0' for target '%1'">;
: Error<"invalid exception model '%select{none|sjlj|seh|dwarf|wasm}0' for target '%1'">;
def warn_fe_concepts_ts_flag : Warning<
"-fconcepts-ts is deprecated - use '-std=c++20' for Concepts support">,
InGroup<Deprecated>;
@@ -155,6 +158,8 @@ def err_verify_invalid_no_diags : Error<
"%select{'expected-no-diagnostics' directive|other expected directives}0">;
def err_verify_no_directives : Error<
"no expected directives found: consider use of 'expected-no-diagnostics'">;
def err_verify_nonconst_addrspace : Error<
"qualifier 'const' is needed for variables in address space '%0'">;
def note_fixit_applied : Note<"FIX-IT applied suggested code changes">;
def note_fixit_in_macro : Note<
@@ -162,8 +162,12 @@ def CXX11CompatDeprecatedWritableStr :
def DeprecatedArrayCompare : DiagGroup<"deprecated-array-compare">;
def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">;
def DeprecatedCopy : DiagGroup<"deprecated-copy">;
def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor">;
def DeprecatedCopyWithUserProvidedCopy : DiagGroup<"deprecated-copy-with-user-provided-copy">;
def DeprecatedCopyWithUserProvidedDtor : DiagGroup<"deprecated-copy-with-user-provided-dtor">;
def DeprecatedCopy : DiagGroup<"deprecated-copy", [DeprecatedCopyWithUserProvidedCopy]>;
def DeprecatedCopyWithDtor : DiagGroup<"deprecated-copy-with-dtor", [DeprecatedCopyWithUserProvidedDtor]>;
// For compatibility with GCC.
def : DiagGroup<"deprecated-copy-dtor", [DeprecatedCopyWithDtor]>;
def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
@@ -186,7 +190,7 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion,
DeprecatedAttributes,
DeprecatedCommaSubscript,
DeprecatedCopy,
DeprecatedCopyDtor,
DeprecatedCopyWithDtor,
DeprecatedDeclarations,
DeprecatedDynamicExceptionSpec,
DeprecatedEnumCompare,
@@ -253,17 +257,33 @@ def : DiagGroup<"c++1z-compat-mangling", [CXX17CompatMangling]>;
// Name of this warning in GCC.
def NoexceptType : DiagGroup<"noexcept-type", [CXX17CompatMangling]>;
// Warnings for C++1y code which is not compatible with prior C++ standards.
def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">;
def CXXPre14CompatPedantic : DiagGroup<"c++98-c++11-compat-pedantic",
// Warnings for C code which is not compatible with previous C standards.
def CPre2xCompat : DiagGroup<"pre-c2x-compat">;
def CPre2xCompatPedantic : DiagGroup<"pre-c2x-compat-pedantic",
[CPre2xCompat]>;
// Warnings for C++ code which is not compatible with previous C++ standards.
def CXXPre14Compat : DiagGroup<"pre-c++14-compat">;
def : DiagGroup<"c++98-c++11-compat", [CXXPre14Compat]>;
def CXXPre14CompatPedantic : DiagGroup<"pre-c++14-compat-pedantic",
[CXXPre14Compat,
CXXPre14CompatBinaryLiteral]>;
def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat">;
def CXXPre17CompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
def : DiagGroup<"c++98-c++11-compat-pedantic", [CXXPre14CompatPedantic]>;
def CXXPre17Compat : DiagGroup<"pre-c++17-compat">;
def : DiagGroup<"c++98-c++11-c++14-compat", [CXXPre17Compat]>;
def CXXPre17CompatPedantic : DiagGroup<"pre-c++17-compat-pedantic",
[CXXPre17Compat]>;
def CXXPre20Compat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
def CXXPre20CompatPedantic : DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic",
def : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
[CXXPre17CompatPedantic]>;
def CXXPre20Compat : DiagGroup<"pre-c++20-compat">;
def : DiagGroup<"c++98-c++11-c++14-c++17-compat", [CXXPre20Compat]>;
def CXXPre20CompatPedantic : DiagGroup<"pre-c++20-compat-pedantic",
[CXXPre20Compat]>;
def : DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic",
[CXXPre20CompatPedantic]>;
def CXXPre2bCompat : DiagGroup<"pre-c++2b-compat">;
def CXXPre2bCompatPedantic :
DiagGroup<"pre-c++2b-compat-pedantic", [CXXPre2bCompat]>;
def CXX98CompatBindToTemporaryCopy :
DiagGroup<"c++98-compat-bind-to-temporary-copy">;
@@ -277,7 +297,8 @@ def CXX98Compat : DiagGroup<"c++98-compat",
CXX98CompatUnnamedTypeTemplateArgs,
CXXPre14Compat,
CXXPre17Compat,
CXXPre20Compat]>;
CXXPre20Compat,
CXXPre2bCompat]>;
// Warnings for C++11 features which are Extensions in C++98 mode.
def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
[CXX98Compat,
@@ -285,7 +306,8 @@ def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
CXX98CompatExtraSemi,
CXXPre14CompatPedantic,
CXXPre17CompatPedantic,
CXXPre20CompatPedantic]>;
CXXPre20CompatPedantic,
CXXPre2bCompatPedantic]>;
def CXX11Narrowing : DiagGroup<"c++11-narrowing">;
@@ -314,33 +336,40 @@ def CXX11Compat : DiagGroup<"c++11-compat",
CXX11CompatDeprecatedWritableStr,
CXXPre14Compat,
CXXPre17Compat,
CXXPre20Compat]>;
CXXPre20Compat,
CXXPre2bCompat]>;
def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",
[CXX11Compat,
CXXPre14CompatPedantic,
CXXPre17CompatPedantic,
CXXPre20CompatPedantic]>;
CXXPre20CompatPedantic,
CXXPre2bCompatPedantic]>;
def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre17Compat,
CXXPre20Compat]>;
CXXPre20Compat,
CXXPre2bCompat]>;
def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
[CXX14Compat,
CXXPre17CompatPedantic,
CXXPre20CompatPedantic]>;
CXXPre20CompatPedantic,
CXXPre2bCompatPedantic]>;
def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister,
DeprecatedIncrementBool,
CXX17CompatMangling,
CXXPre20Compat]>;
CXXPre20Compat,
CXXPre2bCompat]>;
def CXX17CompatPedantic : DiagGroup<"c++17-compat-pedantic",
[CXX17Compat,
CXXPre20CompatPedantic]>;
CXXPre20CompatPedantic,
CXXPre2bCompatPedantic]>;
def : DiagGroup<"c++1z-compat", [CXX17Compat]>;
def CXX20Compat : DiagGroup<"c++20-compat">;
def CXX20Compat : DiagGroup<"c++20-compat", [CXXPre2bCompat]>;
def CXX20CompatPedantic : DiagGroup<"c++20-compat-pedantic",
[CXX20Compat]>;
[CXX20Compat,
CXXPre2bCompatPedantic]>;
def : DiagGroup<"c++2a-compat", [CXX20Compat]>;
def : DiagGroup<"c++2a-compat-pedantic", [CXX20CompatPedantic]>;
@@ -437,6 +466,7 @@ def ModuleBuild : DiagGroup<"module-build">;
def ModuleImport : DiagGroup<"module-import">;
def ModuleConflict : DiagGroup<"module-conflict">;
def ModuleFileExtension : DiagGroup<"module-file-extension">;
def RoundTripCC1Args : DiagGroup<"round-trip-cc1-args">;
def NewlineEOF : DiagGroup<"newline-eof">;
def Nullability : DiagGroup<"nullability">;
def NullabilityDeclSpec : DiagGroup<"nullability-declspec">;
@@ -457,6 +487,7 @@ def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
def : DiagGroup<"nonportable-cfstrings">;
def NonVirtualDtor : DiagGroup<"non-virtual-dtor">;
def NullPointerArithmetic : DiagGroup<"null-pointer-arithmetic">;
def NullPointerSubtraction : DiagGroup<"null-pointer-subtraction">;
def : DiagGroup<"effc++", [NonVirtualDtor]>;
def OveralignedType : DiagGroup<"over-aligned">;
def OldStyleCast : DiagGroup<"old-style-cast">;
@@ -473,6 +504,7 @@ def PrivateExtern : DiagGroup<"private-extern">;
def SelTypeCast : DiagGroup<"cast-of-sel-type">;
def FunctionDefInObjCContainer : DiagGroup<"function-def-in-objc-container">;
def BadFunctionCast : DiagGroup<"bad-function-cast">;
def CastFunctionType : DiagGroup<"cast-function-type">;
def ObjCPropertyImpl : DiagGroup<"objc-property-implementation">;
def ObjCPropertyNoAttribute : DiagGroup<"objc-property-no-attribute">;
def ObjCPropertyAssignOnObjectType : DiagGroup<"objc-property-assign-on-object-type">;
@@ -494,18 +526,17 @@ def OpenCLUnsupportedRGBA: DiagGroup<"opencl-unsupported-rgba">;
def UnderalignedExceptionObject : DiagGroup<"underaligned-exception-object">;
def DeprecatedObjCIsaUsage : DiagGroup<"deprecated-objc-isa-usage">;
def ExplicitInitializeCall : DiagGroup<"explicit-initialize-call">;
def OrderedCompareFunctionPointers : DiagGroup<"ordered-compare-function-pointers">;
def Packed : DiagGroup<"packed">;
def Padded : DiagGroup<"padded">;
def PessimizingMove : DiagGroup<"pessimizing-move">;
def ReturnStdMoveInCXX11 : DiagGroup<"return-std-move-in-c++11">;
def ReturnStdMove : DiagGroup<"return-std-move">;
def PointerArith : DiagGroup<"pointer-arith">;
def PoundWarning : DiagGroup<"#warnings">;
def PoundPragmaMessage : DiagGroup<"#pragma-messages">,
DiagCategory<"#pragma message Directive">;
def : DiagGroup<"pointer-to-int-cast">;
def : DiagGroup<"redundant-decls">;
def RedeclaredClassMember : DiagGroup<"redeclared-class-member">;
def GNURedeclaredEnum : DiagGroup<"gnu-redeclared-enum">;
@@ -540,7 +571,6 @@ def ShadowAll : DiagGroup<"shadow-all", [Shadow, ShadowFieldInConstructor,
def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
def : DiagGroup<"sign-promo">;
def SignCompare : DiagGroup<"sign-compare">;
def : DiagGroup<"stack-protector">;
def : DiagGroup<"switch-default">;
def : DiagGroup<"synth">;
def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
@@ -567,11 +597,13 @@ def SwiftNameAttribute : DiagGroup<"swift-name-attribute">;
def IntInBoolContext : DiagGroup<"int-in-bool-context">;
def TautologicalTypeLimitCompare : DiagGroup<"tautological-type-limit-compare">;
def TautologicalUnsignedZeroCompare : DiagGroup<"tautological-unsigned-zero-compare">;
def TautologicalUnsignedCharZeroCompare : DiagGroup<"tautological-unsigned-char-zero-compare">;
def TautologicalUnsignedEnumZeroCompare : DiagGroup<"tautological-unsigned-enum-zero-compare">;
// For compatibility with GCC. Tautological comparison warnings for constants
// that are an extremal value of the type.
def TypeLimits : DiagGroup<"type-limits", [TautologicalTypeLimitCompare,
TautologicalUnsignedZeroCompare,
TautologicalUnsignedCharZeroCompare,
TautologicalUnsignedEnumZeroCompare]>;
// Additional tautological comparison warnings based on the expression, not
// only on its type.
@@ -608,7 +640,8 @@ def : DiagGroup<"sequence-point", [Unsequenced]>;
// Preprocessor warnings.
def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
def KeywordAsMacro : DiagGroup<"keyword-macro">;
def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
def ReservedIdAsMacro : DiagGroup<"reserved-macro-identifier">;
def ReservedIdAsMacroAlias : DiagGroup<"reserved-id-macro", [ReservedIdAsMacro]>;
// Just silence warnings about -Wstrict-aliasing for now.
def : DiagGroup<"strict-aliasing=0">;
@@ -626,7 +659,6 @@ def : DiagGroup<"strict-overflow=5">;
def : DiagGroup<"strict-overflow">;
def InvalidOffsetof : DiagGroup<"invalid-offsetof">;
def : DiagGroup<"strict-prototypes">;
def StrictSelector : DiagGroup<"strict-selector-match">;
def MethodDuplicate : DiagGroup<"duplicate-method-match">;
def ObjCCStringFormat : DiagGroup<"cstring-format-directive">;
@@ -695,6 +727,7 @@ def UnusedMemberFunction : DiagGroup<"unused-member-function",
def UnusedLabel : DiagGroup<"unused-label">;
def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">;
def UnusedParameter : DiagGroup<"unused-parameter">;
def UnusedButSetParameter : DiagGroup<"unused-but-set-parameter">;
def UnusedResult : DiagGroup<"unused-result">;
def PotentiallyEvaluatedExpression : DiagGroup<"potentially-evaluated-expression">;
def UnevaluatedExpression : DiagGroup<"unevaluated-expression",
@@ -704,6 +737,7 @@ def UnusedValue : DiagGroup<"unused-value", [UnusedComparison, UnusedResult,
def UnusedConstVariable : DiagGroup<"unused-const-variable">;
def UnusedVariable : DiagGroup<"unused-variable",
[UnusedConstVariable]>;
def UnusedButSetVariable : DiagGroup<"unused-but-set-variable">;
def UnusedLocalTypedef : DiagGroup<"unused-local-typedef">;
def UnusedPropertyIvar : DiagGroup<"unused-property-ivar">;
def UnusedGetterReturnValue : DiagGroup<"unused-getter-return-value">;
@@ -752,7 +786,6 @@ def Visibility : DiagGroup<"visibility">;
def ZeroLengthArray : DiagGroup<"zero-length-array">;
def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">;
def GNUZeroVariadicMacroArguments : DiagGroup<"gnu-zero-variadic-macro-arguments">;
def Fallback : DiagGroup<"fallback">;
def MisleadingIndentation : DiagGroup<"misleading-indentation">;
// This covers both the deprecated case (in C++98)
@@ -773,6 +806,9 @@ def LargeByValueCopy : DiagGroup<"large-by-value-copy">;
def DuplicateArgDecl : DiagGroup<"duplicate-method-arg">;
def SignedEnumBitfield : DiagGroup<"signed-enum-bitfield">;
def ReservedIdentifier : DiagGroup<"reserved-identifier",
[ReservedIdAsMacro]>;
// Unreachable code warning groups.
//
// The goal is make -Wunreachable-code on by default, in -Wall, or at
@@ -843,7 +879,7 @@ def Unused : DiagGroup<"unused",
// UnusedMemberFunction, (clean-up llvm before enabling)
UnusedPrivateField, UnusedLambdaCapture,
UnusedLocalTypedef, UnusedValue, UnusedVariable,
UnusedPropertyIvar]>,
UnusedButSetVariable, UnusedPropertyIvar]>,
DiagCategory<"Unused Entity Issue">;
// Format settings.
@@ -895,7 +931,9 @@ def Extra : DiagGroup<"extra", [
MissingMethodReturnType,
SignCompare,
UnusedParameter,
UnusedButSetParameter,
NullPointerArithmetic,
NullPointerSubtraction,
EmptyInitStatement,
StringConcatation,
FUseLdPath,
@@ -1006,6 +1044,10 @@ def CXX17 : DiagGroup<"c++17-extensions">;
// earlier C++ versions.
def CXX20 : DiagGroup<"c++20-extensions", [CXX20Designator]>;
// A warning group for warnings about using C++2b features as extensions in
// earlier C++ versions.
def CXX2b : DiagGroup<"c++2b-extensions">;
def : DiagGroup<"c++0x-extensions", [CXX11]>;
def : DiagGroup<"c++1y-extensions", [CXX14]>;
def : DiagGroup<"c++1z-extensions", [CXX17]>;
@@ -1043,6 +1085,9 @@ def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUAnonymousStruct,
// A warning group for warnings about code that clang accepts but gcc doesn't.
def GccCompat : DiagGroup<"gcc-compat">;
// A warning group for warnings about code that may be incompatible on AIX.
def AIXCompat : DiagGroup<"aix-compat">;
// Warnings for Microsoft extensions.
def MicrosoftCharize : DiagGroup<"microsoft-charize">;
def MicrosoftDrectveSection : DiagGroup<"microsoft-drectve-section">;
@@ -1050,6 +1095,7 @@ def MicrosoftInclude : DiagGroup<"microsoft-include">;
def MicrosoftCppMacro : DiagGroup<"microsoft-cpp-macro">;
def MicrosoftFixedEnum : DiagGroup<"microsoft-fixed-enum">;
def MicrosoftSealed : DiagGroup<"microsoft-sealed">;
def MicrosoftAbstract : DiagGroup<"microsoft-abstract">;
def MicrosoftUnqualifiedFriend : DiagGroup<"microsoft-unqualified-friend">;
def MicrosoftExceptionSpec : DiagGroup<"microsoft-exception-spec">;
def MicrosoftUsingDecl : DiagGroup<"microsoft-using-decl">;
@@ -1078,6 +1124,8 @@ def MicrosoftAnonTag : DiagGroup<"microsoft-anon-tag">;
def MicrosoftCommentPaste : DiagGroup<"microsoft-comment-paste">;
def MicrosoftEndOfFile : DiagGroup<"microsoft-end-of-file">;
def MicrosoftInaccessibleBase : DiagGroup<"microsoft-inaccessible-base">;
def MicrosoftStaticAssert : DiagGroup<"microsoft-static-assert">;
// Aliases.
def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
// -Wmsvc-include = -Wmicrosoft-include
@@ -1085,7 +1133,7 @@ def : DiagGroup<"msvc-include", [MicrosoftInclude]>;
// Warnings group for warnings about Microsoft extensions.
def Microsoft : DiagGroup<"microsoft",
[MicrosoftCharize, MicrosoftDrectveSection, MicrosoftInclude,
MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed,
MicrosoftCppMacro, MicrosoftFixedEnum, MicrosoftSealed, MicrosoftAbstract,
MicrosoftUnqualifiedFriend, MicrosoftExceptionSpec, MicrosoftUsingDecl,
MicrosoftMutableReference, MicrosoftPureDefinition,
MicrosoftUnionMemberReference, MicrosoftExplicitConstructorCall,
@@ -1093,7 +1141,7 @@ def Microsoft : DiagGroup<"microsoft",
MicrosoftRedeclareStatic, MicrosoftEnumForwardReference, MicrosoftGoto,
MicrosoftFlexibleArray, MicrosoftExtraQualification, MicrosoftCast,
MicrosoftConstInit, MicrosoftVoidPseudoDtor, MicrosoftAnonTag,
MicrosoftCommentPaste, MicrosoftEndOfFile,
MicrosoftCommentPaste, MicrosoftEndOfFile, MicrosoftStaticAssert,
MicrosoftInconsistentDllImport]>;
def ClangClPch : DiagGroup<"clang-cl-pch">;
@@ -1143,13 +1191,19 @@ def OpenMPClauses : DiagGroup<"openmp-clauses">;
def OpenMPLoopForm : DiagGroup<"openmp-loop-form">;
def OpenMPMapping : DiagGroup<"openmp-mapping">;
def OpenMPTarget : DiagGroup<"openmp-target", [OpenMPMapping]>;
def OpenMPPre51Compat : DiagGroup<"pre-openmp-51-compat">;
def OpenMP51Ext : DiagGroup<"openmp-51-extensions">;
def OpenMP : DiagGroup<"openmp", [
SourceUsesOpenMP, OpenMPClauses, OpenMPLoopForm, OpenMPTarget, OpenMPMapping
SourceUsesOpenMP, OpenMPClauses, OpenMPLoopForm, OpenMPTarget,
OpenMPMapping, OpenMP51Ext
]>;
// Backend warnings.
def BackendInlineAsm : DiagGroup<"inline-asm">;
def BackendFrameLargerThanEQ : DiagGroup<"frame-larger-than=">;
def BackendSourceMgr : DiagGroup<"source-mgr">;
def BackendFrameLargerThan : DiagGroup<"frame-larger-than">;
// Compatibility flag name from old versions of Clang.
def : DiagGroup<"frame-larger-than=", [BackendFrameLargerThan]>;
def BackendPlugin : DiagGroup<"backend-plugin">;
def RemarkBackendPlugin : DiagGroup<"remark-backend-plugin">;
def BackendOptimizationRemark : DiagGroup<"pass">;
@@ -1247,3 +1301,5 @@ in addition with the pragmas or -fmax-tokens flag to get any warnings.
def WebAssemblyExceptionSpec : DiagGroup<"wasm-exception-spec">;
def RTTI : DiagGroup<"rtti">;
def OpenCLCoreFeaturesDiagGroup : DiagGroup<"pedantic-core-features">;
@@ -36,7 +36,7 @@ namespace clang {
DIAG_SIZE_AST = 250,
DIAG_SIZE_COMMENT = 100,
DIAG_SIZE_CROSSTU = 100,
DIAG_SIZE_SEMA = 4000,
DIAG_SIZE_SEMA = 4500,
DIAG_SIZE_ANALYSIS = 100,
DIAG_SIZE_REFACTORING = 1000,
};
@@ -179,6 +179,9 @@ def err_invalid_suffix_constant : Error<
def warn_cxx11_compat_digit_separator : Warning<
"digit separators are incompatible with C++ standards before C++14">,
InGroup<CXXPre14Compat>, DefaultIgnore;
def warn_c2x_compat_digit_separator : Warning<
"digit separators are incompatible with C standards before C2x">,
InGroup<CPre2xCompat>, DefaultIgnore;
def err_digit_separator_not_between_digits : Error<
"digit separator cannot appear at %select{start|end}0 of digit sequence">;
def warn_extraneous_char_constant : Warning<
@@ -452,9 +455,11 @@ def err_pp_malformed_ident : Error<"invalid #ident directive">;
def err_pp_unterminated_conditional : Error<
"unterminated conditional directive">;
def pp_err_else_after_else : Error<"#else after #else">;
def pp_err_elif_after_else : Error<"#elif after #else">;
def pp_err_elif_after_else : Error<
"%select{#elif|#elifdef|#elifndef}0 after #else">;
def pp_err_else_without_if : Error<"#else without #if">;
def pp_err_elif_without_if : Error<"#elif without #if">;
def pp_err_elif_without_if : Error<
"%select{#elif|#elifdef|#elifndef}0 without #if">;
def err_pp_endif_without_if : Error<"#endif without #if">;
def err_pp_expected_value_in_expr : Error<"expected value in expression">;
def err_pp_expected_rparen : Error<"expected ')' in preprocessor expression">;
@@ -78,7 +78,6 @@ ENUM_DIAGOPT(VerifyIgnoreUnexpected, DiagnosticLevelMask, 4,
/// -verify.
DIAGOPT(ElideType, 1, 0) /// Elide identical types in template diffing
DIAGOPT(ShowTemplateTree, 1, 0) /// Print a template tree when diffing
DIAGOPT(CLFallbackMode, 1, 0) /// Format for clang-cl fallback mode
VALUE_DIAGOPT(ErrorLimit, 32, 0) /// Limit # errors emitted.
/// Limit depth of macro expansion backtrace.
@@ -21,7 +21,7 @@ let CategoryName = "Inline Assembly Issue" in {
def err_asm_empty : Error<"__asm used with no assembly instructions">;
def err_inline_ms_asm_parsing : Error<"%0">;
def err_msasm_unsupported_arch : Error<
"Unsupported architecture '%0' for MS-style inline assembly">;
"unsupported architecture '%0' for MS-style inline assembly">;
def err_msasm_unable_to_create_target : Error<
"MS-style inline assembly is not available: %0">;
def err_gnu_inline_asm_disabled : Error<
@@ -424,12 +424,21 @@ def err_bool_redeclaration : Error<
def warn_cxx98_compat_static_assert : Warning<
"static_assert declarations are incompatible with C++98">,
InGroup<CXX98Compat>, DefaultIgnore;
def ext_static_assert_no_message : ExtWarn<
"static_assert with no message is a C++17 extension">, InGroup<CXX17>;
def ext_ms_static_assert : ExtWarn<
"use of 'static_assert' without inclusion of <assert.h> is a Microsoft "
"extension">, InGroup<MicrosoftStaticAssert>;
def ext_cxx_static_assert_no_message : ExtWarn<
"'static_assert' with no message is a C++17 extension">, InGroup<CXX17>;
def ext_c_static_assert_no_message : ExtWarn<
"'_Static_assert' with no message is a C2x extension">, InGroup<C2x>;
def warn_cxx14_compat_static_assert_no_message : Warning<
"static_assert with no message is incompatible with C++ standards before "
"'static_assert' with no message is incompatible with C++ standards before "
"C++17">,
DefaultIgnore, InGroup<CXXPre17Compat>;
def warn_c17_compat_static_assert_no_message : Warning<
"'_Static_assert' with no message is incompatible with C standards before "
"C2x">,
DefaultIgnore, InGroup<CPre2xCompat>;
def err_function_definition_not_allowed : Error<
"function definition is not allowed here">;
def err_expected_end_of_enumerator : Error<
@@ -571,6 +580,12 @@ def warn_cxx98_compat_noexcept_decl : Warning<
def err_expected_catch : Error<"expected catch">;
def err_using_namespace_in_class : Error<
"'using namespace' is not allowed in classes">;
def warn_cxx17_compat_using_enum_declaration : Warning<
"using enum declaration is incompatible with C++ standards before C++20">,
InGroup<CXXPre20Compat>, DefaultIgnore;
def ext_using_enum_declaration : ExtWarn<
"using enum declaration is a C++20 extension">,
InGroup<CXX20>;
def err_constructor_bad_name : Error<
"missing return type for function %0; did you mean the constructor name %1?">;
def err_destructor_tilde_identifier : Error<
@@ -675,8 +690,6 @@ def err_attribute_requires_arguments : Error<
"parentheses must be omitted if %0 attribute's argument list is empty">;
def err_cxx11_attribute_forbids_ellipsis : Error<
"attribute %0 cannot be used as an attribute pack">;
def err_cxx11_attribute_repeated : Error<
"attribute %0 cannot appear multiple times in an attribute specifier">;
def warn_cxx14_compat_using_attribute_ns : Warning<
"default scope specifier for attributes is incompatible with C++ standards "
"before C++17">, InGroup<CXXPre17Compat>, DefaultIgnore;
@@ -686,6 +699,9 @@ def ext_using_attribute_ns : ExtWarn<
def err_using_attribute_ns_conflict : Error<
"attribute with scope specifier cannot follow default scope specifier">;
def err_attributes_not_allowed : Error<"an attribute list cannot appear here">;
def ext_cxx11_attr_placement : ExtWarn<
"ISO C++ does not allow an attribute list to appear here">,
InGroup<DiagGroup<"cxx-attribute-extension">>;
def err_attributes_misplaced : Error<"misplaced attributes; expected attributes here">;
def err_l_square_l_square_not_attribute : Error<
"C++11 only allows consecutive left square brackets when "
@@ -915,10 +931,16 @@ def err_override_control_interface : Error<
def ext_ms_sealed_keyword : ExtWarn<
"'sealed' keyword is a Microsoft extension">,
InGroup<MicrosoftSealed>;
def ext_ms_abstract_keyword : ExtWarn<
"'abstract' keyword is a Microsoft extension">,
InGroup<MicrosoftAbstract>;
def err_access_specifier_interface : Error<
"interface types cannot specify '%select{private|protected}0' access">;
def err_duplicate_class_virt_specifier : Error<
"class already marked '%0'">;
def err_duplicate_virt_specifier : Error<
"class member already marked '%0'">;
@@ -940,9 +962,6 @@ def err_expected_lambda_body : Error<"expected body of lambda expression">;
def warn_cxx98_compat_lambda : Warning<
"lambda expressions are incompatible with C++98">,
InGroup<CXX98Compat>, DefaultIgnore;
def err_lambda_missing_parens : Error<
"lambda requires '()' before %select{'mutable'|return type|"
"attribute specifier|'constexpr'|'consteval'|'requires' clause}0">;
def err_lambda_decl_specifier_repeated : Error<
"%select{'mutable'|'constexpr'|'consteval'}0 cannot appear multiple times in a lambda declarator">;
def err_lambda_capture_misplaced_ellipsis : Error<
@@ -952,6 +971,16 @@ def err_lambda_capture_multiple_ellipses : Error<
"multiple ellipses in pack capture">;
def err_capture_default_first : Error<
"capture default must be first">;
def ext_decl_attrs_on_lambda : ExtWarn<
"an attribute specifier sequence in this position is a C++2b extension">,
InGroup<CXX2b>;
def ext_lambda_missing_parens : ExtWarn<
"lambda without a parameter clause is a C++2b extension">,
InGroup<CXX2b>;
def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
"an attribute specifier sequence in this position is incompatible with C++ "
"standards before C++2b">, InGroup<CXXPre2bCompat>, DefaultIgnore;
// C++17 lambda expressions
def err_expected_star_this_capture : Error<
"expected 'this' following '*' in lambda capture list">;
@@ -1220,22 +1249,18 @@ def note_pragma_attribute_namespace_on_attribute : Note<
"omit the namespace to add attributes to the most-recently"
" pushed attribute group">;
def err_opencl_unroll_hint_on_non_loop : Error<
"OpenCL only supports 'opencl_unroll_hint' attribute on for, while, and do statements">;
// OpenCL EXTENSION pragma (OpenCL 1.1 [9.1])
def warn_pragma_expected_colon : Warning<
"missing ':' after %0 - ignoring">, InGroup<IgnoredPragmas>;
def warn_pragma_expected_predicate : Warning<
"expected %select{'enable', 'disable', 'begin' or 'end'|'disable'}0 - ignoring">, InGroup<IgnoredPragmas>;
def warn_pragma_begin_end_mismatch : Warning<
"OpenCL extension end directive mismatches begin directive - ignoring">, InGroup<IgnoredPragmas>;
def warn_pragma_unknown_extension : Warning<
"unknown OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>;
def warn_pragma_unsupported_extension : Warning<
"unsupported OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>;
def warn_pragma_extension_is_core : Warning<
"OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup<DiagGroup<"pedantic-core-features">>, DefaultIgnore;
"OpenCL extension %0 is core feature or supported optional core feature - ignoring">,
InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore;
// OpenCL errors.
def err_opencl_taking_function_address_parser : Error<
@@ -1302,7 +1327,15 @@ def warn_omp_unknown_assumption_clause_without_args
def note_omp_assumption_clause_continue_here
: Note<"the ignored tokens spans until here">;
def err_omp_declare_target_unexpected_clause: Error<
"unexpected '%0' clause, only %select{'to' or 'link'|'to', 'link' or 'device_type'}1 clauses expected">;
"unexpected '%0' clause, only %select{'device_type'|'to' or 'link'|'to', 'link' or 'device_type'}1 clauses expected">;
def err_omp_begin_declare_target_unexpected_implicit_to_clause: Error<
"unexpected '(', only 'to', 'link' or 'device_type' clauses expected for 'begin declare target' directive">;
def err_omp_declare_target_unexpected_clause_after_implicit_to: Error<
"unexpected clause after an implicit 'to' clause">;
def err_omp_declare_target_missing_to_or_link_clause: Error<
"expected at least one 'to' or 'link' clause">;
def err_omp_declare_target_multiple : Error<
"%0 appears multiple times in clauses on the same declare target directive">;
def err_omp_expected_clause: Error<
"expected at least one clause on '#pragma omp %0' directive">;
def err_omp_mapper_illegal_identifier : Error<
@@ -1387,6 +1420,22 @@ def err_omp_variant_ctx_second_match_extension : Error<
"only a single match extension allowed per OpenMP context selector">;
def err_omp_invalid_dsa: Error<
"data-sharing attribute '%0' in '%1' clause requires OpenMP version %2 or above">;
def err_omp_expected_punc_after_interop_mod : Error<
"expected ',' after interop modifier">;
def err_omp_expected_interop_type : Error<
"expected interop type: 'target' and/or 'targetsync'">;
def warn_omp_more_one_interop_type
: Warning<"interop type '%0' cannot be specified more than once">,
InGroup<OpenMPClauses>;
def err_expected_sequence_or_directive : Error<
"expected an OpenMP 'directive' or 'sequence' attribute argument">;
def ext_omp_attributes : ExtWarn<
"specifying OpenMP directives with [[]] is an OpenMP 5.1 extension">,
InGroup<OpenMP51Ext>;
def warn_omp51_compat_attributes : Warning<
"specifying OpenMP directives with [[]] is incompatible with OpenMP "
"standards before OpenMP 5.1">,
InGroup<OpenMPPre51Compat>, DefaultIgnore;
// Pragma loop support.
def err_pragma_loop_missing_argument : Error<
@@ -82,11 +82,11 @@ def err_typecheck_converted_constant_expression_indirect : Error<
"bind reference to a temporary">;
def err_expr_not_cce : Error<
"%select{case value|enumerator value|non-type template argument|"
"array size|constexpr if condition|explicit specifier argument}0 "
"array size|explicit specifier argument}0 "
"is not a constant expression">;
def ext_cce_narrowing : ExtWarn<
"%select{case value|enumerator value|non-type template argument|"
"array size|constexpr if condition|explicit specifier argument}0 "
"array size|explicit specifier argument}0 "
"%select{cannot be narrowed from type %2 to %3|"
"evaluates to %2, which cannot be narrowed to type %3}1">,
InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure;
@@ -118,7 +118,8 @@ def warn_float_underflow : Warning<
"magnitude of floating-point constant too small for type %0; minimum is %1">,
InGroup<LiteralRange>;
def warn_double_const_requires_fp64 : Warning<
"double precision constant requires cl_khr_fp64, casting to single precision">;
"double precision constant requires %select{cl_khr_fp64|cl_khr_fp64 and __opencl_c_fp64}0, "
"casting to single precision">;
def err_half_const_requires_fp16 : Error<
"half precision constant requires cl_khr_fp16">;
@@ -214,6 +215,9 @@ def ext_designated_init_reordered : ExtWarn<
SFINAEFailure;
def note_previous_field_init : Note<
"previous initialization for field %0 is here">;
def ext_designated_init_brace_elision : ExtWarn<
"brace elision for designated initializer is a C99 extension">,
InGroup<C99Designator>, SFINAEFailure;
// Declarations.
def ext_plain_complex : ExtWarn<
@@ -290,6 +294,10 @@ def err_anyx86_interrupt_attribute : Error<
"a pointer as the first parameter|a %2 type as the second parameter}1">;
def err_anyx86_interrupt_called : Error<
"interrupt service routine cannot be called directly">;
def warn_anyx86_interrupt_regsave : Warning<
"interrupt service routine should only call a function"
" with attribute 'no_caller_saved_registers'">,
InGroup<DiagGroup<"interrupt-service-routine">>;
def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's VFP registers">,
InGroup<Extra>;
@@ -303,8 +311,12 @@ def note_riscv_repeated_interrupt_attribute : Note<
"repeated RISC-V 'interrupt' attribute is here">;
def warn_unused_parameter : Warning<"unused parameter %0">,
InGroup<UnusedParameter>, DefaultIgnore;
def warn_unused_but_set_parameter : Warning<"parameter %0 set but not used">,
InGroup<UnusedButSetParameter>, DefaultIgnore;
def warn_unused_variable : Warning<"unused variable %0">,
InGroup<UnusedVariable>, DefaultIgnore;
def warn_unused_but_set_variable : Warning<"variable %0 set but not used">,
InGroup<UnusedButSetVariable>, DefaultIgnore;
def warn_unused_local_typedef : Warning<
"unused %select{typedef|type alias}0 %1">,
InGroup<UnusedLocalTypedef>, DefaultIgnore;
@@ -372,6 +384,15 @@ def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
"%select{used|required to be captured for this use}1">,
InGroup<UnusedLambdaCapture>, DefaultIgnore;
def warn_reserved_extern_symbol: Warning<
"identifier %0 is reserved because %select{"
"<ERROR>|" // ReservedIdentifierStatus::NotReserved
"it starts with '_' at global scope|"
"it starts with '__'|"
"it starts with '_' followed by a capital letter|"
"it contains '__'}1">,
InGroup<ReservedIdentifier>, DefaultIgnore;
def warn_parameter_size: Warning<
"%0 is a large (%1 bytes) pass-by-value argument; "
"pass it by reference instead ?">, InGroup<LargeByValueCopy>;
@@ -422,7 +443,8 @@ def warn_decl_shadow :
"static data member of %2|"
"field of %2|"
"typedef in %2|"
"type alias in %2}1">,
"type alias in %2|"
"structured binding}1">,
InGroup<Shadow>, DefaultIgnore;
def warn_decl_shadow_uncaptured_local :
Warning<warn_decl_shadow.Text>,
@@ -514,6 +536,10 @@ def err_using_dependent_value_is_type : Error<
"dependent using declaration resolved to type without 'typename'">;
def err_using_decl_nested_name_specifier_is_not_class : Error<
"using declaration in class refers into '%0', which is not a class">;
def warn_cxx17_compat_using_decl_non_member_enumerator : Warning<
"member using declaration naming non-class '%0' enumerator is "
"incompatible with C++ standards before C++20">, InGroup<CXXPre20Compat>,
DefaultIgnore;
def err_using_decl_nested_name_specifier_is_current_class : Error<
"using declaration refers to its own class">;
def err_using_decl_nested_name_specifier_is_not_base_class : Error<
@@ -522,6 +548,14 @@ def err_using_decl_constructor_not_in_direct_base : Error<
"%0 is not a direct base of %1, cannot inherit constructors">;
def err_using_decl_can_not_refer_to_class_member : Error<
"using declaration cannot refer to class member">;
def warn_cxx17_compat_using_decl_class_member_enumerator : Warning<
"member using declaration naming a non-member enumerator is incompatible "
"with C++ standards before C++20">, InGroup<CXXPre20Compat>, DefaultIgnore;
def ext_using_decl_class_member_enumerator : ExtWarn<
"member using declaration naming a non-member enumerator is "
"a C++20 extension">, InGroup<CXX20>;
def err_using_enum_is_dependent : Error<
"using-enum cannot name a dependent type">;
def err_ambiguous_inherited_constructor : Error<
"constructor of %0 inherited from multiple base class subobjects">;
def note_ambiguous_inherited_constructor_using : Note<
@@ -531,8 +565,12 @@ def note_using_decl_class_member_workaround : Note<
"a const variable|a constexpr variable}0 instead">;
def err_using_decl_can_not_refer_to_namespace : Error<
"using declaration cannot refer to a namespace">;
def err_using_decl_can_not_refer_to_scoped_enum : Error<
"using declaration cannot refer to a scoped enumerator">;
def warn_cxx17_compat_using_decl_scoped_enumerator: Warning<
"using declaration naming a scoped enumerator is incompatible with "
"C++ standards before C++20">, InGroup<CXXPre20Compat>, DefaultIgnore;
def ext_using_decl_scoped_enumerator : ExtWarn<
"using declaration naming a scoped enumerator is a C++20 extension">,
InGroup<CXX20>;
def err_using_decl_constructor : Error<
"using declaration cannot refer to a constructor">;
def warn_cxx98_compat_using_decl_constructor : Warning<
@@ -552,6 +590,15 @@ def err_using_decl_conflict_reverse : Error<
def note_using_decl : Note<"%select{|previous }0using declaration">;
def err_using_decl_redeclaration_expansion : Error<
"using declaration pack expansion at block scope produces multiple values">;
def err_use_of_empty_using_if_exists : Error<
"reference to unresolved using declaration">;
def note_empty_using_if_exists_here : Note<
"using declaration annotated with 'using_if_exists' here">;
def err_using_if_exists_on_ctor : Error<
"'using_if_exists' attribute cannot be applied to an inheriting constructor">;
def err_using_enum_decl_redeclaration : Error<
"redeclaration of using-enum declaration">;
def note_using_enum_decl : Note<"%select{|previous }0using-enum declaration">;
def warn_access_decl_deprecated : Warning<
"access declarations are deprecated; use using declarations instead">,
@@ -559,15 +606,24 @@ def warn_access_decl_deprecated : Warning<
def err_access_decl : Error<
"ISO C++11 does not allow access declarations; "
"use using declarations instead">;
def warn_deprecated_copy_operation : Warning<
def warn_deprecated_copy : Warning<
"definition of implicit copy %select{constructor|assignment operator}1 "
"for %0 is deprecated because it has a user-declared copy "
"%select{assignment operator|constructor}1">,
InGroup<DeprecatedCopy>, DefaultIgnore;
def warn_deprecated_copy_dtor_operation : Warning<
def warn_deprecated_copy_with_dtor : Warning<
"definition of implicit copy %select{constructor|assignment operator}1 "
"for %0 is deprecated because it has a user-declared destructor">,
InGroup<DeprecatedCopyDtor>, DefaultIgnore;
InGroup<DeprecatedCopyWithDtor>, DefaultIgnore;
def warn_deprecated_copy_with_user_provided_copy: Warning<
"definition of implicit copy %select{constructor|assignment operator}1 "
"for %0 is deprecated because it has a user-provided copy "
"%select{assignment operator|constructor}1">,
InGroup<DeprecatedCopyWithUserProvidedCopy>, DefaultIgnore;
def warn_deprecated_copy_with_user_provided_dtor : Warning<
"definition of implicit copy %select{constructor|assignment operator}1 "
"for %0 is deprecated because it has a user-provided destructor">,
InGroup<DeprecatedCopyWithUserProvidedDtor>, DefaultIgnore;
def warn_cxx17_compat_exception_spec_in_signature : Warning<
"mangled name of %0 will change in C++17 due to non-throwing exception "
"specification in function signature">, InGroup<CXX17CompatMangling>;
@@ -1431,6 +1487,8 @@ def err_messaging_class_with_direct_method : Error<
// C++ declarations
def err_static_assert_expression_is_not_constant : Error<
"static_assert expression is not an integral constant expression">;
def err_constexpr_if_condition_expression_is_not_constant : Error<
"constexpr if condition is not a constant expression">;
def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">;
def err_static_assert_requirement_failed : Error<
"static_assert failed due to requirement '%0'%select{ %2|}1">;
@@ -1705,6 +1763,8 @@ def warn_cxx98_compat_sfinae_access_control : Warning<
// C++ name lookup
def err_incomplete_nested_name_spec : Error<
"incomplete type %0 named in nested name specifier">;
def err_incomplete_enum : Error<
"enumeration %0 is incomplete">;
def err_dependent_nested_name_spec : Error<
"nested name specifier for a declaration cannot depend on a template "
"parameter">;
@@ -2816,6 +2876,53 @@ def warn_nomerge_attribute_ignored_in_stmt: Warning<
"%0 attribute is ignored because there exists no call expression inside the "
"statement">,
InGroup<IgnoredAttributes>;
def err_musttail_needs_trivial_args : Error<
"tail call requires that the return value, all parameters, and any "
"temporaries created by the expression are trivially destructible">;
def err_musttail_needs_call : Error<
"%0 attribute requires that the return value is the result of a function call"
>;
def err_musttail_needs_prototype : Error<
"%0 attribute requires that both caller and callee functions have a "
"prototype">;
def note_musttail_fix_non_prototype : Note<
"add 'void' to the parameter list to turn an old-style K&R function "
"declaration into a prototype">;
def err_musttail_structors_forbidden : Error<"cannot perform a tail call "
"%select{from|to}0 a %select{constructor|destructor}1">;
def note_musttail_structors_forbidden : Note<"target "
"%select{constructor|destructor}0 is declared here">;
def err_musttail_forbidden_from_this_context : Error<
"%0 attribute cannot be used from "
"%select{a block|an Objective-C function|this context}1">;
def err_musttail_member_mismatch : Error<
"%select{non-member|static member|non-static member}0 "
"function cannot perform a tail call to "
"%select{non-member|static member|non-static member|pointer-to-member}1 "
"function%select{| %3}2">;
def note_musttail_callee_defined_here : Note<"%0 declared here">;
def note_tail_call_required : Note<"tail call required by %0 attribute here">;
def err_musttail_mismatch : Error<
"cannot perform a tail call to function%select{| %1}0 because its signature "
"is incompatible with the calling function">;
def note_musttail_mismatch : Note<
"target function "
"%select{is a member of different class%diff{ (expected $ but has $)|}1,2"
"|has different number of parameters (expected %1 but has %2)"
"|has type mismatch at %ordinal3 parameter"
"%diff{ (expected $ but has $)|}1,2"
"|has different return type%diff{ ($ expected but has $)|}1,2}0">;
def err_musttail_callconv_mismatch : Error<
"cannot perform a tail call to function%select{| %1}0 because it uses an "
"incompatible calling convention">;
def note_musttail_callconv_mismatch : Note<
"target function has calling convention %1 (expected %0)">;
def err_musttail_scope : Error<
"cannot perform a tail call from this return statement">;
def err_musttail_no_variadic : Error<
"%0 attribute may not be used with variadic functions">;
def err_nsobject_attribute : Error<
"'NSObject' attribute is for pointer types only">;
def err_attributes_are_not_compatible : Error<
@@ -3049,7 +3156,8 @@ def warn_nsdictionary_duplicate_key : Warning<
def note_nsdictionary_duplicate_key_here : Note<
"previous equal key is here">;
def err_swift_param_attr_not_swiftcall : Error<
"'%0' parameter can only be used with swiftcall calling convention">;
"'%0' parameter can only be used with swiftcall%select{ or swiftasynccall|}1 "
"calling convention%select{|s}1">;
def err_swift_indirect_result_not_first : Error<
"'swift_indirect_result' parameters must be first parameters of function">;
def err_swift_error_result_not_after_swift_context : Error<
@@ -3078,6 +3186,8 @@ def warn_objc_redundant_literal_use : Warning<
def err_attr_tlsmodel_arg : Error<"tls_model must be \"global-dynamic\", "
"\"local-dynamic\", \"initial-exec\" or \"local-exec\"">;
def err_aix_attr_unsupported_tls_model : Error<"TLS model '%0' is not yet supported on AIX">;
def err_tls_var_aligned_over_maximum : Error<
"alignment (%0) of thread-local variable %1 is greater than the maximum supported "
"alignment (%2) for a thread-local variable on this target">;
@@ -3087,6 +3197,8 @@ def err_only_annotate_after_access_spec : Error<
def err_attribute_section_invalid_for_target : Error<
"argument to %select{'code_seg'|'section'}1 attribute is not valid for this target: %0">;
def err_pragma_section_invalid_for_target : Error<
"argument to #pragma section is not valid for this target: %0">;
def warn_attribute_section_drectve : Warning<
"#pragma %0(\".drectve\") has undefined behavior, "
"use #pragma comment(linker, ...) instead">, InGroup<MicrosoftDrectveSection>;
@@ -3142,6 +3254,10 @@ def warn_assume_aligned_too_great
: Warning<"requested alignment must be %0 bytes or smaller; maximum "
"alignment assumed">,
InGroup<DiagGroup<"builtin-assume-aligned-alignment">>;
def warn_not_xl_compatible
: Warning<"requesting an alignment of 16 bytes or greater for struct"
" members is not binary compatible with AIX XL 16.1 and older">,
InGroup<AIXCompat>;
def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning<
"%q0 redeclared without %1 attribute: previous %1 ignored">,
InGroup<MicrosoftInconsistentDllImport>;
@@ -3156,6 +3272,9 @@ def warn_attribute_ignored : Warning<"%0 attribute ignored">,
def warn_nothrow_attribute_ignored : Warning<"'nothrow' attribute conflicts with"
" exception specification; attribute ignored">,
InGroup<IgnoredAttributes>;
def warn_attribute_ignored_on_non_definition :
Warning<"%0 attribute ignored on a non-definition declaration">,
InGroup<IgnoredAttributes>;
def warn_attribute_ignored_on_inline :
Warning<"%0 attribute ignored on inline function">,
InGroup<IgnoredAttributes>;
@@ -3430,6 +3549,10 @@ def warn_at_available_unchecked_use : Warning<
"use if (%select{@available|__builtin_available}0) instead">,
InGroup<DiagGroup<"unsupported-availability-guard">>;
def warn_missing_sdksettings_for_availability_checking : Warning<
"%0 availability is ignored without a valid 'SDKSettings.json' in the SDK">,
InGroup<DiagGroup<"ignored-availability-without-sdk-settings">>;
// Thread Safety Attributes
def warn_thread_attribute_ignored : Warning<
"ignoring %0 attribute because its argument is invalid">,
@@ -3554,13 +3677,13 @@ def warn_fun_requires_lock_precise :
def note_found_mutex_near_match : Note<"found near match '%0'">;
// Verbose thread safety warnings
def warn_thread_safety_verbose : Warning<"Thread safety verbose warning.">,
def warn_thread_safety_verbose : Warning<"thread safety verbose warning">,
InGroup<ThreadSafetyVerbose>, DefaultIgnore;
def note_thread_warning_in_fun : Note<"Thread warning in function %0">;
def note_guarded_by_declared_here : Note<"Guarded_by declared here.">;
def note_thread_warning_in_fun : Note<"thread warning in function %0">;
def note_guarded_by_declared_here : Note<"guarded_by declared here">;
// Dummy warning that will trigger "beta" warnings from the analysis if enabled.
def warn_thread_safety_beta : Warning<"Thread safety beta warning.">,
def warn_thread_safety_beta : Warning<"thread safety beta warning">,
InGroup<ThreadSafetyBeta>, DefaultIgnore;
// Consumed warnings
@@ -3876,6 +3999,9 @@ def warn_attribute_sentinel_named_arguments : Warning<
def warn_attribute_sentinel_not_variadic : Warning<
"'sentinel' attribute only supported for variadic %select{functions|blocks}0">,
InGroup<IgnoredAttributes>;
def warn_deprecated_ignored_on_using : Warning<
"%0 currently has no effect on a using declaration">,
InGroup<IgnoredAttributes>;
def err_attribute_sentinel_less_than_zero : Error<
"'sentinel' parameter 1 less than zero">;
def err_attribute_sentinel_not_zero_or_one : Error<
@@ -3957,6 +4083,8 @@ def note_protocol_decl_undefined : Note<
def err_attribute_preferred_name_arg_invalid : Error<
"argument %0 to 'preferred_name' attribute is not a typedef for "
"a specialization of %1">;
def err_attribute_builtin_alias : Error<
"%0 attribute can only be applied to a ARM or RISC-V builtin">;
// called-once attribute diagnostics.
def err_called_once_attribute_wrong_type : Error<
@@ -4104,6 +4232,17 @@ def err_swift_async_bad_block_type : Error<
"'swift_async' completion handler parameter must have block type returning"
" 'void', type here is %0">;
def err_swift_async_error_without_swift_async : Error<
"%0 attribute must be applied to a %select{function|method}1 annotated "
"with non-'none' attribute 'swift_async'">;
def err_swift_async_error_no_error_parameter : Error<
"%0 attribute with 'nonnull_error' convention can only be applied to a "
"%select{function|method}1 with a completion handler with an error "
"parameter">;
def err_swift_async_error_non_integral : Error<
"%0 attribute with '%1' convention must have an integral-typed parameter "
"in completion handler at index %2, type here is %3">;
def warn_ignored_objc_externally_retained : Warning<
"'objc_externally_retained' can only be applied to local variables "
"%select{of retainable type|with strong ownership}0">,
@@ -4279,8 +4418,6 @@ def warn_diagnose_if_succeeded : Warning<"%0">, InGroup<UserDefinedWarnings>,
ShowInSystemHeader;
def note_ovl_candidate_disabled_by_function_cond_attr : Note<
"candidate disabled: %0">;
def note_ovl_candidate_disabled_by_extension : Note<
"candidate unavailable as it requires OpenCL extension '%0' to be enabled">;
def err_addrof_function_disabled_by_enable_if_attr : Error<
"cannot take address of function %0 because it has one or more "
"non-tautological enable_if conditions">;
@@ -5710,11 +5847,8 @@ def err_anon_bitfield_has_negative_width : Error<
"anonymous bit-field has negative width (%0)">;
def err_bitfield_has_zero_width : Error<"named bit-field %0 has zero width">;
def err_bitfield_width_exceeds_type_width : Error<
"width of bit-field %0 (%1 bits) exceeds %select{width|size}2 "
"of its type (%3 bit%s3)">;
def err_anon_bitfield_width_exceeds_type_width : Error<
"width of anonymous bit-field (%0 bits) exceeds %select{width|size}1 "
"of its type (%2 bit%s2)">;
"width of%select{ anonymous|}0 bit-field%select{| %1}0 (%2 bits) exceeds the "
"%select{width|size}3 of its type (%4 bit%s4)">;
def err_incorrect_number_of_vector_initializers : Error<
"number of elements must be either one or match the size of the vector">;
@@ -5753,6 +5887,9 @@ def note_goto_ms_asm_label : Note<
def warn_unused_label : Warning<"unused label %0">,
InGroup<UnusedLabel>, DefaultIgnore;
def err_continue_from_cond_var_init : Error<
"cannot jump from this continue statement to the loop increment; "
"jump bypasses initialization of loop condition variable">;
def err_goto_into_protected_scope : Error<
"cannot jump from this goto statement to its label">;
def ext_goto_into_protected_scope : ExtWarn<
@@ -6257,6 +6394,14 @@ def warn_pointer_arith_null_ptr : Warning<
def warn_gnu_null_ptr_arith : Warning<
"arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension">,
InGroup<NullPointerArithmetic>, DefaultIgnore;
def warn_pointer_sub_null_ptr : Warning<
"performing pointer subtraction with a null pointer %select{has|may have}0 undefined behavior">,
InGroup<NullPointerSubtraction>, DefaultIgnore;
def err_kernel_invalidates_sycl_unique_stable_name
: Error<"kernel instantiation changes the result of an evaluated "
"'__builtin_sycl_unique_stable_name'">;
def note_sycl_unique_stable_name_evaluated_here
: Note<"'__builtin_sycl_unique_stable_name' evaluated here">;
def warn_floatingpoint_eq : Warning<
"comparing floating point with == or != is unsafe">,
@@ -6351,19 +6496,6 @@ def warn_pessimizing_move_on_initialization : Warning<
InGroup<PessimizingMove>, DefaultIgnore;
def note_remove_move : Note<"remove std::move call here">;
def warn_return_std_move : Warning<
"local variable %0 will be copied despite being %select{returned|thrown}1 by name">,
InGroup<ReturnStdMove>, DefaultIgnore;
def note_add_std_move : Note<
"call 'std::move' explicitly to avoid copying">;
def warn_return_std_move_in_cxx11 : Warning<
"prior to the resolution of a defect report against ISO C++11, "
"local variable %0 would have been copied despite being returned by name, "
"due to its not matching the function return type%diff{ ($ vs $)|}1,2">,
InGroup<ReturnStdMoveInCXX11>, DefaultIgnore;
def note_add_std_move_in_cxx11 : Note<
"call 'std::move' explicitly to avoid copying on older compilers">;
def warn_string_plus_int : Warning<
"adding %0 to a string does not append to the string">,
InGroup<StringPlusInt>;
@@ -6637,11 +6769,14 @@ def warn_pointer_indirection_from_incompatible_type : Warning<
def warn_taking_address_of_packed_member : Warning<
"taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">,
InGroup<DiagGroup<"address-of-packed-member">>;
def warn_param_mismatched_alignment : Warning<
"passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may result in an unaligned pointer access">,
InGroup<DiagGroup<"align-mismatch">>;
def err_objc_object_assignment : Error<
"cannot assign to class object (%0 invalid)">;
def err_typecheck_invalid_operands : Error<
"invalid operands to binary expression (%0 and %1)">;
"invalid operands to binary expression (%0 and %1)">, Deferrable;
def note_typecheck_invalid_operands_converted : Note<
"%select{first|second}0 operand was implicitly converted to type %1">;
def err_typecheck_logical_vector_expr_gnu_cpp_restrict : Error<
@@ -6664,9 +6799,14 @@ def ext_typecheck_compare_complete_incomplete_pointers : Extension<
"%0 is %select{|in}2complete and "
"%1 is %select{|in}3complete">,
InGroup<C11>;
def warn_typecheck_ordered_comparison_of_function_pointers : Warning<
"ordered comparison of function pointers (%0 and %1)">,
InGroup<OrderedCompareFunctionPointers>;
def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
"ordered comparison of function pointers (%0 and %1)">,
InGroup<DiagGroup<"ordered-compare-function-pointers">>;
InGroup<OrderedCompareFunctionPointers>;
def err_typecheck_ordered_comparison_of_function_pointers : Error<
"ordered comparison of function pointers (%0 and %1)">;
def ext_typecheck_comparison_of_fptr_to_void : Extension<
"equality comparison between function pointer and void pointer (%0 and %1)">;
def err_typecheck_comparison_of_fptr_to_void : Error<
@@ -6762,6 +6902,10 @@ def warn_unsigned_always_true_comparison : Warning<
"result of comparison of %select{%3|unsigned expression}0 %2 "
"%select{unsigned expression|%3}0 is always %4">,
InGroup<TautologicalUnsignedZeroCompare>, DefaultIgnore;
def warn_unsigned_char_always_true_comparison : Warning<
"result of comparison of %select{%3|char expression}0 %2 "
"%select{char expression|%3}0 is always %4, since char is interpreted as "
"unsigned">, InGroup<TautologicalUnsignedCharZeroCompare>, DefaultIgnore;
def warn_unsigned_enum_always_true_comparison : Warning<
"result of comparison of %select{%3|unsigned enum expression}0 %2 "
"%select{unsigned enum expression|%3}0 is always %4">,
@@ -7172,6 +7316,9 @@ def err_need_header_before_typeid : Error<
"you need to include <typeinfo> before using the 'typeid' operator">;
def err_need_header_before_ms_uuidof : Error<
"you need to include <guiddef.h> before using the '__uuidof' operator">;
def err_need_header_before_placement_new : Error<
"no matching %0 function for non-allocating placement new expression; "
"include <new>">;
def err_ms___leave_not_in___try : Error<
"'__leave' statement not in __try block">;
def err_uuidof_without_guid : Error<
@@ -7299,6 +7446,12 @@ def warn_deprecated_volatile_structured_binding : Warning<
"volatile qualifier in structured binding declaration is deprecated">,
InGroup<DeprecatedVolatile>;
def warn_deprecated_altivec_src_compat : Warning<
"Current handling of vector bool and vector pixel types in this context are "
"deprecated. The default behaviour will soon change to that implied by the "
"'-altivec-compat=xl' option">,
InGroup<DiagGroup<"deprecated-altivec-src-compat">>;
def err_catch_incomplete_ptr : Error<
"cannot catch pointer to incomplete type %0">;
def err_catch_incomplete_ref : Error<
@@ -7401,9 +7554,10 @@ def err_conditional_vector_element_size : Error<
def err_conditional_vector_has_void : Error<
"GNU vector conditional operand cannot be %select{void|a throw expression}0">;
def err_conditional_vector_operand_type
: Error<"%select{enumeration|extended vector}0 type %1 is not allowed in a "
"vector conditional">;
def err_conditional_vector_mismatched_vectors
: Error<"enumeration type %0 is not allowed in a vector conditional">;
def err_conditional_vector_cond_result_mismatch
: Error<"cannot mix vectors and extended vectors in a vector conditional">;
def err_conditional_vector_mismatched
: Error<"vector operands to the vector conditional must be the same type "
"%diff{($ and $)|}0,1}">;
@@ -7439,6 +7593,8 @@ let CategoryName = "Lambda Issue" in {
"duration">;
def err_this_capture : Error<
"'this' cannot be %select{implicitly |}0captured in this context">;
def note_lambda_this_capture_fixit : Note<
"explicitly capture 'this'">;
def err_lambda_capture_anonymous_var : Error<
"unnamed variable cannot be implicitly captured in a lambda expression">;
def err_lambda_capture_flexarray_type : Error<
@@ -7447,6 +7603,10 @@ let CategoryName = "Lambda Issue" in {
def err_lambda_impcap : Error<
"variable %0 cannot be implicitly captured in a lambda with no "
"capture-default specified">;
def note_lambda_variable_capture_fixit : Note<
"capture %0 by %select{value|reference}1">;
def note_lambda_default_capture_fixit : Note<
"default capture by %select{value|reference}0">;
def note_lambda_decl : Note<"lambda expression begins here">;
def err_lambda_unevaluated_operand : Error<
"lambda expression in an unevaluated operand">;
@@ -7624,7 +7784,7 @@ def warn_condition_is_assignment : Warning<"using the result of an "
"assignment as a condition without parentheses">,
InGroup<Parentheses>;
def warn_free_nonheap_object
: Warning<"attempt to call %0 on non-heap object %1">,
: Warning<"attempt to call %0 on non-heap %select{object %2|object: block expression|object: lambda-to-function-pointer conversion}1">,
InGroup<FreeNonHeapObject>;
// Completely identical except off by default.
@@ -8156,6 +8316,9 @@ def err_atomic_op_needs_non_const_pointer : Error<
def err_atomic_op_needs_trivial_copy : Error<
"address argument to atomic operation must be a pointer to a "
"trivially-copyable type (%0 invalid)">;
def err_atomic_op_needs_atomic_int_ptr_or_fp : Error<
"address argument to atomic operation must be a pointer to %select{|atomic }0"
"integer, pointer or supported floating point type (%1 invalid)">;
def err_atomic_op_needs_atomic_int_or_ptr : Error<
"address argument to atomic operation must be a pointer to %select{|atomic }0"
"integer or pointer (%1 invalid)">;
@@ -8208,6 +8371,10 @@ def err_global_call_not_config : Error<
def err_ref_bad_target : Error<
"reference to %select{__device__|__global__|__host__|__host__ __device__}0 "
"%select{function|variable}1 %2 in %select{__device__|__global__|__host__|__host__ __device__}3 function">;
def note_cuda_const_var_unpromoted : Note<
"const variable cannot be emitted on device side due to dynamic initialization">;
def note_cuda_host_var : Note<
"host variable declared here">;
def err_ref_bad_target_global_initializer : Error<
"reference to %select{__device__|__global__|__host__|__host__ __device__}0 "
"function %1 in global initializer">;
@@ -8271,6 +8438,9 @@ def note_cuda_device_builtin_surftex_should_be_template_class : Note<
"%0 needs to be instantiated from a class template with proper "
"template arguments">;
def err_hip_invalid_args_builtin_mangled_name : Error<
"invalid argument: symbol must be a device-side function or global variable">;
def warn_non_pod_vararg_with_format_string : Warning<
"cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "
"%select{function|block|method|constructor}2; expected type from format "
@@ -8354,6 +8524,9 @@ def note_change_calling_conv_fixit : Note<
def warn_bad_function_cast : Warning<
"cast from function call of type %0 to non-matching type %1">,
InGroup<BadFunctionCast>, DefaultIgnore;
def warn_cast_function_type : Warning<
"cast %diff{from $ to $ |}0,1converts to incompatible function type">,
InGroup<CastFunctionType>, DefaultIgnore;
def err_cast_pointer_to_non_pointer_int : Error<
"pointer cannot be cast to type %0">;
def err_cast_to_bfloat16 : Error<"cannot type-cast to __bf16">;
@@ -8362,6 +8535,9 @@ def err_typecheck_expect_scalar_operand : Error<
"operand of type %0 where arithmetic or pointer type is required">;
def err_typecheck_cond_incompatible_operands : Error<
"incompatible operand types%diff{ ($ and $)|}0,1">;
def err_typecheck_expect_flt_or_vector : Error<
"invalid operand of type %0 where floating, complex or "
"a vector of such types is required">;
def err_cast_selector_expr : Error<
"cannot type cast @selector expression">;
def ext_typecheck_cond_incompatible_pointers : ExtWarn<
@@ -8492,6 +8668,7 @@ let CategoryName = "Inline Assembly Issue" in {
"asm constraint has an unexpected number of alternatives: %0 vs %1">;
def err_asm_incomplete_type : Error<"asm operand has incomplete type %0">;
def err_asm_unknown_register_name : Error<"unknown register name '%0' in asm">;
def err_asm_unwind_and_goto : Error<"unwind clobber can't be used with asm goto">;
def err_asm_invalid_global_var_reg : Error<"register '%0' unsuitable for "
"global register variables on this target">;
def err_asm_register_size_mismatch : Error<"size of register '%0' does not "
@@ -8539,6 +8716,12 @@ let CategoryName = "Inline Assembly Issue" in {
let CategoryName = "Semantic Issue" in {
def err_invalid_conversion_between_matrixes : Error<
"conversion between matrix types%diff{ $ and $|}0,1 of different size is not allowed">;
def err_invalid_conversion_between_matrix_and_type : Error<
"conversion between matrix type %0 and incompatible type %1 is not allowed">;
def err_invalid_conversion_between_vectors : Error<
"invalid conversion between vector type%diff{ $ and $|}0,1 of different "
"size">;
@@ -8547,7 +8730,7 @@ def err_invalid_conversion_between_vector_and_integer : Error<
"of different size">;
def err_opencl_function_pointer : Error<
"pointers to functions are not allowed">;
"%select{pointers|references}0 to functions are not allowed">;
def err_opencl_taking_address_capture : Error<
"taking address of a capture is not allowed">;
@@ -8574,6 +8757,15 @@ def warn_initializer_out_of_order : Warning<
"%select{field|base class}0 %1 will be initialized after "
"%select{field|base}2 %3">,
InGroup<ReorderCtor>, DefaultIgnore;
def warn_some_initializers_out_of_order : Warning<
"initializer order does not match the declaration order">,
InGroup<ReorderCtor>, DefaultIgnore;
def note_initializer_out_of_order : Note<
"%select{field|base class}0 %1 will be initialized after "
"%select{field|base}2 %3">;
def warn_abstract_vbase_init_ignored : Warning<
"initializer for virtual base class %0 of abstract class %1 "
"will never be used">,
@@ -8950,8 +9142,8 @@ def note_defaulted_comparison_calls_deleted : Note<
"defaulted %0 is implicitly deleted because it would invoke a deleted "
"comparison function%select{| for member %2| for base class %2}1">;
def note_defaulted_comparison_no_viable_function : Note<
"defaulted %0 is implicitly deleted because there is no viable comparison "
"function%select{| for member %2| for base class %2}1">;
"defaulted %0 is implicitly deleted because there is no viable three-way "
"comparison function for%select{| member| base class}1 %2">;
def note_defaulted_comparison_no_viable_function_synthesized : Note<
"three-way comparison cannot be synthesized because there is no viable "
"function for %select{'=='|'<'}0 comparison">;
@@ -9003,6 +9195,14 @@ def warn_array_index_precedes_bounds : Warning<
def warn_array_index_exceeds_bounds : Warning<
"array index %0 is past the end of the array (which contains %1 "
"element%s2)">, InGroup<ArrayBounds>;
def warn_ptr_arith_exceeds_max_addressable_bounds : Warning<
"the pointer incremented by %0 refers past the last possible element for an array in %1-bit "
"address space containing %2-bit (%3-byte) elements (max possible %4 element%s5)">,
InGroup<ArrayBounds>;
def warn_array_index_exceeds_max_addressable_bounds : Warning<
"array index %0 refers past the last possible element for an array in %1-bit "
"address space containing %2-bit (%3-byte) elements (max possible %4 element%s5)">,
InGroup<ArrayBounds>;
def note_array_declared_here : Note<
"array %0 declared here">;
@@ -9537,6 +9737,8 @@ def err_argument_not_shifted_byte : Error<
"argument should be an 8-bit value shifted by a multiple of 8 bits">;
def err_argument_not_shifted_byte_or_xxff : Error<
"argument should be an 8-bit value shifted by a multiple of 8 bits, or in the form 0x??FF">;
def err_argument_not_contiguous_bit_field : Error<
"argument %0 value should represent a contiguous bit field">;
def err_rotation_argument_to_cadd
: Error<"argument should be the value 90 or 270">;
def err_rotation_argument_to_cmla
@@ -9565,8 +9767,8 @@ def err_mips_builtin_requires_dspr2 : Error<
"this builtin requires 'dsp r2' ASE, please use -mdspr2">;
def err_mips_builtin_requires_msa : Error<
"this builtin requires 'msa' ASE, please use -mmsa">;
def err_ppc_builtin_only_on_pwr7 : Error<
"this builtin is only valid on POWER7 or later CPUs">;
def err_ppc_builtin_only_on_arch : Error<
"this builtin is only valid on POWER%0 or later CPUs">;
def err_ppc_invalid_use_mma_type : Error<
"invalid use of PPC MMA type">;
def err_x86_builtin_invalid_rounding : Error<
@@ -9618,7 +9820,7 @@ def warn_duplicate_attribute_exact : Warning<
"attribute %0 is already applied">, InGroup<IgnoredAttributes>;
def warn_duplicate_attribute : Warning<
"attribute %0 is already applied with different parameters">,
"attribute %0 is already applied with different arguments">,
InGroup<IgnoredAttributes>;
def warn_sync_fetch_and_nand_semantics_change : Warning<
@@ -9886,13 +10088,20 @@ def err_opencl_pointer_to_type : Error<
"pointer to type %0 is invalid in OpenCL">;
def err_opencl_type_can_only_be_used_as_function_parameter : Error <
"type %0 can only be used as a function parameter in OpenCL">;
def err_opencl_type_not_found : Error<
"%0 type %1 not found; include the base header with -finclude-default-header">;
def warn_opencl_attr_deprecated_ignored : Warning <
"%0 attribute is deprecated and ignored in OpenCL version %1">,
InGroup<IgnoredAttributes>;
def err_opencl_variadic_function : Error<
"invalid prototype, variadic arguments are not allowed in OpenCL">;
def err_opencl_requires_extension : Error<
"use of %select{type|declaration}0 %1 requires %2 extension to be enabled">;
"use of %select{type|declaration}0 %1 requires %2 support">;
def ext_opencl_double_without_pragma : Extension<
"Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is"
" supported">;
def err_opencl_double_requires_extension : Error<
"use of type 'double' requires %select{cl_khr_fp64|cl_khr_fp64 and __opencl_c_fp64}0 support">;
def warn_opencl_generic_address_space_arg : Warning<
"passing non-generic address space pointer to %0"
" may cause dynamic conversion affecting performance">,
@@ -9912,7 +10121,8 @@ def err_opencl_builtin_pipe_invalid_access_modifier : Error<
def err_opencl_invalid_access_qualifier : Error<
"access qualifier can only be used for pipe and image type">;
def err_opencl_invalid_read_write : Error<
"access qualifier %0 can not be used for %1 %select{|prior to OpenCL version 2.0}2">;
"access qualifier %0 can not be used for %1 %select{|prior to OpenCL C version 2.0 or in version 3.0 "
"and without __opencl_c_read_write_images feature}2">;
def err_opencl_multiple_access_qualifiers : Error<
"multiple access qualifiers">;
def note_opencl_typedef_access_qualifier : Note<
@@ -9947,9 +10157,9 @@ def err_opencl_enqueue_kernel_blocks_no_args : Error<
def err_opencl_builtin_expected_type : Error<
"illegal call to %0, expected %1 argument type">;
// OpenCL v2.2 s2.1.2.3 - Vector Component Access
// OpenCL v3.0 s6.3.7 - Vector Components
def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
"vector component name '%0' is an OpenCL version 2.2 feature">,
"vector component name '%0' is an OpenCL C version 3.0 feature">,
InGroup<OpenCLUnsupportedRGBA>;
def err_openclcxx_placement_new : Error<
@@ -10101,8 +10311,6 @@ def warn_omp_alignment_not_power_of_two : Warning<
InGroup<OpenMPClauses>;
def err_omp_invalid_target_decl : Error<
"%0 used in declare target directive is not a variable or a function name">;
def err_omp_declare_target_multiple : Error<
"%0 appears multiple times in clauses on the same declare target directive">;
def err_omp_declare_target_to_and_link : Error<
"%0 must not appear in both clauses 'to' and 'link'">;
def warn_omp_not_in_target_context : Warning<
@@ -10465,6 +10673,8 @@ def err_omp_expected_private_copy_for_allocate : Error<
"the referenced item is not found in any private clause on the same directive">;
def err_omp_stmt_depends_on_loop_counter : Error<
"the loop %select{initializer|condition}0 expression depends on the current loop control variable">;
def err_omp_invariant_dependency : Error<
"expected loop invariant expression">;
def err_omp_invariant_or_linear_dependency : Error<
"expected loop invariant expression or '<invariant1> * %0 + <invariant2>' kind of expression">;
def err_omp_wrong_dependency_iterator_type : Error<
@@ -10554,6 +10764,23 @@ def note_omp_protected_structured_block
: Note<"jump bypasses OpenMP structured block">;
def note_omp_exits_structured_block
: Note<"jump exits scope of OpenMP structured block">;
def err_omp_interop_variable_expected : Error<
"expected%select{| non-const}0 variable of type 'omp_interop_t'">;
def err_omp_interop_variable_wrong_type : Error<
"interop variable must be of type 'omp_interop_t'">;
def err_omp_interop_prefer_type : Error<
"prefer_list item must be a string literal or constant integral "
"expression">;
def err_omp_interop_bad_depend_clause : Error<
"'depend' clause requires the 'targetsync' interop type">;
def err_omp_interop_var_multiple_actions : Error<
"interop variable %0 used in multiple action clauses">;
def err_omp_dispatch_statement_call
: Error<"statement after '#pragma omp dispatch' must be a direct call"
" to a target function or an assignment to one">;
def err_omp_unroll_full_variable_trip_count : Error<
"loop to be fully unrolled must have a constant trip count">;
def note_omp_directive_here : Note<"'%0' directive found here">;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {
@@ -11119,4 +11346,10 @@ def err_tcb_conflicting_attributes : Error<
def warn_tcb_enforcement_violation : Warning<
"calling %0 is a violation of trusted computing base '%1'">,
InGroup<DiagGroup<"tcb-enforcement">>;
// RISC-V builtin required extension warning
def err_riscv_builtin_requires_extension : Error<
"builtin requires '%0' extension support to be enabled">;
def err_riscv_builtin_invalid_lmul : Error<
"LMUL argument must be in the range [0,3] or [5,7]">;
} // end of sema component.
@@ -69,6 +69,9 @@ def err_module_file_not_module : Error<
"AST file '%0' was not built as a module">, DefaultFatal;
def err_module_file_missing_top_level_submodule : Error<
"module file '%0' is missing its top-level submodule">, DefaultFatal;
def note_module_file_conflict : Note<
"this is generally caused by modules with the same name found in multiple "
"paths">;
def remark_module_import : Remark<
"importing module '%0'%select{| into '%3'}2 from '%1'">,
@@ -120,8 +120,7 @@ template <class RefTy> class MapEntryOptionalStorage {
MapEntryOptionalStorage() : MaybeRef(optional_none_tag()) {}
template <class... ArgTypes>
explicit MapEntryOptionalStorage(llvm::optional_detail::in_place_t,
ArgTypes &&...Args)
explicit MapEntryOptionalStorage(llvm::in_place_t, ArgTypes &&...Args)
: MaybeRef(std::forward<ArgTypes>(Args)...) {}
void reset() { MaybeRef = optional_none_tag(); }
@@ -49,6 +49,7 @@ FEATURE(memtag_sanitizer, LangOpts.Sanitize.has(SanitizerKind::MemTag))
FEATURE(xray_instrument, LangOpts.XRayInstrument)
FEATURE(undefined_behavior_sanitizer,
LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
FEATURE(coverage_sanitizer, LangOpts.SanitizeCoverage)
FEATURE(assume_nonnull, true)
FEATURE(attribute_analyzer_noreturn, true)
FEATURE(attribute_availability, true)
@@ -92,6 +93,9 @@ FEATURE(memory_sanitizer,
FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread))
FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow))
FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo))
FEATURE(swiftasynccc,
PP.getTargetInfo().checkCallingConvention(CC_SwiftAsync) ==
clang::TargetInfo::CCCR_OK)
// Objective-C features
FEATURE(objc_arr, LangOpts.ObjCAutoRefCount) // FIXME: REMOVE?
FEATURE(objc_arc, LangOpts.ObjCAutoRefCount)
@@ -253,9 +257,12 @@ EXTENSION(cxx_variable_templates, LangOpts.CPlusPlus)
EXTENSION(overloadable_unmarked, true)
EXTENSION(pragma_clang_attribute_namespaces, true)
EXTENSION(pragma_clang_attribute_external_declaration, true)
EXTENSION(statement_attributes_with_gnu_syntax, true)
EXTENSION(gnu_asm, LangOpts.GNUAsm)
EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
EXTENSION(matrix_types, LangOpts.MatrixTypes)
EXTENSION(matrix_types_scalar_division, true)
EXTENSION(cxx_attributes_on_using_declarations, LangOpts.CPlusPlus11)
FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVTables)
@@ -40,6 +40,14 @@ class LangOptions;
class MultiKeywordSelector;
class SourceLocation;
enum class ReservedIdentifierStatus {
NotReserved = 0,
StartsWithUnderscoreAtGlobalScope,
StartsWithDoubleUnderscore,
StartsWithUnderscoreFollowedByCapitalLetter,
ContainsDoubleUnderscore,
};
/// A simple pair of identifier info and location.
using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>;
@@ -48,7 +56,7 @@ using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>;
/// of a pointer to one of these classes.
enum { IdentifierInfoAlignment = 8 };
static constexpr int ObjCOrBuiltinIDBits = 15;
static constexpr int ObjCOrBuiltinIDBits = 16;
/// One of these records is kept for each identifier that
/// is lexed. This contains information about whether the token was \#define'd,
@@ -385,14 +393,7 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
/// Determine whether \p this is a name reserved for the implementation (C99
/// 7.1.3, C++ [lib.global.names]).
bool isReservedName(bool doubleUnderscoreOnly = false) const {
if (getLength() < 2)
return false;
const char *Name = getNameStart();
return Name[0] == '_' &&
(Name[1] == '_' ||
(Name[1] >= 'A' && Name[1] <= 'Z' && !doubleUnderscoreOnly));
}
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const;
/// Provide less than operator for lexicographical sorting.
bool operator<(const IdentifierInfo &RHS) const {
@@ -22,6 +22,9 @@
// None.h includes an enumerator that is desired & cannot be forward declared
// without a definition of NoneType.
#include "llvm/ADT/None.h"
// Add this header as a workaround to prevent `too few template arguments for
// class template 'SmallVector'` building error with build compilers like XL.
#include "llvm/ADT/SmallVector.h"
namespace llvm {
// ADT's.

Some files were not shown because too many files have changed in this diff Show More