├── .gitattributes ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── STATIC-CHECKS.md ├── USEME.md ├── checker ├── 3rdparty │ └── llvm-project_llvmorg-11.1.0.diff ├── CMakeLists.txt ├── README.md ├── build.bat ├── build.sh ├── checkout.bat ├── checkout.sh ├── cmake-ninja-debug.bat ├── doc │ ├── CHECKER-BUILD-WINDOWS-DEBUG.md │ ├── CHECKER-QUICK-START.md │ ├── CHECKER-RUN.md │ ├── CHECKER-TESTS.md │ ├── CHECKER.md │ └── INSTRUMENT.md ├── install.sh ├── set-path.bat ├── src │ ├── .clang-format │ ├── .clang-tidy │ ├── CMakeLists.txt │ ├── run-clang-tidy.py │ ├── safememory-checker │ │ ├── CMakeLists.txt │ │ ├── CheckerASTVisitor.h │ │ ├── CheckerData.cpp │ │ ├── CheckerData.h │ │ ├── ClangTidy.cpp │ │ ├── ClangTidy.h │ │ ├── ClangTidyDiagnosticConsumer.cpp │ │ ├── ClangTidyDiagnosticConsumer.h │ │ ├── ClangTidyModule.cpp │ │ ├── ClangTidyModule.h │ │ ├── ClangTidyModuleRegistry.h │ │ ├── ClangTidyOptions.cpp │ │ ├── ClangTidyOptions.h │ │ ├── ConsistencyRule.cpp │ │ ├── ConsistencyRule.h │ │ ├── DeterminismRule.cpp │ │ ├── DeterminismRule.h │ │ ├── FlagRiia.h │ │ ├── JSONSafeDatabase.cpp │ │ ├── JSONSafeDatabase.h │ │ ├── MiscellaneousRule.cpp │ │ ├── MiscellaneousRule.h │ │ ├── MustCoAwaitRule.cpp │ │ ├── MustCoAwaitRule.h │ │ ├── NoSideEffectRule.cpp │ │ ├── NoSideEffectRule.h │ │ ├── ReferenceOverCoAwaitRule.cpp │ │ ├── ReferenceOverCoAwaitRule.h │ │ ├── add_new_check.py │ │ ├── nodecpp │ │ │ ├── ArrayExprCheck.cpp │ │ │ ├── ArrayExprCheck.h │ │ │ ├── AsmCheck.cpp │ │ │ ├── AsmCheck.h │ │ │ ├── CMakeLists.txt │ │ │ ├── CallExprCheck.cpp │ │ │ ├── CallExprCheck.h │ │ │ ├── ConstCheck.cpp │ │ │ ├── ConstCheck.h │ │ │ ├── CoroutineCheck.cpp │ │ │ ├── CoroutineCheck.h │ │ │ ├── MayExtendLambdaCheck.cpp │ │ │ ├── MayExtendLambdaCheck.h │ │ │ ├── NakedAssignmentCheck.cpp │ │ │ ├── NakedAssignmentCheck.h │ │ │ ├── NakedPtrHelper.cpp │ │ │ ├── NakedPtrHelper.h │ │ │ ├── NewExprCheck.cpp │ │ │ ├── NewExprCheck.h │ │ │ ├── NodeCppTidyModule.cpp │ │ │ ├── RawPointerAssignmentCheck.cpp │ │ │ ├── RawPointerAssignmentCheck.h │ │ │ ├── RawPtrExprCheck.cpp │ │ │ ├── RawPtrExprCheck.h │ │ │ ├── RecordDeclCheck.cpp │ │ │ ├── RecordDeclCheck.h │ │ │ ├── ReturnCheck.cpp │ │ │ ├── ReturnCheck.h │ │ │ ├── StaticStorageCheck.cpp │ │ │ ├── StaticStorageCheck.h │ │ │ ├── StringLiteralCheck.cpp │ │ │ ├── StringLiteralCheck.h │ │ │ ├── TemporaryExprCheck.cpp │ │ │ ├── TemporaryExprCheck.h │ │ │ ├── VarDeclCheck.cpp │ │ │ └── VarDeclCheck.h │ │ ├── rename_check.py │ │ └── tool │ │ │ ├── CMakeLists.txt │ │ │ ├── ClangTidyMain.cpp │ │ │ ├── clang-tidy-diff.py │ │ │ └── run-clang-tidy.py │ ├── safememory-instrument │ │ ├── BaseASTVisitor.h │ │ ├── CMakeLists.txt │ │ ├── CodeChange.cpp │ │ ├── CodeChange.h │ │ ├── Dezombiefy.cpp │ │ ├── Dezombiefy.h │ │ ├── DezombiefyHelper.h │ │ ├── DezombiefyRelaxASTVisitor.h │ │ ├── Dezombify1ASTVisitor.h │ │ ├── Dezombify2ASTVisitor.h │ │ ├── InclusionRewriter.cpp │ │ ├── InclusionRewriter.h │ │ ├── NodeCppDezombify.cpp │ │ ├── Op2CallFixExprVisitor.h │ │ ├── SequenceCheckAndFix.cpp │ │ ├── SequenceCheckAndFix.h │ │ ├── SequenceCheckExprVisitor.h │ │ └── UnwrapFixExprVisitor.h │ ├── safememory-library-db │ │ ├── CMakeLists.txt │ │ ├── NodeCppSafeLibrary.cpp │ │ └── raiistdiofile.h │ ├── safememory-odr │ │ ├── CMakeLists.txt │ │ ├── SafeMemoryOdr.cpp │ │ └── raiistdiofile.h │ └── tidy.sh ├── test.bat ├── test.sh ├── test │ ├── CMakeLists.txt │ ├── check_safememory_instrument.py │ ├── checker │ │ ├── Inputs │ │ │ ├── awaitable.h │ │ │ ├── check_as_user_code.h │ │ │ ├── cstddef │ │ │ ├── cstdint │ │ │ ├── deep_const_type.h │ │ │ ├── functional │ │ │ ├── nodecpp_error.h │ │ │ ├── safememory │ │ │ │ ├── memory_safety.h │ │ │ │ ├── safe_ptr.h │ │ │ │ ├── safe_ptr_impl.h │ │ │ │ └── safe_ptr_no_checks.h │ │ │ ├── server.h │ │ │ ├── type_info │ │ │ ├── type_traits │ │ │ └── utility │ │ ├── c1.cpp │ │ ├── c2.cpp │ │ ├── c3.cpp │ │ ├── compile_flags.txt │ │ ├── d1.cpp │ │ ├── d2.cpp │ │ ├── m1.cpp │ │ ├── node.cpp │ │ ├── nodecpp-awaitable.cpp │ │ ├── nodecpp-deep-const.cpp │ │ ├── nodecpp-naked-struct.cpp │ │ ├── nodecpp-no-side-effect.cpp │ │ ├── nodecpp-var-decl.cpp │ │ ├── s1-1-1.cpp │ │ ├── s1-1.cpp │ │ ├── s1-3.cpp │ │ ├── s1-4.cpp │ │ ├── s1.cpp │ │ ├── s2.cpp │ │ ├── s3.cpp │ │ ├── s4.cpp │ │ ├── s5-1.cpp │ │ ├── s5-3.cpp │ │ ├── s5-7.cpp │ │ ├── s5-8.cpp │ │ ├── s6.cpp │ │ ├── s8.cpp │ │ ├── s8.json │ │ ├── s9.cpp │ │ └── safe_memory_check_as_user_code.cpp │ ├── instrument │ │ ├── .gitignore │ │ ├── Inputs │ │ │ ├── cstddef │ │ │ ├── cstdint │ │ │ ├── safe_types.h │ │ │ ├── safememory │ │ │ │ ├── detail │ │ │ │ │ └── instrument.h │ │ │ │ ├── memory_safety.h │ │ │ │ ├── safe_ptr.h │ │ │ │ ├── safe_ptr_impl.h │ │ │ │ └── safe_ptr_no_checks.h │ │ │ ├── type_traits │ │ │ └── utility │ │ ├── check_Z1.cpp │ │ ├── check_Z2.cpp │ │ ├── check_Z9.cpp │ │ ├── compile_flags.txt │ │ ├── dz_base.cpp │ │ ├── dz_constexpr_if.cpp │ │ ├── dz_param_pack.cpp │ │ ├── dz_template_class.cpp │ │ ├── dz_template_error_1.cpp │ │ ├── dz_template_func.cpp │ │ ├── dz_template_out_of_line.cpp │ │ ├── fix_Z1.cpp │ │ ├── fix_Z1_macro_error.cpp │ │ ├── fix_Z2_args.cpp │ │ ├── fix_Z2_macro_error.cpp │ │ ├── fix_Z2_move.cpp │ │ ├── fix_Z2_op.cpp │ │ ├── fix_Z2_param_pack.cpp │ │ ├── fix_Z2_stmt.cpp │ │ ├── fix_Z2_this.cpp │ │ └── user_include.h │ ├── library │ │ ├── all-good.cpp │ │ ├── compile_flags.txt │ │ ├── dump.txt │ │ ├── iterator.cpp │ │ ├── library-db │ │ │ ├── nodecpp.hpp │ │ │ ├── safememory.hpp │ │ │ └── std.hpp │ │ ├── rules.cpp │ │ ├── rules5.cpp │ │ ├── safe_library.hpp │ │ ├── safe_library.json │ │ ├── string_literal.cpp │ │ ├── unordered_map.cpp │ │ └── vector.cpp │ ├── lit.cfg │ └── lit.site.cfg.in └── tools │ └── teamcity-ninja-windows.bat └── library ├── 3rdparty ├── EABase-2.09.06.diff ├── EABase-EASTL.md ├── EABase │ ├── .gitignore │ ├── .gitmodules │ ├── .p4ignore │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── doc │ │ └── EABase.html │ ├── include │ │ └── Common │ │ │ └── EABase │ │ │ ├── config │ │ │ ├── eacompiler.h │ │ │ ├── eacompilertraits.h │ │ │ └── eaplatform.h │ │ │ ├── eabase.h │ │ │ ├── eahave.h │ │ │ ├── earesult.h │ │ │ ├── eastdarg.h │ │ │ ├── eaunits.h │ │ │ ├── int128.h │ │ │ ├── nullptr.h │ │ │ └── version.h │ └── test │ │ ├── CMakeLists.txt │ │ └── source │ │ ├── CEntryPoint.cpp │ │ ├── TestEABase.cpp │ │ ├── TestEABase.h │ │ ├── TestEABaseC.c │ │ └── TestEABaseSeparate.cpp ├── EASTL-3.17.03.diff ├── EASTL-3.18.00.diff ├── EASTL-3.19.05.diff ├── EASTL │ ├── .clang-format │ ├── .gitattributes │ ├── .github │ │ └── workflows │ │ │ └── c-cpp.yml │ ├── .gitignore │ ├── .gitmodules │ ├── .p4ignore │ ├── .travis.yml │ ├── 3RDPARTYLICENSES.TXT │ ├── CMakeLists.txt │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── _config.yml │ ├── benchmark │ │ ├── CMakeLists.txt │ │ └── source │ │ │ ├── BenchmarkAlgorithm.cpp │ │ │ ├── BenchmarkBitset.cpp │ │ │ ├── BenchmarkDeque.cpp │ │ │ ├── BenchmarkHash.cpp │ │ │ ├── BenchmarkHeap.cpp │ │ │ ├── BenchmarkList.cpp │ │ │ ├── BenchmarkMap.cpp │ │ │ ├── BenchmarkSet.cpp │ │ │ ├── BenchmarkSort.cpp │ │ │ ├── BenchmarkString.cpp │ │ │ ├── BenchmarkTupleVector.cpp │ │ │ ├── BenchmarkVector.cpp │ │ │ ├── EASTLBenchmark.cpp │ │ │ ├── EASTLBenchmark.h │ │ │ └── main.cpp │ ├── doc │ │ ├── Benchmarks.md │ │ ├── BestPractices.md │ │ ├── Bonus │ │ │ └── tuple_vector_readme.md │ │ ├── CMake │ │ │ └── EASTL_Project_Integration.md │ │ ├── Design.md │ │ ├── EASTL-n2271.pdf │ │ ├── EASTL.natvis │ │ ├── FAQ.md │ │ ├── Glossary.md │ │ ├── Gotchas.md │ │ ├── Introduction.md │ │ ├── Maintenance.md │ │ ├── Modules.md │ │ ├── html │ │ │ ├── EASTL Benchmarks.html │ │ │ ├── EASTL Best Practices.html │ │ │ ├── EASTL Design.html │ │ │ ├── EASTL FAQ.html │ │ │ ├── EASTL Glossary.html │ │ │ ├── EASTL Gotchas.html │ │ │ ├── EASTL Introduction.html │ │ │ ├── EASTL Maintenance.html │ │ │ ├── EASTL Modules.html │ │ │ └── EASTLDoc.css │ │ └── quick-reference.pdf │ ├── include │ │ └── EASTL │ │ │ ├── algorithm.h │ │ │ ├── allocator.h │ │ │ ├── allocator_malloc.h │ │ │ ├── any.h │ │ │ ├── array.h │ │ │ ├── atomic.h │ │ │ ├── bit.h │ │ │ ├── bitset.h │ │ │ ├── bitvector.h │ │ │ ├── bonus │ │ │ ├── adaptors.h │ │ │ ├── call_traits.h │ │ │ ├── compressed_pair.h │ │ │ ├── fixed_ring_buffer.h │ │ │ ├── fixed_tuple_vector.h │ │ │ ├── intrusive_sdlist.h │ │ │ ├── intrusive_slist.h │ │ │ ├── list_map.h │ │ │ ├── lru_cache.h │ │ │ ├── overloaded.h │ │ │ ├── ring_buffer.h │ │ │ ├── sort_extra.h │ │ │ └── tuple_vector.h │ │ │ ├── chrono.h │ │ │ ├── compare.h │ │ │ ├── core_allocator.h │ │ │ ├── core_allocator_adapter.h │ │ │ ├── deque.h │ │ │ ├── finally.h │ │ │ ├── fixed_allocator.h │ │ │ ├── fixed_function.h │ │ │ ├── fixed_hash_map.h │ │ │ ├── fixed_hash_set.h │ │ │ ├── fixed_list.h │ │ │ ├── fixed_map.h │ │ │ ├── fixed_set.h │ │ │ ├── fixed_slist.h │ │ │ ├── fixed_string.h │ │ │ ├── fixed_substring.h │ │ │ ├── fixed_vector.h │ │ │ ├── functional.h │ │ │ ├── hash_map.h │ │ │ ├── hash_set.h │ │ │ ├── heap.h │ │ │ ├── initializer_list.h │ │ │ ├── internal │ │ │ ├── atomic │ │ │ │ ├── arch │ │ │ │ │ ├── arch.h │ │ │ │ │ ├── arch_add_fetch.h │ │ │ │ │ ├── arch_and_fetch.h │ │ │ │ │ ├── arch_cmpxchg_strong.h │ │ │ │ │ ├── arch_cmpxchg_weak.h │ │ │ │ │ ├── arch_compiler_barrier.h │ │ │ │ │ ├── arch_cpu_pause.h │ │ │ │ │ ├── arch_exchange.h │ │ │ │ │ ├── arch_fetch_add.h │ │ │ │ │ ├── arch_fetch_and.h │ │ │ │ │ ├── arch_fetch_or.h │ │ │ │ │ ├── arch_fetch_sub.h │ │ │ │ │ ├── arch_fetch_xor.h │ │ │ │ │ ├── arch_load.h │ │ │ │ │ ├── arch_memory_barrier.h │ │ │ │ │ ├── arch_or_fetch.h │ │ │ │ │ ├── arch_signal_fence.h │ │ │ │ │ ├── arch_store.h │ │ │ │ │ ├── arch_sub_fetch.h │ │ │ │ │ ├── arch_thread_fence.h │ │ │ │ │ ├── arch_xor_fetch.h │ │ │ │ │ ├── arm │ │ │ │ │ │ ├── arch_arm.h │ │ │ │ │ │ ├── arch_arm_load.h │ │ │ │ │ │ ├── arch_arm_memory_barrier.h │ │ │ │ │ │ ├── arch_arm_store.h │ │ │ │ │ │ └── arch_arm_thread_fence.h │ │ │ │ │ └── x86 │ │ │ │ │ │ ├── arch_x86.h │ │ │ │ │ │ ├── arch_x86_add_fetch.h │ │ │ │ │ │ ├── arch_x86_and_fetch.h │ │ │ │ │ │ ├── arch_x86_cmpxchg_strong.h │ │ │ │ │ │ ├── arch_x86_cmpxchg_weak.h │ │ │ │ │ │ ├── arch_x86_exchange.h │ │ │ │ │ │ ├── arch_x86_fetch_add.h │ │ │ │ │ │ ├── arch_x86_fetch_and.h │ │ │ │ │ │ ├── arch_x86_fetch_or.h │ │ │ │ │ │ ├── arch_x86_fetch_sub.h │ │ │ │ │ │ ├── arch_x86_fetch_xor.h │ │ │ │ │ │ ├── arch_x86_load.h │ │ │ │ │ │ ├── arch_x86_memory_barrier.h │ │ │ │ │ │ ├── arch_x86_or_fetch.h │ │ │ │ │ │ ├── arch_x86_store.h │ │ │ │ │ │ ├── arch_x86_sub_fetch.h │ │ │ │ │ │ ├── arch_x86_thread_fence.h │ │ │ │ │ │ └── arch_x86_xor_fetch.h │ │ │ │ ├── atomic.h │ │ │ │ ├── atomic_asserts.h │ │ │ │ ├── atomic_base_width.h │ │ │ │ ├── atomic_casts.h │ │ │ │ ├── atomic_flag.h │ │ │ │ ├── atomic_flag_standalone.h │ │ │ │ ├── atomic_integral.h │ │ │ │ ├── atomic_macros.h │ │ │ │ ├── atomic_macros │ │ │ │ │ ├── atomic_macros.h │ │ │ │ │ ├── atomic_macros_add_fetch.h │ │ │ │ │ ├── atomic_macros_and_fetch.h │ │ │ │ │ ├── atomic_macros_base.h │ │ │ │ │ ├── atomic_macros_cmpxchg_strong.h │ │ │ │ │ ├── atomic_macros_cmpxchg_weak.h │ │ │ │ │ ├── atomic_macros_compiler_barrier.h │ │ │ │ │ ├── atomic_macros_cpu_pause.h │ │ │ │ │ ├── atomic_macros_exchange.h │ │ │ │ │ ├── atomic_macros_fetch_add.h │ │ │ │ │ ├── atomic_macros_fetch_and.h │ │ │ │ │ ├── atomic_macros_fetch_or.h │ │ │ │ │ ├── atomic_macros_fetch_sub.h │ │ │ │ │ ├── atomic_macros_fetch_xor.h │ │ │ │ │ ├── atomic_macros_load.h │ │ │ │ │ ├── atomic_macros_memory_barrier.h │ │ │ │ │ ├── atomic_macros_or_fetch.h │ │ │ │ │ ├── atomic_macros_signal_fence.h │ │ │ │ │ ├── atomic_macros_store.h │ │ │ │ │ ├── atomic_macros_sub_fetch.h │ │ │ │ │ ├── atomic_macros_thread_fence.h │ │ │ │ │ └── atomic_macros_xor_fetch.h │ │ │ │ ├── atomic_memory_order.h │ │ │ │ ├── atomic_pointer.h │ │ │ │ ├── atomic_pop_compiler_options.h │ │ │ │ ├── atomic_push_compiler_options.h │ │ │ │ ├── atomic_size_aligned.h │ │ │ │ ├── atomic_standalone.h │ │ │ │ └── compiler │ │ │ │ │ ├── compiler.h │ │ │ │ │ ├── compiler_add_fetch.h │ │ │ │ │ ├── compiler_and_fetch.h │ │ │ │ │ ├── compiler_barrier.h │ │ │ │ │ ├── compiler_cmpxchg_strong.h │ │ │ │ │ ├── compiler_cmpxchg_weak.h │ │ │ │ │ ├── compiler_cpu_pause.h │ │ │ │ │ ├── compiler_exchange.h │ │ │ │ │ ├── compiler_fetch_add.h │ │ │ │ │ ├── compiler_fetch_and.h │ │ │ │ │ ├── compiler_fetch_or.h │ │ │ │ │ ├── compiler_fetch_sub.h │ │ │ │ │ ├── compiler_fetch_xor.h │ │ │ │ │ ├── compiler_load.h │ │ │ │ │ ├── compiler_memory_barrier.h │ │ │ │ │ ├── compiler_or_fetch.h │ │ │ │ │ ├── compiler_signal_fence.h │ │ │ │ │ ├── compiler_store.h │ │ │ │ │ ├── compiler_sub_fetch.h │ │ │ │ │ ├── compiler_thread_fence.h │ │ │ │ │ ├── compiler_xor_fetch.h │ │ │ │ │ ├── gcc │ │ │ │ │ ├── compiler_gcc.h │ │ │ │ │ ├── compiler_gcc_add_fetch.h │ │ │ │ │ ├── compiler_gcc_and_fetch.h │ │ │ │ │ ├── compiler_gcc_barrier.h │ │ │ │ │ ├── compiler_gcc_cmpxchg_strong.h │ │ │ │ │ ├── compiler_gcc_cmpxchg_weak.h │ │ │ │ │ ├── compiler_gcc_cpu_pause.h │ │ │ │ │ ├── compiler_gcc_exchange.h │ │ │ │ │ ├── compiler_gcc_fetch_add.h │ │ │ │ │ ├── compiler_gcc_fetch_and.h │ │ │ │ │ ├── compiler_gcc_fetch_or.h │ │ │ │ │ ├── compiler_gcc_fetch_sub.h │ │ │ │ │ ├── compiler_gcc_fetch_xor.h │ │ │ │ │ ├── compiler_gcc_load.h │ │ │ │ │ ├── compiler_gcc_or_fetch.h │ │ │ │ │ ├── compiler_gcc_signal_fence.h │ │ │ │ │ ├── compiler_gcc_store.h │ │ │ │ │ ├── compiler_gcc_sub_fetch.h │ │ │ │ │ ├── compiler_gcc_thread_fence.h │ │ │ │ │ └── compiler_gcc_xor_fetch.h │ │ │ │ │ └── msvc │ │ │ │ │ ├── compiler_msvc.h │ │ │ │ │ ├── compiler_msvc_add_fetch.h │ │ │ │ │ ├── compiler_msvc_and_fetch.h │ │ │ │ │ ├── compiler_msvc_barrier.h │ │ │ │ │ ├── compiler_msvc_cmpxchg_strong.h │ │ │ │ │ ├── compiler_msvc_cmpxchg_weak.h │ │ │ │ │ ├── compiler_msvc_cpu_pause.h │ │ │ │ │ ├── compiler_msvc_exchange.h │ │ │ │ │ ├── compiler_msvc_fetch_add.h │ │ │ │ │ ├── compiler_msvc_fetch_and.h │ │ │ │ │ ├── compiler_msvc_fetch_or.h │ │ │ │ │ ├── compiler_msvc_fetch_sub.h │ │ │ │ │ ├── compiler_msvc_fetch_xor.h │ │ │ │ │ ├── compiler_msvc_or_fetch.h │ │ │ │ │ ├── compiler_msvc_signal_fence.h │ │ │ │ │ ├── compiler_msvc_sub_fetch.h │ │ │ │ │ └── compiler_msvc_xor_fetch.h │ │ │ ├── char_traits.h │ │ │ ├── config.h │ │ │ ├── copy_help.h │ │ │ ├── enable_shared.h │ │ │ ├── fill_help.h │ │ │ ├── fixed_pool.h │ │ │ ├── function.h │ │ │ ├── function_detail.h │ │ │ ├── function_help.h │ │ │ ├── functional_base.h │ │ │ ├── generic_iterator.h │ │ │ ├── hashtable.h │ │ │ ├── in_place_t.h │ │ │ ├── integer_sequence.h │ │ │ ├── intrusive_hashtable.h │ │ │ ├── mem_fn.h │ │ │ ├── memory_base.h │ │ │ ├── move_help.h │ │ │ ├── pair_fwd_decls.h │ │ │ ├── piecewise_construct_t.h │ │ │ ├── red_black_tree.h │ │ │ ├── smart_ptr.h │ │ │ ├── thread_support.h │ │ │ ├── tuple_fwd_decls.h │ │ │ ├── type_compound.h │ │ │ ├── type_detected.h │ │ │ ├── type_fundamental.h │ │ │ ├── type_pod.h │ │ │ ├── type_properties.h │ │ │ ├── type_transformations.h │ │ │ └── type_void_t.h │ │ │ ├── intrusive_hash_map.h │ │ │ ├── intrusive_hash_set.h │ │ │ ├── intrusive_list.h │ │ │ ├── intrusive_ptr.h │ │ │ ├── iterator.h │ │ │ ├── linked_array.h │ │ │ ├── linked_ptr.h │ │ │ ├── list.h │ │ │ ├── map.h │ │ │ ├── memory.h │ │ │ ├── meta.h │ │ │ ├── numeric.h │ │ │ ├── numeric_limits.h │ │ │ ├── optional.h │ │ │ ├── priority_queue.h │ │ │ ├── queue.h │ │ │ ├── random.h │ │ │ ├── ratio.h │ │ │ ├── safe_ptr.h │ │ │ ├── scoped_array.h │ │ │ ├── scoped_ptr.h │ │ │ ├── segmented_vector.h │ │ │ ├── set.h │ │ │ ├── shared_array.h │ │ │ ├── shared_ptr.h │ │ │ ├── slist.h │ │ │ ├── sort.h │ │ │ ├── span.h │ │ │ ├── stack.h │ │ │ ├── string.h │ │ │ ├── string_hash_map.h │ │ │ ├── string_map.h │ │ │ ├── string_view.h │ │ │ ├── tuple.h │ │ │ ├── type_traits.h │ │ │ ├── unique_ptr.h │ │ │ ├── unordered_map.h │ │ │ ├── unordered_set.h │ │ │ ├── utility.h │ │ │ ├── variant.h │ │ │ ├── vector.h │ │ │ ├── vector_map.h │ │ │ ├── vector_multimap.h │ │ │ ├── vector_multiset.h │ │ │ ├── vector_set.h │ │ │ ├── version.h │ │ │ └── weak_ptr.h │ ├── scripts │ │ ├── CMake │ │ │ └── CommonCppFlags.cmake │ │ └── build.sh │ ├── source │ │ ├── allocator_eastl.cpp │ │ ├── assert.cpp │ │ ├── atomic.cpp │ │ ├── fixed_pool.cpp │ │ ├── hashtable.cpp │ │ ├── intrusive_list.cpp │ │ ├── numeric_limits.cpp │ │ ├── red_black_tree.cpp │ │ ├── string.cpp │ │ └── thread_support.cpp │ └── test │ │ ├── CMakeLists.txt │ │ └── source │ │ ├── ConceptImpls.h │ │ ├── EASTLTest.cpp │ │ ├── EASTLTest.h │ │ ├── EASTLTestAllocator.cpp │ │ ├── EASTLTestAllocator.h │ │ ├── GetTypeName.h │ │ ├── TestAlgorithm.cpp │ │ ├── TestAllocator.cpp │ │ ├── TestAny.cpp │ │ ├── TestArray.cpp │ │ ├── TestAtomicAsm.cpp │ │ ├── TestAtomicBasic.cpp │ │ ├── TestBitVector.cpp │ │ ├── TestBitcast.cpp │ │ ├── TestBitset.cpp │ │ ├── TestCharTraits.cpp │ │ ├── TestChrono.cpp │ │ ├── TestCppCXTypeTraits.cpp │ │ ├── TestDeque.cpp │ │ ├── TestExtra.cpp │ │ ├── TestFinally.cpp │ │ ├── TestFixedFunction.cpp │ │ ├── TestFixedHash.cpp │ │ ├── TestFixedList.cpp │ │ ├── TestFixedMap.cpp │ │ ├── TestFixedSList.cpp │ │ ├── TestFixedSet.cpp │ │ ├── TestFixedString.cpp │ │ ├── TestFixedTupleVector.cpp │ │ ├── TestFixedVector.cpp │ │ ├── TestFunctional.cpp │ │ ├── TestHash.cpp │ │ ├── TestHeap.cpp │ │ ├── TestIntrusiveHash.cpp │ │ ├── TestIntrusiveList.cpp │ │ ├── TestIntrusiveSDList.cpp │ │ ├── TestIntrusiveSList.cpp │ │ ├── TestIterator.cpp │ │ ├── TestList.cpp │ │ ├── TestListMap.cpp │ │ ├── TestLruCache.cpp │ │ ├── TestMap.cpp │ │ ├── TestMap.h │ │ ├── TestMemory.cpp │ │ ├── TestMeta.cpp │ │ ├── TestNumericLimits.cpp │ │ ├── TestOptional.cpp │ │ ├── TestRandom.cpp │ │ ├── TestRatio.cpp │ │ ├── TestRingBuffer.cpp │ │ ├── TestSList.cpp │ │ ├── TestSegmentedVector.cpp │ │ ├── TestSet.cpp │ │ ├── TestSet.h │ │ ├── TestSmartPtr.cpp │ │ ├── TestSort.cpp │ │ ├── TestSpan.cpp │ │ ├── TestString.cpp │ │ ├── TestString.inl │ │ ├── TestStringHashMap.cpp │ │ ├── TestStringMap.cpp │ │ ├── TestStringView.cpp │ │ ├── TestStringView.inl │ │ ├── TestTuple.cpp │ │ ├── TestTupleVector.cpp │ │ ├── TestTypeTraits.cpp │ │ ├── TestUtility.cpp │ │ ├── TestVariant.cpp │ │ ├── TestVariant2.cpp │ │ ├── TestVector.cpp │ │ ├── TestVectorMap.cpp │ │ ├── TestVectorSet.cpp │ │ └── main.cpp ├── clone-EABase-EASTL.bat └── clone-EABase-EASTL.sh ├── CMakeLists.txt ├── doc ├── DIRECTORY-LAYOUT.md ├── EASTL-and-containers.md └── dezombiefy-iterators.md ├── gcc_lto_workaround ├── build_gcc_lto_workaround_so.sh ├── gcc_lto_workaround.cpp └── install_lib.sh ├── include ├── nodecpp_error │ └── nodecpp_error.h └── safememory │ ├── algorithm.h │ ├── array.h │ ├── detail │ ├── allocator_to_eastl.h │ ├── array_iterator.h │ ├── checker_attributes.h │ ├── dezombiefy_iterators.h │ ├── flexible_array.h │ ├── hashtable_iterator.h │ ├── instrument.h │ ├── safe_ptr_common.h │ └── soft_ptr_with_zero_offset.h │ ├── functional.h │ ├── memory_safety.h │ ├── safe_ptr.h │ ├── sm_containers.h │ ├── string.h │ ├── string_format.h │ ├── string_literal.h │ ├── unordered_map.h │ ├── unordered_set.h │ └── vector.h ├── samples ├── CMakeLists.txt ├── basic_sample │ ├── CMakeLists.txt │ ├── build │ │ ├── basic_sample.sln │ │ ├── basic_sample.vcxproj │ │ ├── build_clang.sh │ │ └── build_gcc.sh │ └── src │ │ └── main.cpp ├── hashmap │ ├── CMakeLists.txt │ └── main.cpp ├── string │ ├── CMakeLists.txt │ └── main.cpp └── vector │ ├── CMakeLists.txt │ └── main.cpp ├── src ├── detail │ └── allocator_to_eastl.cpp ├── memory_safety.h ├── nodecpp_error.cpp ├── safe_ptr.cpp ├── safe_ptr.h ├── safe_ptr_common.h ├── safe_ptr_impl.h ├── safe_ptr_no_checks.h ├── startup_checks.h └── string.cpp ├── test ├── build │ ├── TestSafePointers.sln │ ├── TestSafePointers.vcxproj │ ├── build_clang.sh │ ├── build_clang_no_workaround.sh │ ├── build_clang_no_workaround_no_lto.sh │ ├── build_clang_with_destruction_info.sh │ ├── build_clang_with_workaround.sh │ ├── build_gcc.sh │ ├── build_gcc_no_lifetime_dse.sh │ ├── build_gcc_no_workaround.sh │ ├── build_gcc_no_workaround_no_lto.sh │ ├── build_gcc_with_destruction_info.sh │ └── build_gcc_with_workaround.sh ├── containers │ ├── EASTL-benchmark │ │ ├── BenchmarkHash.cpp │ │ ├── BenchmarkString.cpp │ │ ├── BenchmarkVector.cpp │ │ ├── CMakeLists.txt │ │ ├── EASTLBenchmark.cpp │ │ ├── EASTLBenchmark.h │ │ ├── EASTLTest.cpp │ │ ├── EASTLTest.h │ │ ├── EAStopwatch.cpp │ │ ├── EAStopwatch.h │ │ └── main.cpp │ ├── EASTL-test │ │ ├── CMakeLists.txt │ │ ├── ConceptImpls.h │ │ ├── EASTLTest.cpp │ │ ├── EASTLTest.h │ │ ├── TestArray.cpp │ │ ├── TestHash.cpp │ │ ├── TestMap.h │ │ ├── TestSet.h │ │ ├── TestString.cpp │ │ ├── TestString.inl │ │ ├── TestVector.cpp │ │ └── main.cpp │ ├── README.txt │ ├── dezombiefy │ │ ├── CMakeLists.txt │ │ └── test_dezombiefy_iterators.cpp │ └── zeroed │ │ ├── CMakeLists.txt │ │ └── test_zeroed_containers.cpp ├── dummy_test_objects.h ├── safety_exclusions.h ├── sample_containers.h └── test_safe_pointers.cpp └── tools ├── ci-android-r23c.bat ├── ci-clang11.sh ├── ci-clang13.sh ├── ci-gcc10.sh ├── ci-vs2019.bat └── ci-vs2022.bat /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | 3 | *.bat text eol=crlf 4 | *.cmd text eol=crlf 5 | *.sln text eol=crlf 6 | *.vcproj text eol=crlf 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .idea 3 | .vs 4 | *.vcxproj.user 5 | *.vcxproj.filters 6 | **/build/x64/ 7 | **/build/Debug/ 8 | **/build/Release/ 9 | /library/build/ 10 | /checker/build/ 11 | /checker/3rdparty/llvm/ 12 | /checker/3rdparty/clang/ 13 | /checker/3rdparty/llvm-project/ 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "library/3rdparty/lest"] 2 | path = library/3rdparty/lest 3 | url = https://github.com/martinmoene/lest 4 | [submodule "library/src/iibmalloc"] 5 | path = library/src/iibmalloc 6 | url = https://github.com/node-dot-cpp/iibmalloc 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | os: linux 3 | dist: bionic 4 | notifications: 5 | email: 6 | if: branch = master OR branch = develop 7 | script: 8 | - cd library 9 | - ./checkout-eastl.sh 10 | - ./src/iibmalloc/src/foundation/tools/travis-unix.sh 11 | addons: 12 | apt: 13 | packages: 14 | - ninja-build 15 | jobs: 16 | include: 17 | - name: Linux GCC 18 | compiler: gcc 19 | - name: Windows MSVC 20 | os: windows 21 | script: 22 | - cd library 23 | - ./checkout-eastl.bat 24 | - ./src/iibmalloc/src/foundation/tools/travis-windows-msvc.bat 25 | - name: macOS Clang 26 | os: osx 27 | compiler: clang 28 | - name: Linux Clang 29 | compiler: clang 30 | - name: Windows Clang 31 | os: windows 32 | install: choco install ninja 33 | script: 34 | - cd library 35 | - ./checkout-eastl.bat 36 | - ./src/iibmalloc/src/foundation/tools/travis-windows-clang.bat 37 | allow_failures: 38 | - name: macOS Clang 39 | - name: Windows Clang 40 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2020, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | cmake_minimum_required(VERSION 3.0) 5 | project(safememory CXX) 6 | set(CMAKE_CXX_STANDARD 17) 7 | include(CTest) 8 | 9 | 10 | #------------------------------------------------------------------------------------------- 11 | # Options 12 | #------------------------------------------------------------------------------------------- 13 | option(SAFEMEMORY_BUILD_CHECKER "Enable generation of checker tool" OFF) 14 | 15 | #------------------------------------------------------------------------------------------- 16 | # Library definition 17 | #------------------------------------------------------------------------------------------- 18 | add_subdirectory(library) 19 | 20 | if(SAFEMEMORY_BUILD_CHECKER) 21 | add_subdirectory(checker) 22 | endif() 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018-2019, OLogN Technologies AG 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /checker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2020, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | 5 | # mb: this is not the real root CMakeLists.txt for this project. 6 | # this project requires to be built as part of llvm/clang build, 7 | # as an llvm 'external' project. 8 | # This file will be processed from inside clang, as an external tool. 9 | 10 | add_subdirectory(src) 11 | 12 | # Add the testsuite after all the tools. 13 | if(CLANG_INCLUDE_TESTS) 14 | add_subdirectory(test) 15 | endif() 16 | -------------------------------------------------------------------------------- /checker/README.md: -------------------------------------------------------------------------------- 1 | # static-checker 2 | Tools for static check of C++ following rules of [__memory-safe-cpp__](https://github.com/node-dot-cpp/memory-safe-cpp) 3 | 4 | 5 | 6 | Goals 7 | ----- 8 | 9 | The memory-safe C++ (as defined at memory-safe-cpp) require of static checks and runtime checks. This project is intended to provide the tools for the static checks. 10 | 11 | 12 | Overview 13 | -------- 14 | The static check tools are based on __clang7 tooling AST__. This means that any source code that is accepted by clang7 _should_ be accepted by the tool. It also means that building the tool implies building big part of clang7. 15 | 16 | 17 | Please see [doc/CHECKER-QUICK-START.md](doc/CHECKER-QUICK-START.md) for a quick introduction to build and use of the tools. 18 | 19 | -------------------------------------------------------------------------------- /checker/build.bat: -------------------------------------------------------------------------------- 1 | 2 | rmdir /S /Q build\vs 3 | mkdir build\vs 4 | cd build\vs 5 | 6 | cmake -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_EXTERNAL_SAFEMEMORY_SOURCE_DIR=%cd%\..\.. -Thost=x64 -G "Visual Studio 16 2019" ..\..\3rdparty\llvm-project\llvm 7 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 8 | 9 | cmake --build . --target safememory-checker --config Release 10 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 11 | 12 | cmake --build . --target safememory-instrument --config Release 13 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 14 | 15 | cmake --build . --target safememory-library-db --config Release 16 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 17 | 18 | cmake --build . --target safememory-odr --config Release 19 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 20 | 21 | cmake --build . --target check-safememory-tools --config Release 22 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 23 | 24 | cd ..\.. 25 | 26 | -------------------------------------------------------------------------------- /checker/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ev 3 | 4 | rm -Rf build/release 5 | mkdir -p build/release 6 | cd build/release 7 | 8 | 9 | # Uncomment lines below to use clang or change to other compiler 10 | # 11 | #export CC=clang-7 12 | #export CXX=clang++-7 13 | 14 | cmake -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_EXTERNAL_SAFEMEMORY_SOURCE_DIR=${PWD}/../.. -G "Unix Makefiles" ../../3rdparty/llvm-project/llvm 15 | 16 | cmake --build . --target safememory-checker 17 | cmake --build . --target safememory-instrument 18 | cmake --build . --target safememory-library-db 19 | cmake --build . --target safememory-odr 20 | 21 | cmake --build . --target check-safememory-tools 22 | 23 | 24 | cd ../.. 25 | 26 | -------------------------------------------------------------------------------- /checker/checkout.bat: -------------------------------------------------------------------------------- 1 | 2 | cd 3rdparty 3 | 4 | rmdir /S /Q llvm 5 | rmdir /S /Q clang 6 | rmdir /S /Q clang-tools-extra 7 | rmdir /S /Q llvm-project 8 | 9 | git clone --depth 1 --branch llvmorg-11.1.0 https://github.com/llvm/llvm-project.git 10 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 11 | 12 | cd llvm-project 13 | git apply ..\llvm-project_llvmorg-11.1.0.diff 14 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 15 | 16 | cd ..\.. 17 | 18 | -------------------------------------------------------------------------------- /checker/checkout.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ev 3 | 4 | cd 3rdparty 5 | 6 | rm -Rf llvm 7 | rm -Rf clang 8 | rm -Rf clang-tools-extra 9 | rm -Rf llvm-project 10 | 11 | git clone --depth 1 --branch llvmorg-11.1.0 https://github.com/llvm/llvm-project.git 12 | 13 | cd llvm-project 14 | git apply ../llvm-project_llvmorg-11.1.0.diff 15 | 16 | cd ../.. 17 | -------------------------------------------------------------------------------- /checker/cmake-ninja-debug.bat: -------------------------------------------------------------------------------- 1 | rmdir /S /Q build\debug 2 | mkdir build\debug 3 | cd build\debug 4 | 5 | cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_EXTERNAL_SAFEMEMORY_SOURCE_DIR=%cd%\..\.. -G Ninja ..\..\3rdparty\llvm-project\llvm 6 | -------------------------------------------------------------------------------- /checker/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cp build/release/bin/safememory-* /usr/local/bin 4 | 5 | mkdir -p /usr/local/lib/clang/9.0.1/include/ 6 | cp -r build/release/lib/clang/9.0.1/include/* /usr/local/lib/clang/9.0.1/include/ 7 | -------------------------------------------------------------------------------- /checker/set-path.bat: -------------------------------------------------------------------------------- 1 | 2 | set PATH=%cd%\3rdparty\llvm-project\llvm\utils\lit;%PATH% 3 | set PATH=%cd%\build\vs\Release\bin;%PATH% 4 | -------------------------------------------------------------------------------- /checker/src/.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | -------------------------------------------------------------------------------- /checker/src/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: '-*,clang-diagnostic-*,misc-*,-misc-unused-parameters,readability-identifier-naming' 2 | CheckOptions: 3 | - key: readability-identifier-naming.ClassCase 4 | value: CamelCase 5 | - key: readability-identifier-naming.EnumCase 6 | value: CamelCase 7 | - key: readability-identifier-naming.FunctionCase 8 | value: camelBack 9 | - key: readability-identifier-naming.MemberCase 10 | value: CamelCase 11 | - key: readability-identifier-naming.ParameterCase 12 | value: CamelCase 13 | - key: readability-identifier-naming.UnionCase 14 | value: CamelCase 15 | - key: readability-identifier-naming.VariableCase 16 | value: CamelCase 17 | 18 | -------------------------------------------------------------------------------- /checker/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(safememory-checker) 2 | add_subdirectory(safememory-instrument) 3 | add_subdirectory(safememory-library-db) 4 | add_subdirectory(safememory-odr) 5 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LLVM_LINK_COMPONENTS 2 | Support 3 | ) 4 | 5 | add_clang_library(nodecppChecker 6 | CheckerData.cpp 7 | ClangTidy.cpp 8 | ClangTidyModule.cpp 9 | ClangTidyDiagnosticConsumer.cpp 10 | ClangTidyOptions.cpp 11 | ConsistencyRule.cpp 12 | DeterminismRule.cpp 13 | JSONSafeDatabase.cpp 14 | MiscellaneousRule.cpp 15 | MustCoAwaitRule.cpp 16 | NoSideEffectRule.cpp 17 | ReferenceOverCoAwaitRule.cpp 18 | 19 | LINK_LIBS 20 | clangAST 21 | clangASTMatchers 22 | clangBasic 23 | clangFormat 24 | clangFrontend 25 | clangLex 26 | clangRewrite 27 | clangSema 28 | clangTooling 29 | clangToolingCore 30 | ) 31 | 32 | if (MSVC) 33 | set_source_files_properties(ClangTidy.cpp PROPERTIES COMPILE_FLAGS /bigobj) 34 | endif() 35 | 36 | add_subdirectory(nodecpp) 37 | add_subdirectory(tool) 38 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/ClangTidyModule.cpp: -------------------------------------------------------------------------------- 1 | //===--- tools/extra/clang-tidy/ClangTidyModule.cpp - Clang tidy tool -----===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | /// 10 | /// \file Implements classes required to build clang-tidy modules. 11 | /// 12 | //===----------------------------------------------------------------------===// 13 | 14 | #include "ClangTidyModule.h" 15 | 16 | namespace nodecpp { 17 | namespace checker { 18 | 19 | void ClangTidyCheckFactories::registerCheckFactory(StringRef Name, 20 | CheckFactory Factory) { 21 | Factories[Name.str()] = std::move(Factory); 22 | } 23 | 24 | void ClangTidyCheckFactories::createChecks( 25 | ClangTidyContext *Context, 26 | std::vector> &Checks) { 27 | for (const auto &Factory : Factories) { 28 | if (Context->isCheckEnabled(Factory.first)) 29 | Checks.emplace_back(Factory.second(Factory.first, Context)); 30 | } 31 | } 32 | 33 | ClangTidyOptions ClangTidyModule::getModuleOptions() { 34 | return ClangTidyOptions(); 35 | } 36 | 37 | } // namespace checker 38 | } // namespace nodecpp 39 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/ClangTidyModuleRegistry.h: -------------------------------------------------------------------------------- 1 | //===--- ClangTidyModuleRegistry.h - clang-tidy -----------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef NODECPP_CHECKER_CLANGTIDYMODULEREGISTRY_H 11 | #define NODECPP_CHECKER_CLANGTIDYMODULEREGISTRY_H 12 | 13 | #include "ClangTidyModule.h" 14 | #include "llvm/Support/Registry.h" 15 | 16 | namespace nodecpp { 17 | namespace checker { 18 | 19 | typedef llvm::Registry ClangTidyModuleRegistry; 20 | 21 | } // end namespace checker 22 | } // end namespace nodecpp 23 | 24 | #endif // NODECPP_CHECKER_CLANGTIDYMODULEREGISTRY_H 25 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/ArrayExprCheck.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- ArrayExprCheck.cpp - clang-tidy-----------------------------------===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "ArrayExprCheck.h" 14 | #include "clang/AST/ASTContext.h" 15 | #include "clang/ASTMatchers/ASTMatchFinder.h" 16 | #include "NakedPtrHelper.h" 17 | 18 | using namespace clang::ast_matchers; 19 | 20 | namespace nodecpp { 21 | namespace checker { 22 | 23 | void ArrayExprCheck::registerMatchers(MatchFinder *Finder) { 24 | 25 | // Finder->addMatcher(typeLoc(loc(arrayType())).bind("type"), this); 26 | 27 | Finder->addMatcher( 28 | arraySubscriptExpr() 29 | .bind("expr"), 30 | this); 31 | 32 | } 33 | 34 | void ArrayExprCheck::check(const MatchFinder::MatchResult &Result) { 35 | 36 | // if (auto T = Result.Nodes.getNodeAs("type")) { 37 | // diag(T->getLocStart(), "do not use arrays"); 38 | // return; 39 | // } 40 | 41 | if (auto Ex = Result.Nodes.getNodeAs("expr")) { 42 | 43 | if(isSystemLocation(getContext(), Ex->getRBracketLoc())) 44 | return; 45 | 46 | diag(Ex->getRBracketLoc(), "(S1) array expression not allowed"); 47 | return; 48 | } 49 | } 50 | 51 | } // namespace checker 52 | } // namespace nodecpp 53 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/ArrayExprCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- ArrayExprCheck.h - clang-tidy---------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_ARRAYEXPRCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_ARRAYEXPRCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-array-expr.html 25 | class ArrayExprCheck : public ClangTidyCheck { 26 | public: 27 | ArrayExprCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_ARRAYEXPRCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/AsmCheck.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- AsmCheck.cpp - clang-tidy-----------------------------------------===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "AsmCheck.h" 14 | #include "clang/AST/ASTContext.h" 15 | #include "clang/ASTMatchers/ASTMatchFinder.h" 16 | #include "NakedPtrHelper.h" 17 | 18 | using namespace clang::ast_matchers; 19 | 20 | namespace nodecpp { 21 | namespace checker { 22 | 23 | void AsmCheck::registerMatchers(MatchFinder *Finder) { 24 | 25 | Finder->addMatcher(asmStmt().bind("asm"), this); 26 | } 27 | 28 | void AsmCheck::check(const MatchFinder::MatchResult &Result) { 29 | 30 | auto St = Result.Nodes.getNodeAs("asm"); 31 | 32 | if(isSystemLocation(getContext(), St->getAsmLoc())) 33 | return; 34 | 35 | diag(St->getAsmLoc(), "(S6.1) asm is prohibited"); 36 | } 37 | 38 | } // namespace checker 39 | } // namespace nodecpp 40 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/AsmCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- AsmCheck.h - clang-tidy---------------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_ASMCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_ASMCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-asm.html 25 | class AsmCheck : public ClangTidyCheck { 26 | public: 27 | AsmCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_ASMCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LLVM_LINK_COMPONENTS support) 2 | 3 | add_clang_library(clangTidyNodeCppModule 4 | ArrayExprCheck.cpp 5 | AsmCheck.cpp 6 | CallExprCheck.cpp 7 | ConstCheck.cpp 8 | CoroutineCheck.cpp 9 | MayExtendLambdaCheck.cpp 10 | NakedAssignmentCheck.cpp 11 | NakedPtrHelper.cpp 12 | NewExprCheck.cpp 13 | NodeCppTidyModule.cpp 14 | RawPointerAssignmentCheck.cpp 15 | RawPtrExprCheck.cpp 16 | RecordDeclCheck.cpp 17 | ReturnCheck.cpp 18 | StaticStorageCheck.cpp 19 | StringLiteralCheck.cpp 20 | TemporaryExprCheck.cpp 21 | VarDeclCheck.cpp 22 | 23 | LINK_LIBS 24 | clangAST 25 | clangASTMatchers 26 | clangBasic 27 | clangLex 28 | clangTooling 29 | ) 30 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/CallExprCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- CallExprCheck.h - clang-tidy----------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_CALLEXPRCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_CALLEXPRCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-call-expr.html 25 | class CallExprCheck : public ClangTidyCheck { 26 | public: 27 | CallExprCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | 32 | }; 33 | 34 | } // namespace checker 35 | } // namespace nodecpp 36 | 37 | #endif // NODECPP_CHECKER_NODECPP_CALLEXPRCHECK_H 38 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/ConstCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- ConstCheck.h - clang-tidy-------------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_CONSTCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_CONSTCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-const.html 25 | class ConstCheck : public ClangTidyCheck { 26 | public: 27 | ConstCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_CONSTCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/CoroutineCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- CoroutineCheck.h - clang-tidy---------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_COROUTINECHECK_H 14 | #define NODECPP_CHECKER_NODECPP_COROUTINECHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-coroutine.html 25 | class CoroutineCheck : public ClangTidyCheck { 26 | public: 27 | CoroutineCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_COROUTINECHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/MayExtendLambdaCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- MayExtendLambdaCheck.h - clang-tidy---------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_MAYEXTENDLAMBDACHECK_H 14 | #define NODECPP_CHECKER_NODECPP_MAYEXTENDLAMBDACHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-may-extend-lambda.html 25 | class MayExtendLambdaCheck : public ClangTidyCheck { 26 | public: 27 | MayExtendLambdaCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | 31 | bool checkLambda(const LambdaExpr *Lamb, bool IsCompositeOfThis); 32 | 33 | /// returns \c true if the expression was checked as a lambda 34 | /// (either positively or negatively) 35 | bool tryCheckAsLambda(const Expr *Ex, bool IsCompositeOfThis); 36 | 37 | static bool isCompositeOfThis(const Expr *Ex); 38 | 39 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 40 | }; 41 | 42 | } // namespace checker 43 | } // namespace nodecpp 44 | 45 | #endif // NODECPP_CHECKER_NODECPP_MAYEXTENDLAMBDACHECK_H 46 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/NakedAssignmentCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- NakedAssignmentCheck.h - clang-tidy------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_NAKEDPTRASSIGNMENTCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_NAKEDPTRASSIGNMENTCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-naked-assignment.html 25 | class NakedAssignmentCheck : public ClangTidyCheck { 26 | public: 27 | NakedAssignmentCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_NAKEDPTRASSIGNMENTCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/NewExprCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- NewExprCheck.h - clang-tidy-------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_NEWEXPRCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_NEWEXPRCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-new-expr.html 25 | class NewExprCheck : public ClangTidyCheck { 26 | public: 27 | NewExprCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | bool checkParentExpr(ASTContext *Context, const Expr *Ex); 31 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 32 | }; 33 | 34 | } // namespace checker 35 | } // namespace nodecpp 36 | 37 | #endif // NODECPP_CHECKER_NODECPP_NEWEXPRCHECK_H 38 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/RawPointerAssignmentCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- RawPointerAssignmentCheck.h - clang-tidy----------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_RAWPOINTERASSIGNMENTCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_RAWPOINTERASSIGNMENTCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-raw-pointer-assignment.html 25 | class RawPointerAssignmentCheck : public ClangTidyCheck { 26 | public: 27 | RawPointerAssignmentCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_RAWPOINTERASSIGNMENTCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/RawPtrExprCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- RawPtrExprCheck.h - clang-tidy-------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_RAWPTREXPRCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_RAWPTREXPRCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-raw-ptr-expr.html 25 | class RawPtrExprCheck : public ClangTidyCheck { 26 | public: 27 | RawPtrExprCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_RAWPTREXPRCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/RecordDeclCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- RecordDeclCheck.h - clang-tidy-------------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_RECORDDECLCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_RECORDDECLCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-record-decl.html 25 | class RecordDeclCheck : public ClangTidyCheck { 26 | public: 27 | RecordDeclCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_RECORDDECLCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/ReturnCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- ReturnCheck.h - clang-tidy----------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_RETURNCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_RETURNCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-naked-ptr-return.html 25 | class ReturnCheck : public ClangTidyCheck { 26 | public: 27 | ReturnCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_RETURNCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/StaticStorageCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- StaticStorageCheck.h - clang-tidy-----------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_STATICSTORAGECHECK_H 14 | #define NODECPP_CHECKER_NODECPP_STATICSTORAGECHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-static-storage.html 25 | class StaticStorageCheck : public ClangTidyCheck { 26 | public: 27 | StaticStorageCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_STATICSTORAGECHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/StringLiteralCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2020 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- StringLiteralCheck.h - clang-tidy-------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_STRINGLITERALCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_STRINGLITERALCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-std-function.html 25 | class StringLiteralCheck : public ClangTidyCheck { 26 | public: 27 | StringLiteralCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_STRINGLITERALCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/TemporaryExprCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- TemporaryExprCheck.h - clang-tidy----------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_TEMPORARYEXPRCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_TEMPORARYEXPRCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-temporary-expr.html 25 | class TemporaryExprCheck : public ClangTidyCheck { 26 | public: 27 | TemporaryExprCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 31 | }; 32 | 33 | } // namespace checker 34 | } // namespace nodecpp 35 | 36 | #endif // NODECPP_CHECKER_NODECPP_TEMPORARYEXPRCHECK_H 37 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/nodecpp/VarDeclCheck.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2019 OLogN Technologies AG 3 | *******************************************************************************/ 4 | //===--- VarDeclCheck.h - clang-tidy----------------------------*- C++ -*-===// 5 | // 6 | // The LLVM Compiler Infrastructure 7 | // 8 | // This file is distributed under the University of Illinois Open Source 9 | // License. See LICENSE.TXT for details. 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #ifndef NODECPP_CHECKER_NODECPP_VARDECLCHECK_H 14 | #define NODECPP_CHECKER_NODECPP_VARDECLCHECK_H 15 | 16 | #include "../ClangTidy.h" 17 | 18 | namespace nodecpp { 19 | namespace checker { 20 | 21 | /// FIXME: Write a short description. 22 | /// 23 | /// For the user-facing documentation see: 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/nodecpp-var-decl.html 25 | class VarDeclCheck : public ClangTidyCheck { 26 | public: 27 | VarDeclCheck(StringRef Name, ClangTidyContext *Context) 28 | : ClangTidyCheck(Name, Context) {} 29 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; 30 | const CXXMethodDecl *getParentMethod(ASTContext *Context, const VarDecl *Var); 31 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 32 | }; 33 | 34 | } // namespace checker 35 | } // namespace nodecpp 36 | 37 | #endif // NODECPP_CHECKER_NODECPP_VARDECLCHECK_H 38 | -------------------------------------------------------------------------------- /checker/src/safememory-checker/tool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LLVM_LINK_COMPONENTS 2 | AllTargetsAsmParsers 3 | Support 4 | ) 5 | 6 | add_clang_tool(safememory-checker 7 | ClangTidyMain.cpp 8 | ) 9 | add_dependencies(safememory-checker 10 | clang-headers 11 | ) 12 | target_link_libraries(safememory-checker 13 | PRIVATE 14 | clangAST 15 | clangASTMatchers 16 | clangBasic 17 | nodecppChecker 18 | clangTidyNodeCppModule 19 | clangTooling 20 | clangToolingCore 21 | ) 22 | 23 | -------------------------------------------------------------------------------- /checker/src/safememory-instrument/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( LLVM_LINK_COMPONENTS 2 | AllTargetsAsmParsers 3 | Support 4 | ) 5 | 6 | add_clang_executable(safememory-instrument 7 | CodeChange.cpp 8 | Dezombiefy.cpp 9 | InclusionRewriter.cpp 10 | NodeCppDezombify.cpp 11 | SequenceCheckAndFix.cpp 12 | ) 13 | 14 | 15 | target_link_libraries(safememory-instrument 16 | PRIVATE 17 | clangAST 18 | clangBasic 19 | clangDriver 20 | clangFrontend 21 | clangTooling 22 | clangRewriteFrontend 23 | ) 24 | 25 | install(TARGETS safememory-instrument 26 | RUNTIME DESTINATION bin) 27 | -------------------------------------------------------------------------------- /checker/src/safememory-library-db/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( LLVM_LINK_COMPONENTS 2 | AllTargetsAsmParsers 3 | Support 4 | ) 5 | 6 | add_clang_executable(safememory-library-db 7 | NodeCppSafeLibrary.cpp 8 | raiistdiofile.h 9 | ) 10 | 11 | 12 | target_link_libraries(safememory-library-db 13 | PRIVATE 14 | clangAST 15 | clangBasic 16 | clangDriver 17 | clangFrontend 18 | clangTooling 19 | ) 20 | 21 | install(TARGETS safememory-library-db 22 | RUNTIME DESTINATION bin) 23 | -------------------------------------------------------------------------------- /checker/src/safememory-library-db/raiistdiofile.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2016 OLogN Technologies AG 3 | *******************************************************************************/ 4 | 5 | #ifndef RAIISTDIOFILE_H_INCLUDED 6 | #define RAIISTDIOFILE_H_INCLUDED 7 | 8 | #include 9 | 10 | class RaiiStdioFile { 11 | FILE* f; 12 | 13 | public: 14 | RaiiStdioFile(FILE* f_) 15 | : f(f_) { 16 | } 17 | ~RaiiStdioFile() { 18 | if(f) 19 | fclose(f); 20 | } 21 | 22 | RaiiStdioFile(const RaiiStdioFile&) = delete; 23 | RaiiStdioFile& operator =(const RaiiStdioFile&) = delete; 24 | 25 | FILE* get() { 26 | return f; 27 | } 28 | }; 29 | 30 | #endif //RAIISTDIOFILE_H_INCLUDED 31 | -------------------------------------------------------------------------------- /checker/src/safememory-odr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set( LLVM_LINK_COMPONENTS 2 | AllTargetsAsmParsers 3 | Support 4 | ) 5 | 6 | add_clang_executable(safememory-odr 7 | SafeMemoryOdr.cpp 8 | raiistdiofile.h 9 | ) 10 | 11 | 12 | target_link_libraries(safememory-odr 13 | PRIVATE 14 | clangAST 15 | clangBasic 16 | clangDriver 17 | clangFrontend 18 | clangTooling 19 | ) 20 | 21 | install(TARGETS safememory-odr 22 | RUNTIME DESTINATION bin) 23 | -------------------------------------------------------------------------------- /checker/src/safememory-odr/raiistdiofile.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Copyright (C) 2016 OLogN Technologies AG 3 | *******************************************************************************/ 4 | 5 | #ifndef RAIISTDIOFILE_H_INCLUDED 6 | #define RAIISTDIOFILE_H_INCLUDED 7 | 8 | #include 9 | 10 | class RaiiStdioFile { 11 | FILE* f; 12 | 13 | public: 14 | RaiiStdioFile(FILE* f_) 15 | : f(f_) { 16 | } 17 | ~RaiiStdioFile() { 18 | if(f) 19 | fclose(f); 20 | } 21 | 22 | RaiiStdioFile(const RaiiStdioFile&) = delete; 23 | RaiiStdioFile& operator =(const RaiiStdioFile&) = delete; 24 | 25 | FILE* get() { 26 | return f; 27 | } 28 | }; 29 | 30 | #endif //RAIISTDIOFILE_H_INCLUDED 31 | -------------------------------------------------------------------------------- /checker/src/tidy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./run-clang-tidy.py -fix -format -p ../build/debug/ -header-filter=safememory-checker -clang-tidy-binary=clang-tidy-7 -clang-apply-replacements-binary=clang-apply-replacements-7 safememory-checker 4 | -------------------------------------------------------------------------------- /checker/test.bat: -------------------------------------------------------------------------------- 1 | 2 | setlocal 3 | set PATH=%cd%\3rdparty\llvm-project\llvm\utils\lit;%PATH% 4 | set PATH=%cd%\build\vs\Release\bin;%PATH% 5 | 6 | llvm-lit.py test 7 | 8 | endlocal 9 | -------------------------------------------------------------------------------- /checker/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PATH=$PWD/3rdparty/llvm-project/llvm/utils/lit:$PATH 4 | PATH=$PWD/build/release/bin:$PATH 5 | 6 | llvm-lit test 7 | -------------------------------------------------------------------------------- /checker/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Test runner infrastructure for Clang-based tools. This configures the Clang 2 | # test trees for use by Lit, and delegates to LLVM's lit test handlers. 3 | # 4 | # Note that currently we don't support stand-alone builds of Clang, you must 5 | # be building Clang from within a combined LLVM+Clang checkout.. 6 | 7 | set(NODECPP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") 8 | set(NODECPP_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") 9 | 10 | if (CMAKE_CFG_INTDIR STREQUAL ".") 11 | set(LLVM_BUILD_MODE ".") 12 | else () 13 | set(LLVM_BUILD_MODE "%(build_mode)s") 14 | endif () 15 | 16 | string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} NODECPP_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) 17 | 18 | configure_lit_site_cfg( 19 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in 20 | ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg 21 | ) 22 | 23 | option(NODECPP_TEST_USE_VG "Run Clang tools' tests under Valgrind" OFF) 24 | if(NODECPP_TEST_USE_VG) 25 | set(NODECPP_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg") 26 | endif() 27 | 28 | 29 | set(NODECPP_TEST_DEPS 30 | safememory-checker 31 | safememory-instrument 32 | safememory-library-db 33 | safememory-odr 34 | FileCheck 35 | not 36 | ) 37 | 38 | add_lit_testsuite(check-safememory-tools "Running the safememory tools regression tests" 39 | ${CMAKE_CURRENT_BINARY_DIR} 40 | DEPENDS ${NODECPP_TEST_DEPS} 41 | ARGS ${NODECPP_TEST_EXTRA_ARGS} 42 | ) 43 | 44 | set_target_properties(check-safememory-tools PROPERTIES FOLDER "safememory tools tests") 45 | -------------------------------------------------------------------------------- /checker/test/checker/Inputs/cstddef: -------------------------------------------------------------------------------- 1 | #ifndef STD_CSTDDEF_H 2 | #define STD_CSTDDEF_H 3 | 4 | 5 | 6 | 7 | #include 8 | 9 | namespace std { typedef decltype(nullptr) nullptr_t; } 10 | using ::std::nullptr_t; 11 | 12 | 13 | #endif //STD_CSTDDEF_H 14 | -------------------------------------------------------------------------------- /checker/test/checker/Inputs/cstdint: -------------------------------------------------------------------------------- 1 | #ifndef STD_CSTDINT_H 2 | #define STD_CSTDINT_H 3 | 4 | 5 | #include 6 | 7 | #endif //STD_CSTDINT_H 8 | -------------------------------------------------------------------------------- /checker/test/checker/Inputs/type_info: -------------------------------------------------------------------------------- 1 | #ifndef STD_TYPE_INFO_H 2 | #define STD_TYPE_INFO_H 3 | 4 | namespace std { 5 | 6 | class type_info {}; 7 | 8 | } 9 | 10 | #endif //STD_TYPE_INFO_H 11 | -------------------------------------------------------------------------------- /checker/test/checker/Inputs/type_traits: -------------------------------------------------------------------------------- 1 | #ifndef STD_TYPE_TRAITS_H 2 | #define STD_TYPE_TRAITS_H 3 | 4 | namespace std { 5 | 6 | template 7 | struct conditional { typedef T type; }; 8 | 9 | template 10 | struct conditional { typedef F type; }; 11 | 12 | template< bool B, class T, class F > 13 | using conditional_t = typename conditional::type; 14 | 15 | } 16 | 17 | #endif //STD_TYPE_TRAITS_H 18 | -------------------------------------------------------------------------------- /checker/test/checker/Inputs/utility: -------------------------------------------------------------------------------- 1 | #ifndef STD_UTILITY_H 2 | #define STD_UTILITY_H 3 | 4 | void* memset( void* dest, int ch, int count ); 5 | 6 | 7 | namespace std { 8 | 9 | template 10 | T&& move(T& t) { return static_cast(t); } 11 | 12 | template 13 | T&& forward(T& t) { return static_cast(t); } 14 | 15 | } 16 | 17 | #endif //STD_UTILITY_H 18 | -------------------------------------------------------------------------------- /checker/test/checker/c1.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | [[safememory::abcd]] void f(); 4 | // CHECK: :[[@LINE-1]]:3: error: (C1) 5 | 6 | -------------------------------------------------------------------------------- /checker/test/checker/c2.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | [[safememory::memory_unsafe]] void f(); 6 | // CHECK: :[[@LINE-1]]:36: error: (C2) 7 | 8 | 9 | [[safememory::non_deterministic]] constexpr int i = 0; 10 | // CHECK: :[[@LINE-1]]:49: error: (C2) 11 | 12 | union [[safememory::naked_struct]] Wrong { 13 | // CHECK: :[[@LINE-1]]:36: error: (C2) 14 | int i; 15 | int j; 16 | }; 17 | 18 | class MayExtendBad { 19 | void onEvent(std::function cb [[safememory::may_extend_to_this]]); 20 | // CHECK: :[[@LINE-1]]:40: error: (C2) 21 | }; 22 | 23 | namespace [[safememory::memory_unsafe]] { 24 | class MayExtendGood { 25 | // now this is ok on user side 26 | void onEvent(std::function cb [[safememory::may_extend_to_this]]); 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /checker/test/checker/c3.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | // don't make much trouble around unnamed namespaces 4 | namespace [[safememory::memory_unsafe]] { 5 | 6 | //this is not checked by checker 7 | static int* ptr = nullptr; 8 | 9 | } 10 | 11 | namespace [[safememory::memory_unsafe]] name1 { 12 | 13 | } 14 | 15 | namespace name1 { 16 | // CHECK: :[[@LINE-1]]:11: error: (C3) 17 | } 18 | 19 | namespace name2 { 20 | 21 | } 22 | 23 | namespace [[safememory::non_deterministic]] name2 { 24 | // CHECK: :[[@LINE-1]]:46: error: (C3) 25 | } 26 | 27 | -------------------------------------------------------------------------------- /checker/test/checker/compile_flags.txt: -------------------------------------------------------------------------------- 1 | -std=c++17 2 | -nostdinc 3 | -fno-ms-compatibility 4 | -fno-delayed-template-parsing 5 | -fno-ms-extensions 6 | -fcoroutines-ts 7 | -isystem 8 | ./Inputs 9 | -isystem 10 | ../../3rdparty/llvm-project/clang/lib/Headers 11 | -------------------------------------------------------------------------------- /checker/test/checker/d1.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | using namespace safememory; 6 | 7 | class Aclass { 8 | void func() { 9 | 10 | (size_t)(void*)this; 11 | // CHECK: :[[@LINE-1]]:3: error: (D1) 12 | // CHECK: :[[@LINE-2]]:11: error: (S1.1) 13 | 14 | reinterpret_cast(this); 15 | // CHECK: :[[@LINE-1]]:3: error: (D1) 16 | 17 | bool good = static_cast(this); 18 | } 19 | }; -------------------------------------------------------------------------------- /checker/test/checker/d2.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | 4 | class Good { 5 | int i = 0; 6 | }; 7 | class Bad { 8 | long l; 9 | }; 10 | 11 | class Bad2 { 12 | int x1 : 8; 13 | }; 14 | 15 | template 16 | struct MaybeBad { 17 | T t; 18 | T get() const { return t; } 19 | }; 20 | 21 | void otherFunc(int); 22 | void func() { 23 | 24 | int good = 0; 25 | long bad; 26 | // CHECK: :[[@LINE-1]]:7: error: (D2) 27 | 28 | Good g1; 29 | Bad b2; 30 | // CHECK: :[[@LINE-1]]:6: error: (D2.1) 31 | Bad b3; 32 | // CHECK: :[[@LINE-1]]:6: error: (D2.1) 33 | 34 | MaybeBad b4; 35 | // CHECK: :[[@LINE-1]]:16: error: (D2.1) 36 | 37 | otherFunc(MaybeBad().get()); 38 | // CHECK: :[[@LINE-1]]:12: error: (D2.1) 39 | } 40 | -------------------------------------------------------------------------------- /checker/test/checker/m1.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | 6 | 7 | void bad() { 8 | try { 9 | 10 | throw 42; 11 | // CHECK: :[[@LINE-1]]:3: error: (M1.1) 12 | } 13 | catch(int i) { 14 | // CHECK: :[[@LINE-1]]:12: error: (M1.2) 15 | 16 | } 17 | catch(nodecpp::error e) { 18 | // CHECK: :[[@LINE-1]]:23: error: (M1.2) 19 | 20 | } 21 | } 22 | 23 | void good() { 24 | 25 | try { 26 | throw nodecpp::error(nodecpp::BAD_ERROR); 27 | } 28 | catch(nodecpp::error& byRef) { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /checker/test/checker/node.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | 6 | using namespace safememory; 7 | 8 | 9 | struct MyServer2 : public NodeBase { 10 | 11 | owning_ptr server; 12 | 13 | void good() { 14 | //is ok because 'this' is derived from NodeBase 15 | server->onEvent([this](nullable_ptr sock) {}); 16 | 17 | // but creating instances is an error 18 | 19 | owning_ptr s = make_owning(); 20 | // CHECK: :[[@LINE-1]]:29: error: (node-dot-cpp) 21 | } 22 | 23 | }; 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /checker/test/checker/nodecpp-awaitable.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | 6 | class [[safememory::awaitable]] UserAwaitable { 7 | // CHECK: :[[@LINE-1]]:33: error: (C2) 8 | // CHECK: :[[@LINE-2]]:33: error: unsafe type 9 | 10 | bool await_ready() noexcept { return false; } 11 | void await_suspend(std::experimental::coroutine_handle<> h_) noexcept {} 12 | void await_resume() { } 13 | 14 | }; 15 | 16 | nodecpp::awaitable func() { 17 | 18 | 19 | co_await nodecpp::hidden_await_function(); 20 | 21 | nodecpp::hidden_await_function(); 22 | // CHECK: :[[@LINE-1]]:2: error: (S9) 23 | co_await nodecpp::bad_await_function(); 24 | 25 | nodecpp::bad_await_function(); 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /checker/test/checker/nodecpp-deep-const.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | 6 | using namespace safememory; 7 | 8 | struct [[safememory::deep_const]] DeepConst { 9 | int l; 10 | nodecpp::deep_const_type str; 11 | }; 12 | 13 | struct DeepConst; 14 | // CHECK: :[[@LINE-1]]:8: error: (C3) 15 | 16 | 17 | struct [[safememory::deep_const]] BadDeepConst { 18 | // CHECK: :[[@LINE-1]]:35: error: unsafe deep_const attribute at declaration [deep-const] 19 | owning_ptr ptr; 20 | }; 21 | 22 | 23 | template 24 | struct [[safememory::deep_const]] DeepConstTemplate { 25 | T t; 26 | }; 27 | 28 | void func() { 29 | 30 | DeepConstTemplate> b1; 31 | // CHECK: :[[@LINE-1]]:38: error: unsafe deep_const attribute at variable declaration [deep-const] 32 | 33 | DeepConstTemplate> b2; 34 | // CHECK: :[[@LINE-1]]:46: error: unsafe deep_const attribute at variable declaration [deep-const] 35 | 36 | 37 | DeepConstTemplate> g1; //ok! 38 | 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /checker/test/checker/nodecpp-naked-struct.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | using namespace safememory; 6 | 7 | struct [[safememory::naked_struct]] NakedInner { 8 | nullable_ptr l; 9 | }; 10 | 11 | 12 | struct [[safememory::naked_struct]] Naked { 13 | // CHECK: :[[@LINE-1]]:37: error: unsafe naked_struct declaration 14 | nullable_ptr i; //ok 15 | int* bad1; //bad 16 | 17 | NakedInner inner; 18 | 19 | nullable_ptr bad2; //TODO 20 | 21 | Naked& operator=(const Naked&) = default; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /checker/test/checker/nodecpp-var-decl.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | using namespace safememory; 6 | 7 | 8 | struct Safe1 { 9 | int i = 0; 10 | }; 11 | 12 | struct Safe2 { 13 | owning_ptr s1Ptr; 14 | 15 | Safe1 s1; 16 | }; 17 | 18 | class Safe3 :public Safe2 {}; 19 | 20 | void safeFun() { 21 | //all ok 22 | Safe1 s1; 23 | 24 | Safe2 s2; 25 | owning_ptr s2Ptr; 26 | 27 | Safe3 s3; 28 | owning_ptr s3Ptr; 29 | } 30 | 31 | 32 | struct [[safememory::naked_struct]] NakedStr { 33 | nullable_ptr ptr; 34 | 35 | nullable_ptr get() const; 36 | NakedStr(); 37 | NakedStr(const NakedStr&); 38 | NakedStr& operator=(const NakedStr&) = delete; 39 | }; 40 | 41 | void nakedFunc() { 42 | 43 | NakedStr naked; //ok 44 | } 45 | 46 | struct Bad1 { 47 | // CHECK: :[[@LINE-1]]:8: error: unsafe type declaration 48 | int* ptr = nullptr; 49 | // CHECK: :[[@LINE-1]]:13: error: (S1.2) 50 | }; 51 | 52 | struct Bad2 : public NakedStr { 53 | // CHECK: :[[@LINE-1]]:8: error: unsafe type declaration 54 | }; 55 | 56 | struct Bad3 { 57 | // CHECK: :[[@LINE-1]]:8: error: unsafe type declaration 58 | int* ptr = nullptr; 59 | // CHECK: :[[@LINE-1]]:13: error: (S1.2) 60 | void set(int* ptr); 61 | 62 | }; 63 | 64 | void badFunc() { 65 | int i0 = 0; 66 | int* i1 = &i0; 67 | int** i = &i1; //bad 68 | // CHECK: :[[@LINE-1]]:8: error: (S5.3) 69 | 70 | NakedStr nstr; 71 | NakedStr* nakedPtr = &nstr; // bad 72 | // CHECK: :[[@LINE-1]]:12: error: (S5.3) 73 | 74 | Bad1 b1; //bad 75 | // CHECK: :[[@LINE-1]]:7: error: unsafe type at variable declaration 76 | } 77 | 78 | -------------------------------------------------------------------------------- /checker/test/checker/s1-1-1.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | using namespace safememory; 6 | 7 | void bad1() { 8 | 9 | soft_ptr i; 10 | 11 | soft_ptr i2 = soft_ptr_static_cast( i ); 12 | // CHECK: :[[@LINE-1]]:21: error: (S1.1.1) 13 | 14 | soft_ptr l = soft_ptr_reinterpret_cast( i ); 15 | // CHECK: :[[@LINE-1]]:21: error: (S1.1.1) 16 | } 17 | -------------------------------------------------------------------------------- /checker/test/checker/s1-1.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | void bad1() { 4 | unsigned i = 0; 5 | reinterpret_cast(i); 6 | // CHECK: :[[@LINE-1]]:2: error: (S1.1) 7 | (void*)i; 8 | // CHECK: :[[@LINE-1]]:2: error: (S1.1) 9 | void* p = nullptr; 10 | // CHECK: :[[@LINE-1]]:12: error: (S1.2) 11 | 12 | static_cast(p); 13 | // CHECK: :[[@LINE-1]]:2: error: (S1.1) 14 | 15 | } 16 | 17 | void good1(int&& i) { 18 | ((void) 0); //ok, definition of assert macro 19 | 20 | int&& j = static_cast(i); //static cast to rvalue is ok 21 | 22 | short s1 = static_cast(5); // cast of non pointer is ok 23 | short s2 = (long) 5; // cast of non pointer is ok 24 | } 25 | -------------------------------------------------------------------------------- /checker/test/checker/s1-3.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | 4 | void f() { 5 | int i = 0; 6 | int* ip = &i; 7 | 8 | int* ip2 = nullptr; 9 | // CHECK: :[[@LINE-1]]:16: error: (S1.2) 10 | 11 | int* ip3 = 0; 12 | // CHECK: :[[@LINE-1]]:16: error: (S1.2) 13 | 14 | *nullptr; // this is not valid C++ 15 | // CHECK: :[[@LINE-1]]:5: error: indirection requires pointer operand 16 | } 17 | 18 | void func(int* ip) { 19 | ip = nullptr; 20 | // CHECK: :[[@LINE-1]]:10: error: (S1.2) 21 | } 22 | 23 | void f(int* p = nullptr); 24 | // CHECK: :[[@LINE-1]]:17: error: (S1.2) 25 | 26 | int* badFunc() { 27 | 28 | f(nullptr); 29 | // CHECK: :[[@LINE-1]]:7: error: (S1.2) 30 | 31 | return 0; 32 | // CHECK: :[[@LINE-1]]:12: error: (S1.2) 33 | } 34 | 35 | 36 | 37 | 38 | 39 | int* badAgain() { 40 | int i = 0; 41 | int* ip = &i; 42 | if(i) 43 | return ip; 44 | //CHECK: :[[@LINE-1]]:16: error: (S5.1) 45 | else 46 | return &i; 47 | //CHECK: :[[@LINE-1]]:16: error: (S5.1) 48 | } 49 | 50 | void func51() { 51 | 52 | int i = 0; 53 | int* ptr1 = &i; 54 | { 55 | int* ptr2 = &i; 56 | ptr2 = ptr1; // ok 57 | ptr1 = ptr2; // bad 58 | //CHECK: :[[@LINE-1]]:8: error: (S5.1) 59 | } 60 | } 61 | 62 | int* change(int* ptr) { 63 | int i = 0; 64 | ptr = &i; 65 | //CHECK: :[[@LINE-1]]:9: error: (S5.1) 66 | 67 | return ptr; //ok 68 | } 69 | -------------------------------------------------------------------------------- /checker/test/checker/s1-4.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | 4 | union Bad { 5 | // CHECK: :[[@LINE-1]]:7: error: unsafe type declaration 6 | int i = 0; 7 | int* ptr; 8 | }; 9 | 10 | void func1() { 11 | Bad bad; 12 | // CHECK: :[[@LINE-1]]:6: error: unsafe union at variable declaration 13 | } 14 | 15 | 16 | template 17 | union MayBeBad { 18 | int i = 0; 19 | T ptr; 20 | }; 21 | 22 | void func2() { 23 | 24 | MayBeBad good; //ok 25 | MayBeBad bad; 26 | // CHECK: :[[@LINE-1]]:18: error: unsafe union at variable declaration 27 | } 28 | 29 | class UsesUnion { 30 | // CHECK: :[[@LINE-1]]:7: error: unsafe type declaration 31 | MayBeBad pt; 32 | }; 33 | 34 | void func3() { 35 | 36 | UsesUnion uu; 37 | // CHECK: :[[@LINE-1]]:12: error: unsafe type at variable declaration 38 | 39 | UsesUnion(); 40 | // CHECK: :[[@LINE-1]]:2: error: unsafe type at temporary expression 41 | } 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /checker/test/checker/s1.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | 4 | void bad() { 5 | int i = 0; 6 | int* a = &i; 7 | 8 | a = a + 1; 9 | // CHECK: :[[@LINE-1]]:8: error: (S1) 10 | a = a - 1; 11 | // CHECK: :[[@LINE-1]]:8: error: (S1) 12 | a += 1; 13 | // CHECK: :[[@LINE-1]]:4: error: (S1) 14 | a -= 1; 15 | // CHECK: :[[@LINE-1]]:4: error: (S1) 16 | a++; 17 | // CHECK: :[[@LINE-1]]:3: error: (S1) 18 | ++a; 19 | // CHECK: :[[@LINE-1]]:2: error: (S1) 20 | a--; 21 | // CHECK: :[[@LINE-1]]:3: error: (S1) 22 | --a; 23 | // CHECK: :[[@LINE-1]]:2: error: (S1) 24 | 25 | int b = 0; 26 | int c = (&b)[0]; 27 | // CHECK: :[[@LINE-1]]:16: error: (S1) 28 | } 29 | -------------------------------------------------------------------------------- /checker/test/checker/s2.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | 4 | 5 | class Bad { 6 | mutable int i; 7 | // CHECK: :[[@LINE-1]]:14: error: (S2.2) 8 | }; 9 | 10 | void bad() { 11 | 12 | const int i = 0; 13 | 14 | int& j = const_cast(i); 15 | // CHECK: :[[@LINE-1]]:11: error: (S2.1) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /checker/test/checker/s3.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | 4 | int bad1; 5 | // CHECK: :[[@LINE-1]]:5: error: (S3) 6 | 7 | extern int bad2; 8 | // CHECK: :[[@LINE-1]]:12: error: (S3) 9 | 10 | static int bad3; 11 | // CHECK: :[[@LINE-1]]:12: error: (S3) 12 | 13 | thread_local int bad4; 14 | // CHECK: :[[@LINE-1]]:18: error: (S3) 15 | 16 | void func() { 17 | static int bad = 0; 18 | // CHECK: :[[@LINE-1]]:13: error: (S3) 19 | } 20 | 21 | class Bad { 22 | static int bad; 23 | // CHECK: :[[@LINE-1]]:13: error: (S3) 24 | }; 25 | 26 | constexpr int good = 5; 27 | const int good2 = 5; 28 | 29 | class Good { 30 | static constexpr int good = 5; 31 | static const int good2 = 5; 32 | static void func() {} 33 | }; 34 | 35 | static 36 | void func2() { 37 | //this is ok 38 | } 39 | 40 | Good ok; //ok, because is empty 41 | 42 | class [[safememory::deep_const]] DeepConst { 43 | int i = 0; 44 | }; 45 | 46 | //both ok, because of deep_const 47 | const DeepConst dc; 48 | constexpr DeepConst dc2; 49 | 50 | -------------------------------------------------------------------------------- /checker/test/checker/s4.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | using namespace safememory; 6 | 7 | void soft_func(soft_ptr sp) { 8 | 9 | } 10 | 11 | void owning_func(owning_ptr sp) { 12 | 13 | } 14 | 15 | void func() { 16 | 17 | new int; 18 | // CHECK: :[[@LINE-1]]:2: error: (S4) 19 | 20 | new int(); 21 | // CHECK: :[[@LINE-1]]:2: error: (S4) 22 | new int[5]; 23 | // CHECK: :[[@LINE-1]]:2: error: (S4) 24 | 25 | void* ptr = nullptr; 26 | // CHECK: :[[@LINE-1]]:14: error: (S1.2) 27 | delete ptr; 28 | // CHECK: :[[@LINE-1]]:2: error: (S4) 29 | 30 | owning_ptr iop = make_owning(5); 31 | 32 | iop = make_owning(7); 33 | 34 | make_owning(0); 35 | // CHECK: :[[@LINE-1]]:2: error: (S4.1) 36 | 37 | soft_ptr sp; 38 | sp = make_owning(2); 39 | // CHECK: :[[@LINE-1]]:7: error: (S4.1) 40 | 41 | owning_func(make_owning(2)); 42 | soft_func(make_owning(2)); 43 | // CHECK: :[[@LINE-1]]:12: error: (S4.1) 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /checker/test/checker/s5-3.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | using namespace safememory; 6 | 7 | 8 | owning_ptr func() { 9 | owning_ptr var = make_owning(); 10 | return var; 11 | } 12 | 13 | const int& func2(const int& i) {return i;} 14 | 15 | void func3(const nullable_ptr& i); 16 | void func4(nullable_ptr&); 17 | // CHECK: :[[@LINE-1]]:30: error: (S5.3) 18 | 19 | 20 | void func5(nullable_ptr> i); 21 | // CHECK: :[[@LINE-1]]:44: error: unsafe 22 | 23 | int main() { 24 | const int& i2; 25 | // CHECK: :[[@LINE-1]]:13: error: (S5.3) 26 | // CHECK: :[[@LINE-2]]:13: error: declaration of reference variable 27 | 28 | const int& i = *func(); 29 | // CHECK: :[[@LINE-1]]:17: error: (S5.3) 30 | 31 | const int& j = func2(i + 1); 32 | // CHECK: :[[@LINE-1]]:17: error: (S5.3) 33 | } -------------------------------------------------------------------------------- /checker/test/checker/s5-7.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | 6 | using namespace safememory; 7 | 8 | void my_sort(std::function); 9 | 10 | struct MyServer { 11 | nodecpp::SrvMember srv; 12 | 13 | void good() { 14 | srv.onEvent([this](nullable_ptr sock) {}); //is ok 15 | } 16 | 17 | void good2() { 18 | int i = 0; 19 | auto l = [this, &i](nullable_ptr sock) {}; 20 | my_sort(l); 21 | } 22 | 23 | void bad1() { 24 | int i = 0; 25 | auto l = [this, &i](nullable_ptr sock) {}; 26 | // CHECK: :[[@LINE-1]]:20: error: (S5.7) 27 | srv.onEvent(l); 28 | } 29 | 30 | void bad2(nullable_ptr i) { 31 | 32 | auto l = [this, &i](nullable_ptr sock) {}; 33 | // CHECK: :[[@LINE-1]]:20: error: (S5.7) 34 | srv.onEvent(l); 35 | } 36 | }; 37 | 38 | 39 | class Bad { 40 | void bad(nullable_ptr srv) { 41 | auto l = [this](nullable_ptr sock) {}; 42 | // CHECK: :[[@LINE-1]]:13: error: (S5.7) 43 | srv->onEvent(l); 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /checker/test/checker/s5-8.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace safememory; 8 | 9 | nodecpp::awaitable af(); 10 | 11 | nodecpp::awaitable func() { 12 | 13 | int i = 0; 14 | { 15 | int& ir = i; 16 | // CHECK: :[[@LINE-1]]:8: error: (S5.8) 17 | nullable_ptr np(&i); 18 | // CHECK: :[[@LINE-1]]:21: error: (S5.8) 19 | co_await af(); 20 | } 21 | 22 | { 23 | //this is ok 24 | co_await af(); 25 | int& ir = i; 26 | nullable_ptr np(&i); 27 | } 28 | 29 | { 30 | //this is ok 31 | { 32 | int& ir = i; 33 | nullable_ptr np(&i); 34 | } 35 | co_await af(); 36 | } 37 | } 38 | 39 | nodecpp::awaitable func2() { 40 | 41 | int i = 0; 42 | { 43 | int& ir = i; 44 | // CHECK: :[[@LINE-1]]:8: error: (S5.8) 45 | nullable_ptr np(&i); 46 | // CHECK: :[[@LINE-1]]:21: error: (S5.8) 47 | co_yield i; 48 | } 49 | co_return 0; 50 | } 51 | -------------------------------------------------------------------------------- /checker/test/checker/s6.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | 4 | void func() { 5 | asm("mov al, 2"); 6 | // CHECK: :[[@LINE-1]]:2: error: (S6.1) 7 | __asm("mov al, 2"); 8 | // CHECK: :[[@LINE-1]]:2: error: (S6.1) 9 | } 10 | 11 | -------------------------------------------------------------------------------- /checker/test/checker/s8.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --library-db=%p/s8.json %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace [[safememory::memory_unsafe]] name { 8 | class UnsafeButOk { 9 | int *P = nullptr; 10 | }; 11 | } 12 | 13 | void func() { 14 | 15 | int i = 0; 16 | memset(&i,0,sizeof(i)); 17 | // CHECK: :[[@LINE-1]]:2: error: (S8) 18 | 19 | 20 | func(); // ok, defined in safe code 21 | 22 | //ok, allowed at 's8.json' 23 | safememory::owning_ptr optr = safememory::make_owning(); 24 | 25 | name::UnsafeButOk Ok; // ok, unsafe but [[safememory::memory_unsafe]] 26 | } 27 | 28 | -------------------------------------------------------------------------------- /checker/test/checker/s8.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "types" : [ 4 | "nodecpp::Socket", 5 | ], 6 | "functions" : [ 7 | "safememory::make_owning", 8 | ] 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /checker/test/checker/s9.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | 6 | 7 | // user functions 8 | nodecpp::awaitable awaitInt(); 9 | void eatAwaitable(nodecpp::awaitable); 10 | 11 | 12 | nodecpp::awaitable func() { 13 | 14 | co_await nodecpp::await_function(); // ok 15 | 16 | nodecpp::await_function(); 17 | // CHECK: :[[@LINE-1]]:2: error: (S9) 18 | 19 | 20 | nodecpp::awaitable var1 = nodecpp::await_function(); 21 | co_await var1; // ok 22 | 23 | auto avar = nodecpp::await_function(); 24 | co_await avar; // ok 25 | 26 | 27 | nodecpp::awaitable var2 = nodecpp::await_function(); 28 | // CHECK: :[[@LINE-1]]:27: error: (S9) 29 | 30 | eatAwaitable(nodecpp::await_function()); 31 | // CHECK: :[[@LINE-1]]:15: error: (S9) 32 | 33 | int i = co_await awaitInt(); //ok 34 | 35 | int j = (co_await awaitInt()) + 1; 36 | // CHECK: :[[@LINE-1]]:11: error: (S9) 37 | 38 | 39 | nodecpp::awaitable var3 = nodecpp::await_function(); 40 | co_await nodecpp::wait_for_all(std::move(var3), nodecpp::await_function()); //all ok 41 | 42 | 43 | nodecpp::no_await_function(); //this is ok 44 | 45 | co_await nodecpp::no_await_function(); //this is ok 46 | 47 | 48 | co_return; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /checker/test/checker/safe_memory_check_as_user_code.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker --no-library-db %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | class MyClass { 6 | public: 7 | bool operator==(const MyClass& other) const { 8 | return false; 9 | } 10 | }; 11 | 12 | template 13 | class Container { 14 | T t; 15 | Eq eq; 16 | public: 17 | bool isEq() const { 18 | return eq(t, t); 19 | } 20 | }; 21 | 22 | void func() { 23 | 24 | Container> mc; 25 | // we must trigger the actual instantiation of the method above 26 | bool b = mc.isEq(); 27 | 28 | 29 | Container> mc2; 30 | // we must trigger the actual instantiation of the method above 31 | bool b2 = mc2.isEq(); 32 | // in this case bad implementation wont report error. Good implementation will. 33 | // error is reported as located in header file, so we check the full location. 34 | 35 | // CHECK: check_as_user_code.h:51:18: error: function with no_side_effect attribute 36 | } 37 | 38 | -------------------------------------------------------------------------------- /checker/test/instrument/.gitignore: -------------------------------------------------------------------------------- 1 | Output 2 | -------------------------------------------------------------------------------- /checker/test/instrument/Inputs/cstddef: -------------------------------------------------------------------------------- 1 | #ifndef STD_CSTDDEF_H 2 | #define STD_CSTDDEF_H 3 | 4 | 5 | 6 | 7 | #include 8 | 9 | namespace std { typedef decltype(nullptr) nullptr_t; } 10 | using ::std::nullptr_t; 11 | 12 | 13 | #endif //STD_CSTDDEF_H 14 | -------------------------------------------------------------------------------- /checker/test/instrument/Inputs/cstdint: -------------------------------------------------------------------------------- 1 | #ifndef STD_CSTDINT_H 2 | #define STD_CSTDINT_H 3 | 4 | 5 | #include 6 | 7 | #endif //STD_CSTDINT_H 8 | -------------------------------------------------------------------------------- /checker/test/instrument/Inputs/type_traits: -------------------------------------------------------------------------------- 1 | #ifndef STD_TYPE_TRAITS_H 2 | #define STD_TYPE_TRAITS_H 3 | 4 | namespace std { 5 | 6 | template 7 | struct conditional { typedef T type; }; 8 | 9 | template 10 | struct conditional { typedef F type; }; 11 | 12 | template< bool B, class T, class F > 13 | using conditional_t = typename conditional::type; 14 | 15 | } 16 | 17 | #endif //STD_TYPE_TRAITS_H 18 | -------------------------------------------------------------------------------- /checker/test/instrument/Inputs/utility: -------------------------------------------------------------------------------- 1 | #ifndef STD_UTILITY_H 2 | #define STD_UTILITY_H 3 | 4 | void* memset( void* dest, int ch, int count ); 5 | 6 | 7 | namespace std { 8 | 9 | template 10 | T&& move(T& t) { return static_cast(t); } 11 | 12 | template 13 | T&& forward(T& t) { return static_cast(t); } 14 | 15 | } 16 | 17 | #endif //STD_UTILITY_H 18 | -------------------------------------------------------------------------------- /checker/test/instrument/check_Z1.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --report-only %s %t %p 2 | 3 | #include 4 | #include 5 | 6 | using namespace safememory; 7 | using namespace nodecpp; 8 | 9 | int release() { return 0; } 10 | 11 | struct Bad { 12 | 13 | owning_ptr StPtr; 14 | 15 | 16 | 17 | Bad() { 18 | StPtr = make_owning(); 19 | } 20 | 21 | // int release() { 22 | // StPtr.reset(); 23 | // return 0; 24 | // } 25 | 26 | 27 | void verifyZombie(SafeType& StRef) { 28 | 29 | auto i = safeFunction(*StPtr) + release();//safeFunction may be eating a zombie 30 | // CHECK-MESSAGES: :[[@LINE-1]]:25: error: (Z1) 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /checker/test/instrument/check_Z9.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --report-only %s %t %p 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace safememory; 8 | using namespace nodecpp; 9 | 10 | struct TrivialUnsafeType { 11 | 12 | void call(int) { } 13 | }; 14 | 15 | struct UnsafeType { 16 | 17 | UnsafeType() {} 18 | UnsafeType(const UnsafeType&) {}// non trivially copiable 19 | void call(int) { } 20 | }; 21 | 22 | struct Bad { 23 | 24 | void verifyZombie(SafeType& StRef) { 25 | 26 | safeTemplate(StRef, TrivialUnsafeType()); //should be ok 27 | 28 | 29 | safeTemplate(StRef, UnsafeType()); //should be error 30 | // CHECK-MESSAGES: :[[@LINE-1]]:23: error: (Z9) 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /checker/test/instrument/compile_flags.txt: -------------------------------------------------------------------------------- 1 | -std=c++17 2 | -nostdinc 3 | -I. 4 | -isystem 5 | ./Inputs 6 | -isystem 7 | ../../3rdparty/llvm-project/clang/lib/Headers 8 | -------------------------------------------------------------------------------- /checker/test/instrument/dz_base.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument %s %t %p 2 | 3 | 4 | 5 | void func(int* ip, int& ir) { 6 | 7 | int* ip2 = ip; 8 | // CHECK-FIXES: int* ip2 = safememory::detail::dezombiefy( ip ); 9 | 10 | int& ir2 = ir; 11 | // CHECK-FIXES: int& ir2 = safememory::detail::dezombiefy( ir ); 12 | 13 | int i = *ip2;// no dz needed here 14 | 15 | i = ir2;// no dz needed here 16 | } 17 | 18 | class Class { 19 | 20 | int attribute = 0; 21 | 22 | void method1() { 23 | int i = attribute; 24 | // CHECK-FIXES: int i = safememory::detail::dezombiefy( this )->attribute; 25 | 26 | i = this->attribute; //no dz needed here 27 | } 28 | 29 | void method2() { 30 | int i = this->attribute; 31 | // CHECK-FIXES: int i = safememory::detail::dezombiefy( this )->attribute; 32 | } 33 | 34 | void method3() { 35 | method1(); 36 | // CHECK-FIXES: safememory::detail::dezombiefy( this )->method1(); 37 | } 38 | 39 | void method4() { 40 | this->method1(); 41 | // CHECK-FIXES: safememory::detail::dezombiefy( this )->method1(); 42 | } 43 | }; -------------------------------------------------------------------------------- /checker/test/instrument/dz_constexpr_if.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument %s %t %p 2 | // XFAIL: * 3 | 4 | 5 | 6 | struct TestObj {}; 7 | 8 | template 9 | T& templConstexprIf(T& t1, T& t2) { 10 | if constexpr (I == 0) 11 | return t1; 12 | // CHECK-FIXES: return safememory::detail::dezombiefy( t1 ); 13 | else 14 | return t2; 15 | // CHECK-FIXES: return safememory::detail::dezombiefy( t2 ); 16 | } 17 | 18 | 19 | void func() { 20 | 21 | TestObj val; 22 | 23 | templConstexprIf(val, val); 24 | 25 | templConstexprIf(val, val); 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /checker/test/instrument/dz_param_pack.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument %s %t %p 2 | // XFAIL: * 3 | 4 | 5 | 6 | 7 | struct TestObj {}; 8 | 9 | int function(); 10 | int function(TestObj&); 11 | int function(TestObj&, TestObj&); 12 | int function(TestObj&, TestObj&, TestObj&); 13 | 14 | template 15 | void execute(ARGS&& ... args) { 16 | auto i = function(args...); 17 | // CHECK-FIXES: auto i = function(safememory::detail::dezombiefy( args )...); 18 | } 19 | 20 | 21 | void dezombiefyParameterPack() { 22 | 23 | TestObj To; 24 | 25 | execute(); 26 | execute(To); 27 | execute(To, To); 28 | execute(To, To, To); 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /checker/test/instrument/dz_template_class.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument %s %t %p 2 | 3 | 4 | 5 | 6 | struct TestObj {}; 7 | struct TestObj2 {}; 8 | 9 | 10 | template 11 | class TemplateClass { 12 | public: 13 | template 14 | class TemplateInner { 15 | public: 16 | 17 | auto aMethod(U u) { 18 | return u; 19 | // CHECK-FIXES: return safememory::detail::dezombiefy( u ); 20 | } 21 | 22 | template 23 | auto templMethod(V v) { 24 | return v; 25 | // CHECK-FIXES: return safememory::detail::dezombiefy( v ); 26 | } 27 | }; 28 | }; 29 | 30 | 31 | int main() { 32 | 33 | TestObj to; 34 | TestObj2 to2; 35 | 36 | TemplateClass::TemplateInner tc12; 37 | TemplateClass::TemplateInner tc21; 38 | TemplateClass::TemplateInner tc22; 39 | 40 | tc12.templMethod(to2); 41 | tc12.templMethod(to); 42 | tc21.templMethod(to); 43 | tc22.templMethod(to2); 44 | tc22.templMethod(to); 45 | 46 | tc12.aMethod(to2); 47 | tc21.aMethod(to); 48 | tc22.aMethod(to2); 49 | } -------------------------------------------------------------------------------- /checker/test/instrument/dz_template_error_1.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --no-silent-mode %s %t %p 2 | 3 | 4 | 5 | 6 | struct TestObj {}; 7 | struct TestObj2 {}; 8 | 9 | 10 | template 11 | class TemplateClass { 12 | public: 13 | template 14 | class TemplateInner { 15 | public: 16 | 17 | auto aMethod(U u) { 18 | //CHECK-MESSAGES: :[[@LINE-1]]:14: error: Template funcion 'aMethod' has inconsistent dezombiefy requirements 19 | return u; 20 | } 21 | 22 | template 23 | auto templMethod(V v) { 24 | //CHECK-MESSAGES: :[[@LINE-1]]:14: error: Template funcion 'templMethod' has inconsistent dezombiefy requirements 25 | return v; 26 | } 27 | }; 28 | }; 29 | 30 | 31 | int main() { 32 | 33 | TestObj to; 34 | 35 | TemplateClass::TemplateInner tcVal; 36 | TemplateClass::TemplateInner tcRef; 37 | 38 | tcVal.aMethod(to); 39 | tcRef.aMethod(to); 40 | 41 | tcVal.templMethod(to); 42 | tcRef.templMethod(to); 43 | } -------------------------------------------------------------------------------- /checker/test/instrument/dz_template_out_of_line.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument %s %t %p 2 | 3 | 4 | 5 | 6 | struct TestObj {}; 7 | struct TestObj2 {}; 8 | 9 | 10 | template 11 | class TemplateClass { 12 | public: 13 | 14 | class Inner { 15 | public: 16 | T attr; 17 | void set(T t) { attr = t; } 18 | 19 | }; 20 | 21 | T method(T t); 22 | }; 23 | 24 | 25 | template 26 | T TemplateClass::method(T t) { 27 | return t; 28 | // CHECK-FIXES: return safememory::detail::dezombiefy( t ); 29 | } 30 | 31 | int main() { 32 | 33 | TemplateClass ti; 34 | TemplateClass td; 35 | 36 | int* ip = nullptr; 37 | ti.method(ip); 38 | 39 | double* dp = nullptr; 40 | td.method(dp); 41 | } -------------------------------------------------------------------------------- /checker/test/instrument/fix_Z1.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --fix-only %s %t %p 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace safememory; 8 | 9 | int release() { return 0; } 10 | 11 | 12 | struct Bad { 13 | 14 | owning_ptr StPtr; 15 | 16 | 17 | 18 | Bad() { 19 | StPtr = make_owning(); 20 | } 21 | 22 | // int release() { 23 | // StPtr.reset(); 24 | // return 0; 25 | // } 26 | 27 | 28 | void verifyZombie(SafeType& StRef) { 29 | 30 | //safeFunction may be eating a zombie 31 | while(safeFunction(*StPtr) + release() != 0); 32 | // CHECK-FIXES: while(safememory::detail::dz_ne(safememory::detail::dz_add(safeFunction(*StPtr) , release()) , 0)); 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /checker/test/instrument/fix_Z1_macro_error.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --fix-only --no-silent-mode %s %t %p 2 | 3 | #include 4 | 5 | #include 6 | 7 | #define MACRO_ADD(X, Y) ((X) + (Y)) 8 | 9 | using namespace safememory; 10 | using namespace nodecpp; 11 | 12 | 13 | int release() { return 0; } 14 | 15 | 16 | struct Bad { 17 | 18 | owning_ptr StPtr; 19 | 20 | 21 | 22 | Bad() { 23 | StPtr = make_owning(); 24 | } 25 | 26 | // int release() { 27 | // StPtr.reset(); 28 | // return 0; 29 | // } 30 | 31 | 32 | void verifyZombie(SafeType& StRef) { 33 | 34 | //safeFunction may be eating a zombie 35 | while(MACRO_ADD(safeFunction(*StPtr), release())); 36 | //CHECK-MESSAGES: :[[@LINE-1]]:9: error: Op2Call couldn't complete because of MACRO 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /checker/test/instrument/fix_Z2_args.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --fix-only %s %t %p 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace safememory; 8 | 9 | struct UnsafeType { 10 | 11 | int call(int i) { return i; } 12 | UnsafeType& operator<<(int) { 13 | return *this; 14 | } 15 | 16 | }; 17 | 18 | 19 | struct Bad { 20 | 21 | SafeType StMember; 22 | owning_ptr StPtr; 23 | owning_ptr UPtr; 24 | 25 | 26 | Bad() { 27 | StPtr = make_owning(); 28 | UPtr = make_owning(); 29 | } 30 | 31 | int release() { 32 | StPtr.reset(); 33 | UPtr.reset(); 34 | return 0; 35 | } 36 | 37 | void otherMethod(int i) {} 38 | SafeType& getSt() { return *StPtr; } 39 | UnsafeType& getU() { return *UPtr; } 40 | 41 | void verifyZombieArgs() { 42 | 43 | //both args may be zombie 44 | safeFunction(getSt(), getSt()); 45 | // CHECK-FIXES: { auto& nodecpp_0 = getSt(); auto& nodecpp_1 = getSt(); safeFunction(nodecpp_0, nodecpp_1); }; 46 | 47 | // literal can't zombie 48 | // nothing to do here 49 | safeFunction(getSt(), "hello!"); 50 | } 51 | }; 52 | -------------------------------------------------------------------------------- /checker/test/instrument/fix_Z2_macro_error.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --fix-only --no-silent-mode %s %t %p 2 | 3 | #include 4 | 5 | #include 6 | 7 | #define MACRO_FUNC(X, Y) (safeFunction((X), (Y))) 8 | #define MACRO_DO(X) (X) 9 | 10 | using namespace safememory; 11 | using namespace nodecpp; 12 | 13 | struct UnsafeType { 14 | 15 | int call(int i) { return i; } 16 | UnsafeType& operator<<(int) { 17 | return *this; 18 | } 19 | 20 | }; 21 | 22 | 23 | struct Bad { 24 | 25 | SafeType StMember; 26 | owning_ptr StPtr; 27 | owning_ptr UPtr; 28 | 29 | 30 | Bad() { 31 | StPtr = make_owning(); 32 | UPtr = make_owning(); 33 | } 34 | 35 | int release() { 36 | StPtr.reset(); 37 | UPtr.reset(); 38 | return 0; 39 | } 40 | 41 | void otherMethod(int i) {} 42 | SafeType& getSt() { return *StPtr; } 43 | UnsafeType& getU() { return *UPtr; } 44 | 45 | void verifyZombieMacro() { 46 | 47 | MACRO_FUNC(getSt(), getSt()); 48 | //CHECK-MESSAGES: :[[@LINE-1]]:3: error: Unwrap couldn't complete because of MACRO 49 | 50 | safeFunction(MACRO_DO(getSt()), getSt()); 51 | //CHECK-MESSAGES: :[[@LINE-1]]:25: error: Unwrap couldn't complete because of MACRO 52 | } 53 | }; 54 | -------------------------------------------------------------------------------- /checker/test/instrument/fix_Z2_move.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --fix-only %s %t %p 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace safememory; 8 | 9 | struct UnsafeType { 10 | 11 | int call(int i) { return i; } 12 | UnsafeType& operator<<(int) { 13 | return *this; 14 | } 15 | 16 | }; 17 | 18 | void unsafeByValue(UnsafeType&, UnsafeType); 19 | 20 | 21 | struct Bad { 22 | 23 | SafeType StMember; 24 | owning_ptr StPtr; 25 | owning_ptr UPtr; 26 | 27 | 28 | Bad() { 29 | StPtr = make_owning(); 30 | UPtr = make_owning(); 31 | } 32 | 33 | int release() { 34 | StPtr.reset(); 35 | UPtr.reset(); 36 | return 0; 37 | } 38 | 39 | void otherMethod(int i) {} 40 | SafeType& getSt() { return *StPtr; } 41 | UnsafeType& getU() { return *UPtr; } 42 | 43 | void verifyZombieMove(SafeType& StRef) { 44 | 45 | safeByValue(getSt(), std::move(StRef)); 46 | // CHECK-FIXES: { auto& nodecpp_0 = getSt(); safeByValue(nodecpp_0, std::move(StRef)); }; 47 | 48 | safeByValue(getSt(), std::move(getSt())); 49 | // CHECK-FIXES: { auto& nodecpp_1 = getSt(); auto& nodecpp_2 = getSt(); safeByValue(nodecpp_2, std::move(nodecpp_1)); }; 50 | 51 | unsafeByValue(getU(), std::move(getU())); 52 | } 53 | }; 54 | -------------------------------------------------------------------------------- /checker/test/instrument/fix_Z2_op.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --fix-only %s %t %p 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace safememory; 8 | 9 | struct UnsafeType { 10 | 11 | int call(int i) { return i; } 12 | UnsafeType& operator<<(int) { 13 | return *this; 14 | } 15 | 16 | }; 17 | 18 | 19 | struct Bad { 20 | 21 | SafeType StMember; 22 | owning_ptr StPtr; 23 | owning_ptr UPtr; 24 | 25 | 26 | Bad() { 27 | StPtr = make_owning(); 28 | UPtr = make_owning(); 29 | } 30 | 31 | int release() { 32 | StPtr.reset(); 33 | UPtr.reset(); 34 | return 0; 35 | } 36 | 37 | void otherMethod(int i) {} 38 | SafeType& getSt() { return *StPtr; } 39 | UnsafeType& getU() { return *UPtr; } 40 | 41 | void verifyZombieOperator(SafeType& StRef) { 42 | 43 | getSt() << release(); 44 | // CHECK-FIXES: { auto& nodecpp_0 = getSt(); auto nodecpp_1 = release(); nodecpp_0 << nodecpp_1; }; 45 | 46 | getSt() << 1 << 2 << release(); 47 | // CHECK-FIXES: { auto& nodecpp_2 = getSt(); auto& nodecpp_3 = nodecpp_2 << 1; auto& nodecpp_4 = nodecpp_3 << 2; auto nodecpp_5 = release(); nodecpp_4 << nodecpp_5; }; 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /checker/test/instrument/fix_Z2_param_pack.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --fix-only %s %t %p 2 | // XFAIL: * 3 | 4 | #include 5 | 6 | 7 | 8 | struct TestObj {}; 9 | 10 | int function(int); 11 | int function(int, TestObj&); 12 | int function(int, TestObj&, TestObj&); 13 | int function(int, TestObj&, TestObj&, TestObj&); 14 | 15 | class Outer { 16 | public: 17 | int arg0 = 5; 18 | template 19 | void execute(ARGS&& ... args) { 20 | auto i = function(arg0, std::forward(args)...); 21 | // CHECK-FIXES: auto i = function(safememory::detail::dezombiefy( args )...); 22 | } 23 | }; 24 | 25 | void dezombiefyParameterPack() { 26 | 27 | TestObj To; 28 | Outer o; 29 | 30 | o.execute(); 31 | o.execute(To); 32 | o.execute(To, To); 33 | o.execute(To, To, To); 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /checker/test/instrument/fix_Z2_stmt.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --fix-only %s %t %p 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace safememory; 8 | 9 | struct UnsafeType { 10 | 11 | int call(int i) { return i; } 12 | UnsafeType& operator<<(int) { 13 | return *this; 14 | } 15 | 16 | }; 17 | 18 | 19 | struct Bad { 20 | 21 | SafeType StMember; 22 | owning_ptr StPtr; 23 | owning_ptr UPtr; 24 | 25 | 26 | Bad() { 27 | StPtr = make_owning(); 28 | UPtr = make_owning(); 29 | } 30 | 31 | int release() { 32 | StPtr.reset(); 33 | UPtr.reset(); 34 | return 0; 35 | } 36 | 37 | void otherMethod(int i) {} 38 | SafeType& getSt() { return *StPtr; } 39 | UnsafeType& getU() { return *UPtr; } 40 | 41 | void verifyZombieStmt() { 42 | 43 | int i = getSt().call(release()); 44 | // CHECK-FIXES: auto& nodecpp_0 = getSt(); auto nodecpp_1 = release(); int i = nodecpp_0.call(nodecpp_1); 45 | 46 | if(getSt().call(release()) != 0) {} 47 | // CHECK-FIXES: auto& nodecpp_2 = getSt(); auto nodecpp_3 = release(); auto nodecpp_4 = nodecpp_2.call(nodecpp_3); if(nodecpp_4 != 0) {} 48 | 49 | if(int j = getSt().call(release())) {} 50 | // CHECK-FIXES: auto& nodecpp_5 = getSt(); auto nodecpp_6 = release(); if(int j = nodecpp_5.call(nodecpp_6)) {} 51 | 52 | 53 | int j, k = getSt().call(release()); 54 | } 55 | }; 56 | -------------------------------------------------------------------------------- /checker/test/instrument/fix_Z2_this.cpp: -------------------------------------------------------------------------------- 1 | // RUN: %check_safememory_instrument --fix-only %s %t %p 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace safememory; 8 | using namespace nodecpp; 9 | 10 | struct UnsafeType { 11 | 12 | int call(int i) { return i; } 13 | UnsafeType& operator<<(int) { 14 | return *this; 15 | } 16 | 17 | }; 18 | 19 | 20 | struct Bad { 21 | 22 | SafeType StMember; 23 | owning_ptr StPtr; 24 | owning_ptr UPtr; 25 | 26 | 27 | Bad() { 28 | StPtr = make_owning(); 29 | UPtr = make_owning(); 30 | } 31 | 32 | int release() { 33 | StPtr.reset(); 34 | UPtr.reset(); 35 | return 0; 36 | } 37 | 38 | void otherMethod(int i) {} 39 | SafeType& getSt() { return *StPtr; } 40 | UnsafeType& getU() { return *UPtr; } 41 | 42 | void verifyZombieThis(SafeType& StRef) { 43 | 44 | //only cases that need fix are here 45 | 46 | //StRef may be deleted, and 'this' will zombie 47 | StRef.call(release()); 48 | // CHECK-FIXES: { auto nodecpp_0 = release(); StRef.call(nodecpp_0); }; 49 | 50 | // StPtr may be deleted, and 'this' will zombie 51 | StPtr->call(release()); 52 | // CHECK-FIXES: { auto nodecpp_1 = std::addressof(*(StPtr)); auto nodecpp_2 = release(); nodecpp_1->call(nodecpp_2); }; 53 | 54 | // ref may be deleted, and 'this' will zombie 55 | getSt().call(release()); 56 | // CHECK-FIXES: { auto& nodecpp_3 = getSt(); auto nodecpp_4 = release(); nodecpp_3.call(nodecpp_4); }; 57 | 58 | } 59 | }; 60 | -------------------------------------------------------------------------------- /checker/test/library/all-good.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker %s | FileCheck %s -allow-empty -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | 5 | /* This file should not generate any warning */ 6 | 7 | using namespace safememory; 8 | 9 | class X { }; 10 | 11 | void fop(owning_ptr op) { 12 | 13 | if(op) 14 | return; 15 | 16 | auto x1 = make_owning(); 17 | fop(std::move(x1)); 18 | } 19 | -------------------------------------------------------------------------------- /checker/test/library/compile_flags.txt: -------------------------------------------------------------------------------- 1 | -std=c++17 2 | -stdlib=libc++ 3 | -fcoroutines-ts 4 | -DNODECPP_NO_STACK_INFO_IN_EXCEPTIONS 5 | -isystem 6 | /usr/lib/llvm-9/bin/../include/c++/v1 7 | -isystem 8 | /usr/lib/llvm-9/lib/clang/9.0.0/include 9 | -isystem 10 | /Library/Developer/CommandLineTools/usr/include/c++/v1 11 | -isystem 12 | /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include 13 | -isystem 14 | ../../../library/include 15 | -isystem 16 | ../../../library/3rdparty/EASTL/include 17 | -isystem 18 | ../../../library/3rdparty/EABase/include/Common 19 | -isystem 20 | ../../../library/src/iibmalloc/src 21 | -isystem 22 | ../../../library/src/iibmalloc/src/foundation/include 23 | -isystem 24 | ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /checker/test/library/dump.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/node-dot-cpp/memory-safe-cpp/f66a4982583916697ee0a3880fcf6ecfd5331db2/checker/test/library/dump.txt -------------------------------------------------------------------------------- /checker/test/library/iterator.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | using namespace safememory; 9 | 10 | vector::iterator itFunc(vector::iterator in) { 11 | return in; 12 | } 13 | 14 | vector::iterator itFunc2() { 15 | vector vi; 16 | return vi.end(); 17 | // CHECK: :[[@LINE-1]]:9: error: (S5.1) return value may extend scope 18 | } 19 | 20 | void vectorIterator() { 21 | //all ok 22 | vector::iterator it; 23 | vector::iterator_safe sit; 24 | { 25 | vector vi; 26 | it = vi.end(); 27 | // CHECK: :[[@LINE-1]]:6: error: (S5.1) assignment may extend scope 28 | 29 | sit = vi.end_safe();//ok 30 | 31 | it = itFunc(vi.end()); 32 | // CHECK: :[[@LINE-1]]:6: error: (S5.1) assignment may extend scope 33 | 34 | sit = vi.make_safe(vi.end()); 35 | } 36 | } 37 | 38 | 39 | unordered_map::iterator mapFunc(unordered_map::iterator in) { 40 | return in; 41 | } 42 | 43 | unordered_map::iterator mapFunc2() { 44 | unordered_map vi; 45 | return vi.end(); 46 | // CHECK: :[[@LINE-1]]:9: error: (S5.1) return value may extend scope 47 | } 48 | 49 | void mapIterator() { 50 | //all ok 51 | unordered_map::iterator it; 52 | unordered_map::iterator_safe sit; 53 | { 54 | unordered_map vi; 55 | it = vi.end(); 56 | // CHECK: :[[@LINE-1]]:6: error: (S5.1) assignment may extend scope 57 | 58 | sit = vi.end_safe();//ok 59 | 60 | it = mapFunc(vi.end()); 61 | // CHECK: :[[@LINE-1]]:6: error: (S5.1) assignment may extend scope 62 | 63 | sit = vi.make_safe(vi.end()); 64 | } 65 | } 66 | 67 | 68 | -------------------------------------------------------------------------------- /checker/test/library/library-db/std.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * This file contain type names and functions names that are declared as 'safe' 5 | * under Rule S8. 6 | * At this moment only names are of interest, we don't care about arguments, 7 | * return type or template parameters. This simplifies this file a lot. 8 | * 9 | */ 10 | 11 | namespace std { 12 | void move(); 13 | void forward(); 14 | 15 | class function { 16 | void operator=(function&); 17 | }; 18 | 19 | struct fake { int i = 0;}; 20 | bool operator==(fake, fake); 21 | bool operator!=(fake, fake); 22 | bool operator<(fake, fake); 23 | bool operator<=(fake, fake); 24 | bool operator>(fake, fake); 25 | bool operator>=(fake, fake); 26 | void swap(fake, fake); 27 | 28 | // apple gcc std lib uses namespace __1 29 | namespace __1 { 30 | void move(); 31 | void forward(); 32 | class function { 33 | void operator=(function&); 34 | }; 35 | 36 | struct fake { int i = 0;}; 37 | bool operator==(fake, fake); 38 | bool operator!=(fake, fake); 39 | bool operator<(fake, fake); 40 | bool operator<=(fake, fake); 41 | bool operator>(fake, fake); 42 | bool operator>=(fake, fake); 43 | void swap(fake, fake); 44 | } 45 | 46 | namespace experimental { 47 | 48 | class suspend_never { 49 | void await_ready(); 50 | void await_resume(); 51 | void await_suspend(); 52 | 53 | }; 54 | 55 | class coroutine_handle { 56 | void from_address(); 57 | }; 58 | namespace coroutines_v1 { 59 | class coroutine_handle; 60 | void operator!=(void*, coroutine_handle); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /checker/test/library/safe_library.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * This file contain type names and functions names that are declared as 'safe' 5 | * under Rule S8. 6 | * At this moment only names are of interest, we don't care about arguments, 7 | * return type or template parameters. This simplifies this file a lot. 8 | * 9 | */ 10 | 11 | #include "library-db/std.hpp" 12 | #include "library-db/safememory.hpp" 13 | #include "library-db/nodecpp.hpp" 14 | 15 | -------------------------------------------------------------------------------- /checker/test/library/string_literal.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | 6 | using namespace safememory; 7 | 8 | void f(string_literal sl); 9 | 10 | void func() { 11 | 12 | const char* cp = "Hello world!"; 13 | 14 | const char arr[] = "Hello world!"; 15 | // CHECK: :[[@LINE-1]]:13: error: unsafe type at variable declaration 16 | 17 | string_literal a = "Hello world!"; 18 | 19 | string_literal b = cp; 20 | // CHECK: :[[@LINE-1]]:17: error: no viable conversion 21 | 22 | string_literal c = string_literal(cp); 23 | // CHECK: :[[@LINE-1]]:21: error: no matching conversion 24 | 25 | string_literal d = string_literal(arr); 26 | // CHECK: :[[@LINE-1]]:21: error: (S10.1) 27 | 28 | f("Implicit"); 29 | 30 | f(cp); 31 | // CHECK: :[[@LINE-1]]:2: error: no matching function for call 32 | 33 | 34 | string str0 = string("real literal"); 35 | 36 | string str1 = string(cp); 37 | // CHECK: :[[@LINE-1]]:16: error: (S10.1) 38 | 39 | string str2 = string(arr); 40 | // CHECK: :[[@LINE-1]]:16: error: (S10.1) 41 | } 42 | 43 | -------------------------------------------------------------------------------- /checker/test/library/vector.cpp: -------------------------------------------------------------------------------- 1 | // RUN: safememory-checker %s | FileCheck %s -implicit-check-not="{{warning|error}}:" 2 | 3 | #include 4 | #include 5 | 6 | 7 | using namespace safememory; 8 | 9 | struct Safe1 { 10 | int i = 0; 11 | }; 12 | 13 | struct Safe2 { 14 | owning_ptr s1Ptr; 15 | 16 | Safe1 s1; 17 | }; 18 | 19 | class Safe3 :public Safe2 {}; 20 | 21 | void safeVector() { 22 | //all ok 23 | vector vi; 24 | 25 | vector vS1; 26 | vector vS2; 27 | } 28 | 29 | 30 | struct [[safememory::naked_struct]] NakedStr { 31 | nullable_ptr ptr; 32 | 33 | nullable_ptr get() const; 34 | NakedStr(); 35 | NakedStr(const NakedStr&); 36 | NakedStr& operator=(const NakedStr&) = delete; 37 | }; 38 | 39 | struct Bad1 { 40 | // CHECK: :[[@LINE-1]]:8: error: unsafe type declaration 41 | nullable_ptr ptr; 42 | }; 43 | 44 | void badFunc() { 45 | vector vp; //bad 46 | // CHECK: :[[@LINE-1]]:15: error: unsafe type at variable declaration 47 | 48 | vector vstr; 49 | // CHECK: :[[@LINE-1]]:19: error: unsafe type at variable declaration 50 | 51 | vector b1; //bad 52 | // CHECK: :[[@LINE-1]]:15: error: unsafe type at variable declaration 53 | } 54 | 55 | -------------------------------------------------------------------------------- /checker/test/lit.site.cfg.in: -------------------------------------------------------------------------------- 1 | @LIT_SITE_CFG_IN_HEADER@ 2 | 3 | import sys 4 | 5 | config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" 6 | config.llvm_libs_dir = "@LLVM_LIBS_DIR@" 7 | config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" 8 | config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@" 9 | config.clang_tools_dir = "@CLANG_TOOLS_DIR@" 10 | config.clang_libs_dir = "@SHLIBDIR@" 11 | #config.python_executable = "@PYTHON_EXECUTABLE@" 12 | config.python_executable = "@Python3_EXECUTABLE@" 13 | config.target_triple = "@TARGET_TRIPLE@" 14 | #config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ 15 | config.nodecpp_tools_dir = "@NODECPP_TOOLS_DIR@" 16 | 17 | # Support substitution of the tools and libs dirs with user parameters. This is 18 | # used when we can't determine the tool dir at configuration time. 19 | try: 20 | config.clang_tools_dir = config.clang_tools_dir % lit_config.params 21 | config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params 22 | config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params 23 | except KeyError: 24 | e = sys.exc_info()[1] 25 | key, = e.args 26 | lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) 27 | 28 | @LIT_SITE_CFG_IN_FOOTER@ 29 | 30 | # Let the main config do the real work. 31 | lit_config.load_config(config, "@NODECPP_SOURCE_DIR@/test/lit.cfg") 32 | -------------------------------------------------------------------------------- /checker/tools/teamcity-ninja-windows.bat: -------------------------------------------------------------------------------- 1 | rem Build script used by teamcity CI 2 | rem This script requires a properly configured environment, in particular 3 | rem vcvars64.bat from Visual Studio and sccache.exe and ninja.exe in the path 4 | 5 | 6 | cd 3rdparty 7 | if not exist "llvm-project\" ( 8 | git clone --depth 1 --branch llvmorg-11.1.0 https://github.com/llvm/llvm-project.git 9 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 10 | 11 | cd llvm-project 12 | git apply ..\llvm-project_llvmorg-11.1.0.diff 13 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 14 | 15 | cd .. 16 | ) 17 | 18 | cd .. 19 | 20 | if not exist "build\" ( 21 | mkdir build 22 | ) 23 | 24 | cd build 25 | 26 | if not exist "teamcity\" ( 27 | mkdir teamcity 28 | ) 29 | 30 | cd teamcity 31 | 32 | cmake -DCMAKE_CXX_COMPILER_LAUNCHER="sccache" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_EXTERNAL_SAFEMEMORY_SOURCE_DIR=%cd%\..\.. -G Ninja ..\..\3rdparty\llvm-project\llvm 33 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 34 | 35 | cmake --build . --target check-safememory-tools 36 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 37 | 38 | cd ..\.. 39 | -------------------------------------------------------------------------------- /library/3rdparty/EABase-2.09.06.diff: -------------------------------------------------------------------------------- 1 | diff --git a/include/Common/EABase/int128.h b/include/Common/EABase/int128.h 2 | index 3e78ebc..bab08b2 100644 3 | --- a/include/Common/EABase/int128.h 4 | +++ b/include/Common/EABase/int128.h 5 | @@ -286,6 +286,7 @@ EA_CONSTEXPR inline int128_t_base::operator signed char() const { return 6 | EA_CONSTEXPR inline int128_t_base::operator unsigned char() const { return static_cast(Low()); } 7 | EA_CONSTEXPR inline int128_t_base::operator unsigned int() const { return static_cast(Low()); } 8 | EA_CONSTEXPR inline int128_t_base::operator unsigned long long() const { return static_cast(Low()); } 9 | +EA_CONSTEXPR inline int128_t_base::operator unsigned long() const { return static_cast(Low()); } 10 | EA_CONSTEXPR inline int128_t_base::operator unsigned short() const { return static_cast(Low()); } 11 | EA_CONSTEXPR inline int128_t_base::operator float() const { return static_cast(Low()); } 12 | EA_CONSTEXPR inline int128_t_base::operator double() const { return static_cast(Low()); } 13 | -------------------------------------------------------------------------------- /library/3rdparty/EABase-EASTL.md: -------------------------------------------------------------------------------- 1 | EABase and EASTL 2 | ================ 3 | 4 | Both libraries, `3rdparty/EABase` and `3rdparty/EASTL` have been cloned _by-value_. 5 | 6 | **EABase** folder is by-value clone of [https://github.com/electronicarts/EABase.git] initially done at tag `2.09.06`. 7 | 8 | **EASTL** folder is by-value clone of [https://github.com/electronicarts/EASTL] initially done at tag `3.18.00` and patched with `EASTL-3.18.00.diff`. 9 | 10 | 11 | It is done with `clone-EABase-EASLT.sh` or `clone-EABase-EASTL.bat` scripts. 12 | 13 | Any future changes to files inside `EASTL` should preserve this procedure. 14 | Recomemded procedure is: 15 | * clone the initial revision in a separate folder 16 | * apply patch and do changes there 17 | * when work is done, make diff `git diff > ../EASTL.diff` 18 | * re-run clone script to overwrite the _by-value_ copy 19 | 20 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | 3 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test/packages/EAMain"] 2 | path = test/packages/EAMain 3 | url = git@github.com:electronicarts/EAMain.git 4 | [submodule "test/packages/EATest"] 5 | path = test/packages/EATest 6 | url = git@github.com:electronicarts/EATest.git 7 | [submodule "test/packages/EAStdC"] 8 | path = test/packages/EAStdC 9 | url = git@github.com:electronicarts/EAStdC.git 10 | [submodule "test/packages/EAAssert"] 11 | path = test/packages/EAAssert 12 | url = git@github.com:electronicarts/EAAssert.git 13 | [submodule "test/packages/EAThread"] 14 | path = test/packages/EAThread 15 | url = git@github.com:electronicarts/EAThread.git 16 | [submodule "test/packages/EASTL"] 17 | path = test/packages/EASTL 18 | url = git@github.com:electronicarts/EASTL.git 19 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/.p4ignore: -------------------------------------------------------------------------------- 1 | tags 2 | .p4ignore 3 | 4 | /.git/ 5 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (C) Electronic Arts Inc. All rights reserved. 3 | #------------------------------------------------------------------------------------------- 4 | cmake_minimum_required(VERSION 3.1) 5 | project(EABase CXX) 6 | 7 | #------------------------------------------------------------------------------------------- 8 | # Options 9 | #------------------------------------------------------------------------------------------- 10 | option(EABASE_BUILD_TESTS "Enable generation of build files for tests" OFF) 11 | 12 | #------------------------------------------------------------------------------------------- 13 | # Package Tests 14 | #------------------------------------------------------------------------------------------- 15 | if(EABASE_BUILD_TESTS) 16 | add_subdirectory(test) 17 | endif() 18 | 19 | #------------------------------------------------------------------------------------------- 20 | # Defines 21 | #------------------------------------------------------------------------------------------- 22 | add_definitions(-D_CHAR16T) 23 | 24 | if (NOT EABASE_BUILD_TESTS) 25 | #------------------------------------------------------------------------------------------- 26 | # Header only library 27 | #------------------------------------------------------------------------------------------- 28 | add_library(EABase INTERFACE) 29 | 30 | #------------------------------------------------------------------------------------------- 31 | # Include dirs 32 | #------------------------------------------------------------------------------------------- 33 | target_include_directories(EABase INTERFACE include/Common) 34 | endif() 35 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2017 Electronic Arts Inc. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of 14 | its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/README.md: -------------------------------------------------------------------------------- 1 | # EABase 2 | 3 | [![Build Status](https://travis-ci.org/electronicarts/EABase.svg?branch=master)](https://travis-ci.org/electronicarts/EABase) 4 | 5 | EABase is a small set of header files that define platform-independent data types and macros. 6 | 7 | 8 | ## Documentation 9 | 10 | Please see [Introduction](doc/EABase.html). 11 | 12 | 13 | ## Compiling sources 14 | 15 | Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on compiling and testing the source. 16 | 17 | 18 | ## Credits 19 | 20 | Roberto Parolin is the current EABase owner within EA and is responsible for the open source repository. 21 | 22 | 23 | ## License 24 | 25 | Modified BSD License (3-Clause BSD license) see the file LICENSE in the project root. 26 | 27 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/include/Common/EABase/earesult.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * earesult.h 3 | * 4 | * Copyright (c) Electronic Arts Inc. All rights reserved. 5 | *---------------------------------------------------------------------------*/ 6 | 7 | 8 | #ifndef INCLUDED_earesult_H 9 | #define INCLUDED_earesult_H 10 | 11 | 12 | #include 13 | 14 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 15 | #pragma once /* Some compilers (e.g. VC++) benefit significantly from using this. We've measured 3-4% build speed improvements in apps as a result. */ 16 | #endif 17 | 18 | 19 | 20 | /* This result type is width-compatible with most systems. */ 21 | typedef int32_t ea_result_type; 22 | 23 | 24 | namespace EA 25 | { 26 | typedef int32_t result_type; 27 | 28 | enum 29 | { 30 | #ifndef SUCCESS 31 | // Deprecated 32 | // Note: a public MS header has created a define of this name which causes a build error. Fortunately they 33 | // define it to 0 which is compatible. 34 | // see: WindowsSDK\8.1.51641-fb\installed\Include\um\RasError.h 35 | SUCCESS = 0, 36 | #endif 37 | // Deprecated 38 | FAILURE = -1, 39 | 40 | // These values are now the preferred constants 41 | EA_SUCCESS = 0, 42 | EA_FAILURE = -1, 43 | }; 44 | } 45 | 46 | 47 | /* Macro to simplify testing for success. */ 48 | #ifndef EA_SUCCEEDED 49 | #define EA_SUCCEEDED(result) ((result) >= 0) 50 | #endif 51 | 52 | /* Macro to simplfify testing for general failure. */ 53 | #ifndef EA_FAILED 54 | #define EA_FAILED(result) ((result) < 0) 55 | #endif 56 | 57 | 58 | #endif 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/include/Common/EABase/version.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * version.h 3 | * 4 | * Copyright (c) Electronic Arts Inc. All rights reserved. 5 | *---------------------------------------------------------------------------*/ 6 | 7 | #ifndef INCLUDED_EABASE_VERSION_H 8 | #define INCLUDED_EABASE_VERSION_H 9 | 10 | /////////////////////////////////////////////////////////////////////////////// 11 | // EABASE_VERSION 12 | // 13 | // We more or less follow the conventional EA packaging approach to versioning 14 | // here. A primary distinction here is that minor versions are defined as two 15 | // digit entities (e.g. .03") instead of minimal digit entities ".3"). The logic 16 | // here is that the value is a counter and not a floating point fraction. 17 | // Note that the major version doesn't have leading zeros. 18 | // 19 | // Example version strings: 20 | // "0.91.00" // Major version 0, minor version 91, patch version 0. 21 | // "1.00.00" // Major version 1, minor and patch version 0. 22 | // "3.10.02" // Major version 3, minor version 10, patch version 02. 23 | // "12.03.01" // Major version 12, minor version 03, patch version 24 | // 25 | // Example usage: 26 | // printf("EABASE version: %s", EABASE_VERSION); 27 | // printf("EABASE version: %d.%d.%d", EABASE_VERSION_N / 10000 % 100, EABASE_VERSION_N / 100 % 100, EABASE_VERSION_N % 100); 28 | // 29 | /////////////////////////////////////////////////////////////////////////////// 30 | 31 | #ifndef EABASE_VERSION 32 | #define EABASE_VERSION "2.09.06" 33 | #define EABASE_VERSION_N 20906 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/test/source/CEntryPoint.cpp: -------------------------------------------------------------------------------- 1 | // EAMain/EAEntryPointMain.inl contains C++ code but it exposes the application entry point with C linkage. 2 | 3 | #include "EAMain/EAEntryPointMain.inl" 4 | #include "EATest/EASTLNewOperatorGuard.inl" 5 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/test/source/TestEABase.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #include 6 | #include 7 | 8 | 9 | // What we do here is verify that EA_PRAGMA_ONCE_SUPPORTED works as intended. 10 | // This header file should be #included two times by TestEABase.cpp 11 | // in order to test this. 12 | 13 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 14 | #pragma once 15 | const int EABaseOncePerTranslationUnitTestVariable = 0; // This should get compiled only once ever for a compilation unit. 16 | #else 17 | // Just implement a classic manual header include guard. 18 | // In this case we aren't really testing anything. 19 | #ifndef TESTEABASE_H 20 | #define TESTEABASE_H 21 | const int EABaseOncePerTranslationUnitTestVariable = 0; 22 | #endif 23 | #endif 24 | 25 | 26 | 27 | // EA_EXTERN_TEMPLATE / EA_COMPILER_NO_EXTERN_TEMPLATE 28 | 29 | #if defined(__cplusplus) 30 | template 31 | struct eabase_template 32 | { 33 | T value; 34 | T GetValue() const { return value; } 35 | }; 36 | 37 | EA_EXTERN_TEMPLATE(struct eabase_template); 38 | #endif 39 | 40 | 41 | -------------------------------------------------------------------------------- /library/3rdparty/EABase/test/source/TestEABaseSeparate.cpp: -------------------------------------------------------------------------------- 1 | // The purpose of this compilation unit is to test EABase in the absence of other system headers. 2 | // For example TestEABase.cpp directly includes system headers like ctype.h, stddef.h, stdarg, etc. 3 | // However, these headers make it impossible to verify that certain definitions are being provided 4 | // by EABase instead of the system headers being included directly. 5 | 6 | #include 7 | 8 | // This structure tests that EABase types are properly defined. 9 | struct EABaseDefinedTypesStruct 10 | { 11 | char8_t mChar8_t; 12 | char16_t mChar16_t; 13 | char32_t mChar32_t; 14 | wchar_t mWchar_t; 15 | bool8_t mBool8_t; 16 | int8_t mInt8_t; 17 | int16_t mInt16_t; 18 | int32_t mInt32_t; 19 | int64_t mInt64_t; 20 | uint8_t mUint8_t; 21 | uint16_t mUint16_t; 22 | uint32_t mUint32_t; 23 | uint64_t mUint64_t; 24 | intmax_t mIntmax_t; 25 | uintmax_t mUintmax_t; 26 | size_t mSize_t; 27 | ssize_t mSsize_t; 28 | float_t mFloat_t; 29 | double_t mDouble_t; 30 | intptr_t mIntptr_t; 31 | uintptr_t mUintptr_t; 32 | ptrdiff_t mPtrdiff_t; 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/.clang-format: -------------------------------------------------------------------------------- 1 | #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#- 2 | Language : Cpp 3 | BasedOnStyle : Google 4 | Standard : Auto 5 | #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#- 6 | AccessModifierOffset : -4 7 | AlignTrailingComments : true 8 | AllowAllParametersOfDeclarationOnNextLine : false 9 | AllowShortBlocksOnASingleLine : true 10 | AllowShortFunctionsOnASingleLine : true 11 | AllowShortIfStatementsOnASingleLine : false 12 | AllowShortLoopsOnASingleLine : false 13 | BinPackParameters : false 14 | BreakBeforeBraces : Allman 15 | BreakBeforeTernaryOperators : false 16 | BreakConstructorInitializersBeforeComma : true 17 | ColumnLimit : 120 18 | Cpp11BracedListStyle : true 19 | DerivePointerAlignment : true 20 | DerivePointerBinding : false 21 | IndentWidth : 4 22 | KeepEmptyLinesAtTheStartOfBlocks : true 23 | MaxEmptyLinesToKeep : 2 24 | NamespaceIndentation : All 25 | PointerBindsToType : true 26 | SpacesBeforeTrailingComments : 1 27 | SpacesInAngles : false 28 | SpacesInSquareBrackets : false 29 | TabWidth : 4 30 | UseTab : ForIndentation 31 | #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#- 32 | #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#- 33 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | # http://git-scm.com/docs/gitattributes 3 | * text=auto 4 | .appveyor.yml -text eol=crlf 5 | .appveyor-mingw.yml -text eol=crlf 6 | ci-*.cmd -text eol=crlf -------------------------------------------------------------------------------- /library/3rdparty/EASTL/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | cscope.out 3 | **/*.swp 4 | **/*.swo 5 | .swp 6 | *.swp 7 | .swo 8 | .TMP 9 | -.d 10 | eastl_build_out 11 | build_bench 12 | bench.bat 13 | build.bat 14 | .p4config 15 | 16 | ## CMake generated files 17 | CMakeCache.txt 18 | cmake_install.cmake 19 | 20 | ## Patch files 21 | *.patch 22 | 23 | ## For Visual Studio Generated projects 24 | *.sln 25 | **/*.vcxproj 26 | **/*.vcxproj.filters 27 | *.VC.opendb 28 | *.sdf 29 | **/*.suo 30 | **/*.user 31 | .vs/* 32 | **/Debug/* 33 | CMakeFiles/* 34 | EASTL.dir/** 35 | RelWithDebInfo/* 36 | Release/* 37 | Win32/* 38 | x64/* 39 | MinSizeRel/* 40 | build*/* 41 | Testing/* 42 | %ALLUSERSPROFILE%/* 43 | 44 | # Buck 45 | /buck-out/ 46 | /.buckd/ 47 | /buckaroo/ 48 | .buckconfig.local 49 | BUCKAROO_DEPS 50 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test/packages/EABase"] 2 | path = test/packages/EABase 3 | url = ../EABase.git 4 | [submodule "test/packages/EAAssert"] 5 | path = test/packages/EAAssert 6 | url = ../EAAssert.git 7 | [submodule "test/packages/EAMain"] 8 | path = test/packages/EAMain 9 | url = ../EAMain.git 10 | [submodule "test/packages/EAStdC"] 11 | path = test/packages/EAStdC 12 | url = ../EAStdC.git 13 | [submodule "test/packages/EATest"] 14 | path = test/packages/EATest 15 | url = ../EATest.git 16 | [submodule "test/packages/EAThread"] 17 | path = test/packages/EAThread 18 | url = ../EAThread.git 19 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/.p4ignore: -------------------------------------------------------------------------------- 1 | /.git/ 2 | tags 3 | .gitignore 4 | cscope.out 5 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, Electronic Arts 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /library/3rdparty/EASTL/doc/EASTL-n2271.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/node-dot-cpp/memory-safe-cpp/f66a4982583916697ee0a3880fcf6ecfd5331db2/library/3rdparty/EASTL/doc/EASTL-n2271.pdf -------------------------------------------------------------------------------- /library/3rdparty/EASTL/doc/html/EASTLDoc.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | font-family: Georgia, "Times New Roman", Times, serif; 4 | font-size: 12pt; 5 | } 6 | 7 | h1 8 | { 9 | font-family: Verdana, Arial, Helvetica, sans-serif; 10 | display: block; 11 | background-color: #BBCCDD; 12 | border: 2px solid #000000; 13 | font-size: 16pt; 14 | font-weight: bold; 15 | padding: 6px; 16 | } 17 | 18 | h2 19 | { 20 | font-size: 14pt; 21 | font-family: Verdana; 22 | border-bottom: 2px solid black; 23 | } 24 | 25 | h3 26 | { 27 | font-family: Verdana; 28 | font-size: 13pt; 29 | font-weight: bold; 30 | } 31 | 32 | .code-example 33 | { 34 | display: block; 35 | background-color: #D1DDE9; 36 | margin-left: 3em; 37 | margin-right: 3em; 38 | margin-top: 1em; 39 | margin-bottom: 1em; 40 | padding: 8px; 41 | border: 2px solid #7993C8; 42 | font-family: "Courier New", Courier, mono; 43 | font-size: 10pt; 44 | white-space: pre; 45 | } 46 | 47 | .code-example-span 48 | { 49 | font-family: "Courier New", Courier, mono; 50 | font-size: 10pt; 51 | white-space: pre; 52 | } 53 | 54 | .code-example-comment 55 | { 56 | background-color: #e0e0f0; 57 | padding: 0px 0px; 58 | font-family: "Courier New", Courier, mono; 59 | font-size: 10pt; 60 | white-space: pre; 61 | color: #999999; 62 | margin: auto auto; 63 | } 64 | 65 | 66 | .faq-question 67 | { 68 | background-color: #D9E2EC; 69 | font-size: 12pt; 70 | font-weight: bold; 71 | margin-top: 0em; 72 | padding-left:5px; 73 | padding-right:8px; 74 | padding-top:2px; 75 | padding-bottom:3px; 76 | margin-bottom: 0.5em; 77 | } 78 | 79 | .faq-answer 80 | { 81 | display: block; 82 | margin: 4pt 1em 0.8em; 83 | } 84 | .indented { 85 | margin-left: 50px; 86 | } 87 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/doc/quick-reference.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/node-dot-cpp/memory-safe-cpp/f66a4982583916697ee0a3880fcf6ecfd5331db2/library/3rdparty/EASTL/doc/quick-reference.pdf -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/compare.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | /////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_COMPARE_H 7 | #define EASTL_COMPARE_H 8 | 9 | 10 | #include 11 | 12 | namespace eastl 13 | { 14 | 15 | #if defined(EA_COMPILER_HAS_THREE_WAY_COMPARISON) 16 | struct synth_three_way 17 | { 18 | template 19 | constexpr auto operator()(const T& t, const U& u) const requires requires 20 | { 21 | {t < u}->std::convertible_to; 22 | {u < t}->std::convertible_to; 23 | } 24 | { 25 | if constexpr (std::three_way_comparable_with) 26 | { 27 | return t <=> u; 28 | } 29 | else 30 | { 31 | return (t < u) ? std::weak_ordering::less : 32 | (u < t) ? std::weak_ordering::greater : 33 | std::weak_ordering::equivalent; 34 | } 35 | } 36 | }; 37 | 38 | template 39 | using synth_three_way_result = decltype(synth_three_way{}(declval(), declval())); 40 | #endif 41 | 42 | } // namespace eastl 43 | 44 | 45 | #endif // Header include guard -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/arch/arch.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_ARCH_H 7 | #define EASTL_ATOMIC_INTERNAL_ARCH_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // Include the architecture specific implementations 17 | // 18 | #if defined(EA_PROCESSOR_X86) || defined(EA_PROCESSOR_X86_64) 19 | 20 | #include "x86/arch_x86.h" 21 | 22 | #elif defined(EA_PROCESSOR_ARM32) || defined(EA_PROCESSOR_ARM64) 23 | 24 | #include "arm/arch_arm.h" 25 | 26 | #endif 27 | 28 | 29 | ///////////////////////////////////////////////////////////////////////////////// 30 | 31 | 32 | #include "arch_fetch_add.h" 33 | #include "arch_fetch_sub.h" 34 | 35 | #include "arch_fetch_and.h" 36 | #include "arch_fetch_xor.h" 37 | #include "arch_fetch_or.h" 38 | 39 | #include "arch_add_fetch.h" 40 | #include "arch_sub_fetch.h" 41 | 42 | #include "arch_and_fetch.h" 43 | #include "arch_xor_fetch.h" 44 | #include "arch_or_fetch.h" 45 | 46 | #include "arch_exchange.h" 47 | 48 | #include "arch_cmpxchg_weak.h" 49 | #include "arch_cmpxchg_strong.h" 50 | 51 | #include "arch_load.h" 52 | #include "arch_store.h" 53 | 54 | #include "arch_compiler_barrier.h" 55 | 56 | #include "arch_cpu_pause.h" 57 | 58 | #include "arch_memory_barrier.h" 59 | 60 | #include "arch_signal_fence.h" 61 | 62 | #include "arch_thread_fence.h" 63 | 64 | 65 | #endif /* EASTL_ATOMIC_INTERNAL_ARCH_H */ 66 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/arch/arch_compiler_barrier.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_ARCH_COMPILER_BARRIER_H 7 | #define EASTL_ATOMIC_INTERNAL_ARCH_COMPILER_BARRIER_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | #define EASTL_ARCH_ATOMIC_COMPILER_BARRIER_AVAILABLE 0 15 | 16 | #define EASTL_ARCH_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY_AVAILABLE 0 17 | 18 | 19 | #endif /* EASTL_ATOMIC_INTERNAL_ARCH_COMPILER_BARRIER_H */ 20 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/arch/arch_cpu_pause.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // copyright (c) electronic arts inc. all rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_ARCH_CPU_PAUSE_H 7 | #define EASTL_ATOMIC_INTERNAL_ARCH_CPU_PAUSE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ARCH_ATOMIC_CPU_PAUSE() 17 | // 18 | #if defined(EASTL_ARCH_ATOMIC_CPU_PAUSE) 19 | #define EASTL_ARCH_ATOMIC_CPU_PAUSE_AVAILABLE 1 20 | #else 21 | #define EASTL_ARCH_ATOMIC_CPU_PAUSE_AVAILABLE 0 22 | #endif 23 | 24 | 25 | #endif /* EASTL_ATOMIC_INTERNAL_ARCH_CPU_PAUSE_H */ 26 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/arch/arch_memory_barrier.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_ARCH_MEMORY_BARRIER_H 7 | #define EASTL_ATOMIC_INTERNAL_ARCH_MEMORY_BARRIER_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ARCH_ATOMIC_CPU_MB() 17 | // 18 | #if defined(EASTL_ARCH_ATOMIC_CPU_MB) 19 | #define EASTL_ARCH_ATOMIC_CPU_MB_AVAILABLE 1 20 | #else 21 | #define EASTL_ARCH_ATOMIC_CPU_MB_AVAILABLE 0 22 | #endif 23 | 24 | 25 | ///////////////////////////////////////////////////////////////////////////////// 26 | // 27 | // void EASTL_ARCH_ATOMIC_CPU_WMB() 28 | // 29 | #if defined(EASTL_ARCH_ATOMIC_CPU_WMB) 30 | #define EASTL_ARCH_ATOMIC_CPU_WMB_AVAILABLE 1 31 | #else 32 | #define EASTL_ARCH_ATOMIC_CPU_WMB_AVAILABLE 0 33 | #endif 34 | 35 | 36 | ///////////////////////////////////////////////////////////////////////////////// 37 | // 38 | // void EASTL_ARCH_ATOMIC_CPU_RMB() 39 | // 40 | #if defined(EASTL_ARCH_ATOMIC_CPU_RMB) 41 | #define EASTL_ARCH_ATOMIC_CPU_RMB_AVAILABLE 1 42 | #else 43 | #define EASTL_ARCH_ATOMIC_CPU_RMB_AVAILABLE 0 44 | #endif 45 | 46 | 47 | #endif /* EASTL_ATOMIC_INTERNAL_ARCH_MEMORY_BARRIER_H */ 48 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/arch/arch_signal_fence.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_ARCH_SIGNAL_FENCE_H 7 | #define EASTL_ATOMIC_INTERNAL_ARCH_SIGNAL_FENCE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | #define EASTL_ARCH_ATOMIC_SIGNAL_FENCE_RELAXED_AVAILABLE 0 15 | #define EASTL_ARCH_ATOMIC_SIGNAL_FENCE_ACQUIRE_AVAILABLE 0 16 | #define EASTL_ARCH_ATOMIC_SIGNAL_FENCE_RELEASE_AVAILABLE 0 17 | #define EASTL_ARCH_ATOMIC_SIGNAL_FENCE_ACQ_REL_AVAILABLE 0 18 | #define EASTL_ARCH_ATOMIC_SIGNAL_FENCE_SEQ_CST_AVAILABLE 0 19 | 20 | 21 | #endif /* EASTL_ATOMIC_INTERNAL_ARCH_SIGNAL_FENCE_H */ 22 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/arch/arch_thread_fence.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_ARCH_THREAD_FENCE_H 7 | #define EASTL_ATOMIC_INTERNAL_ARCH_THREAD_FENCE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ARCH_ATOMIC_THREAD_FENCE_*() 17 | // 18 | #if defined(EASTL_ARCH_ATOMIC_THREAD_FENCE_RELAXED) 19 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_RELAXED_AVAILABLE 1 20 | #else 21 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_RELAXED_AVAILABLE 0 22 | #endif 23 | 24 | #if defined(EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQUIRE) 25 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQUIRE_AVAILABLE 1 26 | #else 27 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQUIRE_AVAILABLE 0 28 | #endif 29 | 30 | #if defined(EASTL_ARCH_ATOMIC_THREAD_FENCE_RELEASE) 31 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_RELEASE_AVAILABLE 1 32 | #else 33 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_RELEASE_AVAILABLE 0 34 | #endif 35 | 36 | #if defined(EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQ_REL) 37 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQ_REL_AVAILABLE 1 38 | #else 39 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQ_REL_AVAILABLE 0 40 | #endif 41 | 42 | #if defined(EASTL_ARCH_ATOMIC_THREAD_FENCE_SEQ_CST) 43 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_SEQ_CST_AVAILABLE 1 44 | #else 45 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_SEQ_CST_AVAILABLE 0 46 | #endif 47 | 48 | 49 | #endif /* EASTL_ATOMIC_INTERNAL_ARCH_THREAD_FENCE_H */ 50 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/arch/arm/arch_arm_thread_fence.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_ARCH_ARM_THREAD_FENCE_H 7 | #define EASTL_ATOMIC_INTERNAL_ARCH_ARM_THREAD_FENCE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ARCH_ATOMIC_THREAD_FENCE_*() 17 | // 18 | #if defined(EA_COMPILER_MSVC) 19 | 20 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_RELAXED() 21 | 22 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQUIRE() \ 23 | EASTL_ATOMIC_CPU_MB() 24 | 25 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_RELEASE() \ 26 | EASTL_ATOMIC_CPU_MB() 27 | 28 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQ_REL() \ 29 | EASTL_ATOMIC_CPU_MB() 30 | 31 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_SEQ_CST() \ 32 | EASTL_ATOMIC_CPU_MB() 33 | 34 | #endif 35 | 36 | 37 | #endif /* EASTL_ATOMIC_INTERNAL_ARCH_ARM_THREAD_FENCE_H */ 38 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/arch/x86/arch_x86_thread_fence.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_ARCH_X86_THREAD_FENCE_H 7 | #define EASTL_ATOMIC_INTERNAL_ARCH_X86_THREAD_FENCE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ARCH_ATOMIC_THREAD_FENCE_*() 17 | // 18 | #if defined(EA_COMPILER_MSVC) 19 | 20 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_RELAXED() 21 | 22 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQUIRE() \ 23 | EASTL_ATOMIC_COMPILER_BARRIER() 24 | 25 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_RELEASE() \ 26 | EASTL_ATOMIC_COMPILER_BARRIER() 27 | 28 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_ACQ_REL() \ 29 | EASTL_ATOMIC_COMPILER_BARRIER() 30 | 31 | #endif 32 | 33 | 34 | #if defined(EA_COMPILER_MSVC) || defined(__clang__) || defined(EA_COMPILER_GNUC) 35 | 36 | #define EASTL_ARCH_ATOMIC_THREAD_FENCE_SEQ_CST() \ 37 | EASTL_ATOMIC_CPU_MB() 38 | 39 | #endif 40 | 41 | 42 | #endif /* EASTL_ATOMIC_INTERNAL_ARCH_X86_THREAD_FENCE_H */ 43 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/atomic_macros/atomic_macros_compiler_barrier.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_MACROS_COMPILER_BARRIER_H 7 | #define EASTL_ATOMIC_INTERNAL_MACROS_COMPILER_BARRIER_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ATOMIC_COMPILER_BARRIER() 17 | // 18 | #define EASTL_ATOMIC_COMPILER_BARRIER() \ 19 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_COMPILER_BARRIER)() 20 | 21 | 22 | ///////////////////////////////////////////////////////////////////////////////// 23 | // 24 | // void EASTL_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY(const T&, type) 25 | // 26 | #define EASTL_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY(val, type) \ 27 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY)(val, type) 28 | 29 | 30 | #endif /* EASTL_ATOMIC_INTERNAL_MACROS_COMPILER_BARRIER_H */ 31 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/atomic_macros/atomic_macros_cpu_pause.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_MACROS_CPU_PAUSE_H 7 | #define EASTL_ATOMIC_INTERNAL_MACROS_CPU_PAUSE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ATOMIC_CPU_PAUSE() 17 | // 18 | #define EASTL_ATOMIC_CPU_PAUSE() \ 19 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_CPU_PAUSE)() 20 | 21 | 22 | #endif /* EASTL_ATOMIC_INTERNAL_MACROS_CPU_PAUSE_H */ 23 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/atomic_macros/atomic_macros_memory_barrier.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_MACROS_MEMORY_BARRIER_H 7 | #define EASTL_ATOMIC_INTERNAL_MACROS_MEMORY_BARRIER_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ATOMIC_CPU_MB() 17 | // 18 | #define EASTL_ATOMIC_CPU_MB() \ 19 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_CPU_MB)() 20 | 21 | 22 | ///////////////////////////////////////////////////////////////////////////////// 23 | // 24 | // void EASTL_ATOMIC_CPU_WMB() 25 | // 26 | #define EASTL_ATOMIC_CPU_WMB() \ 27 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_CPU_WMB)() 28 | 29 | 30 | ///////////////////////////////////////////////////////////////////////////////// 31 | // 32 | // void EASTL_ATOMIC_CPU_RMB() 33 | // 34 | #define EASTL_ATOMIC_CPU_RMB() \ 35 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_CPU_RMB)() 36 | 37 | 38 | #endif /* EASTL_ATOMIC_INTERNAL_MACROS_MEMORY_BARRIER_H */ 39 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/atomic_macros/atomic_macros_signal_fence.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_MACROS_SIGNAL_FENCE_H 7 | #define EASTL_ATOMIC_INTERNAL_MACROS_SIGNAL_FENCE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ATOMIC_SIGNAL_FENCE_*() 17 | // 18 | #define EASTL_ATOMIC_SIGNAL_FENCE_RELAXED() \ 19 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_SIGNAL_FENCE_RELAXED)() 20 | 21 | #define EASTL_ATOMIC_SIGNAL_FENCE_ACQUIRE() \ 22 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_SIGNAL_FENCE_ACQUIRE)() 23 | 24 | #define EASTL_ATOMIC_SIGNAL_FENCE_RELEASE() \ 25 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_SIGNAL_FENCE_RELEASE)() 26 | 27 | #define EASTL_ATOMIC_SIGNAL_FENCE_ACQ_REL() \ 28 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_SIGNAL_FENCE_ACQ_REL)() 29 | 30 | #define EASTL_ATOMIC_SIGNAL_FENCE_SEQ_CST() \ 31 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_SIGNAL_FENCE_SEQ_CST)() 32 | 33 | 34 | #endif /* EASTL_ATOMIC_INTERNAL_MACROS_SIGNAL_FENCE_H */ 35 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/atomic_macros/atomic_macros_thread_fence.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_MACROS_THREAD_FENCE_H 7 | #define EASTL_ATOMIC_INTERNAL_MACROS_THREAD_FENCE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_ATOMIC_THREAD_FENCE_*() 17 | // 18 | #define EASTL_ATOMIC_THREAD_FENCE_RELAXED() \ 19 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_THREAD_FENCE_RELAXED)() 20 | 21 | #define EASTL_ATOMIC_THREAD_FENCE_ACQUIRE() \ 22 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_THREAD_FENCE_ACQUIRE)() 23 | 24 | #define EASTL_ATOMIC_THREAD_FENCE_RELEASE() \ 25 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_THREAD_FENCE_RELEASE)() 26 | 27 | #define EASTL_ATOMIC_THREAD_FENCE_ACQ_REL() \ 28 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_THREAD_FENCE_ACQ_REL)() 29 | 30 | #define EASTL_ATOMIC_THREAD_FENCE_SEQ_CST() \ 31 | EASTL_ATOMIC_CHOOSE_OP_IMPL(ATOMIC_THREAD_FENCE_SEQ_CST)() 32 | 33 | 34 | #endif /* EASTL_ATOMIC_INTERNAL_MACROS_THREAD_FENCE_H */ 35 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/atomic_memory_order.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_MEMORY_ORDER_H 7 | #define EASTL_ATOMIC_INTERNAL_MEMORY_ORDER_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | namespace eastl 15 | { 16 | 17 | 18 | namespace internal 19 | { 20 | 21 | 22 | struct memory_order_relaxed_s {}; 23 | struct memory_order_read_depends_s {}; 24 | struct memory_order_acquire_s {}; 25 | struct memory_order_release_s {}; 26 | struct memory_order_acq_rel_s {}; 27 | struct memory_order_seq_cst_s {}; 28 | 29 | 30 | } // namespace internal 31 | 32 | 33 | EASTL_CPP17_INLINE_VARIABLE EA_CONSTEXPR auto memory_order_relaxed = internal::memory_order_relaxed_s{}; 34 | EASTL_CPP17_INLINE_VARIABLE EA_CONSTEXPR auto memory_order_read_depends = internal::memory_order_read_depends_s{}; 35 | EASTL_CPP17_INLINE_VARIABLE EA_CONSTEXPR auto memory_order_acquire = internal::memory_order_acquire_s{}; 36 | EASTL_CPP17_INLINE_VARIABLE EA_CONSTEXPR auto memory_order_release = internal::memory_order_release_s{}; 37 | EASTL_CPP17_INLINE_VARIABLE EA_CONSTEXPR auto memory_order_acq_rel = internal::memory_order_acq_rel_s{}; 38 | EASTL_CPP17_INLINE_VARIABLE EA_CONSTEXPR auto memory_order_seq_cst = internal::memory_order_seq_cst_s{}; 39 | 40 | 41 | } // namespace eastl 42 | 43 | 44 | #endif /* EASTL_ATOMIC_INTERNAL_MEMORY_ORDER_H */ 45 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/atomic_pop_compiler_options.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | /* NOTE: No Header Guard */ 7 | 8 | 9 | EA_RESTORE_VC_WARNING(); 10 | 11 | EA_RESTORE_CLANG_WARNING(); 12 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/atomic_push_compiler_options.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | /* NOTE: No Header Guard */ 7 | 8 | 9 | // 'class' : multiple assignment operators specified 10 | EA_DISABLE_VC_WARNING(4522); 11 | 12 | // misaligned atomic operation may incur significant performance penalty 13 | // The above warning is emitted in earlier versions of clang incorrectly. 14 | // All eastl::atomic objects are size aligned. 15 | // This is static and runtime asserted. 16 | // Thus we disable this warning. 17 | EA_DISABLE_CLANG_WARNING(-Watomic-alignment); 18 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/compiler_barrier.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_BARRIER_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_BARRIER_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_COMPILER_ATOMIC_COMPILER_BARRIER() 17 | // 18 | #if defined(EASTL_COMPILER_ATOMIC_COMPILER_BARRIER) 19 | #define EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_AVAILABLE 1 20 | #else 21 | #define EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_AVAILABLE 0 22 | #endif 23 | 24 | 25 | ///////////////////////////////////////////////////////////////////////////////// 26 | // 27 | // void EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY(const T&, type) 28 | // 29 | #if defined(EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY) 30 | #define EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY_AVAILABLE 1 31 | #else 32 | #define EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY_AVAILABLE 0 33 | #endif 34 | 35 | 36 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_BARRIER_H */ 37 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/compiler_cpu_pause.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_CPU_PAUSE_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_CPU_PAUSE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_COMPILER_ATOMIC_CPU_PAUSE() 17 | // 18 | #if defined(EASTL_COMPILER_ATOMIC_CPU_PAUSE) 19 | 20 | #define EASTL_COMPILER_ATOMIC_CPU_PAUSE_AVAILABLE 1 21 | 22 | #else 23 | 24 | #define EASTL_COMPILER_ATOMIC_CPU_PAUSE() \ 25 | ((void)0) 26 | 27 | #define EASTL_COMPILER_ATOMIC_CPU_PAUSE_AVAILABLE 1 28 | 29 | #endif 30 | 31 | 32 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_CPU_PAUSE_H */ 33 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/compiler_memory_barrier.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_MEMORY_BARRIER_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_MEMORY_BARRIER_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_COMPILER_ATOMIC_CPU_MB() 17 | // 18 | #if defined(EASTL_COMPILER_ATOMIC_CPU_MB) 19 | #define EASTL_COMPILER_ATOMIC_CPU_MB_AVAILABLE 1 20 | #else 21 | #define EASTL_COMPILER_ATOMIC_CPU_MB_AVAILABLE 0 22 | #endif 23 | 24 | 25 | ///////////////////////////////////////////////////////////////////////////////// 26 | // 27 | // void EASTL_COMPILER_ATOMIC_CPU_WMB() 28 | // 29 | #if defined(EASTL_COMPILER_ATOMIC_CPU_WMB) 30 | #define EASTL_COMPILER_ATOMIC_CPU_WMB_AVAILABLE 1 31 | #else 32 | #define EASTL_COMPILER_ATOMIC_CPU_WMB_AVAILABLE 0 33 | #endif 34 | 35 | 36 | ///////////////////////////////////////////////////////////////////////////////// 37 | // 38 | // void EASTL_COMPILER_ATOMIC_CPU_RMB() 39 | // 40 | #if defined(EASTL_COMPILER_ATOMIC_CPU_RMB) 41 | #define EASTL_COMPILER_ATOMIC_CPU_RMB_AVAILABLE 1 42 | #else 43 | #define EASTL_COMPILER_ATOMIC_CPU_RMB_AVAILABLE 0 44 | #endif 45 | 46 | 47 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_MEMORY_BARRIER_H */ 48 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/gcc/compiler_gcc_barrier.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_GCC_BARRIER_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_GCC_BARRIER_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_COMPILER_ATOMIC_COMPILER_BARRIER() 17 | // 18 | #define EASTL_COMPILER_ATOMIC_COMPILER_BARRIER() \ 19 | __asm__ __volatile__ ("" ::: "memory") 20 | 21 | 22 | ///////////////////////////////////////////////////////////////////////////////// 23 | // 24 | // void EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY(const T&, type) 25 | // 26 | #define EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY(val, type) \ 27 | __asm__ __volatile__ ("" : /* Output Operands */ : "r"(&(val)) : "memory") 28 | 29 | 30 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_GCC_BARRIER_H */ 31 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/gcc/compiler_gcc_cpu_pause.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_GCC_CPU_PAUSE_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_GCC_CPU_PAUSE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_COMPILER_ATOMIC_CPU_PAUSE() 17 | // 18 | #if defined(EA_PROCESSOR_X86) || defined(EA_PROCESSOR_X86_64) 19 | 20 | #define EASTL_COMPILER_ATOMIC_CPU_PAUSE() \ 21 | __asm__ __volatile__ ("pause") 22 | 23 | #elif defined(EA_PROCESSOR_ARM32) || defined(EA_PROCESSOR_ARM64) 24 | 25 | #define EASTL_COMPILER_ATOMIC_CPU_PAUSE() \ 26 | __asm__ __volatile__ ("yield") 27 | 28 | #endif 29 | 30 | 31 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_GCC_CPU_PAUSE_H */ 32 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/gcc/compiler_gcc_signal_fence.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_GCC_SIGNAL_FENCE_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_GCC_SIGNAL_FENCE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | #define EASTL_GCC_ATOMIC_SIGNAL_FENCE(gccMemoryOrder) \ 15 | __atomic_signal_fence(gccMemoryOrder) 16 | 17 | 18 | ///////////////////////////////////////////////////////////////////////////////// 19 | // 20 | // void EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_*() 21 | // 22 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_RELAXED() \ 23 | EASTL_GCC_ATOMIC_SIGNAL_FENCE(__ATOMIC_RELAXED) 24 | 25 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_ACQUIRE() \ 26 | EASTL_GCC_ATOMIC_SIGNAL_FENCE(__ATOMIC_ACQUIRE) 27 | 28 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_RELEASE() \ 29 | EASTL_GCC_ATOMIC_SIGNAL_FENCE(__ATOMIC_RELEASE) 30 | 31 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_ACQ_REL() \ 32 | EASTL_GCC_ATOMIC_SIGNAL_FENCE(__ATOMIC_ACQ_REL) 33 | 34 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_SEQ_CST() \ 35 | EASTL_GCC_ATOMIC_SIGNAL_FENCE(__ATOMIC_SEQ_CST) 36 | 37 | 38 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_GCC_SIGNAL_FENCE_H */ 39 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/gcc/compiler_gcc_thread_fence.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_GCC_THREAD_FENCE_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_GCC_THREAD_FENCE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | #define EASTL_GCC_ATOMIC_THREAD_FENCE(gccMemoryOrder) \ 15 | __atomic_thread_fence(gccMemoryOrder) 16 | 17 | 18 | ///////////////////////////////////////////////////////////////////////////////// 19 | // 20 | // void EASTL_COMPILER_ATOMIC_THREAD_FENCE_*() 21 | // 22 | #define EASTL_COMPILER_ATOMIC_THREAD_FENCE_RELAXED() \ 23 | EASTL_GCC_ATOMIC_THREAD_FENCE(__ATOMIC_RELAXED) 24 | 25 | #define EASTL_COMPILER_ATOMIC_THREAD_FENCE_ACQUIRE() \ 26 | EASTL_GCC_ATOMIC_THREAD_FENCE(__ATOMIC_ACQUIRE) 27 | 28 | #define EASTL_COMPILER_ATOMIC_THREAD_FENCE_RELEASE() \ 29 | EASTL_GCC_ATOMIC_THREAD_FENCE(__ATOMIC_RELEASE) 30 | 31 | #define EASTL_COMPILER_ATOMIC_THREAD_FENCE_ACQ_REL() \ 32 | EASTL_GCC_ATOMIC_THREAD_FENCE(__ATOMIC_ACQ_REL) 33 | 34 | #define EASTL_COMPILER_ATOMIC_THREAD_FENCE_SEQ_CST() \ 35 | EASTL_GCC_ATOMIC_THREAD_FENCE(__ATOMIC_SEQ_CST) 36 | 37 | 38 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_GCC_THREAD_FENCE_H */ 39 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/msvc/compiler_msvc_barrier.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_MSVC_BARRIER_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_MSVC_BARRIER_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_COMPILER_ATOMIC_COMPILER_BARRIER() 17 | // 18 | #define EASTL_COMPILER_ATOMIC_COMPILER_BARRIER() \ 19 | EA_DISABLE_CLANG_WARNING(-Wdeprecated-declarations) \ 20 | _ReadWriteBarrier() \ 21 | EA_RESTORE_CLANG_WARNING() 22 | 23 | 24 | ///////////////////////////////////////////////////////////////////////////////// 25 | // 26 | // void EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY(const T&, type) 27 | // 28 | #define EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY(val, type) \ 29 | EASTL_COMPILER_ATOMIC_COMPILER_BARRIER_DATA_DEPENDENCY_FUNC(const_cast(eastl::addressof((val)))); \ 30 | EASTL_ATOMIC_COMPILER_BARRIER() 31 | 32 | 33 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_MSVC_BARRIER_H */ 34 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/msvc/compiler_msvc_cpu_pause.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // copyright (c) electronic arts inc. all rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_MSVC_CPU_PAUSE_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_MSVC_CPU_PAUSE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | #if defined(EA_PROCESSOR_X86) || defined(EA_PROCESSOR_X86_64) 14 | #define EASTL_COMPILER_ATOMIC_CPU_PAUSE() _mm_pause() 15 | #elif defined(EA_PROCESSOR_ARM32) || defined(EA_PROCESSOR_ARM64) 16 | #define EASTL_COMPILER_ATOMIC_CPU_PAUSE() __yield() 17 | #else 18 | #error Unsupported CPU architecture for EASTL_COMPILER_ATOMIC_CPU_PAUSE 19 | #endif 20 | 21 | 22 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_MSVC_CPU_PAUSE_H */ 23 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/atomic/compiler/msvc/compiler_msvc_signal_fence.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_ATOMIC_INTERNAL_COMPILER_MSVC_SIGNAL_FENCE_H 7 | #define EASTL_ATOMIC_INTERNAL_COMPILER_MSVC_SIGNAL_FENCE_H 8 | 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | 14 | ///////////////////////////////////////////////////////////////////////////////// 15 | // 16 | // void EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_*() 17 | // 18 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_RELAXED() \ 19 | EASTL_ATOMIC_COMPILER_BARRIER() 20 | 21 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_ACQUIRE() \ 22 | EASTL_ATOMIC_COMPILER_BARRIER() 23 | 24 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_RELEASE() \ 25 | EASTL_ATOMIC_COMPILER_BARRIER() 26 | 27 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_ACQ_REL() \ 28 | EASTL_ATOMIC_COMPILER_BARRIER() 29 | 30 | #define EASTL_COMPILER_ATOMIC_SIGNAL_FENCE_SEQ_CST() \ 31 | EASTL_ATOMIC_COMPILER_BARRIER() 32 | 33 | 34 | #endif /* EASTL_ATOMIC_INTERNAL_COMPILER_MSVC_SIGNAL_FENCE_H */ 35 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/function_help.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef EASTL_INTERNAL_FUNCTION_HELP_H 6 | #define EASTL_INTERNAL_FUNCTION_HELP_H 7 | 8 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | namespace eastl 16 | { 17 | namespace internal 18 | { 19 | 20 | ////////////////////////////////////////////////////////////////////// 21 | // is_null 22 | // 23 | template 24 | bool is_null(const T&) 25 | { 26 | return false; 27 | } 28 | 29 | template 30 | bool is_null(Result (*const& function_pointer)(Arguments...)) 31 | { 32 | return function_pointer == nullptr; 33 | } 34 | 35 | template 36 | bool is_null(Result (Class::*const& function_pointer)(Arguments...)) 37 | { 38 | return function_pointer == nullptr; 39 | } 40 | 41 | template 42 | bool is_null(Result (Class::*const& function_pointer)(Arguments...) const) 43 | { 44 | return function_pointer == nullptr; 45 | } 46 | 47 | } // namespace internal 48 | } // namespace eastl 49 | 50 | #endif // Header include guard 51 | 52 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/memory_base.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef EASTL_INTERNAL_MEMORY_BASE_H 6 | #define EASTL_INTERNAL_MEMORY_BASE_H 7 | 8 | #include 9 | 10 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 11 | #pragma once // Some compilers (e.g. VC++) benefit significantly from using this. We've measured 3-4% build speed improvements in apps as a result. 12 | #endif 13 | 14 | 15 | //////////////////////////////////////////////////////////////////////////////////////////// 16 | // This file contains basic functionality found in the standard library 'memory' header that 17 | // have limited or no dependencies. This allows us to utilize these utilize these functions 18 | // in other EASTL code while avoid circular dependencies. 19 | //////////////////////////////////////////////////////////////////////////////////////////// 20 | 21 | namespace eastl 22 | { 23 | /// addressof 24 | /// 25 | /// From the C++11 Standard, section 20.6.12.1 26 | /// Returns the actual address of the object or function referenced by r, even in the presence of an overloaded operator&. 27 | /// 28 | template 29 | T* addressof(T& value) EA_NOEXCEPT 30 | { 31 | return reinterpret_cast(&const_cast(reinterpret_cast(value))); 32 | } 33 | 34 | } // namespace eastl 35 | 36 | #endif // EASTL_INTERNAL_MEMORY_BASE_H 37 | 38 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/pair_fwd_decls.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef EASTL_PAIR_FWD_DECLS_H 6 | #define EASTL_PAIR_FWD_DECLS_H 7 | 8 | #include 9 | 10 | namespace eastl 11 | { 12 | template 13 | struct pair; 14 | } 15 | 16 | #endif // EASTL_PAIR_FWD_DECLS_H 17 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/piecewise_construct_t.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_INTERNAL_PIECEWISE_CONSTRUCT_T_H 7 | #define EASTL_INTERNAL_PIECEWISE_CONSTRUCT_T_H 8 | 9 | 10 | #include 11 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 12 | #pragma once 13 | #endif 14 | 15 | namespace eastl 16 | { 17 | /////////////////////////////////////////////////////////////////////////////// 18 | /// piecewise_construct_t 19 | /// 20 | /// http://en.cppreference.com/w/cpp/utility/piecewise_construct_t 21 | /// 22 | struct piecewise_construct_t 23 | { 24 | explicit piecewise_construct_t() = default; 25 | }; 26 | 27 | 28 | /////////////////////////////////////////////////////////////////////////////// 29 | /// piecewise_construct 30 | /// 31 | /// A tag type used to disambiguate between function overloads that take two tuple arguments. 32 | /// 33 | /// http://en.cppreference.com/w/cpp/utility/piecewise_construct 34 | /// 35 | EA_CONSTEXPR piecewise_construct_t piecewise_construct = eastl::piecewise_construct_t(); 36 | 37 | } // namespace eastl 38 | 39 | 40 | #endif // Header include guard 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/internal/type_void_t.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_INTERNAL_TYPE_VOID_T_H 7 | #define EASTL_INTERNAL_TYPE_VOID_T_H 8 | 9 | 10 | #include 11 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 12 | #pragma once 13 | #endif 14 | 15 | namespace eastl 16 | { 17 | 18 | /////////////////////////////////////////////////////////////////////// 19 | // void_t 20 | // 21 | // Maps a sequence of any types to void. This utility class is used in 22 | // template meta programming to simplify compile time reflection mechanisms 23 | // required by the standard library. 24 | // 25 | // http://en.cppreference.com/w/cpp/types/void_t 26 | // 27 | // Example: 28 | // template 29 | // struct is_iterable : false_type {}; 30 | // 31 | // template 32 | // struct is_iterable().begin()), 33 | // decltype(declval().end())>> : true_type {}; 34 | // 35 | /////////////////////////////////////////////////////////////////////// 36 | template 37 | using void_t = void; 38 | 39 | 40 | } // namespace eastl 41 | 42 | 43 | #endif // Header include guard 44 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/version.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef EASTL_VERSION_H 6 | #define EASTL_VERSION_H 7 | 8 | #include 9 | #if defined(EA_PRAGMA_ONCE_SUPPORTED) 10 | #pragma once 11 | #endif 12 | 13 | #include 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/include/EASTL/weak_ptr.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | /////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTL_WEAK_PTR_H 7 | #define EASTL_WEAK_PTR_H 8 | 9 | 10 | // This header file is deprecated. The implementation has moved: 11 | #include 12 | 13 | 14 | #endif 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/scripts/build.sh: -------------------------------------------------------------------------------- 1 | build_folder=build 2 | 3 | rm -rf $build_folder 4 | mkdir $build_folder 5 | pushd $build_folder 6 | 7 | cmake .. -DEASTL_BUILD_TESTS:BOOL=OFF -DEASTL_BUILD_BENCHMARK:BOOL=ON 8 | cmake --build . --config Release -- -j 32 9 | 10 | cmake .. -DEASTL_BUILD_TESTS:BOOL=OFF -DEASTL_BUILD_BENCHMARK:BOOL=OFF 11 | cmake --build . --config Release -- -j 32 12 | 13 | cmake .. -DEASTL_BUILD_TESTS:BOOL=ON -DEASTL_BUILD_BENCHMARK:BOOL=OFF 14 | cmake --build . --config Release -- -j 32 15 | 16 | cmake .. -DEASTL_BUILD_TESTS:BOOL=ON -DEASTL_BUILD_BENCHMARK:BOOL=ON 17 | cmake --build . --config Release -- -j 32 18 | cmake --build . --config Debug -- -j 32 19 | cmake --build . --config RelWithDebInfo -- -j 32 20 | cmake --build . --config MinSizeRel -- -j 32 21 | pushd test 22 | ctest -C Release -V 23 | ctest -C Debug -V 24 | ctest -C RelWithDebInfo -V 25 | ctest -C MinSizeRel -V 26 | popd 27 | popd 28 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/source/allocator_eastl.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #include 7 | #include 8 | 9 | 10 | /////////////////////////////////////////////////////////////////////////////// 11 | // ReadMe 12 | // 13 | // This file implements the default application allocator. 14 | // You can replace this allocator.cpp file with a different one, 15 | // you can define EASTL_USER_DEFINED_ALLOCATOR below to ignore this file, 16 | // or you can modify the EASTL config.h file to redefine how allocators work. 17 | /////////////////////////////////////////////////////////////////////////////// 18 | 19 | 20 | #ifndef EASTL_USER_DEFINED_ALLOCATOR // If the user hasn't declared that he has defined an allocator implementation elsewhere... 21 | 22 | namespace eastl 23 | { 24 | 25 | /// gDefaultAllocator 26 | /// Default global allocator instance. 27 | EASTL_API allocator gDefaultAllocator; 28 | EASTL_API allocator* gpDefaultAllocator = &gDefaultAllocator; 29 | 30 | EASTL_API allocator* GetDefaultAllocator() 31 | { 32 | return gpDefaultAllocator; 33 | } 34 | 35 | EASTL_API allocator* SetDefaultAllocator(allocator* pAllocator) 36 | { 37 | allocator* const pPrevAllocator = gpDefaultAllocator; 38 | gpDefaultAllocator = pAllocator; 39 | return pPrevAllocator; 40 | } 41 | 42 | } // namespace eastl 43 | 44 | 45 | #endif // EASTL_USER_DEFINED_ALLOCATOR 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/source/atomic.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #include 7 | 8 | 9 | namespace eastl 10 | { 11 | 12 | namespace internal 13 | { 14 | 15 | 16 | static void EastlCompilerBarrierDataDependencyFunc(void*) 17 | { 18 | } 19 | 20 | volatile CompilerBarrierDataDependencyFuncPtr gCompilerBarrierDataDependencyFunc = &EastlCompilerBarrierDataDependencyFunc; 21 | 22 | 23 | } // namespace internal 24 | 25 | } // namespace eastl 26 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/test/source/EASTLTestAllocator.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #ifndef EASTLTEST_ALLOCATOR_H 7 | #define EASTLTEST_ALLOCATOR_H 8 | 9 | #include 10 | #include 11 | 12 | void* operator new(size_t size); 13 | void* operator new[](size_t size); 14 | void* operator new[](size_t size, const char* /*name*/, int /*flags*/, unsigned /*debugFlags*/, const char* /*file*/, int /*line*/); 15 | void* operator new[](size_t size, size_t alignment, size_t /*alignmentOffset*/, const char* /*name*/, int /*flags*/, unsigned /*debugFlags*/, const char* /*file*/, int /*line*/); 16 | void* operator new(size_t size, size_t alignment); 17 | void* operator new(size_t size, size_t alignment, const std::nothrow_t&) EA_THROW_SPEC_NEW_NONE(); 18 | void* operator new[](size_t size, size_t alignment); 19 | void* operator new[](size_t size, size_t alignment, const std::nothrow_t&)EA_THROW_SPEC_NEW_NONE(); 20 | void operator delete(void* p) EA_THROW_SPEC_DELETE_NONE(); 21 | void operator delete[](void* p) EA_THROW_SPEC_DELETE_NONE(); 22 | void EASTLTest_SetGeneralAllocator(); 23 | bool EASTLTest_ValidateHeap(); 24 | 25 | 26 | #endif // Header include guard 27 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/test/source/TestBitcast.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #include "EASTLTest.h" 7 | #include 8 | 9 | using namespace eastl; 10 | 11 | 12 | int TestBitcast() 13 | { 14 | int nErrorCount = 0; 15 | 16 | { 17 | uint32_t int32Value = 0x12345678; 18 | float floatValue = eastl::bit_cast(int32Value); 19 | VERIFY(memcmp(&int32Value, &floatValue, sizeof(float)) == 0); 20 | } 21 | 22 | { 23 | struct IntFloatStruct 24 | { 25 | uint32_t i = 0x87654321; 26 | float f = 10.f; 27 | }; 28 | struct CharIntStruct 29 | { 30 | char c1; 31 | char c2; 32 | char c3; 33 | char c4; 34 | uint32_t i; 35 | }; 36 | 37 | IntFloatStruct ifStruct; 38 | CharIntStruct ciStruct = eastl::bit_cast(ifStruct); 39 | VERIFY(memcmp(&ifStruct, &ciStruct, sizeof(IntFloatStruct)) == 0); 40 | } 41 | 42 | #if EASTL_CONSTEXPR_BIT_CAST_SUPPORTED 43 | { 44 | constexpr uint32_t int32Value = 40; 45 | constexpr float floatValue = eastl::bit_cast(int32Value); 46 | VERIFY(memcmp(&int32Value, &floatValue, sizeof(float)) == 0); 47 | } 48 | #endif 49 | 50 | 51 | return nErrorCount; 52 | } 53 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/test/source/TestCharTraits.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #include "EASTLTest.h" 6 | #include 7 | #include 8 | 9 | 10 | template 11 | int TestCharTraits() 12 | { 13 | int nErrorCount = 0; 14 | return nErrorCount; 15 | } 16 | 17 | 18 | int TestCharTraits() 19 | { 20 | using namespace eastl; 21 | 22 | int nErrorCount = 0; 23 | 24 | nErrorCount += TestCharTraits(); 25 | nErrorCount += TestCharTraits(); 26 | nErrorCount += TestCharTraits(); 27 | nErrorCount += TestCharTraits(); 28 | 29 | return nErrorCount; 30 | } 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/test/source/TestCppCXTypeTraits.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #include "EASTLTest.h" 7 | #include 8 | 9 | using namespace eastl; 10 | 11 | #if defined(__cplusplus_winrt) 12 | ref class Foo 13 | { 14 | 15 | }; 16 | #endif 17 | 18 | int TestCppCXTypeTraits() 19 | { 20 | int nErrorCount = 0; 21 | 22 | // We can only build this code if C++/CX is enabled 23 | #if defined(__cplusplus_winrt) 24 | { 25 | Foo^ foo = ref new Foo(); 26 | static_assert(eastl::is_pod::value == false, "Ref types are not POD"); 27 | static_assert(eastl::is_trivially_destructible::value == false, "Ref types cannot be trivially destructible"); 28 | static_assert(eastl::is_trivially_constructible::value == false, "Ref types cannot be trivially constructible"); 29 | static_assert(eastl::is_trivially_copy_constructible::value == false, "Ref types cannot be trivially copyable"); 30 | static_assert(eastl::is_trivially_copy_assignable::value == false, "Ref types cannot be trivially copyable"); 31 | } 32 | #endif 33 | 34 | return nErrorCount; 35 | } 36 | -------------------------------------------------------------------------------- /library/3rdparty/EASTL/test/source/TestIntrusiveSList.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) Electronic Arts Inc. All rights reserved. 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | 6 | #include "EASTLTest.h" 7 | #include 8 | #include 9 | 10 | 11 | 12 | // Template instantations. 13 | // These tell the compiler to compile all the functions for the given class. 14 | //template class intrusive_slist; 15 | 16 | 17 | 18 | int TestIntrusiveSList() 19 | { 20 | int nErrorCount = 0; 21 | 22 | // As of this writing, we don't yet have a completed intrusive_slist implementation. 23 | // The interface is in place but the implementation hasn't been done yet. 24 | 25 | return nErrorCount; 26 | } 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /library/3rdparty/clone-EABase-EASTL.bat: -------------------------------------------------------------------------------- 1 | 2 | rmdir /S /Q EABase 3 | rmdir /S /Q EASTL 4 | 5 | git clone --depth 1 -b 2.09.06 https://github.com/electronicarts/EABase.git 6 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 7 | cd EABase 8 | git apply ..\EABase-2.09.06.diff 9 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 10 | rmdir /S /Q .git 11 | cd .. 12 | 13 | git clone --depth 1 -b eastl-3.19.05 https://github.com/electronicarts/EASTL.git 14 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 15 | cd EASTL 16 | git apply ..\EASTL-3.19.05.diff 17 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 18 | rmdir /S /Q .git 19 | cd .. 20 | -------------------------------------------------------------------------------- /library/3rdparty/clone-EABase-EASTL.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ev 3 | 4 | rm -Rf EABase 5 | rm -Rf EASTL 6 | 7 | git clone --depth 1 -b 2.09.06 https://github.com/electronicarts/EABase.git 8 | cd EABase 9 | git apply ../EABase-2.09.06.diff 10 | rm -Rf .git 11 | cd .. 12 | 13 | git clone --depth 1 -b eastl-3.19.05 https://github.com/electronicarts/EASTL.git 14 | cd EASTL 15 | git apply ../EASTL-3.19.05.diff 16 | rm -Rf .git 17 | cd .. 18 | -------------------------------------------------------------------------------- /library/gcc_lto_workaround/build_gcc_lto_workaround_so.sh: -------------------------------------------------------------------------------- 1 | g++-10 -I ../src/iibmalloc/src/foundation/include -I ../src/iibmalloc/src/foundation/3rdparty/fmt/include -shared -o libgcc_lto_workaround.so -fPIC gcc_lto_workaround.cpp -------------------------------------------------------------------------------- /library/gcc_lto_workaround/install_lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cp libgcc_lto_workaround.so /usr/lib/libgcc_lto_workaround.so 3 | -------------------------------------------------------------------------------- /library/samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2020, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | 5 | #------------------------------------------------------------------------------------------- 6 | # Subdirectories 7 | #------------------------------------------------------------------------------------------- 8 | add_subdirectory(basic_sample) 9 | 10 | add_subdirectory(hashmap) 11 | add_subdirectory(string) 12 | add_subdirectory(vector) 13 | -------------------------------------------------------------------------------- /library/samples/basic_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2020, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | 5 | add_executable(BasicSample src/main.cpp) 6 | 7 | target_link_libraries(BasicSample safememory) 8 | 9 | -------------------------------------------------------------------------------- /library/samples/basic_sample/build/basic_sample.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.136 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic_sample", "basic_sample.vcxproj", "{EA4CD000-B5FD-4F9C-AE42-9A89C41B6F99}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {EA4CD000-B5FD-4F9C-AE42-9A89C41B6F99}.Debug|x64.ActiveCfg = Debug|x64 15 | {EA4CD000-B5FD-4F9C-AE42-9A89C41B6F99}.Debug|x64.Build.0 = Debug|x64 16 | {EA4CD000-B5FD-4F9C-AE42-9A89C41B6F99}.Release|x64.ActiveCfg = Release|x64 17 | {EA4CD000-B5FD-4F9C-AE42-9A89C41B6F99}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {16051A02-6000-4FC9-8401-4CF10DCAB1C9} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /library/samples/basic_sample/build/build_clang.sh: -------------------------------------------------------------------------------- 1 | rm ./sample.bin 2 | clang++ ../src/main.cpp ../../../src/safe_ptr.cpp ../../../src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../src/iibmalloc/src/foundation/src/log.cpp ../../../src/iibmalloc/src/foundation/src/cpu_exceptions_translator.cpp ../../../src/iibmalloc/src/foundation/src/std_error.cpp ../../../src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../src/iibmalloc/src/page_allocator_linux.cpp ../../../src/iibmalloc/src/iibmalloc_linux.cpp -I../../../src/iibmalloc/src -I../../../src -I../../../src/iibmalloc/src/foundation/include -I../../../src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++17 -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -fexceptions -fnon-call-exceptions -DNDEBUG -O2 -flto -o sample.bin -------------------------------------------------------------------------------- /library/samples/basic_sample/build/build_gcc.sh: -------------------------------------------------------------------------------- 1 | rm ./sample.bin 2 | g++ ../src/main.cpp ../../../src/safe_ptr.cpp ../../../gcc_lto_workaround/gcc_lto_workaround.cpp ../../../src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../src/iibmalloc/src/foundation/src/log.cpp ../../../src/iibmalloc/src/foundation/src/cpu_exceptions_translator.cpp ../../../src/iibmalloc/src/foundation/src/std_error.cpp ../../../src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../src/iibmalloc/src/page_allocator_linux.cpp ../../../src/iibmalloc/src/iibmalloc_linux.cpp -I../../../src/iibmalloc/src -I../../../src -I../../../src/iibmalloc/src/foundation/include -I../../../src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++17 -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -fexceptions -fnon-call-exceptions -DNDEBUG -O2 -flto -o sample.bin -------------------------------------------------------------------------------- /library/samples/basic_sample/src/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | using namespace safememory; 6 | 7 | void sampleTestCall() 8 | { 9 | struct Any { soft_ptr softN; }; 10 | owning_ptr any = make_owning(); 11 | { 12 | owning_ptr owningN = make_owning( 5 ); 13 | any->softN = owningN; 14 | printf( "so far, so good (we\'ve assigned a value of owning_ptr to soft_ptr)\n" ); 15 | printf( "end of scope of owning_ptr...\n" ); 16 | // what's pointed by owningN is deleted here 17 | } 18 | printf( "trying to access a deleted object...\n" ); 19 | printf( "throwing call (control value: %d)\n", *(any->softN) ); 20 | 21 | soft_ptr softN; 22 | nullable_ptr x = nullptr; 23 | printf( "throwing call (control value: %d)\n", *x ); 24 | 25 | } 26 | 27 | int main() 28 | { 29 | printf( "Hello Memory Safe Cpp!\n" ); 30 | try { 31 | sampleTestCall(); 32 | printf( "Passed successfully!\n" ); 33 | } 34 | catch (nodecpp::error::memory_error e) 35 | { 36 | printf( "Exception caught: \"%s\"\n", e.description().c_str() ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /library/samples/hashmap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2020, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | 5 | add_executable(HashMapSample main.cpp) 6 | 7 | target_link_libraries(HashMapSample safememory) 8 | 9 | -------------------------------------------------------------------------------- /library/samples/string/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2020, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | 5 | add_executable(StringSample main.cpp) 6 | 7 | target_link_libraries(StringSample safememory) 8 | 9 | -------------------------------------------------------------------------------- /library/samples/string/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace sm = safememory; 10 | 11 | void someFunc(const sm::string& str) {} 12 | 13 | int main() { 14 | 15 | sm::string_literal lit = "hello!"; 16 | sm::string s = sm::string_literal("hello!"); 17 | sm::string s2("hello!"); 18 | safememory::string s3 = sm::string{"hello!"}; //error 19 | 20 | s3 = "w3"; 21 | 22 | if(s3 == "world") 23 | someFunc(sm::string{"hello!"}); 24 | 25 | s.append("! - "); 26 | 27 | for(auto it = s.begin(); it != s.end(); ++it) 28 | s2 += *it; 29 | 30 | for(auto its = s2.begin(); its != s2.end(); ++its) { 31 | s += *its; 32 | } 33 | 34 | // fmt::print("{}\n", sm::to_string(42)); //sm::string_literal 35 | fmt::print("{}\n", lit); //sm::string_literal 36 | fmt::print("{}\n", s2); //sm::string 37 | 38 | std::cout << lit << std::endl << s2 << std::endl; 39 | 40 | fmt::printf(s2.c_str()); 41 | 42 | s2.erase(s2.cbegin() + 7, s2.cend()); 43 | fmt::printf(s2.c_str()); 44 | 45 | fmt::printf("done\n"); 46 | return 0; 47 | } 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /library/samples/vector/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2020, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | 5 | add_executable(VectorSample main.cpp) 6 | 7 | target_link_libraries(VectorSample safememory) 8 | 9 | -------------------------------------------------------------------------------- /library/samples/vector/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | 6 | int main() { 7 | 8 | safememory::vector vi; 9 | 10 | vi.push_back(3); 11 | vi.push_back(4); 12 | vi.push_back(5); 13 | 14 | 15 | fmt::printf("done\n"); 16 | return 0; 17 | } 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /library/test/build/build_clang.sh: -------------------------------------------------------------------------------- 1 | clang++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/gcc_lto_workaround/gcc_lto_workaround.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -flto -lpthread -o test_clang.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_clang_no_workaround.sh: -------------------------------------------------------------------------------- 1 | clang++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/gcc_lto_workaround/gcc_lto_workaround.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -lpthread -flto -o test_clang_no_workaround.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_clang_no_workaround_no_lto.sh: -------------------------------------------------------------------------------- 1 | clang++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/gcc_lto_workaround/gcc_lto_workaround.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -lpthread -o test_clang_no_workaround_no_lto.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_clang_with_destruction_info.sh: -------------------------------------------------------------------------------- 1 | clang++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/gcc_lto_workaround/gcc_lto_workaround.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -DNODECPP_MEMORY_SAFETY_DBG_ADD_PTR_LIFECYCLE_INFO -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -flto -lpthread -o test_clang_with_destruction_info.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_clang_with_workaround.sh: -------------------------------------------------------------------------------- 1 | clang++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -flto -lgcc_lto_workaround -lpthread -o test_clang_with_workaround.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_gcc.sh: -------------------------------------------------------------------------------- 1 | g++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/gcc_lto_workaround/gcc_lto_workaround.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -flto -fno-lifetime-dse -ldl -lpthread -o test_gcc_no_lifetime_dse.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_gcc_no_lifetime_dse.sh: -------------------------------------------------------------------------------- 1 | g++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/gcc_lto_workaround/gcc_lto_workaround.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -flto -fno-lifetime-dse -ldl -lpthread -o test_gcc_no_lifetime_dse.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_gcc_no_workaround.sh: -------------------------------------------------------------------------------- 1 | g++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/gcc_lto_workaround/gcc_lto_workaround.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -flto -ldl -lpthread -o test_gcc_no_workaround.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_gcc_no_workaround_no_lto.sh: -------------------------------------------------------------------------------- 1 | g++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/gcc_lto_workaround/gcc_lto_workaround.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -ldl -lpthread -o test_gcc_no_workaround_no_lto.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_gcc_with_destruction_info.sh: -------------------------------------------------------------------------------- 1 | g++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/gcc_lto_workaround/gcc_lto_workaround.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -DNODECPP_MEMORY_SAFETY_DBG_ADD_PTR_LIFECYCLE_INFO -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -flto -fno-lifetime-dse -ldl -lpthread -o test_gcc_with_destruction_info.bin 2 | -------------------------------------------------------------------------------- /library/test/build/build_gcc_with_workaround.sh: -------------------------------------------------------------------------------- 1 | g++-10 ../test_safe_pointers.cpp ../../../library/src/safe_ptr.cpp ../../../library/src/string.cpp ../../../library/src/nodecpp_error.cpp ../../../library/src/iibmalloc/src/foundation/src/std_error.cpp ../../../library/src/iibmalloc/src/foundation/src/safe_memory_error.cpp ../../../library/src/iibmalloc/src/foundation/src/log.cpp ../../../library/src/iibmalloc/src/foundation/src/tagged_ptr_impl.cpp ../../../library/src/iibmalloc/src/foundation/src/stack_info.cpp ../../../library/src/detail/allocator_to_eastl.cpp ../../../library/3rdparty/EASTL/source/hashtable.cpp ../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/src/format.cc ../../../library/src/iibmalloc/src/foundation/src/nodecpp_assert.cpp ../../../library/src/iibmalloc/src/foundation/src/page_allocator.cpp ../../../library/src/iibmalloc/src/iibmalloc.cpp -I../../../library/src/iibmalloc/src -I../../../library/src -I../../../library/include -I../../../library/3rdparty/EABase/include/Common -I../../../library/3rdparty/EASTL/include -I../../../library/src/iibmalloc/src/foundation/include -I../../../library/src/iibmalloc/src/foundation/3rdparty/fmt/include -std=c++20 -DNODECPP_MEMORY_SAFETY_EXCLUSIONS="\"../test/safety_exclusions.h\"" -DUSING_T_SOCKETS -DEASTL_EXCEPTIONS_ENABLED -DEASTL_STRING_OPT_RANGE_ERRORS=0 -DEASTL_STD_ITERATOR_CATEGORY_ENABLED -DEASTL_EASTDC_VSNPRINTF=0 -DEASTL_SIZE_T_32BIT -g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-empty-body -DNDEBUG -O2 -flto -lgcc_lto_workaround -ldl -lpthread -o test_gcc_with_workaround.bin 2 | -------------------------------------------------------------------------------- /library/test/containers/EASTL-benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2021, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | 5 | #------------------------------------------------------------------------------------------- 6 | # CMake info 7 | #------------------------------------------------------------------------------------------- 8 | cmake_minimum_required(VERSION 3.1) 9 | project(SafeMemoryBenchmarks CXX) 10 | include(CTest) 11 | 12 | 13 | #------------------------------------------------------------------------------------------- 14 | # Executable definition 15 | #------------------------------------------------------------------------------------------- 16 | add_executable(SafeMemoryBenchmarks 17 | BenchmarkHash.cpp 18 | BenchmarkString.cpp 19 | BenchmarkVector.cpp 20 | EASTLBenchmark.cpp 21 | EASTLTest.cpp 22 | EAStopwatch.cpp 23 | main.cpp 24 | ) 25 | 26 | target_link_libraries(SafeMemoryBenchmarks safememory) 27 | 28 | #------------------------------------------------------------------------------------------- 29 | # Run Unit tests and verify the results. 30 | #------------------------------------------------------------------------------------------- 31 | # add_test(SafeMemoryBenchmarksRun SafeMemoryBenchmarks) 32 | 33 | -------------------------------------------------------------------------------- /library/test/containers/README.txt: -------------------------------------------------------------------------------- 1 | 2 | All 'EA' files under this folder are taken from EASTL 3.15.00 3 | and its subtrees. 4 | 5 | https://github.com/electronicarts/EASTL/tree/3.15.00 6 | 7 | -------------------------------------------------------------------------------- /library/test/containers/dezombiefy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2021, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | 5 | #------------------------------------------------------------------------------------------- 6 | # Executable definition 7 | #------------------------------------------------------------------------------------------- 8 | 9 | add_executable(test_dezombiefy_iterators test_dezombiefy_iterators.cpp) 10 | target_link_libraries(test_dezombiefy_iterators safememory_dz_it) 11 | 12 | #------------------------------------------------------------------------------------------- 13 | # Run Unit tests and verify the results. 14 | #------------------------------------------------------------------------------------------- 15 | add_test(test_dezombiefy_iteratorsRun test_dezombiefy_iterators) 16 | -------------------------------------------------------------------------------- /library/test/containers/zeroed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------- 2 | # Copyright (c) 2021, OLogN Technologies AG 3 | #------------------------------------------------------------------------------------------- 4 | 5 | #------------------------------------------------------------------------------------------- 6 | # Executable definition 7 | #------------------------------------------------------------------------------------------- 8 | 9 | add_executable(test_zeroed_containers test_zeroed_containers.cpp) 10 | target_link_libraries(test_zeroed_containers safememory) 11 | 12 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 13 | target_compile_options(test_zeroed_containers PRIVATE -Wno-class-memaccess) 14 | endif() 15 | 16 | #------------------------------------------------------------------------------------------- 17 | # Run Unit tests and verify the results. 18 | #------------------------------------------------------------------------------------------- 19 | add_test(test_zeroed_containersRun test_zeroed_containers) 20 | -------------------------------------------------------------------------------- /library/tools/ci-android-r23c.bat: -------------------------------------------------------------------------------- 1 | rem script to build with Visual Studio 2 | rem run from root as 'tools\ci-msvc2019' 3 | 4 | rmdir /S /Q library\build\android-r23c 5 | mkdir library\build\android-r23c 6 | cd library\build\android-r23c 7 | 8 | rem env variable ANDROID_SDK_HOME should point to the root Sdk folder 9 | 10 | cmake -DSAFEMEMORY_TEST=ON -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=arm64-v8a -DANDROID_NDK=%ANDROID_SDK_HOME%\ndk\23.2.8568313 -DCMAKE_TOOLCHAIN_FILE=%ANDROID_SDK_HOME%\ndk\23.2.8568313\build\cmake\android.toolchain.cmake -G Ninja ..\.. 11 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 12 | 13 | cmake --build . 14 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 15 | 16 | rem we don't test here, since we must deploy on (virtual) device 17 | rem ctest --output-on-failure -C Release 18 | rem @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 19 | -------------------------------------------------------------------------------- /library/tools/ci-clang11.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ev 3 | 4 | rm -Rf library/build/clang11 5 | mkdir -p library/build/clang11 6 | cd library/build/clang11 7 | 8 | export CC=clang-11 9 | export CXX=clang++-11 10 | 11 | cmake -DCMAKE_BUILD_TYPE=Release -DSAFEMEMORY_TEST=ON -G "Unix Makefiles" ../.. 12 | 13 | cmake --build . 14 | 15 | ctest --output-on-failure 16 | 17 | -------------------------------------------------------------------------------- /library/tools/ci-clang13.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ev 3 | 4 | rm -Rf library/build/clang13 5 | mkdir -p library/build/clang13 6 | cd library/build/clang13 7 | 8 | export CC=clang-13 9 | export CXX=clang++-13 10 | 11 | cmake -DCMAKE_BUILD_TYPE=Release -DSAFEMEMORY_TEST=ON -G "Unix Makefiles" ../.. 12 | 13 | cmake --build . 14 | 15 | ctest --output-on-failure 16 | 17 | -------------------------------------------------------------------------------- /library/tools/ci-gcc10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ev 3 | 4 | rm -Rf library/build/gcc10 5 | mkdir -p library/build/gcc10 6 | cd library/build/gcc10 7 | 8 | export CC=gcc-10 9 | export CXX=g++-10 10 | 11 | cmake -DCMAKE_BUILD_TYPE=Release -DSAFEMEMORY_TEST=ON -G "Unix Makefiles" ../.. 12 | 13 | cmake --build . 14 | 15 | ctest --output-on-failure 16 | 17 | -------------------------------------------------------------------------------- /library/tools/ci-vs2019.bat: -------------------------------------------------------------------------------- 1 | rem script to build with Visual Studio 2 | rem run from root as 'tools\ci-msvc2019' 3 | 4 | rmdir /S /Q library\build\vs2019 5 | mkdir library\build\vs2019 6 | cd library\build\vs2019 7 | 8 | cmake -DSAFEMEMORY_TEST=ON -G "Visual Studio 16 2019" ..\.. 9 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 10 | 11 | cmake --build . --config Release 12 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 13 | 14 | ctest --output-on-failure -C Release 15 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 16 | -------------------------------------------------------------------------------- /library/tools/ci-vs2022.bat: -------------------------------------------------------------------------------- 1 | rem script to build with Visual Studio 2 | rem run from root as 'tools\ci-msvc2022' 3 | 4 | rmdir /S /Q library\build\vs2022 5 | mkdir library\build\vs2022 6 | cd library\build\vs2022 7 | 8 | cmake -DSAFEMEMORY_TEST=ON -G "Visual Studio 17 2022" ..\.. 9 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 10 | 11 | cmake --build . --config Release 12 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 13 | 14 | ctest --output-on-failure -C Release 15 | @if ERRORLEVEL 1 exit /b %ERRORLEVEL% 16 | --------------------------------------------------------------------------------