diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index df713cfd1fb0fe..91f55fc04b8514 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -40,6 +40,290 @@ # xargs -n1 | sort | uniq -d; # done +# 2021mmdd: new clang import which bumps version from 11.0.1 to 12.0.0. +OLD_FILES+=usr/lib/clang/11.0.1/include/cuda_wrappers/algorithm +OLD_FILES+=usr/lib/clang/11.0.1/include/cuda_wrappers/complex +OLD_FILES+=usr/lib/clang/11.0.1/include/cuda_wrappers/new +OLD_DIRS+=usr/lib/clang/11.0.1/include/cuda_wrappers +OLD_FILES+=usr/lib/clang/11.0.1/include/fuzzer/FuzzedDataProvider.h +OLD_DIRS+=usr/lib/clang/11.0.1/include/fuzzer +OLD_FILES+=usr/lib/clang/11.0.1/include/openmp_wrappers/__clang_openmp_device_functions.h +OLD_FILES+=usr/lib/clang/11.0.1/include/openmp_wrappers/cmath +OLD_FILES+=usr/lib/clang/11.0.1/include/openmp_wrappers/complex +OLD_FILES+=usr/lib/clang/11.0.1/include/openmp_wrappers/complex.h +OLD_FILES+=usr/lib/clang/11.0.1/include/openmp_wrappers/math.h +OLD_FILES+=usr/lib/clang/11.0.1/include/openmp_wrappers/new +OLD_DIRS+=usr/lib/clang/11.0.1/include/openmp_wrappers +OLD_FILES+=usr/lib/clang/11.0.1/include/ppc_wrappers/emmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ppc_wrappers/mm_malloc.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ppc_wrappers/mmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ppc_wrappers/pmmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ppc_wrappers/smmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ppc_wrappers/tmmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ppc_wrappers/xmmintrin.h +OLD_DIRS+=usr/lib/clang/11.0.1/include/ppc_wrappers +OLD_FILES+=usr/lib/clang/11.0.1/include/profile/InstrProfData.inc +OLD_DIRS+=usr/lib/clang/11.0.1/include/profile +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/allocator_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/asan_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/common_interface_defs.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/coverage_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/dfsan_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/hwasan_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/linux_syscall_hooks.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/lsan_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/msan_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/netbsd_syscall_hooks.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/scudo_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/tsan_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/tsan_interface_atomic.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sanitizer/ubsan_interface.h +OLD_DIRS+=usr/lib/clang/11.0.1/include/sanitizer +OLD_FILES+=usr/lib/clang/11.0.1/include/xray/xray_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/xray/xray_log_interface.h +OLD_FILES+=usr/lib/clang/11.0.1/include/xray/xray_records.h +OLD_DIRS+=usr/lib/clang/11.0.1/include/xray +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_cuda_builtin_vars.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_cuda_cmath.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_cuda_complex_builtins.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_cuda_device_functions.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_cuda_intrinsics.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_cuda_libdevice_declares.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_cuda_math.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_cuda_math_forward_declares.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_cuda_runtime_wrapper.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_hip_libdevice_declares.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_hip_math.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__clang_hip_runtime_wrapper.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__stddef_max_align_t.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__wmmintrin_aes.h +OLD_FILES+=usr/lib/clang/11.0.1/include/__wmmintrin_pclmul.h +OLD_FILES+=usr/lib/clang/11.0.1/include/adxintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/altivec.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ammintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/amxintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/arm64intr.h +OLD_FILES+=usr/lib/clang/11.0.1/include/arm_acle.h +OLD_FILES+=usr/lib/clang/11.0.1/include/arm_bf16.h +OLD_FILES+=usr/lib/clang/11.0.1/include/arm_cde.h +OLD_FILES+=usr/lib/clang/11.0.1/include/arm_cmse.h +OLD_FILES+=usr/lib/clang/11.0.1/include/arm_fp16.h +OLD_FILES+=usr/lib/clang/11.0.1/include/arm_mve.h +OLD_FILES+=usr/lib/clang/11.0.1/include/arm_neon.h +OLD_FILES+=usr/lib/clang/11.0.1/include/arm_sve.h +OLD_FILES+=usr/lib/clang/11.0.1/include/armintr.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx2intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512bf16intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512bitalgintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512bwintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512cdintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512dqintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512erintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512fintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512ifmaintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512ifmavlintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512pfintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vbmi2intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vbmiintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vbmivlintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vlbf16intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vlbitalgintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vlbwintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vlcdintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vldqintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vlintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vlvbmi2intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vlvnniintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vlvp2intersectintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vnniintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vp2intersectintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vpopcntdqintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avx512vpopcntdqvlintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/avxintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/bmi2intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/bmiintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/cet.h +OLD_FILES+=usr/lib/clang/11.0.1/include/cetintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/cldemoteintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/clflushoptintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/clwbintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/clzerointrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/cpuid.h +OLD_FILES+=usr/lib/clang/11.0.1/include/emmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/enqcmdintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/f16cintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/float.h +OLD_FILES+=usr/lib/clang/11.0.1/include/fma4intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/fmaintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/fxsrintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/gfniintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/htmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/htmxlintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ia32intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/immintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/inttypes.h +OLD_FILES+=usr/lib/clang/11.0.1/include/invpcidintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/iso646.h +OLD_FILES+=usr/lib/clang/11.0.1/include/limits.h +OLD_FILES+=usr/lib/clang/11.0.1/include/lwpintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/lzcntintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/mm3dnow.h +OLD_FILES+=usr/lib/clang/11.0.1/include/mm_malloc.h +OLD_FILES+=usr/lib/clang/11.0.1/include/mmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/module.modulemap +OLD_FILES+=usr/lib/clang/11.0.1/include/movdirintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/msa.h +OLD_FILES+=usr/lib/clang/11.0.1/include/mwaitxintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/nmmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/omp-tools.h +OLD_FILES+=usr/lib/clang/11.0.1/include/omp.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ompt.h +OLD_FILES+=usr/lib/clang/11.0.1/include/opencl-c-base.h +OLD_FILES+=usr/lib/clang/11.0.1/include/opencl-c.h +OLD_FILES+=usr/lib/clang/11.0.1/include/pconfigintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/pkuintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/pmmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/popcntintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/prfchwintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/ptwriteintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/rdseedintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/rtmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/s390intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/serializeintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/sgxintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/shaintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/smmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/stdalign.h +OLD_FILES+=usr/lib/clang/11.0.1/include/stdarg.h +OLD_FILES+=usr/lib/clang/11.0.1/include/stdatomic.h +OLD_FILES+=usr/lib/clang/11.0.1/include/stdbool.h +OLD_FILES+=usr/lib/clang/11.0.1/include/stddef.h +OLD_FILES+=usr/lib/clang/11.0.1/include/stdint.h +OLD_FILES+=usr/lib/clang/11.0.1/include/stdnoreturn.h +OLD_FILES+=usr/lib/clang/11.0.1/include/tbmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/tgmath.h +OLD_FILES+=usr/lib/clang/11.0.1/include/tmmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/tsxldtrkintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/unwind.h +OLD_FILES+=usr/lib/clang/11.0.1/include/vadefs.h +OLD_FILES+=usr/lib/clang/11.0.1/include/vaesintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/varargs.h +OLD_FILES+=usr/lib/clang/11.0.1/include/vecintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/vpclmulqdqintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/waitpkgintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/wasm_simd128.h +OLD_FILES+=usr/lib/clang/11.0.1/include/wbnoinvdintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/wmmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/x86intrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/xmmintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/xopintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/xsavecintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/xsaveintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/xsaveoptintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/xsavesintrin.h +OLD_FILES+=usr/lib/clang/11.0.1/include/xtestintrin.h +OLD_DIRS+=usr/lib/clang/11.0.1/include +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-aarch64.so +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-arm.so +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-armhf.so +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-i386.so +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-preinit-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-preinit-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-preinit-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-preinit-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-preinit-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-x86_64.so +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan_cxx-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan_cxx-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan_cxx-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan_cxx-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan_cxx-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi_diag-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi_diag-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi_diag-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi_diag-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.cfi_diag-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.dd-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.dd-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.fuzzer-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.fuzzer-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.fuzzer_no_main-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.fuzzer_no_main-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.msan-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.msan-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.msan_cxx-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.msan_cxx-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.profile-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.profile-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.profile-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.profile-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.profile-powerpc.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.profile-powerpc64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.profile-powerpc64le.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.profile-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.safestack-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.safestack-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.safestack-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats_client-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats_client-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats_client-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats_client-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.stats_client-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.tsan-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.tsan-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.tsan_cxx-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.tsan_cxx-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_minimal-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_minimal-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_minimal-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_minimal-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_minimal-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-i386.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-basic-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-basic-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-basic-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-basic-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-fdr-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-fdr-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-fdr-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-fdr-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-profiling-aarch64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-profiling-arm.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-profiling-armhf.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-profiling-x86_64.a +OLD_FILES+=usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.xray-x86_64.a +OLD_DIRS+=usr/lib/clang/11.0.1/lib/freebsd +OLD_DIRS+=usr/lib/clang/11.0.1/lib +OLD_DIRS+=usr/lib/clang/11.0.1 + # 20210611: Remove svn and svnlite OLD_FILES+=usr/bin/svn OLD_FILES+=usr/bin/svnadmin diff --git a/contrib/llvm-project/clang/include/clang-c/Index.h b/contrib/llvm-project/clang/include/clang-c/Index.h index 5fa728d6d66c84..e305283bbaf197 100644 --- a/contrib/llvm-project/clang/include/clang-c/Index.h +++ b/contrib/llvm-project/clang/include/clang-c/Index.h @@ -33,7 +33,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 60 +#define CINDEX_VERSION_MINOR 61 #define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1)) @@ -2052,62 +2052,58 @@ enum CXCursorKind { */ CXCursor_CXXFunctionalCastExpr = 128, - /** OpenCL's addrspace_cast<> expression. - */ - CXCursor_CXXAddrspaceCastExpr = 129, - /** A C++ typeid expression (C++ [expr.typeid]). */ - CXCursor_CXXTypeidExpr = 130, + CXCursor_CXXTypeidExpr = 129, /** [C++ 2.13.5] C++ Boolean Literal. */ - CXCursor_CXXBoolLiteralExpr = 131, + CXCursor_CXXBoolLiteralExpr = 130, /** [C++0x 2.14.7] C++ Pointer Literal. */ - CXCursor_CXXNullPtrLiteralExpr = 132, + CXCursor_CXXNullPtrLiteralExpr = 131, /** Represents the "this" expression in C++ */ - CXCursor_CXXThisExpr = 133, + CXCursor_CXXThisExpr = 132, /** [C++ 15] C++ Throw Expression. * * This handles 'throw' and 'throw' assignment-expression. When * assignment-expression isn't present, Op will be null. */ - CXCursor_CXXThrowExpr = 134, + CXCursor_CXXThrowExpr = 133, /** A new expression for memory allocation and constructor calls, e.g: * "new CXXNewExpr(foo)". */ - CXCursor_CXXNewExpr = 135, + CXCursor_CXXNewExpr = 134, /** A delete expression for memory deallocation and destructor calls, * e.g. "delete[] pArray". */ - CXCursor_CXXDeleteExpr = 136, + CXCursor_CXXDeleteExpr = 135, /** A unary expression. (noexcept, sizeof, or other traits) */ - CXCursor_UnaryExpr = 137, + CXCursor_UnaryExpr = 136, /** An Objective-C string literal i.e. @"foo". */ - CXCursor_ObjCStringLiteral = 138, + CXCursor_ObjCStringLiteral = 137, /** An Objective-C \@encode expression. */ - CXCursor_ObjCEncodeExpr = 139, + CXCursor_ObjCEncodeExpr = 138, /** An Objective-C \@selector expression. */ - CXCursor_ObjCSelectorExpr = 140, + CXCursor_ObjCSelectorExpr = 139, /** An Objective-C \@protocol expression. */ - CXCursor_ObjCProtocolExpr = 141, + CXCursor_ObjCProtocolExpr = 140, /** An Objective-C "bridged" cast expression, which casts between * Objective-C pointers and C pointers, transferring ownership in the process. @@ -2116,7 +2112,7 @@ enum CXCursorKind { * NSString *str = (__bridge_transfer NSString *)CFCreateString(); * \endcode */ - CXCursor_ObjCBridgedCastExpr = 142, + CXCursor_ObjCBridgedCastExpr = 141, /** Represents a C++0x pack expansion that produces a sequence of * expressions. @@ -2131,7 +2127,7 @@ enum CXCursorKind { * } * \endcode */ - CXCursor_PackExpansionExpr = 143, + CXCursor_PackExpansionExpr = 142, /** Represents an expression that computes the length of a parameter * pack. @@ -2143,7 +2139,7 @@ enum CXCursorKind { * }; * \endcode */ - CXCursor_SizeOfPackExpr = 144, + CXCursor_SizeOfPackExpr = 143, /* Represents a C++ lambda expression that produces a local function * object. @@ -2157,39 +2153,43 @@ enum CXCursorKind { * } * \endcode */ - CXCursor_LambdaExpr = 145, + CXCursor_LambdaExpr = 144, /** Objective-c Boolean Literal. */ - CXCursor_ObjCBoolLiteralExpr = 146, + CXCursor_ObjCBoolLiteralExpr = 145, /** Represents the "self" expression in an Objective-C method. */ - CXCursor_ObjCSelfExpr = 147, + CXCursor_ObjCSelfExpr = 146, /** OpenMP 5.0 [2.1.5, Array Section]. */ - CXCursor_OMPArraySectionExpr = 148, + CXCursor_OMPArraySectionExpr = 147, /** Represents an @available(...) check. */ - CXCursor_ObjCAvailabilityCheckExpr = 149, + CXCursor_ObjCAvailabilityCheckExpr = 148, /** * Fixed point literal */ - CXCursor_FixedPointLiteral = 150, + CXCursor_FixedPointLiteral = 149, /** OpenMP 5.0 [2.1.4, Array Shaping]. */ - CXCursor_OMPArrayShapingExpr = 151, + CXCursor_OMPArrayShapingExpr = 150, /** * OpenMP 5.0 [2.1.6 Iterators] */ - CXCursor_OMPIteratorExpr = 152, + CXCursor_OMPIteratorExpr = 151, - CXCursor_LastExpr = CXCursor_OMPIteratorExpr, + /** OpenCL's addrspace_cast<> expression. + */ + CXCursor_CXXAddrspaceCastExpr = 152, + + CXCursor_LastExpr = CXCursor_CXXAddrspaceCastExpr, /* Statements */ CXCursor_FirstStmt = 200, @@ -2940,6 +2940,26 @@ CINDEX_LINKAGE int clang_getCursorPlatformAvailability( CINDEX_LINKAGE void clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability); +/** + * If cursor refers to a variable declaration and it has initializer returns + * cursor referring to the initializer otherwise return null cursor. + */ +CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor); + +/** + * If cursor refers to a variable declaration that has global storage returns 1. + * If cursor refers to a variable declaration that doesn't have global storage + * returns 0. Otherwise returns -1. + */ +CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor); + +/** + * If cursor refers to a variable declaration that has external storage + * returns 1. If cursor refers to a variable declaration that doesn't have + * external storage returns 0. Otherwise returns -1. + */ +CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor); + /** * Describe the "language" of the entity referred to by a cursor. */ @@ -3841,7 +3861,15 @@ enum CXTypeNullabilityKind { /** * Nullability is not applicable to this type. */ - CXTypeNullability_Invalid = 3 + CXTypeNullability_Invalid = 3, + + /** + * Generally behaves like Nullable, except when used in a block parameter that + * was imported into a swift async method. There, swift will assume that the + * parameter can get null even if no error occured. _Nullable parameters are + * assumed to only get null on error. + */ + CXTypeNullability_NullableResult = 4 }; /** diff --git a/contrib/llvm-project/clang/include/clang-c/Rewrite.h b/contrib/llvm-project/clang/include/clang-c/Rewrite.h new file mode 100644 index 00000000000000..ce1b05594b3843 --- /dev/null +++ b/contrib/llvm-project/clang/include/clang-c/Rewrite.h @@ -0,0 +1,63 @@ +/*===-- clang-c/Rewrite.h - C CXRewriter --------------------------*- 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_C_REWRITE_H +#define LLVM_CLANG_C_REWRITE_H + +#include "clang-c/CXString.h" +#include "clang-c/ExternC.h" +#include "clang-c/Index.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +typedef void *CXRewriter; + +/** + * Create CXRewriter. + */ +CINDEX_LINKAGE CXRewriter clang_CXRewriter_create(CXTranslationUnit TU); + +/** + * Insert the specified string at the specified location in the original buffer. + */ +CINDEX_LINKAGE void clang_CXRewriter_insertTextBefore(CXRewriter Rew, CXSourceLocation Loc, + const char *Insert); + +/** + * Replace the specified range of characters in the input with the specified + * replacement. + */ +CINDEX_LINKAGE void clang_CXRewriter_replaceText(CXRewriter Rew, CXSourceRange ToBeReplaced, + const char *Replacement); + +/** + * Remove the specified range. + */ +CINDEX_LINKAGE void clang_CXRewriter_removeText(CXRewriter Rew, CXSourceRange ToBeRemoved); + +/** + * Save all changed files to disk. + * Returns 1 if any files were not saved successfully, returns 0 otherwise. + */ +CINDEX_LINKAGE int clang_CXRewriter_overwriteChangedFiles(CXRewriter Rew); + +/** + * Write out rewritten version of the main file to stdout. + */ +CINDEX_LINKAGE void clang_CXRewriter_writeMainFileToStdOut(CXRewriter Rew); + +/** + * Free the given CXRewriter. + */ +CINDEX_LINKAGE void clang_CXRewriter_dispose(CXRewriter Rew); + +LLVM_CLANG_C_EXTERN_C_END + +#endif diff --git a/contrib/llvm-project/clang/include/clang/APINotes/APINotesYAMLCompiler.h b/contrib/llvm-project/clang/include/clang/APINotes/APINotesYAMLCompiler.h new file mode 100644 index 00000000000000..6098d0ee36fc47 --- /dev/null +++ b/contrib/llvm-project/clang/include/clang/APINotes/APINotesYAMLCompiler.h @@ -0,0 +1,24 @@ +//===-- APINotesYAMLCompiler.h - API Notes YAML Format Reader ---*- 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_APINOTES_APINOTESYAMLCOMPILER_H +#define LLVM_CLANG_APINOTES_APINOTESYAMLCOMPILER_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/raw_ostream.h" + +namespace clang { +namespace api_notes { +/// Parses the APINotes YAML content and writes the representation back to the +/// specified stream. This provides a means of testing the YAML processing of +/// the APINotes format. +bool parseAndDumpAPINotes(llvm::StringRef YI, llvm::raw_ostream &OS); +} // namespace api_notes +} // namespace clang + +#endif diff --git a/contrib/llvm-project/clang/include/clang/APINotes/Types.h b/contrib/llvm-project/clang/include/clang/APINotes/Types.h new file mode 100644 index 00000000000000..d9bf2f07291f5b --- /dev/null +++ b/contrib/llvm-project/clang/include/clang/APINotes/Types.h @@ -0,0 +1,734 @@ +//===-- Types.h - API Notes Data Types --------------------------*- 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_APINOTES_TYPES_H +#define LLVM_CLANG_APINOTES_TYPES_H + +#include "clang/Basic/Specifiers.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringRef.h" +#include +#include + +namespace clang { +namespace api_notes { +enum class RetainCountConventionKind { + None, + CFReturnsRetained, + CFReturnsNotRetained, + NSReturnsRetained, + NSReturnsNotRetained, +}; + +/// The payload for an enum_extensibility attribute. This is a tri-state rather +/// than just a boolean because the presence of the attribute indicates +/// auditing. +enum class EnumExtensibilityKind { + None, + Open, + Closed, +}; + +/// The kind of a swift_wrapper/swift_newtype. +enum class SwiftNewTypeKind { + None, + Struct, + Enum, +}; + +/// Describes API notes data for any entity. +/// +/// This is used as the base of all API notes. +class CommonEntityInfo { +public: + /// Message to use when this entity is unavailable. + std::string UnavailableMsg; + + /// Whether this entity is marked unavailable. + unsigned Unavailable : 1; + + /// Whether this entity is marked unavailable in Swift. + unsigned UnavailableInSwift : 1; + +private: + /// Whether SwiftPrivate was specified. + unsigned SwiftPrivateSpecified : 1; + + /// Whether this entity is considered "private" to a Swift overlay. + unsigned SwiftPrivate : 1; + +public: + /// Swift name of this entity. + std::string SwiftName; + + CommonEntityInfo() + : Unavailable(0), UnavailableInSwift(0), SwiftPrivateSpecified(0), + SwiftPrivate(0) {} + + llvm::Optional isSwiftPrivate() const { + return SwiftPrivateSpecified ? llvm::Optional(SwiftPrivate) + : llvm::None; + } + + void setSwiftPrivate(llvm::Optional Private) { + SwiftPrivateSpecified = Private.hasValue(); + SwiftPrivate = Private.hasValue() ? *Private : 0; + } + + friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &); + + CommonEntityInfo &operator|=(const CommonEntityInfo &RHS) { + // Merge unavailability. + if (RHS.Unavailable) { + Unavailable = true; + if (UnavailableMsg.empty()) + UnavailableMsg = RHS.UnavailableMsg; + } + + if (RHS.UnavailableInSwift) { + UnavailableInSwift = true; + if (UnavailableMsg.empty()) + UnavailableMsg = RHS.UnavailableMsg; + } + + if (!SwiftPrivateSpecified) + setSwiftPrivate(RHS.isSwiftPrivate()); + + if (SwiftName.empty()) + SwiftName = RHS.SwiftName; + + return *this; + } + + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const; +}; + +inline bool operator==(const CommonEntityInfo &LHS, + const CommonEntityInfo &RHS) { + return LHS.UnavailableMsg == RHS.UnavailableMsg && + LHS.Unavailable == RHS.Unavailable && + LHS.UnavailableInSwift == RHS.UnavailableInSwift && + LHS.SwiftPrivateSpecified == RHS.SwiftPrivateSpecified && + LHS.SwiftPrivate == RHS.SwiftPrivate && LHS.SwiftName == RHS.SwiftName; +} + +inline bool operator!=(const CommonEntityInfo &LHS, + const CommonEntityInfo &RHS) { + return !(LHS == RHS); +} + +/// Describes API notes for types. +class CommonTypeInfo : public CommonEntityInfo { + /// The Swift type to which a given type is bridged. + /// + /// Reflects the swift_bridge attribute. + llvm::Optional SwiftBridge; + + /// The NS error domain for this type. + llvm::Optional NSErrorDomain; + +public: + CommonTypeInfo() : CommonEntityInfo() {} + + const llvm::Optional &getSwiftBridge() const { + return SwiftBridge; + } + + void setSwiftBridge(const llvm::Optional &SwiftType) { + SwiftBridge = SwiftType; + } + + void setSwiftBridge(const llvm::Optional &SwiftType) { + SwiftBridge = SwiftType + ? llvm::Optional(std::string(*SwiftType)) + : llvm::None; + } + + const llvm::Optional &getNSErrorDomain() const { + return NSErrorDomain; + } + + void setNSErrorDomain(const llvm::Optional &Domain) { + NSErrorDomain = Domain; + } + + void setNSErrorDomain(const llvm::Optional &Domain) { + NSErrorDomain = + Domain ? llvm::Optional(std::string(*Domain)) : llvm::None; + } + + friend bool operator==(const CommonTypeInfo &, const CommonTypeInfo &); + + CommonTypeInfo &operator|=(const CommonTypeInfo &RHS) { + // Merge inherited info. + static_cast(*this) |= RHS; + + if (!SwiftBridge) + setSwiftBridge(RHS.getSwiftBridge()); + if (!NSErrorDomain) + setNSErrorDomain(RHS.getNSErrorDomain()); + + return *this; + } + + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const; +}; + +inline bool operator==(const CommonTypeInfo &LHS, const CommonTypeInfo &RHS) { + return static_cast(LHS) == RHS && + LHS.SwiftBridge == RHS.SwiftBridge && + LHS.NSErrorDomain == RHS.NSErrorDomain; +} + +inline bool operator!=(const CommonTypeInfo &LHS, const CommonTypeInfo &RHS) { + return !(LHS == RHS); +} + +/// Describes API notes data for an Objective-C class or protocol. +class ObjCContextInfo : public CommonTypeInfo { + /// Whether this class has a default nullability. + unsigned HasDefaultNullability : 1; + + /// The default nullability. + unsigned DefaultNullability : 2; + + /// Whether this class has designated initializers recorded. + unsigned HasDesignatedInits : 1; + + unsigned SwiftImportAsNonGenericSpecified : 1; + unsigned SwiftImportAsNonGeneric : 1; + + unsigned SwiftObjCMembersSpecified : 1; + unsigned SwiftObjCMembers : 1; + +public: + ObjCContextInfo() + : CommonTypeInfo(), HasDefaultNullability(0), DefaultNullability(0), + HasDesignatedInits(0), SwiftImportAsNonGenericSpecified(false), + SwiftImportAsNonGeneric(false), SwiftObjCMembersSpecified(false), + SwiftObjCMembers(false) {} + + /// Determine the default nullability for properties and methods of this + /// class. + /// + /// eturns the default nullability, if implied, or None if there is no + llvm::Optional getDefaultNullability() const { + return HasDefaultNullability + ? llvm::Optional( + static_cast(DefaultNullability)) + : llvm::None; + } + + /// Set the default nullability for properties and methods of this class. + void setDefaultNullability(NullabilityKind Kind) { + HasDefaultNullability = true; + DefaultNullability = static_cast(Kind); + } + + bool hasDesignatedInits() const { return HasDesignatedInits; } + void setHasDesignatedInits(bool Value) { HasDesignatedInits = Value; } + + llvm::Optional getSwiftImportAsNonGeneric() const { + return SwiftImportAsNonGenericSpecified + ? llvm::Optional(SwiftImportAsNonGeneric) + : llvm::None; + } + void setSwiftImportAsNonGeneric(llvm::Optional Value) { + SwiftImportAsNonGenericSpecified = Value.hasValue(); + SwiftImportAsNonGeneric = Value.hasValue() ? *Value : false; + } + + llvm::Optional getSwiftObjCMembers() const { + return SwiftObjCMembersSpecified ? llvm::Optional(SwiftObjCMembers) + : llvm::None; + } + void setSwiftObjCMembers(llvm::Optional Value) { + SwiftObjCMembersSpecified = Value.hasValue(); + SwiftObjCMembers = Value.hasValue() ? *Value : false; + } + + /// Strip off any information within the class information structure that is + /// module-local, such as 'audited' flags. + void stripModuleLocalInfo() { + HasDefaultNullability = false; + DefaultNullability = 0; + } + + friend bool operator==(const ObjCContextInfo &, const ObjCContextInfo &); + + ObjCContextInfo &operator|=(const ObjCContextInfo &RHS) { + // Merge inherited info. + static_cast(*this) |= RHS; + + // Merge nullability. + if (!getDefaultNullability()) + if (auto Nullability = RHS.getDefaultNullability()) + setDefaultNullability(*Nullability); + + if (!SwiftImportAsNonGenericSpecified) + setSwiftImportAsNonGeneric(RHS.getSwiftImportAsNonGeneric()); + + if (!SwiftObjCMembersSpecified) + setSwiftObjCMembers(RHS.getSwiftObjCMembers()); + + HasDesignatedInits |= RHS.HasDesignatedInits; + + return *this; + } + + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS); +}; + +inline bool operator==(const ObjCContextInfo &LHS, const ObjCContextInfo &RHS) { + return static_cast(LHS) == RHS && + LHS.getDefaultNullability() == RHS.getDefaultNullability() && + LHS.HasDesignatedInits == RHS.HasDesignatedInits && + LHS.getSwiftImportAsNonGeneric() == RHS.getSwiftImportAsNonGeneric() && + LHS.getSwiftObjCMembers() == RHS.getSwiftObjCMembers(); +} + +inline bool operator!=(const ObjCContextInfo &LHS, const ObjCContextInfo &RHS) { + return !(LHS == RHS); +} + +/// API notes for a variable/property. +class VariableInfo : public CommonEntityInfo { + /// Whether this property has been audited for nullability. + unsigned NullabilityAudited : 1; + + /// The kind of nullability for this property. Only valid if the nullability + /// has been audited. + unsigned Nullable : 2; + + /// The C type of the variable, as a string. + std::string Type; + +public: + VariableInfo() : CommonEntityInfo(), NullabilityAudited(false), Nullable(0) {} + + llvm::Optional getNullability() const { + return NullabilityAudited ? llvm::Optional( + static_cast(Nullable)) + : llvm::None; + } + + void setNullabilityAudited(NullabilityKind kind) { + NullabilityAudited = true; + Nullable = static_cast(kind); + } + + const std::string &getType() const { return Type; } + void setType(const std::string &type) { Type = type; } + + friend bool operator==(const VariableInfo &, const VariableInfo &); + + VariableInfo &operator|=(const VariableInfo &RHS) { + static_cast(*this) |= RHS; + + if (!NullabilityAudited && RHS.NullabilityAudited) + setNullabilityAudited(*RHS.getNullability()); + if (Type.empty()) + Type = RHS.Type; + + return *this; + } + + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const; +}; + +inline bool operator==(const VariableInfo &LHS, const VariableInfo &RHS) { + return static_cast(LHS) == RHS && + LHS.NullabilityAudited == RHS.NullabilityAudited && + LHS.Nullable == RHS.Nullable && LHS.Type == RHS.Type; +} + +inline bool operator!=(const VariableInfo &LHS, const VariableInfo &RHS) { + return !(LHS == RHS); +} + +/// Describes API notes data for an Objective-C property. +class ObjCPropertyInfo : public VariableInfo { + unsigned SwiftImportAsAccessorsSpecified : 1; + unsigned SwiftImportAsAccessors : 1; + +public: + ObjCPropertyInfo() + : VariableInfo(), SwiftImportAsAccessorsSpecified(false), + SwiftImportAsAccessors(false) {} + + llvm::Optional getSwiftImportAsAccessors() const { + return SwiftImportAsAccessorsSpecified + ? llvm::Optional(SwiftImportAsAccessors) + : llvm::None; + } + void setSwiftImportAsAccessors(llvm::Optional Value) { + SwiftImportAsAccessorsSpecified = Value.hasValue(); + SwiftImportAsAccessors = Value.hasValue() ? *Value : false; + } + + friend bool operator==(const ObjCPropertyInfo &, const ObjCPropertyInfo &); + + /// Merge class-wide information into the given property. + ObjCPropertyInfo &operator|=(const ObjCContextInfo &RHS) { + static_cast(*this) |= RHS; + + // Merge nullability. + if (!getNullability()) + if (auto Nullable = RHS.getDefaultNullability()) + setNullabilityAudited(*Nullable); + + return *this; + } + + ObjCPropertyInfo &operator|=(const ObjCPropertyInfo &RHS) { + static_cast(*this) |= RHS; + + if (!SwiftImportAsAccessorsSpecified) + setSwiftImportAsAccessors(RHS.getSwiftImportAsAccessors()); + + return *this; + } + + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const; +}; + +inline bool operator==(const ObjCPropertyInfo &LHS, + const ObjCPropertyInfo &RHS) { + return static_cast(LHS) == RHS && + LHS.getSwiftImportAsAccessors() == RHS.getSwiftImportAsAccessors(); +} + +inline bool operator!=(const ObjCPropertyInfo &LHS, + const ObjCPropertyInfo &RHS) { + return !(LHS == RHS); +} + +/// Describes a function or method parameter. +class ParamInfo : public VariableInfo { + /// Whether noescape was specified. + unsigned NoEscapeSpecified : 1; + + /// Whether the this parameter has the 'noescape' attribute. + unsigned NoEscape : 1; + + /// A biased RetainCountConventionKind, where 0 means "unspecified". + /// + /// Only relevant for out-parameters. + unsigned RawRetainCountConvention : 3; + +public: + ParamInfo() + : VariableInfo(), NoEscapeSpecified(false), NoEscape(false), + RawRetainCountConvention() {} + + llvm::Optional isNoEscape() const { + if (!NoEscapeSpecified) + return llvm::None; + return NoEscape; + } + void setNoEscape(llvm::Optional Value) { + NoEscapeSpecified = Value.hasValue(); + NoEscape = Value.hasValue() ? *Value : false; + } + + llvm::Optional getRetainCountConvention() const { + if (!RawRetainCountConvention) + return llvm::None; + return static_cast(RawRetainCountConvention - 1); + } + void + setRetainCountConvention(llvm::Optional Value) { + RawRetainCountConvention = + Value.hasValue() ? static_cast(Value.getValue()) + 1 : 0; + assert(getRetainCountConvention() == Value && "bitfield too small"); + } + + ParamInfo &operator|=(const ParamInfo &RHS) { + static_cast(*this) |= RHS; + + if (!NoEscapeSpecified && RHS.NoEscapeSpecified) { + NoEscapeSpecified = true; + NoEscape = RHS.NoEscape; + } + + if (!RawRetainCountConvention) + RawRetainCountConvention = RHS.RawRetainCountConvention; + + return *this; + } + + friend bool operator==(const ParamInfo &, const ParamInfo &); + + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const; +}; + +inline bool operator==(const ParamInfo &LHS, const ParamInfo &RHS) { + return static_cast(LHS) == RHS && + LHS.NoEscapeSpecified == RHS.NoEscapeSpecified && + LHS.NoEscape == RHS.NoEscape && + LHS.RawRetainCountConvention == RHS.RawRetainCountConvention; +} + +inline bool operator!=(const ParamInfo &LHS, const ParamInfo &RHS) { + return !(LHS == RHS); +} + +/// API notes for a function or method. +class FunctionInfo : public CommonEntityInfo { +private: + static constexpr const unsigned NullabilityKindMask = 0x3; + static constexpr const unsigned NullabilityKindSize = 2; + + static constexpr const unsigned ReturnInfoIndex = 0; + +public: + // If yes, we consider all types to be non-nullable unless otherwise noted. + // If this flag is not set, the pointer types are considered to have + // unknown nullability. + + /// Whether the signature has been audited with respect to nullability. + unsigned NullabilityAudited : 1; + + /// Number of types whose nullability is encoded with the NullabilityPayload. + unsigned NumAdjustedNullable : 8; + + /// A biased RetainCountConventionKind, where 0 means "unspecified". + unsigned RawRetainCountConvention : 3; + + // NullabilityKindSize bits are used to encode the nullability. The info + // about the return type is stored at position 0, followed by the nullability + // of the parameters. + + /// Stores the nullability of the return type and the parameters. + uint64_t NullabilityPayload = 0; + + /// The result type of this function, as a C type. + std::string ResultType; + + /// The function parameters. + std::vector Params; + + FunctionInfo() + : CommonEntityInfo(), NullabilityAudited(false), NumAdjustedNullable(0), + RawRetainCountConvention() {} + + static unsigned getMaxNullabilityIndex() { + return ((sizeof(NullabilityPayload) * CHAR_BIT) / NullabilityKindSize); + } + + void addTypeInfo(unsigned index, NullabilityKind kind) { + assert(index <= getMaxNullabilityIndex()); + assert(static_cast(kind) < NullabilityKindMask); + + NullabilityAudited = true; + if (NumAdjustedNullable < index + 1) + NumAdjustedNullable = index + 1; + + // Mask the bits. + NullabilityPayload &= + ~(NullabilityKindMask << (index * NullabilityKindSize)); + + // Set the value. + unsigned kindValue = (static_cast(kind)) + << (index * NullabilityKindSize); + NullabilityPayload |= kindValue; + } + + /// Adds the return type info. + void addReturnTypeInfo(NullabilityKind kind) { + addTypeInfo(ReturnInfoIndex, kind); + } + + /// Adds the parameter type info. + void addParamTypeInfo(unsigned index, NullabilityKind kind) { + addTypeInfo(index + 1, kind); + } + + NullabilityKind getParamTypeInfo(unsigned index) const { + return getTypeInfo(index + 1); + } + + NullabilityKind getReturnTypeInfo() const { return getTypeInfo(0); } + + llvm::Optional getRetainCountConvention() const { + if (!RawRetainCountConvention) + return llvm::None; + return static_cast(RawRetainCountConvention - 1); + } + void + setRetainCountConvention(llvm::Optional Value) { + RawRetainCountConvention = + Value.hasValue() ? static_cast(Value.getValue()) + 1 : 0; + assert(getRetainCountConvention() == Value && "bitfield too small"); + } + + friend bool operator==(const FunctionInfo &, const FunctionInfo &); + +private: + NullabilityKind getTypeInfo(unsigned index) const { + assert(NullabilityAudited && + "Checking the type adjustment on non-audited method."); + + // If we don't have info about this parameter, return the default. + if (index > NumAdjustedNullable) + return NullabilityKind::NonNull; + auto nullability = NullabilityPayload >> (index * NullabilityKindSize); + return static_cast(nullability & NullabilityKindMask); + } + +public: + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const; +}; + +inline bool operator==(const FunctionInfo &LHS, const FunctionInfo &RHS) { + return static_cast(LHS) == RHS && + LHS.NullabilityAudited == RHS.NullabilityAudited && + LHS.NumAdjustedNullable == RHS.NumAdjustedNullable && + LHS.NullabilityPayload == RHS.NullabilityPayload && + LHS.ResultType == RHS.ResultType && LHS.Params == RHS.Params && + LHS.RawRetainCountConvention == RHS.RawRetainCountConvention; +} + +inline bool operator!=(const FunctionInfo &LHS, const FunctionInfo &RHS) { + return !(LHS == RHS); +} + +/// Describes API notes data for an Objective-C method. +class ObjCMethodInfo : public FunctionInfo { +public: + /// Whether this is a designated initializer of its class. + unsigned DesignatedInit : 1; + + /// Whether this is a required initializer. + unsigned RequiredInit : 1; + + ObjCMethodInfo() + : FunctionInfo(), DesignatedInit(false), RequiredInit(false) {} + + friend bool operator==(const ObjCMethodInfo &, const ObjCMethodInfo &); + + ObjCMethodInfo &operator|=(const ObjCContextInfo &RHS) { + // Merge Nullability. + if (!NullabilityAudited) { + if (auto Nullable = RHS.getDefaultNullability()) { + NullabilityAudited = true; + addTypeInfo(0, *Nullable); + } + } + return *this; + } + + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS); +}; + +inline bool operator==(const ObjCMethodInfo &LHS, const ObjCMethodInfo &RHS) { + return static_cast(LHS) == RHS && + LHS.DesignatedInit == RHS.DesignatedInit && + LHS.RequiredInit == RHS.RequiredInit; +} + +inline bool operator!=(const ObjCMethodInfo &LHS, const ObjCMethodInfo &RHS) { + return !(LHS == RHS); +} + +/// Describes API notes data for a global variable. +class GlobalVariableInfo : public VariableInfo { +public: + GlobalVariableInfo() : VariableInfo() {} +}; + +/// Describes API notes data for a global function. +class GlobalFunctionInfo : public FunctionInfo { +public: + GlobalFunctionInfo() : FunctionInfo() {} +}; + +/// Describes API notes data for an enumerator. +class EnumConstantInfo : public CommonEntityInfo { +public: + EnumConstantInfo() : CommonEntityInfo() {} +}; + +/// Describes API notes data for a tag. +class TagInfo : public CommonTypeInfo { + unsigned HasFlagEnum : 1; + unsigned IsFlagEnum : 1; + +public: + llvm::Optional EnumExtensibility; + + TagInfo() : CommonTypeInfo(), HasFlagEnum(0), IsFlagEnum(0) {} + + llvm::Optional isFlagEnum() const { + if (HasFlagEnum) + return IsFlagEnum; + return llvm::None; + } + void setFlagEnum(llvm::Optional Value) { + HasFlagEnum = Value.hasValue(); + IsFlagEnum = Value.hasValue() ? *Value : false; + } + + TagInfo &operator|=(const TagInfo &RHS) { + static_cast(*this) |= RHS; + + if (!HasFlagEnum && HasFlagEnum) + setFlagEnum(RHS.isFlagEnum()); + + if (!EnumExtensibility.hasValue()) + EnumExtensibility = RHS.EnumExtensibility; + + return *this; + } + + friend bool operator==(const TagInfo &, const TagInfo &); + + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS); +}; + +inline bool operator==(const TagInfo &LHS, const TagInfo &RHS) { + return static_cast(LHS) == RHS && + LHS.isFlagEnum() == RHS.isFlagEnum() && + LHS.EnumExtensibility == RHS.EnumExtensibility; +} + +inline bool operator!=(const TagInfo &LHS, const TagInfo &RHS) { + return !(LHS == RHS); +} + +/// Describes API notes data for a typedef. +class TypedefInfo : public CommonTypeInfo { +public: + llvm::Optional SwiftWrapper; + + TypedefInfo() : CommonTypeInfo() {} + + TypedefInfo &operator|=(const TypedefInfo &RHS) { + static_cast(*this) |= RHS; + if (!SwiftWrapper.hasValue()) + SwiftWrapper = RHS.SwiftWrapper; + return *this; + } + + friend bool operator==(const TypedefInfo &, const TypedefInfo &); + + LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS) const; +}; + +inline bool operator==(const TypedefInfo &LHS, const TypedefInfo &RHS) { + return static_cast(LHS) == RHS && + LHS.SwiftWrapper == RHS.SwiftWrapper; +} + +inline bool operator!=(const TypedefInfo &LHS, const TypedefInfo &RHS) { + return !(LHS == RHS); +} +} // namespace api_notes +} // namespace clang + +#endif diff --git a/contrib/llvm-project/clang/include/clang/ARCMigrate/FileRemapper.h b/contrib/llvm-project/clang/include/clang/ARCMigrate/FileRemapper.h index 76b65b2f6884c9..4da68a678be202 100644 --- a/contrib/llvm-project/clang/include/clang/ARCMigrate/FileRemapper.h +++ b/contrib/llvm-project/clang/include/clang/ARCMigrate/FileRemapper.h @@ -12,11 +12,13 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PointerUnion.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include namespace llvm { class MemoryBuffer; + class MemoryBufferRef; } namespace clang { @@ -55,6 +57,12 @@ class FileRemapper { void applyMappings(PreprocessorOptions &PPOpts) const; + /// Iterate through all the mappings. + void forEachMapping( + llvm::function_ref CaptureFile, + llvm::function_ref + CaptureBuffer) const; + void clear(StringRef outputDir = StringRef()); private: diff --git a/contrib/llvm-project/clang/include/clang/AST/APValue.h b/contrib/llvm-project/clang/include/clang/AST/APValue.h index cca92b5f82352f..5f4ac02f53c9a4 100644 --- a/contrib/llvm-project/clang/include/clang/AST/APValue.h +++ b/contrib/llvm-project/clang/include/clang/AST/APValue.h @@ -13,14 +13,20 @@ #ifndef LLVM_CLANG_AST_APVALUE_H #define LLVM_CLANG_AST_APVALUE_H -#include "clang/Basic/FixedPoint.h" #include "clang/Basic/LLVM.h" +#include "llvm/ADT/APFixedPoint.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APSInt.h" +#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" +#include "llvm/Support/AlignOf.h" namespace clang { +namespace serialization { +template class BasicReaderBase; +} // end namespace serialization + class AddrLabelExpr; class ASTContext; class CharUnits; @@ -32,6 +38,7 @@ namespace clang { struct PrintingPolicy; class Type; class ValueDecl; + class QualType; /// Symbolic representation of typeid(T) for some type T. class TypeInfoLValue { @@ -113,6 +120,7 @@ namespace clang { /// [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset], /// [Vector: N * APValue], [Array: N * APValue] class APValue { + typedef llvm::APFixedPoint APFixedPoint; typedef llvm::APSInt APSInt; typedef llvm::APFloat APFloat; public: @@ -147,6 +155,8 @@ class APValue { static LValueBase getDynamicAlloc(DynamicAllocLValue LV, QualType Type); static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo); + void Profile(llvm::FoldingSetNodeID &ID) const; + template bool is() const { return Ptr.is(); } @@ -167,11 +177,14 @@ class APValue { QualType getTypeInfoType() const; QualType getDynamicAllocType() const; + QualType getType() const; + friend bool operator==(const LValueBase &LHS, const LValueBase &RHS); friend bool operator!=(const LValueBase &LHS, const LValueBase &RHS) { return !(LHS == RHS); } friend llvm::hash_code hash_value(const LValueBase &Base); + friend struct llvm::DenseMapInfo; private: PtrTy Ptr; @@ -199,8 +212,7 @@ class APValue { public: LValuePathEntry() : Value() {} - LValuePathEntry(BaseOrMemberType BaseOrMember) - : Value{reinterpret_cast(BaseOrMember.getOpaqueValue())} {} + LValuePathEntry(BaseOrMemberType BaseOrMember); static LValuePathEntry ArrayIndex(uint64_t Index) { LValuePathEntry Result; Result.Value = Index; @@ -213,6 +225,8 @@ class APValue { } uint64_t getAsArrayIndex() const { return Value; } + void Profile(llvm::FoldingSetNodeID &ID) const; + friend bool operator==(LValuePathEntry A, LValuePathEntry B) { return A.Value == B.Value; } @@ -223,12 +237,22 @@ class APValue { return llvm::hash_value(A.Value); } }; + class LValuePathSerializationHelper { + const void *ElemTy; + + public: + ArrayRef Path; + + LValuePathSerializationHelper(ArrayRef, QualType); + QualType getType(); + }; struct NoLValuePath {}; struct UninitArray {}; struct UninitStruct {}; - friend class ASTReader; - friend class ASTWriter; + template friend class clang::serialization::BasicReaderBase; + friend class ASTImporter; + friend class ASTNodeImporter; private: ValueKind Kind; @@ -302,7 +326,7 @@ class APValue { MakeComplexFloat(); setComplexFloat(std::move(R), std::move(I)); } APValue(const APValue &RHS); - APValue(APValue &&RHS) : Kind(None) { swap(RHS); } + APValue(APValue &&RHS); APValue(LValueBase B, const CharUnits &O, NoLValuePath N, bool IsNullPtr = false) : Kind(None) { @@ -337,6 +361,9 @@ class APValue { return Result; } + APValue &operator=(const APValue &RHS); + APValue &operator=(APValue &&RHS); + ~APValue() { if (Kind != None && Kind != Indeterminate) DestroyDataAndMakeUninit(); @@ -352,6 +379,11 @@ class APValue { /// Swaps the contents of this and the given APValue. void swap(APValue &RHS); + /// profile this value. There is no guarantee that values of different + /// types will not produce the same profiled value, so the type should + /// typically also be profiled if it's not implied by the context. + void Profile(llvm::FoldingSetNodeID &ID) const; + ValueKind getKind() const { return Kind; } bool isAbsent() const { return Kind == None; } @@ -375,11 +407,14 @@ class APValue { void dump(raw_ostream &OS, const ASTContext &Context) const; void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const; + void printPretty(raw_ostream &OS, const PrintingPolicy &Policy, QualType Ty, + const ASTContext *Ctx = nullptr) const; + std::string getAsString(const ASTContext &Ctx, QualType Ty) const; APSInt &getInt() { assert(isInt() && "Invalid accessor"); - return *(APSInt*)(char*)Data.buffer; + return *(APSInt *)(char *)&Data; } const APSInt &getInt() const { return const_cast(this)->getInt(); @@ -393,7 +428,7 @@ class APValue { APFloat &getFloat() { assert(isFloat() && "Invalid accessor"); - return *(APFloat*)(char*)Data.buffer; + return *(APFloat *)(char *)&Data; } const APFloat &getFloat() const { return const_cast(this)->getFloat(); @@ -401,7 +436,7 @@ class APValue { APFixedPoint &getFixedPoint() { assert(isFixedPoint() && "Invalid accessor"); - return *(APFixedPoint *)(char *)Data.buffer; + return *(APFixedPoint *)(char *)&Data; } const APFixedPoint &getFixedPoint() const { return const_cast(this)->getFixedPoint(); @@ -409,7 +444,7 @@ class APValue { APSInt &getComplexIntReal() { assert(isComplexInt() && "Invalid accessor"); - return ((ComplexAPSInt*)(char*)Data.buffer)->Real; + return ((ComplexAPSInt *)(char *)&Data)->Real; } const APSInt &getComplexIntReal() const { return const_cast(this)->getComplexIntReal(); @@ -417,7 +452,7 @@ class APValue { APSInt &getComplexIntImag() { assert(isComplexInt() && "Invalid accessor"); - return ((ComplexAPSInt*)(char*)Data.buffer)->Imag; + return ((ComplexAPSInt *)(char *)&Data)->Imag; } const APSInt &getComplexIntImag() const { return const_cast(this)->getComplexIntImag(); @@ -425,7 +460,7 @@ class APValue { APFloat &getComplexFloatReal() { assert(isComplexFloat() && "Invalid accessor"); - return ((ComplexAPFloat*)(char*)Data.buffer)->Real; + return ((ComplexAPFloat *)(char *)&Data)->Real; } const APFloat &getComplexFloatReal() const { return const_cast(this)->getComplexFloatReal(); @@ -433,7 +468,7 @@ class APValue { APFloat &getComplexFloatImag() { assert(isComplexFloat() && "Invalid accessor"); - return ((ComplexAPFloat*)(char*)Data.buffer)->Imag; + return ((ComplexAPFloat *)(char *)&Data)->Imag; } const APFloat &getComplexFloatImag() const { return const_cast(this)->getComplexFloatImag(); @@ -454,20 +489,20 @@ class APValue { APValue &getVectorElt(unsigned I) { assert(isVector() && "Invalid accessor"); assert(I < getVectorLength() && "Index out of range"); - return ((Vec*)(char*)Data.buffer)->Elts[I]; + return ((Vec *)(char *)&Data)->Elts[I]; } const APValue &getVectorElt(unsigned I) const { return const_cast(this)->getVectorElt(I); } unsigned getVectorLength() const { assert(isVector() && "Invalid accessor"); - return ((const Vec*)(const void *)Data.buffer)->NumElts; + return ((const Vec *)(const void *)&Data)->NumElts; } APValue &getArrayInitializedElt(unsigned I) { assert(isArray() && "Invalid accessor"); assert(I < getArrayInitializedElts() && "Index out of range"); - return ((Arr*)(char*)Data.buffer)->Elts[I]; + return ((Arr *)(char *)&Data)->Elts[I]; } const APValue &getArrayInitializedElt(unsigned I) const { return const_cast(this)->getArrayInitializedElt(I); @@ -478,35 +513,37 @@ class APValue { APValue &getArrayFiller() { assert(isArray() && "Invalid accessor"); assert(hasArrayFiller() && "No array filler"); - return ((Arr*)(char*)Data.buffer)->Elts[getArrayInitializedElts()]; + return ((Arr *)(char *)&Data)->Elts[getArrayInitializedElts()]; } const APValue &getArrayFiller() const { return const_cast(this)->getArrayFiller(); } unsigned getArrayInitializedElts() const { assert(isArray() && "Invalid accessor"); - return ((const Arr*)(const void *)Data.buffer)->NumElts; + return ((const Arr *)(const void *)&Data)->NumElts; } unsigned getArraySize() const { assert(isArray() && "Invalid accessor"); - return ((const Arr*)(const void *)Data.buffer)->ArrSize; + return ((const Arr *)(const void *)&Data)->ArrSize; } unsigned getStructNumBases() const { assert(isStruct() && "Invalid accessor"); - return ((const StructData*)(const char*)Data.buffer)->NumBases; + return ((const StructData *)(const char *)&Data)->NumBases; } unsigned getStructNumFields() const { assert(isStruct() && "Invalid accessor"); - return ((const StructData*)(const char*)Data.buffer)->NumFields; + return ((const StructData *)(const char *)&Data)->NumFields; } APValue &getStructBase(unsigned i) { assert(isStruct() && "Invalid accessor"); - return ((StructData*)(char*)Data.buffer)->Elts[i]; + assert(i < getStructNumBases() && "base class index OOB"); + return ((StructData *)(char *)&Data)->Elts[i]; } APValue &getStructField(unsigned i) { assert(isStruct() && "Invalid accessor"); - return ((StructData*)(char*)Data.buffer)->Elts[getStructNumBases() + i]; + assert(i < getStructNumFields() && "field index OOB"); + return ((StructData *)(char *)&Data)->Elts[getStructNumBases() + i]; } const APValue &getStructBase(unsigned i) const { return const_cast(this)->getStructBase(i); @@ -517,11 +554,11 @@ class APValue { const FieldDecl *getUnionField() const { assert(isUnion() && "Invalid accessor"); - return ((const UnionData*)(const char*)Data.buffer)->Field; + return ((const UnionData *)(const char *)&Data)->Field; } APValue &getUnionValue() { assert(isUnion() && "Invalid accessor"); - return *((UnionData*)(char*)Data.buffer)->Value; + return *((UnionData *)(char *)&Data)->Value; } const APValue &getUnionValue() const { return const_cast(this)->getUnionValue(); @@ -533,119 +570,125 @@ class APValue { const AddrLabelExpr* getAddrLabelDiffLHS() const { assert(isAddrLabelDiff() && "Invalid accessor"); - return ((const AddrLabelDiffData*)(const char*)Data.buffer)->LHSExpr; + return ((const AddrLabelDiffData *)(const char *)&Data)->LHSExpr; } const AddrLabelExpr* getAddrLabelDiffRHS() const { assert(isAddrLabelDiff() && "Invalid accessor"); - return ((const AddrLabelDiffData*)(const char*)Data.buffer)->RHSExpr; + return ((const AddrLabelDiffData *)(const char *)&Data)->RHSExpr; } void setInt(APSInt I) { assert(isInt() && "Invalid accessor"); - *(APSInt *)(char *)Data.buffer = std::move(I); + *(APSInt *)(char *)&Data = std::move(I); } void setFloat(APFloat F) { assert(isFloat() && "Invalid accessor"); - *(APFloat *)(char *)Data.buffer = std::move(F); + *(APFloat *)(char *)&Data = std::move(F); } void setFixedPoint(APFixedPoint FX) { assert(isFixedPoint() && "Invalid accessor"); - *(APFixedPoint *)(char *)Data.buffer = std::move(FX); + *(APFixedPoint *)(char *)&Data = std::move(FX); } void setVector(const APValue *E, unsigned N) { - assert(isVector() && "Invalid accessor"); - ((Vec*)(char*)Data.buffer)->Elts = new APValue[N]; - ((Vec*)(char*)Data.buffer)->NumElts = N; + MutableArrayRef InternalElts = setVectorUninit(N); for (unsigned i = 0; i != N; ++i) - ((Vec*)(char*)Data.buffer)->Elts[i] = E[i]; + InternalElts[i] = E[i]; } void setComplexInt(APSInt R, APSInt I) { assert(R.getBitWidth() == I.getBitWidth() && "Invalid complex int (type mismatch)."); assert(isComplexInt() && "Invalid accessor"); - ((ComplexAPSInt *)(char *)Data.buffer)->Real = std::move(R); - ((ComplexAPSInt *)(char *)Data.buffer)->Imag = std::move(I); + ((ComplexAPSInt *)(char *)&Data)->Real = std::move(R); + ((ComplexAPSInt *)(char *)&Data)->Imag = std::move(I); } void setComplexFloat(APFloat R, APFloat I) { assert(&R.getSemantics() == &I.getSemantics() && "Invalid complex float (type mismatch)."); assert(isComplexFloat() && "Invalid accessor"); - ((ComplexAPFloat *)(char *)Data.buffer)->Real = std::move(R); - ((ComplexAPFloat *)(char *)Data.buffer)->Imag = std::move(I); + ((ComplexAPFloat *)(char *)&Data)->Real = std::move(R); + ((ComplexAPFloat *)(char *)&Data)->Imag = std::move(I); } void setLValue(LValueBase B, const CharUnits &O, NoLValuePath, bool IsNullPtr); void setLValue(LValueBase B, const CharUnits &O, ArrayRef Path, bool OnePastTheEnd, bool IsNullPtr); - void setUnion(const FieldDecl *Field, const APValue &Value) { - assert(isUnion() && "Invalid accessor"); - ((UnionData*)(char*)Data.buffer)->Field = Field; - *((UnionData*)(char*)Data.buffer)->Value = Value; - } + void setUnion(const FieldDecl *Field, const APValue &Value); void setAddrLabelDiff(const AddrLabelExpr* LHSExpr, const AddrLabelExpr* RHSExpr) { - ((AddrLabelDiffData*)(char*)Data.buffer)->LHSExpr = LHSExpr; - ((AddrLabelDiffData*)(char*)Data.buffer)->RHSExpr = RHSExpr; - } - - /// Assign by swapping from a copy of the RHS. - APValue &operator=(APValue RHS) { - swap(RHS); - return *this; + ((AddrLabelDiffData *)(char *)&Data)->LHSExpr = LHSExpr; + ((AddrLabelDiffData *)(char *)&Data)->RHSExpr = RHSExpr; } private: void DestroyDataAndMakeUninit(); void MakeInt() { assert(isAbsent() && "Bad state change"); - new ((void*)Data.buffer) APSInt(1); + new ((void *)&Data) APSInt(1); Kind = Int; } void MakeFloat() { assert(isAbsent() && "Bad state change"); - new ((void*)(char*)Data.buffer) APFloat(0.0); + new ((void *)(char *)&Data) APFloat(0.0); Kind = Float; } void MakeFixedPoint(APFixedPoint &&FX) { assert(isAbsent() && "Bad state change"); - new ((void *)(char *)Data.buffer) APFixedPoint(std::move(FX)); + new ((void *)(char *)&Data) APFixedPoint(std::move(FX)); Kind = FixedPoint; } void MakeVector() { assert(isAbsent() && "Bad state change"); - new ((void*)(char*)Data.buffer) Vec(); + new ((void *)(char *)&Data) Vec(); Kind = Vector; } void MakeComplexInt() { assert(isAbsent() && "Bad state change"); - new ((void*)(char*)Data.buffer) ComplexAPSInt(); + new ((void *)(char *)&Data) ComplexAPSInt(); Kind = ComplexInt; } void MakeComplexFloat() { assert(isAbsent() && "Bad state change"); - new ((void*)(char*)Data.buffer) ComplexAPFloat(); + new ((void *)(char *)&Data) ComplexAPFloat(); Kind = ComplexFloat; } void MakeLValue(); void MakeArray(unsigned InitElts, unsigned Size); void MakeStruct(unsigned B, unsigned M) { assert(isAbsent() && "Bad state change"); - new ((void*)(char*)Data.buffer) StructData(B, M); + new ((void *)(char *)&Data) StructData(B, M); Kind = Struct; } void MakeUnion() { assert(isAbsent() && "Bad state change"); - new ((void*)(char*)Data.buffer) UnionData(); + new ((void *)(char *)&Data) UnionData(); Kind = Union; } void MakeMemberPointer(const ValueDecl *Member, bool IsDerivedMember, ArrayRef Path); void MakeAddrLabelDiff() { assert(isAbsent() && "Bad state change"); - new ((void*)(char*)Data.buffer) AddrLabelDiffData(); + new ((void *)(char *)&Data) AddrLabelDiffData(); Kind = AddrLabelDiff; } + +private: + /// The following functions are used as part of initialization, during + /// deserialization and importing. Reserve the space so that it can be + /// filled in by those steps. + MutableArrayRef setVectorUninit(unsigned N) { + assert(isVector() && "Invalid accessor"); + Vec *V = ((Vec *)(char *)&Data); + V->Elts = new APValue[N]; + V->NumElts = N; + return {V->Elts, V->NumElts}; + } + MutableArrayRef + setLValueUninit(LValueBase B, const CharUnits &O, unsigned Size, + bool OnePastTheEnd, bool IsNullPtr); + MutableArrayRef + setMemberPointerUninit(const ValueDecl *Member, bool IsDerivedMember, + unsigned Size); }; } // end namespace clang. diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h index 3700d0101daf26..ae69a68608b708 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h @@ -36,6 +36,7 @@ #include "clang/Basic/Linkage.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" @@ -43,6 +44,7 @@ #include "llvm/ADT/APSInt.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/MapVector.h" @@ -73,6 +75,8 @@ namespace llvm { +class APFixedPoint; +class FixedPointSemantics; struct fltSemantics; template class SmallPtrSet; @@ -80,7 +84,6 @@ template class SmallPtrSet; namespace clang { -class APFixedPoint; class APValue; class ASTMutationListener; class ASTRecordLayout; @@ -98,7 +101,6 @@ class ParentMapContext; class DynTypedNode; class DynTypedNodeList; class Expr; -class FixedPointSemantics; class GlobalDecl; class MangleContext; class MangleNumberingContext; @@ -170,6 +172,16 @@ struct TypeInfo { : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {} }; +struct TypeInfoChars { + CharUnits Width; + CharUnits Align; + bool AlignIsRequired : 1; + + TypeInfoChars() : AlignIsRequired(false) {} + TypeInfoChars(CharUnits Width, CharUnits Align, bool AlignIsRequired) + : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {} +}; + /// Holds long-lived AST nodes (such as types and decls) that can be /// referred to throughout the semantic analysis of a file. class ASTContext : public RefCountedBase { @@ -278,8 +290,8 @@ class ASTContext : public RefCountedBase { /// Mapping from GUIDs to the corresponding MSGuidDecl. mutable llvm::FoldingSet MSGuidDecls; - /// Used to cleanups APValues stored in the AST. - mutable llvm::SmallVector APValueCleanups; + /// Mapping from APValues to the corresponding TemplateParamObjects. + mutable llvm::FoldingSet TemplateParamObjectDecls; /// A cache mapping a string value to a StringLiteral object with the same /// value. @@ -526,6 +538,9 @@ class ASTContext : public RefCountedBase { /// need them (like static local vars). llvm::MapVector MangleNumbers; llvm::MapVector StaticLocalNumbers; + /// Mapping the associated device lambda mangling number if present. + mutable llvm::DenseMap + DeviceLambdaManglingNumbers; /// Mapping that stores parameterIndex values for ParmVarDecls when /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex. @@ -555,6 +570,10 @@ class ASTContext : public RefCountedBase { /// should be imbued with the XRay "always" or "never" attributes. std::unique_ptr XRayFilter; + /// ProfileList object that is used by the profile instrumentation + /// to decide which entities should be instrumented. + std::unique_ptr ProfList; + /// The allocator used to create AST objects. /// /// AST objects are never destructed; rather, all memory associated with the @@ -562,7 +581,7 @@ class ASTContext : public RefCountedBase { mutable llvm::BumpPtrAllocator BumpAlloc; /// Allocator for partial diagnostics. - PartialDiagnostic::StorageAllocator DiagAllocator; + PartialDiagnostic::DiagStorageAllocator DiagAllocator; /// The current C++ ABI. std::unique_ptr ABI; @@ -641,7 +660,7 @@ class ASTContext : public RefCountedBase { /// Return the total memory used for various side tables. size_t getSideTableAllocatedMemory() const; - PartialDiagnostic::StorageAllocator &getDiagAllocator() { + PartialDiagnostic::DiagStorageAllocator &getDiagAllocator() { return DiagAllocator; } @@ -664,6 +683,14 @@ class ASTContext : public RefCountedBase { const LangOptions& getLangOpts() const { return LangOpts; } + // If this condition is false, typo correction must be performed eagerly + // rather than delayed in many places, as it makes use of dependent types. + // the condition is false for clang's C-only codepath, as it doesn't support + // dependent types yet. + bool isDependenceAllowed() const { + return LangOpts.CPlusPlus || LangOpts.RecoveryAST; + } + const SanitizerBlacklist &getSanitizerBlacklist() const { return *SanitizerBL; } @@ -672,6 +699,8 @@ class ASTContext : public RefCountedBase { return *XRayFilter; } + const ProfileList &getProfileList() const { return *ProfList; } + DiagnosticsEngine &getDiagnostics() const; FullSourceLoc getFullLoc(SourceLocation Loc) const { @@ -988,6 +1017,9 @@ class ASTContext : public RefCountedBase { #define SVE_TYPE(Name, Id, SingletonId) \ CanQualType SingletonId; #include "clang/Basic/AArch64SVEACLETypes.def" +#define PPC_VECTOR_TYPE(Name, Id, Size) \ + CanQualType Id##Ty; +#include "clang/Basic/PPCTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. @@ -1000,6 +1032,9 @@ class ASTContext : public RefCountedBase { // Implicitly-declared type 'struct _GUID'. mutable TagDecl *MSGuidTagDecl = nullptr; + /// Keep track of CUDA/HIP static device variables referenced by host code. + llvm::DenseSet CUDAStaticDeviceVarReferencedByHost; + ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins); ASTContext(const ASTContext &) = delete; @@ -1406,7 +1441,7 @@ class ASTContext : public RefCountedBase { /// Return the unique reference to the type for the specified /// typedef-name decl. QualType getTypedefType(const TypedefNameDecl *Decl, - QualType Canon = QualType()) const; + QualType Underlying = QualType()) const; QualType getRecordType(const RecordDecl *Decl) const; @@ -1981,9 +2016,9 @@ class ASTContext : public RefCountedBase { unsigned char getFixedPointScale(QualType Ty) const; unsigned char getFixedPointIBits(QualType Ty) const; - FixedPointSemantics getFixedPointSemantics(QualType Ty) const; - APFixedPoint getFixedPointMax(QualType Ty) const; - APFixedPoint getFixedPointMin(QualType Ty) const; + llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const; + llvm::APFixedPoint getFixedPointMax(QualType Ty) const; + llvm::APFixedPoint getFixedPointMin(QualType Ty) const; DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const; @@ -2022,6 +2057,10 @@ class ASTContext : public RefCountedBase { GE_Missing_ucontext }; + QualType DecodeTypeStr(const char *&Str, const ASTContext &Context, + ASTContext::GetBuiltinTypeError &Error, + bool &RequireICE, bool AllowTypeModifiers) const; + /// Return the type for the specified builtin. /// /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of @@ -2054,6 +2093,15 @@ class ASTContext : public RefCountedBase { /// types. bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec); + /// Return true if the given types are an SVE builtin and a VectorType that + /// is a fixed-length representation of the SVE builtin for a specific + /// vector-length. + bool areCompatibleSveTypes(QualType FirstType, QualType SecondType); + + /// Return true if the given vector types are lax-compatible SVE vector types, + /// false otherwise. + bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType); + /// Return true if the type has been explicitly qualified with ObjC ownership. /// A type may be implicitly qualified with ownership under ObjC ARC, and in /// some cases the compiler treats these differently. @@ -2125,16 +2173,25 @@ class ASTContext : public RefCountedBase { } unsigned getTypeUnadjustedAlign(const Type *T) const; - /// Return the ABI-specified alignment of a type, in bits, or 0 if + /// Return the alignment of a type, in bits, or 0 if /// the type is incomplete and we cannot determine the alignment (for - /// example, from alignment attributes). - unsigned getTypeAlignIfKnown(QualType T) const; + /// example, from alignment attributes). The returned alignment is the + /// Preferred alignment if NeedsPreferredAlignment is true, otherwise is the + /// ABI alignment. + unsigned getTypeAlignIfKnown(QualType T, + bool NeedsPreferredAlignment = false) const; /// Return the ABI-specified alignment of a (complete) type \p T, in /// characters. CharUnits getTypeAlignInChars(QualType T) const; CharUnits getTypeAlignInChars(const Type *T) const; + /// Return the PreferredAlignment of a (complete) type \p T, in + /// characters. + CharUnits getPreferredTypeAlignInChars(QualType T) const { + return toCharUnitsFromBits(getPreferredTypeAlign(T)); + } + /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, /// in characters, before alignment adjustments. This method does not work on /// incomplete types. @@ -2143,10 +2200,10 @@ class ASTContext : public RefCountedBase { // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the // type is a record, its data size is returned. - std::pair getTypeInfoDataSizeInChars(QualType T) const; + TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const; - std::pair getTypeInfoInChars(const Type *T) const; - std::pair getTypeInfoInChars(QualType T) const; + TypeInfoChars getTypeInfoInChars(const Type *T) const; + TypeInfoChars getTypeInfoInChars(QualType T) const; /// Determine if the alignment the type has was required using an /// alignment attribute. @@ -2157,7 +2214,12 @@ class ASTContext : public RefCountedBase { /// the current target, in bits. /// /// This can be different than the ABI alignment in cases where it is - /// beneficial for performance to overalign a data type. + /// beneficial for performance or backwards compatibility preserving to + /// overalign a data type. (Note: despite the name, the preferred alignment + /// is ABI-impacting, and not an optimization.) + unsigned getPreferredTypeAlign(QualType T) const { + return getPreferredTypeAlign(T.getTypePtr()); + } unsigned getPreferredTypeAlign(const Type *T) const; /// Return the default alignment for __attribute__((aligned)) on @@ -2250,6 +2312,10 @@ class ASTContext : public RefCountedBase { const ObjCImplementationDecl *ID, const ObjCIvarDecl *Ivar) const; + /// Find the 'this' offset for the member path in a pointer-to-member + /// APValue. + CharUnits getMemberPointerPathAdjustment(const APValue &MP) const; + bool isNearlyEmpty(const CXXRecordDecl *RD) const; VTableContextBase *getVTableContext(); @@ -2345,12 +2411,10 @@ class ASTContext : public RefCountedBase { return (*SuperTnullability == NullabilityKind::NonNull && *SubTnullability == NullabilityKind::Nullable); } - else { - // For the return type, it's okay for the superclass method to specify - // "nullable" and the subclass method specify "nonnull" - return (*SuperTnullability == NullabilityKind::Nullable && - *SubTnullability == NullabilityKind::NonNull); - } + // For the return type, it's okay for the superclass method to specify + // "nullable" and the subclass method specify "nonnull" + return (*SuperTnullability == NullabilityKind::Nullable && + *SubTnullability == NullabilityKind::NonNull); } return true; } @@ -2830,6 +2894,11 @@ class ASTContext : public RefCountedBase { /// GUID value. MSGuidDecl *getMSGuidDecl(MSGuidDeclParts Parts) const; + /// Return the template parameter object of the given type with the given + /// value. + TemplateParamObjectDecl *getTemplateParamObjectDecl(QualType T, + const APValue &V) const; + /// Parses the target attributes passed in, and returns only the ones that are /// valid feature names. ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const; @@ -3025,13 +3094,12 @@ OPT_LIST(V) }; struct SectionInfo { - DeclaratorDecl *Decl; + NamedDecl *Decl; SourceLocation PragmaSectionLocation; int SectionFlags; SectionInfo() = default; - SectionInfo(DeclaratorDecl *Decl, - SourceLocation PragmaSectionLocation, + SectionInfo(NamedDecl *Decl, SourceLocation PragmaSectionLocation, int SectionFlags) : Decl(Decl), PragmaSectionLocation(PragmaSectionLocation), SectionFlags(SectionFlags) {} @@ -3042,6 +3110,12 @@ OPT_LIST(V) /// Return a new OMPTraitInfo object owned by this context. OMPTraitInfo &getNewOMPTraitInfo(); + /// Whether a C++ static variable may be externalized. + bool mayExternalizeStaticVar(const Decl *D) const; + + /// Whether a C++ static variable should be externalized. + bool shouldExternalizeStaticVar(const Decl *D) const; + private: /// All OMPTraitInfo objects live in this collection, one per /// `pragma omp [begin] declare variant` directive. @@ -3049,8 +3123,8 @@ OPT_LIST(V) }; /// Insertion operator for diagnostics. -const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - const ASTContext::SectionInfo &Section); +const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, + const ASTContext::SectionInfo &Section); /// Utility function for constructing a nullary selector. inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) { diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTFwd.h b/contrib/llvm-project/clang/include/clang/AST/ASTFwd.h index 65319a19728b5f..649b571134246e 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTFwd.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTFwd.h @@ -27,9 +27,9 @@ class Type; #include "clang/AST/TypeNodes.inc" class CXXCtorInitializer; class OMPClause; -#define OMP_CLAUSE_CLASS(Enum, Str, Class) class Class; -#include "llvm/Frontend/OpenMP/OMPKinds.def" - +#define GEN_CLANG_CLAUSE_CLASS +#define CLAUSE_CLASS(Enum, Str, Class) class Class; +#include "llvm/Frontend/OpenMP/OMP.inc" } // end namespace clang diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTImporter.h b/contrib/llvm-project/clang/include/clang/AST/ASTImporter.h index 205d7ec67754fb..a6d822ba2ea6df 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTImporter.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTImporter.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_ASTIMPORTER_H #define LLVM_CLANG_AST_ASTIMPORTER_H +#include "clang/AST/APValue.h" #include "clang/AST/DeclBase.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/ExprCXX.h" @@ -503,6 +504,13 @@ class TypeSourceInfo; /// "to" context, or the import error. llvm::Expected Import(const CXXBaseSpecifier *FromSpec); + /// Import the given APValue from the "from" context into + /// the "to" context. + /// + /// \return the equivalent APValue in the "to" context or the import + /// error. + llvm::Expected Import(const APValue &FromValue); + /// Import the definition of the given declaration, including all of /// the declarations it contains. LLVM_NODISCARD llvm::Error ImportDefinition(Decl *From); diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h b/contrib/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h index 26656b7162b617..bb5b0c73f02871 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h @@ -82,8 +82,12 @@ class ASTNodeTraverser bool getDeserialize() const { return Deserialize; } void SetTraversalKind(TraversalKind TK) { Traversal = TK; } + TraversalKind GetTraversalKind() const { return Traversal; } void Visit(const Decl *D) { + if (Traversal == TK_IgnoreUnlessSpelledInSource && D->isImplicit()) + return; + getNodeDelegate().AddChild([=] { getNodeDelegate().Visit(D); if (!D) @@ -100,6 +104,14 @@ class ASTNodeTraverser // Decls within functions are visited by the body. if (!isa(*D) && !isa(*D)) { + if (Traversal != TK_AsIs) { + if (const auto *CTSD = dyn_cast(D)) { + auto SK = CTSD->getSpecializationKind(); + if (SK == TSK_ExplicitInstantiationDeclaration || + SK == TSK_ExplicitInstantiationDefinition) + return; + } + } if (const auto *DC = dyn_cast(D)) dumpDeclContext(DC); } @@ -114,9 +126,6 @@ class ASTNodeTraverser switch (Traversal) { case TK_AsIs: break; - case TK_IgnoreImplicitCastsAndParentheses: - S = E->IgnoreParenImpCasts(); - break; case TK_IgnoreUnlessSpelledInSource: S = E->IgnoreUnlessSpelledInSource(); break; @@ -135,7 +144,9 @@ class ASTNodeTraverser if (isa(S) || isa(S)) return; - if (isa(S) && Traversal == TK_IgnoreUnlessSpelledInSource) + if (Traversal == TK_IgnoreUnlessSpelledInSource && + isa(S)) return; for (const Stmt *SubStmt : S->children()) @@ -176,6 +187,8 @@ class ASTNodeTraverser } void Visit(const CXXCtorInitializer *Init) { + if (Traversal == TK_IgnoreUnlessSpelledInSource && !Init->isWritten()) + return; getNodeDelegate().AddChild([=] { getNodeDelegate().Visit(Init); Visit(Init->getInit()); @@ -392,6 +405,9 @@ class ASTNodeTraverser if (const Expr *TRC = D->getTrailingRequiresClause()) Visit(TRC); + if (Traversal == TK_IgnoreUnlessSpelledInSource && D->isDefaulted()) + return; + if (const auto *C = dyn_cast(D)) for (const auto *I : C->inits()) Visit(I); @@ -408,6 +424,9 @@ class ASTNodeTraverser } void VisitVarDecl(const VarDecl *D) { + if (Traversal == TK_IgnoreUnlessSpelledInSource && D->isCXXForRangeDecl()) + return; + if (D->hasInit()) Visit(D->getInit()); } @@ -481,8 +500,10 @@ class ASTNodeTraverser Visit(D->getTemplatedDecl()); - for (const auto *Child : D->specializations()) - dumpTemplateDeclSpecialization(Child); + if (Traversal == TK_AsIs) { + for (const auto *Child : D->specializations()) + dumpTemplateDeclSpecialization(Child); + } } void VisitTypeAliasDecl(const TypeAliasDecl *D) { @@ -543,9 +564,7 @@ class ASTNodeTraverser void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) { if (const auto *TC = D->getTypeConstraint()) - if (TC->hasExplicitTemplateArgs()) - for (const auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments()) - dumpTemplateArgumentLoc(ArgLoc); + Visit(TC->getImmediatelyDeclaredConstraint()); if (D->hasDefaultArgument()) Visit(D->getDefaultArgument(), SourceRange(), D->getDefaultArgStorage().getInheritedFrom(), @@ -574,6 +593,12 @@ class ASTNodeTraverser Visit(D->getConstraintExpr()); } + void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *CSE) { + if (CSE->hasExplicitTemplateArgs()) + for (const auto &ArgLoc : CSE->getTemplateArgsAsWritten()->arguments()) + dumpTemplateArgumentLoc(ArgLoc); + } + void VisitUsingShadowDecl(const UsingShadowDecl *D) { if (auto *TD = dyn_cast(D->getUnderlyingDecl())) Visit(TD->getTypeForDecl()); @@ -702,6 +727,35 @@ class ASTNodeTraverser Visit(CatchParam); } + void VisitCXXForRangeStmt(const CXXForRangeStmt *Node) { + if (Traversal == TK_IgnoreUnlessSpelledInSource) { + Visit(Node->getInit()); + Visit(Node->getLoopVariable()); + Visit(Node->getRangeInit()); + Visit(Node->getBody()); + } + } + + void VisitCallExpr(const CallExpr *Node) { + for (const auto *Child : + make_filter_range(Node->children(), [this](const Stmt *Child) { + if (Traversal != TK_IgnoreUnlessSpelledInSource) + return false; + return !isa(Child); + })) { + Visit(Child); + } + } + + void VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *Node) { + if (Traversal == TK_IgnoreUnlessSpelledInSource) { + Visit(Node->getLHS()); + Visit(Node->getRHS()); + } else { + ConstStmtVisitor::VisitCXXRewrittenBinaryOperator(Node); + } + } + void VisitExpressionTemplateArgument(const TemplateArgument &TA) { Visit(TA.getAsExpr()); } diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTStructuralEquivalence.h b/contrib/llvm-project/clang/include/clang/AST/ASTStructuralEquivalence.h index 36a42070fd2819..c958a16aba2132 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTStructuralEquivalence.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTStructuralEquivalence.h @@ -97,6 +97,13 @@ struct StructuralEquivalenceContext { /// \c VisitedDecls members) and can cause faulty equivalent results. bool IsEquivalent(QualType T1, QualType T2); + /// Determine whether the two statements are structurally equivalent. + /// Implementation functions (all static functions in + /// ASTStructuralEquivalence.cpp) must never call this function because that + /// will wreak havoc the internal state (\c DeclsToCheck and + /// \c VisitedDecls members) and can cause faulty equivalent results. + bool IsEquivalent(Stmt *S1, Stmt *S2); + /// Find the index of the given anonymous struct/union within its /// context. /// diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTTypeTraits.h b/contrib/llvm-project/clang/include/clang/AST/ASTTypeTraits.h index 328b7bce6ba50c..57195a9d606671 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTTypeTraits.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTTypeTraits.h @@ -40,10 +40,6 @@ enum TraversalKind { /// Will traverse all child nodes. TK_AsIs, - /// Will not traverse implicit casts and parentheses. - /// Corresponds to Expr::IgnoreParenImpCasts() - TK_IgnoreImplicitCastsAndParentheses, - /// Ignore AST nodes not written in the source TK_IgnoreUnlessSpelledInSource }; @@ -104,6 +100,8 @@ class ASTNodeKind { static ASTNodeKind getMostDerivedCommonAncestor(ASTNodeKind Kind1, ASTNodeKind Kind2); + ASTNodeKind getCladeKind() const; + /// Hooks for using ASTNodeKind as a key in a DenseMap. struct DenseMapInfo { // ASTNodeKind() is a good empty key because it is represented as a 0. @@ -132,6 +130,7 @@ class ASTNodeKind { enum NodeKindId { NKI_None, NKI_TemplateArgument, + NKI_TemplateArgumentLoc, NKI_TemplateName, NKI_NestedNameSpecifierLoc, NKI_QualType, @@ -150,8 +149,9 @@ class ASTNodeKind { #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type, #include "clang/AST/TypeNodes.inc" NKI_OMPClause, -#define OMP_CLAUSE_CLASS(Enum, Str, Class) NKI_##Class, -#include "llvm/Frontend/OpenMP/OMPKinds.def" +#define GEN_CLANG_CLAUSE_CLASS +#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class, +#include "llvm/Frontend/OpenMP/OMP.inc" NKI_NumberOfKinds }; @@ -191,6 +191,7 @@ class ASTNodeKind { }; KIND_TO_KIND_ID(CXXCtorInitializer) KIND_TO_KIND_ID(TemplateArgument) +KIND_TO_KIND_ID(TemplateArgumentLoc) KIND_TO_KIND_ID(TemplateName) KIND_TO_KIND_ID(NestedNameSpecifier) KIND_TO_KIND_ID(NestedNameSpecifierLoc) @@ -207,8 +208,9 @@ KIND_TO_KIND_ID(CXXBaseSpecifier) #include "clang/AST/StmtNodes.inc" #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type) #include "clang/AST/TypeNodes.inc" -#define OMP_CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class) -#include "llvm/Frontend/OpenMP/OMPKinds.def" +#define GEN_CLANG_CLAUSE_CLASS +#define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class) +#include "llvm/Frontend/OpenMP/OMP.inc" #undef KIND_TO_KIND_ID inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) { @@ -248,9 +250,8 @@ class DynTypedNode { /// in the \c DynTypedNode, and the returned pointer points at /// the storage inside DynTypedNode. For those nodes, do not /// use the pointer outside the scope of the DynTypedNode. - template - const T *get() const { - return BaseConverter::get(NodeKind, Storage.buffer); + template const T *get() const { + return BaseConverter::get(NodeKind, &Storage); } /// Retrieve the stored node as type \c T. @@ -258,7 +259,7 @@ class DynTypedNode { /// Similar to \c get(), but asserts that the type is what we are expecting. template const T &getUnchecked() const { - return BaseConverter::getUnchecked(NodeKind, Storage.buffer); + return BaseConverter::getUnchecked(NodeKind, &Storage); } ASTNodeKind getNodeKind() const { return NodeKind; } @@ -270,7 +271,7 @@ class DynTypedNode { /// method returns NULL. const void *getMemoizationData() const { return NodeKind.hasPointerIdentity() - ? *reinterpret_cast(Storage.buffer) + ? *reinterpret_cast(&Storage) : nullptr; } @@ -392,12 +393,12 @@ class DynTypedNode { /// Converter that uses dyn_cast from a stored BaseT*. template struct DynCastPtrConverter { - static const T *get(ASTNodeKind NodeKind, const char Storage[]) { + static const T *get(ASTNodeKind NodeKind, const void *Storage) { if (ASTNodeKind::getFromNodeKind().isBaseOf(NodeKind)) return &getUnchecked(NodeKind, Storage); return nullptr; } - static const T &getUnchecked(ASTNodeKind NodeKind, const char Storage[]) { + static const T &getUnchecked(ASTNodeKind NodeKind, const void *Storage) { assert(ASTNodeKind::getFromNodeKind().isBaseOf(NodeKind)); return *cast(static_cast( *reinterpret_cast(Storage))); @@ -405,19 +406,19 @@ class DynTypedNode { static DynTypedNode create(const BaseT &Node) { DynTypedNode Result; Result.NodeKind = ASTNodeKind::getFromNode(Node); - new (Result.Storage.buffer) const void *(&Node); + new (&Result.Storage) const void *(&Node); return Result; } }; /// Converter that stores T* (by pointer). template struct PtrConverter { - static const T *get(ASTNodeKind NodeKind, const char Storage[]) { + static const T *get(ASTNodeKind NodeKind, const void *Storage) { if (ASTNodeKind::getFromNodeKind().isSame(NodeKind)) return &getUnchecked(NodeKind, Storage); return nullptr; } - static const T &getUnchecked(ASTNodeKind NodeKind, const char Storage[]) { + static const T &getUnchecked(ASTNodeKind NodeKind, const void *Storage) { assert(ASTNodeKind::getFromNodeKind().isSame(NodeKind)); return *static_cast( *reinterpret_cast(Storage)); @@ -425,26 +426,26 @@ class DynTypedNode { static DynTypedNode create(const T &Node) { DynTypedNode Result; Result.NodeKind = ASTNodeKind::getFromNodeKind(); - new (Result.Storage.buffer) const void *(&Node); + new (&Result.Storage) const void *(&Node); return Result; } }; /// Converter that stores T (by value). template struct ValueConverter { - static const T *get(ASTNodeKind NodeKind, const char Storage[]) { + static const T *get(ASTNodeKind NodeKind, const void *Storage) { if (ASTNodeKind::getFromNodeKind().isSame(NodeKind)) return reinterpret_cast(Storage); return nullptr; } - static const T &getUnchecked(ASTNodeKind NodeKind, const char Storage[]) { + static const T &getUnchecked(ASTNodeKind NodeKind, const void *Storage) { assert(ASTNodeKind::getFromNodeKind().isSame(NodeKind)); return *reinterpret_cast(Storage); } static DynTypedNode create(const T &Node) { DynTypedNode Result; Result.NodeKind = ASTNodeKind::getFromNodeKind(); - new (Result.Storage.buffer) T(Node); + new (&Result.Storage) T(Node); return Result; } }; @@ -456,12 +457,13 @@ class DynTypedNode { /// Note that we can store \c Decls, \c Stmts, \c Types, /// \c NestedNameSpecifiers and \c CXXCtorInitializer by pointer as they are /// guaranteed to be unique pointers pointing to dedicated storage in the AST. - /// \c QualTypes, \c NestedNameSpecifierLocs, \c TypeLocs and - /// \c TemplateArguments on the other hand do not have storage or unique - /// pointers and thus need to be stored by value. + /// \c QualTypes, \c NestedNameSpecifierLocs, \c TypeLocs, + /// \c TemplateArguments and \c TemplateArgumentLocs on the other hand do not + /// have storage or unique pointers and thus need to be stored by value. llvm::AlignedCharArrayUnion Storage; + TemplateArgumentLoc, NestedNameSpecifierLoc, + QualType, TypeLoc> + Storage; }; template @@ -496,6 +498,10 @@ template <> struct DynTypedNode::BaseConverter< TemplateArgument, void> : public ValueConverter {}; +template <> +struct DynTypedNode::BaseConverter + : public ValueConverter {}; + template <> struct DynTypedNode::BaseConverter< TemplateName, void> : public ValueConverter {}; @@ -527,20 +533,6 @@ template struct DynTypedNode::BaseConverter { } }; -// Previously these types were defined in the clang::ast_type_traits namespace. -// Provide typedefs so that legacy code can be fixed asynchronously. -namespace ast_type_traits { -using DynTypedNode = ::clang::DynTypedNode; -using ASTNodeKind = ::clang::ASTNodeKind; -using TraversalKind = ::clang::TraversalKind; - -constexpr TraversalKind TK_AsIs = ::clang::TK_AsIs; -constexpr TraversalKind TK_IgnoreImplicitCastsAndParentheses = - ::clang::TK_IgnoreImplicitCastsAndParentheses; -constexpr TraversalKind TK_IgnoreUnlessSpelledInSource = - ::clang::TK_IgnoreUnlessSpelledInSource; -} // namespace ast_type_traits - } // end namespace clang namespace llvm { diff --git a/contrib/llvm-project/clang/include/clang/AST/AbstractBasicReader.h b/contrib/llvm-project/clang/include/clang/AST/AbstractBasicReader.h index d7b3a9da88ec2e..5505d661b44e2b 100644 --- a/contrib/llvm-project/clang/include/clang/AST/AbstractBasicReader.h +++ b/contrib/llvm-project/clang/include/clang/AST/AbstractBasicReader.h @@ -177,6 +177,40 @@ class DataStreamBasicReader : public BasicReaderBase { return llvm::APInt(bitWidth, numWords, &data[0]); } + llvm::FixedPointSemantics readFixedPointSemantics() { + unsigned width = asImpl().readUInt32(); + unsigned scale = asImpl().readUInt32(); + unsigned tmp = asImpl().readUInt32(); + bool isSigned = tmp & 0x1; + bool isSaturated = tmp & 0x2; + bool hasUnsignedPadding = tmp & 0x4; + return llvm::FixedPointSemantics(width, scale, isSigned, isSaturated, + hasUnsignedPadding); + } + + APValue::LValuePathSerializationHelper readLValuePathSerializationHelper( + SmallVectorImpl &path) { + auto elemTy = asImpl().readQualType(); + unsigned pathLength = asImpl().readUInt32(); + for (unsigned i = 0; i < pathLength; ++i) { + if (elemTy->template getAs()) { + unsigned int_ = asImpl().readUInt32(); + Decl *decl = asImpl().template readDeclAs(); + if (auto *recordDecl = dyn_cast(decl)) + elemTy = getASTContext().getRecordType(recordDecl); + else + elemTy = cast(decl)->getType(); + path.push_back( + APValue::LValuePathEntry(APValue::BaseOrMemberType(decl, int_))); + } else { + elemTy = getASTContext().getAsArrayType(elemTy)->getElementType(); + path.push_back( + APValue::LValuePathEntry::ArrayIndex(asImpl().readUInt32())); + } + } + return APValue::LValuePathSerializationHelper(path, elemTy); + } + Qualifiers readQualifiers() { static_assert(sizeof(Qualifiers().getAsOpaqueValue()) <= sizeof(uint32_t), "update this if the value size changes"); diff --git a/contrib/llvm-project/clang/include/clang/AST/AbstractBasicWriter.h b/contrib/llvm-project/clang/include/clang/AST/AbstractBasicWriter.h index 0a6730c86bbfee..75aef734ba9b51 100644 --- a/contrib/llvm-project/clang/include/clang/AST/AbstractBasicWriter.h +++ b/contrib/llvm-project/clang/include/clang/AST/AbstractBasicWriter.h @@ -9,6 +9,7 @@ #ifndef CLANG_AST_ABSTRACTBASICWRITER_H #define CLANG_AST_ABSTRACTBASICWRITER_H +#include "clang/AST/ASTContext.h" #include "clang/AST/DeclTemplate.h" namespace clang { @@ -121,6 +122,7 @@ template class DataStreamBasicWriter : public BasicWriterBase { protected: using BasicWriterBase::asImpl; + DataStreamBasicWriter(ASTContext &ctx) : BasicWriterBase(ctx) {} public: /// Implement property-find by ignoring it. We rely on properties being @@ -163,6 +165,39 @@ class DataStreamBasicWriter : public BasicWriterBase { asImpl().writeUInt64(words[i]); } + void writeFixedPointSemantics(const llvm::FixedPointSemantics &sema) { + asImpl().writeUInt32(sema.getWidth()); + asImpl().writeUInt32(sema.getScale()); + asImpl().writeUInt32(sema.isSigned() | sema.isSaturated() << 1 | + sema.hasUnsignedPadding() << 2); + } + + void writeLValuePathSerializationHelper( + APValue::LValuePathSerializationHelper lvaluePath) { + ArrayRef path = lvaluePath.Path; + QualType elemTy = lvaluePath.getType(); + asImpl().writeQualType(elemTy); + asImpl().writeUInt32(path.size()); + auto &ctx = ((BasicWriterBase *)this)->getASTContext(); + for (auto elem : path) { + if (elemTy->getAs()) { + asImpl().writeUInt32(elem.getAsBaseOrMember().getInt()); + const Decl *baseOrMember = elem.getAsBaseOrMember().getPointer(); + if (const auto *recordDecl = dyn_cast(baseOrMember)) { + asImpl().writeDeclRef(recordDecl); + elemTy = ctx.getRecordType(recordDecl); + } else { + const auto *valueDecl = cast(baseOrMember); + asImpl().writeDeclRef(valueDecl); + elemTy = valueDecl->getType(); + } + } else { + asImpl().writeUInt32(elem.getAsArrayIndex()); + elemTy = ctx.getAsArrayType(elemTy)->getElementType(); + } + } + } + void writeQualifiers(Qualifiers value) { static_assert(sizeof(value.getAsOpaqueValue()) <= sizeof(uint32_t), "update this if the value size changes"); diff --git a/contrib/llvm-project/clang/include/clang/AST/Attr.h b/contrib/llvm-project/clang/include/clang/AST/Attr.h index 1b457337d65876..e453733ab92c69 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Attr.h +++ b/contrib/llvm-project/clang/include/clang/AST/Attr.h @@ -162,6 +162,21 @@ class InheritableAttr : public Attr { } }; +class DeclOrStmtAttr : public InheritableAttr { +protected: + DeclOrStmtAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, + attr::Kind AK, bool IsLateParsed, + bool InheritEvenIfAlreadyPresent) + : InheritableAttr(Context, CommonInfo, AK, IsLateParsed, + InheritEvenIfAlreadyPresent) {} + +public: + static bool classof(const Attr *A) { + return A->getKind() >= attr::FirstDeclOrStmtAttr && + A->getKind() <= attr::LastDeclOrStmtAttr; + } +}; + class InheritableParamAttr : public InheritableAttr { protected: InheritableParamAttr(ASTContext &Context, @@ -259,7 +274,10 @@ class ParamIdx { /// Construct from a result from \c serialize. static ParamIdx deserialize(SerialType S) { - ParamIdx P(*reinterpret_cast(&S)); + // Using this two-step static_cast via void * instead of reinterpret_cast + // silences a -Wstrict-aliasing false positive from GCC7 and earlier. + void *ParamIdxPtr = static_cast(&S); + ParamIdx P(*static_cast(ParamIdxPtr)); assert((!P.IsValid || P.Idx >= 1) && "valid Idx must be one-origin"); return P; } @@ -334,29 +352,28 @@ static_assert(sizeof(ParamIdx) == sizeof(ParamIdx::SerialType), struct ParsedTargetAttr { std::vector Features; StringRef Architecture; + StringRef Tune; StringRef BranchProtection; bool DuplicateArchitecture = false; + bool DuplicateTune = false; bool operator ==(const ParsedTargetAttr &Other) const { return DuplicateArchitecture == Other.DuplicateArchitecture && - Architecture == Other.Architecture && Features == Other.Features; + DuplicateTune == Other.DuplicateTune && + Architecture == Other.Architecture && + Tune == Other.Tune && + BranchProtection == Other.BranchProtection && + Features == Other.Features; } }; #include "clang/AST/Attrs.inc" -inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - const Attr *At) { +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, + const Attr *At) { DB.AddTaggedVal(reinterpret_cast(At), DiagnosticsEngine::ak_attr); return DB; } - -inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - const Attr *At) { - PD.AddTaggedVal(reinterpret_cast(At), - DiagnosticsEngine::ak_attr); - return PD; -} } // end namespace clang #endif diff --git a/contrib/llvm-project/clang/include/clang/AST/CXXInheritance.h b/contrib/llvm-project/clang/include/clang/AST/CXXInheritance.h index 8b1bcb367b3b47..709f08bff82aee 100644 --- a/contrib/llvm-project/clang/include/clang/AST/CXXInheritance.h +++ b/contrib/llvm-project/clang/include/clang/AST/CXXInheritance.h @@ -149,12 +149,6 @@ class CXXBasePaths { /// to help build the set of paths. CXXBasePath ScratchPath; - /// Array of the declarations that have been found. This - /// array is constructed only if needed, e.g., to iterate over the - /// results within LookupResult. - std::unique_ptr DeclsFound; - unsigned NumDeclsFound = 0; - /// FindAmbiguities - Whether Sema::IsDerivedFrom should try find /// ambiguous paths while it is looking for a path from a derived /// type to a base type. @@ -170,8 +164,6 @@ class CXXBasePaths { /// is also recorded. bool DetectVirtual; - void ComputeDeclsFound(); - bool lookupInBases(ASTContext &Context, const CXXRecordDecl *Record, CXXRecordDecl::BaseMatchesCallback BaseMatches, bool LookupInDependent = false); @@ -198,8 +190,6 @@ class CXXBasePaths { using decl_range = llvm::iterator_range; - decl_range found_decls(); - /// Determine whether the path from the most-derived type to the /// given base type is ambiguous (i.e., it refers to multiple subobjects of /// the same base type). diff --git a/contrib/llvm-project/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def b/contrib/llvm-project/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def index 33e65f8ebf446d..d15d6698860f4a 100644 --- a/contrib/llvm-project/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def +++ b/contrib/llvm-project/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def @@ -131,6 +131,10 @@ FIELD(HasUninitializedFields, 1, NO_MERGE) /// constructors from a base class. FIELD(HasInheritedConstructor, 1, NO_MERGE) +/// True if there are any member using-declarations that inherit +/// default constructors from a base class. +FIELD(HasInheritedDefaultConstructor, 1, NO_MERGE) + /// True if there are any member using-declarations named /// 'operator='. FIELD(HasInheritedAssignment, 1, NO_MERGE) @@ -210,6 +214,9 @@ FIELD(DefaultedDestructorIsConstexpr, 1, NO_MERGE) /// member or base class of non-literal or volatile type. FIELD(HasNonLiteralTypeFieldsOrBases, 1, NO_MERGE) +/// True if this class is a structural type, assuming it is a literal type. +FIELD(StructuralIfLiteral, 1, NO_MERGE) + /// Whether we have a C++11 user-provided default constructor (not /// explicitly deleted or defaulted). FIELD(UserProvidedDefaultConstructor, 1, NO_MERGE) diff --git a/contrib/llvm-project/clang/include/clang/AST/CanonicalType.h b/contrib/llvm-project/clang/include/clang/AST/CanonicalType.h index 488284713bceca..15d7e9efc26aab 100644 --- a/contrib/llvm-project/clang/include/clang/AST/CanonicalType.h +++ b/contrib/llvm-project/clang/include/clang/AST/CanonicalType.h @@ -215,8 +215,8 @@ inline CanQualType Type::getCanonicalTypeUnqualified() const { return CanQualType::CreateUnsafe(getCanonicalTypeInternal()); } -inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - CanQualType T) { +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, + CanQualType T) { DB << static_cast(T); return DB; } diff --git a/contrib/llvm-project/clang/include/clang/AST/CommentLexer.h b/contrib/llvm-project/clang/include/clang/AST/CommentLexer.h index 138fdaca0ff612..94f778501e758f 100644 --- a/contrib/llvm-project/clang/include/clang/AST/CommentLexer.h +++ b/contrib/llvm-project/clang/include/clang/AST/CommentLexer.h @@ -62,13 +62,6 @@ class Token { /// The actual kind of the token. tok::TokenKind Kind; - /// Length of the token spelling in comment. Can be 0 for synthenized - /// tokens. - unsigned Length; - - /// Contains text value associated with a token. - const char *TextPtr; - /// Integer value associated with a token. /// /// If the token is a known command, contains command ID and TextPtr is @@ -76,6 +69,13 @@ class Token { /// contains the length of the string that starts at TextPtr. unsigned IntVal; + /// Length of the token spelling in comment. Can be 0 for synthenized + /// tokens. + unsigned Length; + + /// Contains text value associated with a token. + const char *TextPtr; + public: SourceLocation getLocation() const LLVM_READONLY { return Loc; } void setLocation(SourceLocation SL) { Loc = SL; } @@ -232,7 +232,6 @@ class Lexer { const char *const BufferStart; const char *const BufferEnd; - SourceLocation FileLoc; const char *BufferPtr; @@ -240,7 +239,14 @@ class Lexer { /// to newline or BufferEnd, for C comments points to star in '*/'. const char *CommentEnd; - enum LexerCommentState { + SourceLocation FileLoc; + + /// If true, the commands, html tags, etc will be parsed and reported as + /// separate tokens inside the comment body. If false, the comment text will + /// be parsed into text and newline tokens. + bool ParseCommands; + + enum LexerCommentState : uint8_t { LCS_BeforeComment, LCS_InsideBCPLComment, LCS_InsideCComment, @@ -250,7 +256,7 @@ class Lexer { /// Low-level lexer state, track if we are inside or outside of comment. LexerCommentState CommentState; - enum LexerState { + enum LexerState : uint8_t { /// Lexing normal comment text LS_Normal, @@ -280,11 +286,6 @@ class Lexer { /// command, including command marker. SmallString<16> VerbatimBlockEndCommandName; - /// If true, the commands, html tags, etc will be parsed and reported as - /// separate tokens inside the comment body. If false, the comment text will - /// be parsed into text and newline tokens. - bool ParseCommands; - /// Given a character reference name (e.g., "lt"), return the character that /// it stands for (e.g., "<"). StringRef resolveHTMLNamedCharacterReference(StringRef Name) const; diff --git a/contrib/llvm-project/clang/include/clang/AST/ComputeDependence.h b/contrib/llvm-project/clang/include/clang/AST/ComputeDependence.h index ac2daf9eb95abf..04e8e2c7d2ccb3 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ComputeDependence.h +++ b/contrib/llvm-project/clang/include/clang/AST/ComputeDependence.h @@ -70,6 +70,7 @@ class CXXPseudoDestructorExpr; class OverloadExpr; class DependentScopeDeclRefExpr; class CXXConstructExpr; +class CXXDefaultInitExpr; class LambdaExpr; class CXXUnresolvedConstructExpr; class CXXDependentScopeMemberExpr; @@ -106,7 +107,7 @@ class ObjCMessageExpr; ExprDependence computeDependence(FullExpr *E); ExprDependence computeDependence(OpaqueValueExpr *E); ExprDependence computeDependence(ParenExpr *E); -ExprDependence computeDependence(UnaryOperator *E); +ExprDependence computeDependence(UnaryOperator *E, const ASTContext &Ctx); ExprDependence computeDependence(UnaryExprOrTypeTraitExpr *E); ExprDependence computeDependence(ArraySubscriptExpr *E); ExprDependence computeDependence(MatrixSubscriptExpr *E); @@ -153,6 +154,7 @@ ExprDependence computeDependence(OverloadExpr *E, bool KnownDependent, bool KnownContainsUnexpandedParameterPack); ExprDependence computeDependence(DependentScopeDeclRefExpr *E); ExprDependence computeDependence(CXXConstructExpr *E); +ExprDependence computeDependence(CXXDefaultInitExpr *E); ExprDependence computeDependence(LambdaExpr *E, bool ContainsUnexpandedParameterPack); ExprDependence computeDependence(CXXUnresolvedConstructExpr *E); diff --git a/contrib/llvm-project/clang/include/clang/AST/Decl.h b/contrib/llvm-project/clang/include/clang/AST/Decl.h index 28faa2c1fc780c..1c5827b9c3a42d 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Decl.h +++ b/contrib/llvm-project/clang/include/clang/AST/Decl.h @@ -265,10 +265,25 @@ class NamedDecl : public Decl { // FIXME: Deprecated, move clients to getName(). std::string getNameAsString() const { return Name.getAsString(); } + /// Pretty-print the unqualified name of this declaration. Can be overloaded + /// by derived classes to provide a more user-friendly name when appropriate. virtual void printName(raw_ostream &os) const; /// Get the actual, stored name of the declaration, which may be a special /// name. + /// + /// Note that generally in diagnostics, the non-null \p NamedDecl* itself + /// should be sent into the diagnostic instead of using the result of + /// \p getDeclName(). + /// + /// A \p DeclarationName in a diagnostic will just be streamed to the output, + /// which will directly result in a call to \p DeclarationName::print. + /// + /// A \p NamedDecl* in a diagnostic will also ultimately result in a call to + /// \p DeclarationName::print, but with two customisation points along the + /// way (\p getNameForDiagnostic and \p printName). These are used to print + /// the template arguments if any, and to provide a user-friendly name for + /// some entities (such as unnamed variables and anonymous records). DeclarationName getDeclName() const { return Name; } /// Set the name of this declaration. @@ -788,18 +803,11 @@ struct EvaluatedStmt { /// Whether this statement is being evaluated. bool IsEvaluating : 1; - /// Whether we already checked whether this statement was an - /// integral constant expression. - bool CheckedICE : 1; - - /// Whether we are checking whether this statement is an - /// integral constant expression. - bool CheckingICE : 1; - - /// Whether this statement is an integral constant expression, - /// or in C++11, whether the statement is a constant expression. Only - /// valid if CheckedICE is true. - bool IsICE : 1; + /// Whether this variable is known to have constant initialization. This is + /// currently only computed in C++, for static / thread storage duration + /// variables that might have constant initialization and for variables that + /// are usable in constant expressions. + bool HasConstantInitialization : 1; /// Whether this variable is known to have constant destruction. That is, /// whether running the destructor on the initial value is a side-effect @@ -808,12 +816,18 @@ struct EvaluatedStmt { /// non-trivial. bool HasConstantDestruction : 1; + /// In C++98, whether the initializer is an ICE. This affects whether the + /// variable is usable in constant expressions. + bool HasICEInit : 1; + bool CheckedForICEInit : 1; + Stmt *Value; APValue Evaluated; EvaluatedStmt() - : WasEvaluated(false), IsEvaluating(false), CheckedICE(false), - CheckingICE(false), IsICE(false), HasConstantDestruction(false) {} + : WasEvaluated(false), IsEvaluating(false), + HasConstantInitialization(false), HasConstantDestruction(false), + HasICEInit(false), CheckedForICEInit(false) {} }; /// Represents a variable declaration or definition. @@ -1248,14 +1262,18 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { /// constant expression, according to the relevant language standard. /// This only checks properties of the declaration, and does not check /// whether the initializer is in fact a constant expression. - bool mightBeUsableInConstantExpressions(ASTContext &C) const; + /// + /// This corresponds to C++20 [expr.const]p3's notion of a + /// "potentially-constant" variable. + bool mightBeUsableInConstantExpressions(const ASTContext &C) const; /// Determine whether this variable's value can be used in a /// constant expression, according to the relevant language standard, /// including checking whether it was initialized by a constant expression. - bool isUsableInConstantExpressions(ASTContext &C) const; + bool isUsableInConstantExpressions(const ASTContext &C) const; EvaluatedStmt *ensureEvaluatedStmt() const; + EvaluatedStmt *getEvaluatedStmt() const; /// Attempt to evaluate the value of the initializer attached to this /// declaration, and produce notes explaining why it cannot be evaluated or is @@ -1272,25 +1290,29 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { /// Evaluate the destruction of this variable to determine if it constitutes /// constant destruction. /// - /// \pre isInitICE() + /// \pre hasConstantInitialization() /// \return \c true if this variable has constant destruction, \c false if /// not. bool evaluateDestruction(SmallVectorImpl &Notes) const; - /// Determines whether it is already known whether the - /// initializer is an integral constant expression or not. - bool isInitKnownICE() const; - - /// Determines whether the initializer is an integral constant - /// expression, or in C++11, whether the initializer is a constant - /// expression. + /// Determine whether this variable has constant initialization. /// - /// \pre isInitKnownICE() - bool isInitICE() const; - - /// Determine whether the value of the initializer attached to this - /// declaration is an integral constant expression. - bool checkInitIsICE() const; + /// This is only set in two cases: when the language semantics require + /// constant initialization (globals in C and some globals in C++), and when + /// the variable is usable in constant expressions (constexpr, const int, and + /// reference variables in C++). + bool hasConstantInitialization() const; + + /// Determine whether the initializer of this variable is an integer constant + /// expression. For use in C++98, where this affects whether the variable is + /// usable in constant expressions. + bool hasICEInitializer(const ASTContext &Context) const; + + /// Evaluate the initializer of this variable to determine whether it's a + /// constant initializer. Should only be called once, after completing the + /// definition of the variable. + bool checkForConstantInitialization( + SmallVectorImpl &Notes) const; void setInitStyle(InitializationStyle Style) { VarDeclBits.InitStyle = Style; @@ -1639,6 +1661,9 @@ class ParmVarDecl : public VarDecl { return ParmVarDeclBits.IsObjCMethodParam; } + /// Determines whether this parameter is destroyed in the callee function. + bool isDestroyedInCallee() const; + unsigned getFunctionScopeDepth() const { if (ParmVarDeclBits.IsObjCMethodParam) return 0; return ParmVarDeclBits.ScopeDepthOrObjCQuals; @@ -1956,7 +1981,7 @@ class FunctionDecl : public DeclaratorDecl, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified = false, bool hasWrittenPrototype = true, - ConstexprSpecKind ConstexprKind = CSK_unspecified, + ConstexprSpecKind ConstexprKind = ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause = nullptr) { DeclarationNameInfo NameInfo(N, NLoc); return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC, @@ -2028,7 +2053,14 @@ class FunctionDecl : public DeclaratorDecl, /// /// The variant that accepts a FunctionDecl pointer will set that function /// declaration to the declaration that is a definition (if there is one). - bool isDefined(const FunctionDecl *&Definition) const; + /// + /// \param CheckForPendingFriendDefinition If \c true, also check for friend + /// declarations that were instantiataed from function definitions. + /// Such a declaration behaves as if it is a definition for the + /// purpose of redefinition checking, but isn't actually a "real" + /// definition until its body is instantiated. + bool isDefined(const FunctionDecl *&Definition, + bool CheckForPendingFriendDefinition = false) const; bool isDefined() const { const FunctionDecl* Definition; @@ -2074,6 +2106,11 @@ class FunctionDecl : public DeclaratorDecl, willHaveBody() || hasDefiningAttr(); } + /// Determine whether this specific declaration of the function is a friend + /// declaration that was instantiated from a function definition. Such + /// declarations behave like definitions in some contexts. + bool isThisDeclarationInstantiatedFromAFriendDefinition() const; + /// Returns whether this specific declaration of the function has a body. bool doesThisDeclarationHaveABody() const { return (!FunctionDeclBits.HasDefaultedFunctionInfo && Body) || @@ -2196,19 +2233,19 @@ class FunctionDecl : public DeclaratorDecl, /// Whether this is a (C++11) constexpr function or constexpr constructor. bool isConstexpr() const { - return FunctionDeclBits.ConstexprKind != CSK_unspecified; + return getConstexprKind() != ConstexprSpecKind::Unspecified; } void setConstexprKind(ConstexprSpecKind CSK) { - FunctionDeclBits.ConstexprKind = CSK; + FunctionDeclBits.ConstexprKind = static_cast(CSK); } ConstexprSpecKind getConstexprKind() const { return static_cast(FunctionDeclBits.ConstexprKind); } bool isConstexprSpecified() const { - return FunctionDeclBits.ConstexprKind == CSK_constexpr; + return getConstexprKind() == ConstexprSpecKind::Constexpr; } bool isConsteval() const { - return FunctionDeclBits.ConstexprKind == CSK_consteval; + return getConstexprKind() == ConstexprSpecKind::Consteval; } /// Whether the instantiation of this function is pending. @@ -2231,10 +2268,6 @@ class FunctionDecl : public DeclaratorDecl, bool usesSEHTry() const { return FunctionDeclBits.UsesSEHTry; } void setUsesSEHTry(bool UST) { FunctionDeclBits.UsesSEHTry = UST; } - /// Indicates the function uses Floating Point constrained intrinsics - bool usesFPIntrin() const { return FunctionDeclBits.UsesFPIntrin; } - void setUsesFPIntrin(bool Val) { FunctionDeclBits.UsesFPIntrin = Val; } - /// Whether this function has been deleted. /// /// A function that is "deleted" (via the C++0x "= delete" syntax) @@ -4498,14 +4531,8 @@ class EmptyDecl : public Decl { /// Insertion operator for diagnostics. This allows sending NamedDecl's /// into a diagnostic with <<. -inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - const NamedDecl* ND) { - DB.AddTaggedVal(reinterpret_cast(ND), - DiagnosticsEngine::ak_nameddecl); - return DB; -} -inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - const NamedDecl* ND) { +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD, + const NamedDecl *ND) { PD.AddTaggedVal(reinterpret_cast(ND), DiagnosticsEngine::ak_nameddecl); return PD; diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclBase.h b/contrib/llvm-project/clang/include/clang/AST/DeclBase.h index af5959c4e9c2e0..bdad53dfb8a033 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclBase.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclBase.h @@ -1246,8 +1246,7 @@ class DeclContextLookupResult { using IteratorBase = llvm::iterator_adaptor_base; + std::random_access_iterator_tag, NamedDecl *>; class iterator : public IteratorBase { value_type SingleElement; diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h b/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h index 2b8d7e879a0aad..89006b1cfa7f4c 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h @@ -744,9 +744,14 @@ class CXXRecordDecl : public RecordDecl { /// /// This value is used for lazy creation of default constructors. bool needsImplicitDefaultConstructor() const { - return !data().UserDeclaredConstructor && - !(data().DeclaredSpecialMembers & SMF_DefaultConstructor) && - (!isLambda() || lambdaIsDefaultConstructibleAndAssignable()); + return (!data().UserDeclaredConstructor && + !(data().DeclaredSpecialMembers & SMF_DefaultConstructor) && + (!isLambda() || lambdaIsDefaultConstructibleAndAssignable())) || + // FIXME: Proposed fix to core wording issue: if a class inherits + // a default constructor and doesn't explicitly declare one, one + // is declared implicitly. + (data().HasInheritedDefaultConstructor && + !(data().DeclaredSpecialMembers & SMF_DefaultConstructor)); } /// Determine whether this class has any user-declared constructors. @@ -1008,8 +1013,13 @@ class CXXRecordDecl : public RecordDecl { /// Retrieve the lambda static invoker, the address of which /// is returned by the conversion operator, and the body of which - /// is forwarded to the lambda call operator. + /// is forwarded to the lambda call operator. The version that does not + /// take a calling convention uses the 'default' calling convention for free + /// functions if the Lambda's calling convention was not modified via + /// attribute. Otherwise, it will return the calling convention specified for + /// the lambda. CXXMethodDecl *getLambdaStaticInvoker() const; + CXXMethodDecl *getLambdaStaticInvoker(CallingConv CC) const; /// Retrieve the generic lambda's template parameter list. /// Returns null if the class does not represent a lambda or a generic @@ -1025,7 +1035,7 @@ class CXXRecordDecl : public RecordDecl { } /// Set the captures for this lambda closure type. - void setCaptures(ArrayRef Captures); + void setCaptures(ASTContext &Context, ArrayRef Captures); /// For a closure type, retrieve the mapping from captured /// variables and \c this to the non-static data members that store the @@ -1396,6 +1406,11 @@ class CXXRecordDecl : public RecordDecl { hasTrivialDefaultConstructor()); } + /// Determine whether this is a structural type. + bool isStructural() const { + return isLiteral() && data().StructuralIfLiteral; + } + /// If this record is an instantiation of a member class, /// retrieves the member class from which it was instantiated. /// @@ -1612,58 +1627,6 @@ class CXXRecordDecl : public RecordDecl { CXXBasePath &Path, const CXXRecordDecl *BaseRecord); - /// Base-class lookup callback that determines whether there exists - /// a tag with the given name. - /// - /// This callback can be used with \c lookupInBases() to find tag members - /// of the given name within a C++ class hierarchy. - static bool FindTagMember(const CXXBaseSpecifier *Specifier, - CXXBasePath &Path, DeclarationName Name); - - /// Base-class lookup callback that determines whether there exists - /// a member with the given name. - /// - /// This callback can be used with \c lookupInBases() to find members - /// of the given name within a C++ class hierarchy. - static bool FindOrdinaryMember(const CXXBaseSpecifier *Specifier, - CXXBasePath &Path, DeclarationName Name); - - /// Base-class lookup callback that determines whether there exists - /// a member with the given name. - /// - /// This callback can be used with \c lookupInBases() to find members - /// of the given name within a C++ class hierarchy, including dependent - /// classes. - static bool - FindOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier, - CXXBasePath &Path, DeclarationName Name); - - /// Base-class lookup callback that determines whether there exists - /// an OpenMP declare reduction member with the given name. - /// - /// This callback can be used with \c lookupInBases() to find members - /// of the given name within a C++ class hierarchy. - static bool FindOMPReductionMember(const CXXBaseSpecifier *Specifier, - CXXBasePath &Path, DeclarationName Name); - - /// Base-class lookup callback that determines whether there exists - /// an OpenMP declare mapper member with the given name. - /// - /// This callback can be used with \c lookupInBases() to find members - /// of the given name within a C++ class hierarchy. - static bool FindOMPMapperMember(const CXXBaseSpecifier *Specifier, - CXXBasePath &Path, DeclarationName Name); - - /// Base-class lookup callback that determines whether there exists - /// a member with the given name that can be used in a nested-name-specifier. - /// - /// This callback can be used with \c lookupInBases() to find members of - /// the given name within a C++ class hierarchy that can occur within - /// nested-name-specifiers. - static bool FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier, - CXXBasePath &Path, - DeclarationName Name); - /// Retrieve the final overriders for each virtual member /// function in the class hierarchy where this class is the /// most-derived class in the class hierarchy. @@ -1672,12 +1635,20 @@ class CXXRecordDecl : public RecordDecl { /// Get the indirect primary bases for this class. void getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet& Bases) const; + /// Determine whether this class has a member with the given name, possibly + /// in a non-dependent base class. + /// + /// No check for ambiguity is performed, so this should never be used when + /// implementing language semantics, but it may be appropriate for warnings, + /// static analysis, or similar. + bool hasMemberName(DeclarationName N) const; + /// Performs an imprecise lookup of a dependent name in this class. /// /// This function does not follow strict semantic rules and should be used /// only when lookup rules can be relaxed, e.g. indexing. std::vector - lookupDependentName(const DeclarationName &Name, + lookupDependentName(DeclarationName Name, llvm::function_ref Filter); /// Renders and displays an inheritance diagram @@ -1764,6 +1735,12 @@ class CXXRecordDecl : public RecordDecl { getLambdaData().HasKnownInternalLinkage = HasKnownInternalLinkage; } + /// Set the device side mangling number. + void setDeviceLambdaManglingNumber(unsigned Num) const; + + /// Retrieve the device side mangling number. + unsigned getDeviceLambdaManglingNumber() const; + /// Returns the inheritance model used for this record. MSInheritanceModel getMSInheritanceModel() const; @@ -1877,7 +1854,7 @@ class CXXDeductionGuideDecl : public FunctionDecl { const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation) : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo, - SC_None, false, CSK_unspecified), + SC_None, false, ConstexprSpecKind::Unspecified), ExplicitSpec(ES) { if (EndLocation.isValid()) setRangeEnd(EndLocation); @@ -4070,11 +4047,8 @@ class MSGuidDecl : public ValueDecl, /// Insertion operator for diagnostics. This allows sending an AccessSpecifier /// into a diagnostic with <<. -const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - AccessSpecifier AS); - -const PartialDiagnostic &operator<<(const PartialDiagnostic &DB, - AccessSpecifier AS); +const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, + AccessSpecifier AS); } // namespace clang diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclObjC.h b/contrib/llvm-project/clang/include/clang/AST/DeclObjC.h index 5613ed8370c034..b1bce069920c63 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclObjC.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclObjC.h @@ -320,6 +320,13 @@ class ObjCMethodDecl : public NamedDecl, public DeclContext { return const_cast(this)->getClassInterface(); } + /// If this method is declared or implemented in a category, return + /// that category. + ObjCCategoryDecl *getCategory(); + const ObjCCategoryDecl *getCategory() const { + return const_cast(this)->getCategory(); + } + Selector getSelector() const { return getDeclName().getObjCSelector(); } QualType getReturnType() const { return MethodDeclType; } @@ -649,20 +656,8 @@ class ObjCTypeParamDecl : public TypedefNameDecl { /// \endcode class ObjCTypeParamList final : private llvm::TrailingObjects { - /// Stores the components of a SourceRange as a POD. - struct PODSourceRange { - unsigned Begin; - unsigned End; - }; - - union { - /// Location of the left and right angle brackets. - PODSourceRange Brackets; - - // Used only for alignment. - ObjCTypeParamDecl *AlignmentHack; - }; - + /// Location of the left and right angle brackets. + SourceRange Brackets; /// The number of parameters in the list, which are tail-allocated. unsigned NumParams; @@ -710,17 +705,9 @@ class ObjCTypeParamList final return *(end() - 1); } - SourceLocation getLAngleLoc() const { - return SourceLocation::getFromRawEncoding(Brackets.Begin); - } - - SourceLocation getRAngleLoc() const { - return SourceLocation::getFromRawEncoding(Brackets.End); - } - - SourceRange getSourceRange() const { - return SourceRange(getLAngleLoc(), getRAngleLoc()); - } + SourceLocation getLAngleLoc() const { return Brackets.getBegin(); } + SourceLocation getRAngleLoc() const { return Brackets.getEnd(); } + SourceRange getSourceRange() const { return Brackets; } /// Gather the default set of type arguments to be substituted for /// these type parameters when dealing with an unspecialized type. @@ -2171,6 +2158,14 @@ class ObjCProtocolDecl : public ObjCContainerDecl, data().ReferencedProtocols.set(List, Num, Locs, C); } + /// This is true iff the protocol is tagged with the + /// `objc_non_runtime_protocol` attribute. + bool isNonRuntimeProtocol() const; + + /// Get the set of all protocols implied by this protocols inheritance + /// hierarchy. + void getImpliedProtocols(llvm::DenseSet &IPs) const; + ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName); // Lookup a method. First, we search locally. If a method isn't diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclOpenMP.h b/contrib/llvm-project/clang/include/clang/AST/DeclOpenMP.h index 154ecb977692ca..4aa5bde92e123f 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclOpenMP.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclOpenMP.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_DECLOPENMP_H #define LLVM_CLANG_AST_DECLOPENMP_H +#include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" #include "clang/AST/ExternalASTSource.h" @@ -24,6 +25,76 @@ namespace clang { +/// This is a basic class for representing single OpenMP declarative directive. +/// +template class OMPDeclarativeDirective : public U { + friend class ASTDeclReader; + friend class ASTDeclWriter; + + /// Get the clauses storage. + MutableArrayRef getClauses() { + if (!Data) + return llvm::None; + return Data->getClauses(); + } + +protected: + /// Data, associated with the directive. + OMPChildren *Data = nullptr; + + /// Build instance of directive. + template + OMPDeclarativeDirective(Params &&... P) : U(std::forward(P)...) {} + + template + static T *createDirective(const ASTContext &C, DeclContext *DC, + ArrayRef Clauses, unsigned NumChildren, + Params &&... P) { + auto *Inst = new (C, DC, size(Clauses.size(), NumChildren)) + T(DC, std::forward(P)...); + Inst->Data = OMPChildren::Create(Inst + 1, Clauses, + /*AssociatedStmt=*/nullptr, NumChildren); + Inst->Data->setClauses(Clauses); + return Inst; + } + + template + static T *createEmptyDirective(const ASTContext &C, unsigned ID, + unsigned NumClauses, unsigned NumChildren, + Params &&... P) { + auto *Inst = new (C, ID, size(NumClauses, NumChildren)) + T(nullptr, std::forward(P)...); + Inst->Data = OMPChildren::CreateEmpty( + Inst + 1, NumClauses, /*HasAssociatedStmt=*/false, NumChildren); + return Inst; + } + + static size_t size(unsigned NumClauses, unsigned NumChildren) { + return OMPChildren::size(NumClauses, /*HasAssociatedStmt=*/false, + NumChildren); + } + +public: + /// Get number of clauses. + unsigned getNumClauses() const { + if (!Data) + return 0; + return Data->getNumClauses(); + } + + /// Returns specified clause. + /// + /// \param I Number of clause. + /// + OMPClause *getClause(unsigned I) const { return clauses()[I]; } + + ArrayRef clauses() const { + if (!Data) + return llvm::None; + return Data->getClauses(); + } +}; + /// This represents '#pragma omp threadprivate ...' directive. /// For example, in the following, both 'a' and 'A::b' are threadprivate: /// @@ -36,25 +107,23 @@ namespace clang { /// }; /// \endcode /// -class OMPThreadPrivateDecl final - : public Decl, - private llvm::TrailingObjects { - friend class ASTDeclReader; - friend TrailingObjects; - - unsigned NumVars; +class OMPThreadPrivateDecl final : public OMPDeclarativeDirective { + friend class OMPDeclarativeDirective; virtual void anchor(); - OMPThreadPrivateDecl(Kind DK, DeclContext *DC, SourceLocation L) : - Decl(DK, DC, L), NumVars(0) { } + OMPThreadPrivateDecl(DeclContext *DC = nullptr, + SourceLocation L = SourceLocation()) + : OMPDeclarativeDirective(OMPThreadPrivate, DC, L) {} ArrayRef getVars() const { - return llvm::makeArrayRef(getTrailingObjects(), NumVars); + auto **Storage = reinterpret_cast(Data->getChildren().data()); + return llvm::makeArrayRef(Storage, Data->getNumChildren()); } MutableArrayRef getVars() { - return MutableArrayRef(getTrailingObjects(), NumVars); + auto **Storage = reinterpret_cast(Data->getChildren().data()); + return llvm::makeMutableArrayRef(Storage, Data->getNumChildren()); } void setVars(ArrayRef VL); @@ -71,8 +140,8 @@ class OMPThreadPrivateDecl final typedef llvm::iterator_range varlist_range; typedef llvm::iterator_range varlist_const_range; - unsigned varlist_size() const { return NumVars; } - bool varlist_empty() const { return NumVars == 0; } + unsigned varlist_size() const { return Data->getNumChildren(); } + bool varlist_empty() const { return Data->getChildren().empty(); } varlist_range varlists() { return varlist_range(varlist_begin(), varlist_end()); @@ -94,7 +163,7 @@ class OMPThreadPrivateDecl final /// 'float': /// /// \code -/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \ +/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) /// initializer (omp_priv = 0) /// \endcode /// @@ -214,11 +283,11 @@ class OMPDeclareReductionDecl final : public ValueDecl, public DeclContext { /// \code /// #pragma omp declare mapper(mid: struct vec v) map(v.len, v.data[0:N]) /// \endcode -class OMPDeclareMapperDecl final : public ValueDecl, public DeclContext { +class OMPDeclareMapperDecl final : public OMPDeclarativeDirective, + public DeclContext { + friend class OMPDeclarativeDirective; friend class ASTDeclReader; - - /// Clauses associated with this mapper declaration - MutableArrayRef Clauses; + friend class ASTDeclWriter; /// Mapper variable, which is 'v' in the example above Expr *MapperVarRef = nullptr; @@ -230,42 +299,36 @@ class OMPDeclareMapperDecl final : public ValueDecl, public DeclContext { void anchor() override; - OMPDeclareMapperDecl(Kind DK, DeclContext *DC, SourceLocation L, - DeclarationName Name, QualType Ty, - DeclarationName VarName, + OMPDeclareMapperDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, + QualType Ty, DeclarationName VarName, OMPDeclareMapperDecl *PrevDeclInScope) - : ValueDecl(DK, DC, L, Name, Ty), DeclContext(DK), VarName(VarName), + : OMPDeclarativeDirective(OMPDeclareMapper, DC, L, Name, Ty), + DeclContext(OMPDeclareMapper), VarName(VarName), PrevDeclInScope(PrevDeclInScope) {} void setPrevDeclInScope(OMPDeclareMapperDecl *Prev) { PrevDeclInScope = Prev; } - /// Sets an array of clauses to this mapper declaration - void setClauses(ArrayRef CL); - public: /// Creates declare mapper node. static OMPDeclareMapperDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, QualType T, DeclarationName VarName, + ArrayRef Clauses, OMPDeclareMapperDecl *PrevDeclInScope); /// Creates deserialized declare mapper node. static OMPDeclareMapperDecl *CreateDeserialized(ASTContext &C, unsigned ID, unsigned N); - /// Creates an array of clauses to this mapper declaration and intializes - /// them. - void CreateClauses(ASTContext &C, ArrayRef CL); - using clauselist_iterator = MutableArrayRef::iterator; using clauselist_const_iterator = ArrayRef::iterator; using clauselist_range = llvm::iterator_range; using clauselist_const_range = llvm::iterator_range; - unsigned clauselist_size() const { return Clauses.size(); } - bool clauselist_empty() const { return Clauses.empty(); } + unsigned clauselist_size() const { return Data->getNumClauses(); } + bool clauselist_empty() const { return Data->getClauses().empty(); } clauselist_range clauselists() { return clauselist_range(clauselist_begin(), clauselist_end()); @@ -273,16 +336,24 @@ class OMPDeclareMapperDecl final : public ValueDecl, public DeclContext { clauselist_const_range clauselists() const { return clauselist_const_range(clauselist_begin(), clauselist_end()); } - clauselist_iterator clauselist_begin() { return Clauses.begin(); } - clauselist_iterator clauselist_end() { return Clauses.end(); } - clauselist_const_iterator clauselist_begin() const { return Clauses.begin(); } - clauselist_const_iterator clauselist_end() const { return Clauses.end(); } + clauselist_iterator clauselist_begin() { return Data->getClauses().begin(); } + clauselist_iterator clauselist_end() { return Data->getClauses().end(); } + clauselist_const_iterator clauselist_begin() const { + return Data->getClauses().begin(); + } + clauselist_const_iterator clauselist_end() const { + return Data->getClauses().end(); + } /// Get the variable declared in the mapper - Expr *getMapperVarRef() { return MapperVarRef; } - const Expr *getMapperVarRef() const { return MapperVarRef; } + Expr *getMapperVarRef() { return cast_or_null(Data->getChildren()[0]); } + const Expr *getMapperVarRef() const { + return cast_or_null(Data->getChildren()[0]); + } /// Set the variable declared in the mapper - void setMapperVarRef(Expr *MapperVarRefE) { MapperVarRef = MapperVarRefE; } + void setMapperVarRef(Expr *MapperVarRefE) { + Data->getChildren()[0] = MapperVarRefE; + } /// Get the name of the variable declared in the mapper DeclarationName getVarName() { return VarName; } @@ -342,34 +413,14 @@ class OMPCapturedExprDecl final : public VarDecl { /// #pragma omp requires unified_address /// \endcode /// -class OMPRequiresDecl final - : public Decl, - private llvm::TrailingObjects { +class OMPRequiresDecl final : public OMPDeclarativeDirective { + friend class OMPDeclarativeDirective; friend class ASTDeclReader; - friend TrailingObjects; - - // Number of clauses associated with this requires declaration - unsigned NumClauses = 0; virtual void anchor(); - OMPRequiresDecl(Kind DK, DeclContext *DC, SourceLocation L) - : Decl(DK, DC, L), NumClauses(0) {} - - /// Returns an array of immutable clauses associated with this requires - /// declaration - ArrayRef getClauses() const { - return llvm::makeArrayRef(getTrailingObjects(), NumClauses); - } - - /// Returns an array of clauses associated with this requires declaration - MutableArrayRef getClauses() { - return MutableArrayRef(getTrailingObjects(), - NumClauses); - } - - /// Sets an array of clauses to this requires declaration - void setClauses(ArrayRef CL); + OMPRequiresDecl(DeclContext *DC, SourceLocation L) + : OMPDeclarativeDirective(OMPRequires, DC, L) {} public: /// Create requires node. @@ -384,8 +435,8 @@ class OMPRequiresDecl final using clauselist_range = llvm::iterator_range; using clauselist_const_range = llvm::iterator_range; - unsigned clauselist_size() const { return NumClauses; } - bool clauselist_empty() const { return NumClauses == 0; } + unsigned clauselist_size() const { return Data->getNumClauses(); } + bool clauselist_empty() const { return Data->getClauses().empty(); } clauselist_range clauselists() { return clauselist_range(clauselist_begin(), clauselist_end()); @@ -393,13 +444,13 @@ class OMPRequiresDecl final clauselist_const_range clauselists() const { return clauselist_const_range(clauselist_begin(), clauselist_end()); } - clauselist_iterator clauselist_begin() { return getClauses().begin(); } - clauselist_iterator clauselist_end() { return getClauses().end(); } + clauselist_iterator clauselist_begin() { return Data->getClauses().begin(); } + clauselist_iterator clauselist_end() { return Data->getClauses().end(); } clauselist_const_iterator clauselist_begin() const { - return getClauses().begin(); + return Data->getClauses().begin(); } clauselist_const_iterator clauselist_end() const { - return getClauses().end(); + return Data->getClauses().end(); } static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -419,53 +470,27 @@ class OMPRequiresDecl final /// }; /// \endcode /// -class OMPAllocateDecl final - : public Decl, - private llvm::TrailingObjects { +class OMPAllocateDecl final : public OMPDeclarativeDirective { + friend class OMPDeclarativeDirective; friend class ASTDeclReader; - friend TrailingObjects; - - /// Number of variable within the allocate directive. - unsigned NumVars = 0; - /// Number of clauses associated with the allocate directive. - unsigned NumClauses = 0; - - size_t numTrailingObjects(OverloadToken) const { - return NumVars; - } - size_t numTrailingObjects(OverloadToken) const { - return NumClauses; - } virtual void anchor(); - OMPAllocateDecl(Kind DK, DeclContext *DC, SourceLocation L) - : Decl(DK, DC, L) {} + OMPAllocateDecl(DeclContext *DC, SourceLocation L) + : OMPDeclarativeDirective(OMPAllocate, DC, L) {} ArrayRef getVars() const { - return llvm::makeArrayRef(getTrailingObjects(), NumVars); + auto **Storage = reinterpret_cast(Data->getChildren().data()); + return llvm::makeArrayRef(Storage, Data->getNumChildren()); } MutableArrayRef getVars() { - return MutableArrayRef(getTrailingObjects(), NumVars); + auto **Storage = reinterpret_cast(Data->getChildren().data()); + return llvm::makeMutableArrayRef(Storage, Data->getNumChildren()); } void setVars(ArrayRef VL); - /// Returns an array of immutable clauses associated with this directive. - ArrayRef getClauses() const { - return llvm::makeArrayRef(getTrailingObjects(), NumClauses); - } - - /// Returns an array of clauses associated with this directive. - MutableArrayRef getClauses() { - return MutableArrayRef(getTrailingObjects(), - NumClauses); - } - - /// Sets an array of clauses to this requires declaration - void setClauses(ArrayRef CL); - public: static OMPAllocateDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef VL, @@ -482,11 +507,10 @@ class OMPAllocateDecl final using clauselist_range = llvm::iterator_range; using clauselist_const_range = llvm::iterator_range; - - unsigned varlist_size() const { return NumVars; } - bool varlist_empty() const { return NumVars == 0; } - unsigned clauselist_size() const { return NumClauses; } - bool clauselist_empty() const { return NumClauses == 0; } + unsigned varlist_size() const { return Data->getNumChildren(); } + bool varlist_empty() const { return Data->getChildren().empty(); } + unsigned clauselist_size() const { return Data->getNumClauses(); } + bool clauselist_empty() const { return Data->getClauses().empty(); } varlist_range varlists() { return varlist_range(varlist_begin(), varlist_end()); @@ -505,13 +529,13 @@ class OMPAllocateDecl final clauselist_const_range clauselists() const { return clauselist_const_range(clauselist_begin(), clauselist_end()); } - clauselist_iterator clauselist_begin() { return getClauses().begin(); } - clauselist_iterator clauselist_end() { return getClauses().end(); } + clauselist_iterator clauselist_begin() { return Data->getClauses().begin(); } + clauselist_iterator clauselist_end() { return Data->getClauses().end(); } clauselist_const_iterator clauselist_begin() const { - return getClauses().begin(); + return Data->getClauses().begin(); } clauselist_const_iterator clauselist_end() const { - return getClauses().end(); + return Data->getClauses().end(); } static bool classof(const Decl *D) { return classofKind(D->getKind()); } diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h b/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h index e9c4879b41e896..7fbf6294970eb7 100755 --- a/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h @@ -77,7 +77,7 @@ class TemplateParameterList final /// The number of template parameters in this template /// parameter list. - unsigned NumParams : 30; + unsigned NumParams : 29; /// Whether this template parameter list contains an unexpanded parameter /// pack. @@ -204,10 +204,6 @@ class TemplateParameterList final bool OmitTemplateKW = false) const; void print(raw_ostream &Out, const ASTContext &Context, const PrintingPolicy &Policy, bool OmitTemplateKW = false) const; - -public: - // FIXME: workaround for MSVC 2013; remove when no longer needed - using FixedSizeStorageOwner = TrailingObjects::FixedSizeStorageOwner; }; /// Stores a list of template parameters and the associated @@ -2270,7 +2266,7 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl { /// Retrieve the set of partial specializations of this class /// template. llvm::FoldingSetVector & - getPartialSpecializations(); + getPartialSpecializations() const; ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, @@ -2367,7 +2363,7 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl { /// Retrieve the partial specializations as an ordered list. void getPartialSpecializations( - SmallVectorImpl &PS); + SmallVectorImpl &PS) const; /// Find a class template partial specialization with the given /// type T. @@ -3099,7 +3095,7 @@ class VarTemplateDecl : public RedeclarableTemplateDecl { /// Retrieve the set of partial specializations of this class /// template. llvm::FoldingSetVector & - getPartialSpecializations(); + getPartialSpecializations() const; VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, @@ -3195,7 +3191,7 @@ class VarTemplateDecl : public RedeclarableTemplateDecl { /// Retrieve the partial specializations as an ordered list. void getPartialSpecializations( - SmallVectorImpl &PS); + SmallVectorImpl &PS) const; /// Find a variable template partial specialization which was /// instantiated @@ -3230,7 +3226,7 @@ class VarTemplateDecl : public RedeclarableTemplateDecl { static bool classofKind(Kind K) { return K == VarTemplate; } }; -// \brief Declaration of a C++2a concept. +/// Declaration of a C++2a concept. class ConceptDecl : public TemplateDecl, public Mergeable { protected: Expr *ConstraintExpr; @@ -3259,6 +3255,9 @@ class ConceptDecl : public TemplateDecl, public Mergeable { return isa(getTemplateParameters()->getParam(0)); } + ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); } + const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); } + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == Concept; } @@ -3268,6 +3267,74 @@ class ConceptDecl : public TemplateDecl, public Mergeable { friend class ASTDeclWriter; }; +/// A template parameter object. +/// +/// Template parameter objects represent values of class type used as template +/// arguments. There is one template parameter object for each such distinct +/// value used as a template argument across the program. +/// +/// \code +/// struct A { int x, y; }; +/// template struct S; +/// S s1; +/// S s2; // same type, argument is same TemplateParamObjectDecl. +/// \endcode +class TemplateParamObjectDecl : public ValueDecl, + public Mergeable, + public llvm::FoldingSetNode { +private: + /// The value of this template parameter object. + APValue Value; + + TemplateParamObjectDecl(DeclContext *DC, QualType T, const APValue &V) + : ValueDecl(TemplateParamObject, DC, SourceLocation(), DeclarationName(), + T), + Value(V) {} + + static TemplateParamObjectDecl *Create(const ASTContext &C, QualType T, + const APValue &V); + static TemplateParamObjectDecl *CreateDeserialized(ASTContext &C, + unsigned ID); + + /// Only ASTContext::getTemplateParamObjectDecl and deserialization + /// create these. + friend class ASTContext; + friend class ASTReader; + friend class ASTDeclReader; + +public: + /// Print this template parameter object in a human-readable format. + void printName(llvm::raw_ostream &OS) const override; + + /// Print this object as an equivalent expression. + void printAsExpr(llvm::raw_ostream &OS) const; + + /// Print this object as an initializer suitable for a variable of the + /// object's type. + void printAsInit(llvm::raw_ostream &OS) const; + + const APValue &getValue() const { return Value; } + + static void Profile(llvm::FoldingSetNodeID &ID, QualType T, + const APValue &V) { + ID.AddPointer(T.getCanonicalType().getAsOpaquePtr()); + V.Profile(ID); + } + void Profile(llvm::FoldingSetNodeID &ID) { + Profile(ID, getType(), getValue()); + } + + TemplateParamObjectDecl *getCanonicalDecl() override { + return getFirstDecl(); + } + const TemplateParamObjectDecl *getCanonicalDecl() const { + return getFirstDecl(); + } + + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == TemplateParamObject; } +}; + inline NamedDecl *getAsNamedDecl(TemplateParameter P) { if (auto *PD = P.dyn_cast()) return PD; @@ -3286,6 +3353,36 @@ inline TemplateDecl *getAsTypeTemplateDecl(Decl *D) { : nullptr; } +/// Check whether the template parameter is a pack expansion, and if so, +/// determine the number of parameters produced by that expansion. For instance: +/// +/// \code +/// template struct A { +/// template class ...TTs, typename ...Us> struct B; +/// }; +/// \endcode +/// +/// In \c A::B, \c NTs and \c TTs have expanded pack size 2, and \c Us +/// is not a pack expansion, so returns an empty Optional. +inline Optional getExpandedPackSize(const NamedDecl *Param) { + if (const auto *TTP = dyn_cast(Param)) { + if (TTP->isExpandedParameterPack()) + return TTP->getNumExpansionParameters(); + } + + if (const auto *NTTP = dyn_cast(Param)) { + if (NTTP->isExpandedParameterPack()) + return NTTP->getNumExpansionTypes(); + } + + if (const auto *TTP = dyn_cast(Param)) { + if (TTP->isExpandedParameterPack()) + return TTP->getNumExpansionTemplateParameters(); + } + + return None; +} + } // namespace clang #endif // LLVM_CLANG_AST_DECLTEMPLATE_H diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclarationName.h b/contrib/llvm-project/clang/include/clang/AST/DeclarationName.h index 82f6868e3a7e1a..3cb0a02ff49b32 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclarationName.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclarationName.h @@ -811,19 +811,10 @@ struct DeclarationNameInfo { SourceLocation getEndLocPrivate() const; }; -/// Insertion operator for diagnostics. This allows sending DeclarationName's -/// into a diagnostic with <<. -inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - DeclarationName N) { - DB.AddTaggedVal(N.getAsOpaqueInteger(), - DiagnosticsEngine::ak_declarationname); - return DB; -} - /// Insertion operator for partial diagnostics. This allows binding /// DeclarationName's into a partial diagnostic with <<. -inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - DeclarationName N) { +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD, + DeclarationName N) { PD.AddTaggedVal(N.getAsOpaqueInteger(), DiagnosticsEngine::ak_declarationname); return PD; @@ -857,6 +848,16 @@ struct DenseMapInfo { } }; +template <> struct PointerLikeTypeTraits { + static inline void *getAsVoidPointer(clang::DeclarationName P) { + return P.getAsOpaquePtr(); + } + static inline clang::DeclarationName getFromVoidPointer(void *P) { + return clang::DeclarationName::getFromOpaquePtr(P); + } + static constexpr int NumLowBitsAvailable = 0; +}; + } // namespace llvm // The definition of AssumedTemplateStorage is factored out of TemplateName to diff --git a/contrib/llvm-project/clang/include/clang/AST/DependenceFlags.h b/contrib/llvm-project/clang/include/clang/AST/DependenceFlags.h index 14a7ffaecb2b04..ca96b65574bdd1 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DependenceFlags.h +++ b/contrib/llvm-project/clang/include/clang/AST/DependenceFlags.h @@ -41,6 +41,7 @@ struct ExprDependenceScope { TypeInstantiation = Type | Instantiation, ValueInstantiation = Value | Instantiation, TypeValueInstantiation = Type | Value | Instantiation, + ErrorDependent = Error | ValueInstantiation, LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Error) }; diff --git a/contrib/llvm-project/clang/include/clang/AST/DependentDiagnostic.h b/contrib/llvm-project/clang/include/clang/AST/DependentDiagnostic.h index 0a98dec0c25e88..18276d54d54047 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DependentDiagnostic.h +++ b/contrib/llvm-project/clang/include/clang/AST/DependentDiagnostic.h @@ -48,7 +48,7 @@ class DependentDiagnostic { QualType BaseObjectType, const PartialDiagnostic &PDiag) { DependentDiagnostic *DD = Create(Context, Parent, PDiag); - DD->AccessData.Loc = Loc.getRawEncoding(); + DD->AccessData.Loc = Loc; DD->AccessData.IsMember = IsMemberAccess; DD->AccessData.Access = AS; DD->AccessData.TargetDecl = TargetDecl; @@ -73,7 +73,7 @@ class DependentDiagnostic { SourceLocation getAccessLoc() const { assert(getKind() == Access); - return SourceLocation::getFromRawEncoding(AccessData.Loc); + return AccessData.Loc; } NamedDecl *getAccessTarget() const { @@ -100,8 +100,8 @@ class DependentDiagnostic { friend class DependentStoredDeclsMap; DependentDiagnostic(const PartialDiagnostic &PDiag, - PartialDiagnostic::Storage *Storage) - : Diag(PDiag, Storage) {} + DiagnosticStorage *Storage) + : Diag(PDiag, Storage) {} static DependentDiagnostic *Create(ASTContext &Context, DeclContext *Parent, @@ -112,7 +112,7 @@ class DependentDiagnostic { PartialDiagnostic Diag; struct { - unsigned Loc; + SourceLocation Loc; unsigned Access : 2; unsigned IsMember : 1; NamedDecl *TargetDecl; diff --git a/contrib/llvm-project/clang/include/clang/AST/Expr.h b/contrib/llvm-project/clang/include/clang/AST/Expr.h index c13b9711928505..52f8f18af205a8 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Expr.h +++ b/contrib/llvm-project/clang/include/clang/AST/Expr.h @@ -24,7 +24,6 @@ #include "clang/AST/TemplateBase.h" #include "clang/AST/Type.h" #include "clang/Basic/CharInfo.h" -#include "clang/Basic/FixedPoint.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/SyncScope.h" #include "clang/Basic/TypeTraits.h" @@ -414,6 +413,10 @@ class Expr : public ValueStmt { return ClassifyImpl(Ctx, &Loc); } + /// Returns the set of floating point options that apply to this expression. + /// Only meaningful for operations on floating point values. + FPOptions getFPFeaturesInEffect(const LangOptions &LO) const; + /// getValueKindForType - Given a formal return or parameter type, /// give its value kind. static ExprValueKind getValueKindForType(QualType T) { @@ -522,16 +525,15 @@ class Expr : public ValueStmt { /// semantically correspond to a bool. bool isKnownToHaveBooleanValue(bool Semantic = true) const; - /// isIntegerConstantExpr - Return true if this expression is a valid integer - /// constant expression, and, if so, return its value in Result. If not a - /// valid i-c-e, return false and fill in Loc (if specified) with the location - /// of the invalid expression. + /// isIntegerConstantExpr - Return the value if this expression is a valid + /// integer constant expression. If not a valid i-c-e, return None and fill + /// in Loc (if specified) with the location of the invalid expression. /// /// Note: This does not perform the implicit conversions required by C++11 /// [expr.const]p5. - bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, - SourceLocation *Loc = nullptr, - bool isEvaluated = true) const; + Optional getIntegerConstantExpr(const ASTContext &Ctx, + SourceLocation *Loc = nullptr, + bool isEvaluated = true) const; bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc = nullptr) const; @@ -708,13 +710,26 @@ class Expr : public ValueStmt { ArrayRef Args, const Expr *This = nullptr) const; - /// Indicates how the constant expression will be used. - enum ConstExprUsage { EvaluateForCodeGen, EvaluateForMangling }; + enum class ConstantExprKind { + /// An integer constant expression (an array bound, enumerator, case value, + /// bit-field width, or similar) or similar. + Normal, + /// A non-class template argument. Such a value is only used for mangling, + /// not for code generation, so can refer to dllimported functions. + NonClassTemplateArgument, + /// A class template argument. Such a value is used for code generation. + ClassTemplateArgument, + /// An immediate invocation. The destruction of the end result of this + /// evaluation is not part of the evaluation, but all other temporaries + /// are destroyed. + ImmediateInvocation, + }; - /// Evaluate an expression that is required to be a constant expression. - bool EvaluateAsConstantExpr(EvalResult &Result, ConstExprUsage Usage, - const ASTContext &Ctx, - bool InPlace = false) const; + /// Evaluate an expression that is required to be a constant expression. Does + /// not check the syntactic constraints for C and C++98 constant expressions. + bool EvaluateAsConstantExpr( + EvalResult &Result, const ASTContext &Ctx, + ConstantExprKind Kind = ConstantExprKind::Normal) const; /// If the current Expr is a pointer, this will try to statically /// determine the number of bytes available where the pointer is pointing. @@ -869,9 +884,9 @@ class Expr : public ValueStmt { /// Skip conversion operators. If this Expr is a call to a conversion /// operator, return the argument. - Expr *IgnoreConversionOperator() LLVM_READONLY; - const Expr *IgnoreConversionOperator() const { - return const_cast(this)->IgnoreConversionOperator(); + Expr *IgnoreConversionOperatorSingleStep() LLVM_READONLY; + const Expr *IgnoreConversionOperatorSingleStep() const { + return const_cast(this)->IgnoreConversionOperatorSingleStep(); } /// Skip past any parentheses and lvalue casts which might surround this @@ -903,9 +918,9 @@ class Expr : public ValueStmt { /// * What IgnoreParens() skips /// * CastExpr which represent a derived-to-base cast (CK_DerivedToBase, /// CK_UncheckedDerivedToBase and CK_NoOp) - Expr *ignoreParenBaseCasts() LLVM_READONLY; - const Expr *ignoreParenBaseCasts() const { - return const_cast(this)->ignoreParenBaseCasts(); + Expr *IgnoreParenBaseCasts() LLVM_READONLY; + const Expr *IgnoreParenBaseCasts() const { + return const_cast(this)->IgnoreParenBaseCasts(); } /// Determine whether this expression is a default function argument. @@ -962,6 +977,13 @@ class Expr : public ValueStmt { T->getStmtClass() <= lastExprConstant; } }; +// PointerLikeTypeTraits is specialized so it can be used with a forward-decl of +// Expr. Verify that we got it right. +static_assert(llvm::PointerLikeTypeTraits::NumLowBitsAvailable <= + llvm::detail::ConstantLog2::value, + "PointerLikeTypeTraits assumes too much alignment."); + +using ConstantExprKind = Expr::ConstantExprKind; //===----------------------------------------------------------------------===// // Wrapper Expressions. @@ -1261,7 +1283,7 @@ class DeclRefExpr final ValueDecl *getDecl() { return D; } const ValueDecl *getDecl() const { return D; } - void setDecl(ValueDecl *NewD) { D = NewD; } + void setDecl(ValueDecl *NewD); DeclarationNameInfo getNameInfo() const { return DeclarationNameInfo(getDecl()->getDeclName(), getLocation(), DNLoc); @@ -1923,17 +1945,13 @@ class StringLiteral final /// [C99 6.4.2.2] - A predefined identifier such as __func__. class PredefinedExpr final : public Expr, - private llvm::TrailingObjects { + private llvm::TrailingObjects { friend class ASTStmtReader; friend TrailingObjects; // PredefinedExpr is optionally followed by a single trailing // "Stmt *" for the predefined identifier. It is present if and only if // hasFunctionName() is true and is always a "StringLiteral *". - // It can also be followed by a Expr* in the case of a - // __builtin_unique_stable_name with an expression, or TypeSourceInfo * if - // __builtin_unique_stable_name with a type. public: enum IdentKind { @@ -1946,18 +1964,12 @@ class PredefinedExpr final PrettyFunction, /// The same as PrettyFunction, except that the /// 'virtual' keyword is omitted for virtual member functions. - PrettyFunctionNoVirtual, - UniqueStableNameType, - UniqueStableNameExpr, + PrettyFunctionNoVirtual }; private: PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK, StringLiteral *SL); - PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK, - TypeSourceInfo *Info); - PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK, - Expr *E); explicit PredefinedExpr(EmptyShell Empty, bool HasFunctionName); @@ -1970,39 +1982,10 @@ class PredefinedExpr final *getTrailingObjects() = SL; } - void setTypeSourceInfo(TypeSourceInfo *Info) { - assert(!hasFunctionName() && getIdentKind() == UniqueStableNameType && - "TypeSourceInfo only valid for UniqueStableName of a Type"); - *getTrailingObjects() = Info; - } - - void setExpr(Expr *E) { - assert(!hasFunctionName() && getIdentKind() == UniqueStableNameExpr && - "TypeSourceInfo only valid for UniqueStableName of n Expression."); - *getTrailingObjects() = E; - } - - size_t numTrailingObjects(OverloadToken) const { - return hasFunctionName(); - } - - size_t numTrailingObjects(OverloadToken) const { - return getIdentKind() == UniqueStableNameType && !hasFunctionName(); - } - size_t numTrailingObjects(OverloadToken) const { - return getIdentKind() == UniqueStableNameExpr && !hasFunctionName(); - } - public: /// Create a PredefinedExpr. static PredefinedExpr *Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, IdentKind IK, StringLiteral *SL); - static PredefinedExpr *Create(const ASTContext &Ctx, SourceLocation L, - QualType FNTy, IdentKind IK, StringLiteral *SL, - TypeSourceInfo *Info); - static PredefinedExpr *Create(const ASTContext &Ctx, SourceLocation L, - QualType FNTy, IdentKind IK, StringLiteral *SL, - Expr *E); /// Create an empty PredefinedExpr. static PredefinedExpr *CreateEmpty(const ASTContext &Ctx, @@ -2027,34 +2010,12 @@ class PredefinedExpr final : nullptr; } - TypeSourceInfo *getTypeSourceInfo() { - assert(!hasFunctionName() && getIdentKind() == UniqueStableNameType && - "TypeSourceInfo only valid for UniqueStableName of a Type"); - return *getTrailingObjects(); - } - - const TypeSourceInfo *getTypeSourceInfo() const { - assert(!hasFunctionName() && getIdentKind() == UniqueStableNameType && - "TypeSourceInfo only valid for UniqueStableName of a Type"); - return *getTrailingObjects(); - } - - Expr *getExpr() { - assert(!hasFunctionName() && getIdentKind() == UniqueStableNameExpr && - "TypeSourceInfo only valid for UniqueStableName of n Expression."); - return *getTrailingObjects(); - } - - const Expr *getExpr() const { - assert(!hasFunctionName() && getIdentKind() == UniqueStableNameExpr && - "TypeSourceInfo only valid for UniqueStableName of n Expression."); - return *getTrailingObjects(); + static StringRef getIdentKindName(IdentKind IK); + StringRef getIdentKindName() const { + return getIdentKindName(getIdentKind()); } - static StringRef getIdentKindName(IdentKind IK); static std::string ComputeName(IdentKind IK, const Decl *CurrentDecl); - static std::string ComputeName(ASTContext &Context, IdentKind IK, - const QualType Ty); SourceLocation getBeginLoc() const { return getLocation(); } SourceLocation getEndLoc() const { return getLocation(); } @@ -2273,12 +2234,12 @@ class UnaryOperator final /// Is FPFeatures in Trailing Storage? bool hasStoredFPFeatures() const { return UnaryOperatorBits.HasFPFeatures; } -protected: - /// Get FPFeatures from trailing storage + /// Get FPFeatures from trailing storage. FPOptionsOverride getStoredFPFeatures() const { return getTrailingFPFeatures(); } +protected: /// Set FPFeatures in trailing storage, used only by Serialization void setStoredFPFeatures(FPOptionsOverride F) { getTrailingFPFeatures() = F; } @@ -2788,6 +2749,8 @@ class CallExpr : public Expr { // // * An array of getNumArgs() "Stmt *" for the argument expressions. // + // * An optional of type FPOptionsOverride. + // // Note that we store the offset in bytes from the this pointer to the start // of the trailing objects. It would be perfectly possible to compute it // based on the dynamic kind of the CallExpr. However 1.) we have plenty of @@ -2809,6 +2772,15 @@ class CallExpr : public Expr { /// this pointer to the trailing objects. static unsigned offsetToTrailingObjects(StmtClass SC); + unsigned getSizeOfTrailingStmts() const { + return (1 + getNumPreArgs() + getNumArgs()) * sizeof(Stmt *); + } + + size_t getOffsetOfTrailingFPFeatures() const { + assert(hasStoredFPFeatures()); + return CallExprBits.OffsetToTrailingObjects + getSizeOfTrailingStmts(); + } + public: enum class ADLCallKind : bool { NotADL, UsesADL }; static constexpr ADLCallKind NotADL = ADLCallKind::NotADL; @@ -2819,16 +2791,19 @@ class CallExpr : public Expr { /// allocated for the trailing objects. CallExpr(StmtClass SC, Expr *Fn, ArrayRef PreArgs, ArrayRef Args, QualType Ty, ExprValueKind VK, - SourceLocation RParenLoc, unsigned MinNumArgs, ADLCallKind UsesADL); + SourceLocation RParenLoc, FPOptionsOverride FPFeatures, + unsigned MinNumArgs, ADLCallKind UsesADL); /// Build an empty call expression, for deserialization. CallExpr(StmtClass SC, unsigned NumPreArgs, unsigned NumArgs, - EmptyShell Empty); + bool hasFPFeatures, EmptyShell Empty); /// Return the size in bytes needed for the trailing objects. /// Used by the derived classes to allocate the right amount of storage. - static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs) { - return (1 + NumPreArgs + NumArgs) * sizeof(Stmt *); + static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs, + bool HasFPFeatures) { + return (1 + NumPreArgs + NumArgs) * sizeof(Stmt *) + + HasFPFeatures * sizeof(FPOptionsOverride); } Stmt *getPreArg(unsigned I) { @@ -2846,22 +2821,43 @@ class CallExpr : public Expr { unsigned getNumPreArgs() const { return CallExprBits.NumPreArgs; } + /// Return a pointer to the trailing FPOptions + FPOptionsOverride *getTrailingFPFeatures() { + assert(hasStoredFPFeatures()); + return reinterpret_cast( + reinterpret_cast(this) + CallExprBits.OffsetToTrailingObjects + + getSizeOfTrailingStmts()); + } + const FPOptionsOverride *getTrailingFPFeatures() const { + assert(hasStoredFPFeatures()); + return reinterpret_cast( + reinterpret_cast(this) + + CallExprBits.OffsetToTrailingObjects + getSizeOfTrailingStmts()); + } + public: - /// Create a call expression. Fn is the callee expression, Args is the - /// argument array, Ty is the type of the call expression (which is *not* - /// the return type in general), VK is the value kind of the call expression - /// (lvalue, rvalue, ...), and RParenLoc is the location of the right - /// parenthese in the call expression. MinNumArgs specifies the minimum - /// number of arguments. The actual number of arguments will be the greater - /// of Args.size() and MinNumArgs. This is used in a few places to allocate - /// enough storage for the default arguments. UsesADL specifies whether the - /// callee was found through argument-dependent lookup. + /// Create a call expression. + /// \param Fn The callee expression, + /// \param Args The argument array, + /// \param Ty The type of the call expression (which is *not* the return + /// type in general), + /// \param VK The value kind of the call expression (lvalue, rvalue, ...), + /// \param RParenLoc The location of the right parenthesis in the call + /// expression. + /// \param FPFeatures Floating-point features associated with the call, + /// \param MinNumArgs Specifies the minimum number of arguments. The actual + /// number of arguments will be the greater of Args.size() + /// and MinNumArgs. This is used in a few places to allocate + /// enough storage for the default arguments. + /// \param UsesADL Specifies whether the callee was found through + /// argument-dependent lookup. /// /// Note that you can use CreateTemporary if you need a temporary call /// expression on the stack. static CallExpr *Create(const ASTContext &Ctx, Expr *Fn, ArrayRef Args, QualType Ty, ExprValueKind VK, - SourceLocation RParenLoc, unsigned MinNumArgs = 0, + SourceLocation RParenLoc, + FPOptionsOverride FPFeatures, unsigned MinNumArgs = 0, ADLCallKind UsesADL = NotADL); /// Create a temporary call expression with no arguments in the memory @@ -2878,7 +2874,7 @@ class CallExpr : public Expr { /// Create an empty call expression, for deserialization. static CallExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, - EmptyShell Empty); + bool HasFPFeatures, EmptyShell Empty); Expr *getCallee() { return cast(getTrailingStmts()[FN]); } const Expr *getCallee() const { return cast(getTrailingStmts()[FN]); } @@ -2892,6 +2888,8 @@ class CallExpr : public Expr { } bool usesADL() const { return getADLCallKind() == UsesADL; } + bool hasStoredFPFeatures() const { return CallExprBits.HasFPFeatures; } + Decl *getCalleeDecl() { return getCallee()->getReferencedDeclOfCallee(); } const Decl *getCalleeDecl() const { return getCallee()->getReferencedDeclOfCallee(); @@ -2984,6 +2982,31 @@ class CallExpr : public Expr { /// this function call. unsigned getNumCommas() const { return getNumArgs() ? getNumArgs() - 1 : 0; } + /// Get FPOptionsOverride from trailing storage. + FPOptionsOverride getStoredFPFeatures() const { + assert(hasStoredFPFeatures()); + return *getTrailingFPFeatures(); + } + /// Set FPOptionsOverride in trailing storage. Used only by Serialization. + void setStoredFPFeatures(FPOptionsOverride F) { + assert(hasStoredFPFeatures()); + *getTrailingFPFeatures() = F; + } + + // Get the FP features status of this operator. Only meaningful for + // operations on floating point types. + FPOptions getFPFeaturesInEffect(const LangOptions &LO) const { + if (hasStoredFPFeatures()) + return getStoredFPFeatures().applyOverrides(LO); + return FPOptions::defaultWithoutTrailingStorage(LO); + } + + FPOptionsOverride getFPFeatures() const { + if (hasStoredFPFeatures()) + return getStoredFPFeatures(); + return FPOptionsOverride(); + } + /// getBuiltinCallee - If this is a call to a builtin, return the builtin ID /// of the callee. If not, return 0. unsigned getBuiltinCallee() const; @@ -3143,7 +3166,7 @@ class MemberExpr final /// The returned declaration will be a FieldDecl or (in C++) a VarDecl (for /// static data members), a CXXMethodDecl, or an EnumConstantDecl. ValueDecl *getMemberDecl() const { return MemberDecl; } - void setMemberDecl(ValueDecl *D) { MemberDecl = D; } + void setMemberDecl(ValueDecl *D); /// Retrieves the declaration found by lookup. DeclAccessPair getFoundDecl() const { @@ -3380,9 +3403,11 @@ class CastExpr : public Expr { } CXXBaseSpecifier **path_buffer(); + friend class ASTStmtReader; + protected: CastExpr(StmtClass SC, QualType ty, ExprValueKind VK, const CastKind kind, - Expr *op, unsigned BasePathSize) + Expr *op, unsigned BasePathSize, bool HasFPFeatures) : Expr(SC, ty, VK, OK_Ordinary), Op(op) { CastExprBits.Kind = kind; CastExprBits.PartOfExplicitCast = false; @@ -3391,17 +3416,27 @@ class CastExpr : public Expr { "BasePathSize overflow!"); setDependence(computeDependence(this)); assert(CastConsistency()); + CastExprBits.HasFPFeatures = HasFPFeatures; } /// Construct an empty cast. - CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize) - : Expr(SC, Empty) { + CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize, + bool HasFPFeatures) + : Expr(SC, Empty) { CastExprBits.PartOfExplicitCast = false; CastExprBits.BasePathSize = BasePathSize; + CastExprBits.HasFPFeatures = HasFPFeatures; assert((CastExprBits.BasePathSize == BasePathSize) && "BasePathSize overflow!"); } + /// Return a pointer to the trailing FPOptions. + /// \pre hasStoredFPFeatures() == true + FPOptionsOverride *getTrailingFPFeatures(); + const FPOptionsOverride *getTrailingFPFeatures() const { + return const_cast(this)->getTrailingFPFeatures(); + } + public: CastKind getCastKind() const { return (CastKind) CastExprBits.Kind; } void setCastKind(CastKind K) { CastExprBits.Kind = K; } @@ -3446,6 +3481,28 @@ class CastExpr : public Expr { return getTargetFieldForToUnionCast(getType(), getSubExpr()->getType()); } + bool hasStoredFPFeatures() const { return CastExprBits.HasFPFeatures; } + + /// Get FPOptionsOverride from trailing storage. + FPOptionsOverride getStoredFPFeatures() const { + assert(hasStoredFPFeatures()); + return *getTrailingFPFeatures(); + } + + // Get the FP features status of this operation. Only meaningful for + // operations on floating point types. + FPOptions getFPFeaturesInEffect(const LangOptions &LO) const { + if (hasStoredFPFeatures()) + return getStoredFPFeatures().applyOverrides(LO); + return FPOptions::defaultWithoutTrailingStorage(LO); + } + + FPOptionsOverride getFPFeatures() const { + if (hasStoredFPFeatures()) + return getStoredFPFeatures(); + return FPOptionsOverride(); + } + static const FieldDecl *getTargetFieldForToUnionCast(QualType unionType, QualType opType); static const FieldDecl *getTargetFieldForToUnionCast(const RecordDecl *RD, @@ -3483,21 +3540,35 @@ class CastExpr : public Expr { /// @endcode class ImplicitCastExpr final : public CastExpr, - private llvm::TrailingObjects { + private llvm::TrailingObjects { ImplicitCastExpr(QualType ty, CastKind kind, Expr *op, - unsigned BasePathLength, ExprValueKind VK) - : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) { } + unsigned BasePathLength, FPOptionsOverride FPO, + ExprValueKind VK) + : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength, + FPO.requiresTrailingStorage()) { + if (hasStoredFPFeatures()) + *getTrailingFPFeatures() = FPO; + } /// Construct an empty implicit cast. - explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize) - : CastExpr(ImplicitCastExprClass, Shell, PathSize) { } + explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : CastExpr(ImplicitCastExprClass, Shell, PathSize, HasFPFeatures) {} + + unsigned numTrailingObjects(OverloadToken) const { + return path_size(); + } public: enum OnStack_t { OnStack }; ImplicitCastExpr(OnStack_t _, QualType ty, CastKind kind, Expr *op, - ExprValueKind VK) - : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0) { + ExprValueKind VK, FPOptionsOverride FPO) + : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0, + FPO.requiresTrailingStorage()) { + if (hasStoredFPFeatures()) + *getTrailingFPFeatures() = FPO; } bool isPartOfExplicitCast() const { return CastExprBits.PartOfExplicitCast; } @@ -3508,10 +3579,10 @@ class ImplicitCastExpr final static ImplicitCastExpr *Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, - ExprValueKind Cat); + ExprValueKind Cat, FPOptionsOverride FPO); static ImplicitCastExpr *CreateEmpty(const ASTContext &Context, - unsigned PathSize); + unsigned PathSize, bool HasFPFeatures); SourceLocation getBeginLoc() const LLVM_READONLY { return getSubExpr()->getBeginLoc(); @@ -3552,12 +3623,14 @@ class ExplicitCastExpr : public CastExpr { protected: ExplicitCastExpr(StmtClass SC, QualType exprTy, ExprValueKind VK, CastKind kind, Expr *op, unsigned PathSize, - TypeSourceInfo *writtenTy) - : CastExpr(SC, exprTy, VK, kind, op, PathSize), TInfo(writtenTy) {} + bool HasFPFeatures, TypeSourceInfo *writtenTy) + : CastExpr(SC, exprTy, VK, kind, op, PathSize, HasFPFeatures), + TInfo(writtenTy) {} /// Construct an empty explicit cast. - ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize) - : CastExpr(SC, Shell, PathSize) { } + ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : CastExpr(SC, Shell, PathSize, HasFPFeatures) {} public: /// getTypeInfoAsWritten - Returns the type source info for the type @@ -3580,29 +3653,38 @@ class ExplicitCastExpr : public CastExpr { /// (Type)expr. For example: @c (int)f. class CStyleCastExpr final : public ExplicitCastExpr, - private llvm::TrailingObjects { + private llvm::TrailingObjects { SourceLocation LPLoc; // the location of the left paren SourceLocation RPLoc; // the location of the right paren CStyleCastExpr(QualType exprTy, ExprValueKind vk, CastKind kind, Expr *op, - unsigned PathSize, TypeSourceInfo *writtenTy, - SourceLocation l, SourceLocation r) - : ExplicitCastExpr(CStyleCastExprClass, exprTy, vk, kind, op, PathSize, - writtenTy), LPLoc(l), RPLoc(r) {} + unsigned PathSize, FPOptionsOverride FPO, + TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation r) + : ExplicitCastExpr(CStyleCastExprClass, exprTy, vk, kind, op, PathSize, + FPO.requiresTrailingStorage(), writtenTy), + LPLoc(l), RPLoc(r) { + if (hasStoredFPFeatures()) + *getTrailingFPFeatures() = FPO; + } /// Construct an empty C-style explicit cast. - explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize) - : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize) { } + explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize, HasFPFeatures) {} + + unsigned numTrailingObjects(OverloadToken) const { + return path_size(); + } public: - static CStyleCastExpr *Create(const ASTContext &Context, QualType T, - ExprValueKind VK, CastKind K, - Expr *Op, const CXXCastPath *BasePath, - TypeSourceInfo *WrittenTy, SourceLocation L, - SourceLocation R); + static CStyleCastExpr * + Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, + Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, + TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R); static CStyleCastExpr *CreateEmpty(const ASTContext &Context, - unsigned PathSize); + unsigned PathSize, bool HasFPFeatures); SourceLocation getLParenLoc() const { return LPLoc; } void setLParenLoc(SourceLocation L) { LPLoc = L; } @@ -4690,6 +4772,13 @@ class InitListExpr : public Expr { setDependence(getDependence() | expr->getDependence()); } + /// Mark the semantic form of the InitListExpr as error when the semantic + /// analysis fails. + void markError() { + assert(isSemanticForm()); + setDependence(getDependence() | ExprDependence::ErrorDependent); + } + /// Reserve space for some number of initializers. void reserveInits(const ASTContext &C, unsigned NumInits); @@ -4904,10 +4993,10 @@ class DesignatedInitExpr final uintptr_t NameOrField; /// The location of the '.' in the designated initializer. - unsigned DotLoc; + SourceLocation DotLoc; /// The location of the field name in the designated initializer. - unsigned FieldLoc; + SourceLocation FieldLoc; }; /// An array or GNU array-range designator, e.g., "[9]" or "[10..15]". @@ -4916,12 +5005,12 @@ class DesignatedInitExpr final /// initializer expression's list of subexpressions. unsigned Index; /// The location of the '[' starting the array range designator. - unsigned LBracketLoc; + SourceLocation LBracketLoc; /// The location of the ellipsis separating the start and end /// indices. Only valid for GNU array-range designators. - unsigned EllipsisLoc; + SourceLocation EllipsisLoc; /// The location of the ']' terminating the array range designator. - unsigned RBracketLoc; + SourceLocation RBracketLoc; }; /// Represents a single C99 designator. @@ -4953,29 +5042,32 @@ class DesignatedInitExpr final Designator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc) : Kind(FieldDesignator) { + new (&Field) DesignatedInitExpr::FieldDesignator; Field.NameOrField = reinterpret_cast(FieldName) | 0x01; - Field.DotLoc = DotLoc.getRawEncoding(); - Field.FieldLoc = FieldLoc.getRawEncoding(); + Field.DotLoc = DotLoc; + Field.FieldLoc = FieldLoc; } /// Initializes an array designator. Designator(unsigned Index, SourceLocation LBracketLoc, SourceLocation RBracketLoc) : Kind(ArrayDesignator) { + new (&ArrayOrRange) DesignatedInitExpr::ArrayOrRangeDesignator; ArrayOrRange.Index = Index; - ArrayOrRange.LBracketLoc = LBracketLoc.getRawEncoding(); - ArrayOrRange.EllipsisLoc = SourceLocation().getRawEncoding(); - ArrayOrRange.RBracketLoc = RBracketLoc.getRawEncoding(); + ArrayOrRange.LBracketLoc = LBracketLoc; + ArrayOrRange.EllipsisLoc = SourceLocation(); + ArrayOrRange.RBracketLoc = RBracketLoc; } /// Initializes a GNU array-range designator. Designator(unsigned Index, SourceLocation LBracketLoc, SourceLocation EllipsisLoc, SourceLocation RBracketLoc) : Kind(ArrayRangeDesignator) { + new (&ArrayOrRange) DesignatedInitExpr::ArrayOrRangeDesignator; ArrayOrRange.Index = Index; - ArrayOrRange.LBracketLoc = LBracketLoc.getRawEncoding(); - ArrayOrRange.EllipsisLoc = EllipsisLoc.getRawEncoding(); - ArrayOrRange.RBracketLoc = RBracketLoc.getRawEncoding(); + ArrayOrRange.LBracketLoc = LBracketLoc; + ArrayOrRange.EllipsisLoc = EllipsisLoc; + ArrayOrRange.RBracketLoc = RBracketLoc; } bool isFieldDesignator() const { return Kind == FieldDesignator; } @@ -4999,30 +5091,30 @@ class DesignatedInitExpr final SourceLocation getDotLoc() const { assert(Kind == FieldDesignator && "Only valid on a field designator"); - return SourceLocation::getFromRawEncoding(Field.DotLoc); + return Field.DotLoc; } SourceLocation getFieldLoc() const { assert(Kind == FieldDesignator && "Only valid on a field designator"); - return SourceLocation::getFromRawEncoding(Field.FieldLoc); + return Field.FieldLoc; } SourceLocation getLBracketLoc() const { assert((Kind == ArrayDesignator || Kind == ArrayRangeDesignator) && "Only valid on an array or array-range designator"); - return SourceLocation::getFromRawEncoding(ArrayOrRange.LBracketLoc); + return ArrayOrRange.LBracketLoc; } SourceLocation getRBracketLoc() const { assert((Kind == ArrayDesignator || Kind == ArrayRangeDesignator) && "Only valid on an array or array-range designator"); - return SourceLocation::getFromRawEncoding(ArrayOrRange.RBracketLoc); + return ArrayOrRange.RBracketLoc; } SourceLocation getEllipsisLoc() const { assert(Kind == ArrayRangeDesignator && "Only valid on an array-range designator"); - return SourceLocation::getFromRawEncoding(ArrayOrRange.EllipsisLoc); + return ArrayOrRange.EllipsisLoc; } unsigned getFirstExprIndex() const { @@ -6240,9 +6332,6 @@ class TypoExpr : public Expr { /// /// One can also reliably suppress all bogus errors on expressions containing /// recovery expressions by examining results of Expr::containsErrors(). -/// -/// FIXME: RecoveryExpr is currently generated by default in C++ mode only, as -/// dependence isn't handled properly on several C-only codepaths. class RecoveryExpr final : public Expr, private llvm::TrailingObjects { public: diff --git a/contrib/llvm-project/clang/include/clang/AST/ExprCXX.h b/contrib/llvm-project/clang/include/clang/AST/ExprCXX.h index 6f0b68479b9d7f..fbeeb4004f7d0c 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ExprCXX.h +++ b/contrib/llvm-project/clang/include/clang/AST/ExprCXX.h @@ -84,7 +84,6 @@ class CXXOperatorCallExpr final : public CallExpr { friend class ASTStmtWriter; SourceRange Range; - FPOptionsOverride Overrides; // CXXOperatorCallExpr has some trailing objects belonging // to CallExpr. See CallExpr for the details. @@ -96,7 +95,7 @@ class CXXOperatorCallExpr final : public CallExpr { SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL); - CXXOperatorCallExpr(unsigned NumArgs, EmptyShell Empty); + CXXOperatorCallExpr(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty); public: static CXXOperatorCallExpr * @@ -106,7 +105,8 @@ class CXXOperatorCallExpr final : public CallExpr { ADLCallKind UsesADL = NotADL); static CXXOperatorCallExpr *CreateEmpty(const ASTContext &Ctx, - unsigned NumArgs, EmptyShell Empty); + unsigned NumArgs, bool HasFPFeatures, + EmptyShell Empty); /// Returns the kind of overloaded operator that this expression refers to. OverloadedOperatorKind getOperator() const { @@ -164,11 +164,6 @@ class CXXOperatorCallExpr final : public CallExpr { static bool classof(const Stmt *T) { return T->getStmtClass() == CXXOperatorCallExprClass; } - - // Set the FPFeatures status of this operator. Only meaningful for - // operations on floating point types. - void setFPFeatures(FPOptionsOverride F) { Overrides = F; } - FPOptionsOverride getFPFeatures() const { return Overrides; } }; /// Represents a call to a member function that @@ -184,18 +179,20 @@ class CXXMemberCallExpr final : public CallExpr { // to CallExpr. See CallExpr for the details. CXXMemberCallExpr(Expr *Fn, ArrayRef Args, QualType Ty, - ExprValueKind VK, SourceLocation RP, unsigned MinNumArgs); + ExprValueKind VK, SourceLocation RP, + FPOptionsOverride FPOptions, unsigned MinNumArgs); - CXXMemberCallExpr(unsigned NumArgs, EmptyShell Empty); + CXXMemberCallExpr(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty); public: static CXXMemberCallExpr *Create(const ASTContext &Ctx, Expr *Fn, ArrayRef Args, QualType Ty, ExprValueKind VK, SourceLocation RP, + FPOptionsOverride FPFeatures, unsigned MinNumArgs = 0); static CXXMemberCallExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, - EmptyShell Empty); + bool HasFPFeatures, EmptyShell Empty); /// Retrieve the implicit object argument for the member call. /// @@ -242,18 +239,21 @@ class CUDAKernelCallExpr final : public CallExpr { CUDAKernelCallExpr(Expr *Fn, CallExpr *Config, ArrayRef Args, QualType Ty, ExprValueKind VK, SourceLocation RP, - unsigned MinNumArgs); + FPOptionsOverride FPFeatures, unsigned MinNumArgs); - CUDAKernelCallExpr(unsigned NumArgs, EmptyShell Empty); + CUDAKernelCallExpr(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty); public: static CUDAKernelCallExpr *Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef Args, QualType Ty, ExprValueKind VK, - SourceLocation RP, unsigned MinNumArgs = 0); + SourceLocation RP, + FPOptionsOverride FPFeatures, + unsigned MinNumArgs = 0); static CUDAKernelCallExpr *CreateEmpty(const ASTContext &Ctx, - unsigned NumArgs, EmptyShell Empty); + unsigned NumArgs, bool HasFPFeatures, + EmptyShell Empty); const CallExpr *getConfig() const { return cast_or_null(getPreArg(CONFIG)); @@ -320,6 +320,16 @@ class CXXRewrittenBinaryOperator : public Expr { bool isReversed() const { return CXXRewrittenBinaryOperatorBits.IsReversed; } BinaryOperatorKind getOperator() const { return getDecomposedForm().Opcode; } + BinaryOperatorKind getOpcode() const { return getOperator(); } + static StringRef getOpcodeStr(BinaryOperatorKind Op) { + return BinaryOperator::getOpcodeStr(Op); + } + StringRef getOpcodeStr() const { + return BinaryOperator::getOpcodeStr(getOpcode()); + } + bool isComparisonOp() const { return true; } + bool isAssignmentOp() const { return false; } + const Expr *getLHS() const { return getDecomposedForm().LHS; } const Expr *getRHS() const { return getDecomposedForm().RHS; } @@ -374,16 +384,17 @@ class CXXNamedCastExpr : public ExplicitCastExpr { protected: friend class ASTStmtReader; - CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK, - CastKind kind, Expr *op, unsigned PathSize, + CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK, CastKind kind, + Expr *op, unsigned PathSize, bool HasFPFeatures, TypeSourceInfo *writtenTy, SourceLocation l, - SourceLocation RParenLoc, - SourceRange AngleBrackets) - : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l), - RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {} + SourceLocation RParenLoc, SourceRange AngleBrackets) + : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, HasFPFeatures, + writtenTy), + Loc(l), RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {} - explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize) - : ExplicitCastExpr(SC, Shell, PathSize) {} + explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : ExplicitCastExpr(SC, Shell, PathSize, HasFPFeatures) {} public: const char *getCastName() const; @@ -419,29 +430,39 @@ class CXXNamedCastExpr : public ExplicitCastExpr { /// \c static_cast(1.0). class CXXStaticCastExpr final : public CXXNamedCastExpr, - private llvm::TrailingObjects { + private llvm::TrailingObjects { CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, - SourceLocation l, SourceLocation RParenLoc, - SourceRange AngleBrackets) + FPOptionsOverride FPO, SourceLocation l, + SourceLocation RParenLoc, SourceRange AngleBrackets) : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize, - writtenTy, l, RParenLoc, AngleBrackets) {} + FPO.requiresTrailingStorage(), writtenTy, l, RParenLoc, + AngleBrackets) { + if (hasStoredFPFeatures()) + *getTrailingFPFeatures() = FPO; + } + + explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize, + bool HasFPFeatures) + : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize, + HasFPFeatures) {} - explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize) - : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) {} + unsigned numTrailingObjects(OverloadToken) const { + return path_size(); + } public: friend class CastExpr; friend TrailingObjects; - static CXXStaticCastExpr *Create(const ASTContext &Context, QualType T, - ExprValueKind VK, CastKind K, Expr *Op, - const CXXCastPath *Path, - TypeSourceInfo *Written, SourceLocation L, - SourceLocation RParenLoc, - SourceRange AngleBrackets); + static CXXStaticCastExpr * + Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, + Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, + FPOptionsOverride FPO, SourceLocation L, SourceLocation RParenLoc, + SourceRange AngleBrackets); static CXXStaticCastExpr *CreateEmpty(const ASTContext &Context, - unsigned PathSize); + unsigned PathSize, bool hasFPFeatures); static bool classof(const Stmt *T) { return T->getStmtClass() == CXXStaticCastExprClass; @@ -456,15 +477,17 @@ class CXXStaticCastExpr final class CXXDynamicCastExpr final : public CXXNamedCastExpr, private llvm::TrailingObjects { - CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, - Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, + CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, Expr *op, + unsigned pathSize, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize, - writtenTy, l, RParenLoc, AngleBrackets) {} + /*HasFPFeatures*/ false, writtenTy, l, RParenLoc, + AngleBrackets) {} explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize) - : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) {} + : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize, + /*HasFPFeatures*/ false) {} public: friend class CastExpr; @@ -499,16 +522,17 @@ class CXXReinterpretCastExpr final : public CXXNamedCastExpr, private llvm::TrailingObjects { - CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, - Expr *op, unsigned pathSize, - TypeSourceInfo *writtenTy, SourceLocation l, - SourceLocation RParenLoc, + CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, + unsigned pathSize, TypeSourceInfo *writtenTy, + SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op, - pathSize, writtenTy, l, RParenLoc, AngleBrackets) {} + pathSize, /*HasFPFeatures*/ false, writtenTy, l, + RParenLoc, AngleBrackets) {} CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize) - : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) {} + : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize, + /*HasFPFeatures*/ false) {} public: friend class CastExpr; @@ -541,11 +565,13 @@ class CXXConstCastExpr final CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) - : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, - 0, writtenTy, l, RParenLoc, AngleBrackets) {} + : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, 0, + /*HasFPFeatures*/ false, writtenTy, l, RParenLoc, + AngleBrackets) {} explicit CXXConstCastExpr(EmptyShell Empty) - : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) {} + : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0, + /*HasFPFeatures*/ false) {} public: friend class CastExpr; @@ -578,10 +604,12 @@ class CXXAddrspaceCastExpr final TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) : CXXNamedCastExpr(CXXAddrspaceCastExprClass, ty, VK, Kind, op, 0, - writtenTy, l, RParenLoc, AngleBrackets) {} + /*HasFPFeatures*/ false, writtenTy, l, RParenLoc, + AngleBrackets) {} explicit CXXAddrspaceCastExpr(EmptyShell Empty) - : CXXNamedCastExpr(CXXAddrspaceCastExprClass, Empty, 0) {} + : CXXNamedCastExpr(CXXAddrspaceCastExprClass, Empty, 0, + /*HasFPFeatures*/ false) {} public: friend class CastExpr; @@ -619,18 +647,20 @@ class UserDefinedLiteral final : public CallExpr { UserDefinedLiteral(Expr *Fn, ArrayRef Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, - SourceLocation SuffixLoc); + SourceLocation SuffixLoc, FPOptionsOverride FPFeatures); - UserDefinedLiteral(unsigned NumArgs, EmptyShell Empty); + UserDefinedLiteral(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty); public: static UserDefinedLiteral *Create(const ASTContext &Ctx, Expr *Fn, ArrayRef Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, - SourceLocation SuffixLoc); + SourceLocation SuffixLoc, + FPOptionsOverride FPFeatures); static UserDefinedLiteral *CreateEmpty(const ASTContext &Ctx, - unsigned NumArgs, EmptyShell Empty); + unsigned NumArgs, bool HasFPOptions, + EmptyShell Empty); /// The kind of literal operator which is invoked. enum LiteralOperatorKind { @@ -838,6 +868,10 @@ class CXXTypeidExpr : public Expr { /// evaluated, per C++11 [expr.typeid]p3. bool isPotentiallyEvaluated() const; + /// Best-effort check if the expression operand refers to a most derived + /// object. This is not a strong guarantee. + bool isMostDerived(ASTContext &Context) const; + bool isTypeOperand() const { return Operand.is(); } /// Retrieves the type operand of this typeid() expression after @@ -1691,34 +1725,43 @@ class CXXInheritedCtorInitExpr : public Expr { /// \endcode class CXXFunctionalCastExpr final : public ExplicitCastExpr, - private llvm::TrailingObjects { + private llvm::TrailingObjects { SourceLocation LParenLoc; SourceLocation RParenLoc; CXXFunctionalCastExpr(QualType ty, ExprValueKind VK, - TypeSourceInfo *writtenTy, - CastKind kind, Expr *castExpr, unsigned pathSize, - SourceLocation lParenLoc, SourceLocation rParenLoc) - : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, - castExpr, pathSize, writtenTy), - LParenLoc(lParenLoc), RParenLoc(rParenLoc) {} + TypeSourceInfo *writtenTy, CastKind kind, + Expr *castExpr, unsigned pathSize, + FPOptionsOverride FPO, SourceLocation lParenLoc, + SourceLocation rParenLoc) + : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, castExpr, + pathSize, FPO.requiresTrailingStorage(), writtenTy), + LParenLoc(lParenLoc), RParenLoc(rParenLoc) { + if (hasStoredFPFeatures()) + *getTrailingFPFeatures() = FPO; + } - explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize) - : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) {} + explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize, + bool HasFPFeatures) + : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize, + HasFPFeatures) {} + + unsigned numTrailingObjects(OverloadToken) const { + return path_size(); + } public: friend class CastExpr; friend TrailingObjects; - static CXXFunctionalCastExpr *Create(const ASTContext &Context, QualType T, - ExprValueKind VK, - TypeSourceInfo *Written, - CastKind Kind, Expr *Op, - const CXXCastPath *Path, - SourceLocation LPLoc, - SourceLocation RPLoc); - static CXXFunctionalCastExpr *CreateEmpty(const ASTContext &Context, - unsigned PathSize); + static CXXFunctionalCastExpr * + Create(const ASTContext &Context, QualType T, ExprValueKind VK, + TypeSourceInfo *Written, CastKind Kind, Expr *Op, + const CXXCastPath *Path, FPOptionsOverride FPO, SourceLocation LPLoc, + SourceLocation RPLoc); + static CXXFunctionalCastExpr * + CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures); SourceLocation getLParenLoc() const { return LParenLoc; } void setLParenLoc(SourceLocation L) { LParenLoc = L; } @@ -1996,6 +2039,9 @@ class LambdaExpr final : public Expr, /// invented by use of an auto parameter). ArrayRef getExplicitTemplateParameters() const; + /// Get the trailing requires clause, if any. + Expr *getTrailingRequiresClause() const; + /// Whether this is a generic lambda. bool isGenericLambda() const { return getTemplateParameterList(); } @@ -3394,17 +3440,18 @@ class CXXUnresolvedConstructExpr final /// The location of the right parentheses (')'). SourceLocation RParenLoc; - CXXUnresolvedConstructExpr(TypeSourceInfo *TSI, SourceLocation LParenLoc, - ArrayRef Args, SourceLocation RParenLoc); + CXXUnresolvedConstructExpr(QualType T, TypeSourceInfo *TSI, + SourceLocation LParenLoc, ArrayRef Args, + SourceLocation RParenLoc); CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs) - : Expr(CXXUnresolvedConstructExprClass, Empty) { + : Expr(CXXUnresolvedConstructExprClass, Empty), TSI(nullptr) { CXXUnresolvedConstructExprBits.NumArgs = NumArgs; } public: static CXXUnresolvedConstructExpr *Create(const ASTContext &Context, - TypeSourceInfo *Type, + QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef Args, SourceLocation RParenLoc); @@ -3436,43 +3483,43 @@ class CXXUnresolvedConstructExpr final bool isListInitialization() const { return LParenLoc.isInvalid(); } /// Retrieve the number of arguments. - unsigned arg_size() const { return CXXUnresolvedConstructExprBits.NumArgs; } + unsigned getNumArgs() const { return CXXUnresolvedConstructExprBits.NumArgs; } using arg_iterator = Expr **; using arg_range = llvm::iterator_range; arg_iterator arg_begin() { return getTrailingObjects(); } - arg_iterator arg_end() { return arg_begin() + arg_size(); } + arg_iterator arg_end() { return arg_begin() + getNumArgs(); } arg_range arguments() { return arg_range(arg_begin(), arg_end()); } using const_arg_iterator = const Expr* const *; using const_arg_range = llvm::iterator_range; const_arg_iterator arg_begin() const { return getTrailingObjects(); } - const_arg_iterator arg_end() const { return arg_begin() + arg_size(); } + const_arg_iterator arg_end() const { return arg_begin() + getNumArgs(); } const_arg_range arguments() const { return const_arg_range(arg_begin(), arg_end()); } Expr *getArg(unsigned I) { - assert(I < arg_size() && "Argument index out-of-range"); + assert(I < getNumArgs() && "Argument index out-of-range"); return arg_begin()[I]; } const Expr *getArg(unsigned I) const { - assert(I < arg_size() && "Argument index out-of-range"); + assert(I < getNumArgs() && "Argument index out-of-range"); return arg_begin()[I]; } void setArg(unsigned I, Expr *E) { - assert(I < arg_size() && "Argument index out-of-range"); + assert(I < getNumArgs() && "Argument index out-of-range"); arg_begin()[I] = E; } SourceLocation getBeginLoc() const LLVM_READONLY; SourceLocation getEndLoc() const LLVM_READONLY { - if (!RParenLoc.isValid() && arg_size() > 0) - return getArg(arg_size() - 1)->getEndLoc(); + if (!RParenLoc.isValid() && getNumArgs() > 0) + return getArg(getNumArgs() - 1)->getEndLoc(); return RParenLoc; } @@ -3483,13 +3530,13 @@ class CXXUnresolvedConstructExpr final // Iterators child_range children() { auto **begin = reinterpret_cast(arg_begin()); - return child_range(begin, begin + arg_size()); + return child_range(begin, begin + getNumArgs()); } const_child_range children() const { auto **begin = reinterpret_cast( const_cast(this)->arg_begin()); - return const_child_range(begin, begin + arg_size()); + return const_child_range(begin, begin + getNumArgs()); } }; @@ -4199,8 +4246,10 @@ class SubstNonTypeTemplateParmExpr : public Expr { friend class ASTReader; friend class ASTStmtReader; - /// The replaced parameter. - NonTypeTemplateParmDecl *Param; + /// The replaced parameter and a flag indicating if it was a reference + /// parameter. For class NTTPs, we can't determine that based on the value + /// category alone. + llvm::PointerIntPair ParamAndRef; /// The replacement expression. Stmt *Replacement; @@ -4211,10 +4260,10 @@ class SubstNonTypeTemplateParmExpr : public Expr { public: SubstNonTypeTemplateParmExpr(QualType Ty, ExprValueKind ValueKind, SourceLocation Loc, - NonTypeTemplateParmDecl *Param, + NonTypeTemplateParmDecl *Param, bool RefParam, Expr *Replacement) : Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary), - Param(Param), Replacement(Replacement) { + ParamAndRef(Param, RefParam), Replacement(Replacement) { SubstNonTypeTemplateParmExprBits.NameLoc = Loc; setDependence(computeDependence(this)); } @@ -4227,7 +4276,14 @@ class SubstNonTypeTemplateParmExpr : public Expr { Expr *getReplacement() const { return cast(Replacement); } - NonTypeTemplateParmDecl *getParameter() const { return Param; } + NonTypeTemplateParmDecl *getParameter() const { + return ParamAndRef.getPointer(); + } + + bool isReferenceParameter() const { return ParamAndRef.getInt(); } + + /// Determine the substituted type of the template parameter. + QualType getParameterType(const ASTContext &Ctx) const; static bool classof(const Stmt *s) { return s->getStmtClass() == SubstNonTypeTemplateParmExprClass; @@ -4476,6 +4532,10 @@ class MaterializeTemporaryExpr : public Expr { return getValueKind() == VK_LValue; } + /// Determine whether this temporary object is usable in constant + /// expressions, as specified in C++20 [expr.const]p4. + bool isUsableInConstantExpressions(const ASTContext &Context) const; + SourceLocation getBeginLoc() const LLVM_READONLY { return getSubExpr()->getBeginLoc(); } @@ -4517,31 +4577,38 @@ class CXXFoldExpr : public Expr { friend class ASTStmtReader; friend class ASTStmtWriter; + enum SubExpr { Callee, LHS, RHS, Count }; + SourceLocation LParenLoc; SourceLocation EllipsisLoc; SourceLocation RParenLoc; // When 0, the number of expansions is not known. Otherwise, this is one more // than the number of expansions. unsigned NumExpansions; - Stmt *SubExprs[2]; + Stmt *SubExprs[SubExpr::Count]; BinaryOperatorKind Opcode; public: - CXXFoldExpr(QualType T, SourceLocation LParenLoc, Expr *LHS, - BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS, - SourceLocation RParenLoc, Optional NumExpansions) + CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, + SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode, + SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, + Optional NumExpansions) : Expr(CXXFoldExprClass, T, VK_RValue, OK_Ordinary), LParenLoc(LParenLoc), EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc), NumExpansions(NumExpansions ? *NumExpansions + 1 : 0), Opcode(Opcode) { - SubExprs[0] = LHS; - SubExprs[1] = RHS; + SubExprs[SubExpr::Callee] = Callee; + SubExprs[SubExpr::LHS] = LHS; + SubExprs[SubExpr::RHS] = RHS; setDependence(computeDependence(this)); } CXXFoldExpr(EmptyShell Empty) : Expr(CXXFoldExprClass, Empty) {} - Expr *getLHS() const { return static_cast(SubExprs[0]); } - Expr *getRHS() const { return static_cast(SubExprs[1]); } + UnresolvedLookupExpr *getCallee() const { + return static_cast(SubExprs[SubExpr::Callee]); + } + Expr *getLHS() const { return static_cast(SubExprs[SubExpr::LHS]); } + Expr *getRHS() const { return static_cast(SubExprs[SubExpr::RHS]); } /// Does this produce a right-associated sequence of operators? bool isRightFold() const { @@ -4557,6 +4624,8 @@ class CXXFoldExpr : public Expr { /// Get the operand that doesn't contain a pack, for a binary fold. Expr *getInit() const { return isLeftFold() ? getLHS() : getRHS(); } + SourceLocation getLParenLoc() const { return LParenLoc; } + SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getEllipsisLoc() const { return EllipsisLoc; } BinaryOperatorKind getOperator() const { return Opcode; } @@ -4566,19 +4635,33 @@ class CXXFoldExpr : public Expr { return None; } - SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + if (LParenLoc.isValid()) + return LParenLoc; + if (isLeftFold()) + return getEllipsisLoc(); + return getLHS()->getBeginLoc(); + } - SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; } + SourceLocation getEndLoc() const LLVM_READONLY { + if (RParenLoc.isValid()) + return RParenLoc; + if (isRightFold()) + return getEllipsisLoc(); + return getRHS()->getEndLoc(); + } static bool classof(const Stmt *T) { return T->getStmtClass() == CXXFoldExprClass; } // Iterators - child_range children() { return child_range(SubExprs, SubExprs + 2); } + child_range children() { + return child_range(SubExprs, SubExprs + SubExpr::Count); + } const_child_range children() const { - return const_child_range(SubExprs, SubExprs + 2); + return const_child_range(SubExprs, SubExprs + SubExpr::Count); } }; @@ -4796,7 +4879,7 @@ class BuiltinBitCastExpr final private llvm::TrailingObjects { friend class ASTStmtReader; friend class CastExpr; - friend class TrailingObjects; + friend TrailingObjects; SourceLocation KWLoc; SourceLocation RParenLoc; @@ -4805,11 +4888,11 @@ class BuiltinBitCastExpr final BuiltinBitCastExpr(QualType T, ExprValueKind VK, CastKind CK, Expr *SrcExpr, TypeSourceInfo *DstType, SourceLocation KWLoc, SourceLocation RParenLoc) - : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0, + : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0, false, DstType), KWLoc(KWLoc), RParenLoc(RParenLoc) {} BuiltinBitCastExpr(EmptyShell Empty) - : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0) {} + : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0, false) {} SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; } SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; } diff --git a/contrib/llvm-project/clang/include/clang/AST/ExprConcepts.h b/contrib/llvm-project/clang/include/clang/AST/ExprConcepts.h index 2a88ed5175d24d..1544c498ef6625 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ExprConcepts.h +++ b/contrib/llvm-project/clang/include/clang/AST/ExprConcepts.h @@ -126,7 +126,11 @@ class ConceptSpecializationExpr final : public Expr, public ConceptReference, } SourceLocation getEndLoc() const LLVM_READONLY { - return ArgsAsWritten->RAngleLoc; + // If the ConceptSpecializationExpr is the ImmediatelyDeclaredConstraint + // of a TypeConstraint written syntactically as a constrained-parameter, + // there may not be a template argument list. + return ArgsAsWritten->RAngleLoc.isValid() ? ArgsAsWritten->RAngleLoc + : ConceptName.getEndLoc(); } // Iterators diff --git a/contrib/llvm-project/clang/include/clang/AST/ExprObjC.h b/contrib/llvm-project/clang/include/clang/AST/ExprObjC.h index 4b39d9ab96a6a7..17eec517269780 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ExprObjC.h +++ b/contrib/llvm-project/clang/include/clang/AST/ExprObjC.h @@ -1639,12 +1639,12 @@ class ObjCBridgedCastExpr final CastKind CK, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *Operand) : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), VK_RValue, - CK, Operand, 0, TSInfo), + CK, Operand, 0, false, TSInfo), LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {} /// Construct an empty Objective-C bridged cast. explicit ObjCBridgedCastExpr(EmptyShell Shell) - : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0) {} + : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0, false) {} SourceLocation getLParenLoc() const { return LParenLoc; } diff --git a/contrib/llvm-project/clang/include/clang/AST/ExternalASTSource.h b/contrib/llvm-project/clang/include/clang/AST/ExternalASTSource.h index def877b9181693..caae0770931b38 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ExternalASTSource.h +++ b/contrib/llvm-project/clang/include/clang/AST/ExternalASTSource.h @@ -161,10 +161,6 @@ class ExternalASTSource : public RefCountedBase { /// Retrieve the module that corresponds to the given module ID. virtual Module *getModule(unsigned ID) { return nullptr; } - /// Determine whether D comes from a PCH which was built with a corresponding - /// object file. - virtual bool DeclIsFromPCHWithObjectFile(const Decl *D) { return false; } - /// Return a descriptor for the corresponding module, if one exists. virtual llvm::Optional getSourceDescriptor(unsigned ID); diff --git a/contrib/llvm-project/clang/include/clang/AST/GlobalDecl.h b/contrib/llvm-project/clang/include/clang/AST/GlobalDecl.h index d8ac498be54fd3..8cb56fb4ae90b6 100644 --- a/contrib/llvm-project/clang/include/clang/AST/GlobalDecl.h +++ b/contrib/llvm-project/clang/include/clang/AST/GlobalDecl.h @@ -32,6 +32,7 @@ enum class DynamicInitKind : unsigned { NoStub = 0, Initializer, AtExit, + GlobalArrayDestructor }; enum class KernelReferenceKind : unsigned { diff --git a/contrib/llvm-project/clang/include/clang/AST/IgnoreExpr.h b/contrib/llvm-project/clang/include/clang/AST/IgnoreExpr.h new file mode 100644 index 00000000000000..1c2b538e5b6353 --- /dev/null +++ b/contrib/llvm-project/clang/include/clang/AST/IgnoreExpr.h @@ -0,0 +1,161 @@ +//===--- IgnoreExpr.h - Ignore intermediate Expressions -----------------===// +// +// 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 common functions to ignore intermediate expression nodes +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_AST_IGNOREEXPR_H +#define LLVM_CLANG_AST_IGNOREEXPR_H + +#include "clang/AST/Expr.h" +#include "clang/AST/ExprCXX.h" + +namespace clang { +namespace detail { +/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *, +/// Return Fn_n(...(Fn_1(E))) +inline Expr *IgnoreExprNodesImpl(Expr *E) { return E; } +template +Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) { + return IgnoreExprNodesImpl(Fn(E), std::forward(Fns)...); +} +} // namespace detail + +/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *, +/// Recursively apply each of the functions to E until reaching a fixed point. +/// Note that a null E is valid; in this case nothing is done. +template Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) { + Expr *LastE = nullptr; + while (E != LastE) { + LastE = E; + E = detail::IgnoreExprNodesImpl(E, std::forward(Fns)...); + } + return E; +} + +template +const Expr *IgnoreExprNodes(const Expr *E, FnTys &&...Fns) { + return const_cast(IgnoreExprNodes(E, std::forward(Fns)...)); +} + +inline Expr *IgnoreImplicitCastsSingleStep(Expr *E) { + if (auto *ICE = dyn_cast(E)) + return ICE->getSubExpr(); + + if (auto *FE = dyn_cast(E)) + return FE->getSubExpr(); + + return E; +} + +inline Expr *IgnoreImplicitCastsExtraSingleStep(Expr *E) { + // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in + // addition to what IgnoreImpCasts() skips to account for the current + // behaviour of IgnoreParenImpCasts(). + Expr *SubE = IgnoreImplicitCastsSingleStep(E); + if (SubE != E) + return SubE; + + if (auto *MTE = dyn_cast(E)) + return MTE->getSubExpr(); + + if (auto *NTTP = dyn_cast(E)) + return NTTP->getReplacement(); + + return E; +} + +inline Expr *IgnoreCastsSingleStep(Expr *E) { + if (auto *CE = dyn_cast(E)) + return CE->getSubExpr(); + + if (auto *FE = dyn_cast(E)) + return FE->getSubExpr(); + + if (auto *MTE = dyn_cast(E)) + return MTE->getSubExpr(); + + if (auto *NTTP = dyn_cast(E)) + return NTTP->getReplacement(); + + return E; +} + +inline Expr *IgnoreLValueCastsSingleStep(Expr *E) { + // Skip what IgnoreCastsSingleStep skips, except that only + // lvalue-to-rvalue casts are skipped. + if (auto *CE = dyn_cast(E)) + if (CE->getCastKind() != CK_LValueToRValue) + return E; + + return IgnoreCastsSingleStep(E); +} + +inline Expr *IgnoreBaseCastsSingleStep(Expr *E) { + if (auto *CE = dyn_cast(E)) + if (CE->getCastKind() == CK_DerivedToBase || + CE->getCastKind() == CK_UncheckedDerivedToBase || + CE->getCastKind() == CK_NoOp) + return CE->getSubExpr(); + + return E; +} + +inline Expr *IgnoreImplicitSingleStep(Expr *E) { + Expr *SubE = IgnoreImplicitCastsSingleStep(E); + if (SubE != E) + return SubE; + + if (auto *MTE = dyn_cast(E)) + return MTE->getSubExpr(); + + if (auto *BTE = dyn_cast(E)) + return BTE->getSubExpr(); + + return E; +} + +inline Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) { + if (auto *ICE = dyn_cast(E)) + return ICE->getSubExprAsWritten(); + + return IgnoreImplicitSingleStep(E); +} + +inline Expr *IgnoreParensOnlySingleStep(Expr *E) { + if (auto *PE = dyn_cast(E)) + return PE->getSubExpr(); + return E; +} + +inline Expr *IgnoreParensSingleStep(Expr *E) { + if (auto *PE = dyn_cast(E)) + return PE->getSubExpr(); + + if (auto *UO = dyn_cast(E)) { + if (UO->getOpcode() == UO_Extension) + return UO->getSubExpr(); + } + + else if (auto *GSE = dyn_cast(E)) { + if (!GSE->isResultDependent()) + return GSE->getResultExpr(); + } + + else if (auto *CE = dyn_cast(E)) { + if (!CE->isConditionDependent()) + return CE->getChosenSubExpr(); + } + + return E; +} + +} // namespace clang + +#endif // LLVM_CLANG_AST_IGNOREEXPR_H diff --git a/contrib/llvm-project/clang/include/clang/AST/Mangle.h b/contrib/llvm-project/clang/include/clang/AST/Mangle.h index 011d1faab8eadd..7b6495d85eb6ed 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Mangle.h +++ b/contrib/llvm-project/clang/include/clang/AST/Mangle.h @@ -96,6 +96,9 @@ 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) {} + // FIXME: consider replacing raw_ostream & with something like SmallString &. void mangleName(GlobalDecl GD, raw_ostream &); virtual void mangleCXXName(GlobalDecl GD, raw_ostream &) = 0; @@ -123,8 +126,11 @@ class MangleContext { void mangleBlock(const DeclContext *DC, const BlockDecl *BD, raw_ostream &Out); - void mangleObjCMethodNameWithoutSize(const ObjCMethodDecl *MD, raw_ostream &); - void mangleObjCMethodName(const ObjCMethodDecl *MD, raw_ostream &); + void mangleObjCMethodName(const ObjCMethodDecl *MD, raw_ostream &OS, + bool includePrefixByte = true, + bool includeCategoryNamespace = true); + void mangleObjCMethodNameAsSourceName(const ObjCMethodDecl *MD, + raw_ostream &); virtual void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &) = 0; @@ -149,14 +155,9 @@ class MangleContext { }; class ItaniumMangleContext : public MangleContext { - bool IsUniqueNameMangler = false; public: explicit ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D) : MangleContext(C, D, MK_Itanium) {} - explicit ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D, - bool IsUniqueNameMangler) - : MangleContext(C, D, MK_Itanium), - IsUniqueNameMangler(IsUniqueNameMangler) {} virtual void mangleCXXVTable(const CXXRecordDecl *RD, raw_ostream &) = 0; virtual void mangleCXXVTT(const CXXRecordDecl *RD, raw_ostream &) = 0; @@ -177,15 +178,12 @@ class ItaniumMangleContext : public MangleContext { virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &) = 0; - bool isUniqueNameMangler() { return IsUniqueNameMangler; } - static bool classof(const MangleContext *C) { return C->getKind() == MK_Itanium; } static ItaniumMangleContext *create(ASTContext &Context, - DiagnosticsEngine &Diags, - bool IsUniqueNameMangler = false); + DiagnosticsEngine &Diags); }; class MicrosoftMangleContext : public MangleContext { diff --git a/contrib/llvm-project/clang/include/clang/AST/MangleNumberingContext.h b/contrib/llvm-project/clang/include/clang/AST/MangleNumberingContext.h index f1ca6a05dbafe9..eb33759682d6f3 100644 --- a/contrib/llvm-project/clang/include/clang/AST/MangleNumberingContext.h +++ b/contrib/llvm-project/clang/include/clang/AST/MangleNumberingContext.h @@ -52,6 +52,11 @@ class MangleNumberingContext { /// this context. virtual unsigned getManglingNumber(const TagDecl *TD, unsigned MSLocalManglingNumber) = 0; + + /// Retrieve the mangling number of a new lambda expression with the + /// given call operator within the device context. No device number is + /// assigned if there's no device numbering context is associated. + virtual unsigned getDeviceManglingNumber(const CXXMethodDecl *) { return 0; } }; } // end namespace clang diff --git a/contrib/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h b/contrib/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h index 540ac3df48fe0b..8bc3e25c0f4b3f 100644 --- a/contrib/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h +++ b/contrib/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h @@ -17,6 +17,7 @@ #include "clang/AST/DependenceFlags.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/Support/Compiler.h" @@ -518,8 +519,8 @@ class NestedNameSpecifierLocBuilder { /// Insertion operator for diagnostics. This allows sending /// NestedNameSpecifiers into a diagnostic with <<. -inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - NestedNameSpecifier *NNS) { +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, + NestedNameSpecifier *NNS) { DB.AddTaggedVal(reinterpret_cast(NNS), DiagnosticsEngine::ak_nestednamespec); return DB; @@ -527,4 +528,33 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, } // namespace clang +namespace llvm { + +template <> struct DenseMapInfo { + using FirstInfo = DenseMapInfo; + using SecondInfo = DenseMapInfo; + + static clang::NestedNameSpecifierLoc getEmptyKey() { + return clang::NestedNameSpecifierLoc(FirstInfo::getEmptyKey(), + SecondInfo::getEmptyKey()); + } + + static clang::NestedNameSpecifierLoc getTombstoneKey() { + return clang::NestedNameSpecifierLoc(FirstInfo::getTombstoneKey(), + SecondInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const clang::NestedNameSpecifierLoc &PairVal) { + return hash_combine( + FirstInfo::getHashValue(PairVal.getNestedNameSpecifier()), + SecondInfo::getHashValue(PairVal.getOpaqueData())); + } + + static bool isEqual(const clang::NestedNameSpecifierLoc &LHS, + const clang::NestedNameSpecifierLoc &RHS) { + return LHS == RHS; + } +}; +} // namespace llvm + #endif // LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H diff --git a/contrib/llvm-project/clang/include/clang/AST/OpenMPClause.h b/contrib/llvm-project/clang/include/clang/AST/OpenMPClause.h index 6de7b6deb51498..877c1d87d8ac36 100644 --- a/contrib/llvm-project/clang/include/clang/AST/OpenMPClause.h +++ b/contrib/llvm-project/clang/include/clang/AST/OpenMPClause.h @@ -16,6 +16,7 @@ #ifndef LLVM_CLANG_AST_OPENMPCLAUSE_H #define LLVM_CLANG_AST_OPENMPCLAUSE_H +#include "clang/AST/ASTFwd.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/Expr.h" @@ -27,6 +28,7 @@ #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/MapVector.h" +#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" @@ -4737,8 +4739,9 @@ class OMPClauseMappableExprCommon { /// subscript it may not have any associated declaration. In that case the /// associated declaration is set to nullptr. class MappableComponent { - /// Expression associated with the component. - Expr *AssociatedExpression = nullptr; + /// Pair of Expression and Non-contiguous pair associated with the + /// component. + llvm::PointerIntPair AssociatedExpressionNonContiguousPr; /// Declaration associated with the declaration. If the component does /// not have a declaration (e.g. array subscripts or section), this is set @@ -4748,14 +4751,22 @@ class OMPClauseMappableExprCommon { public: explicit MappableComponent() = default; explicit MappableComponent(Expr *AssociatedExpression, - ValueDecl *AssociatedDeclaration) - : AssociatedExpression(AssociatedExpression), + ValueDecl *AssociatedDeclaration, + bool IsNonContiguous) + : AssociatedExpressionNonContiguousPr(AssociatedExpression, + IsNonContiguous), AssociatedDeclaration( AssociatedDeclaration ? cast(AssociatedDeclaration->getCanonicalDecl()) : nullptr) {} - Expr *getAssociatedExpression() const { return AssociatedExpression; } + Expr *getAssociatedExpression() const { + return AssociatedExpressionNonContiguousPr.getPointer(); + } + + bool isNonContiguous() const { + return AssociatedExpressionNonContiguousPr.getInt(); + } ValueDecl *getAssociatedDeclaration() const { return AssociatedDeclaration; @@ -4820,6 +4831,11 @@ class OMPMappableExprListClause : public OMPVarListClause, /// Total number of components in this clause. unsigned NumComponents; + /// Whether this clause is possible to have user-defined mappers associated. + /// It should be true for map, to, and from clauses, and false for + /// use_device_ptr and is_device_ptr. + const bool SupportsMapper; + /// C++ nested name specifier for the associated user-defined mapper. NestedNameSpecifierLoc MapperQualifierLoc; @@ -4840,19 +4856,21 @@ class OMPMappableExprListClause : public OMPVarListClause, /// NumUniqueDeclarations: number of unique base declarations in this clause; /// 3) NumComponentLists: number of component lists in this clause; and 4) /// NumComponents: total number of expression components in the clause. + /// \param SupportsMapper Indicates whether this clause is possible to have + /// user-defined mappers associated. /// \param MapperQualifierLocPtr C++ nested name specifier for the associated /// user-defined mapper. /// \param MapperIdInfoPtr The identifier of associated user-defined mapper. OMPMappableExprListClause( OpenMPClauseKind K, const OMPVarListLocTy &Locs, - const OMPMappableExprListSizeTy &Sizes, + const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false, NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr, DeclarationNameInfo *MapperIdInfoPtr = nullptr) : OMPVarListClause(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc, Sizes.NumVars), NumUniqueDeclarations(Sizes.NumUniqueDeclarations), NumComponentLists(Sizes.NumComponentLists), - NumComponents(Sizes.NumComponents) { + NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) { if (MapperQualifierLocPtr) MapperQualifierLoc = *MapperQualifierLocPtr; if (MapperIdInfoPtr) @@ -5051,6 +5069,8 @@ class OMPMappableExprListClause : public OMPVarListClause, /// Get the user-defined mapper references that are in the trailing objects of /// the class. MutableArrayRef getUDMapperRefs() { + assert(SupportsMapper && + "Must be a clause that is possible to have user-defined mappers"); return llvm::makeMutableArrayRef( static_cast(this)->template getTrailingObjects() + OMPVarListClause::varlist_size(), @@ -5060,8 +5080,10 @@ class OMPMappableExprListClause : public OMPVarListClause, /// Get the user-defined mappers references that are in the trailing objects /// of the class. ArrayRef getUDMapperRefs() const { + assert(SupportsMapper && + "Must be a clause that is possible to have user-defined mappers"); return llvm::makeArrayRef( - static_cast(this)->template getTrailingObjects() + + static_cast(this)->template getTrailingObjects() + OMPVarListClause::varlist_size(), OMPVarListClause::varlist_size()); } @@ -5071,6 +5093,8 @@ class OMPMappableExprListClause : public OMPVarListClause, void setUDMapperRefs(ArrayRef DMDs) { assert(DMDs.size() == OMPVarListClause::varlist_size() && "Unexpected number of user-defined mappers."); + assert(SupportsMapper && + "Must be a clause that is possible to have user-defined mappers"); std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin()); } @@ -5107,6 +5131,12 @@ class OMPMappableExprListClause : public OMPVarListClause, // The list number associated with the current declaration. ArrayRef::iterator NumListsCur; + // Whether this clause is possible to have user-defined mappers associated. + const bool SupportsMapper; + + // The user-defined mapper associated with the current declaration. + ArrayRef::iterator MapperCur; + // Remaining lists for the current declaration. unsigned RemainingLists = 0; @@ -5127,16 +5157,20 @@ class OMPMappableExprListClause : public OMPVarListClause, explicit const_component_lists_iterator( ArrayRef UniqueDecls, ArrayRef DeclsListNum, ArrayRef CumulativeListSizes, - MappableExprComponentListRef Components) + MappableExprComponentListRef Components, bool SupportsMapper, + ArrayRef Mappers) : const_component_lists_iterator::iterator_adaptor_base( Components.begin()), DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()), + SupportsMapper(SupportsMapper), ListSizeCur(CumulativeListSizes.begin()), ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) { assert(UniqueDecls.size() == DeclsListNum.size() && "Inconsistent number of declarations and list sizes!"); if (!DeclsListNum.empty()) RemainingLists = *NumListsCur; + if (SupportsMapper) + MapperCur = Mappers.begin(); } /// Construct an iterator that scan lists for a given declaration \a @@ -5144,9 +5178,11 @@ class OMPMappableExprListClause : public OMPVarListClause, explicit const_component_lists_iterator( const ValueDecl *Declaration, ArrayRef UniqueDecls, ArrayRef DeclsListNum, ArrayRef CumulativeListSizes, - MappableExprComponentListRef Components) + MappableExprComponentListRef Components, bool SupportsMapper, + ArrayRef Mappers) : const_component_lists_iterator(UniqueDecls, DeclsListNum, - CumulativeListSizes, Components) { + CumulativeListSizes, Components, + SupportsMapper, Mappers) { // Look for the desired declaration. While we are looking for it, we // update the state so that we know the component where a given list // starts. @@ -5161,6 +5197,9 @@ class OMPMappableExprListClause : public OMPVarListClause, std::advance(ListSizeCur, *NumListsCur - 1); PrevListSize = *ListSizeCur; ++ListSizeCur; + + if (SupportsMapper) + ++MapperCur; } // If we didn't find any declaration, advance the iterator to after the @@ -5186,14 +5225,20 @@ class OMPMappableExprListClause : public OMPVarListClause, // Return the array with the current list. The sizes are cumulative, so the // array size is the difference between the current size and previous one. - std::pair + std::tuple operator*() const { assert(ListSizeCur != ListSizeEnd && "Invalid iterator!"); - return std::make_pair( + const ValueDecl *Mapper = nullptr; + if (SupportsMapper && *MapperCur) + Mapper = cast(cast(*MapperCur)->getDecl()); + return std::make_tuple( *DeclCur, - MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize)); + MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize), + Mapper); } - std::pair + std::tuple operator->() const { return **this; } @@ -5216,6 +5261,8 @@ class OMPMappableExprListClause : public OMPVarListClause, if (!(--RemainingLists)) { ++DeclCur; ++NumListsCur; + if (SupportsMapper) + ++MapperCur; RemainingLists = *NumListsCur; assert(RemainingLists && "No lists in the following declaration??"); } @@ -5233,13 +5280,15 @@ class OMPMappableExprListClause : public OMPVarListClause, const_component_lists_iterator component_lists_begin() const { return const_component_lists_iterator( getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(), - getComponentsRef()); + getComponentsRef(), SupportsMapper, + SupportsMapper ? getUDMapperRefs() : llvm::None); } const_component_lists_iterator component_lists_end() const { return const_component_lists_iterator( ArrayRef(), ArrayRef(), ArrayRef(), MappableExprComponentListRef(getComponentsRef().end(), - getComponentsRef().end())); + getComponentsRef().end()), + SupportsMapper, llvm::None); } const_component_lists_range component_lists() const { return {component_lists_begin(), component_lists_end()}; @@ -5251,7 +5300,8 @@ class OMPMappableExprListClause : public OMPVarListClause, decl_component_lists_begin(const ValueDecl *VD) const { return const_component_lists_iterator( VD, getUniqueDeclsRef(), getDeclNumListsRef(), - getComponentListSizesRef(), getComponentsRef()); + getComponentListSizesRef(), getComponentsRef(), SupportsMapper, + SupportsMapper ? getUDMapperRefs() : llvm::None); } const_component_lists_iterator decl_component_lists_end() const { return component_lists_end(); @@ -5354,7 +5404,7 @@ class OMPMapClause final : public OMPMappableExprListClause, /// Map-type-modifiers for the 'map' clause. OpenMPMapModifierKind MapTypeModifiers[NumberOfOMPMapClauseModifiers] = { OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown, - OMPC_MAP_MODIFIER_unknown}; + OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown}; /// Location of map-type-modifiers for the 'map' clause. SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers]; @@ -5399,7 +5449,8 @@ class OMPMapClause final : public OMPMappableExprListClause, SourceLocation MapLoc, const OMPVarListLocTy &Locs, const OMPMappableExprListSizeTy &Sizes) : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes, - &MapperQualifierLoc, &MapperIdInfo), + /*SupportsMapper=*/true, &MapperQualifierLoc, + &MapperIdInfo), MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) { assert(llvm::array_lengthof(MapTypeModifiers) == MapModifiers.size() && "Unexpected number of map type modifiers."); @@ -5419,8 +5470,8 @@ class OMPMapClause final : public OMPMappableExprListClause, /// 3) NumComponentLists: number of component lists in this clause; and 4) /// NumComponents: total number of expression components in the clause. explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes) - : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), - Sizes) {} + : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes, + /*SupportsMapper=*/true) {} /// Set map-type-modifier for the clause. /// @@ -6289,8 +6340,20 @@ class OMPToClause final : public OMPMappableExprListClause, friend OMPVarListClause; friend TrailingObjects; + /// Motion-modifiers for the 'to' clause. + OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = { + OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown}; + + /// Location of motion-modifiers for the 'to' clause. + SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers]; + + /// Colon location. + SourceLocation ColonLoc; + /// Build clause with number of variables \a NumVars. /// + /// \param TheMotionModifiers Motion-modifiers. + /// \param TheMotionModifiersLoc Locations of motion-modifiers. /// \param MapperQualifierLoc C++ nested name specifier for the associated /// user-defined mapper. /// \param MapperIdInfo The identifier of associated user-defined mapper. @@ -6302,12 +6365,24 @@ class OMPToClause final : public OMPMappableExprListClause, /// NumUniqueDeclarations: number of unique base declarations in this clause; /// 3) NumComponentLists: number of component lists in this clause; and 4) /// NumComponents: total number of expression components in the clause. - explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc, + explicit OMPToClause(ArrayRef TheMotionModifiers, + ArrayRef TheMotionModifiersLoc, + NestedNameSpecifierLoc MapperQualifierLoc, DeclarationNameInfo MapperIdInfo, const OMPVarListLocTy &Locs, const OMPMappableExprListSizeTy &Sizes) : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes, - &MapperQualifierLoc, &MapperIdInfo) {} + /*SupportsMapper=*/true, &MapperQualifierLoc, + &MapperIdInfo) { + assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && + "Unexpected number of motion modifiers."); + llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); + + assert(llvm::array_lengthof(MotionModifiersLoc) == + TheMotionModifiersLoc.size() && + "Unexpected number of motion modifier locations."); + llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); + } /// Build an empty clause. /// @@ -6317,8 +6392,31 @@ class OMPToClause final : public OMPMappableExprListClause, /// 3) NumComponentLists: number of component lists in this clause; and 4) /// NumComponents: total number of expression components in the clause. explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes) - : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), - Sizes) {} + : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes, + /*SupportsMapper=*/true) {} + + /// Set motion-modifier for the clause. + /// + /// \param I index for motion-modifier. + /// \param T motion-modifier for the clause. + void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) { + assert(I < NumberOfOMPMotionModifiers && + "Unexpected index to store motion modifier, exceeds array size."); + MotionModifiers[I] = T; + } + + /// Set location for the motion-modifier. + /// + /// \param I index for motion-modifier location. + /// \param TLoc motion-modifier location. + void setMotionModifierLoc(unsigned I, SourceLocation TLoc) { + assert(I < NumberOfOMPMotionModifiers && + "Index to store motion modifier location exceeds array size."); + MotionModifiersLoc[I] = TLoc; + } + + /// Set colon location. + void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } /// Define the sizes of each trailing object array except the last one. This /// is required for TrailingObjects to work properly. @@ -6344,6 +6442,8 @@ class OMPToClause final : public OMPMappableExprListClause, /// \param Vars The original expression used in the clause. /// \param Declarations Declarations used in the clause. /// \param ComponentLists Component lists used in the clause. + /// \param MotionModifiers Motion-modifiers. + /// \param MotionModifiersLoc Location of motion-modifiers. /// \param UDMapperRefs References to user-defined mappers associated with /// expressions used in the clause. /// \param UDMQualifierLoc C++ nested name specifier for the associated @@ -6354,6 +6454,8 @@ class OMPToClause final : public OMPMappableExprListClause, ArrayRef Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef UDMapperRefs, + ArrayRef MotionModifiers, + ArrayRef MotionModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId); @@ -6368,6 +6470,38 @@ class OMPToClause final : public OMPMappableExprListClause, static OMPToClause *CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes); + /// Fetches the motion-modifier at 'Cnt' index of array of modifiers. + /// + /// \param Cnt index for motion-modifier. + OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY { + assert(Cnt < NumberOfOMPMotionModifiers && + "Requested modifier exceeds the total number of modifiers."); + return MotionModifiers[Cnt]; + } + + /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers' + /// locations. + /// + /// \param Cnt index for motion-modifier location. + SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY { + assert(Cnt < NumberOfOMPMotionModifiers && + "Requested modifier location exceeds total number of modifiers."); + return MotionModifiersLoc[Cnt]; + } + + /// Fetches ArrayRef of motion-modifiers. + ArrayRef getMotionModifiers() const LLVM_READONLY { + return llvm::makeArrayRef(MotionModifiers); + } + + /// Fetches ArrayRef of location of motion-modifiers. + ArrayRef getMotionModifiersLoc() const LLVM_READONLY { + return llvm::makeArrayRef(MotionModifiersLoc); + } + + /// Get colon location. + SourceLocation getColonLoc() const { return ColonLoc; } + child_range children() { return child_range(reinterpret_cast(varlist_begin()), reinterpret_cast(varlist_end())); @@ -6408,8 +6542,20 @@ class OMPFromClause final friend OMPVarListClause; friend TrailingObjects; + /// Motion-modifiers for the 'from' clause. + OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = { + OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown}; + + /// Location of motion-modifiers for the 'from' clause. + SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers]; + + /// Colon location. + SourceLocation ColonLoc; + /// Build clause with number of variables \a NumVars. /// + /// \param TheMotionModifiers Motion-modifiers. + /// \param TheMotionModifiersLoc Locations of motion-modifiers. /// \param MapperQualifierLoc C++ nested name specifier for the associated /// user-defined mapper. /// \param MapperIdInfo The identifier of associated user-defined mapper. @@ -6421,12 +6567,24 @@ class OMPFromClause final /// NumUniqueDeclarations: number of unique base declarations in this clause; /// 3) NumComponentLists: number of component lists in this clause; and 4) /// NumComponents: total number of expression components in the clause. - explicit OMPFromClause(NestedNameSpecifierLoc MapperQualifierLoc, + explicit OMPFromClause(ArrayRef TheMotionModifiers, + ArrayRef TheMotionModifiersLoc, + NestedNameSpecifierLoc MapperQualifierLoc, DeclarationNameInfo MapperIdInfo, const OMPVarListLocTy &Locs, const OMPMappableExprListSizeTy &Sizes) : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes, - &MapperQualifierLoc, &MapperIdInfo) {} + /*SupportsMapper=*/true, &MapperQualifierLoc, + &MapperIdInfo) { + assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() && + "Unexpected number of motion modifiers."); + llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); + + assert(llvm::array_lengthof(MotionModifiersLoc) == + TheMotionModifiersLoc.size() && + "Unexpected number of motion modifier locations."); + llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); + } /// Build an empty clause. /// @@ -6437,7 +6595,30 @@ class OMPFromClause final /// NumComponents: total number of expression components in the clause. explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes) : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(), - Sizes) {} + Sizes, /*SupportsMapper=*/true) {} + + /// Set motion-modifier for the clause. + /// + /// \param I index for motion-modifier. + /// \param T motion-modifier for the clause. + void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) { + assert(I < NumberOfOMPMotionModifiers && + "Unexpected index to store motion modifier, exceeds array size."); + MotionModifiers[I] = T; + } + + /// Set location for the motion-modifier. + /// + /// \param I index for motion-modifier location. + /// \param TLoc motion-modifier location. + void setMotionModifierLoc(unsigned I, SourceLocation TLoc) { + assert(I < NumberOfOMPMotionModifiers && + "Index to store motion modifier location exceeds array size."); + MotionModifiersLoc[I] = TLoc; + } + + /// Set colon location. + void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } /// Define the sizes of each trailing object array except the last one. This /// is required for TrailingObjects to work properly. @@ -6463,18 +6644,21 @@ class OMPFromClause final /// \param Vars The original expression used in the clause. /// \param Declarations Declarations used in the clause. /// \param ComponentLists Component lists used in the clause. + /// \param MotionModifiers Motion-modifiers. + /// \param MotionModifiersLoc Location of motion-modifiers. /// \param UDMapperRefs References to user-defined mappers associated with /// expressions used in the clause. /// \param UDMQualifierLoc C++ nested name specifier for the associated /// user-defined mapper. /// \param MapperId The identifier of associated user-defined mapper. - static OMPFromClause *Create(const ASTContext &C, const OMPVarListLocTy &Locs, - ArrayRef Vars, - ArrayRef Declarations, - MappableExprComponentListsRef ComponentLists, - ArrayRef UDMapperRefs, - NestedNameSpecifierLoc UDMQualifierLoc, - DeclarationNameInfo MapperId); + static OMPFromClause * + Create(const ASTContext &C, const OMPVarListLocTy &Locs, + ArrayRef Vars, ArrayRef Declarations, + MappableExprComponentListsRef ComponentLists, + ArrayRef UDMapperRefs, + ArrayRef MotionModifiers, + ArrayRef MotionModifiersLoc, + NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId); /// Creates an empty clause with the place for \a NumVars variables. /// @@ -6487,6 +6671,38 @@ class OMPFromClause final static OMPFromClause *CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes); + /// Fetches the motion-modifier at 'Cnt' index of array of modifiers. + /// + /// \param Cnt index for motion-modifier. + OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY { + assert(Cnt < NumberOfOMPMotionModifiers && + "Requested modifier exceeds the total number of modifiers."); + return MotionModifiers[Cnt]; + } + + /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers' + /// locations. + /// + /// \param Cnt index for motion-modifier location. + SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY { + assert(Cnt < NumberOfOMPMotionModifiers && + "Requested modifier location exceeds total number of modifiers."); + return MotionModifiersLoc[Cnt]; + } + + /// Fetches ArrayRef of motion-modifiers. + ArrayRef getMotionModifiers() const LLVM_READONLY { + return llvm::makeArrayRef(MotionModifiers); + } + + /// Fetches ArrayRef of location of motion-modifiers. + ArrayRef getMotionModifiersLoc() const LLVM_READONLY { + return llvm::makeArrayRef(MotionModifiersLoc); + } + + /// Get colon location. + SourceLocation getColonLoc() const { return ColonLoc; } + child_range children() { return child_range(reinterpret_cast(varlist_begin()), reinterpret_cast(varlist_end())); @@ -7542,22 +7758,22 @@ class OMPClauseVisitorBase { #define DISPATCH(CLASS) \ return static_cast(this)->Visit##CLASS(static_cast(S)) -#define OMP_CLAUSE_CLASS(Enum, Str, Class) \ - RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); } -#include "llvm/Frontend/OpenMP/OMPKinds.def" +#define GEN_CLANG_CLAUSE_CLASS +#define CLAUSE_CLASS(Enum, Str, Class) \ + RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); } +#include "llvm/Frontend/OpenMP/OMP.inc" RetTy Visit(PTR(OMPClause) S) { // Top switch clause: visit each OMPClause. switch (S->getClauseKind()) { -#define OMP_CLAUSE_CLASS(Enum, Str, Class) \ +#define GEN_CLANG_CLAUSE_CLASS +#define CLAUSE_CLASS(Enum, Str, Class) \ case llvm::omp::Clause::Enum: \ return Visit##Class(static_cast(S)); -#define OMP_CLAUSE_NO_CLASS(Enum, Str) \ +#define CLAUSE_NO_CLASS(Enum, Str) \ case llvm::omp::Clause::Enum: \ break; -#include "llvm/Frontend/OpenMP/OMPKinds.def" - default: - break; +#include "llvm/Frontend/OpenMP/OMP.inc" } } // Base case, ignore it. :) @@ -7581,18 +7797,24 @@ class OMPClausePrinter final : public OMPClauseVisitor { /// Process clauses with list of variables. template void VisitOMPClauseList(T *Node, char StartSym); + /// Process motion clauses. + template void VisitOMPMotionClause(T *Node); public: OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy) : OS(OS), Policy(Policy) {} -#define OMP_CLAUSE_CLASS(Enum, Str, Class) \ - void Visit##Class(Class *S); -#include "llvm/Frontend/OpenMP/OMPKinds.def" +#define GEN_CLANG_CLAUSE_CLASS +#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S); +#include "llvm/Frontend/OpenMP/OMP.inc" }; struct OMPTraitProperty { llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid; + + /// The raw string as we parsed it. This is needed for the `isa` trait set + /// (which accepts anything) and (later) extensions. + StringRef RawString; }; struct OMPTraitSelector { Expr *ScoreOrCondition = nullptr; @@ -7644,12 +7866,190 @@ class OMPTraitInfo { /// Return a string representation identifying this context selector. std::string getMangledName() const; + /// Check the extension trait \p TP is active. + bool isExtensionActive(llvm::omp::TraitProperty TP) { + for (const OMPTraitSet &Set : Sets) { + if (Set.Kind != llvm::omp::TraitSet::implementation) + continue; + for (const OMPTraitSelector &Selector : Set.Selectors) { + if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension) + continue; + for (const OMPTraitProperty &Property : Selector.Properties) { + if (Property.Kind == TP) + return true; + } + } + } + return false; + } + /// Print a human readable representation into \p OS. void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const; }; llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI); llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI); +/// Clang specific specialization of the OMPContext to lookup target features. +struct TargetOMPContext final : public llvm::omp::OMPContext { + + TargetOMPContext(ASTContext &ASTCtx, + std::function &&DiagUnknownTrait, + const FunctionDecl *CurrentFunctionDecl); + virtual ~TargetOMPContext() = default; + + /// See llvm::omp::OMPContext::matchesISATrait + bool matchesISATrait(StringRef RawString) const override; + +private: + std::function FeatureValidityCheck; + std::function DiagUnknownTrait; + llvm::StringMap FeatureMap; +}; + +/// Contains data for OpenMP directives: clauses, children +/// expressions/statements (helpers for codegen) and associated statement, if +/// any. +class OMPChildren final + : private llvm::TrailingObjects { + friend TrailingObjects; + friend class OMPClauseReader; + friend class OMPExecutableDirective; + template friend class OMPDeclarativeDirective; + + /// Numbers of clauses. + unsigned NumClauses = 0; + /// Number of child expressions/stmts. + unsigned NumChildren = 0; + /// true if the directive has associated statement. + bool HasAssociatedStmt = false; + + /// Define the sizes of each trailing object array except the last one. This + /// is required for TrailingObjects to work properly. + size_t numTrailingObjects(OverloadToken) const { + return NumClauses; + } + + OMPChildren() = delete; + + OMPChildren(unsigned NumClauses, unsigned NumChildren, bool HasAssociatedStmt) + : NumClauses(NumClauses), NumChildren(NumChildren), + HasAssociatedStmt(HasAssociatedStmt) {} + + static size_t size(unsigned NumClauses, bool HasAssociatedStmt, + unsigned NumChildren); + + static OMPChildren *Create(void *Mem, ArrayRef Clauses); + static OMPChildren *Create(void *Mem, ArrayRef Clauses, Stmt *S, + unsigned NumChildren = 0); + static OMPChildren *CreateEmpty(void *Mem, unsigned NumClauses, + bool HasAssociatedStmt = false, + unsigned NumChildren = 0); + +public: + unsigned getNumClauses() const { return NumClauses; } + unsigned getNumChildren() const { return NumChildren; } + bool hasAssociatedStmt() const { return HasAssociatedStmt; } + + /// Set associated statement. + void setAssociatedStmt(Stmt *S) { + getTrailingObjects()[NumChildren] = S; + } + + void setChildren(ArrayRef Children); + + /// Sets the list of variables for this clause. + /// + /// \param Clauses The list of clauses for the directive. + /// + void setClauses(ArrayRef Clauses); + + /// Returns statement associated with the directive. + const Stmt *getAssociatedStmt() const { + return const_cast(this)->getAssociatedStmt(); + } + Stmt *getAssociatedStmt() { + assert(HasAssociatedStmt && + "Expected directive with the associated statement."); + return getTrailingObjects()[NumChildren]; + } + + /// Get the clauses storage. + MutableArrayRef getClauses() { + return llvm::makeMutableArrayRef(getTrailingObjects(), + NumClauses); + } + ArrayRef getClauses() const { + return const_cast(this)->getClauses(); + } + + /// Returns the captured statement associated with the + /// component region within the (combined) directive. + /// + /// \param RegionKind Component region kind. + const CapturedStmt * + getCapturedStmt(OpenMPDirectiveKind RegionKind, + ArrayRef CaptureRegions) const { + assert(llvm::any_of( + CaptureRegions, + [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) && + "RegionKind not found in OpenMP CaptureRegions."); + auto *CS = cast(getAssociatedStmt()); + for (auto ThisCaptureRegion : CaptureRegions) { + if (ThisCaptureRegion == RegionKind) + return CS; + CS = cast(CS->getCapturedStmt()); + } + llvm_unreachable("Incorrect RegionKind specified for directive."); + } + + /// Get innermost captured statement for the construct. + CapturedStmt * + getInnermostCapturedStmt(ArrayRef CaptureRegions) { + assert(hasAssociatedStmt() && "Must have associated captured statement."); + assert(!CaptureRegions.empty() && + "At least one captured statement must be provided."); + auto *CS = cast(getAssociatedStmt()); + for (unsigned Level = CaptureRegions.size(); Level > 1; --Level) + CS = cast(CS->getCapturedStmt()); + return CS; + } + + const CapturedStmt * + getInnermostCapturedStmt(ArrayRef CaptureRegions) const { + return const_cast(this)->getInnermostCapturedStmt( + CaptureRegions); + } + + MutableArrayRef getChildren(); + ArrayRef getChildren() const { + return const_cast(this)->getChildren(); + } + + Stmt *getRawStmt() { + assert(HasAssociatedStmt && + "Expected directive with the associated statement."); + if (auto *CS = dyn_cast(getAssociatedStmt())) { + Stmt *S = nullptr; + do { + S = CS->getCapturedStmt(); + CS = dyn_cast(S); + } while (CS); + return S; + } + return getAssociatedStmt(); + } + const Stmt *getRawStmt() const { + return const_cast(this)->getRawStmt(); + } + + Stmt::child_range getAssociatedStmtAsRange() { + if (!HasAssociatedStmt) + return Stmt::child_range(Stmt::child_iterator(), Stmt::child_iterator()); + return Stmt::child_range(&getTrailingObjects()[NumChildren], + &getTrailingObjects()[NumChildren + 1]); + } +}; + } // namespace clang #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H diff --git a/contrib/llvm-project/clang/include/clang/AST/OperationKinds.def b/contrib/llvm-project/clang/include/clang/AST/OperationKinds.def index f29664e8eb3389..7c82ab6e57eff5 100644 --- a/contrib/llvm-project/clang/include/clang/AST/OperationKinds.def +++ b/contrib/llvm-project/clang/include/clang/AST/OperationKinds.def @@ -77,9 +77,10 @@ CAST_OPERATION(LValueToRValueBitCast) CAST_OPERATION(LValueToRValue) /// CK_NoOp - A conversion which does not affect the type other than -/// (possibly) adding qualifiers. +/// (possibly) adding qualifiers or removing noexcept. /// int -> int /// char** -> const char * const * +/// void () noexcept -> void () CAST_OPERATION(NoOp) /// CK_BaseToDerived - A conversion from a C++ class pointer/reference @@ -201,6 +202,14 @@ CAST_OPERATION(IntegralToBoolean) /// float f = i; CAST_OPERATION(IntegralToFloating) +/// CK_FloatingToFixedPoint - Floating to fixed point. +/// _Accum a = f; +CAST_OPERATION(FloatingToFixedPoint) + +/// CK_FixedPointToFloating - Fixed point to floating. +/// (float) 2.5k +CAST_OPERATION(FixedPointToFloating) + /// CK_FixedPointCast - Fixed point to fixed point. /// (_Accum) 0.5r CAST_OPERATION(FixedPointCast) diff --git a/contrib/llvm-project/clang/include/clang/AST/OptionalDiagnostic.h b/contrib/llvm-project/clang/include/clang/AST/OptionalDiagnostic.h index c57199f0fdf124..c9a2d19f4ebce0 100644 --- a/contrib/llvm-project/clang/include/clang/AST/OptionalDiagnostic.h +++ b/contrib/llvm-project/clang/include/clang/AST/OptionalDiagnostic.h @@ -63,7 +63,7 @@ class OptionalDiagnostic { return *this; } - OptionalDiagnostic &operator<<(const APFixedPoint &FX) { + OptionalDiagnostic &operator<<(const llvm::APFixedPoint &FX) { if (Diag) { SmallVector Buffer; FX.toString(Buffer); diff --git a/contrib/llvm-project/clang/include/clang/AST/ParentMap.h b/contrib/llvm-project/clang/include/clang/AST/ParentMap.h index 1e65d7efd27263..86e2f048a34453 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ParentMap.h +++ b/contrib/llvm-project/clang/include/clang/AST/ParentMap.h @@ -51,9 +51,7 @@ class ParentMap { return getParentIgnoreParenCasts(const_cast(S)); } - bool hasParent(Stmt* S) const { - return getParent(S) != nullptr; - } + bool hasParent(const Stmt *S) const { return getParent(S) != nullptr; } bool isConsumedExpr(Expr *E) const; diff --git a/contrib/llvm-project/clang/include/clang/AST/ParentMapContext.h b/contrib/llvm-project/clang/include/clang/AST/ParentMapContext.h index be4d75df7b9990..a0412380a864e7 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ParentMapContext.h +++ b/contrib/llvm-project/clang/include/clang/AST/ParentMapContext.h @@ -94,25 +94,24 @@ class DynTypedNodeList { public: DynTypedNodeList(const DynTypedNode &N) : IsSingleNode(true) { - new (Storage.buffer) DynTypedNode(N); + new (&Storage) DynTypedNode(N); } DynTypedNodeList(ArrayRef A) : IsSingleNode(false) { - new (Storage.buffer) ArrayRef(A); + new (&Storage) ArrayRef(A); } const DynTypedNode *begin() const { if (!IsSingleNode) - return reinterpret_cast *>(Storage.buffer) + return reinterpret_cast *>(&Storage) ->begin(); - return reinterpret_cast(Storage.buffer); + return reinterpret_cast(&Storage); } const DynTypedNode *end() const { if (!IsSingleNode) - return reinterpret_cast *>(Storage.buffer) - ->end(); - return reinterpret_cast(Storage.buffer) + 1; + return reinterpret_cast *>(&Storage)->end(); + return reinterpret_cast(&Storage) + 1; } size_t size() const { return end() - begin(); } diff --git a/contrib/llvm-project/clang/include/clang/AST/PrettyPrinter.h b/contrib/llvm-project/clang/include/clang/AST/PrettyPrinter.h index 616647f44430cd..3baf2b2ba94d61 100644 --- a/contrib/llvm-project/clang/include/clang/AST/PrettyPrinter.h +++ b/contrib/llvm-project/clang/include/clang/AST/PrettyPrinter.h @@ -18,6 +18,7 @@ namespace clang { +class DeclContext; class LangOptions; class SourceManager; class Stmt; @@ -39,6 +40,15 @@ class PrintingCallbacks { virtual std::string remapPath(StringRef Path) const { return std::string(Path); } + + /// When printing type to be inserted into code in specific context, this + /// callback can be used to avoid printing the redundant part of the + /// qualifier. For example, when inserting code inside namespace foo, we + /// should print bar::SomeType instead of foo::bar::SomeType. + /// To do this, shouldPrintScope should return true on "foo" NamespaceDecl. + /// The printing stops at the first isScopeVisible() == true, so there will + /// be no calls with outer scopes. + virtual bool isScopeVisible(const DeclContext *DC) const { return false; } }; /// Describes how types, statements, expressions, and declarations should be @@ -52,12 +62,13 @@ struct PrintingPolicy { : Indentation(2), SuppressSpecifiers(false), SuppressTagKeyword(LO.CPlusPlus), IncludeTagDefinition(false), SuppressScope(false), SuppressUnwrittenScope(false), - SuppressInitializers(false), ConstantArraySizeAsWritten(false), - AnonymousTagLocations(true), SuppressStrongLifetime(false), - SuppressLifetimeQualifiers(false), - SuppressTemplateArgsInCXXConstructors(false), Bool(LO.Bool), - Restrict(LO.C99), Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11), - UseVoidForZeroParams(!LO.CPlusPlus), + SuppressInlineNamespace(true), SuppressInitializers(false), + ConstantArraySizeAsWritten(false), AnonymousTagLocations(true), + SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false), + SuppressTemplateArgsInCXXConstructors(false), + SuppressDefaultTemplateArgs(true), Bool(LO.Bool), + Nullptr(LO.CPlusPlus11), Restrict(LO.C99), Alignof(LO.CPlusPlus11), + UnderscoreAlignof(LO.C11), UseVoidForZeroParams(!LO.CPlusPlus), SplitTemplateClosers(!LO.CPlusPlus11), TerseOutput(false), PolishForDeclaration(false), Half(LO.Half), MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true), @@ -117,10 +128,15 @@ struct PrintingPolicy { /// Suppresses printing of scope specifiers. unsigned SuppressScope : 1; - /// Suppress printing parts of scope specifiers that don't need - /// to be written, e.g., for inline or anonymous namespaces. + /// Suppress printing parts of scope specifiers that are never + /// written, e.g., for anonymous namespaces. unsigned SuppressUnwrittenScope : 1; + /// Suppress printing parts of scope specifiers that correspond + /// to inline namespaces, where the name is unambiguous with the specifier + /// removed. + unsigned SuppressInlineNamespace : 1; + /// Suppress printing of variable initializers. /// /// This flag is used when printing the loop variable in a for-range @@ -167,10 +183,18 @@ struct PrintingPolicy { /// constructors. unsigned SuppressTemplateArgsInCXXConstructors : 1; + /// When true, attempt to suppress template arguments that match the default + /// argument for the parameter. + unsigned SuppressDefaultTemplateArgs : 1; + /// Whether we can use 'bool' rather than '_Bool' (even if the language /// doesn't actually have 'bool', because, e.g., it is defined as a macro). unsigned Bool : 1; + /// Whether we should use 'nullptr' rather than '0' as a null pointer + /// constant. + unsigned Nullptr : 1; + /// Whether we can use 'restrict' rather than '__restrict'. unsigned Restrict : 1; diff --git a/contrib/llvm-project/clang/include/clang/AST/PropertiesBase.td b/contrib/llvm-project/clang/include/clang/AST/PropertiesBase.td index ba0f237a3bc3c9..a087cb406b290d 100644 --- a/contrib/llvm-project/clang/include/clang/AST/PropertiesBase.td +++ b/contrib/llvm-project/clang/include/clang/AST/PropertiesBase.td @@ -72,6 +72,8 @@ class CountPropertyType : PropertyType { def APInt : PropertyType<"llvm::APInt"> { let PassByReference = 1; } def APSInt : PropertyType<"llvm::APSInt"> { let PassByReference = 1; } +def APValue : PropertyType { let PassByReference = 1; } +def APValueKind : EnumPropertyType<"APValue::ValueKind">; def ArraySizeModifier : EnumPropertyType<"ArrayType::ArraySizeModifier">; def AttrKind : EnumPropertyType<"attr::Kind">; def AutoTypeKeyword : EnumPropertyType; @@ -109,7 +111,15 @@ def DeclRef : RefPropertyType<"Decl"> { let ConstWhenWriting = 1; } SubclassPropertyType<"ValueDecl", DeclRef>; def ElaboratedTypeKeyword : EnumPropertyType; def ExtParameterInfo : PropertyType<"FunctionProtoType::ExtParameterInfo">; +def FixedPointSemantics : PropertyType<"llvm::FixedPointSemantics"> { + let PassByReference = 1; +} def Identifier : RefPropertyType<"IdentifierInfo"> { let ConstWhenWriting = 1; } +def LValuePathEntry : PropertyType<"APValue::LValuePathEntry">; +def LValuePathSerializationHelper : + PropertyType<"APValue::LValuePathSerializationHelper"> { + let BufferElementTypes = [ LValuePathEntry ]; +} def NestedNameSpecifier : PropertyType<"NestedNameSpecifier *">; def NestedNameSpecifierKind : EnumPropertyType<"NestedNameSpecifier::SpecifierKind">; @@ -237,6 +247,304 @@ class PropertyTypeCase : HasProperties { string Name = name; } +// Type cases for APValue. +def : PropertyTypeKind; +let Class = PropertyTypeCase in { + def : Creator<[{ return APValue(); }]>; +} +let Class = PropertyTypeCase in { + def : Creator<[{ return APValue::IndeterminateValue(); }]>; +} +let Class = PropertyTypeCase in { + def : Property<"value", APSInt> { + let Read = [{ node.getInt() }]; + } + def : Creator<[{ return APValue(value); }]>; +} +let Class = PropertyTypeCase in { + def : Property<"semantics", UInt32> { + let Read = [{ + static_cast( + llvm::APFloatBase::SemanticsToEnum(node.getFloat().getSemantics())) + }]; + } + def : Property<"value", APInt> { + let Read = [{ node.getFloat().bitcastToAPInt() }]; + } + def : Creator<[{ + const llvm::fltSemantics &floatSema = llvm::APFloatBase::EnumToSemantics( + static_cast(semantics)); + return APValue(llvm::APFloat(floatSema, value)); + }]>; +} +let Class = PropertyTypeCase in { + def : Property<"semantics", FixedPointSemantics> { + let Read = [{ node.getFixedPoint().getSemantics() }]; + } + def : Property<"value", APSInt> { + let Read = [{ node.getFixedPoint().getValue() }]; + } + def : Creator<[{ + return APValue(llvm::APFixedPoint(std::move(value), semantics)); + }]>; +} +let Class = PropertyTypeCase in { + def : Property<"real", APSInt> { + let Read = [{ node.getComplexIntReal() }]; + } + def : Property<"imag", APSInt> { + let Read = [{ node.getComplexIntImag() }]; + } + def : Creator<[{ return APValue(real, imag); }]>; +} +let Class = PropertyTypeCase in { + def : ReadHelper<[{ + auto sema = llvm::APFloatBase::SemanticsToEnum( + node.getComplexFloatReal().getSemantics()); + assert(sema == llvm::APFloatBase::SemanticsToEnum( + node.getComplexFloatImag().getSemantics())); + }]>; + def : Property<"semantics", UInt32> { + let Read = [{ static_cast(sema) }]; + } + def : Property<"real", APInt> { + let Read = [{ node.getComplexFloatReal().bitcastToAPInt() }]; + } + def : Property<"imag", APInt> { + let Read = [{ node.getComplexFloatImag().bitcastToAPInt() }]; + } + def : Creator<[{ + const llvm::fltSemantics &sema = llvm::APFloatBase::EnumToSemantics( + static_cast(semantics)); + return APValue(llvm::APFloat(sema, real), + llvm::APFloat(sema, imag)); + }]>; +} +let Class = PropertyTypeCase in { + def : ReadHelper<[{ + SmallVector buffer; + unsigned len = node.getVectorLength(); + for (unsigned i = 0; i < len; ++i) + buffer.push_back(node.getVectorElt(i)); + }]>; + def : Property<"elements", Array> { + let Read = [{ buffer }]; + } + def : Creator<[{ + APValue result; + result.MakeVector(); + unsigned length = elements.size(); + (void)result.setVectorUninit(length); + for (unsigned i = 0; i < length; i++) + result.getVectorElt(i) = elements[i]; + return result; + }]>; +} +let Class = PropertyTypeCase in { + def : ReadHelper<[{ + SmallVector buffer{}; + unsigned initLength = node.getArrayInitializedElts(); + for (unsigned i = 0; i < initLength; ++i) + buffer.push_back(node.getArrayInitializedElt(i)); + if (node.hasArrayFiller()) + buffer.push_back(node.getArrayFiller()); + }]>; + def : Property<"totalLength", UInt32> { + let Read = [{ node.getArraySize() }]; + } + def : Property<"hasFiller", Bool> { + let Read = [{ node.hasArrayFiller() }]; + } + def : Property<"elements", Array> { + let Read = [{ buffer }]; + } + def : Creator<[{ + APValue result; + unsigned initLength = elements.size() - (hasFiller ? 1 : 0); + result.MakeArray(initLength, totalLength); + for (unsigned i = 0; i < initLength; ++i) + result.getArrayInitializedElt(i) = elements[i]; + if (hasFiller) + result.getArrayFiller() = elements.back(); + return result; + }]>; +} +let Class = PropertyTypeCase in { + def : ReadHelper<[{ + SmallVector structBases; + unsigned numBases = node.getStructNumBases(); + for (unsigned i = 0; i < numBases; ++i) + structBases.push_back(node.getStructBase(i)); + SmallVector structFields; + unsigned numFields = node.getStructNumFields(); + for (unsigned i = 0; i < numFields; ++i) + structFields.push_back(node.getStructField(i)); + }]>; + def : Property<"bases", Array> { + let Read = [{ structBases }]; + } + def : Property<"fields", Array> { + let Read = [{ structFields }]; + } + def : Creator<[{ + APValue result; + result.MakeStruct(bases.size(), fields.size()); + for (unsigned i = 0; i < bases.size(); ++i) + result.getStructBase(i) = bases[i]; + for (unsigned i = 0; i < fields.size(); ++i) + result.getStructField(i) = fields[i]; + return result; + }]>; +} +let Class = PropertyTypeCase in { + def : Property<"fieldDecl", DeclRef> { + let Read = [{ node.getUnionField() }]; + } + def : Property<"value", APValue> { + let Read = [{ node.getUnionValue() }]; + } + def : Creator<[{ + return APValue(cast(fieldDecl), std::move(value)); + }]>; +} +let Class = PropertyTypeCase in { + def : Property<"lhs", StmtRef> { + let Read = [{ const_cast(node.getAddrLabelDiffLHS()) }]; + } + def : Property<"rhs", StmtRef> { + let Read = [{ const_cast(node.getAddrLabelDiffRHS()) }]; + } + def : Creator<[{ + return APValue(cast(lhs), cast(rhs)); + }]>; +} +let Class = PropertyTypeCase in { + def : Property<"isDerived", Bool> { + let Read = [{ node.isMemberPointerToDerivedMember() }]; + } + def : Property<"member", ValueDeclRef> { + let Read = [{ node.getMemberPointerDecl() }]; + } + def : Property<"memberPath", Array> { + let Read = [{ node.getMemberPointerPath() }]; + } + def : Creator<[{ + APValue result; + unsigned pathSize = memberPath.size(); + const CXXRecordDecl **pathArray = + result.setMemberPointerUninit(member, isDerived, pathSize).data(); + for (unsigned i = 0; i < pathSize; ++i) + pathArray[i] = memberPath[i]->getCanonicalDecl(); + return result; + }]>; +} +let Class = PropertyTypeCase in { + def : ReadHelper<[{ + auto lvalueBase = node.getLValueBase(); + const Expr *expr = + lvalueBase ? lvalueBase.dyn_cast() : nullptr; + bool lvalueBaseIsExpr = (bool) expr; + bool lvalueBaseIsTypeInfo = lvalueBase.is(); + QualType elemTy; + if (lvalueBase) { + if (lvalueBaseIsTypeInfo) { + elemTy = lvalueBase.getTypeInfoType(); + } else if (lvalueBaseIsExpr) { + elemTy = expr->getType(); + } else { + elemTy = lvalueBase.get()->getType(); + } + } + }]>; + def : Property<"hasLValuePath", Bool> { + let Read = [{ node.hasLValuePath() }]; + } + def : Property<"isLValueOnePastTheEnd", Bool> { + let Read = [{ node.isLValueOnePastTheEnd() }]; + } + def : Property<"isExpr", Bool> { + let Read = [{ lvalueBaseIsExpr }]; + } + def : Property<"isTypeInfo", Bool> { + let Read = [{ lvalueBaseIsTypeInfo }]; + } + def : Property<"hasBase", Bool> { + let Read = [{ static_cast(lvalueBase) }]; + } + def : Property<"isNullPtr", Bool> { + let Read = [{ node.isNullPointer() }]; + } + def : Property<"typeInfo", QualType> { + let Conditional = [{ hasBase && isTypeInfo }]; + let Read = [{ + QualType(node.getLValueBase().get().getType(), 0) + }]; + } + def : Property<"type", QualType> { + let Conditional = [{ hasBase && isTypeInfo }]; + let Read = [{ node.getLValueBase().getTypeInfoType() }]; + } + def : Property<"callIndex", UInt32> { + let Conditional = [{ hasBase && !isTypeInfo }]; + let Read = [{ node.getLValueBase().getCallIndex() }]; + } + def : Property<"version", UInt32> { + let Conditional = [{ hasBase && !isTypeInfo }]; + let Read = [{ node.getLValueBase().getVersion() }]; + } + def : Property<"stmt", StmtRef> { + let Conditional = [{ hasBase && !isTypeInfo && isExpr }]; + let Read = [{ const_cast(expr) }]; + } + def : Property<"decl", DeclRef> { + let Conditional = [{ hasBase && !isTypeInfo && !isExpr }]; + let Read = [{ lvalueBase.get() }]; + } + def : Property<"offsetQuantity", UInt32> { + let Read = [{ node.getLValueOffset().getQuantity() }]; + } + def : Property<"lvaluePath", LValuePathSerializationHelper> { + let Conditional = [{ hasLValuePath }]; + let Read = [{ + APValue::LValuePathSerializationHelper(node.getLValuePath(), elemTy) + }]; + } + def : Creator<[{ + (void)ctx; + APValue::LValueBase base; + QualType elemTy; + if (hasBase) { + if (isTypeInfo) { + base = APValue::LValueBase::getTypeInfo( + TypeInfoLValue(typeInfo.getValue().getTypePtr()), type.getValue()); + elemTy = base.getTypeInfoType(); + } else if (isExpr) { + base = APValue::LValueBase(cast(stmt.getValue()), + callIndex.getValue(), version.getValue()); + elemTy = base.get()->getType(); + } else { + base = APValue::LValueBase(cast(decl.getValue()), + callIndex.getValue(), version.getValue()); + elemTy = base.get()->getType(); + } + } + CharUnits offset = CharUnits::fromQuantity(offsetQuantity); + APValue result; + result.MakeLValue(); + if (!hasLValuePath) { + result.setLValue(base, offset, APValue::NoLValuePath{}, isNullPtr); + return result; + } + auto pathLength = lvaluePath->Path.size(); + APValue::LValuePathEntry *path = result.setLValueUninit( + base, offset, pathLength, isLValueOnePastTheEnd, isNullPtr).data(); + assert(lvaluePath->getType() == elemTy && "Unexpected type reference!"); + llvm::copy(lvaluePath->Path, path); + return result; + }]>; +} + // Type cases for DeclarationName. def : PropertyTypeKind; diff --git a/contrib/llvm-project/clang/include/clang/AST/RecordLayout.h b/contrib/llvm-project/clang/include/clang/AST/RecordLayout.h index b259791af509d4..dd18f9c49f84fb 100644 --- a/contrib/llvm-project/clang/include/clang/AST/RecordLayout.h +++ b/contrib/llvm-project/clang/include/clang/AST/RecordLayout.h @@ -70,6 +70,11 @@ class ASTRecordLayout { // Alignment - Alignment of record in characters. CharUnits Alignment; + // PreferredAlignment - Preferred alignment of record in characters. This + // can be different than Alignment in cases where it is beneficial for + // performance or backwards compatibility preserving (e.g. AIX-ABI). + CharUnits PreferredAlignment; + // UnadjustedAlignment - Maximum of the alignments of the record members in // characters. CharUnits UnadjustedAlignment; @@ -91,6 +96,11 @@ class ASTRecordLayout { /// which is the alignment of the object without virtual bases. CharUnits NonVirtualAlignment; + /// PreferredNVAlignment - The preferred non-virtual alignment (in chars) of + /// an object, which is the preferred alignment of the object without + /// virtual bases. + CharUnits PreferredNVAlignment; + /// SizeOfLargestEmptySubobject - The size of the largest empty subobject /// (either a base or a member). Will be zero if the class doesn't contain /// any empty subobjects. @@ -139,30 +149,26 @@ class ASTRecordLayout { CXXRecordLayoutInfo *CXXInfo = nullptr; ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment, - CharUnits unadjustedAlignment, + CharUnits preferredAlignment, CharUnits unadjustedAlignment, CharUnits requiredAlignment, CharUnits datasize, ArrayRef fieldoffsets); using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy; // Constructor for C++ records. - ASTRecordLayout(const ASTContext &Ctx, - CharUnits size, CharUnits alignment, - CharUnits unadjustedAlignment, - CharUnits requiredAlignment, - bool hasOwnVFPtr, bool hasExtendableVFPtr, - CharUnits vbptroffset, - CharUnits datasize, - ArrayRef fieldoffsets, + ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment, + CharUnits preferredAlignment, CharUnits unadjustedAlignment, + CharUnits requiredAlignment, bool hasOwnVFPtr, + bool hasExtendableVFPtr, CharUnits vbptroffset, + CharUnits datasize, ArrayRef fieldoffsets, CharUnits nonvirtualsize, CharUnits nonvirtualalignment, + CharUnits preferrednvalignment, CharUnits SizeOfLargestEmptySubobject, - const CXXRecordDecl *PrimaryBase, - bool IsPrimaryBaseVirtual, + const CXXRecordDecl *PrimaryBase, bool IsPrimaryBaseVirtual, const CXXRecordDecl *BaseSharingVBPtr, - bool EndsWithZeroSizedObject, - bool LeadsWithZeroSizedBase, - const BaseOffsetsMapTy& BaseOffsets, - const VBaseOffsetsMapTy& VBaseOffsets); + bool EndsWithZeroSizedObject, bool LeadsWithZeroSizedBase, + const BaseOffsetsMapTy &BaseOffsets, + const VBaseOffsetsMapTy &VBaseOffsets); ~ASTRecordLayout() = default; @@ -175,6 +181,10 @@ class ASTRecordLayout { /// getAlignment - Get the record alignment in characters. CharUnits getAlignment() const { return Alignment; } + /// getPreferredFieldAlignment - Get the record preferred alignment in + /// characters. + CharUnits getPreferredAlignment() const { return PreferredAlignment; } + /// getUnadjustedAlignment - Get the record alignment in characters, before /// alignment adjustement. CharUnits getUnadjustedAlignment() const { return UnadjustedAlignment; } @@ -193,9 +203,7 @@ class ASTRecordLayout { /// getDataSize() - Get the record data size, which is the record size /// without tail padding, in characters. - CharUnits getDataSize() const { - return DataSize; - } + CharUnits getDataSize() const { return DataSize; } /// getNonVirtualSize - Get the non-virtual size (in chars) of an object, /// which is the size of the object without virtual bases. @@ -205,14 +213,23 @@ class ASTRecordLayout { return CXXInfo->NonVirtualSize; } - /// getNonVirtualSize - Get the non-virtual alignment (in chars) of an object, - /// which is the alignment of the object without virtual bases. + /// getNonVirtualAlignment - Get the non-virtual alignment (in chars) of an + /// object, which is the alignment of the object without virtual bases. CharUnits getNonVirtualAlignment() const { assert(CXXInfo && "Record layout does not have C++ specific info!"); return CXXInfo->NonVirtualAlignment; } + /// getPreferredNVAlignment - Get the preferred non-virtual alignment (in + /// chars) of an object, which is the preferred alignment of the object + /// without virtual bases. + CharUnits getPreferredNVAlignment() const { + assert(CXXInfo && "Record layout does not have C++ specific info!"); + + return CXXInfo->PreferredNVAlignment; + } + /// getPrimaryBase - Get the primary base for this record. const CXXRecordDecl *getPrimaryBase() const { assert(CXXInfo && "Record layout does not have C++ specific info!"); @@ -231,6 +248,8 @@ class ASTRecordLayout { /// getBaseClassOffset - Get the offset, in chars, for the given base class. CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const { assert(CXXInfo && "Record layout does not have C++ specific info!"); + + Base = Base->getDefinition(); assert(CXXInfo->BaseOffsets.count(Base) && "Did not find base!"); return CXXInfo->BaseOffsets[Base]; @@ -239,6 +258,8 @@ class ASTRecordLayout { /// getVBaseClassOffset - Get the offset, in chars, for the given base class. CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const { assert(CXXInfo && "Record layout does not have C++ specific info!"); + + VBase = VBase->getDefinition(); assert(CXXInfo->VBaseOffsets.count(VBase) && "Did not find base!"); return CXXInfo->VBaseOffsets[VBase].VBaseOffset; @@ -287,9 +308,7 @@ class ASTRecordLayout { return !CXXInfo->VBPtrOffset.isNegative(); } - CharUnits getRequiredAlignment() const { - return RequiredAlignment; - } + CharUnits getRequiredAlignment() const { return RequiredAlignment; } bool endsWithZeroSizedObject() const { return CXXInfo && CXXInfo->EndsWithZeroSizedObject; diff --git a/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h b/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h index 3dcfc9fee629ac..7870cea198a7f5 100644 --- a/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h @@ -186,6 +186,9 @@ template class RecursiveASTVisitor { /// code, e.g., implicit constructors and destructors. bool shouldVisitImplicitCode() const { return false; } + /// Return whether this visitor should recurse into lambda body + bool shouldVisitLambdaBody() const { return true; } + /// Return whether this visitor should traverse post-order. bool shouldTraversePostOrder() const { return false; } @@ -461,6 +464,15 @@ template class RecursiveASTVisitor { bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child); +#define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \ + bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D); + DEF_TRAVERSE_TMPL_INST(Class) + DEF_TRAVERSE_TMPL_INST(Var) + DEF_TRAVERSE_TMPL_INST(Function) +#undef DEF_TRAVERSE_TMPL_INST + + bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue); + private: // These are helper methods used by more than one Traverse* method. bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL); @@ -469,12 +481,6 @@ template class RecursiveASTVisitor { template bool TraverseDeclTemplateParameterLists(T *D); -#define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \ - bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D); - DEF_TRAVERSE_TMPL_INST(Class) - DEF_TRAVERSE_TMPL_INST(Var) - DEF_TRAVERSE_TMPL_INST(Function) -#undef DEF_TRAVERSE_TMPL_INST bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL, unsigned Count); bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL); @@ -487,15 +493,15 @@ template class RecursiveASTVisitor { bool TraverseOMPExecutableDirective(OMPExecutableDirective *S); bool TraverseOMPLoopDirective(OMPLoopDirective *S); bool TraverseOMPClause(OMPClause *C); -#define OMP_CLAUSE_CLASS(Enum, Str, Class) bool Visit##Class(Class *C); -#include "llvm/Frontend/OpenMP/OMPKinds.def" +#define GEN_CLANG_CLAUSE_CLASS +#define CLAUSE_CLASS(Enum, Str, Class) bool Visit##Class(Class *C); +#include "llvm/Frontend/OpenMP/OMP.inc" /// Process clauses with list of variables. template bool VisitOMPClauseList(T *Node); /// Process clauses with pre-initis. bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node); bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node); - bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue); bool PostVisitStmt(Stmt *S); }; @@ -1777,8 +1783,17 @@ DEF_TRAVERSE_DECL(TemplateTypeParmDecl, { // D is the "T" in something like "template class vector;" if (D->getTypeForDecl()) TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0))); - if (const auto *TC = D->getTypeConstraint()) - TRY_TO(TraverseConceptReference(*TC)); + if (const auto *TC = D->getTypeConstraint()) { + if (Expr *IDC = TC->getImmediatelyDeclaredConstraint()) { + TRY_TO(TraverseStmt(IDC)); + } else { + // Avoid traversing the ConceptReference in the TypeCosntraint + // if we have an immediately-declared-constraint, otherwise + // we'll end up visiting the concept and the arguments in + // the TC twice. + TRY_TO(TraverseConceptReference(*TC)); + } + } if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc())); }) @@ -1961,6 +1976,8 @@ DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); }) DEF_TRAVERSE_DECL(MSGuidDecl, {}) +DEF_TRAVERSE_DECL(TemplateParamObjectDecl, {}) + DEF_TRAVERSE_DECL(FieldDecl, { TRY_TO(TraverseDeclaratorHelper(D)); if (D->isBitField()) @@ -2043,6 +2060,15 @@ bool RecursiveASTVisitor::TraverseFunctionHelper(FunctionDecl *D) { // by clang. (!D->isDefaulted() || getDerived().shouldVisitImplicitCode()); + if (const auto *MD = dyn_cast(D)) { + if (const CXXRecordDecl *RD = MD->getParent()) { + if (RD->isLambda() && + declaresSameEntity(RD->getLambdaCallOperator(), MD)) { + VisitBody = VisitBody && getDerived().shouldVisitLambdaBody(); + } + } + } + if (VisitBody) { TRY_TO(TraverseStmt(D->getBody())); // Function body. } @@ -2491,17 +2517,12 @@ DEF_TRAVERSE_STMT(LambdaExpr, { TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc(); FunctionProtoTypeLoc Proto = TL.getAsAdjusted(); - for (Decl *D : S->getExplicitTemplateParameters()) { - // Visit explicit template parameters. - TRY_TO(TraverseDecl(D)); - } + TRY_TO(TraverseTemplateParameterListHelper(S->getTemplateParameterList())); if (S->hasExplicitParameters()) { // Visit parameters. for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I) TRY_TO(TraverseDecl(Proto.getParam(I))); } - if (S->hasExplicitResultType()) - TRY_TO(TraverseTypeLoc(Proto.getReturnLoc())); auto *T = Proto.getTypePtr(); for (const auto &E : T->exceptions()) @@ -2510,6 +2531,10 @@ DEF_TRAVERSE_STMT(LambdaExpr, { if (Expr *NE = T->getNoexceptExpr()) TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(NE); + if (S->hasExplicitResultType()) + TRY_TO(TraverseTypeLoc(Proto.getReturnLoc())); + TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getTrailingRequiresClause()); + TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody()); } ShouldVisitChildren = false; @@ -2938,16 +2963,15 @@ bool RecursiveASTVisitor::TraverseOMPClause(OMPClause *C) { if (!C) return true; switch (C->getClauseKind()) { -#define OMP_CLAUSE_CLASS(Enum, Str, Class) \ +#define GEN_CLANG_CLAUSE_CLASS +#define CLAUSE_CLASS(Enum, Str, Class) \ case llvm::omp::Clause::Enum: \ TRY_TO(Visit##Class(static_cast(C))); \ break; -#define OMP_CLAUSE_NO_CLASS(Enum, Str) \ +#define CLAUSE_NO_CLASS(Enum, Str) \ case llvm::omp::Clause::Enum: \ break; -#include "llvm/Frontend/OpenMP/OMPKinds.def" - default: - break; +#include "llvm/Frontend/OpenMP/OMP.inc" } return true; } diff --git a/contrib/llvm-project/clang/include/clang/AST/Redeclarable.h b/contrib/llvm-project/clang/include/clang/AST/Redeclarable.h index 0975773dd2cb57..87252337a0f4b5 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Redeclarable.h +++ b/contrib/llvm-project/clang/include/clang/AST/Redeclarable.h @@ -370,6 +370,7 @@ template class CanonicalDeclPtr { private: friend struct llvm::DenseMapInfo>; + friend struct llvm::PointerLikeTypeTraits>; decl_type *Ptr = nullptr; }; @@ -407,6 +408,20 @@ struct DenseMapInfo> { } }; +template +struct PointerLikeTypeTraits> { + static inline void *getAsVoidPointer(clang::CanonicalDeclPtr P) { + return P.Ptr; + } + static inline clang::CanonicalDeclPtr getFromVoidPointer(void *P) { + clang::CanonicalDeclPtr C; + C.Ptr = PointerLikeTypeTraits::getFromVoidPtr(P); + return C; + } + static constexpr int NumLowBitsAvailable = + PointerLikeTypeTraits::NumLowBitsAvailable; +}; + } // namespace llvm #endif // LLVM_CLANG_AST_REDECLARABLE_H diff --git a/contrib/llvm-project/clang/include/clang/AST/Stmt.h b/contrib/llvm-project/clang/include/clang/AST/Stmt.h index d3fad58fcf5968..c2e69a91e55d09 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Stmt.h +++ b/contrib/llvm-project/clang/include/clang/AST/Stmt.h @@ -464,8 +464,11 @@ class alignas(void *) Stmt { /// True if the callee of the call expression was found using ADL. unsigned UsesADL : 1; + /// True if the call expression has some floating-point features. + unsigned HasFPFeatures : 1; + /// Padding used to align OffsetToTrailingObjects to a byte multiple. - unsigned : 24 - 2 - NumExprBits; + unsigned : 24 - 3 - NumExprBits; /// The offset in bytes from the this pointer to the start of the /// trailing objects belonging to CallExpr. Intentionally byte sized @@ -518,6 +521,9 @@ class alignas(void *) Stmt { unsigned Kind : 6; unsigned PartOfExplicitCast : 1; // Only set for ImplicitCastExpr. + /// True if the call expression has some floating-point features. + unsigned HasFPFeatures : 1; + /// The number of CXXBaseSpecifiers in the cast. 14 bits would be enough /// here. ([implimits] Direct and indirect base classes [16384]). unsigned BasePathSize; @@ -1095,6 +1101,14 @@ class alignas(void *) Stmt { /// de-serialization). struct EmptyShell {}; + /// The likelihood of a branch being taken. + enum Likelihood { + LH_Unlikely = -1, ///< Branch has the [[unlikely]] attribute. + LH_None, ///< No attribute set or branches of the IfStmt have + ///< the same attribute. + LH_Likely ///< Branch has the [[likely]] attribute. + }; + protected: /// Iterator for iterating over Stmt * arrays that contain only T *. /// @@ -1163,6 +1177,26 @@ class alignas(void *) Stmt { static void EnableStatistics(); static void PrintStats(); + /// \returns the likelihood of a set of attributes. + static Likelihood getLikelihood(ArrayRef Attrs); + + /// \returns the likelihood of a statement. + static Likelihood getLikelihood(const Stmt *S); + + /// \returns the likelihood attribute of a statement. + static const Attr *getLikelihoodAttr(const Stmt *S); + + /// \returns the likelihood of the 'then' branch of an 'if' statement. The + /// 'else' branch is required to determine whether both branches specify the + /// same likelihood, which affects the result. + static Likelihood getLikelihood(const Stmt *Then, const Stmt *Else); + + /// \returns whether the likelihood of the branches of an if statement are + /// conflicting. When the first element is \c true there's a conflict and + /// the Attr's are the conflicting attributes of the Then and Else Stmt. + static std::tuple + determineLikelihoodConflict(const Stmt *Then, const Stmt *Else); + /// Dumps the specified AST fragment and all subtrees to /// \c llvm::errs(). void dump() const; @@ -1892,6 +1926,8 @@ class IfStmt final // Present if and only if hasElseStorage(). enum { InitOffset = 0, ThenOffsetFromCond = 1, ElseOffsetFromCond = 2 }; enum { NumMandatoryStmtPtr = 2 }; + SourceLocation LParenLoc; + SourceLocation RParenLoc; unsigned numTrailingObjects(OverloadToken) const { return NumMandatoryStmtPtr + hasElseStorage() + hasVarStorage() + @@ -1912,7 +1948,8 @@ class IfStmt final /// Build an if/then/else statement. IfStmt(const ASTContext &Ctx, SourceLocation IL, bool IsConstexpr, Stmt *Init, - VarDecl *Var, Expr *Cond, Stmt *Then, SourceLocation EL, Stmt *Else); + VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, + SourceLocation RParenLoc, Stmt *Then, SourceLocation EL, Stmt *Else); /// Build an empty if/then/else statement. explicit IfStmt(EmptyShell Empty, bool HasElse, bool HasVar, bool HasInit); @@ -1921,7 +1958,8 @@ class IfStmt final /// Create an IfStmt. static IfStmt *Create(const ASTContext &Ctx, SourceLocation IL, bool IsConstexpr, Stmt *Init, VarDecl *Var, Expr *Cond, - Stmt *Then, SourceLocation EL = SourceLocation(), + SourceLocation LPL, SourceLocation RPL, Stmt *Then, + SourceLocation EL = SourceLocation(), Stmt *Else = nullptr); /// Create an empty IfStmt optionally with storage for an else statement, @@ -2051,6 +2089,10 @@ class IfStmt final return getElse()->getEndLoc(); return getThen()->getEndLoc(); } + SourceLocation getLParenLoc() const { return LParenLoc; } + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + SourceLocation getRParenLoc() const { return RParenLoc; } + void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } // Iterators over subexpressions. The iterators will include iterating // over the initialization expression referenced by the condition variable. @@ -2098,6 +2140,8 @@ class SwitchStmt final : public Stmt, // Always present. enum { InitOffset = 0, BodyOffsetFromCond = 1 }; enum { NumMandatoryStmtPtr = 2 }; + SourceLocation LParenLoc; + SourceLocation RParenLoc; unsigned numTrailingObjects(OverloadToken) const { return NumMandatoryStmtPtr + hasInitStorage() + hasVarStorage(); @@ -2111,7 +2155,8 @@ class SwitchStmt final : public Stmt, unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; } /// Build a switch statement. - SwitchStmt(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond); + SwitchStmt(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond, + SourceLocation LParenLoc, SourceLocation RParenLoc); /// Build a empty switch statement. explicit SwitchStmt(EmptyShell Empty, bool HasInit, bool HasVar); @@ -2119,7 +2164,8 @@ class SwitchStmt final : public Stmt, public: /// Create a switch statement. static SwitchStmt *Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, - Expr *Cond); + Expr *Cond, SourceLocation LParenLoc, + SourceLocation RParenLoc); /// Create an empty switch statement optionally with storage for /// an init expression and a condition variable. @@ -2207,6 +2253,10 @@ class SwitchStmt final : public Stmt, SourceLocation getSwitchLoc() const { return SwitchStmtBits.SwitchLoc; } void setSwitchLoc(SourceLocation L) { SwitchStmtBits.SwitchLoc = L; } + SourceLocation getLParenLoc() const { return LParenLoc; } + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + SourceLocation getRParenLoc() const { return RParenLoc; } + void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } void setBody(Stmt *S, SourceLocation SL) { setBody(S); diff --git a/contrib/llvm-project/clang/include/clang/AST/StmtIterator.h b/contrib/llvm-project/clang/include/clang/AST/StmtIterator.h index 911205347aadca..bcdb0df829fba2 100644 --- a/contrib/llvm-project/clang/include/clang/AST/StmtIterator.h +++ b/contrib/llvm-project/clang/include/clang/AST/StmtIterator.h @@ -104,12 +104,13 @@ class StmtIteratorImpl : public StmtIteratorBase, return tmp; } - bool operator==(const DERIVED& RHS) const { - return stmt == RHS.stmt && DGI == RHS.DGI && RawVAPtr == RHS.RawVAPtr; + friend bool operator==(const DERIVED &LHS, const DERIVED &RHS) { + return LHS.stmt == RHS.stmt && LHS.DGI == RHS.DGI && + LHS.RawVAPtr == RHS.RawVAPtr; } - bool operator!=(const DERIVED& RHS) const { - return stmt != RHS.stmt || DGI != RHS.DGI || RawVAPtr != RHS.RawVAPtr; + friend bool operator!=(const DERIVED &LHS, const DERIVED &RHS) { + return !(LHS == RHS); } REFERENCE operator*() const { diff --git a/contrib/llvm-project/clang/include/clang/AST/StmtOpenMP.h b/contrib/llvm-project/clang/include/clang/AST/StmtOpenMP.h index bd87eafc903485..b7bbf15949a00d 100644 --- a/contrib/llvm-project/clang/include/clang/AST/StmtOpenMP.h +++ b/contrib/llvm-project/clang/include/clang/AST/StmtOpenMP.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_STMTOPENMP_H #define LLVM_CLANG_AST_STMTOPENMP_H +#include "clang/AST/ASTContext.h" #include "clang/AST/Expr.h" #include "clang/AST/OpenMPClause.h" #include "clang/AST/Stmt.h" @@ -32,30 +33,26 @@ namespace clang { /// class OMPExecutableDirective : public Stmt { friend class ASTStmtReader; + friend class ASTStmtWriter; + /// Kind of the directive. - OpenMPDirectiveKind Kind; + OpenMPDirectiveKind Kind = llvm::omp::OMPD_unknown; /// Starting location of the directive (directive keyword). SourceLocation StartLoc; /// Ending location of the directive. SourceLocation EndLoc; - /// Numbers of clauses. - const unsigned NumClauses; - /// Number of child expressions/stmts. - const unsigned NumChildren; - /// Offset from this to the start of clauses. - /// There are NumClauses pointers to clauses, they are followed by - /// NumChildren pointers to child stmts/exprs (if the directive type - /// requires an associated stmt, then it has to be the first of them). - const unsigned ClausesOffset; /// Get the clauses storage. MutableArrayRef getClauses() { - OMPClause **ClauseStorage = reinterpret_cast( - reinterpret_cast(this) + ClausesOffset); - return MutableArrayRef(ClauseStorage, NumClauses); + if (!Data) + return llvm::None; + return Data->getClauses(); } protected: + /// Data, associated with the directive. + OMPChildren *Data = nullptr; + /// Build instance of directive of class \a K. /// /// \param SC Statement class. @@ -63,28 +60,57 @@ class OMPExecutableDirective : public Stmt { /// \param StartLoc Starting location of the directive (directive keyword). /// \param EndLoc Ending location of the directive. /// - template - OMPExecutableDirective(const T *, StmtClass SC, OpenMPDirectiveKind K, - SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses, unsigned NumChildren) + OMPExecutableDirective(StmtClass SC, OpenMPDirectiveKind K, + SourceLocation StartLoc, SourceLocation EndLoc) : Stmt(SC), Kind(K), StartLoc(std::move(StartLoc)), - EndLoc(std::move(EndLoc)), NumClauses(NumClauses), - NumChildren(NumChildren), - ClausesOffset(llvm::alignTo(sizeof(T), alignof(OMPClause *))) {} - - /// Sets the list of variables for this clause. - /// - /// \param Clauses The list of clauses for the directive. - /// - void setClauses(ArrayRef Clauses); + EndLoc(std::move(EndLoc)) {} + + template + static T *createDirective(const ASTContext &C, ArrayRef Clauses, + Stmt *AssociatedStmt, unsigned NumChildren, + Params &&... P) { + void *Mem = + C.Allocate(sizeof(T) + OMPChildren::size(Clauses.size(), AssociatedStmt, + NumChildren), + alignof(T)); + + auto *Data = OMPChildren::Create(reinterpret_cast(Mem) + 1, Clauses, + AssociatedStmt, NumChildren); + auto *Inst = new (Mem) T(std::forward(P)...); + Inst->Data = Data; + return Inst; + } + + template + static T *createEmptyDirective(const ASTContext &C, unsigned NumClauses, + bool HasAssociatedStmt, unsigned NumChildren, + Params &&... P) { + void *Mem = + C.Allocate(sizeof(T) + OMPChildren::size(NumClauses, HasAssociatedStmt, + NumChildren), + alignof(T)); + auto *Data = + OMPChildren::CreateEmpty(reinterpret_cast(Mem) + 1, NumClauses, + HasAssociatedStmt, NumChildren); + auto *Inst = new (Mem) T(std::forward(P)...); + Inst->Data = Data; + return Inst; + } - /// Set the associated statement for the directive. - /// - /// /param S Associated statement. - /// - void setAssociatedStmt(Stmt *S) { - assert(hasAssociatedStmt() && "no associated statement."); - *child_begin() = S; + template + static T *createEmptyDirective(const ASTContext &C, unsigned NumClauses, + bool HasAssociatedStmt = false, + unsigned NumChildren = 0) { + void *Mem = + C.Allocate(sizeof(T) + OMPChildren::size(NumClauses, HasAssociatedStmt, + NumChildren), + alignof(T)); + auto *Data = + OMPChildren::CreateEmpty(reinterpret_cast(Mem) + 1, NumClauses, + HasAssociatedStmt, NumChildren); + auto *Inst = new (Mem) T; + Inst->Data = Data; + return Inst; } public: @@ -238,59 +264,50 @@ class OMPExecutableDirective : public Stmt { void setLocEnd(SourceLocation Loc) { EndLoc = Loc; } /// Get number of clauses. - unsigned getNumClauses() const { return NumClauses; } + unsigned getNumClauses() const { + if (!Data) + return 0; + return Data->getNumClauses(); + } /// Returns specified clause. /// - /// \param i Number of clause. + /// \param I Number of clause. /// - OMPClause *getClause(unsigned i) const { return clauses()[i]; } + OMPClause *getClause(unsigned I) const { return clauses()[I]; } /// Returns true if directive has associated statement. - bool hasAssociatedStmt() const { return NumChildren > 0; } + bool hasAssociatedStmt() const { return Data && Data->hasAssociatedStmt(); } /// Returns statement associated with the directive. const Stmt *getAssociatedStmt() const { - assert(hasAssociatedStmt() && "no associated statement."); - return *child_begin(); + return const_cast(this)->getAssociatedStmt(); } Stmt *getAssociatedStmt() { - assert(hasAssociatedStmt() && "no associated statement."); - return *child_begin(); + assert(hasAssociatedStmt() && + "Expected directive with the associated statement."); + return Data->getAssociatedStmt(); } /// Returns the captured statement associated with the /// component region within the (combined) directive. - // - // \param RegionKind Component region kind. + /// + /// \param RegionKind Component region kind. const CapturedStmt *getCapturedStmt(OpenMPDirectiveKind RegionKind) const { + assert(hasAssociatedStmt() && + "Expected directive with the associated statement."); SmallVector CaptureRegions; getOpenMPCaptureRegions(CaptureRegions, getDirectiveKind()); - assert(std::any_of( - CaptureRegions.begin(), CaptureRegions.end(), - [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) && - "RegionKind not found in OpenMP CaptureRegions."); - auto *CS = cast(getAssociatedStmt()); - for (auto ThisCaptureRegion : CaptureRegions) { - if (ThisCaptureRegion == RegionKind) - return CS; - CS = cast(CS->getCapturedStmt()); - } - llvm_unreachable("Incorrect RegionKind specified for directive."); + return Data->getCapturedStmt(RegionKind, CaptureRegions); } /// Get innermost captured statement for the construct. CapturedStmt *getInnermostCapturedStmt() { - assert(hasAssociatedStmt() && getAssociatedStmt() && - "Must have associated statement."); + assert(hasAssociatedStmt() && + "Expected directive with the associated statement."); SmallVector CaptureRegions; getOpenMPCaptureRegions(CaptureRegions, getDirectiveKind()); - assert(!CaptureRegions.empty() && - "At least one captured statement must be provided."); - auto *CS = cast(getAssociatedStmt()); - for (unsigned Level = CaptureRegions.size(); Level > 1; --Level) - CS = cast(CS->getCapturedStmt()); - return CS; + return Data->getInnermostCapturedStmt(CaptureRegions); } const CapturedStmt *getInnermostCapturedStmt() const { @@ -306,26 +323,19 @@ class OMPExecutableDirective : public Stmt { } child_range children() { - if (!hasAssociatedStmt()) + if (!Data) return child_range(child_iterator(), child_iterator()); - Stmt **ChildStorage = reinterpret_cast(getClauses().end()); - /// Do not mark all the special expression/statements as children, except - /// for the associated statement. - return child_range(ChildStorage, ChildStorage + 1); + return Data->getAssociatedStmtAsRange(); } const_child_range children() const { - if (!hasAssociatedStmt()) - return const_child_range(const_child_iterator(), const_child_iterator()); - Stmt **ChildStorage = reinterpret_cast( - const_cast(this)->getClauses().end()); - return const_child_range(ChildStorage, ChildStorage + 1); + return const_cast(this)->children(); } - ArrayRef clauses() { return getClauses(); } - ArrayRef clauses() const { - return const_cast(this)->getClauses(); + if (!Data) + return llvm::None; + return Data->getClauses(); } /// Returns whether or not this is a Standalone directive. @@ -337,11 +347,18 @@ class OMPExecutableDirective : public Stmt { /// Returns the AST node representing OpenMP structured-block of this /// OpenMP executable directive, /// Prerequisite: Executable Directive must not be Standalone directive. - const Stmt *getStructuredBlock() const; + const Stmt *getStructuredBlock() const { + return const_cast(this)->getStructuredBlock(); + } + Stmt *getStructuredBlock(); - Stmt *getStructuredBlock() { - return const_cast( - const_cast(this)->getStructuredBlock()); + const Stmt *getRawStmt() const { + return const_cast(this)->getRawStmt(); + } + Stmt *getRawStmt() { + assert(hasAssociatedStmt() && + "Expected directive with the associated statement."); + return Data->getRawStmt(); } }; @@ -356,36 +373,28 @@ class OMPExecutableDirective : public Stmt { /// class OMPParallelDirective : public OMPExecutableDirective { friend class ASTStmtReader; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; + friend class OMPExecutableDirective; /// true if the construct has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive (directive keyword). /// \param EndLoc Ending Location of the directive. /// - OMPParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPParallelDirectiveClass, - llvm::omp::OMPD_parallel, StartLoc, EndLoc, - NumClauses, 1), - HasCancel(false) {} + OMPParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPParallelDirectiveClass, + llvm::omp::OMPD_parallel, StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPParallelDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPParallelDirectiveClass, + explicit OMPParallelDirective() + : OMPExecutableDirective(OMPParallelDirectiveClass, llvm::omp::OMPD_parallel, SourceLocation(), - SourceLocation(), NumClauses, 1), - HasCancel(false) {} + SourceLocation()) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -416,8 +425,12 @@ class OMPParallelDirective : public OMPExecutableDirective { unsigned NumClauses, EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[0]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this)->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -433,7 +446,7 @@ class OMPParallelDirective : public OMPExecutableDirective { class OMPLoopDirective : public OMPExecutableDirective { friend class ASTStmtReader; /// Number of collapsed loops as specified by 'collapse' clause. - unsigned CollapsedNum; + unsigned CollapsedNum = 0; /// Offsets to the stored exprs. /// This enumeration contains offsets to all the pointers to children @@ -452,110 +465,110 @@ class OMPLoopDirective : public OMPExecutableDirective { /// (e.g. 'distribute parallel for') /// enum { - AssociatedStmtOffset = 0, - IterationVariableOffset = 1, - LastIterationOffset = 2, - CalcLastIterationOffset = 3, - PreConditionOffset = 4, - CondOffset = 5, - InitOffset = 6, - IncOffset = 7, - PreInitsOffset = 8, + IterationVariableOffset = 0, + LastIterationOffset = 1, + CalcLastIterationOffset = 2, + PreConditionOffset = 3, + CondOffset = 4, + InitOffset = 5, + IncOffset = 6, + PreInitsOffset = 7, // The '...End' enumerators do not correspond to child expressions - they // specify the offset to the end (and start of the following counters/ // updates/finals/dependent_counters/dependent_inits/finals_conditions // arrays). - DefaultEnd = 9, + DefaultEnd = 8, // The following 8 exprs are used by worksharing and distribute loops only. - IsLastIterVariableOffset = 9, - LowerBoundVariableOffset = 10, - UpperBoundVariableOffset = 11, - StrideVariableOffset = 12, - EnsureUpperBoundOffset = 13, - NextLowerBoundOffset = 14, - NextUpperBoundOffset = 15, - NumIterationsOffset = 16, + IsLastIterVariableOffset = 8, + LowerBoundVariableOffset = 9, + UpperBoundVariableOffset = 10, + StrideVariableOffset = 11, + EnsureUpperBoundOffset = 12, + NextLowerBoundOffset = 13, + NextUpperBoundOffset = 14, + NumIterationsOffset = 15, // Offset to the end for worksharing loop directives. - WorksharingEnd = 17, - PrevLowerBoundVariableOffset = 17, - PrevUpperBoundVariableOffset = 18, - DistIncOffset = 19, - PrevEnsureUpperBoundOffset = 20, - CombinedLowerBoundVariableOffset = 21, - CombinedUpperBoundVariableOffset = 22, - CombinedEnsureUpperBoundOffset = 23, - CombinedInitOffset = 24, - CombinedConditionOffset = 25, - CombinedNextLowerBoundOffset = 26, - CombinedNextUpperBoundOffset = 27, - CombinedDistConditionOffset = 28, - CombinedParForInDistConditionOffset = 29, + WorksharingEnd = 16, + PrevLowerBoundVariableOffset = 16, + PrevUpperBoundVariableOffset = 17, + DistIncOffset = 18, + PrevEnsureUpperBoundOffset = 19, + CombinedLowerBoundVariableOffset = 20, + CombinedUpperBoundVariableOffset = 21, + CombinedEnsureUpperBoundOffset = 22, + CombinedInitOffset = 23, + CombinedConditionOffset = 24, + CombinedNextLowerBoundOffset = 25, + CombinedNextUpperBoundOffset = 26, + CombinedDistConditionOffset = 27, + CombinedParForInDistConditionOffset = 28, // Offset to the end (and start of the following // counters/updates/finals/dependent_counters/dependent_inits/finals_conditions // arrays) for combined distribute loop directives. - CombinedDistributeEnd = 30, + CombinedDistributeEnd = 29, }; /// Get the counters storage. MutableArrayRef getCounters() { - Expr **Storage = reinterpret_cast( - &(*(std::next(child_begin(), getArraysOffset(getDirectiveKind()))))); - return MutableArrayRef(Storage, CollapsedNum); + auto **Storage = reinterpret_cast( + &Data->getChildren()[getArraysOffset(getDirectiveKind())]); + return llvm::makeMutableArrayRef(Storage, CollapsedNum); } /// Get the private counters storage. MutableArrayRef getPrivateCounters() { - Expr **Storage = reinterpret_cast(&*std::next( - child_begin(), getArraysOffset(getDirectiveKind()) + CollapsedNum)); - return MutableArrayRef(Storage, CollapsedNum); + auto **Storage = reinterpret_cast( + &Data->getChildren()[getArraysOffset(getDirectiveKind()) + + CollapsedNum]); + return llvm::makeMutableArrayRef(Storage, CollapsedNum); } /// Get the updates storage. MutableArrayRef getInits() { - Expr **Storage = reinterpret_cast( - &*std::next(child_begin(), - getArraysOffset(getDirectiveKind()) + 2 * CollapsedNum)); - return MutableArrayRef(Storage, CollapsedNum); + auto **Storage = reinterpret_cast( + &Data->getChildren()[getArraysOffset(getDirectiveKind()) + + 2 * CollapsedNum]); + return llvm::makeMutableArrayRef(Storage, CollapsedNum); } /// Get the updates storage. MutableArrayRef getUpdates() { - Expr **Storage = reinterpret_cast( - &*std::next(child_begin(), - getArraysOffset(getDirectiveKind()) + 3 * CollapsedNum)); - return MutableArrayRef(Storage, CollapsedNum); + auto **Storage = reinterpret_cast( + &Data->getChildren()[getArraysOffset(getDirectiveKind()) + + 3 * CollapsedNum]); + return llvm::makeMutableArrayRef(Storage, CollapsedNum); } /// Get the final counter updates storage. MutableArrayRef getFinals() { - Expr **Storage = reinterpret_cast( - &*std::next(child_begin(), - getArraysOffset(getDirectiveKind()) + 4 * CollapsedNum)); - return MutableArrayRef(Storage, CollapsedNum); + auto **Storage = reinterpret_cast( + &Data->getChildren()[getArraysOffset(getDirectiveKind()) + + 4 * CollapsedNum]); + return llvm::makeMutableArrayRef(Storage, CollapsedNum); } /// Get the dependent counters storage. MutableArrayRef getDependentCounters() { - Expr **Storage = reinterpret_cast( - &*std::next(child_begin(), - getArraysOffset(getDirectiveKind()) + 5 * CollapsedNum)); - return MutableArrayRef(Storage, CollapsedNum); + auto **Storage = reinterpret_cast( + &Data->getChildren()[getArraysOffset(getDirectiveKind()) + + 5 * CollapsedNum]); + return llvm::makeMutableArrayRef(Storage, CollapsedNum); } /// Get the dependent inits storage. MutableArrayRef getDependentInits() { - Expr **Storage = reinterpret_cast( - &*std::next(child_begin(), - getArraysOffset(getDirectiveKind()) + 6 * CollapsedNum)); - return MutableArrayRef(Storage, CollapsedNum); + auto **Storage = reinterpret_cast( + &Data->getChildren()[getArraysOffset(getDirectiveKind()) + + 6 * CollapsedNum]); + return llvm::makeMutableArrayRef(Storage, CollapsedNum); } /// Get the finals conditions storage. MutableArrayRef getFinalsConditions() { - Expr **Storage = reinterpret_cast( - &*std::next(child_begin(), - getArraysOffset(getDirectiveKind()) + 7 * CollapsedNum)); - return MutableArrayRef(Storage, CollapsedNum); + auto **Storage = reinterpret_cast( + &Data->getChildren()[getArraysOffset(getDirectiveKind()) + + 7 * CollapsedNum]); + return llvm::makeMutableArrayRef(Storage, CollapsedNum); } protected: @@ -566,17 +579,11 @@ class OMPLoopDirective : public OMPExecutableDirective { /// \param StartLoc Starting location of the directive (directive keyword). /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed loops from 'collapse' clause. - /// \param NumClauses Number of clauses. - /// \param NumSpecialChildren Number of additional directive-specific stmts. /// - template - OMPLoopDirective(const T *That, StmtClass SC, OpenMPDirectiveKind Kind, + OMPLoopDirective(StmtClass SC, OpenMPDirectiveKind Kind, SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses, - unsigned NumSpecialChildren = 0) - : OMPExecutableDirective(That, SC, Kind, StartLoc, EndLoc, NumClauses, - numLoopChildren(CollapsedNum, Kind) + - NumSpecialChildren), + unsigned CollapsedNum) + : OMPExecutableDirective(SC, Kind, StartLoc, EndLoc), CollapsedNum(CollapsedNum) {} /// Offset to the start of children expression arrays. @@ -599,146 +606,142 @@ class OMPLoopDirective : public OMPExecutableDirective { } void setIterationVariable(Expr *IV) { - *std::next(child_begin(), IterationVariableOffset) = IV; + Data->getChildren()[IterationVariableOffset] = IV; } void setLastIteration(Expr *LI) { - *std::next(child_begin(), LastIterationOffset) = LI; + Data->getChildren()[LastIterationOffset] = LI; } void setCalcLastIteration(Expr *CLI) { - *std::next(child_begin(), CalcLastIterationOffset) = CLI; - } - void setPreCond(Expr *PC) { - *std::next(child_begin(), PreConditionOffset) = PC; + Data->getChildren()[CalcLastIterationOffset] = CLI; } - void setCond(Expr *Cond) { - *std::next(child_begin(), CondOffset) = Cond; - } - void setInit(Expr *Init) { *std::next(child_begin(), InitOffset) = Init; } - void setInc(Expr *Inc) { *std::next(child_begin(), IncOffset) = Inc; } + void setPreCond(Expr *PC) { Data->getChildren()[PreConditionOffset] = PC; } + void setCond(Expr *Cond) { Data->getChildren()[CondOffset] = Cond; } + void setInit(Expr *Init) { Data->getChildren()[InitOffset] = Init; } + void setInc(Expr *Inc) { Data->getChildren()[IncOffset] = Inc; } void setPreInits(Stmt *PreInits) { - *std::next(child_begin(), PreInitsOffset) = PreInits; + Data->getChildren()[PreInitsOffset] = PreInits; } void setIsLastIterVariable(Expr *IL) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - *std::next(child_begin(), IsLastIterVariableOffset) = IL; + Data->getChildren()[IsLastIterVariableOffset] = IL; } void setLowerBoundVariable(Expr *LB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - *std::next(child_begin(), LowerBoundVariableOffset) = LB; + Data->getChildren()[LowerBoundVariableOffset] = LB; } void setUpperBoundVariable(Expr *UB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - *std::next(child_begin(), UpperBoundVariableOffset) = UB; + Data->getChildren()[UpperBoundVariableOffset] = UB; } void setStrideVariable(Expr *ST) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - *std::next(child_begin(), StrideVariableOffset) = ST; + Data->getChildren()[StrideVariableOffset] = ST; } void setEnsureUpperBound(Expr *EUB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - *std::next(child_begin(), EnsureUpperBoundOffset) = EUB; + Data->getChildren()[EnsureUpperBoundOffset] = EUB; } void setNextLowerBound(Expr *NLB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - *std::next(child_begin(), NextLowerBoundOffset) = NLB; + Data->getChildren()[NextLowerBoundOffset] = NLB; } void setNextUpperBound(Expr *NUB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - *std::next(child_begin(), NextUpperBoundOffset) = NUB; + Data->getChildren()[NextUpperBoundOffset] = NUB; } void setNumIterations(Expr *NI) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - *std::next(child_begin(), NumIterationsOffset) = NI; + Data->getChildren()[NumIterationsOffset] = NI; } void setPrevLowerBoundVariable(Expr *PrevLB) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), PrevLowerBoundVariableOffset) = PrevLB; + Data->getChildren()[PrevLowerBoundVariableOffset] = PrevLB; } void setPrevUpperBoundVariable(Expr *PrevUB) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), PrevUpperBoundVariableOffset) = PrevUB; + Data->getChildren()[PrevUpperBoundVariableOffset] = PrevUB; } void setDistInc(Expr *DistInc) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), DistIncOffset) = DistInc; + Data->getChildren()[DistIncOffset] = DistInc; } void setPrevEnsureUpperBound(Expr *PrevEUB) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), PrevEnsureUpperBoundOffset) = PrevEUB; + Data->getChildren()[PrevEnsureUpperBoundOffset] = PrevEUB; } void setCombinedLowerBoundVariable(Expr *CombLB) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), CombinedLowerBoundVariableOffset) = CombLB; + Data->getChildren()[CombinedLowerBoundVariableOffset] = CombLB; } void setCombinedUpperBoundVariable(Expr *CombUB) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), CombinedUpperBoundVariableOffset) = CombUB; + Data->getChildren()[CombinedUpperBoundVariableOffset] = CombUB; } void setCombinedEnsureUpperBound(Expr *CombEUB) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), CombinedEnsureUpperBoundOffset) = CombEUB; + Data->getChildren()[CombinedEnsureUpperBoundOffset] = CombEUB; } void setCombinedInit(Expr *CombInit) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), CombinedInitOffset) = CombInit; + Data->getChildren()[CombinedInitOffset] = CombInit; } void setCombinedCond(Expr *CombCond) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), CombinedConditionOffset) = CombCond; + Data->getChildren()[CombinedConditionOffset] = CombCond; } void setCombinedNextLowerBound(Expr *CombNLB) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), CombinedNextLowerBoundOffset) = CombNLB; + Data->getChildren()[CombinedNextLowerBoundOffset] = CombNLB; } void setCombinedNextUpperBound(Expr *CombNUB) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - *std::next(child_begin(), CombinedNextUpperBoundOffset) = CombNUB; + Data->getChildren()[CombinedNextUpperBoundOffset] = CombNUB; } void setCombinedDistCond(Expr *CombDistCond) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound distribute sharing directive"); - *std::next(child_begin(), CombinedDistConditionOffset) = CombDistCond; + Data->getChildren()[CombinedDistConditionOffset] = CombDistCond; } void setCombinedParForInDistCond(Expr *CombParForInDistCond) { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound distribute sharing directive"); - *std::next(child_begin(), - CombinedParForInDistConditionOffset) = CombParForInDistCond; + Data->getChildren()[CombinedParForInDistConditionOffset] = + CombParForInDistCond; } void setCounters(ArrayRef A); void setPrivateCounters(ArrayRef A); @@ -925,178 +928,144 @@ class OMPLoopDirective : public OMPExecutableDirective { unsigned getCollapsedNumber() const { return CollapsedNum; } Expr *getIterationVariable() const { - return const_cast(reinterpret_cast( - *std::next(child_begin(), IterationVariableOffset))); + return cast(Data->getChildren()[IterationVariableOffset]); } Expr *getLastIteration() const { - return const_cast(reinterpret_cast( - *std::next(child_begin(), LastIterationOffset))); + return cast(Data->getChildren()[LastIterationOffset]); } Expr *getCalcLastIteration() const { - return const_cast(reinterpret_cast( - *std::next(child_begin(), CalcLastIterationOffset))); + return cast(Data->getChildren()[CalcLastIterationOffset]); } Expr *getPreCond() const { - return const_cast(reinterpret_cast( - *std::next(child_begin(), PreConditionOffset))); - } - Expr *getCond() const { - return const_cast( - reinterpret_cast(*std::next(child_begin(), CondOffset))); - } - Expr *getInit() const { - return const_cast( - reinterpret_cast(*std::next(child_begin(), InitOffset))); - } - Expr *getInc() const { - return const_cast( - reinterpret_cast(*std::next(child_begin(), IncOffset))); + return cast(Data->getChildren()[PreConditionOffset]); } + Expr *getCond() const { return cast(Data->getChildren()[CondOffset]); } + Expr *getInit() const { return cast(Data->getChildren()[InitOffset]); } + Expr *getInc() const { return cast(Data->getChildren()[IncOffset]); } const Stmt *getPreInits() const { - return *std::next(child_begin(), PreInitsOffset); + return Data->getChildren()[PreInitsOffset]; } - Stmt *getPreInits() { return *std::next(child_begin(), PreInitsOffset); } + Stmt *getPreInits() { return Data->getChildren()[PreInitsOffset]; } Expr *getIsLastIterVariable() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), IsLastIterVariableOffset))); + return cast(Data->getChildren()[IsLastIterVariableOffset]); } Expr *getLowerBoundVariable() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), LowerBoundVariableOffset))); + return cast(Data->getChildren()[LowerBoundVariableOffset]); } Expr *getUpperBoundVariable() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), UpperBoundVariableOffset))); + return cast(Data->getChildren()[UpperBoundVariableOffset]); } Expr *getStrideVariable() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), StrideVariableOffset))); + return cast(Data->getChildren()[StrideVariableOffset]); } Expr *getEnsureUpperBound() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), EnsureUpperBoundOffset))); + return cast(Data->getChildren()[EnsureUpperBoundOffset]); } Expr *getNextLowerBound() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), NextLowerBoundOffset))); + return cast(Data->getChildren()[NextLowerBoundOffset]); } Expr *getNextUpperBound() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), NextUpperBoundOffset))); + return cast(Data->getChildren()[NextUpperBoundOffset]); } Expr *getNumIterations() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), NumIterationsOffset))); + return cast(Data->getChildren()[NumIterationsOffset]); } Expr *getPrevLowerBoundVariable() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), PrevLowerBoundVariableOffset))); + return cast(Data->getChildren()[PrevLowerBoundVariableOffset]); } Expr *getPrevUpperBoundVariable() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), PrevUpperBoundVariableOffset))); + return cast(Data->getChildren()[PrevUpperBoundVariableOffset]); } Expr *getDistInc() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), DistIncOffset))); + return cast(Data->getChildren()[DistIncOffset]); } Expr *getPrevEnsureUpperBound() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), PrevEnsureUpperBoundOffset))); + return cast(Data->getChildren()[PrevEnsureUpperBoundOffset]); } Expr *getCombinedLowerBoundVariable() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), CombinedLowerBoundVariableOffset))); + return cast(Data->getChildren()[CombinedLowerBoundVariableOffset]); } Expr *getCombinedUpperBoundVariable() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), CombinedUpperBoundVariableOffset))); + return cast(Data->getChildren()[CombinedUpperBoundVariableOffset]); } Expr *getCombinedEnsureUpperBound() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), CombinedEnsureUpperBoundOffset))); + return cast(Data->getChildren()[CombinedEnsureUpperBoundOffset]); } Expr *getCombinedInit() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), CombinedInitOffset))); + return cast(Data->getChildren()[CombinedInitOffset]); } Expr *getCombinedCond() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), CombinedConditionOffset))); + return cast(Data->getChildren()[CombinedConditionOffset]); } Expr *getCombinedNextLowerBound() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), CombinedNextLowerBoundOffset))); + return cast(Data->getChildren()[CombinedNextLowerBoundOffset]); } Expr *getCombinedNextUpperBound() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), CombinedNextUpperBoundOffset))); + return cast(Data->getChildren()[CombinedNextUpperBoundOffset]); } Expr *getCombinedDistCond() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound distribute sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), CombinedDistConditionOffset))); + return cast(Data->getChildren()[CombinedDistConditionOffset]); } Expr *getCombinedParForInDistCond() const { assert(isOpenMPLoopBoundSharingDirective(getDirectiveKind()) && "expected loop bound distribute sharing directive"); - return const_cast(reinterpret_cast( - *std::next(child_begin(), CombinedParForInDistConditionOffset))); + return cast(Data->getChildren()[CombinedParForInDistConditionOffset]); } /// Try to find the next loop sub-statement in the specified statement \p /// CurStmt. @@ -1206,27 +1175,25 @@ class OMPLoopDirective : public OMPExecutableDirective { /// class OMPSimdDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPSimdDirectiveClass, llvm::omp::OMPD_simd, - StartLoc, EndLoc, CollapsedNum, NumClauses) {} + unsigned CollapsedNum) + : OMPLoopDirective(OMPSimdDirectiveClass, llvm::omp::OMPD_simd, StartLoc, + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPSimdDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPSimdDirectiveClass, llvm::omp::OMPD_simd, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses) {} + explicit OMPSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPSimdDirectiveClass, llvm::omp::OMPD_simd, + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -1271,38 +1238,34 @@ class OMPSimdDirective : public OMPLoopDirective { /// class OMPForDirective : public OMPLoopDirective { friend class ASTStmtReader; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; + friend class OMPExecutableDirective; /// true if current directive has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPForDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPForDirectiveClass, llvm::omp::OMPD_for, - StartLoc, EndLoc, CollapsedNum, NumClauses), - HasCancel(false) {} + unsigned CollapsedNum) + : OMPLoopDirective(OMPForDirectiveClass, llvm::omp::OMPD_for, StartLoc, + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPForDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPForDirectiveClass, llvm::omp::OMPD_for, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses), - HasCancel(false) {} + explicit OMPForDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPForDirectiveClass, llvm::omp::OMPD_for, + SourceLocation(), SourceLocation(), CollapsedNum) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { + Data->getChildren()[numLoopChildren(getCollapsedNumber(), + llvm::omp::OMPD_for)] = E; + } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -1338,8 +1301,13 @@ class OMPForDirective : public OMPLoopDirective { unsigned CollapsedNum, EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[numLoopChildren( + getCollapsedNumber(), llvm::omp::OMPD_for)]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this)->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -1360,28 +1328,25 @@ class OMPForDirective : public OMPLoopDirective { /// class OMPForSimdDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPForSimdDirectiveClass, - llvm::omp::OMPD_for_simd, StartLoc, EndLoc, - CollapsedNum, NumClauses) {} + unsigned CollapsedNum) + : OMPLoopDirective(OMPForSimdDirectiveClass, llvm::omp::OMPD_for_simd, + StartLoc, EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPForSimdDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPForSimdDirectiveClass, - llvm::omp::OMPD_for_simd, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses) {} + explicit OMPForSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPForSimdDirectiveClass, llvm::omp::OMPD_for_simd, + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -1426,38 +1391,29 @@ class OMPForSimdDirective : public OMPLoopDirective { /// class OMPSectionsDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; /// true if current directive has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPSectionsDirectiveClass, - llvm::omp::OMPD_sections, StartLoc, EndLoc, - NumClauses, 1), - HasCancel(false) {} + OMPSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPSectionsDirectiveClass, + llvm::omp::OMPD_sections, StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPSectionsDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPSectionsDirectiveClass, + explicit OMPSectionsDirective() + : OMPExecutableDirective(OMPSectionsDirectiveClass, llvm::omp::OMPD_sections, SourceLocation(), - SourceLocation(), NumClauses, 1), - HasCancel(false) {} + SourceLocation()) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -1489,8 +1445,12 @@ class OMPSectionsDirective : public OMPExecutableDirective { unsigned NumClauses, EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[0]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this)->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -1508,9 +1468,10 @@ class OMPSectionsDirective : public OMPExecutableDirective { /// class OMPSectionDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// true if current directive has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// @@ -1518,17 +1479,15 @@ class OMPSectionDirective : public OMPExecutableDirective { /// \param EndLoc Ending location of the directive. /// OMPSectionDirective(SourceLocation StartLoc, SourceLocation EndLoc) - : OMPExecutableDirective(this, OMPSectionDirectiveClass, - llvm::omp::OMPD_section, StartLoc, EndLoc, 0, 1), - HasCancel(false) {} + : OMPExecutableDirective(OMPSectionDirectiveClass, + llvm::omp::OMPD_section, StartLoc, EndLoc) {} /// Build an empty directive. /// explicit OMPSectionDirective() - : OMPExecutableDirective(this, OMPSectionDirectiveClass, + : OMPExecutableDirective(OMPSectionDirectiveClass, llvm::omp::OMPD_section, SourceLocation(), - SourceLocation(), 0, 1), - HasCancel(false) {} + SourceLocation()) {} public: /// Creates directive. @@ -1571,26 +1530,21 @@ class OMPSectionDirective : public OMPExecutableDirective { /// class OMPSingleDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPSingleDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPSingleDirectiveClass, - llvm::omp::OMPD_single, StartLoc, EndLoc, - NumClauses, 1) {} + OMPSingleDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPSingleDirectiveClass, llvm::omp::OMPD_single, + StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPSingleDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPSingleDirectiveClass, - llvm::omp::OMPD_single, SourceLocation(), - SourceLocation(), NumClauses, 1) {} + explicit OMPSingleDirective() + : OMPExecutableDirective(OMPSingleDirectiveClass, llvm::omp::OMPD_single, + SourceLocation(), SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -1627,22 +1581,21 @@ class OMPSingleDirective : public OMPExecutableDirective { /// class OMPMasterDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// OMPMasterDirective(SourceLocation StartLoc, SourceLocation EndLoc) - : OMPExecutableDirective(this, OMPMasterDirectiveClass, - llvm::omp::OMPD_master, StartLoc, EndLoc, 0, 1) { - } + : OMPExecutableDirective(OMPMasterDirectiveClass, llvm::omp::OMPD_master, + StartLoc, EndLoc) {} /// Build an empty directive. /// explicit OMPMasterDirective() - : OMPExecutableDirective(this, OMPMasterDirectiveClass, - llvm::omp::OMPD_master, SourceLocation(), - SourceLocation(), 0, 1) {} + : OMPExecutableDirective(OMPMasterDirectiveClass, llvm::omp::OMPD_master, + SourceLocation(), SourceLocation()) {} public: /// Creates directive. @@ -1676,6 +1629,7 @@ class OMPMasterDirective : public OMPExecutableDirective { /// class OMPCriticalDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Name of the directive. DeclarationNameInfo DirName; /// Build directive with the given start and end location. @@ -1683,24 +1637,19 @@ class OMPCriticalDirective : public OMPExecutableDirective { /// \param Name Name of the directive. /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// OMPCriticalDirective(const DeclarationNameInfo &Name, SourceLocation StartLoc, - SourceLocation EndLoc, unsigned NumClauses) - : OMPExecutableDirective(this, OMPCriticalDirectiveClass, - llvm::omp::OMPD_critical, StartLoc, EndLoc, - NumClauses, 1), + SourceLocation EndLoc) + : OMPExecutableDirective(OMPCriticalDirectiveClass, + llvm::omp::OMPD_critical, StartLoc, EndLoc), DirName(Name) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPCriticalDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPCriticalDirectiveClass, + explicit OMPCriticalDirective() + : OMPExecutableDirective(OMPCriticalDirectiveClass, llvm::omp::OMPD_critical, SourceLocation(), - SourceLocation(), NumClauses, 1), - DirName() {} + SourceLocation()) {} /// Set name of the directive. /// @@ -1751,40 +1700,37 @@ class OMPCriticalDirective : public OMPExecutableDirective { /// class OMPParallelForDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; /// true if current region has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPParallelForDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPParallelForDirectiveClass, llvm::omp::OMPD_parallel_for, StartLoc, EndLoc, - CollapsedNum, NumClauses), - HasCancel(false) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPParallelForDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPParallelForDirectiveClass, + explicit OMPParallelForDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPParallelForDirectiveClass, llvm::omp::OMPD_parallel_for, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses), - HasCancel(false) {} + SourceLocation(), CollapsedNum) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { + Data->getChildren()[numLoopChildren(getCollapsedNumber(), + llvm::omp::OMPD_parallel_for)] = E; + } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -1822,8 +1768,14 @@ class OMPParallelForDirective : public OMPLoopDirective { EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[numLoopChildren( + getCollapsedNumber(), llvm::omp::OMPD_parallel_for)]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this) + ->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -1845,29 +1797,27 @@ class OMPParallelForDirective : public OMPLoopDirective { /// class OMPParallelForSimdDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPParallelForSimdDirectiveClass, llvm::omp::OMPD_parallel_for_simd, StartLoc, EndLoc, - CollapsedNum, NumClauses) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPParallelForSimdDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPParallelForSimdDirectiveClass, + explicit OMPParallelForSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPParallelForSimdDirectiveClass, llvm::omp::OMPD_parallel_for_simd, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses) {} + SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -1912,25 +1862,20 @@ class OMPParallelForSimdDirective : public OMPLoopDirective { /// class OMPParallelMasterDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; - - OMPParallelMasterDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPParallelMasterDirectiveClass, + OMPParallelMasterDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPParallelMasterDirectiveClass, llvm::omp::OMPD_parallel_master, StartLoc, - EndLoc, NumClauses, 1) {} + EndLoc) {} - explicit OMPParallelMasterDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPParallelMasterDirectiveClass, + explicit OMPParallelMasterDirective() + : OMPExecutableDirective(OMPParallelMasterDirectiveClass, llvm::omp::OMPD_parallel_master, - SourceLocation(), SourceLocation(), NumClauses, - 1) {} + SourceLocation(), SourceLocation()) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; } public: /// Creates directive with a list of \a Clauses. @@ -1957,8 +1902,13 @@ class OMPParallelMasterDirective : public OMPExecutableDirective { CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[0]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this) + ->getTaskReductionRefExpr(); + } static bool classof(const Stmt *T) { return T->getStmtClass() == OMPParallelMasterDirectiveClass; @@ -1976,39 +1926,30 @@ class OMPParallelMasterDirective : public OMPExecutableDirective { /// class OMPParallelSectionsDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; /// true if current directive has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPParallelSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass, + OMPParallelSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPParallelSectionsDirectiveClass, llvm::omp::OMPD_parallel_sections, StartLoc, - EndLoc, NumClauses, 1), - HasCancel(false) {} + EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPParallelSectionsDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPParallelSectionsDirectiveClass, + explicit OMPParallelSectionsDirective() + : OMPExecutableDirective(OMPParallelSectionsDirectiveClass, llvm::omp::OMPD_parallel_sections, - SourceLocation(), SourceLocation(), NumClauses, - 1), - HasCancel(false) {} + SourceLocation(), SourceLocation()) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -2040,8 +1981,13 @@ class OMPParallelSectionsDirective : public OMPExecutableDirective { CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[0]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this) + ->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -2061,31 +2007,24 @@ class OMPParallelSectionsDirective : public OMPExecutableDirective { /// class OMPTaskDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// true if this directive has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPTaskDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTaskDirectiveClass, - llvm::omp::OMPD_task, StartLoc, EndLoc, - NumClauses, 1), - HasCancel(false) {} + OMPTaskDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTaskDirectiveClass, llvm::omp::OMPD_task, + StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPTaskDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTaskDirectiveClass, - llvm::omp::OMPD_task, SourceLocation(), - SourceLocation(), NumClauses, 1), - HasCancel(false) {} + explicit OMPTaskDirective() + : OMPExecutableDirective(OMPTaskDirectiveClass, llvm::omp::OMPD_task, + SourceLocation(), SourceLocation()) {} /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -2130,22 +2069,22 @@ class OMPTaskDirective : public OMPExecutableDirective { /// class OMPTaskyieldDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// OMPTaskyieldDirective(SourceLocation StartLoc, SourceLocation EndLoc) - : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, - llvm::omp::OMPD_taskyield, StartLoc, EndLoc, 0, - 0) {} + : OMPExecutableDirective(OMPTaskyieldDirectiveClass, + llvm::omp::OMPD_taskyield, StartLoc, EndLoc) {} /// Build an empty directive. /// explicit OMPTaskyieldDirective() - : OMPExecutableDirective(this, OMPTaskyieldDirectiveClass, + : OMPExecutableDirective(OMPTaskyieldDirectiveClass, llvm::omp::OMPD_taskyield, SourceLocation(), - SourceLocation(), 0, 0) {} + SourceLocation()) {} public: /// Creates directive. @@ -2176,22 +2115,22 @@ class OMPTaskyieldDirective : public OMPExecutableDirective { /// class OMPBarrierDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// OMPBarrierDirective(SourceLocation StartLoc, SourceLocation EndLoc) - : OMPExecutableDirective(this, OMPBarrierDirectiveClass, - llvm::omp::OMPD_barrier, StartLoc, EndLoc, 0, - 0) {} + : OMPExecutableDirective(OMPBarrierDirectiveClass, + llvm::omp::OMPD_barrier, StartLoc, EndLoc) {} /// Build an empty directive. /// explicit OMPBarrierDirective() - : OMPExecutableDirective(this, OMPBarrierDirectiveClass, + : OMPExecutableDirective(OMPBarrierDirectiveClass, llvm::omp::OMPD_barrier, SourceLocation(), - SourceLocation(), 0, 0) {} + SourceLocation()) {} public: /// Creates directive. @@ -2222,22 +2161,22 @@ class OMPBarrierDirective : public OMPExecutableDirective { /// class OMPTaskwaitDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// OMPTaskwaitDirective(SourceLocation StartLoc, SourceLocation EndLoc) - : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, - llvm::omp::OMPD_taskwait, StartLoc, EndLoc, 0, - 0) {} + : OMPExecutableDirective(OMPTaskwaitDirectiveClass, + llvm::omp::OMPD_taskwait, StartLoc, EndLoc) {} /// Build an empty directive. /// explicit OMPTaskwaitDirective() - : OMPExecutableDirective(this, OMPTaskwaitDirectiveClass, + : OMPExecutableDirective(OMPTaskwaitDirectiveClass, llvm::omp::OMPD_taskwait, SourceLocation(), - SourceLocation(), 0, 0) {} + SourceLocation()) {} public: /// Creates directive. @@ -2268,30 +2207,25 @@ class OMPTaskwaitDirective : public OMPExecutableDirective { /// class OMPTaskgroupDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPTaskgroupDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, - llvm::omp::OMPD_taskgroup, StartLoc, EndLoc, - NumClauses, 2) {} + OMPTaskgroupDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTaskgroupDirectiveClass, + llvm::omp::OMPD_taskgroup, StartLoc, EndLoc) {} /// Build an empty directive. - /// \param NumClauses Number of clauses. /// - explicit OMPTaskgroupDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, + explicit OMPTaskgroupDirective() + : OMPExecutableDirective(OMPTaskgroupDirectiveClass, llvm::omp::OMPD_taskgroup, SourceLocation(), - SourceLocation(), NumClauses, 2) {} + SourceLocation()) {} /// Sets the task_reduction return variable. - void setReductionRef(Expr *RR) { - *std::next(child_begin(), 1) = RR; - } + void setReductionRef(Expr *RR) { Data->getChildren()[0] = RR; } public: /// Creates directive. @@ -2319,11 +2253,9 @@ class OMPTaskgroupDirective : public OMPExecutableDirective { /// Returns reference to the task_reduction return variable. const Expr *getReductionRef() const { - return static_cast(*std::next(child_begin(), 1)); - } - Expr *getReductionRef() { - return static_cast(*std::next(child_begin(), 1)); + return const_cast(this)->getReductionRef(); } + Expr *getReductionRef() { return cast_or_null(Data->getChildren()[0]); } static bool classof(const Stmt *T) { return T->getStmtClass() == OMPTaskgroupDirectiveClass; @@ -2342,26 +2274,21 @@ class OMPTaskgroupDirective : public OMPExecutableDirective { /// FlushClause. class OMPFlushDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPFlushDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPFlushDirectiveClass, - llvm::omp::OMPD_flush, StartLoc, EndLoc, - NumClauses, 0) {} + OMPFlushDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPFlushDirectiveClass, llvm::omp::OMPD_flush, + StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPFlushDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPFlushDirectiveClass, - llvm::omp::OMPD_flush, SourceLocation(), - SourceLocation(), NumClauses, 0) {} + explicit OMPFlushDirective() + : OMPExecutableDirective(OMPFlushDirectiveClass, llvm::omp::OMPD_flush, + SourceLocation(), SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -2399,27 +2326,22 @@ class OMPFlushDirective : public OMPExecutableDirective { /// 'a' with dependence type 'in' and a list with 'x' and 'y' locators. class OMPDepobjDirective final : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPDepobjDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPDepobjDirectiveClass, - llvm::omp::OMPD_depobj, StartLoc, EndLoc, - NumClauses, 0) {} + OMPDepobjDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPDepobjDirectiveClass, llvm::omp::OMPD_depobj, + StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPDepobjDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPDepobjDirectiveClass, - llvm::omp::OMPD_depobj, SourceLocation(), - SourceLocation(), NumClauses, 0) {} + explicit OMPDepobjDirective() + : OMPExecutableDirective(OMPDepobjDirectiveClass, llvm::omp::OMPD_depobj, + SourceLocation(), SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -2456,26 +2378,22 @@ class OMPDepobjDirective final : public OMPExecutableDirective { /// class OMPOrderedDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPOrderedDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPOrderedDirectiveClass, - llvm::omp::OMPD_ordered, StartLoc, EndLoc, - NumClauses, 1) {} + OMPOrderedDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPOrderedDirectiveClass, + llvm::omp::OMPD_ordered, StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPOrderedDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPOrderedDirectiveClass, + explicit OMPOrderedDirective() + : OMPExecutableDirective(OMPOrderedDirectiveClass, llvm::omp::OMPD_ordered, SourceLocation(), - SourceLocation(), NumClauses, 1) {} + SourceLocation()) {} public: /// Creates directive. @@ -2494,9 +2412,11 @@ class OMPOrderedDirective : public OMPExecutableDirective { /// /// \param C AST context. /// \param NumClauses Number of clauses. + /// \param IsStandalone true, if the the standalone directive is created. /// static OMPOrderedDirective *CreateEmpty(const ASTContext &C, - unsigned NumClauses, EmptyShell); + unsigned NumClauses, + bool IsStandalone, EmptyShell); static bool classof(const Stmt *T) { return T->getStmtClass() == OMPOrderedDirectiveClass; @@ -2512,6 +2432,7 @@ class OMPOrderedDirective : public OMPExecutableDirective { /// class OMPAtomicDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Used for 'atomic update' or 'atomic capture' constructs. They may /// have atomic expressions of forms /// \code @@ -2521,7 +2442,7 @@ class OMPAtomicDirective : public OMPExecutableDirective { /// This field is true for the first form of the expression and false for the /// second. Required for correct codegen of non-associative operations (like /// << or >>). - bool IsXLHSInRHSPart; + bool IsXLHSInRHSPart = false; /// Used for 'atomic update' or 'atomic capture' constructs. They may /// have atomic expressions of forms /// \code @@ -2530,41 +2451,33 @@ class OMPAtomicDirective : public OMPExecutableDirective { /// \endcode /// This field is true for the first(postfix) form of the expression and false /// otherwise. - bool IsPostfixUpdate; + bool IsPostfixUpdate = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPAtomicDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPAtomicDirectiveClass, - llvm::omp::OMPD_atomic, StartLoc, EndLoc, - NumClauses, 5), - IsXLHSInRHSPart(false), IsPostfixUpdate(false) {} + OMPAtomicDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic, + StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPAtomicDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPAtomicDirectiveClass, - llvm::omp::OMPD_atomic, SourceLocation(), - SourceLocation(), NumClauses, 5), - IsXLHSInRHSPart(false), IsPostfixUpdate(false) {} + explicit OMPAtomicDirective() + : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic, + SourceLocation(), SourceLocation()) {} /// Set 'x' part of the associated expression/statement. - void setX(Expr *X) { *std::next(child_begin()) = X; } + void setX(Expr *X) { Data->getChildren()[0] = X; } /// Set helper expression of the form /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'. - void setUpdateExpr(Expr *UE) { *std::next(child_begin(), 2) = UE; } + void setUpdateExpr(Expr *UE) { Data->getChildren()[1] = UE; } /// Set 'v' part of the associated expression/statement. - void setV(Expr *V) { *std::next(child_begin(), 3) = V; } + void setV(Expr *V) { Data->getChildren()[2] = V; } /// Set 'expr' part of the associated expression/statement. - void setExpr(Expr *E) { *std::next(child_begin(), 4) = E; } + void setExpr(Expr *E) { Data->getChildren()[3] = E; } public: /// Creates directive with a list of \a Clauses and 'x', 'v' and 'expr' @@ -2601,18 +2514,16 @@ class OMPAtomicDirective : public OMPExecutableDirective { unsigned NumClauses, EmptyShell); /// Get 'x' part of the associated expression/statement. - Expr *getX() { return cast_or_null(*std::next(child_begin())); } + Expr *getX() { return cast_or_null(Data->getChildren()[0]); } const Expr *getX() const { - return cast_or_null(*std::next(child_begin())); + return cast_or_null(Data->getChildren()[0]); } /// Get helper expression of the form /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'. - Expr *getUpdateExpr() { - return cast_or_null(*std::next(child_begin(), 2)); - } + Expr *getUpdateExpr() { return cast_or_null(Data->getChildren()[1]); } const Expr *getUpdateExpr() const { - return cast_or_null(*std::next(child_begin(), 2)); + return cast_or_null(Data->getChildren()[1]); } /// Return true if helper update expression has form /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form @@ -2622,14 +2533,14 @@ class OMPAtomicDirective : public OMPExecutableDirective { /// 'x', false if 'v' must be updated to the new value of 'x'. bool isPostfixUpdate() const { return IsPostfixUpdate; } /// Get 'v' part of the associated expression/statement. - Expr *getV() { return cast_or_null(*std::next(child_begin(), 3)); } + Expr *getV() { return cast_or_null(Data->getChildren()[2]); } const Expr *getV() const { - return cast_or_null(*std::next(child_begin(), 3)); + return cast_or_null(Data->getChildren()[2]); } /// Get 'expr' part of the associated expression/statement. - Expr *getExpr() { return cast_or_null(*std::next(child_begin(), 4)); } + Expr *getExpr() { return cast_or_null(Data->getChildren()[3]); } const Expr *getExpr() const { - return cast_or_null(*std::next(child_begin(), 4)); + return cast_or_null(Data->getChildren()[3]); } static bool classof(const Stmt *T) { @@ -2647,26 +2558,21 @@ class OMPAtomicDirective : public OMPExecutableDirective { /// class OMPTargetDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPTargetDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetDirectiveClass, - llvm::omp::OMPD_target, StartLoc, EndLoc, - NumClauses, 1) {} + OMPTargetDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTargetDirectiveClass, llvm::omp::OMPD_target, + StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPTargetDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetDirectiveClass, - llvm::omp::OMPD_target, SourceLocation(), - SourceLocation(), NumClauses, 1) {} + explicit OMPTargetDirective() + : OMPExecutableDirective(OMPTargetDirectiveClass, llvm::omp::OMPD_target, + SourceLocation(), SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -2706,26 +2612,22 @@ class OMPTargetDirective : public OMPExecutableDirective { /// class OMPTargetDataDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending Location of the directive. - /// \param NumClauses The number of clauses. /// - OMPTargetDataDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, - llvm::omp::OMPD_target_data, StartLoc, EndLoc, - NumClauses, 1) {} + OMPTargetDataDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTargetDataDirectiveClass, + llvm::omp::OMPD_target_data, StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPTargetDataDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, + explicit OMPTargetDataDirective() + : OMPExecutableDirective(OMPTargetDataDirectiveClass, llvm::omp::OMPD_target_data, SourceLocation(), - SourceLocation(), NumClauses, 1) {} + SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -2764,27 +2666,23 @@ class OMPTargetDataDirective : public OMPExecutableDirective { /// class OMPTargetEnterDataDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending Location of the directive. - /// \param NumClauses The number of clauses. /// - OMPTargetEnterDataDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass, + OMPTargetEnterDataDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTargetEnterDataDirectiveClass, llvm::omp::OMPD_target_enter_data, StartLoc, - EndLoc, NumClauses, /*NumChildren=*/1) {} + EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPTargetEnterDataDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass, + explicit OMPTargetEnterDataDirective() + : OMPExecutableDirective(OMPTargetEnterDataDirectiveClass, llvm::omp::OMPD_target_enter_data, - SourceLocation(), SourceLocation(), NumClauses, - /*NumChildren=*/1) {} + SourceLocation(), SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -2823,27 +2721,23 @@ class OMPTargetEnterDataDirective : public OMPExecutableDirective { /// class OMPTargetExitDataDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending Location of the directive. - /// \param NumClauses The number of clauses. /// - OMPTargetExitDataDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass, + OMPTargetExitDataDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTargetExitDataDirectiveClass, llvm::omp::OMPD_target_exit_data, StartLoc, - EndLoc, NumClauses, /*NumChildren=*/1) {} + EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPTargetExitDataDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass, + explicit OMPTargetExitDataDirective() + : OMPExecutableDirective(OMPTargetExitDataDirectiveClass, llvm::omp::OMPD_target_exit_data, - SourceLocation(), SourceLocation(), NumClauses, - /*NumChildren=*/1) {} + SourceLocation(), SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -2881,9 +2775,7 @@ class OMPTargetExitDataDirective : public OMPExecutableDirective { /// class OMPTargetParallelDirective : public OMPExecutableDirective { friend class ASTStmtReader; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; + friend class OMPExecutableDirective; /// true if the construct has inner cancel directive. bool HasCancel = false; @@ -2891,26 +2783,21 @@ class OMPTargetParallelDirective : public OMPExecutableDirective { /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPTargetParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass, + OMPTargetParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTargetParallelDirectiveClass, llvm::omp::OMPD_target_parallel, StartLoc, - EndLoc, NumClauses, /*NumChildren=*/1) {} + EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPTargetParallelDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetParallelDirectiveClass, + explicit OMPTargetParallelDirective() + : OMPExecutableDirective(OMPTargetParallelDirectiveClass, llvm::omp::OMPD_target_parallel, - SourceLocation(), SourceLocation(), NumClauses, - /*NumChildren=*/1) {} + SourceLocation(), SourceLocation()) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { Data->getChildren()[0] = E; } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -2941,8 +2828,13 @@ class OMPTargetParallelDirective : public OMPExecutableDirective { CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[0]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this) + ->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -2963,41 +2855,37 @@ class OMPTargetParallelDirective : public OMPExecutableDirective { /// class OMPTargetParallelForDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; /// true if current region has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTargetParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetParallelForDirectiveClass, llvm::omp::OMPD_target_parallel_for, StartLoc, EndLoc, - CollapsedNum, NumClauses), - HasCancel(false) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTargetParallelForDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetParallelForDirectiveClass, + explicit OMPTargetParallelForDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetParallelForDirectiveClass, llvm::omp::OMPD_target_parallel_for, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses), - HasCancel(false) {} + SourceLocation(), CollapsedNum) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { + Data->getChildren()[numLoopChildren( + getCollapsedNumber(), llvm::omp::OMPD_target_parallel_for)] = E; + } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -3035,8 +2923,14 @@ class OMPTargetParallelForDirective : public OMPLoopDirective { EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[numLoopChildren( + getCollapsedNumber(), llvm::omp::OMPD_target_parallel_for)]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this) + ->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -3056,26 +2950,21 @@ class OMPTargetParallelForDirective : public OMPLoopDirective { /// class OMPTeamsDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTeamsDirectiveClass, - llvm::omp::OMPD_teams, StartLoc, EndLoc, - NumClauses, 1) {} + OMPTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTeamsDirectiveClass, llvm::omp::OMPD_teams, + StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPTeamsDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTeamsDirectiveClass, - llvm::omp::OMPD_teams, SourceLocation(), - SourceLocation(), NumClauses, 1) {} + explicit OMPTeamsDirective() + : OMPExecutableDirective(OMPTeamsDirectiveClass, llvm::omp::OMPD_teams, + SourceLocation(), SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -3114,25 +3003,24 @@ class OMPTeamsDirective : public OMPExecutableDirective { /// In this example a cancellation point is created for innermost 'for' region. class OMPCancellationPointDirective : public OMPExecutableDirective { friend class ASTStmtReader; - OpenMPDirectiveKind CancelRegion; + friend class OMPExecutableDirective; + OpenMPDirectiveKind CancelRegion = llvm::omp::OMPD_unknown; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. + /// statements and child expressions. /// OMPCancellationPointDirective(SourceLocation StartLoc, SourceLocation EndLoc) - : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass, + : OMPExecutableDirective(OMPCancellationPointDirectiveClass, llvm::omp::OMPD_cancellation_point, StartLoc, - EndLoc, 0, 0), - CancelRegion(llvm::omp::OMPD_unknown) {} + EndLoc) {} /// Build an empty directive. - /// explicit OMPCancellationPointDirective() - : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass, + : OMPExecutableDirective(OMPCancellationPointDirectiveClass, llvm::omp::OMPD_cancellation_point, - SourceLocation(), SourceLocation(), 0, 0), - CancelRegion(llvm::omp::OMPD_unknown) {} + SourceLocation(), SourceLocation()) {} /// Set cancel region for current cancellation point. /// \param CR Cancellation region. @@ -3173,28 +3061,22 @@ class OMPCancellationPointDirective : public OMPExecutableDirective { /// In this example a cancel is created for innermost 'for' region. class OMPCancelDirective : public OMPExecutableDirective { friend class ASTStmtReader; - OpenMPDirectiveKind CancelRegion; + friend class OMPExecutableDirective; + OpenMPDirectiveKind CancelRegion = llvm::omp::OMPD_unknown; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPCancelDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPCancelDirectiveClass, - llvm::omp::OMPD_cancel, StartLoc, EndLoc, - NumClauses, 0), - CancelRegion(llvm::omp::OMPD_unknown) {} + OMPCancelDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPCancelDirectiveClass, llvm::omp::OMPD_cancel, + StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - explicit OMPCancelDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPCancelDirectiveClass, - llvm::omp::OMPD_cancel, SourceLocation(), - SourceLocation(), NumClauses, 0), - CancelRegion(llvm::omp::OMPD_unknown) {} + explicit OMPCancelDirective() + : OMPExecutableDirective(OMPCancelDirectiveClass, llvm::omp::OMPD_cancel, + SourceLocation(), SourceLocation()) {} /// Set cancel region for current cancellation point. /// \param CR Cancellation region. @@ -3239,33 +3121,28 @@ class OMPCancelDirective : public OMPExecutableDirective { /// class OMPTaskLoopDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// true if the construct has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, - llvm::omp::OMPD_taskloop, StartLoc, EndLoc, - CollapsedNum, NumClauses), - HasCancel(false) {} + unsigned CollapsedNum) + : OMPLoopDirective(OMPTaskLoopDirectiveClass, llvm::omp::OMPD_taskloop, + StartLoc, EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTaskLoopDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTaskLoopDirectiveClass, - llvm::omp::OMPD_taskloop, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses), - HasCancel(false) {} + explicit OMPTaskLoopDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTaskLoopDirectiveClass, llvm::omp::OMPD_taskloop, + SourceLocation(), SourceLocation(), CollapsedNum) {} /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -3317,28 +3194,27 @@ class OMPTaskLoopDirective : public OMPLoopDirective { /// class OMPTaskLoopSimdDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTaskLoopSimdDirectiveClass, llvm::omp::OMPD_taskloop_simd, StartLoc, EndLoc, - CollapsedNum, NumClauses) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTaskLoopSimdDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTaskLoopSimdDirectiveClass, + explicit OMPTaskLoopSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTaskLoopSimdDirectiveClass, llvm::omp::OMPD_taskloop_simd, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses) {} + SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -3384,34 +3260,30 @@ class OMPTaskLoopSimdDirective : public OMPLoopDirective { /// class OMPMasterTaskLoopDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// true if the construct has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPMasterTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPMasterTaskLoopDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPMasterTaskLoopDirectiveClass, llvm::omp::OMPD_master_taskloop, StartLoc, EndLoc, - CollapsedNum, NumClauses), - HasCancel(false) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPMasterTaskLoopDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPMasterTaskLoopDirectiveClass, + explicit OMPMasterTaskLoopDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPMasterTaskLoopDirectiveClass, llvm::omp::OMPD_master_taskloop, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses), - HasCancel(false) {} + SourceLocation(), CollapsedNum) {} /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -3464,29 +3336,27 @@ class OMPMasterTaskLoopDirective : public OMPLoopDirective { /// class OMPMasterTaskLoopSimdDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPMasterTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPMasterTaskLoopSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPMasterTaskLoopSimdDirectiveClass, llvm::omp::OMPD_master_taskloop_simd, StartLoc, EndLoc, - CollapsedNum, NumClauses) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPMasterTaskLoopSimdDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPMasterTaskLoopSimdDirectiveClass, + explicit OMPMasterTaskLoopSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPMasterTaskLoopSimdDirectiveClass, llvm::omp::OMPD_master_taskloop_simd, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses) {} + SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \p Clauses. @@ -3532,36 +3402,31 @@ class OMPMasterTaskLoopSimdDirective : public OMPLoopDirective { /// class OMPParallelMasterTaskLoopDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// true if the construct has inner cancel directive. - bool HasCancel; + bool HasCancel = false; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPParallelMasterTaskLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPParallelMasterTaskLoopDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPParallelMasterTaskLoopDirectiveClass, llvm::omp::OMPD_parallel_master_taskloop, StartLoc, - EndLoc, CollapsedNum, NumClauses), - HasCancel(false) {} + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPParallelMasterTaskLoopDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPParallelMasterTaskLoopDirectiveClass, + explicit OMPParallelMasterTaskLoopDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPParallelMasterTaskLoopDirectiveClass, llvm::omp::OMPD_parallel_master_taskloop, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses), - HasCancel(false) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -3615,32 +3480,28 @@ class OMPParallelMasterTaskLoopDirective : public OMPLoopDirective { /// class OMPParallelMasterTaskLoopSimdDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPParallelMasterTaskLoopSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPParallelMasterTaskLoopSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPParallelMasterTaskLoopSimdDirectiveClass, llvm::omp::OMPD_parallel_master_taskloop_simd, - StartLoc, EndLoc, CollapsedNum, NumClauses) {} + StartLoc, EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPParallelMasterTaskLoopSimdDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPParallelMasterTaskLoopSimdDirectiveClass, + explicit OMPParallelMasterTaskLoopSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPParallelMasterTaskLoopSimdDirectiveClass, llvm::omp::OMPD_parallel_master_taskloop_simd, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \p Clauses. @@ -3684,29 +3545,28 @@ class OMPParallelMasterTaskLoopSimdDirective : public OMPLoopDirective { /// class OMPDistributeDirective : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPDistributeDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPDistributeDirectiveClass, llvm::omp::OMPD_distribute, StartLoc, EndLoc, - CollapsedNum, NumClauses) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPDistributeDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPDistributeDirectiveClass, + explicit OMPDistributeDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPDistributeDirectiveClass, llvm::omp::OMPD_distribute, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses) {} + SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -3751,26 +3611,23 @@ class OMPDistributeDirective : public OMPLoopDirective { /// class OMPTargetUpdateDirective : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending Location of the directive. - /// \param NumClauses The number of clauses. /// - OMPTargetUpdateDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass, - llvm::omp::OMPD_target_update, StartLoc, EndLoc, - NumClauses, 1) {} + OMPTargetUpdateDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTargetUpdateDirectiveClass, + llvm::omp::OMPD_target_update, StartLoc, + EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPTargetUpdateDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetUpdateDirectiveClass, + explicit OMPTargetUpdateDirective() + : OMPExecutableDirective(OMPTargetUpdateDirectiveClass, llvm::omp::OMPD_target_update, SourceLocation(), - SourceLocation(), NumClauses, 1) {} + SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -3810,9 +3667,7 @@ class OMPTargetUpdateDirective : public OMPExecutableDirective { /// class OMPDistributeParallelForDirective : public OMPLoopDirective { friend class ASTStmtReader; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; + friend class OMPExecutableDirective; /// true if the construct has inner cancel directive. bool HasCancel = false; @@ -3821,31 +3676,28 @@ class OMPDistributeParallelForDirective : public OMPLoopDirective { /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPDistributeParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPDistributeParallelForDirectiveClass, llvm::omp::OMPD_distribute_parallel_for, StartLoc, - EndLoc, CollapsedNum, NumClauses), - HasCancel(false) {} + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPDistributeParallelForDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass, + explicit OMPDistributeParallelForDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPDistributeParallelForDirectiveClass, llvm::omp::OMPD_distribute_parallel_for, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses), - HasCancel(false) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { + Data->getChildren()[numLoopChildren( + getCollapsedNumber(), llvm::omp::OMPD_distribute_parallel_for)] = E; + } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -3883,8 +3735,14 @@ class OMPDistributeParallelForDirective : public OMPLoopDirective { EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[numLoopChildren( + getCollapsedNumber(), llvm::omp::OMPD_distribute_parallel_for)]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this) + ->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -3905,33 +3763,29 @@ class OMPDistributeParallelForDirective : public OMPLoopDirective { /// class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPDistributeParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPDistributeParallelForSimdDirectiveClass, llvm::omp::OMPD_distribute_parallel_for_simd, StartLoc, - EndLoc, CollapsedNum, NumClauses) {} + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass, + explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPDistributeParallelForSimdDirectiveClass, llvm::omp::OMPD_distribute_parallel_for_simd, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -3974,30 +3828,28 @@ class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective { /// class OMPDistributeSimdDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPDistributeSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPDistributeSimdDirectiveClass, llvm::omp::OMPD_distribute_simd, StartLoc, EndLoc, - CollapsedNum, NumClauses) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPDistributeSimdDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass, + explicit OMPDistributeSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPDistributeSimdDirectiveClass, llvm::omp::OMPD_distribute_simd, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses) {} + SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -4042,32 +3894,29 @@ class OMPDistributeSimdDirective final : public OMPLoopDirective { /// class OMPTargetParallelForSimdDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTargetParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetParallelForSimdDirectiveClass, llvm::omp::OMPD_target_parallel_for_simd, StartLoc, - EndLoc, CollapsedNum, NumClauses) {} + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTargetParallelForSimdDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetParallelForSimdDirectiveClass, + explicit OMPTargetParallelForSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetParallelForSimdDirectiveClass, llvm::omp::OMPD_target_parallel_for_simd, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -4112,29 +3961,28 @@ class OMPTargetParallelForSimdDirective final : public OMPLoopDirective { /// class OMPTargetSimdDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTargetSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetSimdDirectiveClass, llvm::omp::OMPD_target_simd, StartLoc, EndLoc, - CollapsedNum, NumClauses) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, + explicit OMPTargetSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetSimdDirectiveClass, llvm::omp::OMPD_target_simd, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses) {} + SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -4178,30 +4026,28 @@ class OMPTargetSimdDirective final : public OMPLoopDirective { /// class OMPTeamsDistributeDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTeamsDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTeamsDistributeDirectiveClass, llvm::omp::OMPD_teams_distribute, StartLoc, EndLoc, - CollapsedNum, NumClauses) {} + CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTeamsDistributeDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass, + explicit OMPTeamsDistributeDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTeamsDistributeDirectiveClass, llvm::omp::OMPD_teams_distribute, SourceLocation(), - SourceLocation(), CollapsedNum, NumClauses) {} + SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -4246,32 +4092,28 @@ class OMPTeamsDistributeDirective final : public OMPLoopDirective { /// class OMPTeamsDistributeSimdDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTeamsDistributeSimdDirective(SourceLocation StartLoc, - SourceLocation EndLoc, unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass, + SourceLocation EndLoc, unsigned CollapsedNum) + : OMPLoopDirective(OMPTeamsDistributeSimdDirectiveClass, llvm::omp::OMPD_teams_distribute_simd, StartLoc, - EndLoc, CollapsedNum, NumClauses) {} + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTeamsDistributeSimdDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass, + explicit OMPTeamsDistributeSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTeamsDistributeSimdDirectiveClass, llvm::omp::OMPD_teams_distribute_simd, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -4318,33 +4160,29 @@ class OMPTeamsDistributeSimdDirective final : public OMPLoopDirective { class OMPTeamsDistributeParallelForSimdDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTeamsDistributeParallelForSimdDirectiveClass, llvm::omp::OMPD_teams_distribute_parallel_for_simd, - StartLoc, EndLoc, CollapsedNum, NumClauses) {} + StartLoc, EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass, + explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTeamsDistributeParallelForSimdDirectiveClass, llvm::omp::OMPD_teams_distribute_parallel_for_simd, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -4388,9 +4226,7 @@ class OMPTeamsDistributeParallelForSimdDirective final /// class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective { friend class ASTStmtReader; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; + friend class OMPExecutableDirective; /// true if the construct has inner cancel directive. bool HasCancel = false; @@ -4399,32 +4235,29 @@ class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective { /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTeamsDistributeParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTeamsDistributeParallelForDirectiveClass, llvm::omp::OMPD_teams_distribute_parallel_for, - StartLoc, EndLoc, CollapsedNum, NumClauses), - HasCancel(false) {} + StartLoc, EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTeamsDistributeParallelForDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass, + explicit OMPTeamsDistributeParallelForDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTeamsDistributeParallelForDirectiveClass, llvm::omp::OMPD_teams_distribute_parallel_for, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses), - HasCancel(false) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { + Data->getChildren()[numLoopChildren( + getCollapsedNumber(), llvm::omp::OMPD_teams_distribute_parallel_for)] = + E; + } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -4460,8 +4293,14 @@ class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective { EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[numLoopChildren( + getCollapsedNumber(), llvm::omp::OMPD_teams_distribute_parallel_for)]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this) + ->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -4481,26 +4320,23 @@ class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective { /// class OMPTargetTeamsDirective final : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPTargetTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass, - llvm::omp::OMPD_target_teams, StartLoc, EndLoc, - NumClauses, 1) {} + OMPTargetTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPTargetTeamsDirectiveClass, + llvm::omp::OMPD_target_teams, StartLoc, EndLoc) { + } /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPTargetTeamsDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass, + explicit OMPTargetTeamsDirective() + : OMPExecutableDirective(OMPTargetTeamsDirectiveClass, llvm::omp::OMPD_target_teams, SourceLocation(), - SourceLocation(), NumClauses, 1) {} + SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. @@ -4540,32 +4376,29 @@ class OMPTargetTeamsDirective final : public OMPExecutableDirective { /// class OMPTargetTeamsDistributeDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTargetTeamsDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetTeamsDistributeDirectiveClass, llvm::omp::OMPD_target_teams_distribute, StartLoc, - EndLoc, CollapsedNum, NumClauses) {} + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass, + explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetTeamsDistributeDirectiveClass, llvm::omp::OMPD_target_teams_distribute, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -4610,9 +4443,7 @@ class OMPTargetTeamsDistributeDirective final : public OMPLoopDirective { class OMPTargetTeamsDistributeParallelForDirective final : public OMPLoopDirective { friend class ASTStmtReader; - /// Special reference expression for handling task reduction. Used to store - /// the taskgroup descriptor returned by the runtime functions. - Expr *TaskRedRef = nullptr; + friend class OMPExecutableDirective; /// true if the construct has inner cancel directive. bool HasCancel = false; @@ -4621,33 +4452,29 @@ class OMPTargetTeamsDistributeParallelForDirective final /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTargetTeamsDistributeParallelForDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, - OMPTargetTeamsDistributeParallelForDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetTeamsDistributeParallelForDirectiveClass, llvm::omp::OMPD_target_teams_distribute_parallel_for, - StartLoc, EndLoc, CollapsedNum, NumClauses), - HasCancel(false) {} + StartLoc, EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTargetTeamsDistributeParallelForDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective( - this, OMPTargetTeamsDistributeParallelForDirectiveClass, - llvm::omp::OMPD_target_teams_distribute_parallel_for, - SourceLocation(), SourceLocation(), CollapsedNum, NumClauses), - HasCancel(false) {} + explicit OMPTargetTeamsDistributeParallelForDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetTeamsDistributeParallelForDirectiveClass, + llvm::omp::OMPD_target_teams_distribute_parallel_for, + SourceLocation(), SourceLocation(), CollapsedNum) {} /// Sets special task reduction descriptor. - void setTaskReductionRefExpr(Expr *E) { TaskRedRef = E; } + void setTaskReductionRefExpr(Expr *E) { + Data->getChildren()[numLoopChildren( + getCollapsedNumber(), + llvm::omp::OMPD_target_teams_distribute_parallel_for)] = E; + } /// Set cancel state. void setHasCancel(bool Has) { HasCancel = Has; } @@ -4683,8 +4510,15 @@ class OMPTargetTeamsDistributeParallelForDirective final EmptyShell); /// Returns special task reduction reference expression. - Expr *getTaskReductionRefExpr() { return TaskRedRef; } - const Expr *getTaskReductionRefExpr() const { return TaskRedRef; } + Expr *getTaskReductionRefExpr() { + return cast_or_null(Data->getChildren()[numLoopChildren( + getCollapsedNumber(), + llvm::omp::OMPD_target_teams_distribute_parallel_for)]); + } + const Expr *getTaskReductionRefExpr() const { + return const_cast(this) + ->getTaskReductionRefExpr(); + } /// Return true if current directive has inner cancel directive. bool hasCancel() const { return HasCancel; } @@ -4707,34 +4541,32 @@ class OMPTargetTeamsDistributeParallelForDirective final class OMPTargetTeamsDistributeParallelForSimdDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTargetTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, - unsigned NumClauses) + unsigned CollapsedNum) : OMPLoopDirective( - this, OMPTargetTeamsDistributeParallelForSimdDirectiveClass, + OMPTargetTeamsDistributeParallelForSimdDirectiveClass, llvm::omp::OMPD_target_teams_distribute_parallel_for_simd, StartLoc, - EndLoc, CollapsedNum, NumClauses) {} + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// explicit OMPTargetTeamsDistributeParallelForSimdDirective( - unsigned CollapsedNum, unsigned NumClauses) + unsigned CollapsedNum) : OMPLoopDirective( - this, OMPTargetTeamsDistributeParallelForSimdDirectiveClass, + OMPTargetTeamsDistributeParallelForSimdDirectiveClass, llvm::omp::OMPD_target_teams_distribute_parallel_for_simd, - SourceLocation(), SourceLocation(), CollapsedNum, NumClauses) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -4779,33 +4611,29 @@ class OMPTargetTeamsDistributeParallelForSimdDirective final /// class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// OMPTargetTeamsDistributeSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass, + unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetTeamsDistributeSimdDirectiveClass, llvm::omp::OMPD_target_teams_distribute_simd, StartLoc, - EndLoc, CollapsedNum, NumClauses) {} + EndLoc, CollapsedNum) {} /// Build an empty directive. /// /// \param CollapsedNum Number of collapsed nested loops. - /// \param NumClauses Number of clauses. /// - explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum, - unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass, + explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPTargetTeamsDistributeSimdDirectiveClass, llvm::omp::OMPD_target_teams_distribute_simd, - SourceLocation(), SourceLocation(), CollapsedNum, - NumClauses) {} + SourceLocation(), SourceLocation(), CollapsedNum) {} public: /// Creates directive with a list of \a Clauses. @@ -4847,26 +4675,21 @@ class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective { /// list item 'a'. class OMPScanDirective final : public OMPExecutableDirective { friend class ASTStmtReader; + friend class OMPExecutableDirective; /// Build directive with the given start and end location. /// /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending location of the directive. - /// \param NumClauses Number of clauses. /// - OMPScanDirective(SourceLocation StartLoc, SourceLocation EndLoc, - unsigned NumClauses) - : OMPExecutableDirective(this, OMPScanDirectiveClass, - llvm::omp::OMPD_scan, StartLoc, EndLoc, - NumClauses, 0) {} + OMPScanDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPScanDirectiveClass, llvm::omp::OMPD_scan, + StartLoc, EndLoc) {} /// Build an empty directive. /// - /// \param NumClauses Number of clauses. - /// - explicit OMPScanDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPScanDirectiveClass, - llvm::omp::OMPD_scan, SourceLocation(), - SourceLocation(), NumClauses, 0) {} + explicit OMPScanDirective() + : OMPExecutableDirective(OMPScanDirectiveClass, llvm::omp::OMPD_scan, + SourceLocation(), SourceLocation()) {} public: /// Creates directive with a list of \a Clauses. diff --git a/contrib/llvm-project/clang/include/clang/AST/TemplateBase.h b/contrib/llvm-project/clang/include/clang/AST/TemplateBase.h index 51fd8ba51034ed..1671637521e244 100644 --- a/contrib/llvm-project/clang/include/clang/AST/TemplateBase.h +++ b/contrib/llvm-project/clang/include/clang/AST/TemplateBase.h @@ -36,6 +36,17 @@ namespace llvm { class FoldingSetNodeID; +// Provide PointerLikeTypeTraits for clang::Expr*, this default one requires a +// full definition of Expr, but this file only sees a forward del because of +// the dependency. +template <> struct PointerLikeTypeTraits { + static inline void *getAsVoidPointer(clang::Expr *P) { return P; } + static inline clang::Expr *getFromVoidPointer(void *P) { + return static_cast(P); + } + static constexpr int NumLowBitsAvailable = 2; +}; + } // namespace llvm namespace clang { @@ -393,56 +404,51 @@ class TemplateArgument { /// Location information for a TemplateArgument. struct TemplateArgumentLocInfo { private: - struct T { + struct TemplateTemplateArgLocInfo { // FIXME: We'd like to just use the qualifier in the TemplateName, // but template arguments get canonicalized too quickly. NestedNameSpecifier *Qualifier; void *QualifierLocData; - unsigned TemplateNameLoc; - unsigned EllipsisLoc; - }; - - union { - struct T Template; - Expr *Expression; - TypeSourceInfo *Declarator; + SourceLocation TemplateNameLoc; + SourceLocation EllipsisLoc; }; -public: - constexpr TemplateArgumentLocInfo() : Template({nullptr, nullptr, 0, 0}) {} + llvm::PointerUnion + Pointer; - TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {} + TemplateTemplateArgLocInfo *getTemplate() const { + return Pointer.get(); + } - TemplateArgumentLocInfo(Expr *E) : Expression(E) {} +public: + TemplateArgumentLocInfo() {} + TemplateArgumentLocInfo(TypeSourceInfo *Declarator) { Pointer = Declarator; } - TemplateArgumentLocInfo(NestedNameSpecifierLoc QualifierLoc, + TemplateArgumentLocInfo(Expr *E) { Pointer = E; } + // Ctx is used for allocation -- this case is unusually large and also rare, + // so we store the payload out-of-line. + TemplateArgumentLocInfo(ASTContext &Ctx, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, - SourceLocation EllipsisLoc) { - Template.Qualifier = QualifierLoc.getNestedNameSpecifier(); - Template.QualifierLocData = QualifierLoc.getOpaqueData(); - Template.TemplateNameLoc = TemplateNameLoc.getRawEncoding(); - Template.EllipsisLoc = EllipsisLoc.getRawEncoding(); - } + SourceLocation EllipsisLoc); TypeSourceInfo *getAsTypeSourceInfo() const { - return Declarator; + return Pointer.get(); } - Expr *getAsExpr() const { - return Expression; - } + Expr *getAsExpr() const { return Pointer.get(); } NestedNameSpecifierLoc getTemplateQualifierLoc() const { - return NestedNameSpecifierLoc(Template.Qualifier, - Template.QualifierLocData); + const auto *Template = getTemplate(); + return NestedNameSpecifierLoc(Template->Qualifier, + Template->QualifierLocData); } SourceLocation getTemplateNameLoc() const { - return SourceLocation::getFromRawEncoding(Template.TemplateNameLoc); + return getTemplate()->TemplateNameLoc; } SourceLocation getTemplateEllipsisLoc() const { - return SourceLocation::getFromRawEncoding(Template.EllipsisLoc); + return getTemplate()->EllipsisLoc; } }; @@ -453,7 +459,7 @@ class TemplateArgumentLoc { TemplateArgumentLocInfo LocInfo; public: - constexpr TemplateArgumentLoc() {} + TemplateArgumentLoc() {} TemplateArgumentLoc(const TemplateArgument &Argument, TemplateArgumentLocInfo Opaque) @@ -475,12 +481,12 @@ class TemplateArgumentLoc { Argument.getKind() == TemplateArgument::Expression); } - TemplateArgumentLoc(const TemplateArgument &Argument, + TemplateArgumentLoc(ASTContext &Ctx, const TemplateArgument &Argument, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc = SourceLocation()) : Argument(Argument), - LocInfo(QualifierLoc, TemplateNameLoc, EllipsisLoc) { + LocInfo(Ctx, QualifierLoc, TemplateNameLoc, EllipsisLoc) { assert(Argument.getKind() == TemplateArgument::Template || Argument.getKind() == TemplateArgument::TemplateExpansion); } @@ -681,8 +687,8 @@ struct alignas(void *) ASTTemplateKWAndArgsInfo { TemplateArgumentListInfo &List) const; }; -const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - const TemplateArgument &Arg); +const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, + const TemplateArgument &Arg); inline TemplateSpecializationType::iterator TemplateSpecializationType::end() const { diff --git a/contrib/llvm-project/clang/include/clang/AST/TemplateName.h b/contrib/llvm-project/clang/include/clang/AST/TemplateName.h index 9bcf2838dcf135..010b813dc52538 100644 --- a/contrib/llvm-project/clang/include/clang/AST/TemplateName.h +++ b/contrib/llvm-project/clang/include/clang/AST/TemplateName.h @@ -342,10 +342,8 @@ class TemplateName { /// Insertion operator for diagnostics. This allows sending TemplateName's /// into a diagnostic with <<. -const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - TemplateName N); -const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - TemplateName N); +const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, + TemplateName N); /// A structure for storing the information associated with a /// substituted template template parameter. diff --git a/contrib/llvm-project/clang/include/clang/AST/TextNodeDumper.h b/contrib/llvm-project/clang/include/clang/AST/TextNodeDumper.h index b4cfb5a380d178..15ca348f47667a 100644 --- a/contrib/llvm-project/clang/include/clang/AST/TextNodeDumper.h +++ b/contrib/llvm-project/clang/include/clang/AST/TextNodeDumper.h @@ -155,6 +155,7 @@ class TextNodeDumper const comments::CommandTraits *Traits = nullptr; const char *getCommandName(unsigned CommandID); + void printFPOptions(FPOptionsOverride FPO); void dumpAPValueChildren(const APValue &Value, QualType Ty, const APValue &(*IdxToChildFun)(const APValue &, @@ -269,6 +270,7 @@ class TextNodeDumper void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node); void VisitCXXThisExpr(const CXXThisExpr *Node); void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node); + void VisitCXXStaticCastExpr(const CXXStaticCastExpr *Node); void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *Node); void VisitCXXConstructExpr(const CXXConstructExpr *Node); void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node); @@ -294,6 +296,7 @@ class TextNodeDumper void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node); void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node); void VisitOMPIteratorExpr(const OMPIteratorExpr *Node); + void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *Node); void VisitRValueReferenceType(const ReferenceType *T); void VisitArrayType(const ArrayType *T); diff --git a/contrib/llvm-project/clang/include/clang/AST/Type.h b/contrib/llvm-project/clang/include/clang/AST/Type.h index 74e4a578cb55a6..95b38da01b01d3 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Type.h +++ b/contrib/llvm-project/clang/include/clang/AST/Type.h @@ -61,6 +61,7 @@ class ExtQuals; class QualType; class ConceptDecl; class TagDecl; +class TemplateParameterList; class Type; enum { @@ -480,6 +481,11 @@ class Qualifiers { // Otherwise in OpenCLC v2.0 s6.5.5: every address space except // for __constant can be used as __generic. (A == LangAS::opencl_generic && B != LangAS::opencl_constant) || + // We also define global_device and global_host address spaces, + // to distinguish global pointers allocated on host from pointers + // allocated on device, which are a subset of __global. + (A == LangAS::opencl_global && (B == LangAS::opencl_global_device || + B == LangAS::opencl_global_host)) || // Consider pointer size address spaces to be equivalent to default. ((isPtrSizeAddressSpace(A) || A == LangAS::Default) && (isPtrSizeAddressSpace(B) || B == LangAS::Default)); @@ -1675,19 +1681,6 @@ class alignas(8) Type : public ExtQualsTypeCommonBase { uint32_t NumElements; }; - class ConstantMatrixTypeBitfields { - friend class ConstantMatrixType; - - unsigned : NumTypeBits; - - /// Number of rows and columns. Using 20 bits allows supporting very large - /// matrixes, while keeping 24 bits to accommodate NumTypeBits. - unsigned NumRows : 20; - unsigned NumColumns : 20; - - static constexpr uint32_t MaxElementsPerDimension = (1 << 20) - 1; - }; - class AttributedTypeBitfields { friend class AttributedType; @@ -1797,7 +1790,6 @@ class alignas(8) Type : public ExtQualsTypeCommonBase { TypeWithKeywordBitfields TypeWithKeywordBits; ElaboratedTypeBitfields ElaboratedTypeBits; VectorTypeBitfields VectorTypeBits; - ConstantMatrixTypeBitfields ConstantMatrixTypeBits; SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits; TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits; DependentTemplateSpecializationTypeBitfields @@ -1853,6 +1845,10 @@ class alignas(8) Type : public ExtQualsTypeCommonBase { Type(TypeClass tc, QualType canon, TypeDependence Dependence) : ExtQualsTypeCommonBase(this, canon.isNull() ? QualType(this_(), 0) : canon) { + static_assert(sizeof(*this) <= 8 + sizeof(ExtQualsTypeCommonBase), + "changing bitfields changed sizeof(Type)!"); + static_assert(alignof(decltype(*this)) % sizeof(void *) == 0, + "Insufficient alignment!"); TypeBits.TC = tc; TypeBits.Dependence = static_cast(Dependence); TypeBits.CacheValid = false; @@ -1925,6 +1921,16 @@ class alignas(8) Type : public ExtQualsTypeCommonBase { bool isSizelessType() const; bool isSizelessBuiltinType() const; + /// Determines if this is a sizeless type supported by the + /// 'arm_sve_vector_bits' type attribute, which can be applied to a single + /// SVE vector or predicate, excluding tuple types such as svint32x4_t. + bool isVLSTBuiltinType() const; + + /// Returns the representative type for the element of an SVE builtin type. + /// This is used to represent fixed-length SVE vectors created with the + /// 'arm_sve_vector_bits' type attribute as VectorType. + QualType getSveEltType(const ASTContext &Ctx) const; + /// Types are partitioned into 3 broad categories (C99 6.2.5p1): /// object types, function types, and incomplete types. @@ -1956,6 +1962,9 @@ class alignas(8) Type : public ExtQualsTypeCommonBase { /// (C++11 [basic.types]p10) bool isLiteralType(const ASTContext &Ctx) const; + /// Determine if this type is a structural type, per C++20 [temp.param]p7. + bool isStructuralType() const; + /// Test if this type is a standard-layout type. /// (C++0x [basic.type]p9) bool isStandardLayoutType() const; @@ -2118,6 +2127,7 @@ class alignas(8) Type : public ExtQualsTypeCommonBase { bool isAtomicType() const; // C11 _Atomic() bool isUndeducedAutoType() const; // C++11 auto or // C++14 decltype(auto) + bool isTypedefNameType() const; // typedef or alias template #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ bool is##Id##Type() const; @@ -2513,6 +2523,9 @@ class BuiltinType : public Type { // SVE Types #define SVE_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/AArch64SVEACLETypes.def" +// PPC MMA Types +#define PPC_VECTOR_TYPE(Name, Id, Size) Id, +#include "clang/Basic/PPCTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id @@ -3250,7 +3263,13 @@ class VectorType : public Type, public llvm::FoldingSetNode { NeonVector, /// is ARM Neon polynomial vector - NeonPolyVector + NeonPolyVector, + + /// is AArch64 SVE fixed-length data vector + SveFixedLengthDataVector, + + /// is AArch64 SVE fixed-length predicate vector + SveFixedLengthPredicateVector }; protected: @@ -3456,8 +3475,15 @@ class ConstantMatrixType final : public MatrixType { friend class ASTContext; /// The element type of the matrix. + // FIXME: Appears to be unused? There is also MatrixType::ElementType... QualType ElementType; + /// Number of rows and columns. + unsigned NumRows; + unsigned NumColumns; + + static constexpr unsigned MaxElementsPerDimension = (1 << 20) - 1; + ConstantMatrixType(QualType MatrixElementType, unsigned NRows, unsigned NColumns, QualType CanonElementType); @@ -3466,25 +3492,24 @@ class ConstantMatrixType final : public MatrixType { public: /// Returns the number of rows in the matrix. - unsigned getNumRows() const { return ConstantMatrixTypeBits.NumRows; } + unsigned getNumRows() const { return NumRows; } /// Returns the number of columns in the matrix. - unsigned getNumColumns() const { return ConstantMatrixTypeBits.NumColumns; } + unsigned getNumColumns() const { return NumColumns; } /// Returns the number of elements required to embed the matrix into a vector. unsigned getNumElementsFlattened() const { - return ConstantMatrixTypeBits.NumRows * ConstantMatrixTypeBits.NumColumns; + return getNumRows() * getNumColumns(); } /// Returns true if \p NumElements is a valid matrix dimension. - static bool isDimensionValid(uint64_t NumElements) { - return NumElements > 0 && - NumElements <= ConstantMatrixTypeBitfields::MaxElementsPerDimension; + static constexpr bool isDimensionValid(size_t NumElements) { + return NumElements > 0 && NumElements <= MaxElementsPerDimension; } /// Returns the maximum number of elements per dimension. - static unsigned getMaxElementsPerDimension() { - return ConstantMatrixTypeBitfields::MaxElementsPerDimension; + static constexpr unsigned getMaxElementsPerDimension() { + return MaxElementsPerDimension; } void Profile(llvm::FoldingSetNodeID &ID) { @@ -4372,10 +4397,11 @@ class UnresolvedUsingType : public Type { class TypedefType : public Type { TypedefNameDecl *Decl; -protected: +private: friend class ASTContext; // ASTContext creates these. - TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can); + TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType underlying, + QualType can); public: TypedefNameDecl *getDecl() const { return Decl; } @@ -4726,6 +4752,9 @@ class AttributedType : public Type, public llvm::FoldingSetNode { case NullabilityKind::Nullable: return attr::TypeNullable; + case NullabilityKind::NullableResult: + return attr::TypeNullableResult; + case NullabilityKind::Unspecified: return attr::TypeNullUnspecified; } @@ -5118,11 +5147,24 @@ class alignas(8) TemplateSpecializationType public: /// Determine whether any of the given template arguments are dependent. - static bool anyDependentTemplateArguments(ArrayRef Args, - bool &InstantiationDependent); - - static bool anyDependentTemplateArguments(const TemplateArgumentListInfo &, - bool &InstantiationDependent); + /// + /// The converted arguments should be supplied when known; whether an + /// argument is dependent can depend on the conversions performed on it + /// (for example, a 'const int' passed as a template argument might be + /// dependent if the parameter is a reference but non-dependent if the + /// parameter is an int). + /// + /// Note that the \p Args parameter is unused: this is intentional, to remind + /// the caller that they need to pass in the converted arguments, not the + /// specified arguments. + static bool + anyDependentTemplateArguments(ArrayRef Args, + ArrayRef Converted); + static bool + anyDependentTemplateArguments(const TemplateArgumentListInfo &, + ArrayRef Converted); + static bool anyInstantiationDependentTemplateArguments( + ArrayRef Args); /// True if this template specialization type matches a current /// instantiation in the context in which it is found. @@ -5207,15 +5249,18 @@ class alignas(8) TemplateSpecializationType /// enclosing the template arguments. void printTemplateArgumentList(raw_ostream &OS, ArrayRef Args, - const PrintingPolicy &Policy); + const PrintingPolicy &Policy, + const TemplateParameterList *TPL = nullptr); void printTemplateArgumentList(raw_ostream &OS, ArrayRef Args, - const PrintingPolicy &Policy); + const PrintingPolicy &Policy, + const TemplateParameterList *TPL = nullptr); void printTemplateArgumentList(raw_ostream &OS, const TemplateArgumentListInfo &Args, - const PrintingPolicy &Policy); + const PrintingPolicy &Policy, + const TemplateParameterList *TPL = nullptr); /// The injected class name of a C++ class template or class /// template partial specialization. Used to record that a type was @@ -5401,7 +5446,9 @@ class ElaboratedType final ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, QualType CanonType, TagDecl *OwnedTagDecl) : TypeWithKeyword(Keyword, Elaborated, CanonType, - NamedType->getDependence()), + NamedType->getDependence() | + (NNS ? toTypeDependence(NNS->getDependence()) + : TypeDependence::None)), NNS(NNS), NamedType(NamedType) { ElaboratedTypeBits.HasOwnedTagDecl = false; if (OwnedTagDecl) { @@ -7056,6 +7103,15 @@ inline bool Type::isOverloadableType() const { return isDependentType() || isRecordType() || isEnumeralType(); } +/// Determines whether this type is written as a typedef-name. +inline bool Type::isTypedefNameType() const { + if (getAs()) + return true; + if (auto *TST = getAs()) + return TST->isTypeAlias(); + return false; +} + /// Determines whether this type can decay to a pointer type. inline bool Type::canDecayToPointerType() const { return isFunctionType() || isArrayType(); @@ -7085,55 +7141,28 @@ inline const Type *Type::getPointeeOrArrayElementType() const { return type->getBaseElementTypeUnsafe(); return type; } -/// Insertion operator for diagnostics. This allows sending address spaces into -/// a diagnostic with <<. -inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - LangAS AS) { - DB.AddTaggedVal(static_cast>(AS), - DiagnosticsEngine::ArgumentKind::ak_addrspace); - return DB; -} - /// Insertion operator for partial diagnostics. This allows sending adress /// spaces into a diagnostic with <<. -inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - LangAS AS) { +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD, + LangAS AS) { PD.AddTaggedVal(static_cast>(AS), DiagnosticsEngine::ArgumentKind::ak_addrspace); return PD; } -/// Insertion operator for diagnostics. This allows sending Qualifiers into a -/// diagnostic with <<. -inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - Qualifiers Q) { - DB.AddTaggedVal(Q.getAsOpaqueValue(), - DiagnosticsEngine::ArgumentKind::ak_qual); - return DB; -} - /// Insertion operator for partial diagnostics. This allows sending Qualifiers /// into a diagnostic with <<. -inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - Qualifiers Q) { +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD, + Qualifiers Q) { PD.AddTaggedVal(Q.getAsOpaqueValue(), DiagnosticsEngine::ArgumentKind::ak_qual); return PD; } -/// Insertion operator for diagnostics. This allows sending QualType's into a -/// diagnostic with <<. -inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - QualType T) { - DB.AddTaggedVal(reinterpret_cast(T.getAsOpaquePtr()), - DiagnosticsEngine::ak_qualtype); - return DB; -} - /// Insertion operator for partial diagnostics. This allows sending QualType's /// into a diagnostic with <<. -inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - QualType T) { +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD, + QualType T) { PD.AddTaggedVal(reinterpret_cast(T.getAsOpaquePtr()), DiagnosticsEngine::ak_qualtype); return PD; diff --git a/contrib/llvm-project/clang/include/clang/AST/TypeLoc.h b/contrib/llvm-project/clang/include/clang/AST/TypeLoc.h index 72cc8ef098e71a..65e95d52c303d4 100644 --- a/contrib/llvm-project/clang/include/clang/AST/TypeLoc.h +++ b/contrib/llvm-project/clang/include/clang/AST/TypeLoc.h @@ -603,32 +603,32 @@ class BuiltinTypeLoc : public ConcreteTypeLoc(getWrittenBuiltinSpecs().Sign); else - return TSS_unspecified; + return TypeSpecifierSign::Unspecified; } bool hasWrittenSignSpec() const { - return getWrittenSignSpec() != TSS_unspecified; + return getWrittenSignSpec() != TypeSpecifierSign::Unspecified; } void setWrittenSignSpec(TypeSpecifierSign written) { if (needsExtraLocalData()) - getWrittenBuiltinSpecs().Sign = written; + getWrittenBuiltinSpecs().Sign = static_cast(written); } TypeSpecifierWidth getWrittenWidthSpec() const { if (needsExtraLocalData()) return static_cast(getWrittenBuiltinSpecs().Width); else - return TSW_unspecified; + return TypeSpecifierWidth::Unspecified; } bool hasWrittenWidthSpec() const { - return getWrittenWidthSpec() != TSW_unspecified; + return getWrittenWidthSpec() != TypeSpecifierWidth::Unspecified; } void setWrittenWidthSpec(TypeSpecifierWidth written) { if (needsExtraLocalData()) - getWrittenBuiltinSpecs().Width = written; + getWrittenBuiltinSpecs().Width = static_cast(written); } TypeSpecifierType getWrittenTypeSpec() const; @@ -658,8 +658,8 @@ class BuiltinTypeLoc : public ConcreteTypeLoc(TypeSpecifierSign::Unspecified); + wbs.Width = static_cast(TypeSpecifierWidth::Unspecified); wbs.Type = TST_unspecified; wbs.ModeAttr = false; } @@ -1749,30 +1749,79 @@ class DependentAddressSpaceTypeLoc // FIXME: size expression and attribute locations (or keyword if we // ever fully support altivec syntax). -class VectorTypeLoc : public InheritingConcreteTypeLoc { +struct VectorTypeLocInfo { + SourceLocation NameLoc; +}; + +class VectorTypeLoc : public ConcreteTypeLoc { +public: + SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; } + + void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; } + + SourceRange getLocalSourceRange() const { + return SourceRange(getNameLoc(), getNameLoc()); + } + + void initializeLocal(ASTContext &Context, SourceLocation Loc) { + setNameLoc(Loc); + } + + TypeLoc getElementLoc() const { return getInnerTypeLoc(); } + + QualType getInnerType() const { return this->getTypePtr()->getElementType(); } }; // FIXME: size expression and attribute locations (or keyword if we // ever fully support altivec syntax). class DependentVectorTypeLoc - : public InheritingConcreteTypeLoc {}; + : public ConcreteTypeLoc { +public: + SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; } -// FIXME: size expression and attribute locations. -class ExtVectorTypeLoc : public InheritingConcreteTypeLoc { + void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; } + + SourceRange getLocalSourceRange() const { + return SourceRange(getNameLoc(), getNameLoc()); + } + + void initializeLocal(ASTContext &Context, SourceLocation Loc) { + setNameLoc(Loc); + } + + TypeLoc getElementLoc() const { return getInnerTypeLoc(); } + + QualType getInnerType() const { return this->getTypePtr()->getElementType(); } }; +// FIXME: size expression and attribute locations. +class ExtVectorTypeLoc + : public InheritingConcreteTypeLoc {}; + // FIXME: attribute locations. // For some reason, this isn't a subtype of VectorType. -class DependentSizedExtVectorTypeLoc : - public InheritingConcreteTypeLoc { +class DependentSizedExtVectorTypeLoc + : public ConcreteTypeLoc { +public: + SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; } + + void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; } + + SourceRange getLocalSourceRange() const { + return SourceRange(getNameLoc(), getNameLoc()); + } + + void initializeLocal(ASTContext &Context, SourceLocation Loc) { + setNameLoc(Loc); + } + + TypeLoc getElementLoc() const { return getInnerTypeLoc(); } + + QualType getInnerType() const { return this->getTypePtr()->getElementType(); } }; struct MatrixTypeLocInfo { diff --git a/contrib/llvm-project/clang/include/clang/AST/TypeProperties.td b/contrib/llvm-project/clang/include/clang/AST/TypeProperties.td index ed91670829b8bd..ffcc8290938fff 100644 --- a/contrib/llvm-project/clang/include/clang/AST/TypeProperties.td +++ b/contrib/llvm-project/clang/include/clang/AST/TypeProperties.td @@ -484,8 +484,12 @@ let Class = TagType in { let Read = [{ node->isDependentType() }]; } def : Property<"declaration", DeclRef> { - // Serializing a reference to the canonical declaration is apparently - // necessary to make module-merging work. + // We don't know which declaration was originally referenced here, and we + // cannot reference a declaration that follows the use (because that can + // introduce deserialization cycles), so conservatively generate a + // reference to the first declaration. + // FIXME: If this is a reference to a class template specialization, that + // can still introduce a deserialization cycle. let Read = [{ node->getDecl()->getCanonicalDecl() }]; } } @@ -761,6 +765,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/AArch64SVEACLETypes.def" +#define PPC_VECTOR_TYPE(NAME, ID, SIZE) \ + case BuiltinType::ID: return ctx.ID##Ty; +#include "clang/Basic/PPCTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchFinder.h b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchFinder.h index 0af98438ab52d4..81125ad8d96d5b 100644 --- a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchFinder.h +++ b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchFinder.h @@ -159,6 +159,8 @@ class MatchFinder { MatchCallback *Action); void addMatcher(const CXXCtorInitializerMatcher &NodeMatch, MatchCallback *Action); + void addMatcher(const TemplateArgumentLocMatcher &NodeMatch, + MatchCallback *Action); /// @} /// Adds a matcher to execute when running over the AST. @@ -209,6 +211,8 @@ class MatchFinder { NestedNameSpecifierLoc; std::vector> TypeLoc; std::vector> CtorInit; + std::vector> + TemplateArgumentLoc; /// All the callbacks in one container to simplify iteration. llvm::SmallPtrSet AllCallbacks; }; diff --git a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h index 643419743a119a..031fa4682c3abe 100644 --- a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -145,6 +145,8 @@ using TypeLocMatcher = internal::Matcher; using NestedNameSpecifierMatcher = internal::Matcher; using NestedNameSpecifierLocMatcher = internal::Matcher; using CXXCtorInitializerMatcher = internal::Matcher; +using TemplateArgumentMatcher = internal::Matcher; +using TemplateArgumentLocMatcher = internal::Matcher; /// @} /// Matches any node. @@ -306,10 +308,9 @@ AST_POLYMORPHIC_MATCHER_REGEX(isExpansionInFileMatching, /// Does not match if only part of the statement is expanded from that macro or /// if different parts of the the statement are expanded from different /// appearances of the macro. -/// -/// FIXME: Change to be a polymorphic matcher that works on any syntactic -/// node. There's nothing `Stmt`-specific about it. -AST_MATCHER_P(Stmt, isExpandedFromMacro, llvm::StringRef, MacroName) { +AST_POLYMORPHIC_MATCHER_P(isExpandedFromMacro, + AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc), + std::string, MacroName) { // Verifies that the statement' beginning and ending are both expanded from // the same instance of the given macro. auto& Context = Finder->getASTContext(); @@ -333,6 +334,19 @@ AST_MATCHER_P(Stmt, isExpandedFromMacro, llvm::StringRef, MacroName) { /// \endcode extern const internal::VariadicAllOfMatcher decl; +/// Matches decomposition-declarations. +/// +/// Examples matches the declaration node with \c foo and \c bar, but not +/// \c number. +/// (matcher = declStmt(has(decompositionDecl()))) +/// +/// \code +/// int number = 42; +/// auto [foo, bar] = std::make_pair{42, 42}; +/// \endcode +extern const internal::VariadicDynCastAllOfMatcher + decompositionDecl; + /// Matches a declaration of a linkage specification. /// /// Given @@ -515,6 +529,18 @@ extern const internal::VariadicAllOfMatcher /// matches 'int' in C. extern const internal::VariadicAllOfMatcher templateArgument; +/// Matches template arguments (with location info). +/// +/// Given +/// \code +/// template struct C {}; +/// C c; +/// \endcode +/// templateArgumentLoc() +/// matches 'int' in C. +extern const internal::VariadicAllOfMatcher + templateArgumentLoc; + /// Matches template name. /// /// Given @@ -549,6 +575,18 @@ extern const internal::VariadicDynCastAllOfMatcher templateTypeParmDecl; +/// Matches template template parameter declarations. +/// +/// Given +/// \code +/// template