diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6864fde8..8ed9517c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,10 @@ jobs: configuration: [ debug, release ] os: [ windows ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: ./scripts/cibuild.cmd -configuration ${{ matrix.configuration }} -architecture ${{ matrix.architecture }} shell: cmd - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }} path: | @@ -36,10 +36,10 @@ jobs: configuration: [ debug, release ] os: [ ubuntu ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: ./scripts/cibuild.sh --configuration ${{ matrix.configuration }} --architecture ${{ matrix.architecture }} shell: bash - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }} path: | @@ -56,10 +56,10 @@ jobs: configuration: [ debug, release ] os: [ macos ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: ./scripts/cibuild.sh --configuration ${{ matrix.configuration }} --architecture ${{ matrix.architecture }} shell: bash - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }} path: | @@ -71,13 +71,13 @@ jobs: build-nuget-preview: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: ./scripts/cibuild.cmd -configuration release -architecture x64 shell: cmd env: EXCLUDE_RUN_ID_FROM_PACKAGE: true EXCLUDE_SUFFIX_FROM_VERSION: false - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: nuget_preview path: | @@ -93,17 +93,17 @@ jobs: permissions: id-token: write steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nuget_preview path: ./artifacts - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: global-json-file: ./global.json - - run: dotnet tool install --tool-path ./artifacts/tools sign --version 0.9.1-beta.23530.1 + - run: dotnet tool install --tool-path ./artifacts/tools sign --version 0.9.1-beta.24170.3 - run: ./artifacts/tools/sign code azure-key-vault "**/*.nupkg" --timestamp-url "http://timestamp.digicert.com" --base-directory "${{ github.workspace }}/artifacts/pkg" --file-list "${{ github.workspace }}/scripts/SignClientFileList.txt" --publisher-name ".NET Foundation" --description "ClangSharp" --description-url "https://github.com/dotnet/clangsharp" --azure-key-vault-certificate "${{ secrets.SC_KEY_VAULT_CERTIFICATE_ID }}" --azure-key-vault-client-id "${{ secrets.SC_AZURE_CLIENT_ID }}" --azure-key-vault-client-secret "${{ secrets.SC_AZURE_CLIENT_SECRET }}" --azure-key-vault-tenant-id "${{ secrets.SC_AZURE_TENANT_ID }}" --azure-key-vault-url "${{ secrets.SC_KEY_VAULT_URL }}" - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: sign_nuget_preview path: | @@ -112,13 +112,13 @@ jobs: build-nuget-release: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: ./scripts/cibuild.cmd -configuration release -architecture x64 shell: cmd env: EXCLUDE_RUN_ID_FROM_PACKAGE: true EXCLUDE_SUFFIX_FROM_VERSION: true - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: nuget_release path: | @@ -134,17 +134,17 @@ jobs: permissions: id-token: write steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nuget_release path: ./artifacts - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: global-json-file: ./global.json - - run: dotnet tool install --tool-path ./artifacts/tools sign --version 0.9.1-beta.23530.1 + - run: dotnet tool install --tool-path ./artifacts/tools sign --version 0.9.1-beta.24170.3 - run: ./artifacts/tools/sign code azure-key-vault "**/*.nupkg" --timestamp-url "http://timestamp.digicert.com" --base-directory "${{ github.workspace }}/artifacts/pkg" --file-list "${{ github.workspace }}/scripts/SignClientFileList.txt" --publisher-name ".NET Foundation" --description "ClangSharp" --description-url "https://github.com/dotnet/clangsharp" --azure-key-vault-certificate "${{ secrets.SC_KEY_VAULT_CERTIFICATE_ID }}" --azure-key-vault-client-id "${{ secrets.SC_AZURE_CLIENT_ID }}" --azure-key-vault-client-secret "${{ secrets.SC_AZURE_CLIENT_SECRET }}" --azure-key-vault-tenant-id "${{ secrets.SC_AZURE_TENANT_ID }}" --azure-key-vault-url "${{ secrets.SC_KEY_VAULT_URL }}" - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: sign_nuget_release path: | @@ -155,13 +155,13 @@ jobs: if: ${{ github.event_name == 'push' }} needs: [ windows-x64, linux-x64, macos-x64, sign-nuget-preview, sign-nuget-release ] steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: windows_release_x64 path: ./artifacts - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' source-url: https://pkgs.clangsharp.dev/index.json env: NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_PAT }} @@ -171,11 +171,11 @@ jobs: if: false needs: [ windows-x64, linux-x64, macos-x64, sign-nuget-preview, sign-nuget-release ] steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: windows_release_x64 path: ./artifacts - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - run: dotnet nuget push "./artifacts/pkg/Release/*.nupkg" --source https://nuget.pkg.github.com/dotnet/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate diff --git a/CMakeLists.txt b/CMakeLists.txt index c6e7d2cf..047dec3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13) -project(ClangSharp VERSION 17.0.4) +project(ClangSharp VERSION 18.1.3) set(CMAKE_CXX_STANDARD 17) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) diff --git a/Directory.Build.props b/Directory.Build.props index d7ca4d54..7b102047 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,7 +20,7 @@ true - preview-all + latest-all $(BaseArtifactsPath)obj/$(BaseArtifactsPathSuffix)/ embedded false @@ -47,7 +47,7 @@ 17.0.0 ClangSharp ClangSharp - 17.0.0 + 18.1.0 rc1 pr diff --git a/Directory.Packages.props b/Directory.Packages.props index 926be196..7430ca20 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -12,12 +12,12 @@ - - - - + + + + - + diff --git a/README.md b/README.md index 2e34eb09..8d8df0c9 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A convenience package which provides the native libClang library for several pla A helper package which exposes many Clang APIs missing from libClang is provided here: https://www.nuget.org/packages/libClangSharp -**NOTE:** libclang and libClangSharp are meta-packages which point to the platform-specific runtime packages ([e.g.](https://www.nuget.org/packages/libClangSharp.runtime.win-x64/17.0.4); see others owned by [tannergooding](https://www.nuget.org/profiles/tannergooding)). Several manual steps may be required to use them, see discussion in [#46](https://github.com/dotnet/ClangSharp/issues/46) and [#118](https://github.com/dotnet/ClangSharp/issues/118). +**NOTE:** libclang and libClangSharp are meta-packages which point to the platform-specific runtime packages ([e.g.](https://www.nuget.org/packages/libClangSharp.runtime.win-x64/18.1.3); see others owned by [tannergooding](https://www.nuget.org/profiles/tannergooding)). Several manual steps may be required to use them, see discussion in [#46](https://github.com/dotnet/ClangSharp/issues/46) and [#118](https://github.com/dotnet/ClangSharp/issues/118). Nightly packages are available via the NuGet Feed URL: https://pkgs.clangsharp.dev/index.json @@ -77,7 +77,7 @@ To successfully build `libClangSharp` you must first build Clang (https://clang. The process done on Windows is roughly: ```cmd -git clone --single-branch --branch llvmorg-17.0.4 https://github.com/llvm/llvm-project +git clone --single-branch --branch llvmorg-18.1.3 https://github.com/llvm/llvm-project cd llvm-project mkdir artifacts/bin cd artifacts/bin @@ -101,7 +101,7 @@ You can then open `libClangSharp.sln` in Visual Studio, change the configuration The process done on Linux is roughly: ```bash -git clone --single-branch --branch llvmorg-17.0.4 https://github.com/llvm/llvm-project +git clone --single-branch --branch llvmorg-18.1.3 https://github.com/llvm/llvm-project cd llvm-project mkdir -p artifacts/bin cd artifacts/bin @@ -123,7 +123,7 @@ git clone https://github.com/dotnet/clangsharp cd clangsharp mkdir -p artifacts/bin/native cd artifacts/bin/native -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install -DPATH_TO_LLVM=../../../../llvm-project/artifacts/install +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install -DPATH_TO_LLVM=../../../../llvm-project/artifacts/install ../../../ make install ``` @@ -133,7 +133,7 @@ This program will take a given set of C or C++ header files and generate C# bind The simplest and recommended setup is to install the generator as a .NET tool and then use response files: ``` -dotnet tool install --global ClangSharpPInvokeGenerator --version 17.0.0 +dotnet tool install --global ClangSharpPInvokeGenerator --version 18.1.0 ClangSharpPInvokeGenerator @generate.rsp ``` diff --git a/packages/libClangSharp/libClangSharp.runtime.linux-arm64/libClangSharp.runtime.linux-arm64.nuspec b/packages/libClangSharp/libClangSharp.runtime.linux-arm64/libClangSharp.runtime.linux-arm64.nuspec index d405ce9d..3396ab28 100644 --- a/packages/libClangSharp/libClangSharp.runtime.linux-arm64/libClangSharp.runtime.linux-arm64.nuspec +++ b/packages/libClangSharp/libClangSharp.runtime.linux-arm64/libClangSharp.runtime.linux-arm64.nuspec @@ -2,7 +2,7 @@ libClangSharp.runtime.linux-arm64 - 17.0.4 + 18.1.3.1 .NET Foundation and Contributors .NET Foundation and Contributors true diff --git a/packages/libClangSharp/libClangSharp.runtime.linux-x64/libClangSharp.runtime.linux-x64.nuspec b/packages/libClangSharp/libClangSharp.runtime.linux-x64/libClangSharp.runtime.linux-x64.nuspec index 8c60a80a..4a4dff09 100644 --- a/packages/libClangSharp/libClangSharp.runtime.linux-x64/libClangSharp.runtime.linux-x64.nuspec +++ b/packages/libClangSharp/libClangSharp.runtime.linux-x64/libClangSharp.runtime.linux-x64.nuspec @@ -2,7 +2,7 @@ libClangSharp.runtime.linux-x64 - 17.0.4 + 18.1.3.1 .NET Foundation and Contributors .NET Foundation and Contributors true diff --git a/packages/libClangSharp/libClangSharp.runtime.osx-arm64/libClangSharp.runtime.osx-arm64.nuspec b/packages/libClangSharp/libClangSharp.runtime.osx-arm64/libClangSharp.runtime.osx-arm64.nuspec index 11b372f1..640f6a12 100644 --- a/packages/libClangSharp/libClangSharp.runtime.osx-arm64/libClangSharp.runtime.osx-arm64.nuspec +++ b/packages/libClangSharp/libClangSharp.runtime.osx-arm64/libClangSharp.runtime.osx-arm64.nuspec @@ -2,7 +2,7 @@ libClangSharp.runtime.osx-arm64 - 17.0.4 + 18.1.3.1 .NET Foundation and Contributors .NET Foundation and Contributors true diff --git a/packages/libClangSharp/libClangSharp.runtime.osx-x64/libClangSharp.runtime.osx-x64.nuspec b/packages/libClangSharp/libClangSharp.runtime.osx-x64/libClangSharp.runtime.osx-x64.nuspec index 73ba7da4..42f41600 100644 --- a/packages/libClangSharp/libClangSharp.runtime.osx-x64/libClangSharp.runtime.osx-x64.nuspec +++ b/packages/libClangSharp/libClangSharp.runtime.osx-x64/libClangSharp.runtime.osx-x64.nuspec @@ -2,7 +2,7 @@ libClangSharp.runtime.osx-x64 - 17.0.4 + 18.1.3.1 .NET Foundation and Contributors .NET Foundation and Contributors true diff --git a/packages/libClangSharp/libClangSharp.runtime.win-arm64/libClangSharp.runtime.win-arm64.nuspec b/packages/libClangSharp/libClangSharp.runtime.win-arm64/libClangSharp.runtime.win-arm64.nuspec index 37da8975..f3c2fda8 100644 --- a/packages/libClangSharp/libClangSharp.runtime.win-arm64/libClangSharp.runtime.win-arm64.nuspec +++ b/packages/libClangSharp/libClangSharp.runtime.win-arm64/libClangSharp.runtime.win-arm64.nuspec @@ -2,7 +2,7 @@ libClangSharp.runtime.win-arm64 - 17.0.4 + 18.1.3.1 .NET Foundation and Contributors .NET Foundation and Contributors true diff --git a/packages/libClangSharp/libClangSharp.runtime.win-x64/libClangSharp.runtime.win-x64.nuspec b/packages/libClangSharp/libClangSharp.runtime.win-x64/libClangSharp.runtime.win-x64.nuspec index b4f60fe0..728a54bd 100644 --- a/packages/libClangSharp/libClangSharp.runtime.win-x64/libClangSharp.runtime.win-x64.nuspec +++ b/packages/libClangSharp/libClangSharp.runtime.win-x64/libClangSharp.runtime.win-x64.nuspec @@ -2,7 +2,7 @@ libClangSharp.runtime.win-x64 - 17.0.4 + 18.1.3.1 .NET Foundation and Contributors .NET Foundation and Contributors true diff --git a/packages/libClangSharp/libClangSharp/libClangSharp.nuspec b/packages/libClangSharp/libClangSharp/libClangSharp.nuspec index d65ca77e..abc1c087 100644 --- a/packages/libClangSharp/libClangSharp/libClangSharp.nuspec +++ b/packages/libClangSharp/libClangSharp/libClangSharp.nuspec @@ -2,7 +2,7 @@ libClangSharp - 17.0.4 + 18.1.3.1 .NET Foundation and Contributors .NET Foundation and Contributors true diff --git a/packages/libClangSharp/libClangSharp/runtime.json b/packages/libClangSharp/libClangSharp/runtime.json index 0b13c899..0d562838 100644 --- a/packages/libClangSharp/libClangSharp/runtime.json +++ b/packages/libClangSharp/libClangSharp/runtime.json @@ -2,32 +2,32 @@ "runtimes": { "linux-arm64": { "libClangSharp": { - "libClangSharp.runtime.linux-arm64": "17.0.4" + "libClangSharp.runtime.linux-arm64": "18.1.3.1" } }, "linux-x64": { "libClangSharp": { - "libClangSharp.runtime.linux-x64": "17.0.4" + "libClangSharp.runtime.linux-x64": "18.1.3.1" } }, "osx-arm64": { "libClangSharp": { - "libClangSharp.runtime.osx-arm64": "17.0.4" + "libClangSharp.runtime.osx-arm64": "18.1.3.1" } }, "osx-x64": { "libClangSharp": { - "libClangSharp.runtime.osx-x64": "17.0.4" + "libClangSharp.runtime.osx-x64": "18.1.3.1" } }, "win-arm64": { "libClangSharp": { - "libClangSharp.runtime.win-arm64": "17.0.4" + "libClangSharp.runtime.win-arm64": "18.1.3.1" } }, "win-x64": { "libClangSharp": { - "libClangSharp.runtime.win-x64": "17.0.4" + "libClangSharp.runtime.win-x64": "18.1.3.1" } } } diff --git a/packages/libclang/libclang.runtime.linux-arm64/libclang.runtime.linux-arm64.nuspec b/packages/libclang/libclang.runtime.linux-arm64/libclang.runtime.linux-arm64.nuspec index 4040079f..503bd138 100644 --- a/packages/libclang/libclang.runtime.linux-arm64/libclang.runtime.linux-arm64.nuspec +++ b/packages/libclang/libclang.runtime.linux-arm64/libclang.runtime.linux-arm64.nuspec @@ -2,7 +2,7 @@ libclang.runtime.linux-arm64 - 17.0.4 + 18.1.3.2 .NET Foundation and Contributors .NET Foundation and Contributors true @@ -10,7 +10,7 @@ https://github.com/dotnet/clangsharp linux arm64 native library for libclang. Copyright © LLVM Project - + diff --git a/packages/libclang/libclang.runtime.linux-x64/libclang.runtime.linux-x64.nuspec b/packages/libclang/libclang.runtime.linux-x64/libclang.runtime.linux-x64.nuspec index 5d85795d..3c428c7a 100644 --- a/packages/libclang/libclang.runtime.linux-x64/libclang.runtime.linux-x64.nuspec +++ b/packages/libclang/libclang.runtime.linux-x64/libclang.runtime.linux-x64.nuspec @@ -2,7 +2,7 @@ libclang.runtime.linux-x64 - 17.0.4 + 18.1.3.2 .NET Foundation and Contributors .NET Foundation and Contributors true @@ -10,7 +10,7 @@ https://github.com/dotnet/clangsharp linux x64 native library for libclang. Copyright © LLVM Project - + diff --git a/packages/libclang/libclang.runtime.osx-arm64/libclang.runtime.osx-arm64.nuspec b/packages/libclang/libclang.runtime.osx-arm64/libclang.runtime.osx-arm64.nuspec index 17a3d37f..8baa43b3 100644 --- a/packages/libclang/libclang.runtime.osx-arm64/libclang.runtime.osx-arm64.nuspec +++ b/packages/libclang/libclang.runtime.osx-arm64/libclang.runtime.osx-arm64.nuspec @@ -2,7 +2,7 @@ libclang.runtime.osx-arm64 - 17.0.4 + 18.1.3 .NET Foundation and Contributors .NET Foundation and Contributors true @@ -10,7 +10,7 @@ https://github.com/dotnet/clangsharp osx arm64 native library for libclang. Copyright © LLVM Project - + diff --git a/packages/libclang/libclang.runtime.osx-x64/libclang.runtime.osx-x64.nuspec b/packages/libclang/libclang.runtime.osx-x64/libclang.runtime.osx-x64.nuspec index b1e3234e..79dd4e31 100644 --- a/packages/libclang/libclang.runtime.osx-x64/libclang.runtime.osx-x64.nuspec +++ b/packages/libclang/libclang.runtime.osx-x64/libclang.runtime.osx-x64.nuspec @@ -2,7 +2,7 @@ libclang.runtime.osx-x64 - 17.0.4 + 18.1.3 .NET Foundation and Contributors .NET Foundation and Contributors true @@ -10,7 +10,7 @@ https://github.com/dotnet/clangsharp osx x64 native library for libclang. Copyright © LLVM Project - + diff --git a/packages/libclang/libclang.runtime.win-arm64/libclang.runtime.win-arm64.nuspec b/packages/libclang/libclang.runtime.win-arm64/libclang.runtime.win-arm64.nuspec index ed6dcb34..2facf612 100644 --- a/packages/libclang/libclang.runtime.win-arm64/libclang.runtime.win-arm64.nuspec +++ b/packages/libclang/libclang.runtime.win-arm64/libclang.runtime.win-arm64.nuspec @@ -2,7 +2,7 @@ libclang.runtime.win-arm64 - 17.0.4 + 18.1.3.1 .NET Foundation and Contributors .NET Foundation and Contributors true @@ -10,7 +10,7 @@ https://github.com/dotnet/clangsharp win arm64 native library for libclang. Copyright © LLVM Project - + diff --git a/packages/libclang/libclang.runtime.win-x64/libclang.runtime.win-x64.nuspec b/packages/libclang/libclang.runtime.win-x64/libclang.runtime.win-x64.nuspec index ad3de842..df20a858 100644 --- a/packages/libclang/libclang.runtime.win-x64/libclang.runtime.win-x64.nuspec +++ b/packages/libclang/libclang.runtime.win-x64/libclang.runtime.win-x64.nuspec @@ -2,7 +2,7 @@ libclang.runtime.win-x64 - 17.0.4 + 18.1.3.2 .NET Foundation and Contributors .NET Foundation and Contributors true @@ -10,7 +10,7 @@ https://github.com/dotnet/clangsharp win x64 native library for libclang. Copyright © LLVM Project - + diff --git a/packages/libclang/libclang/libclang.nuspec b/packages/libclang/libclang/libclang.nuspec index 0b08e294..17113d9e 100644 --- a/packages/libclang/libclang/libclang.nuspec +++ b/packages/libclang/libclang/libclang.nuspec @@ -2,7 +2,7 @@ libclang - 17.0.4 + 18.1.3.2 .NET Foundation and Contributors .NET Foundation and Contributors true @@ -10,7 +10,7 @@ https://github.com/dotnet/clangsharp Multi-platform native library for libclang. Copyright © LLVM Project - + diff --git a/packages/libclang/libclang/runtime.json b/packages/libclang/libclang/runtime.json index 12bb4a03..6ef3f32b 100644 --- a/packages/libclang/libclang/runtime.json +++ b/packages/libclang/libclang/runtime.json @@ -2,32 +2,32 @@ "runtimes": { "linux-arm64": { "libclang": { - "libclang.runtime.linux-arm64": "17.0.4" + "libclang.runtime.linux-arm64": "18.1.3.2" } }, "linux-x64": { "libclang": { - "libclang.runtime.linux-x64": "17.0.4" + "libclang.runtime.linux-x64": "18.1.3.2" } }, "osx-arm64": { "libclang": { - "libclang.runtime.osx-arm64": "17.0.4" + "libclang.runtime.osx-arm64": "18.1.3" } }, "osx-x64": { "libclang": { - "libclang.runtime.osx-x64": "17.0.4" + "libclang.runtime.osx-x64": "18.1.3" } }, "win-arm64": { "libclang": { - "libclang.runtime.win-arm64": "17.0.4" + "libclang.runtime.win-arm64": "18.1.3.1" } }, "win-x64": { "libclang": { - "libclang.runtime.win-x64": "17.0.4" + "libclang.runtime.win-x64": "18.1.3.2" } } } diff --git a/sources/ClangSharp.Interop/ClangSharp.Interop.csproj b/sources/ClangSharp.Interop/ClangSharp.Interop.csproj index b3f47c02..0e1fe8a1 100644 --- a/sources/ClangSharp.Interop/ClangSharp.Interop.csproj +++ b/sources/ClangSharp.Interop/ClangSharp.Interop.csproj @@ -28,6 +28,10 @@ $(NoWarn);CA1003;CA1008;CA1027;CA1034;CA1041;CA1051;CA1069;CA1305;CA1508;CA1707;CA1708;CA1710;CA1711;CA1712;CA1720;CA1721;CA1724;CA1815;CA2225 + + + + diff --git a/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs b/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs index 58cd8f36..0e42e09b 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs @@ -4,16 +4,11 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXCompilationDatabase : IDisposable, IEquatable +public unsafe partial struct CXCompilationDatabase(IntPtr handle) : IDisposable, IEquatable { - public CXCompilationDatabase(IntPtr handle) - { - Handle = handle; - } - public readonly CXCompileCommands AllCompileCommands => (CXCompileCommands)clang.CompilationDatabase_getAllCompileCommands(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static explicit operator CXCompilationDatabase(void* value) => new CXCompilationDatabase((IntPtr)value); diff --git a/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs b/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs index f09932a0..a6b07301 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs @@ -4,18 +4,13 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXCompileCommand : IEquatable +public unsafe partial struct CXCompileCommand(IntPtr handle) : IEquatable { - public CXCompileCommand(IntPtr handle) - { - Handle = handle; - } - public readonly CXString Directory => clang.CompileCommand_getDirectory(this); public readonly CXString Filename => clang.CompileCommand_getFilename(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public readonly uint NumArgs => clang.CompileCommand_getNumArgs(this); diff --git a/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs b/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs index 908b96b8..b48186f2 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs @@ -4,18 +4,13 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXCompletionString : IEquatable +public unsafe partial struct CXCompletionString(IntPtr handle) : IEquatable { - public CXCompletionString(IntPtr handle) - { - Handle = handle; - } - public readonly CXAvailabilityKind Availability => clang.getCompletionAvailability(this); public readonly CXString BriefComment => clang.getCompletionBriefComment(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public readonly uint NumAnnotations => clang.getCompletionNumAnnotations(this); diff --git a/sources/ClangSharp.Interop/Extensions/CXCursor.cs b/sources/ClangSharp.Interop/Extensions/CXCursor.cs index 3c006452..11963608 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCursor.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCursor.cs @@ -37,11 +37,11 @@ public readonly string AttrKindSpelling Debug.Assert(CX_AttrKind_FirstTypeAttr == CX_AttrKind_AddressSpace); Debug.Assert(CX_AttrKind_LastTypeAttr == CX_AttrKind_WebAssemblyFuncref); - Debug.Assert(CX_AttrKind_FirstStmtAttr == CX_AttrKind_FallThrough); + Debug.Assert(CX_AttrKind_FirstStmtAttr == CX_AttrKind_CodeAlign); Debug.Assert(CX_AttrKind_LastStmtAttr == CX_AttrKind_Unlikely); Debug.Assert(CX_AttrKind_FirstDeclOrStmtAttr == CX_AttrKind_AlwaysInline); - Debug.Assert(CX_AttrKind_LastDeclOrStmtAttr == CX_AttrKind_NoMerge); + Debug.Assert(CX_AttrKind_LastDeclOrStmtAttr == CX_AttrKind_Suppress); Debug.Assert(CX_AttrKind_FirstInheritableAttr == CX_AttrKind_AlwaysInline); Debug.Assert(CX_AttrKind_LastInheritableAttr == CX_AttrKind_ZeroCallUsedRegs); @@ -62,11 +62,17 @@ public readonly string AttrKindSpelling CX_AttrKind_Invalid => "Invalid", CX_AttrKind_AddressSpace => "AddressSpace", CX_AttrKind_AnnotateType => "AnnotateType", + CX_AttrKind_ArmIn => "ArmIn", + CX_AttrKind_ArmInOut => "ArmInOut", CX_AttrKind_ArmMveStrictPolymorphism => "ArmMveStrictPolymorphism", - CX_AttrKind_ArmStreaming => "CX_AttrKind_ArmStreaming", + CX_AttrKind_ArmOut => "ArmOut", + CX_AttrKind_ArmPreserves => "ArmPreserves", + CX_AttrKind_ArmStreaming => "ArmStreaming", + CX_AttrKind_ArmStreamingCompatible => "ArmStreamingCompatible", CX_AttrKind_BTFTypeTag => "BTFTypeTag", CX_AttrKind_CmseNSCall => "CmseNSCall", CX_AttrKind_HLSLGroupSharedAddressSpace => "HLSLGroupSharedAddressSpace", + CX_AttrKind_HLSLParamModifier => "HLSLParamModifier", CX_AttrKind_NoDeref => "NoDeref", CX_AttrKind_ObjCGC => "ObjCGC", CX_AttrKind_ObjCInertUnsafeUnretained => "ObjCInertUnsafeUnretained", @@ -87,15 +93,16 @@ public readonly string AttrKindSpelling CX_AttrKind_TypeNullableResult => "TypeNullableResult", CX_AttrKind_UPtr => "UPtr", CX_AttrKind_WebAssemblyFuncref => "WebAssemblyFuncref", + CX_AttrKind_CodeAlign => "CodeAlign", CX_AttrKind_FallThrough => "FallThrough", CX_AttrKind_Likely => "Likely", CX_AttrKind_MustTail => "MustTail", CX_AttrKind_OpenCLUnrollHint => "OpenCLUnrollHint", - CX_AttrKind_Suppress => "Suppress", CX_AttrKind_Unlikely => "Unlikely", CX_AttrKind_AlwaysInline => "AlwaysInline", CX_AttrKind_NoInline => "NoInline", CX_AttrKind_NoMerge => "NoMerge", + CX_AttrKind_Suppress => "Suppress", CX_AttrKind_AArch64SVEPcs => "AArch64SVEPcs", CX_AttrKind_AArch64VectorPcs => "AArch64VectorPcs", CX_AttrKind_AMDGPUKernelCall => "AMDGPUKernelCall", @@ -105,6 +112,7 @@ public readonly string AttrKindSpelling CX_AttrKind_FastCall => "FastCall", CX_AttrKind_IntelOclBicc => "IntelOclBicc", CX_AttrKind_LifetimeBound => "LifetimeBound", + CX_AttrKind_M68kRTD => "M68kRTD", CX_AttrKind_MSABI => "MSABI", CX_AttrKind_NSReturnsRetained => "NSReturnsRetained", CX_AttrKind_ObjCOwnership => "ObjCOwnership", @@ -156,6 +164,8 @@ public readonly string AttrKindSpelling CX_AttrKind_ArcWeakrefUnavailable => "ArcWeakrefUnavailable", CX_AttrKind_ArgumentWithTypeTag => "ArgumentWithTypeTag", CX_AttrKind_ArmBuiltinAlias => "ArmBuiltinAlias", + CX_AttrKind_ArmLocallyStreaming => "ArmLocallyStreaming", + CX_AttrKind_ArmNew => "ArmNew", CX_AttrKind_Artificial => "Artificial", CX_AttrKind_AsmLabel => "AsmLabel", CX_AttrKind_AssertCapability => "AssertCapability", @@ -166,6 +176,7 @@ public readonly string AttrKindSpelling CX_AttrKind_Availability => "Availability", CX_AttrKind_AvailableOnlyInDefaultEvalMethod => "AvailableOnlyInDefaultEvalMethod", CX_AttrKind_BPFPreserveAccessIndex => "BPFPreserveAccessIndex", + CX_AttrKind_BPFPreserveStaticOffset => "BPFPreserveStaticOffset", CX_AttrKind_BTFDeclTag => "BTFDeclTag", CX_AttrKind_Blocks => "Blocks", CX_AttrKind_Builtin => "Builtin", @@ -194,6 +205,7 @@ public readonly string AttrKindSpelling CX_AttrKind_CapturedRecord => "CapturedRecord", CX_AttrKind_Cleanup => "Cleanup", CX_AttrKind_CmseNSEntry => "CmseNSEntry", + CX_AttrKind_CodeModel => "CodeModel", CX_AttrKind_CodeSeg => "CodeSeg", CX_AttrKind_Cold => "Cold", CX_AttrKind_Common => "Common", @@ -204,6 +216,12 @@ public readonly string AttrKindSpelling CX_AttrKind_ConsumableAutoCast => "ConsumableAutoCast", CX_AttrKind_ConsumableSetOnRead => "ConsumableSetOnRead", CX_AttrKind_Convergent => "Convergent", + CX_AttrKind_CoroDisableLifetimeBound => "CoroDisableLifetimeBound", + CX_AttrKind_CoroLifetimeBound => "CoroLifetimeBound", + CX_AttrKind_CoroOnlyDestroyWhenComplete => "CoroOnlyDestroyWhenComplete", + CX_AttrKind_CoroReturnType => "CoroReturnType", + CX_AttrKind_CoroWrapper => "CoroWrapper", + CX_AttrKind_CountedBy => "CountedBy", CX_AttrKind_DLLExport => "DLLExport", CX_AttrKind_DLLExportStaticLocal => "DLLExportStaticLocal", CX_AttrKind_DLLImport => "DLLImport", @@ -251,6 +269,7 @@ public readonly string AttrKindSpelling CX_AttrKind_M68kInterrupt => "M68kInterrupt", CX_AttrKind_MIGServerRoutine => "MIGServerRoutine", CX_AttrKind_MSAllocator => "MSAllocator", + CX_AttrKind_MSConstexpr => "MSConstexpr", CX_AttrKind_MSInheritance => "MSInheritance", CX_AttrKind_MSNoVTable => "MSNoVTable", CX_AttrKind_MSP430Interrupt => "MSP430Interrupt", @@ -333,6 +352,7 @@ public readonly string AttrKindSpelling CX_AttrKind_PragmaClangRodataSection => "PragmaClangRodataSection", CX_AttrKind_PragmaClangTextSection => "PragmaClangTextSection", CX_AttrKind_PreferredName => "PreferredName", + CX_AttrKind_PreferredType => "PreferredType", CX_AttrKind_PtGuardedBy => "PtGuardedBy", CX_AttrKind_PtGuardedVar => "PtGuardedVar", CX_AttrKind_Pure => "Pure", @@ -367,6 +387,8 @@ public readonly string AttrKindSpelling CX_AttrKind_SwiftBridge => "SwiftBridge", CX_AttrKind_SwiftBridgedTypedef => "SwiftBridgedTypedef", CX_AttrKind_SwiftError => "SwiftError", + CX_AttrKind_SwiftImportAsNonGeneric => "SwiftImportAsNonGeneric", + CX_AttrKind_SwiftImportPropertyAsAccessors => "SwiftImportPropertyAsAccessors", CX_AttrKind_SwiftName => "SwiftName", CX_AttrKind_SwiftNewType => "SwiftNewType", CX_AttrKind_SwiftPrivate => "SwiftPrivate", @@ -431,6 +453,8 @@ public readonly string AttrKindSpelling CX_AttrKind_Overloadable => "Overloadable", CX_AttrKind_RenderScriptKernel => "RenderScriptKernel", CX_AttrKind_SwiftObjCMembers => "SwiftObjCMembers", + CX_AttrKind_SwiftVersionedAddition => "SwiftVersionedAddition", + CX_AttrKind_SwiftVersionedRemoval => "SwiftVersionedRemoval", CX_AttrKind_Thread => "Thread", _ => Kind.ToString()[12..], }; @@ -441,7 +465,8 @@ public readonly string AttrKindSpelling public readonly CXBinaryOperatorKind BinaryOperatorKind => clangsharp.Cursor_getBinaryOpcode(this); - public readonly CXString BinaryOperatorKindSpelling => clang.getBinaryOperatorKindSpelling(BinaryOperatorKind); + public readonly CXString BinaryOperatorKindSpelling + => (BinaryOperatorKind != CXBinaryOperator_Invalid) ? clang.getBinaryOperatorKindSpelling(BinaryOperatorKind) : default; public readonly CXCursor BindingExpr => clangsharp.Cursor_getBindingExpr(this); @@ -617,20 +642,35 @@ public readonly string DeclKindSpelling { get { - Debug.Assert(CX_DeclKind_FirstBaseUsing == CX_DeclKind_Using); - Debug.Assert(CX_DeclKind_LastBaseUsing == CX_DeclKind_UsingEnum); + Debug.Assert(CX_DeclKind_FirstObjCImpl == CX_DeclKind_ObjCImplementation); + Debug.Assert(CX_DeclKind_LastObjCImpl == CX_DeclKind_ObjCCategoryImpl); + + Debug.Assert(CX_DeclKind_FirstObjCContainer == CX_DeclKind_ObjCProtocol); + Debug.Assert(CX_DeclKind_LastObjCContainer == CX_DeclKind_ObjCCategory); + + Debug.Assert(CX_DeclKind_FirstCXXMethod == CX_DeclKind_CXXMethod); + Debug.Assert(CX_DeclKind_LastCXXMethod == CX_DeclKind_CXXConstructor); + + Debug.Assert(CX_DeclKind_FirstFunction == CX_DeclKind_Function); + Debug.Assert(CX_DeclKind_LastFunction == CX_DeclKind_CXXDeductionGuide); + + Debug.Assert(CX_DeclKind_FirstVarTemplateSpecialization == CX_DeclKind_VarTemplateSpecialization); + Debug.Assert(CX_DeclKind_LastVarTemplateSpecialization == CX_DeclKind_VarTemplatePartialSpecialization); + + Debug.Assert(CX_DeclKind_FirstVar == CX_DeclKind_Var); + Debug.Assert(CX_DeclKind_LastVar == CX_DeclKind_Decomposition); - Debug.Assert(CX_DeclKind_FirstObjCImpl == CX_DeclKind_ObjCCategoryImpl); - Debug.Assert(CX_DeclKind_LastObjCImpl == CX_DeclKind_ObjCImplementation); + Debug.Assert(CX_DeclKind_FirstField == CX_DeclKind_Field); + Debug.Assert(CX_DeclKind_LastField == CX_DeclKind_ObjCAtDefsField); - Debug.Assert(CX_DeclKind_FirstObjCContainer == CX_DeclKind_ObjCCategory); - Debug.Assert(CX_DeclKind_LastObjCContainer == CX_DeclKind_ObjCProtocol); + Debug.Assert(CX_DeclKind_FirstDeclarator == CX_DeclKind_Function); + Debug.Assert(CX_DeclKind_LastDeclarator == CX_DeclKind_ObjCAtDefsField); - Debug.Assert(CX_DeclKind_FirstRedeclarableTemplate == CX_DeclKind_ClassTemplate); - Debug.Assert(CX_DeclKind_LastRedeclarableTemplate == CX_DeclKind_VarTemplate); + Debug.Assert(CX_DeclKind_FirstValue == CX_DeclKind_OMPDeclareReduction); + Debug.Assert(CX_DeclKind_LastValue == CX_DeclKind_Binding); - Debug.Assert(CX_DeclKind_FirstTemplate == CX_DeclKind_BuiltinTemplate); - Debug.Assert(CX_DeclKind_LastTemplate == CX_DeclKind_TemplateTemplateParm); + Debug.Assert(CX_DeclKind_FirstUsingShadow == CX_DeclKind_UsingShadow); + Debug.Assert(CX_DeclKind_LastUsingShadow == CX_DeclKind_ConstructorUsingShadow); Debug.Assert(CX_DeclKind_FirstClassTemplateSpecialization == CX_DeclKind_ClassTemplateSpecialization); Debug.Assert(CX_DeclKind_LastClassTemplateSpecialization == CX_DeclKind_ClassTemplatePartialSpecialization); @@ -641,134 +681,118 @@ public readonly string DeclKindSpelling Debug.Assert(CX_DeclKind_FirstRecord == CX_DeclKind_Record); Debug.Assert(CX_DeclKind_LastRecord == CX_DeclKind_ClassTemplatePartialSpecialization); - Debug.Assert(CX_DeclKind_FirstTag == CX_DeclKind_Enum); - Debug.Assert(CX_DeclKind_LastTag == CX_DeclKind_ClassTemplatePartialSpecialization); - - Debug.Assert(CX_DeclKind_FirstTypedefName == CX_DeclKind_ObjCTypeParam); - Debug.Assert(CX_DeclKind_LastTypedefName == CX_DeclKind_Typedef); + Debug.Assert(CX_DeclKind_FirstTag == CX_DeclKind_Record); + Debug.Assert(CX_DeclKind_LastTag == CX_DeclKind_Enum); - Debug.Assert(CX_DeclKind_FirstType == CX_DeclKind_Enum); - Debug.Assert(CX_DeclKind_LastType == CX_DeclKind_UnresolvedUsingTypename); + Debug.Assert(CX_DeclKind_FirstTypedefName == CX_DeclKind_Typedef); + Debug.Assert(CX_DeclKind_LastTypedefName == CX_DeclKind_ObjCTypeParam); - Debug.Assert(CX_DeclKind_FirstUsingShadow == CX_DeclKind_UsingShadow); - Debug.Assert(CX_DeclKind_LastUsingShadow == CX_DeclKind_ConstructorUsingShadow); - - Debug.Assert(CX_DeclKind_FirstField == CX_DeclKind_Field); - Debug.Assert(CX_DeclKind_LastField == CX_DeclKind_ObjCIvar); - - Debug.Assert(CX_DeclKind_FirstCXXMethod == CX_DeclKind_CXXMethod); - Debug.Assert(CX_DeclKind_LastCXXMethod == CX_DeclKind_CXXDestructor); - - Debug.Assert(CX_DeclKind_FirstFunction == CX_DeclKind_Function); - Debug.Assert(CX_DeclKind_LastFunction == CX_DeclKind_CXXDestructor); + Debug.Assert(CX_DeclKind_FirstType == CX_DeclKind_Record); + Debug.Assert(CX_DeclKind_LastType == CX_DeclKind_TemplateTypeParm); - Debug.Assert(CX_DeclKind_FirstVarTemplateSpecialization == CX_DeclKind_VarTemplateSpecialization); - Debug.Assert(CX_DeclKind_LastVarTemplateSpecialization == CX_DeclKind_VarTemplatePartialSpecialization); - - Debug.Assert(CX_DeclKind_FirstVar == CX_DeclKind_Var); - Debug.Assert(CX_DeclKind_LastVar == CX_DeclKind_VarTemplatePartialSpecialization); + Debug.Assert(CX_DeclKind_FirstRedeclarableTemplate == CX_DeclKind_VarTemplate); + Debug.Assert(CX_DeclKind_LastRedeclarableTemplate == CX_DeclKind_ClassTemplate); - Debug.Assert(CX_DeclKind_FirstDeclarator == CX_DeclKind_Field); - Debug.Assert(CX_DeclKind_LastDeclarator == CX_DeclKind_VarTemplatePartialSpecialization); + Debug.Assert(CX_DeclKind_FirstTemplate == CX_DeclKind_TemplateTemplateParm); + Debug.Assert(CX_DeclKind_LastTemplate == CX_DeclKind_BuiltinTemplate); - Debug.Assert(CX_DeclKind_FirstValue == CX_DeclKind_Binding); - Debug.Assert(CX_DeclKind_LastValue == CX_DeclKind_UnresolvedUsingValue); + Debug.Assert(CX_DeclKind_FirstBaseUsing == CX_DeclKind_UsingEnum); + Debug.Assert(CX_DeclKind_LastBaseUsing == CX_DeclKind_Using); - Debug.Assert(CX_DeclKind_FirstNamed == CX_DeclKind_Using); - Debug.Assert(CX_DeclKind_LastNamed == CX_DeclKind_UnresolvedUsingValue); + Debug.Assert(CX_DeclKind_FirstNamed == CX_DeclKind_ObjCMethod); + Debug.Assert(CX_DeclKind_LastNamed == CX_DeclKind_Using); - Debug.Assert(CX_DeclKind_FirstDecl == CX_DeclKind_AccessSpec); - Debug.Assert(CX_DeclKind_LastDecl == CX_DeclKind_TranslationUnit); + Debug.Assert(CX_DeclKind_FirstDecl == CX_DeclKind_TranslationUnit); + Debug.Assert(CX_DeclKind_LastDecl == CX_DeclKind_AccessSpec); return DeclKind switch { CX_DeclKind_Invalid => "Invalid", - CX_DeclKind_AccessSpec => "AccessSpec", - CX_DeclKind_Block => "Block", - CX_DeclKind_Captured => "Captured", - CX_DeclKind_ClassScopeFunctionSpecialization => "ClassScopeFunctionSpecialization", - CX_DeclKind_Empty => "Empty", - CX_DeclKind_Export => "Export", - CX_DeclKind_ExternCContext => "ExternCContext", - CX_DeclKind_FileScopeAsm => "FileScopeAsm", - CX_DeclKind_Friend => "Friend", - CX_DeclKind_FriendTemplate => "FriendTemplate", - CX_DeclKind_ImplicitConceptSpecialization => "ImplicitConceptSpecialization", - CX_DeclKind_Import => "Import", - CX_DeclKind_LifetimeExtendedTemporary => "LifetimeExtendedTemporary", + CX_DeclKind_TranslationUnit => "TranslationUnit", + CX_DeclKind_RequiresExprBody => "RequiresExprBody", CX_DeclKind_LinkageSpec => "LinkageSpec", - CX_DeclKind_Using => "Using", - CX_DeclKind_UsingEnum => "UsingEnum", - CX_DeclKind_Label => "Label", - CX_DeclKind_HLSLBuffer => "HLSLBuffer", - CX_DeclKind_Namespace => "Namespace", - CX_DeclKind_NamespaceAlias => "NamespaceAlias", - CX_DeclKind_ObjCCompatibleAlias => "ObjCCompatibleAlias", - CX_DeclKind_ObjCCategory => "ObjCCategory", - CX_DeclKind_ObjCCategoryImpl => "ObjCCategoryImpl", - CX_DeclKind_ObjCImplementation => "ObjCImplementation", - CX_DeclKind_ObjCInterface => "ObjCInterface", - CX_DeclKind_ObjCProtocol => "ObjCProtocol", + CX_DeclKind_ExternCContext => "ExternCContext", + CX_DeclKind_Export => "Export", + CX_DeclKind_Captured => "Captured", + CX_DeclKind_Block => "Block", + CX_DeclKind_TopLevelStmt => "TopLevelStmt", + CX_DeclKind_StaticAssert => "StaticAssert", + CX_DeclKind_PragmaDetectMismatch => "PragmaDetectMismatch", + CX_DeclKind_PragmaComment => "PragmaComment", + CX_DeclKind_ObjCPropertyImpl => "ObjCPropertyImpl", + CX_DeclKind_OMPThreadPrivate => "OMPThreadPrivate", + CX_DeclKind_OMPRequires => "OMPRequires", + CX_DeclKind_OMPAllocate => "OMPAllocate", CX_DeclKind_ObjCMethod => "ObjCMethod", - CX_DeclKind_ObjCProperty => "ObjCProperty", - CX_DeclKind_BuiltinTemplate => "BuiltinTemplate", - CX_DeclKind_Concept => "Concept", - CX_DeclKind_ClassTemplate => "ClassTemplate", - CX_DeclKind_FunctionTemplate => "FunctionTemplate", - CX_DeclKind_TypeAliasTemplate => "TypeAliasTemplate", - CX_DeclKind_VarTemplate => "VarTemplate", - CX_DeclKind_TemplateTemplateParm => "TemplateTemplateParm", - CX_DeclKind_Enum => "Enum", - CX_DeclKind_Record => "Record", - CX_DeclKind_CXXRecord => "CXXRecord", - CX_DeclKind_ClassTemplateSpecialization => "ClassTemplateSpecialization", - CX_DeclKind_ClassTemplatePartialSpecialization => "ClassTemplatePartialSpecialization", - CX_DeclKind_TemplateTypeParm => "TemplateTypeParm", - CX_DeclKind_ObjCTypeParam => "ObjCTypeParam", - CX_DeclKind_TypeAlias => "TypeAlias", - CX_DeclKind_Typedef => "Typedef", - CX_DeclKind_UnresolvedUsingTypename => "UnresolvedUsingTypename", - CX_DeclKind_UnresolvedUsingIfExists => "UnresolvedUsingIfExists", - CX_DeclKind_UsingDirective => "UsingDirective", - CX_DeclKind_UsingPack => "UsingPack", - CX_DeclKind_UsingShadow => "UsingShadow", - CX_DeclKind_ConstructorUsingShadow => "ConstructorUsingShadow", - CX_DeclKind_Binding => "Binding", - CX_DeclKind_Field => "Field", - CX_DeclKind_ObjCAtDefsField => "ObjCAtDefsField", - CX_DeclKind_ObjCIvar => "ObjCIvar", + CX_DeclKind_ObjCProtocol => "ObjCProtocol", + CX_DeclKind_ObjCInterface => "ObjCInterface", + CX_DeclKind_ObjCImplementation => "ObjCImplementation", + CX_DeclKind_ObjCCategoryImpl => "ObjCCategoryImpl", + CX_DeclKind_ObjCCategory => "ObjCCategory", + CX_DeclKind_Namespace => "Namespace", + CX_DeclKind_HLSLBuffer => "HLSLBuffer", + CX_DeclKind_OMPDeclareReduction => "OMPDeclareReduction", + CX_DeclKind_OMPDeclareMapper => "OMPDeclareMapper", + CX_DeclKind_UnresolvedUsingValue => "UnresolvedUsingValue", + CX_DeclKind_UnnamedGlobalConstant => "UnnamedGlobalConstant", + CX_DeclKind_TemplateParamObject => "TemplateParamObject", + CX_DeclKind_MSGuid => "MSGuid", + CX_DeclKind_IndirectField => "IndirectField", + CX_DeclKind_EnumConstant => "EnumConstant", CX_DeclKind_Function => "Function", - CX_DeclKind_CXXDeductionGuide => "CXXDeductionGuide", CX_DeclKind_CXXMethod => "CXXMethod", - CX_DeclKind_CXXConstructor => "CXXConstructor", - CX_DeclKind_CXXConversion => "CXXConversion", CX_DeclKind_CXXDestructor => "CXXDestructor", - CX_DeclKind_MSProperty => "MSProperty", - CX_DeclKind_NonTypeTemplateParm => "NonTypeTemplateParm", + CX_DeclKind_CXXConversion => "CXXConversion", + CX_DeclKind_CXXConstructor => "CXXConstructor", + CX_DeclKind_CXXDeductionGuide => "CXXDeductionGuide", CX_DeclKind_Var => "Var", - CX_DeclKind_Decomposition => "Decomposition", - CX_DeclKind_ImplicitParam => "ImplicitParam", - CX_DeclKind_OMPCapturedExpr => "OMPCapturedExpr", - CX_DeclKind_ParmVar => "ParmVar", CX_DeclKind_VarTemplateSpecialization => "VarTemplateSpecialization", CX_DeclKind_VarTemplatePartialSpecialization => "VarTemplatePartialSpecialization", - CX_DeclKind_EnumConstant => "EnumConstant", - CX_DeclKind_IndirectField => "IndirectField", - CX_DeclKind_MSGuid => "MSGuid", - CX_DeclKind_OMPDeclareMapper => "OMPDeclareMapper", - CX_DeclKind_OMPDeclareReduction => "OMPDeclareReduction", - CX_DeclKind_TemplateParamObject => "TemplateParamObject", - CX_DeclKind_UnnamedGlobalConstant => "UnnamedGlobalConstant", - CX_DeclKind_UnresolvedUsingValue => "UnresolvedUsingValue", - CX_DeclKind_OMPAllocate => "OMPAllocate", - CX_DeclKind_OMPRequires => "OMPRequires", - CX_DeclKind_OMPThreadPrivate => "OMPThreadPrivate", - CX_DeclKind_ObjCPropertyImpl => "ObjCPropertyImpl", - CX_DeclKind_PragmaComment => "PragmaComment", - CX_DeclKind_PragmaDetectMismatch => "PragmaDetectMismatch", - CX_DeclKind_RequiresExprBody => "RequiresExprBody", - CX_DeclKind_StaticAssert => "StaticAssert", - CX_DeclKind_TopLevelStmt => "TopLevelStmt", - CX_DeclKind_TranslationUnit => "TranslationUnit", + CX_DeclKind_ParmVar => "ParmVar", + CX_DeclKind_OMPCapturedExpr => "OMPCapturedExpr", + CX_DeclKind_ImplicitParam => "ImplicitParam", + CX_DeclKind_Decomposition => "Decomposition", + CX_DeclKind_NonTypeTemplateParm => "NonTypeTemplateParm", + CX_DeclKind_MSProperty => "MSProperty", + CX_DeclKind_Field => "Field", + CX_DeclKind_ObjCIvar => "ObjCIvar", + CX_DeclKind_ObjCAtDefsField => "ObjCAtDefsField", + CX_DeclKind_Binding => "Binding", + CX_DeclKind_UsingShadow => "UsingShadow", + CX_DeclKind_ConstructorUsingShadow => "ConstructorUsingShadow", + CX_DeclKind_UsingPack => "UsingPack", + CX_DeclKind_UsingDirective => "UsingDirective", + CX_DeclKind_UnresolvedUsingIfExists => "UnresolvedUsingIfExists", + CX_DeclKind_Record => "Record", + CX_DeclKind_CXXRecord => "CXXRecord", + CX_DeclKind_ClassTemplateSpecialization => "ClassTemplateSpecialization", + CX_DeclKind_ClassTemplatePartialSpecialization => "ClassTemplatePartialSpecialization", + CX_DeclKind_Enum => "Enum", + CX_DeclKind_UnresolvedUsingTypename => "UnresolvedUsingTypename", + CX_DeclKind_Typedef => "Typedef", + CX_DeclKind_TypeAlias => "TypeAlias", + CX_DeclKind_ObjCTypeParam => "ObjCTypeParam", + CX_DeclKind_TemplateTypeParm => "TemplateTypeParm", + CX_DeclKind_TemplateTemplateParm => "TemplateTemplateParm", + CX_DeclKind_VarTemplate => "VarTemplate", + CX_DeclKind_TypeAliasTemplate => "TypeAliasTemplate", + CX_DeclKind_FunctionTemplate => "FunctionTemplate", + CX_DeclKind_ClassTemplate => "ClassTemplate", + CX_DeclKind_Concept => "Concept", + CX_DeclKind_BuiltinTemplate => "BuiltinTemplate", + CX_DeclKind_ObjCProperty => "ObjCProperty", + CX_DeclKind_ObjCCompatibleAlias => "ObjCCompatibleAlias", + CX_DeclKind_NamespaceAlias => "NamespaceAlias", + CX_DeclKind_Label => "Label", + CX_DeclKind_UsingEnum => "UsingEnum", + CX_DeclKind_Using => "Using", + CX_DeclKind_LifetimeExtendedTemporary => "LifetimeExtendedTemporary", + CX_DeclKind_Import => "Import", + CX_DeclKind_ImplicitConceptSpecialization => "ImplicitConceptSpecialization", + CX_DeclKind_FriendTemplate => "FriendTemplate", + CX_DeclKind_Friend => "Friend", + CX_DeclKind_FileScopeAsm => "FileScopeAsm", + CX_DeclKind_Empty => "Empty", + CX_DeclKind_AccessSpec => "AccessSpec", _ => Kind.ToString()[12..], }; } @@ -778,7 +802,20 @@ public readonly string DeclKindSpelling public readonly CXCursor DecomposedDecl => clangsharp.Cursor_getDecomposedDecl(this); - public readonly CXCursor DefaultArg => clangsharp.Cursor_getDefaultArg(this); + public readonly CXCursor DefaultArg + { + get + { + if (DeclKind == CX_DeclKind_ParmVar) + { + if (HasUnparsedDefaultArg || HasUninstantiatedDefaultArg) + { + return CXCursor.Null; + } + } + return clangsharp.Cursor_getDefaultArg(this); + } + } public readonly CXType DefaultArgType => clangsharp.Cursor_getDefaultArgType(this); @@ -864,6 +901,10 @@ public readonly string DeclKindSpelling public readonly bool HasTemplateKeyword => clangsharp.Cursor_getHasTemplateKeyword(this) != 0; + public readonly bool HasUninstantiatedDefaultArg => clangsharp.Cursor_getHasUninstantiatedDefaultArg(this) != 0; + + public readonly bool HasUnparsedDefaultArg => clangsharp.Cursor_getHasUnparsedDefaultArg(this) != 0; + public readonly bool HasUserDeclaredConstructor => clangsharp.Cursor_getHasUserDeclaredConstructor(this) != 0; public readonly bool HasUserDeclaredCopyAssignment => clangsharp.Cursor_getHasUserDeclaredCopyAssignment(this) != 0; @@ -1024,7 +1065,7 @@ public readonly string DeclKindSpelling public readonly bool IsPreprocessing => clang.isPreprocessing(Kind) != 0; - public readonly bool IsPure => clangsharp.Cursor_getIsPure(this) != 0; + public readonly bool IsPureVirtual => clangsharp.Cursor_getIsPureVirtual(this) != 0; public readonly bool IsReference => clang.isReference(Kind) != 0; @@ -1238,298 +1279,299 @@ public readonly string StmtClassSpelling { get { - Debug.Assert(CX_StmtClass_FirstAsmStmt == CX_StmtClass_GCCAsmStmt); - Debug.Assert(CX_StmtClass_LastAsmStmt == CX_StmtClass_MSAsmStmt); - - Debug.Assert(CX_StmtClass_FirstOMPLoopDirective == CX_StmtClass_OMPDistributeDirective); - Debug.Assert(CX_StmtClass_LastOMPLoopDirective == CX_StmtClass_OMPTeamsGenericLoopDirective); + Debug.Assert(CX_StmtClass_FirstOverloadExpr == CX_StmtClass_UnresolvedMemberExpr); + Debug.Assert(CX_StmtClass_LastOverloadExpr == CX_StmtClass_UnresolvedLookupExpr); - Debug.Assert(CX_StmtClass_FirstOMPLoopTransformationDirective == CX_StmtClass_OMPTileDirective); - Debug.Assert(CX_StmtClass_LastOMPLoopTransformationDirective == CX_StmtClass_OMPUnrollDirective); + Debug.Assert(CX_StmtClass_FirstFullExpr == CX_StmtClass_ExprWithCleanups); + Debug.Assert(CX_StmtClass_LastFullExpr == CX_StmtClass_ConstantExpr); - Debug.Assert(CX_StmtClass_FirstOMPLoopBasedDirective == CX_StmtClass_OMPDistributeDirective); - Debug.Assert(CX_StmtClass_LastOMPLoopBasedDirective == CX_StmtClass_OMPUnrollDirective); + Debug.Assert(CX_StmtClass_FirstCoroutineSuspendExpr == CX_StmtClass_CoyieldExpr); + Debug.Assert(CX_StmtClass_LastCoroutineSuspendExpr == CX_StmtClass_CoawaitExpr); - Debug.Assert(CX_StmtClass_FirstOMPExecutableDirective == CX_StmtClass_OMPAtomicDirective); - Debug.Assert(CX_StmtClass_LastOMPExecutableDirective == CX_StmtClass_OMPTeamsDirective); + Debug.Assert(CX_StmtClass_FirstCXXNamedCastExpr == CX_StmtClass_CXXStaticCastExpr); + Debug.Assert(CX_StmtClass_LastCXXNamedCastExpr == CX_StmtClass_CXXAddrspaceCastExpr); - Debug.Assert(CX_StmtClass_FirstSwitchCase == CX_StmtClass_CaseStmt); - Debug.Assert(CX_StmtClass_LastSwitchCase == CX_StmtClass_DefaultStmt); + Debug.Assert(CX_StmtClass_FirstExplicitCastExpr == CX_StmtClass_ObjCBridgedCastExpr); + Debug.Assert(CX_StmtClass_LastExplicitCastExpr == CX_StmtClass_BuiltinBitCastExpr); - Debug.Assert(CX_StmtClass_FirstAbstractConditionalOperator == CX_StmtClass_BinaryConditionalOperator); - Debug.Assert(CX_StmtClass_LastAbstractConditionalOperator == CX_StmtClass_ConditionalOperator); + Debug.Assert(CX_StmtClass_FirstCastExpr == CX_StmtClass_ImplicitCastExpr); + Debug.Assert(CX_StmtClass_LastCastExpr == CX_StmtClass_BuiltinBitCastExpr); - Debug.Assert(CX_StmtClass_FirstBinaryOperator == CX_StmtClass_BinaryOperator); - Debug.Assert(CX_StmtClass_LastBinaryOperator == CX_StmtClass_CompoundAssignOperator); + Debug.Assert(CX_StmtClass_FirstCallExpr == CX_StmtClass_CallExpr); + Debug.Assert(CX_StmtClass_LastCallExpr == CX_StmtClass_CUDAKernelCallExpr); Debug.Assert(CX_StmtClass_FirstCXXConstructExpr == CX_StmtClass_CXXConstructExpr); Debug.Assert(CX_StmtClass_LastCXXConstructExpr == CX_StmtClass_CXXTemporaryObjectExpr); - Debug.Assert(CX_StmtClass_FirstCallExpr == CX_StmtClass_CallExpr); - Debug.Assert(CX_StmtClass_LastCallExpr == CX_StmtClass_UserDefinedLiteral); + Debug.Assert(CX_StmtClass_FirstBinaryOperator == CX_StmtClass_BinaryOperator); + Debug.Assert(CX_StmtClass_LastBinaryOperator == CX_StmtClass_CompoundAssignOperator); - Debug.Assert(CX_StmtClass_FirstCXXNamedCastExpr == CX_StmtClass_CXXAddrspaceCastExpr); - Debug.Assert(CX_StmtClass_LastCXXNamedCastExpr == CX_StmtClass_CXXStaticCastExpr); + Debug.Assert(CX_StmtClass_FirstAbstractConditionalOperator == CX_StmtClass_ConditionalOperator); + Debug.Assert(CX_StmtClass_LastAbstractConditionalOperator == CX_StmtClass_BinaryConditionalOperator); - Debug.Assert(CX_StmtClass_FirstExplicitCastExpr == CX_StmtClass_BuiltinBitCastExpr); - Debug.Assert(CX_StmtClass_LastExplicitCastExpr == CX_StmtClass_ObjCBridgedCastExpr); + Debug.Assert(CX_StmtClass_FirstExpr == CX_StmtClass_VAArgExpr); + Debug.Assert(CX_StmtClass_LastExpr == CX_StmtClass_BinaryConditionalOperator); - Debug.Assert(CX_StmtClass_FirstCastExpr == CX_StmtClass_BuiltinBitCastExpr); - Debug.Assert(CX_StmtClass_LastCastExpr == CX_StmtClass_ImplicitCastExpr); + Debug.Assert(CX_StmtClass_FirstValueStmt == CX_StmtClass_LabelStmt); + Debug.Assert(CX_StmtClass_LastValueStmt == CX_StmtClass_AttributedStmt); - Debug.Assert(CX_StmtClass_FirstCoroutineSuspendExpr == CX_StmtClass_CoawaitExpr); - Debug.Assert(CX_StmtClass_LastCoroutineSuspendExpr == CX_StmtClass_CoyieldExpr); + Debug.Assert(CX_StmtClass_FirstSwitchCase == CX_StmtClass_DefaultStmt); + Debug.Assert(CX_StmtClass_LastSwitchCase == CX_StmtClass_CaseStmt); - Debug.Assert(CX_StmtClass_FirstFullExpr == CX_StmtClass_ConstantExpr); - Debug.Assert(CX_StmtClass_LastFullExpr == CX_StmtClass_ExprWithCleanups); + Debug.Assert(CX_StmtClass_FirstOMPLoopTransformationDirective == CX_StmtClass_OMPUnrollDirective); + Debug.Assert(CX_StmtClass_LastOMPLoopTransformationDirective == CX_StmtClass_OMPTileDirective); - Debug.Assert(CX_StmtClass_FirstOverloadExpr == CX_StmtClass_UnresolvedLookupExpr); - Debug.Assert(CX_StmtClass_LastOverloadExpr == CX_StmtClass_UnresolvedMemberExpr); + Debug.Assert(CX_StmtClass_FirstOMPLoopDirective == CX_StmtClass_OMPTeamsGenericLoopDirective); + Debug.Assert(CX_StmtClass_LastOMPLoopDirective == CX_StmtClass_OMPDistributeDirective); - Debug.Assert(CX_StmtClass_FirstExpr == CX_StmtClass_BinaryConditionalOperator); - Debug.Assert(CX_StmtClass_LastExpr == CX_StmtClass_VAArgExpr); + Debug.Assert(CX_StmtClass_FirstOMPLoopBasedDirective == CX_StmtClass_OMPUnrollDirective); + Debug.Assert(CX_StmtClass_LastOMPLoopBasedDirective == CX_StmtClass_OMPDistributeDirective); - Debug.Assert(CX_StmtClass_FirstValueStmt == CX_StmtClass_AttributedStmt); - Debug.Assert(CX_StmtClass_LastValueStmt == CX_StmtClass_LabelStmt); + Debug.Assert(CX_StmtClass_FirstOMPExecutableDirective == CX_StmtClass_OMPTeamsDirective); + Debug.Assert(CX_StmtClass_LastOMPExecutableDirective == CX_StmtClass_OMPAtomicDirective); - Debug.Assert(CX_StmtClass_FirstStmt == CX_StmtClass_GCCAsmStmt); - Debug.Assert(CX_StmtClass_LastStmt == CX_StmtClass_WhileStmt); + Debug.Assert(CX_StmtClass_FirstAsmStmt == CX_StmtClass_MSAsmStmt); + Debug.Assert(CX_StmtClass_LastAsmStmt == CX_StmtClass_GCCAsmStmt); + + Debug.Assert(CX_StmtClass_FirstStmt == CX_StmtClass_WhileStmt); + Debug.Assert(CX_StmtClass_LastStmt == CX_StmtClass_GCCAsmStmt); return StmtClass switch { CX_StmtClass_Invalid => "Invalid", - CX_StmtClass_GCCAsmStmt => "GCCAsmStmt", - CX_StmtClass_MSAsmStmt => "MSAsmStmt", - CX_StmtClass_BreakStmt => "BreakStmt", - CX_StmtClass_CXXCatchStmt => "CXXCatchStmt", - CX_StmtClass_CXXForRangeStmt => "CXXForRangeStmt", - CX_StmtClass_CXXTryStmt => "CXXTryStmt", - CX_StmtClass_CapturedStmt => "CapturedStmt", - CX_StmtClass_CompoundStmt => "CompoundStmt", - CX_StmtClass_ContinueStmt => "ContinueStmt", - CX_StmtClass_CoreturnStmt => "CoreturnStmt", - CX_StmtClass_CoroutineBodyStmt => "CoroutineBodyStmt", - CX_StmtClass_DeclStmt => "DeclStmt", - CX_StmtClass_DoStmt => "DoStmt", - CX_StmtClass_ForStmt => "ForStmt", - CX_StmtClass_GotoStmt => "GotoStmt", - CX_StmtClass_IfStmt => "IfStmt", - CX_StmtClass_IndirectGotoStmt => "IndirectGotoStmt", - CX_StmtClass_MSDependentExistsStmt => "MSDependentExistsStmt", - CX_StmtClass_NullStmt => "NullStmt", - CX_StmtClass_OMPCanonicalLoop => "OMPCanonicalLoop", - CX_StmtClass_OMPAtomicDirective => "OMPAtomicDirective", - CX_StmtClass_OMPBarrierDirective => "OMPBarrierDirective", - CX_StmtClass_OMPCancelDirective => "OMPCancelDirective", - CX_StmtClass_OMPCancellationPointDirective => "OMPCancellationPointDirective", - CX_StmtClass_OMPCriticalDirective => "OMPCriticalDirective", - CX_StmtClass_OMPDepobjDirective => "OMPDepobjDirective", - CX_StmtClass_OMPDispatchDirective => "OMPDispatchDirective", - CX_StmtClass_OMPErrorDirective => "OMPErrorDirective", - CX_StmtClass_OMPFlushDirective => "OMPFlushDirective", - CX_StmtClass_OMPInteropDirective => "OMPInteropDirective", - CX_StmtClass_OMPDistributeDirective => "OMPDistributeDirective", - CX_StmtClass_OMPDistributeParallelForDirective => "OMPDistributeParallelForDirective", - CX_StmtClass_OMPDistributeParallelForSimdDirective => "OMPDistributeParallelForSimdDirective", - CX_StmtClass_OMPDistributeSimdDirective => "OMPDistributeSimdDirective", - CX_StmtClass_OMPForDirective => "OMPForDirective", - CX_StmtClass_OMPForSimdDirective => "OMPForSimdDirective", - CX_StmtClass_OMPGenericLoopDirective => "OMPGenericLoopDirective", - CX_StmtClass_OMPMaskedTaskLoopDirective => "OMPMaskedTaskLoopDirective", - CX_StmtClass_OMPMaskedTaskLoopSimdDirective => "OMPMaskedTaskLoopSimdDirective", - CX_StmtClass_OMPMasterTaskLoopDirective => "OMPMasterTaskLoopDirective", - CX_StmtClass_OMPMasterTaskLoopSimdDirective => "OMPMasterTaskLoopSimdDirective", - CX_StmtClass_OMPParallelForDirective => "OMPParallelForDirective", - CX_StmtClass_OMPParallelForSimdDirective => "OMPParallelForSimdDirective", - CX_StmtClass_OMPParallelGenericLoopDirective => "OMPParallelGenericLoopDirective", - CX_StmtClass_OMPParallelMaskedTaskLoopDirective => "OMPParallelMaskedTaskLoopDirective", - CX_StmtClass_OMPParallelMaskedTaskLoopSimdDirective => "OMPParallelMaskedTaskLoopSimdDirective", - CX_StmtClass_OMPParallelMasterTaskLoopDirective => "OMPParallelMasterTaskLoopDirective", - CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective => "OMPParallelMasterTaskLoopSimdDirective", - CX_StmtClass_OMPSimdDirective => "OMPSimdDirective", - CX_StmtClass_OMPTargetParallelForSimdDirective => "OMPTargetParallelForSimdDirective", - CX_StmtClass_OMPTargetParallelGenericLoopDirective => "OMPTargetParallelGenericLoopDirective", - CX_StmtClass_OMPTargetSimdDirective => "OMPTargetSimdDirective", - CX_StmtClass_OMPTargetTeamsDistributeDirective => "OMPTargetTeamsDistributeDirective", - CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective => "OMPTargetTeamsDistributeParallelForDirective", - CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective => "OMPTargetTeamsDistributeParallelForSimdDirective", - CX_StmtClass_OMPTargetTeamsDistributeSimdDirective => "OMPTargetTeamsDistributeSimdDirective", - CX_StmtClass_OMPTargetTeamsGenericLoopDirective => "OMPTargetTeamsGenericLoopDirective", - CX_StmtClass_OMPTaskLoopDirective => "OMPTaskLoopDirective", - CX_StmtClass_OMPTaskLoopSimdDirective => "OMPTaskLoopSimdDirective", - CX_StmtClass_OMPTeamsDistributeDirective => "OMPTeamsDistributeDirective", - CX_StmtClass_OMPTeamsDistributeParallelForDirective => "OMPTeamsDistributeParallelForDirective", - CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective => "OMPTeamsDistributeParallelForSimdDirective", - CX_StmtClass_OMPTeamsDistributeSimdDirective => "OMPTeamsDistributeSimdDirective", - CX_StmtClass_OMPTeamsGenericLoopDirective => "OMPTeamsGenericLoopDirective", - CX_StmtClass_OMPTileDirective => "OMPTileDirective", - CX_StmtClass_OMPUnrollDirective => "OMPUnrollDirective", - CX_StmtClass_OMPMaskedDirective => "OMPMaskedDirective", - CX_StmtClass_OMPMasterDirective => "OMPMasterDirective", - CX_StmtClass_OMPMetaDirective => "OMPMetaDirective", - CX_StmtClass_OMPOrderedDirective => "OMPOrderedDirective", - CX_StmtClass_OMPParallelDirective => "OMPParallelDirective", - CX_StmtClass_OMPParallelMaskedDirective => "OMPParallelMaskedDirective", - CX_StmtClass_OMPParallelMasterDirective => "OMPParallelMasterDirective", - CX_StmtClass_OMPParallelSectionsDirective => "OMPParallelSectionsDirective", - CX_StmtClass_OMPScanDirective => "OMPScanDirective", - CX_StmtClass_OMPSectionDirective => "OMPSectionDirective", - CX_StmtClass_OMPSectionsDirective => "OMPSectionsDirective", - CX_StmtClass_OMPSingleDirective => "OMPSingleDirective", - CX_StmtClass_OMPTargetDataDirective => "OMPTargetDataDirective", - CX_StmtClass_OMPTargetDirective => "OMPTargetDirective", - CX_StmtClass_OMPTargetEnterDataDirective => "OMPTargetEnterDataDirective", - CX_StmtClass_OMPTargetExitDataDirective => "OMPTargetExitDataDirective", - CX_StmtClass_OMPTargetParallelDirective => "OMPTargetParallelDirective", - CX_StmtClass_OMPTargetParallelForDirective => "OMPTargetParallelForDirective", - CX_StmtClass_OMPTargetTeamsDirective => "OMPTargetTeamsDirective", - CX_StmtClass_OMPTargetUpdateDirective => "OMPTargetUpdateDirective", - CX_StmtClass_OMPTaskDirective => "OMPTaskDirective", - CX_StmtClass_OMPTaskgroupDirective => "OMPTaskgroupDirective", - CX_StmtClass_OMPTaskwaitDirective => "OMPTaskwaitDirective", - CX_StmtClass_OMPTaskyieldDirective => "OMPTaskyieldDirective", - CX_StmtClass_OMPTeamsDirective => "OMPTeamsDirective", - CX_StmtClass_ObjCAtCatchStmt => "ObjCAtCatchStmt", - CX_StmtClass_ObjCAtFinallyStmt => "ObjCAtFinallyStmt", - CX_StmtClass_ObjCAtSynchronizedStmt => "ObjCAtSynchronizedStmt", - CX_StmtClass_ObjCAtThrowStmt => "ObjCAtThrowStmt", - CX_StmtClass_ObjCAtTryStmt => "ObjCAtTryStmt", - CX_StmtClass_ObjCAutoreleasePoolStmt => "ObjCAutoreleasePoolStmt", - CX_StmtClass_ObjCForCollectionStmt => "ObjCForCollectionStmt", - CX_StmtClass_ReturnStmt => "ReturnStmt", - CX_StmtClass_SEHExceptStmt => "SEHExceptStmt", - CX_StmtClass_SEHFinallyStmt => "SEHFinallyStmt", - CX_StmtClass_SEHLeaveStmt => "SEHLeaveStmt", - CX_StmtClass_SEHTryStmt => "SEHTryStmt", - CX_StmtClass_CaseStmt => "CaseStmt", - CX_StmtClass_DefaultStmt => "DefaultStmt", - CX_StmtClass_SwitchStmt => "SwitchStmt", - CX_StmtClass_AttributedStmt => "AttributedStmt", - CX_StmtClass_BinaryConditionalOperator => "BinaryConditionalOperator", - CX_StmtClass_ConditionalOperator => "ConditionalOperator", - CX_StmtClass_AddrLabelExpr => "AddrLabelExpr", - CX_StmtClass_ArrayInitIndexExpr => "ArrayInitIndexExpr", - CX_StmtClass_ArrayInitLoopExpr => "ArrayInitLoopExpr", - CX_StmtClass_ArraySubscriptExpr => "ArraySubscriptExpr", - CX_StmtClass_ArrayTypeTraitExpr => "ArrayTypeTraitExpr", - CX_StmtClass_AsTypeExpr => "AsTypeExpr", - CX_StmtClass_AtomicExpr => "AtomicExpr", - CX_StmtClass_BinaryOperator => "BinaryOperator", - CX_StmtClass_CompoundAssignOperator => "CompoundAssignOperator", - CX_StmtClass_BlockExpr => "BlockExpr", - CX_StmtClass_CXXBindTemporaryExpr => "CXXBindTemporaryExpr", - CX_StmtClass_CXXBoolLiteralExpr => "CXXBoolLiteralExpr", - CX_StmtClass_CXXConstructExpr => "CXXConstructExpr", - CX_StmtClass_CXXTemporaryObjectExpr => "CXXTemporaryObjectExpr", - CX_StmtClass_CXXDefaultArgExpr => "CXXDefaultArgExpr", - CX_StmtClass_CXXDefaultInitExpr => "CXXDefaultInitExpr", - CX_StmtClass_CXXDeleteExpr => "CXXDeleteExpr", - CX_StmtClass_CXXDependentScopeMemberExpr => "CXXDependentScopeMemberExpr", - CX_StmtClass_CXXFoldExpr => "CXXFoldExpr", - CX_StmtClass_CXXInheritedCtorInitExpr => "CXXInheritedCtorInitExpr", - CX_StmtClass_CXXNewExpr => "CXXNewExpr", - CX_StmtClass_CXXNoexceptExpr => "CXXNoexceptExpr", - CX_StmtClass_CXXNullPtrLiteralExpr => "CXXNullPtrLiteralExpr", - CX_StmtClass_CXXParenListInitExpr => "CXXParenListInitExpr", - CX_StmtClass_CXXPseudoDestructorExpr => "CXXPseudoDestructorExpr", - CX_StmtClass_CXXRewrittenBinaryOperator => "CXXRewrittenBinaryOperator", - CX_StmtClass_CXXScalarValueInitExpr => "CXXScalarValueInitExpr", - CX_StmtClass_CXXStdInitializerListExpr => "CXXStdInitializerListExpr", - CX_StmtClass_CXXThisExpr => "CXXThisExpr", - CX_StmtClass_CXXThrowExpr => "CXXThrowExpr", - CX_StmtClass_CXXTypeidExpr => "CXXTypeidExpr", - CX_StmtClass_CXXUnresolvedConstructExpr => "CXXUnresolvedConstructExpr", - CX_StmtClass_CXXUuidofExpr => "CXXUuidofExpr", + CX_StmtClass_WhileStmt => "WhileStmt", + CX_StmtClass_LabelStmt => "LabelStmt", + CX_StmtClass_VAArgExpr => "VAArgExpr", + CX_StmtClass_UnaryOperator => "UnaryOperator", + CX_StmtClass_UnaryExprOrTypeTraitExpr => "UnaryExprOrTypeTraitExpr", + CX_StmtClass_TypoExpr => "TypoExpr", + CX_StmtClass_TypeTraitExpr => "TypeTraitExpr", + CX_StmtClass_SubstNonTypeTemplateParmPackExpr => "SubstNonTypeTemplateParmPackExpr", + CX_StmtClass_SubstNonTypeTemplateParmExpr => "SubstNonTypeTemplateParmExpr", + CX_StmtClass_StringLiteral => "StringLiteral", + CX_StmtClass_StmtExpr => "StmtExpr", + CX_StmtClass_SourceLocExpr => "SourceLocExpr", + CX_StmtClass_SizeOfPackExpr => "SizeOfPackExpr", + CX_StmtClass_ShuffleVectorExpr => "ShuffleVectorExpr", + CX_StmtClass_SYCLUniqueStableNameExpr => "SYCLUniqueStableNameExpr", + CX_StmtClass_RequiresExpr => "RequiresExpr", + CX_StmtClass_RecoveryExpr => "RecoveryExpr", + CX_StmtClass_PseudoObjectExpr => "PseudoObjectExpr", + CX_StmtClass_PredefinedExpr => "PredefinedExpr", + CX_StmtClass_ParenListExpr => "ParenListExpr", + CX_StmtClass_ParenExpr => "ParenExpr", + CX_StmtClass_PackExpansionExpr => "PackExpansionExpr", + CX_StmtClass_UnresolvedMemberExpr => "UnresolvedMemberExpr", + CX_StmtClass_UnresolvedLookupExpr => "UnresolvedLookupExpr", + CX_StmtClass_OpaqueValueExpr => "OpaqueValueExpr", + CX_StmtClass_OffsetOfExpr => "OffsetOfExpr", + CX_StmtClass_ObjCSubscriptRefExpr => "ObjCSubscriptRefExpr", + CX_StmtClass_ObjCStringLiteral => "ObjCStringLiteral", + CX_StmtClass_ObjCSelectorExpr => "ObjCSelectorExpr", + CX_StmtClass_ObjCProtocolExpr => "ObjCProtocolExpr", + CX_StmtClass_ObjCPropertyRefExpr => "ObjCPropertyRefExpr", + CX_StmtClass_ObjCMessageExpr => "ObjCMessageExpr", + CX_StmtClass_ObjCIvarRefExpr => "ObjCIvarRefExpr", + CX_StmtClass_ObjCIsaExpr => "ObjCIsaExpr", + CX_StmtClass_ObjCIndirectCopyRestoreExpr => "ObjCIndirectCopyRestoreExpr", + CX_StmtClass_ObjCEncodeExpr => "ObjCEncodeExpr", + CX_StmtClass_ObjCDictionaryLiteral => "ObjCDictionaryLiteral", + CX_StmtClass_ObjCBoxedExpr => "ObjCBoxedExpr", + CX_StmtClass_ObjCBoolLiteralExpr => "ObjCBoolLiteralExpr", + CX_StmtClass_ObjCAvailabilityCheckExpr => "ObjCAvailabilityCheckExpr", + CX_StmtClass_ObjCArrayLiteral => "ObjCArrayLiteral", + CX_StmtClass_OMPIteratorExpr => "OMPIteratorExpr", + CX_StmtClass_OMPArrayShapingExpr => "OMPArrayShapingExpr", + CX_StmtClass_OMPArraySectionExpr => "OMPArraySectionExpr", + CX_StmtClass_NoInitExpr => "NoInitExpr", + CX_StmtClass_MemberExpr => "MemberExpr", + CX_StmtClass_MatrixSubscriptExpr => "MatrixSubscriptExpr", + CX_StmtClass_MaterializeTemporaryExpr => "MaterializeTemporaryExpr", + CX_StmtClass_MSPropertySubscriptExpr => "MSPropertySubscriptExpr", + CX_StmtClass_MSPropertyRefExpr => "MSPropertyRefExpr", + CX_StmtClass_LambdaExpr => "LambdaExpr", + CX_StmtClass_IntegerLiteral => "IntegerLiteral", + CX_StmtClass_InitListExpr => "InitListExpr", + CX_StmtClass_ImplicitValueInitExpr => "ImplicitValueInitExpr", + CX_StmtClass_ImaginaryLiteral => "ImaginaryLiteral", + CX_StmtClass_GenericSelectionExpr => "GenericSelectionExpr", + CX_StmtClass_GNUNullExpr => "GNUNullExpr", + CX_StmtClass_FunctionParmPackExpr => "FunctionParmPackExpr", + CX_StmtClass_ExprWithCleanups => "ExprWithCleanups", + CX_StmtClass_ConstantExpr => "ConstantExpr", + CX_StmtClass_FloatingLiteral => "FloatingLiteral", + CX_StmtClass_FixedPointLiteral => "FixedPointLiteral", + CX_StmtClass_ExtVectorElementExpr => "ExtVectorElementExpr", + CX_StmtClass_ExpressionTraitExpr => "ExpressionTraitExpr", + CX_StmtClass_DesignatedInitUpdateExpr => "DesignatedInitUpdateExpr", + CX_StmtClass_DesignatedInitExpr => "DesignatedInitExpr", + CX_StmtClass_DependentScopeDeclRefExpr => "DependentScopeDeclRefExpr", + CX_StmtClass_DependentCoawaitExpr => "DependentCoawaitExpr", + CX_StmtClass_DeclRefExpr => "DeclRefExpr", + CX_StmtClass_CoyieldExpr => "CoyieldExpr", + CX_StmtClass_CoawaitExpr => "CoawaitExpr", + CX_StmtClass_ConvertVectorExpr => "ConvertVectorExpr", + CX_StmtClass_ConceptSpecializationExpr => "ConceptSpecializationExpr", + CX_StmtClass_CompoundLiteralExpr => "CompoundLiteralExpr", + CX_StmtClass_ChooseExpr => "ChooseExpr", + CX_StmtClass_CharacterLiteral => "CharacterLiteral", + CX_StmtClass_ImplicitCastExpr => "ImplicitCastExpr", + CX_StmtClass_ObjCBridgedCastExpr => "ObjCBridgedCastExpr", + CX_StmtClass_CXXStaticCastExpr => "CXXStaticCastExpr", + CX_StmtClass_CXXReinterpretCastExpr => "CXXReinterpretCastExpr", + CX_StmtClass_CXXDynamicCastExpr => "CXXDynamicCastExpr", + CX_StmtClass_CXXConstCastExpr => "CXXConstCastExpr", + CX_StmtClass_CXXAddrspaceCastExpr => "CXXAddrspaceCastExpr", + CX_StmtClass_CXXFunctionalCastExpr => "CXXFunctionalCastExpr", + CX_StmtClass_CStyleCastExpr => "CStyleCastExpr", + CX_StmtClass_BuiltinBitCastExpr => "BuiltinBitCastExpr", CX_StmtClass_CallExpr => "CallExpr", - CX_StmtClass_CUDAKernelCallExpr => "CUDAKernelCallExpr", - CX_StmtClass_CXXMemberCallExpr => "CXXMemberCallExpr", - CX_StmtClass_CXXOperatorCallExpr => "CXXOperatorCallExpr", CX_StmtClass_UserDefinedLiteral => "UserDefinedLiteral", - CX_StmtClass_BuiltinBitCastExpr => "BuiltinBitCastExpr", - CX_StmtClass_CStyleCastExpr => "CStyleCastExpr", - CX_StmtClass_CXXFunctionalCastExpr => "CXXFunctionalCastExpr", - CX_StmtClass_CXXAddrspaceCastExpr => "CXXAddrspaceCastExpr", - CX_StmtClass_CXXConstCastExpr => "CXXConstCastExpr", - CX_StmtClass_CXXDynamicCastExpr => "CXXDynamicCastExpr", - CX_StmtClass_CXXReinterpretCastExpr => "CXXReinterpretCastExpr", - CX_StmtClass_CXXStaticCastExpr => "CXXStaticCastExpr", - CX_StmtClass_ObjCBridgedCastExpr => "ObjCBridgedCastExpr", - CX_StmtClass_ImplicitCastExpr => "ImplicitCastExpr", - CX_StmtClass_CharacterLiteral => "CharacterLiteral", - CX_StmtClass_ChooseExpr => "ChooseExpr", - CX_StmtClass_CompoundLiteralExpr => "CompoundLiteralExpr", - CX_StmtClass_ConceptSpecializationExpr => "ConceptSpecializationExpr", - CX_StmtClass_ConvertVectorExpr => "ConvertVectorExpr", - CX_StmtClass_CoawaitExpr => "CoawaitExpr", - CX_StmtClass_CoyieldExpr => "CoyieldExpr", - CX_StmtClass_DeclRefExpr => "DeclRefExpr", - CX_StmtClass_DependentCoawaitExpr => "DependentCoawaitExpr", - CX_StmtClass_DependentScopeDeclRefExpr => "DependentScopeDeclRefExpr", - CX_StmtClass_DesignatedInitExpr => "DesignatedInitExpr", - CX_StmtClass_DesignatedInitUpdateExpr => "DesignatedInitUpdateExpr", - CX_StmtClass_ExpressionTraitExpr => "ExpressionTraitExpr", - CX_StmtClass_ExtVectorElementExpr => "ExtVectorElementExpr", - CX_StmtClass_FixedPointLiteral => "FixedPointLiteral", - CX_StmtClass_FloatingLiteral => "FloatingLiteral", - CX_StmtClass_ConstantExpr => "ConstantExpr", - CX_StmtClass_ExprWithCleanups => "ExprWithCleanups", - CX_StmtClass_FunctionParmPackExpr => "FunctionParmPackExpr", - CX_StmtClass_GNUNullExpr => "GNUNullExpr", - CX_StmtClass_GenericSelectionExpr => "GenericSelectionExpr", - CX_StmtClass_ImaginaryLiteral => "ImaginaryLiteral", - CX_StmtClass_ImplicitValueInitExpr => "ImplicitValueInitExpr", - CX_StmtClass_InitListExpr => "InitListExpr", - CX_StmtClass_IntegerLiteral => "IntegerLiteral", - CX_StmtClass_LambdaExpr => "LambdaExpr", - CX_StmtClass_MSPropertyRefExpr => "MSPropertyRefExpr", - CX_StmtClass_MSPropertySubscriptExpr => "MSPropertySubscriptExpr", - CX_StmtClass_MaterializeTemporaryExpr => "MaterializeTemporaryExpr", - CX_StmtClass_MatrixSubscriptExpr => "MatrixSubscriptExpr", - CX_StmtClass_MemberExpr => "MemberExpr", - CX_StmtClass_NoInitExpr => "NoInitExpr", - CX_StmtClass_OMPArraySectionExpr => "OMPArraySectionExpr", - CX_StmtClass_OMPArrayShapingExpr => "OMPArrayShapingExpr", - CX_StmtClass_OMPIteratorExpr => "OMPIteratorExpr", - CX_StmtClass_ObjCArrayLiteral => "ObjCArrayLiteral", - CX_StmtClass_ObjCAvailabilityCheckExpr => "ObjCAvailabilityCheckExpr", - CX_StmtClass_ObjCBoolLiteralExpr => "ObjCBoolLiteralExpr", - CX_StmtClass_ObjCBoxedExpr => "ObjCBoxedExpr", - CX_StmtClass_ObjCDictionaryLiteral => "ObjCDictionaryLiteral", - CX_StmtClass_ObjCEncodeExpr => "ObjCEncodeExpr", - CX_StmtClass_ObjCIndirectCopyRestoreExpr => "ObjCIndirectCopyRestoreExpr", - CX_StmtClass_ObjCIsaExpr => "ObjCIsaExpr", - CX_StmtClass_ObjCIvarRefExpr => "ObjCIvarRefExpr", - CX_StmtClass_ObjCMessageExpr => "ObjCMessageExpr", - CX_StmtClass_ObjCPropertyRefExpr => "ObjCPropertyRefExpr", - CX_StmtClass_ObjCProtocolExpr => "ObjCProtocolExpr", - CX_StmtClass_ObjCSelectorExpr => "ObjCSelectorExpr", - CX_StmtClass_ObjCStringLiteral => "ObjCStringLiteral", - CX_StmtClass_ObjCSubscriptRefExpr => "ObjCSubscriptRefExpr", - CX_StmtClass_OffsetOfExpr => "OffsetOfExpr", - CX_StmtClass_OpaqueValueExpr => "OpaqueValueExpr", - CX_StmtClass_UnresolvedLookupExpr => "UnresolvedLookupExpr", - CX_StmtClass_UnresolvedMemberExpr => "UnresolvedMemberExpr", - CX_StmtClass_PackExpansionExpr => "PackExpansionExpr", - CX_StmtClass_ParenExpr => "ParenExpr", - CX_StmtClass_ParenListExpr => "ParenListExpr", - CX_StmtClass_PredefinedExpr => "PredefinedExpr", - CX_StmtClass_PseudoObjectExpr => "PseudoObjectExpr", - CX_StmtClass_RecoveryExpr => "RecoveryExpr", - CX_StmtClass_RequiresExpr => "RequiresExpr", - CX_StmtClass_SYCLUniqueStableNameExpr => "SYCLUniqueStableNameExpr", - CX_StmtClass_ShuffleVectorExpr => "ShuffleVectorExpr", - CX_StmtClass_SizeOfPackExpr => "SizeOfPackExpr", - CX_StmtClass_SourceLocExpr => "SourceLocExpr", - CX_StmtClass_StmtExpr => "StmtExpr", - CX_StmtClass_StringLiteral => "StringLiteral", - CX_StmtClass_SubstNonTypeTemplateParmExpr => "SubstNonTypeTemplateParmExpr", - CX_StmtClass_SubstNonTypeTemplateParmPackExpr => "SubstNonTypeTemplateParmPackExpr", - CX_StmtClass_TypeTraitExpr => "TypeTraitExpr", - CX_StmtClass_TypoExpr => "TypoExpr", - CX_StmtClass_UnaryExprOrTypeTraitExpr => "UnaryExprOrTypeTraitExpr", - CX_StmtClass_UnaryOperator => "UnaryOperator", - CX_StmtClass_VAArgExpr => "VAArgExpr", - CX_StmtClass_LabelStmt => "LabelStmt", - CX_StmtClass_WhileStmt => "WhileStmt", + CX_StmtClass_CXXOperatorCallExpr => "CXXOperatorCallExpr", + CX_StmtClass_CXXMemberCallExpr => "CXXMemberCallExpr", + CX_StmtClass_CUDAKernelCallExpr => "CUDAKernelCallExpr", + CX_StmtClass_CXXUuidofExpr => "CXXUuidofExpr", + CX_StmtClass_CXXUnresolvedConstructExpr => "CXXUnresolvedConstructExpr", + CX_StmtClass_CXXTypeidExpr => "CXXTypeidExpr", + CX_StmtClass_CXXThrowExpr => "CXXThrowExpr", + CX_StmtClass_CXXThisExpr => "CXXThisExpr", + CX_StmtClass_CXXStdInitializerListExpr => "CXXStdInitializerListExpr", + CX_StmtClass_CXXScalarValueInitExpr => "CXXScalarValueInitExpr", + CX_StmtClass_CXXRewrittenBinaryOperator => "CXXRewrittenBinaryOperator", + CX_StmtClass_CXXPseudoDestructorExpr => "CXXPseudoDestructorExpr", + CX_StmtClass_CXXParenListInitExpr => "CXXParenListInitExpr", + CX_StmtClass_CXXNullPtrLiteralExpr => "CXXNullPtrLiteralExpr", + CX_StmtClass_CXXNoexceptExpr => "CXXNoexceptExpr", + CX_StmtClass_CXXNewExpr => "CXXNewExpr", + CX_StmtClass_CXXInheritedCtorInitExpr => "CXXInheritedCtorInitExpr", + CX_StmtClass_CXXFoldExpr => "CXXFoldExpr", + CX_StmtClass_CXXDependentScopeMemberExpr => "CXXDependentScopeMemberExpr", + CX_StmtClass_CXXDeleteExpr => "CXXDeleteExpr", + CX_StmtClass_CXXDefaultInitExpr => "CXXDefaultInitExpr", + CX_StmtClass_CXXDefaultArgExpr => "CXXDefaultArgExpr", + CX_StmtClass_CXXConstructExpr => "CXXConstructExpr", + CX_StmtClass_CXXTemporaryObjectExpr => "CXXTemporaryObjectExpr", + CX_StmtClass_CXXBoolLiteralExpr => "CXXBoolLiteralExpr", + CX_StmtClass_CXXBindTemporaryExpr => "CXXBindTemporaryExpr", + CX_StmtClass_BlockExpr => "BlockExpr", + CX_StmtClass_BinaryOperator => "BinaryOperator", + CX_StmtClass_CompoundAssignOperator => "CompoundAssignOperator", + CX_StmtClass_AtomicExpr => "AtomicExpr", + CX_StmtClass_AsTypeExpr => "AsTypeExpr", + CX_StmtClass_ArrayTypeTraitExpr => "ArrayTypeTraitExpr", + CX_StmtClass_ArraySubscriptExpr => "ArraySubscriptExpr", + CX_StmtClass_ArrayInitLoopExpr => "ArrayInitLoopExpr", + CX_StmtClass_ArrayInitIndexExpr => "ArrayInitIndexExpr", + CX_StmtClass_AddrLabelExpr => "AddrLabelExpr", + CX_StmtClass_ConditionalOperator => "ConditionalOperator", + CX_StmtClass_BinaryConditionalOperator => "BinaryConditionalOperator", + CX_StmtClass_AttributedStmt => "AttributedStmt", + CX_StmtClass_SwitchStmt => "SwitchStmt", + CX_StmtClass_DefaultStmt => "DefaultStmt", + CX_StmtClass_CaseStmt => "CaseStmt", + CX_StmtClass_SEHTryStmt => "SEHTryStmt", + CX_StmtClass_SEHLeaveStmt => "SEHLeaveStmt", + CX_StmtClass_SEHFinallyStmt => "SEHFinallyStmt", + CX_StmtClass_SEHExceptStmt => "SEHExceptStmt", + CX_StmtClass_ReturnStmt => "ReturnStmt", + CX_StmtClass_ObjCForCollectionStmt => "ObjCForCollectionStmt", + CX_StmtClass_ObjCAutoreleasePoolStmt => "ObjCAutoreleasePoolStmt", + CX_StmtClass_ObjCAtTryStmt => "ObjCAtTryStmt", + CX_StmtClass_ObjCAtThrowStmt => "ObjCAtThrowStmt", + CX_StmtClass_ObjCAtSynchronizedStmt => "ObjCAtSynchronizedStmt", + CX_StmtClass_ObjCAtFinallyStmt => "ObjCAtFinallyStmt", + CX_StmtClass_ObjCAtCatchStmt => "ObjCAtCatchStmt", + CX_StmtClass_OMPTeamsDirective => "OMPTeamsDirective", + CX_StmtClass_OMPTaskyieldDirective => "OMPTaskyieldDirective", + CX_StmtClass_OMPTaskwaitDirective => "OMPTaskwaitDirective", + CX_StmtClass_OMPTaskgroupDirective => "OMPTaskgroupDirective", + CX_StmtClass_OMPTaskDirective => "OMPTaskDirective", + CX_StmtClass_OMPTargetUpdateDirective => "OMPTargetUpdateDirective", + CX_StmtClass_OMPTargetTeamsDirective => "OMPTargetTeamsDirective", + CX_StmtClass_OMPTargetParallelForDirective => "OMPTargetParallelForDirective", + CX_StmtClass_OMPTargetParallelDirective => "OMPTargetParallelDirective", + CX_StmtClass_OMPTargetExitDataDirective => "OMPTargetExitDataDirective", + CX_StmtClass_OMPTargetEnterDataDirective => "OMPTargetEnterDataDirective", + CX_StmtClass_OMPTargetDirective => "OMPTargetDirective", + CX_StmtClass_OMPTargetDataDirective => "OMPTargetDataDirective", + CX_StmtClass_OMPSingleDirective => "OMPSingleDirective", + CX_StmtClass_OMPSectionsDirective => "OMPSectionsDirective", + CX_StmtClass_OMPSectionDirective => "OMPSectionDirective", + CX_StmtClass_OMPScopeDirective => "OMPScopeDirective", + CX_StmtClass_OMPScanDirective => "OMPScanDirective", + CX_StmtClass_OMPParallelSectionsDirective => "OMPParallelSectionsDirective", + CX_StmtClass_OMPParallelMasterDirective => "OMPParallelMasterDirective", + CX_StmtClass_OMPParallelMaskedDirective => "OMPParallelMaskedDirective", + CX_StmtClass_OMPParallelDirective => "OMPParallelDirective", + CX_StmtClass_OMPOrderedDirective => "OMPOrderedDirective", + CX_StmtClass_OMPMetaDirective => "OMPMetaDirective", + CX_StmtClass_OMPMasterDirective => "OMPMasterDirective", + CX_StmtClass_OMPMaskedDirective => "OMPMaskedDirective", + CX_StmtClass_OMPUnrollDirective => "OMPUnrollDirective", + CX_StmtClass_OMPTileDirective => "OMPTileDirective", + CX_StmtClass_OMPTeamsGenericLoopDirective => "OMPTeamsGenericLoopDirective", + CX_StmtClass_OMPTeamsDistributeSimdDirective => "OMPTeamsDistributeSimdDirective", + CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective => "OMPTeamsDistributeParallelForSimdDirective", + CX_StmtClass_OMPTeamsDistributeParallelForDirective => "OMPTeamsDistributeParallelForDirective", + CX_StmtClass_OMPTeamsDistributeDirective => "OMPTeamsDistributeDirective", + CX_StmtClass_OMPTaskLoopSimdDirective => "OMPTaskLoopSimdDirective", + CX_StmtClass_OMPTaskLoopDirective => "OMPTaskLoopDirective", + CX_StmtClass_OMPTargetTeamsGenericLoopDirective => "OMPTargetTeamsGenericLoopDirective", + CX_StmtClass_OMPTargetTeamsDistributeSimdDirective => "OMPTargetTeamsDistributeSimdDirective", + CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective => "OMPTargetTeamsDistributeParallelForSimdDirective", + CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective => "OMPTargetTeamsDistributeParallelForDirective", + CX_StmtClass_OMPTargetTeamsDistributeDirective => "OMPTargetTeamsDistributeDirective", + CX_StmtClass_OMPTargetSimdDirective => "OMPTargetSimdDirective", + CX_StmtClass_OMPTargetParallelGenericLoopDirective => "OMPTargetParallelGenericLoopDirective", + CX_StmtClass_OMPTargetParallelForSimdDirective => "OMPTargetParallelForSimdDirective", + CX_StmtClass_OMPSimdDirective => "OMPSimdDirective", + CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective => "OMPParallelMasterTaskLoopSimdDirective", + CX_StmtClass_OMPParallelMasterTaskLoopDirective => "OMPParallelMasterTaskLoopDirective", + CX_StmtClass_OMPParallelMaskedTaskLoopSimdDirective => "OMPParallelMaskedTaskLoopSimdDirective", + CX_StmtClass_OMPParallelMaskedTaskLoopDirective => "OMPParallelMaskedTaskLoopDirective", + CX_StmtClass_OMPParallelGenericLoopDirective => "OMPParallelGenericLoopDirective", + CX_StmtClass_OMPParallelForSimdDirective => "OMPParallelForSimdDirective", + CX_StmtClass_OMPParallelForDirective => "OMPParallelForDirective", + CX_StmtClass_OMPMasterTaskLoopSimdDirective => "OMPMasterTaskLoopSimdDirective", + CX_StmtClass_OMPMasterTaskLoopDirective => "OMPMasterTaskLoopDirective", + CX_StmtClass_OMPMaskedTaskLoopSimdDirective => "OMPMaskedTaskLoopSimdDirective", + CX_StmtClass_OMPMaskedTaskLoopDirective => "OMPMaskedTaskLoopDirective", + CX_StmtClass_OMPGenericLoopDirective => "OMPGenericLoopDirective", + CX_StmtClass_OMPForSimdDirective => "OMPForSimdDirective", + CX_StmtClass_OMPForDirective => "OMPForDirective", + CX_StmtClass_OMPDistributeSimdDirective => "OMPDistributeSimdDirective", + CX_StmtClass_OMPDistributeParallelForSimdDirective => "OMPDistributeParallelForSimdDirective", + CX_StmtClass_OMPDistributeParallelForDirective => "OMPDistributeParallelForDirective", + CX_StmtClass_OMPDistributeDirective => "OMPDistributeDirective", + CX_StmtClass_OMPInteropDirective => "OMPInteropDirective", + CX_StmtClass_OMPFlushDirective => "OMPFlushDirective", + CX_StmtClass_OMPErrorDirective => "OMPErrorDirective", + CX_StmtClass_OMPDispatchDirective => "OMPDispatchDirective", + CX_StmtClass_OMPDepobjDirective => "OMPDepobjDirective", + CX_StmtClass_OMPCriticalDirective => "OMPCriticalDirective", + CX_StmtClass_OMPCancellationPointDirective => "OMPCancellationPointDirective", + CX_StmtClass_OMPCancelDirective => "OMPCancelDirective", + CX_StmtClass_OMPBarrierDirective => "OMPBarrierDirective", + CX_StmtClass_OMPAtomicDirective => "OMPAtomicDirective", + CX_StmtClass_OMPCanonicalLoop => "OMPCanonicalLoop", + CX_StmtClass_NullStmt => "NullStmt", + CX_StmtClass_MSDependentExistsStmt => "MSDependentExistsStmt", + CX_StmtClass_IndirectGotoStmt => "IndirectGotoStmt", + CX_StmtClass_IfStmt => "IfStmt", + CX_StmtClass_GotoStmt => "GotoStmt", + CX_StmtClass_ForStmt => "ForStmt", + CX_StmtClass_DoStmt => "DoStmt", + CX_StmtClass_DeclStmt => "DeclStmt", + CX_StmtClass_CoroutineBodyStmt => "CoroutineBodyStmt", + CX_StmtClass_CoreturnStmt => "CoreturnStmt", + CX_StmtClass_ContinueStmt => "ContinueStmt", + CX_StmtClass_CompoundStmt => "CompoundStmt", + CX_StmtClass_CapturedStmt => "CapturedStmt", + CX_StmtClass_CXXTryStmt => "CXXTryStmt", + CX_StmtClass_CXXForRangeStmt => "CXXForRangeStmt", + CX_StmtClass_CXXCatchStmt => "CXXCatchStmt", + CX_StmtClass_BreakStmt => "BreakStmt", + CX_StmtClass_MSAsmStmt => "MSAsmStmt", + CX_StmtClass_GCCAsmStmt => "GCCAsmStmt", _ => StmtClass.ToString()[13..], }; } @@ -1537,6 +1579,8 @@ public readonly string StmtClassSpelling public readonly CX_StorageClass StorageClass => clang.Cursor_getStorageClass(this); + public readonly CX_StringKind StringLiteralKind => clangsharp.Cursor_getStringLiteralKind(this); + public readonly CXString StringLiteralValue => clangsharp.Cursor_getStringLiteralValue(this); public readonly CXCursor SubExpr => clangsharp.Cursor_getSubExpr(this); @@ -1583,7 +1627,8 @@ public readonly string StmtClassSpelling public readonly CXUnaryOperatorKind UnaryOperatorKind => clang.getCursorUnaryOperatorKind(this); - public readonly CXString UnaryOperatorKindSpelling => clang.getUnaryOperatorKindSpelling(UnaryOperatorKind); + public readonly CXString UnaryOperatorKindSpelling + => (UnaryOperatorKind != CXUnaryOperator_Invalid) ? clang.getUnaryOperatorKindSpelling(UnaryOperatorKind) : default; public readonly CXCursor UnderlyingDecl => clangsharp.Cursor_getUnderlyingDecl(this); diff --git a/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs b/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs index 1de69061..53e82685 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXCursorSet : IDisposable, IEquatable +public unsafe partial struct CXCursorSet(IntPtr handle) : IDisposable, IEquatable { - public CXCursorSet(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static implicit operator CXCursorSet(CXCursorSetImpl* value) => new CXCursorSet((IntPtr)value); diff --git a/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs b/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs index 5d7b0775..af8fa80d 100644 --- a/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs +++ b/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs @@ -6,7 +6,7 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXDiagnosticSet : IDisposable, IEquatable, IReadOnlyCollection +public unsafe partial struct CXDiagnosticSet(IntPtr handle) : IDisposable, IEquatable, IReadOnlyCollection { public static CXDiagnosticSet Load(string file, out CXLoadDiag_Error error, out CXString errorString) { @@ -19,16 +19,11 @@ public static CXDiagnosticSet Load(string file, out CXLoadDiag_Error error, out } } - public CXDiagnosticSet(IntPtr handle) - { - Handle = handle; - } - public readonly CXDiagnostic this[uint index] => GetDiagnostic(index); public readonly int Count => (int)NumDiagnostics; - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public readonly uint NumDiagnostics => clang.getNumDiagnosticsInSet(this); diff --git a/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs b/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs index 3660c27b..f8b00a4e 100644 --- a/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs +++ b/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs @@ -5,13 +5,8 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXEvalResult : IDisposable, IEquatable +public unsafe partial struct CXEvalResult(IntPtr handle) : IDisposable, IEquatable { - public CXEvalResult(IntPtr handle) - { - Handle = handle; - } - public readonly double AsDouble => (Kind == CXEval_Float) ? clang.EvalResult_getAsDouble(this) : 0; public readonly int AsInt => (Kind == CXEval_Int) ? clang.EvalResult_getAsInt(this) : 0; @@ -35,7 +30,7 @@ public readonly string AsStr public readonly ulong AsUnsigned => (Kind == CXEval_Int) ? clang.EvalResult_getAsUnsigned(this) : 0; - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public readonly bool IsUnsignedInt => (Kind == CXEval_Int) && (clang.EvalResult_isUnsignedInt(this) != 0); diff --git a/sources/ClangSharp.Interop/Extensions/CXFile.cs b/sources/ClangSharp.Interop/Extensions/CXFile.cs index 2a829da2..a3c717d3 100644 --- a/sources/ClangSharp.Interop/Extensions/CXFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXFile.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXFile : IEquatable +public unsafe partial struct CXFile(IntPtr handle) : IEquatable { - public CXFile(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public readonly CXString Name => clang.getFileName(this); diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs index b951af6e..92bf090e 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXIdxClientASTFile : IEquatable +public unsafe partial struct CXIdxClientASTFile(IntPtr handle) : IEquatable { - public CXIdxClientASTFile(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static explicit operator CXIdxClientASTFile(void* value) => new CXIdxClientASTFile((IntPtr)value); diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs index 65a95e5c..53cfe4c6 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXIdxClientContainer : IEquatable +public unsafe partial struct CXIdxClientContainer(IntPtr handle) : IEquatable { - public CXIdxClientContainer(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static explicit operator CXIdxClientContainer(void* value) => new CXIdxClientContainer((IntPtr)value); diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs index 8073dd9e..cf43ee56 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXIdxClientEntity : IEquatable +public unsafe partial struct CXIdxClientEntity(IntPtr handle) : IEquatable { - public CXIdxClientEntity(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static explicit operator CXIdxClientEntity(void* value) => new CXIdxClientEntity((IntPtr)value); diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs index c9be23c0..c2af5b8b 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXIdxClientFile : IEquatable +public unsafe partial struct CXIdxClientFile(IntPtr handle) : IEquatable { - public CXIdxClientFile(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static explicit operator CXIdxClientFile(void* value) => new CXIdxClientFile((IntPtr)value); diff --git a/sources/ClangSharp.Interop/Extensions/CXIndex.cs b/sources/ClangSharp.Interop/Extensions/CXIndex.cs index 249ea679..c5ee7991 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIndex.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIndex.cs @@ -4,13 +4,8 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXIndex : IDisposable, IEquatable +public unsafe partial struct CXIndex(IntPtr handle) : IDisposable, IEquatable { - public CXIndex(IntPtr handle) - { - Handle = handle; - } - public readonly CXGlobalOptFlags GlobalOptions { get @@ -24,7 +19,7 @@ public readonly CXGlobalOptFlags GlobalOptions } } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static explicit operator CXIndex(void* value) => new CXIndex((IntPtr)value); diff --git a/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs b/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs index 7f24dc25..ea598ee9 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXIndexAction : IDisposable, IEquatable +public unsafe partial struct CXIndexAction(IntPtr handle) : IDisposable, IEquatable { - public CXIndexAction(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static explicit operator CXIndexAction(void* value) => new CXIndexAction((IntPtr)value); diff --git a/sources/ClangSharp.Interop/Extensions/CXModule.cs b/sources/ClangSharp.Interop/Extensions/CXModule.cs index 0cc087dc..afeee5fd 100644 --- a/sources/ClangSharp.Interop/Extensions/CXModule.cs +++ b/sources/ClangSharp.Interop/Extensions/CXModule.cs @@ -4,18 +4,13 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXModule : IEquatable +public unsafe partial struct CXModule(IntPtr handle) : IEquatable { - public CXModule(IntPtr handle) - { - Handle = handle; - } - public readonly CXFile AstFile => (CXFile)clang.Module_getASTFile(this); public readonly CXString FullName => clang.Module_getFullName(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public readonly bool IsSystem => clang.Module_isSystem(this) != 0; diff --git a/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs b/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs index 2531311d..07d82b5b 100644 --- a/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs +++ b/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXModuleMapDescriptor : IDisposable, IEquatable +public unsafe partial struct CXModuleMapDescriptor(IntPtr handle) : IDisposable, IEquatable { - public CXModuleMapDescriptor(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static implicit operator CXModuleMapDescriptor(CXModuleMapDescriptorImpl* value) => new CXModuleMapDescriptor((IntPtr)value); @@ -54,18 +49,6 @@ public readonly Span WriteToBuffer(uint options, out CXErrorCode errorCode { sbyte* pBuffer; uint size; errorCode = clang.ModuleMapDescriptor_writeToBuffer(this, options, &pBuffer, &size); - -#if NETSTANDARD - var result = new byte[checked((int)size)]; - - fixed (byte* pResult = result) - { - Buffer.MemoryCopy(pBuffer, pResult, size, size); - } - - return result; -#else return new Span(pBuffer, (int)size); -#endif } } diff --git a/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs b/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs index d4d6aa50..50c54234 100644 --- a/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs +++ b/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXPrintingPolicy : IDisposable, IEquatable +public unsafe partial struct CXPrintingPolicy(IntPtr handle) : IDisposable, IEquatable { - public CXPrintingPolicy(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static explicit operator CXPrintingPolicy(void* value) => new CXPrintingPolicy((IntPtr)value); diff --git a/sources/ClangSharp.Interop/Extensions/CXRemapping.cs b/sources/ClangSharp.Interop/Extensions/CXRemapping.cs index 6af3cc91..0e766db2 100644 --- a/sources/ClangSharp.Interop/Extensions/CXRemapping.cs +++ b/sources/ClangSharp.Interop/Extensions/CXRemapping.cs @@ -4,13 +4,8 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXRemapping : IDisposable, IEquatable +public unsafe partial struct CXRemapping(IntPtr handle) : IDisposable, IEquatable { - public CXRemapping(IntPtr handle) - { - Handle = handle; - } - public static CXRemapping GetRemappings(string path) { using var marshaledPath = new MarshaledString(path); @@ -26,7 +21,7 @@ public static CXRemapping GetRemappingsFromFileList(ReadOnlySpan filePat return (CXRemapping)clang.getRemappingsFromFileList(pMarshaledPaths, (uint)filePaths.Length); } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public readonly uint NumFiles => clang.remap_getNumFiles(this); diff --git a/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs b/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs index 6ca98652..e041dd7b 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXTargetInfo : IDisposable, IEquatable +public unsafe partial struct CXTargetInfo(IntPtr handle) : IDisposable, IEquatable { - public CXTargetInfo(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public readonly int PointerWidth => clang.TargetInfo_getPointerWidth(this); diff --git a/sources/ClangSharp.Interop/Extensions/CXToken.cs b/sources/ClangSharp.Interop/Extensions/CXToken.cs index 3ee5e844..b42a0763 100644 --- a/sources/ClangSharp.Interop/Extensions/CXToken.cs +++ b/sources/ClangSharp.Interop/Extensions/CXToken.cs @@ -32,7 +32,7 @@ public unsafe partial struct CXToken : IEquatable public readonly CXSourceRange GetExtent(CXTranslationUnit translationUnit) => clang.getTokenExtent(translationUnit, this); - public override int GetHashCode() => HashCode.Combine(int_data[0], int_data[1], int_data[2], int_data[3], (IntPtr)ptr_data); + public override readonly int GetHashCode() => HashCode.Combine(int_data[0], int_data[1], int_data[2], int_data[3], (IntPtr)ptr_data); public readonly CXSourceLocation GetLocation(CXTranslationUnit translationUnit) => clang.getTokenLocation(translationUnit, this); diff --git a/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs b/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs index 09739a27..f0e5d2d7 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs @@ -5,13 +5,8 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXTranslationUnit : IDisposable, IEquatable +public unsafe partial struct CXTranslationUnit(IntPtr handle) : IDisposable, IEquatable { - public CXTranslationUnit(IntPtr handle) - { - Handle = handle; - } - public static CXTranslationUnit_Flags DefaultEditingOptions => (CXTranslationUnit_Flags)clang.defaultEditingTranslationUnitOptions(); public readonly CXSourceRangeList* AllSkippedRanges => clang.getAllSkippedRanges(this); @@ -24,7 +19,7 @@ public CXTranslationUnit(IntPtr handle) public readonly CXDiagnosticSet DiagnosticSet => (CXDiagnosticSet)clang.getDiagnosticSetFromTU(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public readonly uint NumDiagnostics => clang.getNumDiagnostics(this); @@ -227,20 +222,7 @@ public readonly Span Tokenize(CXSourceRange sourceRange) { CXToken* pTokens; uint numTokens; clang.tokenize(this, sourceRange, &pTokens, &numTokens); - -#if NETSTANDARD - var result = new CXToken[checked((int)numTokens)]; - - fixed (CXToken* pResult = result) - { - var size = sizeof(CXToken) * numTokens; - Buffer.MemoryCopy(pTokens, pResult, size, size); - } - - return result; -#else return new Span(pTokens, (int)numTokens); -#endif } public override readonly string ToString() => Spelling.ToString(); diff --git a/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs b/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs index 77917126..3f61354a 100644 --- a/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs @@ -10,41 +10,39 @@ public unsafe partial struct CXUnsavedFile : IDisposable { public static CXUnsavedFile Create(string filename, string contents) { - IntPtr pFilename, pContents; - int filenameLength, contentsLength; + sbyte* pFilename, pContents; + nuint contentsLength; - if ((filename is null) || (filename.Length == 0)) + if (string.IsNullOrEmpty(filename)) { - pFilename = IntPtr.Zero; + pFilename = null; } else { - var filenameBytes = Encoding.UTF8.GetBytes(filename); - filenameLength = filenameBytes.Length; - pFilename = Marshal.AllocHGlobal(filenameLength + 1); - Marshal.Copy(filenameBytes, 0, pFilename, filenameLength); - Marshal.WriteByte(pFilename, filenameLength, 0); + var maxFilenameLength = Encoding.UTF8.GetMaxByteCount(filename.Length); + pFilename = (sbyte*)NativeMemory.Alloc((uint)maxFilenameLength + 1); + var filenameLength = (uint)Encoding.UTF8.GetBytes(filename, new Span(pFilename, maxFilenameLength)); + pFilename[filenameLength] = 0; } - if ((contents is null) || (contents.Length == 0)) + if (string.IsNullOrEmpty(contents)) { contentsLength = 0; - pContents = IntPtr.Zero; + pContents = null; } else { - var contentsBytes = Encoding.UTF8.GetBytes(contents); - contentsLength = contentsBytes.Length; - pContents = Marshal.AllocHGlobal(contentsLength + 1); - Marshal.Copy(contentsBytes, 0, pContents, contentsLength); - Marshal.WriteByte(pContents, contentsLength, 0); + var maxContentsLength = Encoding.UTF8.GetMaxByteCount(contents.Length); + pContents = (sbyte*)NativeMemory.Alloc((uint)maxContentsLength + 1); + contentsLength = (uint)Encoding.UTF8.GetBytes(contents, new Span(pContents, maxContentsLength)); + pContents[contentsLength] = 0; } return new CXUnsavedFile() { - Filename = (sbyte*)pFilename, - Contents = (sbyte*)pContents, - Length = (UIntPtr)contentsLength + Filename = pFilename, + Contents = pContents, + Length = contentsLength }; } @@ -52,15 +50,15 @@ public void Dispose() { if (Filename != null) { - Marshal.FreeHGlobal((IntPtr)Filename); + NativeMemory.Free(Filename); Filename = null; } if (Contents != null) { - Marshal.FreeHGlobal((IntPtr)Contents); + NativeMemory.Free(Contents); Contents = null; - Length = (UIntPtr)0; + Length = 0; } } diff --git a/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs b/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs index bdf8c07c..953d6f0f 100644 --- a/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs +++ b/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs @@ -4,14 +4,9 @@ namespace ClangSharp.Interop; -public unsafe partial struct CXVirtualFileOverlay : IDisposable, IEquatable +public unsafe partial struct CXVirtualFileOverlay(IntPtr handle) : IDisposable, IEquatable { - public CXVirtualFileOverlay(IntPtr handle) - { - Handle = handle; - } - - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } = handle; public static implicit operator CXVirtualFileOverlay(CXVirtualFileOverlayImpl* value) => new CXVirtualFileOverlay((IntPtr)value); @@ -51,18 +46,6 @@ public readonly Span WriteToBuffer(uint options, out CXErrorCode errorCode { sbyte* pBuffer; uint size; errorCode = clang.VirtualFileOverlay_writeToBuffer(this, options, &pBuffer, &size); - -#if NETSTANDARD - var result = new byte[checked((int)size)]; - - fixed (byte* pResult = result) - { - Buffer.MemoryCopy(pBuffer, pResult, size, size); - } - - return result; -#else return new Span(pBuffer, (int)size); -#endif } } diff --git a/sources/ClangSharp.Interop/Internals/MarshaledString.cs b/sources/ClangSharp.Interop/Internals/MarshaledString.cs index 152149c3..66295579 100644 --- a/sources/ClangSharp.Interop/Internals/MarshaledString.cs +++ b/sources/ClangSharp.Interop/Internals/MarshaledString.cs @@ -10,25 +10,38 @@ public unsafe struct MarshaledString : IDisposable { public MarshaledString(string? input) { - int length; - IntPtr value; + int valueLength; + sbyte* pValue; if (input is null) { - length = 0; - value = IntPtr.Zero; + valueLength = 0; + pValue = null; } else { - var valueBytes = (input.Length != 0) ? Encoding.UTF8.GetBytes(input) : []; - length = valueBytes.Length; - value = Marshal.AllocHGlobal(length + 1); - Marshal.Copy(valueBytes, 0, value, length); - Marshal.WriteByte(value, length, 0); + var maxValueLength = Encoding.UTF8.GetMaxByteCount(input.Length); + pValue = (sbyte*)NativeMemory.Alloc((uint)maxValueLength + 1); + valueLength = Encoding.UTF8.GetBytes(input, new Span(pValue, maxValueLength)); + pValue[valueLength] = 0; } - Length = length; - Value = (sbyte*)value; + Length = valueLength; + Value = pValue; + } + + public MarshaledString(ReadOnlySpan input) + { + int valueLength; + sbyte* pValue; + + var maxValueLength = Encoding.UTF8.GetMaxByteCount(input.Length); + pValue = (sbyte*)NativeMemory.Alloc((uint)maxValueLength + 1); + valueLength = Encoding.UTF8.GetBytes(input, new Span(pValue, maxValueLength)); + pValue[valueLength] = 0; + + Length = valueLength; + Value = pValue; } public readonly ReadOnlySpan AsSpan() => new ReadOnlySpan(Value, Length); @@ -41,7 +54,7 @@ public void Dispose() { if (Value != null) { - Marshal.FreeHGlobal((IntPtr)Value); + NativeMemory.Free(Value); Value = null; Length = 0; } diff --git a/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs b/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs index c0b74151..846d1996 100644 --- a/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs +++ b/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs @@ -25,6 +25,8 @@ public MarshaledStringArray(ReadOnlySpan inputs) } } + public readonly int Count => Values.Length; + public readonly ReadOnlySpan Values => _values; public void Dispose() diff --git a/sources/ClangSharp.Interop/Internals/NativeTypeNameAttribute.cs b/sources/ClangSharp.Interop/Internals/NativeTypeNameAttribute.cs index abd87224..847c887e 100644 --- a/sources/ClangSharp.Interop/Internals/NativeTypeNameAttribute.cs +++ b/sources/ClangSharp.Interop/Internals/NativeTypeNameAttribute.cs @@ -7,12 +7,7 @@ namespace ClangSharp.Interop; [Conditional("DEBUG")] [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] -internal sealed class NativeTypeNameAttribute : Attribute +internal sealed class NativeTypeNameAttribute(string name) : Attribute { - public NativeTypeNameAttribute(string name) - { - Name = name; - } - - public string Name { get; } + public string Name { get; } = name; } diff --git a/sources/ClangSharp.Interop/Internals/SpanExtensions.cs b/sources/ClangSharp.Interop/Internals/SpanExtensions.cs index a69a8c94..6badc522 100644 --- a/sources/ClangSharp.Interop/Internals/SpanExtensions.cs +++ b/sources/ClangSharp.Interop/Internals/SpanExtensions.cs @@ -10,12 +10,7 @@ public static unsafe class SpanExtensions { public static string AsString(sbyte* pStr) { -#if NET6_0_OR_GREATER var span = MemoryMarshal.CreateReadOnlySpanFromNullTerminated((byte*)(pStr)); -#else - var span = new ReadOnlySpan(pStr, int.MaxValue); - span = span.Slice(0, span.IndexOf((byte)'\0')); -#endif return span.AsString(); } diff --git a/sources/ClangSharp.Interop/Manual/CXAPISetImpl.cs b/sources/ClangSharp.Interop/Manual/CXAPISetImpl.cs index 5919df17..3a31c17d 100644 --- a/sources/ClangSharp.Interop/Manual/CXAPISetImpl.cs +++ b/sources/ClangSharp.Interop/Manual/CXAPISetImpl.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/Manual/CXCursorSetImpl.cs b/sources/ClangSharp.Interop/Manual/CXCursorSetImpl.cs index 22c0a56a..13ee87e4 100644 --- a/sources/ClangSharp.Interop/Manual/CXCursorSetImpl.cs +++ b/sources/ClangSharp.Interop/Manual/CXCursorSetImpl.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/Manual/CXCursorVisitor.cs b/sources/ClangSharp.Interop/Manual/CXCursorVisitor.cs index 2395c987..e4a1aeda 100644 --- a/sources/ClangSharp.Interop/Manual/CXCursorVisitor.cs +++ b/sources/ClangSharp.Interop/Manual/CXCursorVisitor.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System.Runtime.InteropServices; diff --git a/sources/ClangSharp.Interop/Manual/CXFieldVisitor.cs b/sources/ClangSharp.Interop/Manual/CXFieldVisitor.cs index afea46ea..bf4f22de 100644 --- a/sources/ClangSharp.Interop/Manual/CXFieldVisitor.cs +++ b/sources/ClangSharp.Interop/Manual/CXFieldVisitor.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System.Runtime.InteropServices; diff --git a/sources/ClangSharp.Interop/Manual/CXInclusionVisitor.cs b/sources/ClangSharp.Interop/Manual/CXInclusionVisitor.cs index 43d11536..318e7588 100644 --- a/sources/ClangSharp.Interop/Manual/CXInclusionVisitor.cs +++ b/sources/ClangSharp.Interop/Manual/CXInclusionVisitor.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System.Runtime.InteropServices; diff --git a/sources/ClangSharp.Interop/Manual/CXModuleMapDescriptorImpl.cs b/sources/ClangSharp.Interop/Manual/CXModuleMapDescriptorImpl.cs index 1f050792..398c18c0 100644 --- a/sources/ClangSharp.Interop/Manual/CXModuleMapDescriptorImpl.cs +++ b/sources/ClangSharp.Interop/Manual/CXModuleMapDescriptorImpl.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/Manual/CXTargetInfoImpl.cs b/sources/ClangSharp.Interop/Manual/CXTargetInfoImpl.cs index bfe0876f..68102601 100644 --- a/sources/ClangSharp.Interop/Manual/CXTargetInfoImpl.cs +++ b/sources/ClangSharp.Interop/Manual/CXTargetInfoImpl.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/Manual/CXTranslationUnitImpl.cs b/sources/ClangSharp.Interop/Manual/CXTranslationUnitImpl.cs index 62cd5fbf..fe344762 100644 --- a/sources/ClangSharp.Interop/Manual/CXTranslationUnitImpl.cs +++ b/sources/ClangSharp.Interop/Manual/CXTranslationUnitImpl.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/Manual/CXVirtualFileOverlayImpl.cs b/sources/ClangSharp.Interop/Manual/CXVirtualFileOverlayImpl.cs index b1b1f164..49e9b937 100644 --- a/sources/ClangSharp.Interop/Manual/CXVirtualFileOverlayImpl.cs +++ b/sources/ClangSharp.Interop/Manual/CXVirtualFileOverlayImpl.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang.cs b/sources/ClangSharp.Interop/clang.cs index 41ba44d5..b6546231 100644 --- a/sources/ClangSharp.Interop/clang.cs +++ b/sources/ClangSharp.Interop/clang.cs @@ -41,8 +41,8 @@ private static bool TryResolveClang(Assembly assembly, DllImportSearchPath? sear { if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - return NativeLibrary.TryLoad("libclang.so.17", assembly, searchPath, out nativeLibrary) - || NativeLibrary.TryLoad("libclang-17", assembly, searchPath, out nativeLibrary) + return NativeLibrary.TryLoad("libclang.so.18", assembly, searchPath, out nativeLibrary) + || NativeLibrary.TryLoad("libclang-18", assembly, searchPath, out nativeLibrary) || NativeLibrary.TryLoad("libclang.so.1", assembly, searchPath, out nativeLibrary); } diff --git a/sources/ClangSharp.Interop/clang/CXAvailabilityKind.cs b/sources/ClangSharp.Interop/clang/CXAvailabilityKind.cs index 8fb5e774..8957cf6e 100644 --- a/sources/ClangSharp.Interop/clang/CXAvailabilityKind.cs +++ b/sources/ClangSharp.Interop/clang/CXAvailabilityKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXBinaryOperatorKind.cs b/sources/ClangSharp.Interop/clang/CXBinaryOperatorKind.cs index 20cbf415..6b49fc03 100644 --- a/sources/ClangSharp.Interop/clang/CXBinaryOperatorKind.cs +++ b/sources/ClangSharp.Interop/clang/CXBinaryOperatorKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCallingConv.cs b/sources/ClangSharp.Interop/clang/CXCallingConv.cs index 8c3314af..c54eb79f 100644 --- a/sources/ClangSharp.Interop/clang/CXCallingConv.cs +++ b/sources/ClangSharp.Interop/clang/CXCallingConv.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; @@ -27,6 +27,7 @@ public enum CXCallingConv CXCallingConv_AArch64VectorCall = 16, CXCallingConv_SwiftAsync = 17, CXCallingConv_AArch64SVEPCS = 18, + CXCallingConv_M68kRTD = 19, CXCallingConv_Invalid = 100, CXCallingConv_Unexposed = 200, } diff --git a/sources/ClangSharp.Interop/clang/CXChildVisitResult.cs b/sources/ClangSharp.Interop/clang/CXChildVisitResult.cs index 27cf39c9..703f2628 100644 --- a/sources/ClangSharp.Interop/clang/CXChildVisitResult.cs +++ b/sources/ClangSharp.Interop/clang/CXChildVisitResult.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXChoice.cs b/sources/ClangSharp.Interop/clang/CXChoice.cs index e53c60c1..4b1f9269 100644 --- a/sources/ClangSharp.Interop/clang/CXChoice.cs +++ b/sources/ClangSharp.Interop/clang/CXChoice.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCodeCompleteResults.cs b/sources/ClangSharp.Interop/clang/CXCodeCompleteResults.cs index 8f554e0f..db791bf3 100644 --- a/sources/ClangSharp.Interop/clang/CXCodeCompleteResults.cs +++ b/sources/ClangSharp.Interop/clang/CXCodeCompleteResults.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCodeComplete_Flags.cs b/sources/ClangSharp.Interop/clang/CXCodeComplete_Flags.cs index a5b32929..531a940f 100644 --- a/sources/ClangSharp.Interop/clang/CXCodeComplete_Flags.cs +++ b/sources/ClangSharp.Interop/clang/CXCodeComplete_Flags.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXComment.cs b/sources/ClangSharp.Interop/clang/CXComment.cs index d3a3c7f5..cb17ef6c 100644 --- a/sources/ClangSharp.Interop/clang/CXComment.cs +++ b/sources/ClangSharp.Interop/clang/CXComment.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCommentInlineCommandRenderKind.cs b/sources/ClangSharp.Interop/clang/CXCommentInlineCommandRenderKind.cs index ac69e001..a0a66953 100644 --- a/sources/ClangSharp.Interop/clang/CXCommentInlineCommandRenderKind.cs +++ b/sources/ClangSharp.Interop/clang/CXCommentInlineCommandRenderKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCommentKind.cs b/sources/ClangSharp.Interop/clang/CXCommentKind.cs index 41980f7c..3ec91725 100644 --- a/sources/ClangSharp.Interop/clang/CXCommentKind.cs +++ b/sources/ClangSharp.Interop/clang/CXCommentKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCommentParamPassDirection.cs b/sources/ClangSharp.Interop/clang/CXCommentParamPassDirection.cs index 9706b363..4ba704d3 100644 --- a/sources/ClangSharp.Interop/clang/CXCommentParamPassDirection.cs +++ b/sources/ClangSharp.Interop/clang/CXCommentParamPassDirection.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCompilationDatabase_Error.cs b/sources/ClangSharp.Interop/clang/CXCompilationDatabase_Error.cs index ae9d3ded..9be2b02d 100644 --- a/sources/ClangSharp.Interop/clang/CXCompilationDatabase_Error.cs +++ b/sources/ClangSharp.Interop/clang/CXCompilationDatabase_Error.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCompletionChunkKind.cs b/sources/ClangSharp.Interop/clang/CXCompletionChunkKind.cs index 4a0f95d5..ea3a04eb 100644 --- a/sources/ClangSharp.Interop/clang/CXCompletionChunkKind.cs +++ b/sources/ClangSharp.Interop/clang/CXCompletionChunkKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCompletionContext.cs b/sources/ClangSharp.Interop/clang/CXCompletionContext.cs index 2955ed2a..a5558c5b 100644 --- a/sources/ClangSharp.Interop/clang/CXCompletionContext.cs +++ b/sources/ClangSharp.Interop/clang/CXCompletionContext.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCompletionResult.cs b/sources/ClangSharp.Interop/clang/CXCompletionResult.cs index 935cebba..a21df104 100644 --- a/sources/ClangSharp.Interop/clang/CXCompletionResult.cs +++ b/sources/ClangSharp.Interop/clang/CXCompletionResult.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCursor.cs b/sources/ClangSharp.Interop/clang/CXCursor.cs index d37082bf..074538d8 100644 --- a/sources/ClangSharp.Interop/clang/CXCursor.cs +++ b/sources/ClangSharp.Interop/clang/CXCursor.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System.Runtime.CompilerServices; diff --git a/sources/ClangSharp.Interop/clang/CXCursorAndRangeVisitor.cs b/sources/ClangSharp.Interop/clang/CXCursorAndRangeVisitor.cs index 8dfecd7b..2ac3caff 100644 --- a/sources/ClangSharp.Interop/clang/CXCursorAndRangeVisitor.cs +++ b/sources/ClangSharp.Interop/clang/CXCursorAndRangeVisitor.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXCursorKind.cs b/sources/ClangSharp.Interop/clang/CXCursorKind.cs index eeea7154..42a586b2 100644 --- a/sources/ClangSharp.Interop/clang/CXCursorKind.cs +++ b/sources/ClangSharp.Interop/clang/CXCursorKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; @@ -233,7 +233,8 @@ public enum CXCursorKind CXCursor_OMPParallelMaskedTaskLoopDirective = 303, CXCursor_OMPParallelMaskedTaskLoopSimdDirective = 304, CXCursor_OMPErrorDirective = 305, - CXCursor_LastStmt = CXCursor_OMPErrorDirective, + CXCursor_OMPScopeDirective = 306, + CXCursor_LastStmt = CXCursor_OMPScopeDirective, CXCursor_TranslationUnit = 350, CXCursor_FirstAttr = 400, CXCursor_UnexposedAttr = 400, diff --git a/sources/ClangSharp.Interop/clang/CXCursor_ExceptionSpecificationKind.cs b/sources/ClangSharp.Interop/clang/CXCursor_ExceptionSpecificationKind.cs index bf0b589b..5c1d53fb 100644 --- a/sources/ClangSharp.Interop/clang/CXCursor_ExceptionSpecificationKind.cs +++ b/sources/ClangSharp.Interop/clang/CXCursor_ExceptionSpecificationKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXDiagnosticDisplayOptions.cs b/sources/ClangSharp.Interop/clang/CXDiagnosticDisplayOptions.cs index 9d2701b7..a1f3752d 100644 --- a/sources/ClangSharp.Interop/clang/CXDiagnosticDisplayOptions.cs +++ b/sources/ClangSharp.Interop/clang/CXDiagnosticDisplayOptions.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXDiagnosticSeverity.cs b/sources/ClangSharp.Interop/clang/CXDiagnosticSeverity.cs index a1fae528..f580c249 100644 --- a/sources/ClangSharp.Interop/clang/CXDiagnosticSeverity.cs +++ b/sources/ClangSharp.Interop/clang/CXDiagnosticSeverity.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXErrorCode.cs b/sources/ClangSharp.Interop/clang/CXErrorCode.cs index 6ce89fcc..1e4023ae 100644 --- a/sources/ClangSharp.Interop/clang/CXErrorCode.cs +++ b/sources/ClangSharp.Interop/clang/CXErrorCode.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXEvalResultKind.cs b/sources/ClangSharp.Interop/clang/CXEvalResultKind.cs index 565fb9ad..dc000cfc 100644 --- a/sources/ClangSharp.Interop/clang/CXEvalResultKind.cs +++ b/sources/ClangSharp.Interop/clang/CXEvalResultKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXFileUniqueID.cs b/sources/ClangSharp.Interop/clang/CXFileUniqueID.cs index b0d415d4..08541baa 100644 --- a/sources/ClangSharp.Interop/clang/CXFileUniqueID.cs +++ b/sources/ClangSharp.Interop/clang/CXFileUniqueID.cs @@ -1,12 +1,20 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. +using System.Runtime.CompilerServices; + namespace ClangSharp.Interop; -public unsafe partial struct CXFileUniqueID +public partial struct CXFileUniqueID { [NativeTypeName("unsigned long long[3]")] - public fixed ulong data[3]; + public _data_e__FixedBuffer data; + + [InlineArray(3)] + public partial struct _data_e__FixedBuffer + { + public ulong e0; + } } diff --git a/sources/ClangSharp.Interop/clang/CXGlobalOptFlags.cs b/sources/ClangSharp.Interop/clang/CXGlobalOptFlags.cs index 8d1774c9..ddea536b 100644 --- a/sources/ClangSharp.Interop/clang/CXGlobalOptFlags.cs +++ b/sources/ClangSharp.Interop/clang/CXGlobalOptFlags.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxAttrInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxAttrInfo.cs index 1b8354c6..3def5799 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxAttrInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxAttrInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxAttrKind.cs b/sources/ClangSharp.Interop/clang/CXIdxAttrKind.cs index 49560dc3..f461126b 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxAttrKind.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxAttrKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxBaseClassInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxBaseClassInfo.cs index ad25f04c..0dcee248 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxBaseClassInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxBaseClassInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxCXXClassDeclInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxCXXClassDeclInfo.cs index bed441ec..b9d7472c 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxCXXClassDeclInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxCXXClassDeclInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxContainerInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxContainerInfo.cs index 286869f2..4f7c4f3f 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxContainerInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxContainerInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxDeclInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxDeclInfo.cs index a412875b..ad8a7b1a 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxDeclInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxDeclInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxDeclInfoFlags.cs b/sources/ClangSharp.Interop/clang/CXIdxDeclInfoFlags.cs index b3e93a53..15bcfabc 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxDeclInfoFlags.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxDeclInfoFlags.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxEntityCXXTemplateKind.cs b/sources/ClangSharp.Interop/clang/CXIdxEntityCXXTemplateKind.cs index 87f2883e..9da7c26f 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxEntityCXXTemplateKind.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxEntityCXXTemplateKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxEntityInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxEntityInfo.cs index 53ce305f..82304b8b 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxEntityInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxEntityInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxEntityKind.cs b/sources/ClangSharp.Interop/clang/CXIdxEntityKind.cs index 4cdb5b13..ca3cc6e9 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxEntityKind.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxEntityKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxEntityLanguage.cs b/sources/ClangSharp.Interop/clang/CXIdxEntityLanguage.cs index 74141030..0fde7af2 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxEntityLanguage.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxEntityLanguage.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxEntityRefInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxEntityRefInfo.cs index 0cddca77..d60d98bf 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxEntityRefInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxEntityRefInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxEntityRefKind.cs b/sources/ClangSharp.Interop/clang/CXIdxEntityRefKind.cs index bfd47369..3f1daa21 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxEntityRefKind.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxEntityRefKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxIBOutletCollectionAttrInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxIBOutletCollectionAttrInfo.cs index 0a753156..786daf83 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxIBOutletCollectionAttrInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxIBOutletCollectionAttrInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxImportedASTFileInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxImportedASTFileInfo.cs index 8a54a95c..d0b1ba35 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxImportedASTFileInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxImportedASTFileInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxIncludedFileInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxIncludedFileInfo.cs index d90cea04..9de436d2 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxIncludedFileInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxIncludedFileInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxLoc.cs b/sources/ClangSharp.Interop/clang/CXIdxLoc.cs index 704d7ee5..2309fc5b 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxLoc.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxLoc.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System.Runtime.CompilerServices; diff --git a/sources/ClangSharp.Interop/clang/CXIdxObjCCategoryDeclInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxObjCCategoryDeclInfo.cs index 408a4747..ed95f7b1 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxObjCCategoryDeclInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxObjCCategoryDeclInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxObjCContainerDeclInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxObjCContainerDeclInfo.cs index b1ab7cfb..580e5caa 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxObjCContainerDeclInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxObjCContainerDeclInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxObjCContainerKind.cs b/sources/ClangSharp.Interop/clang/CXIdxObjCContainerKind.cs index 28a1b0f8..d92df8f7 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxObjCContainerKind.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxObjCContainerKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxObjCInterfaceDeclInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxObjCInterfaceDeclInfo.cs index 309934d9..61b95173 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxObjCInterfaceDeclInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxObjCInterfaceDeclInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxObjCPropertyDeclInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxObjCPropertyDeclInfo.cs index fbfb45da..65edc889 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxObjCPropertyDeclInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxObjCPropertyDeclInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxObjCProtocolRefInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxObjCProtocolRefInfo.cs index 550a95f5..e8ca74cd 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxObjCProtocolRefInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxObjCProtocolRefInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIdxObjCProtocolRefListInfo.cs b/sources/ClangSharp.Interop/clang/CXIdxObjCProtocolRefListInfo.cs index ca0ce3e5..cb02880d 100644 --- a/sources/ClangSharp.Interop/clang/CXIdxObjCProtocolRefListInfo.cs +++ b/sources/ClangSharp.Interop/clang/CXIdxObjCProtocolRefListInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIndexOptFlags.cs b/sources/ClangSharp.Interop/clang/CXIndexOptFlags.cs index 4c27f141..3c2dd327 100644 --- a/sources/ClangSharp.Interop/clang/CXIndexOptFlags.cs +++ b/sources/ClangSharp.Interop/clang/CXIndexOptFlags.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXIndexOptions.cs b/sources/ClangSharp.Interop/clang/CXIndexOptions.cs index 0a7e6a19..859e06c8 100644 --- a/sources/ClangSharp.Interop/clang/CXIndexOptions.cs +++ b/sources/ClangSharp.Interop/clang/CXIndexOptions.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System.Runtime.CompilerServices; diff --git a/sources/ClangSharp.Interop/clang/CXLanguageKind.cs b/sources/ClangSharp.Interop/clang/CXLanguageKind.cs index 5f965ea7..790fd346 100644 --- a/sources/ClangSharp.Interop/clang/CXLanguageKind.cs +++ b/sources/ClangSharp.Interop/clang/CXLanguageKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXLinkageKind.cs b/sources/ClangSharp.Interop/clang/CXLinkageKind.cs index 5b3f19e9..cbb05f8f 100644 --- a/sources/ClangSharp.Interop/clang/CXLinkageKind.cs +++ b/sources/ClangSharp.Interop/clang/CXLinkageKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXLoadDiag_Error.cs b/sources/ClangSharp.Interop/clang/CXLoadDiag_Error.cs index 33784a07..f142982b 100644 --- a/sources/ClangSharp.Interop/clang/CXLoadDiag_Error.cs +++ b/sources/ClangSharp.Interop/clang/CXLoadDiag_Error.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXNameRefFlags.cs b/sources/ClangSharp.Interop/clang/CXNameRefFlags.cs index 27c2fa8a..b6293159 100644 --- a/sources/ClangSharp.Interop/clang/CXNameRefFlags.cs +++ b/sources/ClangSharp.Interop/clang/CXNameRefFlags.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXObjCDeclQualifierKind.cs b/sources/ClangSharp.Interop/clang/CXObjCDeclQualifierKind.cs index fd152188..ff264cc8 100644 --- a/sources/ClangSharp.Interop/clang/CXObjCDeclQualifierKind.cs +++ b/sources/ClangSharp.Interop/clang/CXObjCDeclQualifierKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXObjCPropertyAttrKind.cs b/sources/ClangSharp.Interop/clang/CXObjCPropertyAttrKind.cs index 6a5fc115..0ec758d4 100644 --- a/sources/ClangSharp.Interop/clang/CXObjCPropertyAttrKind.cs +++ b/sources/ClangSharp.Interop/clang/CXObjCPropertyAttrKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXPlatformAvailability.cs b/sources/ClangSharp.Interop/clang/CXPlatformAvailability.cs index b4244af7..2f39fd87 100644 --- a/sources/ClangSharp.Interop/clang/CXPlatformAvailability.cs +++ b/sources/ClangSharp.Interop/clang/CXPlatformAvailability.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXPrintingPolicyProperty.cs b/sources/ClangSharp.Interop/clang/CXPrintingPolicyProperty.cs index a805ca8d..d983f321 100644 --- a/sources/ClangSharp.Interop/clang/CXPrintingPolicyProperty.cs +++ b/sources/ClangSharp.Interop/clang/CXPrintingPolicyProperty.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXRefQualifierKind.cs b/sources/ClangSharp.Interop/clang/CXRefQualifierKind.cs index 67a2f76d..ffa81942 100644 --- a/sources/ClangSharp.Interop/clang/CXRefQualifierKind.cs +++ b/sources/ClangSharp.Interop/clang/CXRefQualifierKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXReparse_Flags.cs b/sources/ClangSharp.Interop/clang/CXReparse_Flags.cs index 70b64d8f..bfcad337 100644 --- a/sources/ClangSharp.Interop/clang/CXReparse_Flags.cs +++ b/sources/ClangSharp.Interop/clang/CXReparse_Flags.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXResult.cs b/sources/ClangSharp.Interop/clang/CXResult.cs index 75d25240..0806c12f 100644 --- a/sources/ClangSharp.Interop/clang/CXResult.cs +++ b/sources/ClangSharp.Interop/clang/CXResult.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXSaveError.cs b/sources/ClangSharp.Interop/clang/CXSaveError.cs index c41514ab..553d709a 100644 --- a/sources/ClangSharp.Interop/clang/CXSaveError.cs +++ b/sources/ClangSharp.Interop/clang/CXSaveError.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXSaveTranslationUnit_Flags.cs b/sources/ClangSharp.Interop/clang/CXSaveTranslationUnit_Flags.cs index 407ac147..07bdc501 100644 --- a/sources/ClangSharp.Interop/clang/CXSaveTranslationUnit_Flags.cs +++ b/sources/ClangSharp.Interop/clang/CXSaveTranslationUnit_Flags.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXSourceLocation.cs b/sources/ClangSharp.Interop/clang/CXSourceLocation.cs index e0f4be03..2f613f31 100644 --- a/sources/ClangSharp.Interop/clang/CXSourceLocation.cs +++ b/sources/ClangSharp.Interop/clang/CXSourceLocation.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System.Runtime.CompilerServices; diff --git a/sources/ClangSharp.Interop/clang/CXSourceRange.cs b/sources/ClangSharp.Interop/clang/CXSourceRange.cs index 2868b590..fcdb87c3 100644 --- a/sources/ClangSharp.Interop/clang/CXSourceRange.cs +++ b/sources/ClangSharp.Interop/clang/CXSourceRange.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System.Runtime.CompilerServices; diff --git a/sources/ClangSharp.Interop/clang/CXSourceRangeList.cs b/sources/ClangSharp.Interop/clang/CXSourceRangeList.cs index ecc2dcd4..991b2a33 100644 --- a/sources/ClangSharp.Interop/clang/CXSourceRangeList.cs +++ b/sources/ClangSharp.Interop/clang/CXSourceRangeList.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXString.cs b/sources/ClangSharp.Interop/clang/CXString.cs index 4739dd76..3b871724 100644 --- a/sources/ClangSharp.Interop/clang/CXString.cs +++ b/sources/ClangSharp.Interop/clang/CXString.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXStringSet.cs b/sources/ClangSharp.Interop/clang/CXStringSet.cs index b7add59a..edaa94d0 100644 --- a/sources/ClangSharp.Interop/clang/CXStringSet.cs +++ b/sources/ClangSharp.Interop/clang/CXStringSet.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXSymbolRole.cs b/sources/ClangSharp.Interop/clang/CXSymbolRole.cs index 101b5151..c9acc0e8 100644 --- a/sources/ClangSharp.Interop/clang/CXSymbolRole.cs +++ b/sources/ClangSharp.Interop/clang/CXSymbolRole.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXTLSKind.cs b/sources/ClangSharp.Interop/clang/CXTLSKind.cs index 73c0dc96..81aa2fda 100644 --- a/sources/ClangSharp.Interop/clang/CXTLSKind.cs +++ b/sources/ClangSharp.Interop/clang/CXTLSKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXTUResourceUsage.cs b/sources/ClangSharp.Interop/clang/CXTUResourceUsage.cs index 300acca1..f0a74664 100644 --- a/sources/ClangSharp.Interop/clang/CXTUResourceUsage.cs +++ b/sources/ClangSharp.Interop/clang/CXTUResourceUsage.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXTUResourceUsageEntry.cs b/sources/ClangSharp.Interop/clang/CXTUResourceUsageEntry.cs index b3bd51bc..fb2fc8ec 100644 --- a/sources/ClangSharp.Interop/clang/CXTUResourceUsageEntry.cs +++ b/sources/ClangSharp.Interop/clang/CXTUResourceUsageEntry.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXTUResourceUsageKind.cs b/sources/ClangSharp.Interop/clang/CXTUResourceUsageKind.cs index aa12a6c7..423bfe71 100644 --- a/sources/ClangSharp.Interop/clang/CXTUResourceUsageKind.cs +++ b/sources/ClangSharp.Interop/clang/CXTUResourceUsageKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXTemplateArgumentKind.cs b/sources/ClangSharp.Interop/clang/CXTemplateArgumentKind.cs index 789efa0d..1375e56b 100644 --- a/sources/ClangSharp.Interop/clang/CXTemplateArgumentKind.cs +++ b/sources/ClangSharp.Interop/clang/CXTemplateArgumentKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXToken.cs b/sources/ClangSharp.Interop/clang/CXToken.cs index a960a81c..c7729f34 100644 --- a/sources/ClangSharp.Interop/clang/CXToken.cs +++ b/sources/ClangSharp.Interop/clang/CXToken.cs @@ -1,14 +1,22 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. +using System.Runtime.CompilerServices; + namespace ClangSharp.Interop; public unsafe partial struct CXToken { [NativeTypeName("unsigned int[4]")] - public fixed uint int_data[4]; + public _int_data_e__FixedBuffer int_data; public void* ptr_data; + + [InlineArray(4)] + public partial struct _int_data_e__FixedBuffer + { + public uint e0; + } } diff --git a/sources/ClangSharp.Interop/clang/CXTokenKind.cs b/sources/ClangSharp.Interop/clang/CXTokenKind.cs index fd13cd5b..48170e30 100644 --- a/sources/ClangSharp.Interop/clang/CXTokenKind.cs +++ b/sources/ClangSharp.Interop/clang/CXTokenKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXTranslationUnit_Flags.cs b/sources/ClangSharp.Interop/clang/CXTranslationUnit_Flags.cs index 191a52dc..57ec6324 100644 --- a/sources/ClangSharp.Interop/clang/CXTranslationUnit_Flags.cs +++ b/sources/ClangSharp.Interop/clang/CXTranslationUnit_Flags.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXType.cs b/sources/ClangSharp.Interop/clang/CXType.cs index e679e940..ba107bfd 100644 --- a/sources/ClangSharp.Interop/clang/CXType.cs +++ b/sources/ClangSharp.Interop/clang/CXType.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System.Runtime.CompilerServices; diff --git a/sources/ClangSharp.Interop/clang/CXTypeKind.cs b/sources/ClangSharp.Interop/clang/CXTypeKind.cs index db7f2aef..ce97a87a 100644 --- a/sources/ClangSharp.Interop/clang/CXTypeKind.cs +++ b/sources/ClangSharp.Interop/clang/CXTypeKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXTypeLayoutError.cs b/sources/ClangSharp.Interop/clang/CXTypeLayoutError.cs index ac2af0ac..963e824b 100644 --- a/sources/ClangSharp.Interop/clang/CXTypeLayoutError.cs +++ b/sources/ClangSharp.Interop/clang/CXTypeLayoutError.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXTypeNullabilityKind.cs b/sources/ClangSharp.Interop/clang/CXTypeNullabilityKind.cs index 37039fbc..58f5075b 100644 --- a/sources/ClangSharp.Interop/clang/CXTypeNullabilityKind.cs +++ b/sources/ClangSharp.Interop/clang/CXTypeNullabilityKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXUnaryOperatorKind.cs b/sources/ClangSharp.Interop/clang/CXUnaryOperatorKind.cs index f68d3324..e4abc5eb 100644 --- a/sources/ClangSharp.Interop/clang/CXUnaryOperatorKind.cs +++ b/sources/ClangSharp.Interop/clang/CXUnaryOperatorKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXUnsavedFile.cs b/sources/ClangSharp.Interop/clang/CXUnsavedFile.cs index e301cab8..a4c5130e 100644 --- a/sources/ClangSharp.Interop/clang/CXUnsavedFile.cs +++ b/sources/ClangSharp.Interop/clang/CXUnsavedFile.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXVersion.cs b/sources/ClangSharp.Interop/clang/CXVersion.cs index 011c4846..c04fefd2 100644 --- a/sources/ClangSharp.Interop/clang/CXVersion.cs +++ b/sources/ClangSharp.Interop/clang/CXVersion.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXVisibilityKind.cs b/sources/ClangSharp.Interop/clang/CXVisibilityKind.cs index c70c0c5e..9901eba3 100644 --- a/sources/ClangSharp.Interop/clang/CXVisibilityKind.cs +++ b/sources/ClangSharp.Interop/clang/CXVisibilityKind.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CXVisitorResult.cs b/sources/ClangSharp.Interop/clang/CXVisitorResult.cs index 0b04c170..0af560b7 100644 --- a/sources/ClangSharp.Interop/clang/CXVisitorResult.cs +++ b/sources/ClangSharp.Interop/clang/CXVisitorResult.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CX_CXXAccessSpecifier.cs b/sources/ClangSharp.Interop/clang/CX_CXXAccessSpecifier.cs index a2de358d..104284df 100644 --- a/sources/ClangSharp.Interop/clang/CX_CXXAccessSpecifier.cs +++ b/sources/ClangSharp.Interop/clang/CX_CXXAccessSpecifier.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/CX_StorageClass.cs b/sources/ClangSharp.Interop/clang/CX_StorageClass.cs index 844cc1c1..53854116 100644 --- a/sources/ClangSharp.Interop/clang/CX_StorageClass.cs +++ b/sources/ClangSharp.Interop/clang/CX_StorageClass.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/IndexerCallbacks.cs b/sources/ClangSharp.Interop/clang/IndexerCallbacks.cs index 097d979a..9c461643 100644 --- a/sources/ClangSharp.Interop/clang/IndexerCallbacks.cs +++ b/sources/ClangSharp.Interop/clang/IndexerCallbacks.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. namespace ClangSharp.Interop; diff --git a/sources/ClangSharp.Interop/clang/clang.cs b/sources/ClangSharp.Interop/clang/clang.cs index 23037e80..5d1d1abb 100644 --- a/sources/ClangSharp.Interop/clang/clang.cs +++ b/sources/ClangSharp.Interop/clang/clang.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. using System; diff --git a/sources/ClangSharp.Interop/clangsharp/CX_AtomicOperatorKind.cs b/sources/ClangSharp.Interop/clangsharp/CX_AtomicOperatorKind.cs index de82094a..8afe0084 100644 --- a/sources/ClangSharp.Interop/clangsharp/CX_AtomicOperatorKind.cs +++ b/sources/ClangSharp.Interop/clangsharp/CX_AtomicOperatorKind.cs @@ -42,6 +42,30 @@ public enum CX_AtomicOperatorKind CX_AO__atomic_max_fetch, CX_AO__atomic_min_fetch, CX_AO__atomic_nand_fetch, + CX_AO__scoped_atomic_load, + CX_AO__scoped_atomic_load_n, + CX_AO__scoped_atomic_store, + CX_AO__scoped_atomic_store_n, + CX_AO__scoped_atomic_exchange, + CX_AO__scoped_atomic_exchange_n, + CX_AO__scoped_atomic_compare_exchange, + CX_AO__scoped_atomic_compare_exchange_n, + CX_AO__scoped_atomic_fetch_add, + CX_AO__scoped_atomic_fetch_sub, + CX_AO__scoped_atomic_fetch_and, + CX_AO__scoped_atomic_fetch_or, + CX_AO__scoped_atomic_fetch_xor, + CX_AO__scoped_atomic_fetch_nand, + CX_AO__scoped_atomic_add_fetch, + CX_AO__scoped_atomic_sub_fetch, + CX_AO__scoped_atomic_and_fetch, + CX_AO__scoped_atomic_or_fetch, + CX_AO__scoped_atomic_xor_fetch, + CX_AO__scoped_atomic_max_fetch, + CX_AO__scoped_atomic_min_fetch, + CX_AO__scoped_atomic_nand_fetch, + CX_AO__scoped_atomic_fetch_min, + CX_AO__scoped_atomic_fetch_max, CX_AO__opencl_atomic_init, CX_AO__opencl_atomic_load, CX_AO__opencl_atomic_store, diff --git a/sources/ClangSharp.Interop/clangsharp/CX_AttrKind.cs b/sources/ClangSharp.Interop/clangsharp/CX_AttrKind.cs index 67280437..5468ac8e 100644 --- a/sources/ClangSharp.Interop/clangsharp/CX_AttrKind.cs +++ b/sources/ClangSharp.Interop/clangsharp/CX_AttrKind.cs @@ -8,11 +8,17 @@ public enum CX_AttrKind CX_AttrKind_Invalid, CX_AttrKind_AddressSpace, CX_AttrKind_AnnotateType, + CX_AttrKind_ArmIn, + CX_AttrKind_ArmInOut, CX_AttrKind_ArmMveStrictPolymorphism, + CX_AttrKind_ArmOut, + CX_AttrKind_ArmPreserves, CX_AttrKind_ArmStreaming, + CX_AttrKind_ArmStreamingCompatible, CX_AttrKind_BTFTypeTag, CX_AttrKind_CmseNSCall, CX_AttrKind_HLSLGroupSharedAddressSpace, + CX_AttrKind_HLSLParamModifier, CX_AttrKind_NoDeref, CX_AttrKind_ObjCGC, CX_AttrKind_ObjCInertUnsafeUnretained, @@ -33,15 +39,16 @@ public enum CX_AttrKind CX_AttrKind_TypeNullableResult, CX_AttrKind_UPtr, CX_AttrKind_WebAssemblyFuncref, + CX_AttrKind_CodeAlign, CX_AttrKind_FallThrough, CX_AttrKind_Likely, CX_AttrKind_MustTail, CX_AttrKind_OpenCLUnrollHint, - CX_AttrKind_Suppress, CX_AttrKind_Unlikely, CX_AttrKind_AlwaysInline, CX_AttrKind_NoInline, CX_AttrKind_NoMerge, + CX_AttrKind_Suppress, CX_AttrKind_AArch64SVEPcs, CX_AttrKind_AArch64VectorPcs, CX_AttrKind_AMDGPUKernelCall, @@ -51,6 +58,7 @@ public enum CX_AttrKind CX_AttrKind_FastCall, CX_AttrKind_IntelOclBicc, CX_AttrKind_LifetimeBound, + CX_AttrKind_M68kRTD, CX_AttrKind_MSABI, CX_AttrKind_NSReturnsRetained, CX_AttrKind_ObjCOwnership, @@ -102,6 +110,8 @@ public enum CX_AttrKind CX_AttrKind_ArcWeakrefUnavailable, CX_AttrKind_ArgumentWithTypeTag, CX_AttrKind_ArmBuiltinAlias, + CX_AttrKind_ArmLocallyStreaming, + CX_AttrKind_ArmNew, CX_AttrKind_Artificial, CX_AttrKind_AsmLabel, CX_AttrKind_AssertCapability, @@ -112,6 +122,7 @@ public enum CX_AttrKind CX_AttrKind_Availability, CX_AttrKind_AvailableOnlyInDefaultEvalMethod, CX_AttrKind_BPFPreserveAccessIndex, + CX_AttrKind_BPFPreserveStaticOffset, CX_AttrKind_BTFDeclTag, CX_AttrKind_Blocks, CX_AttrKind_Builtin, @@ -140,6 +151,7 @@ public enum CX_AttrKind CX_AttrKind_CapturedRecord, CX_AttrKind_Cleanup, CX_AttrKind_CmseNSEntry, + CX_AttrKind_CodeModel, CX_AttrKind_CodeSeg, CX_AttrKind_Cold, CX_AttrKind_Common, @@ -150,6 +162,12 @@ public enum CX_AttrKind CX_AttrKind_ConsumableAutoCast, CX_AttrKind_ConsumableSetOnRead, CX_AttrKind_Convergent, + CX_AttrKind_CoroDisableLifetimeBound, + CX_AttrKind_CoroLifetimeBound, + CX_AttrKind_CoroOnlyDestroyWhenComplete, + CX_AttrKind_CoroReturnType, + CX_AttrKind_CoroWrapper, + CX_AttrKind_CountedBy, CX_AttrKind_DLLExport, CX_AttrKind_DLLExportStaticLocal, CX_AttrKind_DLLImport, @@ -197,6 +215,7 @@ public enum CX_AttrKind CX_AttrKind_M68kInterrupt, CX_AttrKind_MIGServerRoutine, CX_AttrKind_MSAllocator, + CX_AttrKind_MSConstexpr, CX_AttrKind_MSInheritance, CX_AttrKind_MSNoVTable, CX_AttrKind_MSP430Interrupt, @@ -279,6 +298,7 @@ public enum CX_AttrKind CX_AttrKind_PragmaClangRodataSection, CX_AttrKind_PragmaClangTextSection, CX_AttrKind_PreferredName, + CX_AttrKind_PreferredType, CX_AttrKind_PtGuardedBy, CX_AttrKind_PtGuardedVar, CX_AttrKind_Pure, @@ -313,6 +333,8 @@ public enum CX_AttrKind CX_AttrKind_SwiftBridge, CX_AttrKind_SwiftBridgedTypedef, CX_AttrKind_SwiftError, + CX_AttrKind_SwiftImportAsNonGeneric, + CX_AttrKind_SwiftImportPropertyAsAccessors, CX_AttrKind_SwiftName, CX_AttrKind_SwiftNewType, CX_AttrKind_SwiftPrivate, @@ -377,15 +399,17 @@ public enum CX_AttrKind CX_AttrKind_Overloadable, CX_AttrKind_RenderScriptKernel, CX_AttrKind_SwiftObjCMembers, + CX_AttrKind_SwiftVersionedAddition, + CX_AttrKind_SwiftVersionedRemoval, CX_AttrKind_Thread, CX_AttrKind_FirstAttr = CX_AttrKind_AddressSpace, CX_AttrKind_LastAttr = CX_AttrKind_Thread, CX_AttrKind_FirstTypeAttr = CX_AttrKind_AddressSpace, CX_AttrKind_LastTypeAttr = CX_AttrKind_WebAssemblyFuncref, - CX_AttrKind_FirstStmtAttr = CX_AttrKind_FallThrough, + CX_AttrKind_FirstStmtAttr = CX_AttrKind_CodeAlign, CX_AttrKind_LastStmtAttr = CX_AttrKind_Unlikely, CX_AttrKind_FirstDeclOrStmtAttr = CX_AttrKind_AlwaysInline, - CX_AttrKind_LastDeclOrStmtAttr = CX_AttrKind_NoMerge, + CX_AttrKind_LastDeclOrStmtAttr = CX_AttrKind_Suppress, CX_AttrKind_FirstInheritableAttr = CX_AttrKind_AlwaysInline, CX_AttrKind_LastInheritableAttr = CX_AttrKind_ZeroCallUsedRegs, CX_AttrKind_FirstDeclOrTypeAttr = CX_AttrKind_AArch64SVEPcs, diff --git a/sources/ClangSharp.Interop/clangsharp/CX_DeclKind.cs b/sources/ClangSharp.Interop/clangsharp/CX_DeclKind.cs index d92da9d7..3e3dbbe6 100644 --- a/sources/ClangSharp.Interop/clangsharp/CX_DeclKind.cs +++ b/sources/ClangSharp.Interop/clangsharp/CX_DeclKind.cs @@ -6,133 +6,132 @@ namespace ClangSharp.Interop; public enum CX_DeclKind { CX_DeclKind_Invalid, - CX_DeclKind_AccessSpec, - CX_DeclKind_Block, - CX_DeclKind_Captured, - CX_DeclKind_ClassScopeFunctionSpecialization, - CX_DeclKind_Empty, - CX_DeclKind_Export, - CX_DeclKind_ExternCContext, - CX_DeclKind_FileScopeAsm, - CX_DeclKind_Friend, - CX_DeclKind_FriendTemplate, - CX_DeclKind_ImplicitConceptSpecialization, - CX_DeclKind_Import, - CX_DeclKind_LifetimeExtendedTemporary, + CX_DeclKind_TranslationUnit, + CX_DeclKind_RequiresExprBody, CX_DeclKind_LinkageSpec, - CX_DeclKind_Using, - CX_DeclKind_UsingEnum, - CX_DeclKind_FirstBaseUsing = CX_DeclKind_Using, - CX_DeclKind_LastBaseUsing = CX_DeclKind_UsingEnum, - CX_DeclKind_HLSLBuffer, - CX_DeclKind_Label, - CX_DeclKind_Namespace, - CX_DeclKind_NamespaceAlias, - CX_DeclKind_ObjCCompatibleAlias, - CX_DeclKind_ObjCCategory, - CX_DeclKind_ObjCCategoryImpl, - CX_DeclKind_ObjCImplementation, - CX_DeclKind_FirstObjCImpl = CX_DeclKind_ObjCCategoryImpl, - CX_DeclKind_LastObjCImpl = CX_DeclKind_ObjCImplementation, - CX_DeclKind_ObjCInterface, - CX_DeclKind_ObjCProtocol, - CX_DeclKind_FirstObjCContainer = CX_DeclKind_ObjCCategory, - CX_DeclKind_LastObjCContainer = CX_DeclKind_ObjCProtocol, + CX_DeclKind_ExternCContext, + CX_DeclKind_Export, + CX_DeclKind_Captured, + CX_DeclKind_Block, + CX_DeclKind_TopLevelStmt, + CX_DeclKind_StaticAssert, + CX_DeclKind_PragmaDetectMismatch, + CX_DeclKind_PragmaComment, + CX_DeclKind_ObjCPropertyImpl, + CX_DeclKind_OMPThreadPrivate, + CX_DeclKind_OMPRequires, + CX_DeclKind_OMPAllocate, CX_DeclKind_ObjCMethod, - CX_DeclKind_ObjCProperty, - CX_DeclKind_BuiltinTemplate, - CX_DeclKind_Concept, - CX_DeclKind_ClassTemplate, - CX_DeclKind_FunctionTemplate, - CX_DeclKind_TypeAliasTemplate, - CX_DeclKind_VarTemplate, - CX_DeclKind_FirstRedeclarableTemplate = CX_DeclKind_ClassTemplate, - CX_DeclKind_LastRedeclarableTemplate = CX_DeclKind_VarTemplate, - CX_DeclKind_TemplateTemplateParm, - CX_DeclKind_FirstTemplate = CX_DeclKind_BuiltinTemplate, - CX_DeclKind_LastTemplate = CX_DeclKind_TemplateTemplateParm, - CX_DeclKind_Enum, - CX_DeclKind_Record, - CX_DeclKind_CXXRecord, - CX_DeclKind_ClassTemplateSpecialization, - CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_FirstClassTemplateSpecialization = CX_DeclKind_ClassTemplateSpecialization, - CX_DeclKind_LastClassTemplateSpecialization = CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_FirstCXXRecord = CX_DeclKind_CXXRecord, - CX_DeclKind_LastCXXRecord = CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_FirstRecord = CX_DeclKind_Record, - CX_DeclKind_LastRecord = CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_FirstTag = CX_DeclKind_Enum, - CX_DeclKind_LastTag = CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_TemplateTypeParm, - CX_DeclKind_ObjCTypeParam, - CX_DeclKind_TypeAlias, - CX_DeclKind_Typedef, - CX_DeclKind_FirstTypedefName = CX_DeclKind_ObjCTypeParam, - CX_DeclKind_LastTypedefName = CX_DeclKind_Typedef, - CX_DeclKind_UnresolvedUsingTypename, - CX_DeclKind_FirstType = CX_DeclKind_Enum, - CX_DeclKind_LastType = CX_DeclKind_UnresolvedUsingTypename, - CX_DeclKind_UnresolvedUsingIfExists, - CX_DeclKind_UsingDirective, - CX_DeclKind_UsingPack, - CX_DeclKind_UsingShadow, - CX_DeclKind_ConstructorUsingShadow, - CX_DeclKind_FirstUsingShadow = CX_DeclKind_UsingShadow, - CX_DeclKind_LastUsingShadow = CX_DeclKind_ConstructorUsingShadow, - CX_DeclKind_Binding, - CX_DeclKind_Field, - CX_DeclKind_ObjCAtDefsField, - CX_DeclKind_ObjCIvar, - CX_DeclKind_FirstField = CX_DeclKind_Field, - CX_DeclKind_LastField = CX_DeclKind_ObjCIvar, + CX_DeclKind_ObjCProtocol, + CX_DeclKind_ObjCInterface, + CX_DeclKind_ObjCImplementation, + CX_DeclKind_ObjCCategoryImpl, + CX_DeclKind_FirstObjCImpl = CX_DeclKind_ObjCImplementation, + CX_DeclKind_LastObjCImpl = CX_DeclKind_ObjCCategoryImpl, + CX_DeclKind_ObjCCategory, + CX_DeclKind_FirstObjCContainer = CX_DeclKind_ObjCProtocol, + CX_DeclKind_LastObjCContainer = CX_DeclKind_ObjCCategory, + CX_DeclKind_Namespace, + CX_DeclKind_HLSLBuffer, + CX_DeclKind_OMPDeclareReduction, + CX_DeclKind_OMPDeclareMapper, + CX_DeclKind_UnresolvedUsingValue, + CX_DeclKind_UnnamedGlobalConstant, + CX_DeclKind_TemplateParamObject, + CX_DeclKind_MSGuid, + CX_DeclKind_IndirectField, + CX_DeclKind_EnumConstant, CX_DeclKind_Function, - CX_DeclKind_CXXDeductionGuide, CX_DeclKind_CXXMethod, - CX_DeclKind_CXXConstructor, - CX_DeclKind_CXXConversion, CX_DeclKind_CXXDestructor, + CX_DeclKind_CXXConversion, + CX_DeclKind_CXXConstructor, CX_DeclKind_FirstCXXMethod = CX_DeclKind_CXXMethod, - CX_DeclKind_LastCXXMethod = CX_DeclKind_CXXDestructor, + CX_DeclKind_LastCXXMethod = CX_DeclKind_CXXConstructor, + CX_DeclKind_CXXDeductionGuide, CX_DeclKind_FirstFunction = CX_DeclKind_Function, - CX_DeclKind_LastFunction = CX_DeclKind_CXXDestructor, - CX_DeclKind_MSProperty, - CX_DeclKind_NonTypeTemplateParm, + CX_DeclKind_LastFunction = CX_DeclKind_CXXDeductionGuide, CX_DeclKind_Var, - CX_DeclKind_Decomposition, - CX_DeclKind_ImplicitParam, - CX_DeclKind_OMPCapturedExpr, - CX_DeclKind_ParmVar, CX_DeclKind_VarTemplateSpecialization, CX_DeclKind_VarTemplatePartialSpecialization, CX_DeclKind_FirstVarTemplateSpecialization = CX_DeclKind_VarTemplateSpecialization, CX_DeclKind_LastVarTemplateSpecialization = CX_DeclKind_VarTemplatePartialSpecialization, + CX_DeclKind_ParmVar, + CX_DeclKind_OMPCapturedExpr, + CX_DeclKind_ImplicitParam, + CX_DeclKind_Decomposition, CX_DeclKind_FirstVar = CX_DeclKind_Var, - CX_DeclKind_LastVar = CX_DeclKind_VarTemplatePartialSpecialization, - CX_DeclKind_FirstDeclarator = CX_DeclKind_Field, - CX_DeclKind_LastDeclarator = CX_DeclKind_VarTemplatePartialSpecialization, - CX_DeclKind_EnumConstant, - CX_DeclKind_IndirectField, - CX_DeclKind_MSGuid, - CX_DeclKind_OMPDeclareMapper, - CX_DeclKind_OMPDeclareReduction, - CX_DeclKind_TemplateParamObject, - CX_DeclKind_UnnamedGlobalConstant, - CX_DeclKind_UnresolvedUsingValue, - CX_DeclKind_FirstValue = CX_DeclKind_Binding, - CX_DeclKind_LastValue = CX_DeclKind_UnresolvedUsingValue, - CX_DeclKind_FirstNamed = CX_DeclKind_Using, - CX_DeclKind_LastNamed = CX_DeclKind_UnresolvedUsingValue, - CX_DeclKind_OMPAllocate, - CX_DeclKind_OMPRequires, - CX_DeclKind_OMPThreadPrivate, - CX_DeclKind_ObjCPropertyImpl, - CX_DeclKind_PragmaComment, - CX_DeclKind_PragmaDetectMismatch, - CX_DeclKind_RequiresExprBody, - CX_DeclKind_StaticAssert, - CX_DeclKind_TopLevelStmt, - CX_DeclKind_TranslationUnit, - CX_DeclKind_FirstDecl = CX_DeclKind_AccessSpec, - CX_DeclKind_LastDecl = CX_DeclKind_TranslationUnit, + CX_DeclKind_LastVar = CX_DeclKind_Decomposition, + CX_DeclKind_NonTypeTemplateParm, + CX_DeclKind_MSProperty, + CX_DeclKind_Field, + CX_DeclKind_ObjCIvar, + CX_DeclKind_ObjCAtDefsField, + CX_DeclKind_FirstField = CX_DeclKind_Field, + CX_DeclKind_LastField = CX_DeclKind_ObjCAtDefsField, + CX_DeclKind_FirstDeclarator = CX_DeclKind_Function, + CX_DeclKind_LastDeclarator = CX_DeclKind_ObjCAtDefsField, + CX_DeclKind_Binding, + CX_DeclKind_FirstValue = CX_DeclKind_OMPDeclareReduction, + CX_DeclKind_LastValue = CX_DeclKind_Binding, + CX_DeclKind_UsingShadow, + CX_DeclKind_ConstructorUsingShadow, + CX_DeclKind_FirstUsingShadow = CX_DeclKind_UsingShadow, + CX_DeclKind_LastUsingShadow = CX_DeclKind_ConstructorUsingShadow, + CX_DeclKind_UsingPack, + CX_DeclKind_UsingDirective, + CX_DeclKind_UnresolvedUsingIfExists, + CX_DeclKind_Record, + CX_DeclKind_CXXRecord, + CX_DeclKind_ClassTemplateSpecialization, + CX_DeclKind_ClassTemplatePartialSpecialization, + CX_DeclKind_FirstClassTemplateSpecialization = CX_DeclKind_ClassTemplateSpecialization, + CX_DeclKind_LastClassTemplateSpecialization = CX_DeclKind_ClassTemplatePartialSpecialization, + CX_DeclKind_FirstCXXRecord = CX_DeclKind_CXXRecord, + CX_DeclKind_LastCXXRecord = CX_DeclKind_ClassTemplatePartialSpecialization, + CX_DeclKind_FirstRecord = CX_DeclKind_Record, + CX_DeclKind_LastRecord = CX_DeclKind_ClassTemplatePartialSpecialization, + CX_DeclKind_Enum, + CX_DeclKind_FirstTag = CX_DeclKind_Record, + CX_DeclKind_LastTag = CX_DeclKind_Enum, + CX_DeclKind_UnresolvedUsingTypename, + CX_DeclKind_Typedef, + CX_DeclKind_TypeAlias, + CX_DeclKind_ObjCTypeParam, + CX_DeclKind_FirstTypedefName = CX_DeclKind_Typedef, + CX_DeclKind_LastTypedefName = CX_DeclKind_ObjCTypeParam, + CX_DeclKind_TemplateTypeParm, + CX_DeclKind_FirstType = CX_DeclKind_Record, + CX_DeclKind_LastType = CX_DeclKind_TemplateTypeParm, + CX_DeclKind_TemplateTemplateParm, + CX_DeclKind_VarTemplate, + CX_DeclKind_TypeAliasTemplate, + CX_DeclKind_FunctionTemplate, + CX_DeclKind_ClassTemplate, + CX_DeclKind_FirstRedeclarableTemplate = CX_DeclKind_VarTemplate, + CX_DeclKind_LastRedeclarableTemplate = CX_DeclKind_ClassTemplate, + CX_DeclKind_Concept, + CX_DeclKind_BuiltinTemplate, + CX_DeclKind_FirstTemplate = CX_DeclKind_TemplateTemplateParm, + CX_DeclKind_LastTemplate = CX_DeclKind_BuiltinTemplate, + CX_DeclKind_ObjCProperty, + CX_DeclKind_ObjCCompatibleAlias, + CX_DeclKind_NamespaceAlias, + CX_DeclKind_Label, + CX_DeclKind_UsingEnum, + CX_DeclKind_Using, + CX_DeclKind_FirstBaseUsing = CX_DeclKind_UsingEnum, + CX_DeclKind_LastBaseUsing = CX_DeclKind_Using, + CX_DeclKind_FirstNamed = CX_DeclKind_ObjCMethod, + CX_DeclKind_LastNamed = CX_DeclKind_Using, + CX_DeclKind_LifetimeExtendedTemporary, + CX_DeclKind_Import, + CX_DeclKind_ImplicitConceptSpecialization, + CX_DeclKind_FriendTemplate, + CX_DeclKind_Friend, + CX_DeclKind_FileScopeAsm, + CX_DeclKind_Empty, + CX_DeclKind_AccessSpec, + CX_DeclKind_FirstDecl = CX_DeclKind_TranslationUnit, + CX_DeclKind_LastDecl = CX_DeclKind_AccessSpec, } diff --git a/sources/ClangSharp.Interop/clangsharp/CX_FloatingSemantics.cs b/sources/ClangSharp.Interop/clangsharp/CX_FloatingSemantics.cs index 717bf1b1..e76a082d 100644 --- a/sources/ClangSharp.Interop/clangsharp/CX_FloatingSemantics.cs +++ b/sources/ClangSharp.Interop/clangsharp/CX_FloatingSemantics.cs @@ -10,7 +10,14 @@ public enum CX_FloatingSemantics CX_FLK_BFloat, CX_FLK_IEEEsingle, CX_FLK_IEEEdouble, - CX_FLK_x87DoubleExtended, CX_FLK_IEEEquad, CX_FLK_PPCDoubleDouble, + CX_FLK_Float8E5M2, + CX_FLK_Float8E5M2FNUZ, + CX_FLK_Float8E4M3FN, + CX_FLK_Float8E4M3FNUZ, + CX_FLK_Float8E4M3B11FNUZ, + CX_FLK_FloatTF32, + CX_FLK_x87DoubleExtended, + CX_FLK_MaxSemantics = CX_FLK_x87DoubleExtended, } diff --git a/sources/ClangSharp.Interop/clangsharp/CX_StmtClass.cs b/sources/ClangSharp.Interop/clangsharp/CX_StmtClass.cs index 31294d5a..0c5dba6f 100644 --- a/sources/ClangSharp.Interop/clangsharp/CX_StmtClass.cs +++ b/sources/ClangSharp.Interop/clangsharp/CX_StmtClass.cs @@ -6,275 +6,276 @@ namespace ClangSharp.Interop; public enum CX_StmtClass { CX_StmtClass_Invalid, - CX_StmtClass_GCCAsmStmt, - CX_StmtClass_MSAsmStmt, - CX_StmtClass_FirstAsmStmt = CX_StmtClass_GCCAsmStmt, - CX_StmtClass_LastAsmStmt = CX_StmtClass_MSAsmStmt, - CX_StmtClass_BreakStmt, - CX_StmtClass_CXXCatchStmt, - CX_StmtClass_CXXForRangeStmt, - CX_StmtClass_CXXTryStmt, - CX_StmtClass_CapturedStmt, - CX_StmtClass_CompoundStmt, - CX_StmtClass_ContinueStmt, - CX_StmtClass_CoreturnStmt, - CX_StmtClass_CoroutineBodyStmt, - CX_StmtClass_DeclStmt, - CX_StmtClass_DoStmt, - CX_StmtClass_ForStmt, - CX_StmtClass_GotoStmt, - CX_StmtClass_IfStmt, - CX_StmtClass_IndirectGotoStmt, - CX_StmtClass_MSDependentExistsStmt, - CX_StmtClass_NullStmt, - CX_StmtClass_OMPCanonicalLoop, - CX_StmtClass_OMPAtomicDirective, - CX_StmtClass_OMPBarrierDirective, - CX_StmtClass_OMPCancelDirective, - CX_StmtClass_OMPCancellationPointDirective, - CX_StmtClass_OMPCriticalDirective, - CX_StmtClass_OMPDepobjDirective, - CX_StmtClass_OMPDispatchDirective, - CX_StmtClass_OMPErrorDirective, - CX_StmtClass_OMPFlushDirective, - CX_StmtClass_OMPInteropDirective, - CX_StmtClass_OMPDistributeDirective, - CX_StmtClass_OMPDistributeParallelForDirective, - CX_StmtClass_OMPDistributeParallelForSimdDirective, - CX_StmtClass_OMPDistributeSimdDirective, - CX_StmtClass_OMPForDirective, - CX_StmtClass_OMPForSimdDirective, - CX_StmtClass_OMPGenericLoopDirective, - CX_StmtClass_OMPMaskedTaskLoopDirective, - CX_StmtClass_OMPMaskedTaskLoopSimdDirective, - CX_StmtClass_OMPMasterTaskLoopDirective, - CX_StmtClass_OMPMasterTaskLoopSimdDirective, - CX_StmtClass_OMPParallelForDirective, - CX_StmtClass_OMPParallelForSimdDirective, - CX_StmtClass_OMPParallelGenericLoopDirective, - CX_StmtClass_OMPParallelMaskedTaskLoopDirective, - CX_StmtClass_OMPParallelMaskedTaskLoopSimdDirective, - CX_StmtClass_OMPParallelMasterTaskLoopDirective, - CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective, - CX_StmtClass_OMPSimdDirective, - CX_StmtClass_OMPTargetParallelForSimdDirective, - CX_StmtClass_OMPTargetParallelGenericLoopDirective, - CX_StmtClass_OMPTargetSimdDirective, - CX_StmtClass_OMPTargetTeamsDistributeDirective, - CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective, - CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective, - CX_StmtClass_OMPTargetTeamsDistributeSimdDirective, - CX_StmtClass_OMPTargetTeamsGenericLoopDirective, - CX_StmtClass_OMPTaskLoopDirective, - CX_StmtClass_OMPTaskLoopSimdDirective, - CX_StmtClass_OMPTeamsDistributeDirective, - CX_StmtClass_OMPTeamsDistributeParallelForDirective, - CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective, - CX_StmtClass_OMPTeamsDistributeSimdDirective, - CX_StmtClass_OMPTeamsGenericLoopDirective, - CX_StmtClass_FirstOMPLoopDirective = CX_StmtClass_OMPDistributeDirective, - CX_StmtClass_LastOMPLoopDirective = CX_StmtClass_OMPTeamsGenericLoopDirective, - CX_StmtClass_OMPTileDirective, - CX_StmtClass_OMPUnrollDirective, - CX_StmtClass_FirstOMPLoopTransformationDirective = CX_StmtClass_OMPTileDirective, - CX_StmtClass_LastOMPLoopTransformationDirective = CX_StmtClass_OMPUnrollDirective, - CX_StmtClass_FirstOMPLoopBasedDirective = CX_StmtClass_OMPDistributeDirective, - CX_StmtClass_LastOMPLoopBasedDirective = CX_StmtClass_OMPUnrollDirective, - CX_StmtClass_OMPMaskedDirective, - CX_StmtClass_OMPMasterDirective, - CX_StmtClass_OMPMetaDirective, - CX_StmtClass_OMPOrderedDirective, - CX_StmtClass_OMPParallelDirective, - CX_StmtClass_OMPParallelMaskedDirective, - CX_StmtClass_OMPParallelMasterDirective, - CX_StmtClass_OMPParallelSectionsDirective, - CX_StmtClass_OMPScanDirective, - CX_StmtClass_OMPSectionDirective, - CX_StmtClass_OMPSectionsDirective, - CX_StmtClass_OMPSingleDirective, - CX_StmtClass_OMPTargetDataDirective, - CX_StmtClass_OMPTargetDirective, - CX_StmtClass_OMPTargetEnterDataDirective, - CX_StmtClass_OMPTargetExitDataDirective, - CX_StmtClass_OMPTargetParallelDirective, - CX_StmtClass_OMPTargetParallelForDirective, - CX_StmtClass_OMPTargetTeamsDirective, - CX_StmtClass_OMPTargetUpdateDirective, - CX_StmtClass_OMPTaskDirective, - CX_StmtClass_OMPTaskgroupDirective, - CX_StmtClass_OMPTaskwaitDirective, - CX_StmtClass_OMPTaskyieldDirective, - CX_StmtClass_OMPTeamsDirective, - CX_StmtClass_FirstOMPExecutableDirective = CX_StmtClass_OMPAtomicDirective, - CX_StmtClass_LastOMPExecutableDirective = CX_StmtClass_OMPTeamsDirective, - CX_StmtClass_ObjCAtCatchStmt, - CX_StmtClass_ObjCAtFinallyStmt, - CX_StmtClass_ObjCAtSynchronizedStmt, - CX_StmtClass_ObjCAtThrowStmt, - CX_StmtClass_ObjCAtTryStmt, - CX_StmtClass_ObjCAutoreleasePoolStmt, - CX_StmtClass_ObjCForCollectionStmt, - CX_StmtClass_ReturnStmt, - CX_StmtClass_SEHExceptStmt, - CX_StmtClass_SEHFinallyStmt, - CX_StmtClass_SEHLeaveStmt, - CX_StmtClass_SEHTryStmt, - CX_StmtClass_CaseStmt, - CX_StmtClass_DefaultStmt, - CX_StmtClass_FirstSwitchCase = CX_StmtClass_CaseStmt, - CX_StmtClass_LastSwitchCase = CX_StmtClass_DefaultStmt, - CX_StmtClass_SwitchStmt, - CX_StmtClass_AttributedStmt, - CX_StmtClass_BinaryConditionalOperator, - CX_StmtClass_ConditionalOperator, - CX_StmtClass_FirstAbstractConditionalOperator = CX_StmtClass_BinaryConditionalOperator, - CX_StmtClass_LastAbstractConditionalOperator = CX_StmtClass_ConditionalOperator, - CX_StmtClass_AddrLabelExpr, - CX_StmtClass_ArrayInitIndexExpr, - CX_StmtClass_ArrayInitLoopExpr, - CX_StmtClass_ArraySubscriptExpr, - CX_StmtClass_ArrayTypeTraitExpr, - CX_StmtClass_AsTypeExpr, - CX_StmtClass_AtomicExpr, - CX_StmtClass_BinaryOperator, - CX_StmtClass_CompoundAssignOperator, - CX_StmtClass_FirstBinaryOperator = CX_StmtClass_BinaryOperator, - CX_StmtClass_LastBinaryOperator = CX_StmtClass_CompoundAssignOperator, - CX_StmtClass_BlockExpr, - CX_StmtClass_CXXBindTemporaryExpr, - CX_StmtClass_CXXBoolLiteralExpr, + CX_StmtClass_WhileStmt, + CX_StmtClass_LabelStmt, + CX_StmtClass_VAArgExpr, + CX_StmtClass_UnaryOperator, + CX_StmtClass_UnaryExprOrTypeTraitExpr, + CX_StmtClass_TypoExpr, + CX_StmtClass_TypeTraitExpr, + CX_StmtClass_SubstNonTypeTemplateParmPackExpr, + CX_StmtClass_SubstNonTypeTemplateParmExpr, + CX_StmtClass_StringLiteral, + CX_StmtClass_StmtExpr, + CX_StmtClass_SourceLocExpr, + CX_StmtClass_SizeOfPackExpr, + CX_StmtClass_ShuffleVectorExpr, + CX_StmtClass_SYCLUniqueStableNameExpr, + CX_StmtClass_RequiresExpr, + CX_StmtClass_RecoveryExpr, + CX_StmtClass_PseudoObjectExpr, + CX_StmtClass_PredefinedExpr, + CX_StmtClass_ParenListExpr, + CX_StmtClass_ParenExpr, + CX_StmtClass_PackExpansionExpr, + CX_StmtClass_UnresolvedMemberExpr, + CX_StmtClass_UnresolvedLookupExpr, + CX_StmtClass_FirstOverloadExpr = CX_StmtClass_UnresolvedMemberExpr, + CX_StmtClass_LastOverloadExpr = CX_StmtClass_UnresolvedLookupExpr, + CX_StmtClass_OpaqueValueExpr, + CX_StmtClass_OffsetOfExpr, + CX_StmtClass_ObjCSubscriptRefExpr, + CX_StmtClass_ObjCStringLiteral, + CX_StmtClass_ObjCSelectorExpr, + CX_StmtClass_ObjCProtocolExpr, + CX_StmtClass_ObjCPropertyRefExpr, + CX_StmtClass_ObjCMessageExpr, + CX_StmtClass_ObjCIvarRefExpr, + CX_StmtClass_ObjCIsaExpr, + CX_StmtClass_ObjCIndirectCopyRestoreExpr, + CX_StmtClass_ObjCEncodeExpr, + CX_StmtClass_ObjCDictionaryLiteral, + CX_StmtClass_ObjCBoxedExpr, + CX_StmtClass_ObjCBoolLiteralExpr, + CX_StmtClass_ObjCAvailabilityCheckExpr, + CX_StmtClass_ObjCArrayLiteral, + CX_StmtClass_OMPIteratorExpr, + CX_StmtClass_OMPArrayShapingExpr, + CX_StmtClass_OMPArraySectionExpr, + CX_StmtClass_NoInitExpr, + CX_StmtClass_MemberExpr, + CX_StmtClass_MatrixSubscriptExpr, + CX_StmtClass_MaterializeTemporaryExpr, + CX_StmtClass_MSPropertySubscriptExpr, + CX_StmtClass_MSPropertyRefExpr, + CX_StmtClass_LambdaExpr, + CX_StmtClass_IntegerLiteral, + CX_StmtClass_InitListExpr, + CX_StmtClass_ImplicitValueInitExpr, + CX_StmtClass_ImaginaryLiteral, + CX_StmtClass_GenericSelectionExpr, + CX_StmtClass_GNUNullExpr, + CX_StmtClass_FunctionParmPackExpr, + CX_StmtClass_ExprWithCleanups, + CX_StmtClass_ConstantExpr, + CX_StmtClass_FirstFullExpr = CX_StmtClass_ExprWithCleanups, + CX_StmtClass_LastFullExpr = CX_StmtClass_ConstantExpr, + CX_StmtClass_FloatingLiteral, + CX_StmtClass_FixedPointLiteral, + CX_StmtClass_ExtVectorElementExpr, + CX_StmtClass_ExpressionTraitExpr, + CX_StmtClass_DesignatedInitUpdateExpr, + CX_StmtClass_DesignatedInitExpr, + CX_StmtClass_DependentScopeDeclRefExpr, + CX_StmtClass_DependentCoawaitExpr, + CX_StmtClass_DeclRefExpr, + CX_StmtClass_CoyieldExpr, + CX_StmtClass_CoawaitExpr, + CX_StmtClass_FirstCoroutineSuspendExpr = CX_StmtClass_CoyieldExpr, + CX_StmtClass_LastCoroutineSuspendExpr = CX_StmtClass_CoawaitExpr, + CX_StmtClass_ConvertVectorExpr, + CX_StmtClass_ConceptSpecializationExpr, + CX_StmtClass_CompoundLiteralExpr, + CX_StmtClass_ChooseExpr, + CX_StmtClass_CharacterLiteral, + CX_StmtClass_ImplicitCastExpr, + CX_StmtClass_ObjCBridgedCastExpr, + CX_StmtClass_CXXStaticCastExpr, + CX_StmtClass_CXXReinterpretCastExpr, + CX_StmtClass_CXXDynamicCastExpr, + CX_StmtClass_CXXConstCastExpr, + CX_StmtClass_CXXAddrspaceCastExpr, + CX_StmtClass_FirstCXXNamedCastExpr = CX_StmtClass_CXXStaticCastExpr, + CX_StmtClass_LastCXXNamedCastExpr = CX_StmtClass_CXXAddrspaceCastExpr, + CX_StmtClass_CXXFunctionalCastExpr, + CX_StmtClass_CStyleCastExpr, + CX_StmtClass_BuiltinBitCastExpr, + CX_StmtClass_FirstExplicitCastExpr = CX_StmtClass_ObjCBridgedCastExpr, + CX_StmtClass_LastExplicitCastExpr = CX_StmtClass_BuiltinBitCastExpr, + CX_StmtClass_FirstCastExpr = CX_StmtClass_ImplicitCastExpr, + CX_StmtClass_LastCastExpr = CX_StmtClass_BuiltinBitCastExpr, + CX_StmtClass_CallExpr, + CX_StmtClass_UserDefinedLiteral, + CX_StmtClass_CXXOperatorCallExpr, + CX_StmtClass_CXXMemberCallExpr, + CX_StmtClass_CUDAKernelCallExpr, + CX_StmtClass_FirstCallExpr = CX_StmtClass_CallExpr, + CX_StmtClass_LastCallExpr = CX_StmtClass_CUDAKernelCallExpr, + CX_StmtClass_CXXUuidofExpr, + CX_StmtClass_CXXUnresolvedConstructExpr, + CX_StmtClass_CXXTypeidExpr, + CX_StmtClass_CXXThrowExpr, + CX_StmtClass_CXXThisExpr, + CX_StmtClass_CXXStdInitializerListExpr, + CX_StmtClass_CXXScalarValueInitExpr, + CX_StmtClass_CXXRewrittenBinaryOperator, + CX_StmtClass_CXXPseudoDestructorExpr, + CX_StmtClass_CXXParenListInitExpr, + CX_StmtClass_CXXNullPtrLiteralExpr, + CX_StmtClass_CXXNoexceptExpr, + CX_StmtClass_CXXNewExpr, + CX_StmtClass_CXXInheritedCtorInitExpr, + CX_StmtClass_CXXFoldExpr, + CX_StmtClass_CXXDependentScopeMemberExpr, + CX_StmtClass_CXXDeleteExpr, + CX_StmtClass_CXXDefaultInitExpr, + CX_StmtClass_CXXDefaultArgExpr, CX_StmtClass_CXXConstructExpr, CX_StmtClass_CXXTemporaryObjectExpr, CX_StmtClass_FirstCXXConstructExpr = CX_StmtClass_CXXConstructExpr, CX_StmtClass_LastCXXConstructExpr = CX_StmtClass_CXXTemporaryObjectExpr, - CX_StmtClass_CXXDefaultArgExpr, - CX_StmtClass_CXXDefaultInitExpr, - CX_StmtClass_CXXDeleteExpr, - CX_StmtClass_CXXDependentScopeMemberExpr, - CX_StmtClass_CXXFoldExpr, - CX_StmtClass_CXXInheritedCtorInitExpr, - CX_StmtClass_CXXNewExpr, - CX_StmtClass_CXXNoexceptExpr, - CX_StmtClass_CXXNullPtrLiteralExpr, - CX_StmtClass_CXXParenListInitExpr, - CX_StmtClass_CXXPseudoDestructorExpr, - CX_StmtClass_CXXRewrittenBinaryOperator, - CX_StmtClass_CXXScalarValueInitExpr, - CX_StmtClass_CXXStdInitializerListExpr, - CX_StmtClass_CXXThisExpr, - CX_StmtClass_CXXThrowExpr, - CX_StmtClass_CXXTypeidExpr, - CX_StmtClass_CXXUnresolvedConstructExpr, - CX_StmtClass_CXXUuidofExpr, - CX_StmtClass_CallExpr, - CX_StmtClass_CUDAKernelCallExpr, - CX_StmtClass_CXXMemberCallExpr, - CX_StmtClass_CXXOperatorCallExpr, - CX_StmtClass_UserDefinedLiteral, - CX_StmtClass_FirstCallExpr = CX_StmtClass_CallExpr, - CX_StmtClass_LastCallExpr = CX_StmtClass_UserDefinedLiteral, - CX_StmtClass_BuiltinBitCastExpr, - CX_StmtClass_CStyleCastExpr, - CX_StmtClass_CXXFunctionalCastExpr, - CX_StmtClass_CXXAddrspaceCastExpr, - CX_StmtClass_CXXConstCastExpr, - CX_StmtClass_CXXDynamicCastExpr, - CX_StmtClass_CXXReinterpretCastExpr, - CX_StmtClass_CXXStaticCastExpr, - CX_StmtClass_FirstCXXNamedCastExpr = CX_StmtClass_CXXAddrspaceCastExpr, - CX_StmtClass_LastCXXNamedCastExpr = CX_StmtClass_CXXStaticCastExpr, - CX_StmtClass_ObjCBridgedCastExpr, - CX_StmtClass_FirstExplicitCastExpr = CX_StmtClass_BuiltinBitCastExpr, - CX_StmtClass_LastExplicitCastExpr = CX_StmtClass_ObjCBridgedCastExpr, - CX_StmtClass_ImplicitCastExpr, - CX_StmtClass_FirstCastExpr = CX_StmtClass_BuiltinBitCastExpr, - CX_StmtClass_LastCastExpr = CX_StmtClass_ImplicitCastExpr, - CX_StmtClass_CharacterLiteral, - CX_StmtClass_ChooseExpr, - CX_StmtClass_CompoundLiteralExpr, - CX_StmtClass_ConceptSpecializationExpr, - CX_StmtClass_ConvertVectorExpr, - CX_StmtClass_CoawaitExpr, - CX_StmtClass_CoyieldExpr, - CX_StmtClass_FirstCoroutineSuspendExpr = CX_StmtClass_CoawaitExpr, - CX_StmtClass_LastCoroutineSuspendExpr = CX_StmtClass_CoyieldExpr, - CX_StmtClass_DeclRefExpr, - CX_StmtClass_DependentCoawaitExpr, - CX_StmtClass_DependentScopeDeclRefExpr, - CX_StmtClass_DesignatedInitExpr, - CX_StmtClass_DesignatedInitUpdateExpr, - CX_StmtClass_ExpressionTraitExpr, - CX_StmtClass_ExtVectorElementExpr, - CX_StmtClass_FixedPointLiteral, - CX_StmtClass_FloatingLiteral, - CX_StmtClass_ConstantExpr, - CX_StmtClass_ExprWithCleanups, - CX_StmtClass_FirstFullExpr = CX_StmtClass_ConstantExpr, - CX_StmtClass_LastFullExpr = CX_StmtClass_ExprWithCleanups, - CX_StmtClass_FunctionParmPackExpr, - CX_StmtClass_GNUNullExpr, - CX_StmtClass_GenericSelectionExpr, - CX_StmtClass_ImaginaryLiteral, - CX_StmtClass_ImplicitValueInitExpr, - CX_StmtClass_InitListExpr, - CX_StmtClass_IntegerLiteral, - CX_StmtClass_LambdaExpr, - CX_StmtClass_MSPropertyRefExpr, - CX_StmtClass_MSPropertySubscriptExpr, - CX_StmtClass_MaterializeTemporaryExpr, - CX_StmtClass_MatrixSubscriptExpr, - CX_StmtClass_MemberExpr, - CX_StmtClass_NoInitExpr, - CX_StmtClass_OMPArraySectionExpr, - CX_StmtClass_OMPArrayShapingExpr, - CX_StmtClass_OMPIteratorExpr, - CX_StmtClass_ObjCArrayLiteral, - CX_StmtClass_ObjCAvailabilityCheckExpr, - CX_StmtClass_ObjCBoolLiteralExpr, - CX_StmtClass_ObjCBoxedExpr, - CX_StmtClass_ObjCDictionaryLiteral, - CX_StmtClass_ObjCEncodeExpr, - CX_StmtClass_ObjCIndirectCopyRestoreExpr, - CX_StmtClass_ObjCIsaExpr, - CX_StmtClass_ObjCIvarRefExpr, - CX_StmtClass_ObjCMessageExpr, - CX_StmtClass_ObjCPropertyRefExpr, - CX_StmtClass_ObjCProtocolExpr, - CX_StmtClass_ObjCSelectorExpr, - CX_StmtClass_ObjCStringLiteral, - CX_StmtClass_ObjCSubscriptRefExpr, - CX_StmtClass_OffsetOfExpr, - CX_StmtClass_OpaqueValueExpr, - CX_StmtClass_UnresolvedLookupExpr, - CX_StmtClass_UnresolvedMemberExpr, - CX_StmtClass_FirstOverloadExpr = CX_StmtClass_UnresolvedLookupExpr, - CX_StmtClass_LastOverloadExpr = CX_StmtClass_UnresolvedMemberExpr, - CX_StmtClass_PackExpansionExpr, - CX_StmtClass_ParenExpr, - CX_StmtClass_ParenListExpr, - CX_StmtClass_PredefinedExpr, - CX_StmtClass_PseudoObjectExpr, - CX_StmtClass_RecoveryExpr, - CX_StmtClass_RequiresExpr, - CX_StmtClass_SYCLUniqueStableNameExpr, - CX_StmtClass_ShuffleVectorExpr, - CX_StmtClass_SizeOfPackExpr, - CX_StmtClass_SourceLocExpr, - CX_StmtClass_StmtExpr, - CX_StmtClass_StringLiteral, - CX_StmtClass_SubstNonTypeTemplateParmExpr, - CX_StmtClass_SubstNonTypeTemplateParmPackExpr, - CX_StmtClass_TypeTraitExpr, - CX_StmtClass_TypoExpr, - CX_StmtClass_UnaryExprOrTypeTraitExpr, - CX_StmtClass_UnaryOperator, - CX_StmtClass_VAArgExpr, - CX_StmtClass_FirstExpr = CX_StmtClass_BinaryConditionalOperator, - CX_StmtClass_LastExpr = CX_StmtClass_VAArgExpr, - CX_StmtClass_LabelStmt, - CX_StmtClass_FirstValueStmt = CX_StmtClass_AttributedStmt, - CX_StmtClass_LastValueStmt = CX_StmtClass_LabelStmt, - CX_StmtClass_WhileStmt, - CX_StmtClass_FirstStmt = CX_StmtClass_GCCAsmStmt, - CX_StmtClass_LastStmt = CX_StmtClass_WhileStmt, + CX_StmtClass_CXXBoolLiteralExpr, + CX_StmtClass_CXXBindTemporaryExpr, + CX_StmtClass_BlockExpr, + CX_StmtClass_BinaryOperator, + CX_StmtClass_CompoundAssignOperator, + CX_StmtClass_FirstBinaryOperator = CX_StmtClass_BinaryOperator, + CX_StmtClass_LastBinaryOperator = CX_StmtClass_CompoundAssignOperator, + CX_StmtClass_AtomicExpr, + CX_StmtClass_AsTypeExpr, + CX_StmtClass_ArrayTypeTraitExpr, + CX_StmtClass_ArraySubscriptExpr, + CX_StmtClass_ArrayInitLoopExpr, + CX_StmtClass_ArrayInitIndexExpr, + CX_StmtClass_AddrLabelExpr, + CX_StmtClass_ConditionalOperator, + CX_StmtClass_BinaryConditionalOperator, + CX_StmtClass_FirstAbstractConditionalOperator = CX_StmtClass_ConditionalOperator, + CX_StmtClass_LastAbstractConditionalOperator = CX_StmtClass_BinaryConditionalOperator, + CX_StmtClass_FirstExpr = CX_StmtClass_VAArgExpr, + CX_StmtClass_LastExpr = CX_StmtClass_BinaryConditionalOperator, + CX_StmtClass_AttributedStmt, + CX_StmtClass_FirstValueStmt = CX_StmtClass_LabelStmt, + CX_StmtClass_LastValueStmt = CX_StmtClass_AttributedStmt, + CX_StmtClass_SwitchStmt, + CX_StmtClass_DefaultStmt, + CX_StmtClass_CaseStmt, + CX_StmtClass_FirstSwitchCase = CX_StmtClass_DefaultStmt, + CX_StmtClass_LastSwitchCase = CX_StmtClass_CaseStmt, + CX_StmtClass_SEHTryStmt, + CX_StmtClass_SEHLeaveStmt, + CX_StmtClass_SEHFinallyStmt, + CX_StmtClass_SEHExceptStmt, + CX_StmtClass_ReturnStmt, + CX_StmtClass_ObjCForCollectionStmt, + CX_StmtClass_ObjCAutoreleasePoolStmt, + CX_StmtClass_ObjCAtTryStmt, + CX_StmtClass_ObjCAtThrowStmt, + CX_StmtClass_ObjCAtSynchronizedStmt, + CX_StmtClass_ObjCAtFinallyStmt, + CX_StmtClass_ObjCAtCatchStmt, + CX_StmtClass_OMPTeamsDirective, + CX_StmtClass_OMPTaskyieldDirective, + CX_StmtClass_OMPTaskwaitDirective, + CX_StmtClass_OMPTaskgroupDirective, + CX_StmtClass_OMPTaskDirective, + CX_StmtClass_OMPTargetUpdateDirective, + CX_StmtClass_OMPTargetTeamsDirective, + CX_StmtClass_OMPTargetParallelForDirective, + CX_StmtClass_OMPTargetParallelDirective, + CX_StmtClass_OMPTargetExitDataDirective, + CX_StmtClass_OMPTargetEnterDataDirective, + CX_StmtClass_OMPTargetDirective, + CX_StmtClass_OMPTargetDataDirective, + CX_StmtClass_OMPSingleDirective, + CX_StmtClass_OMPSectionsDirective, + CX_StmtClass_OMPSectionDirective, + CX_StmtClass_OMPScopeDirective, + CX_StmtClass_OMPScanDirective, + CX_StmtClass_OMPParallelSectionsDirective, + CX_StmtClass_OMPParallelMasterDirective, + CX_StmtClass_OMPParallelMaskedDirective, + CX_StmtClass_OMPParallelDirective, + CX_StmtClass_OMPOrderedDirective, + CX_StmtClass_OMPMetaDirective, + CX_StmtClass_OMPMasterDirective, + CX_StmtClass_OMPMaskedDirective, + CX_StmtClass_OMPUnrollDirective, + CX_StmtClass_OMPTileDirective, + CX_StmtClass_FirstOMPLoopTransformationDirective = CX_StmtClass_OMPUnrollDirective, + CX_StmtClass_LastOMPLoopTransformationDirective = CX_StmtClass_OMPTileDirective, + CX_StmtClass_OMPTeamsGenericLoopDirective, + CX_StmtClass_OMPTeamsDistributeSimdDirective, + CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective, + CX_StmtClass_OMPTeamsDistributeParallelForDirective, + CX_StmtClass_OMPTeamsDistributeDirective, + CX_StmtClass_OMPTaskLoopSimdDirective, + CX_StmtClass_OMPTaskLoopDirective, + CX_StmtClass_OMPTargetTeamsGenericLoopDirective, + CX_StmtClass_OMPTargetTeamsDistributeSimdDirective, + CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective, + CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective, + CX_StmtClass_OMPTargetTeamsDistributeDirective, + CX_StmtClass_OMPTargetSimdDirective, + CX_StmtClass_OMPTargetParallelGenericLoopDirective, + CX_StmtClass_OMPTargetParallelForSimdDirective, + CX_StmtClass_OMPSimdDirective, + CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective, + CX_StmtClass_OMPParallelMasterTaskLoopDirective, + CX_StmtClass_OMPParallelMaskedTaskLoopSimdDirective, + CX_StmtClass_OMPParallelMaskedTaskLoopDirective, + CX_StmtClass_OMPParallelGenericLoopDirective, + CX_StmtClass_OMPParallelForSimdDirective, + CX_StmtClass_OMPParallelForDirective, + CX_StmtClass_OMPMasterTaskLoopSimdDirective, + CX_StmtClass_OMPMasterTaskLoopDirective, + CX_StmtClass_OMPMaskedTaskLoopSimdDirective, + CX_StmtClass_OMPMaskedTaskLoopDirective, + CX_StmtClass_OMPGenericLoopDirective, + CX_StmtClass_OMPForSimdDirective, + CX_StmtClass_OMPForDirective, + CX_StmtClass_OMPDistributeSimdDirective, + CX_StmtClass_OMPDistributeParallelForSimdDirective, + CX_StmtClass_OMPDistributeParallelForDirective, + CX_StmtClass_OMPDistributeDirective, + CX_StmtClass_FirstOMPLoopDirective = CX_StmtClass_OMPTeamsGenericLoopDirective, + CX_StmtClass_LastOMPLoopDirective = CX_StmtClass_OMPDistributeDirective, + CX_StmtClass_FirstOMPLoopBasedDirective = CX_StmtClass_OMPUnrollDirective, + CX_StmtClass_LastOMPLoopBasedDirective = CX_StmtClass_OMPDistributeDirective, + CX_StmtClass_OMPInteropDirective, + CX_StmtClass_OMPFlushDirective, + CX_StmtClass_OMPErrorDirective, + CX_StmtClass_OMPDispatchDirective, + CX_StmtClass_OMPDepobjDirective, + CX_StmtClass_OMPCriticalDirective, + CX_StmtClass_OMPCancellationPointDirective, + CX_StmtClass_OMPCancelDirective, + CX_StmtClass_OMPBarrierDirective, + CX_StmtClass_OMPAtomicDirective, + CX_StmtClass_FirstOMPExecutableDirective = CX_StmtClass_OMPTeamsDirective, + CX_StmtClass_LastOMPExecutableDirective = CX_StmtClass_OMPAtomicDirective, + CX_StmtClass_OMPCanonicalLoop, + CX_StmtClass_NullStmt, + CX_StmtClass_MSDependentExistsStmt, + CX_StmtClass_IndirectGotoStmt, + CX_StmtClass_IfStmt, + CX_StmtClass_GotoStmt, + CX_StmtClass_ForStmt, + CX_StmtClass_DoStmt, + CX_StmtClass_DeclStmt, + CX_StmtClass_CoroutineBodyStmt, + CX_StmtClass_CoreturnStmt, + CX_StmtClass_ContinueStmt, + CX_StmtClass_CompoundStmt, + CX_StmtClass_CapturedStmt, + CX_StmtClass_CXXTryStmt, + CX_StmtClass_CXXForRangeStmt, + CX_StmtClass_CXXCatchStmt, + CX_StmtClass_BreakStmt, + CX_StmtClass_MSAsmStmt, + CX_StmtClass_GCCAsmStmt, + CX_StmtClass_FirstAsmStmt = CX_StmtClass_MSAsmStmt, + CX_StmtClass_LastAsmStmt = CX_StmtClass_GCCAsmStmt, + CX_StmtClass_FirstStmt = CX_StmtClass_WhileStmt, + CX_StmtClass_LastStmt = CX_StmtClass_GCCAsmStmt, } diff --git a/sources/ClangSharp.Interop/clangsharp/CX_StringKind.cs b/sources/ClangSharp.Interop/clangsharp/CX_StringKind.cs new file mode 100644 index 00000000..ab614c16 --- /dev/null +++ b/sources/ClangSharp.Interop/clangsharp/CX_StringKind.cs @@ -0,0 +1,15 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. +// Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp + +namespace ClangSharp.Interop; + +public enum CX_StringKind +{ + CX_SLK_Invalid, + CX_SLK_Ordinary, + CX_SLK_Wide, + CX_SLK_UTF8, + CX_SLK_UTF16, + CX_SLK_UTF32, + CX_SLK_Unevaluated, +} diff --git a/sources/ClangSharp.Interop/clangsharp/CX_TemplateNameKind.cs b/sources/ClangSharp.Interop/clangsharp/CX_TemplateNameKind.cs index 5c44aa3a..e0358a00 100644 --- a/sources/ClangSharp.Interop/clangsharp/CX_TemplateNameKind.cs +++ b/sources/ClangSharp.Interop/clangsharp/CX_TemplateNameKind.cs @@ -13,4 +13,5 @@ public enum CX_TemplateNameKind CX_TNK_DependentTemplate, CX_TNK_SubstTemplateTemplateParm, CX_TNK_SubstTemplateTemplateParmPack, + CX_TNK_UsingTemplate, } diff --git a/sources/ClangSharp.Interop/clangsharp/CX_UnaryExprOrTypeTrait.cs b/sources/ClangSharp.Interop/clangsharp/CX_UnaryExprOrTypeTrait.cs index 3d2450ac..24a2b68c 100644 --- a/sources/ClangSharp.Interop/clangsharp/CX_UnaryExprOrTypeTrait.cs +++ b/sources/ClangSharp.Interop/clangsharp/CX_UnaryExprOrTypeTrait.cs @@ -7,9 +7,11 @@ public enum CX_UnaryExprOrTypeTrait { CX_UETT_Invalid, CX_UETT_SizeOf, + CX_UETT_DataSizeOf, CX_UETT_AlignOf, CX_UETT_PreferredAlignOf, CX_UETT_VecStep, CX_UETT_OpenMPRequiredSimdAlign, - CX_UETT_Last = -1 + 1 + 1 + 1 + 1 + 1, + CX_UETT_VectorElements, + CX_UETT_Last = -1 + 1 + 1 + 1 + 1 + 1 + 1 + 1, } diff --git a/sources/ClangSharp.Interop/clangsharp/clangsharp.cs b/sources/ClangSharp.Interop/clangsharp/clangsharp.cs index 1c675a8e..91979977 100644 --- a/sources/ClangSharp.Interop/clangsharp/clangsharp.cs +++ b/sources/ClangSharp.Interop/clangsharp/clangsharp.cs @@ -270,6 +270,14 @@ public static partial class @clangsharp [return: NativeTypeName("unsigned int")] public static extern uint Cursor_getHasDefaultArg(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUnparsedDefaultArg", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasUnparsedDefaultArg(CXCursor C); + + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUninstantiatedDefaultArg", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasUninstantiatedDefaultArg(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasElseStorage", ExactSpelling = true)] [return: NativeTypeName("unsigned int")] public static extern uint Cursor_getHasElseStorage(CXCursor C); @@ -540,9 +548,9 @@ public static partial class @clangsharp [return: NativeTypeName("unsigned int")] public static extern uint Cursor_getIsPotentiallyEvaluated(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPure", ExactSpelling = true)] + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPureVirtual", ExactSpelling = true)] [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsPure(CXCursor C); + public static extern uint Cursor_getIsPureVirtual(CXCursor C); [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsResultDependent", ExactSpelling = true)] [return: NativeTypeName("unsigned int")] @@ -791,6 +799,9 @@ public static partial class @clangsharp [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getStmtClass", ExactSpelling = true)] public static extern CX_StmtClass Cursor_getStmtClass(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getStringLiteralKind", ExactSpelling = true)] + public static extern CX_StringKind Cursor_getStringLiteralKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getStringLiteralValue", ExactSpelling = true)] public static extern CXString Cursor_getStringLiteralValue(CXCursor C); diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs index c798c5a0..522d5c79 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs @@ -12,7 +12,7 @@ internal partial class CSharpOutputBuilder public void WriteCustomAttribute(string attribute, Action? callback = null) { - if (attribute.Equals("Flags", StringComparison.Ordinal) || attribute.Equals("Obsolete", StringComparison.Ordinal)) + if (attribute.Equals("Flags", StringComparison.Ordinal) || attribute.Equals("Obsolete", StringComparison.Ordinal) || attribute.StartsWith("Obsolete(", StringComparison.Ordinal)) { AddUsingDirective("System"); } @@ -73,7 +73,7 @@ public void WriteDivider(bool force = false) public void WriteIid(string name, Guid value) { - if (_config.GenerateUnmanagedConstants) + if (_generator.Config.GenerateUnmanagedConstants) { AddUsingDirective("System"); AddUsingDirective("System.Diagnostics"); @@ -89,7 +89,7 @@ public void WriteIid(string name, Guid value) WriteIndented("ReadOnlySpan data = "); - if (_config.GenerateLatestCode) + if (_generator.Config.GenerateLatestCode) { WriteLine('['); } @@ -124,7 +124,7 @@ public void WriteIid(string name, Guid value) WriteNewline(); DecreaseIndentation(); - if (_config.GenerateLatestCode) + if (_generator.Config.GenerateLatestCode) { WriteIndented(']'); } diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs index 83b230fa..712f8c81 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs @@ -31,7 +31,7 @@ public void EndUnchecked() public void BeginValue(in ValueDesc desc) { - if (_config.GenerateDocIncludes && (desc.Kind == ValueKind.Enumerator)) + if (_generator.Config.GenerateDocIncludes && (desc.Kind == ValueKind.Enumerator)) { WriteIndented("/// (indirectFieldDecl, type, out var constantArrayType) ? constantArrayType.Size : 0; + arraySize = Math.Max(arraySize, 1); + if (isSupportedFixedSizedBufferType) { code.Write("[0], "); - code.Write(Math.Max(IsType(indirectFieldDecl, type, out var constantArrayType) ? constantArrayType.Size : 0, 1)); + code.Write(arraySize); + code.Write(')'); } - else + else if (!_config.GenerateLatestCode || arraySize == 1) { code.Write(".AsSpan("); + + if (arraySize == 1) + { + if (TryGetRemappedValue(indirectFieldDecl, _config.WithLengths, out var length)) + { + code.Write(length); + } + else + { + AddDiagnostic(DiagnosticLevel.Warning, $"Found variable length array: '{GetCursorQualifiedName(indirectFieldDecl)}'. Please specify the length using `--with-length `.", indirectFieldDecl); + } + } + + code.Write(')'); } } else { - code.Write(", 1)"); + code.Write(", 1))"); } - code.Write(')'); - if (isIndirectPointerField) { code.Write('.'); @@ -1216,10 +1253,13 @@ void ForFunctionDecl(ParmVarDecl parmVarDecl, FunctionDecl functionDecl) var handledDefaultArg = false; var isExprDefaultValue = false; + var defaultArg = (parmVarDecl.HasDefaultArg && !parmVarDecl.HasUnparsedDefaultArg) ? + (parmVarDecl.HasUninstantiatedDefaultArg ? parmVarDecl.UninstantiatedDefaultArg : parmVarDecl.DefaultArg) : + null; - if (parmVarDecl.HasDefaultArg) + if (defaultArg != null) { - isExprDefaultValue = IsDefaultValue(parmVarDecl.DefaultArg); + isExprDefaultValue = IsDefaultValue(defaultArg); if ((_outputBuilder is CSharpOutputBuilder csharpOutputBuilder) && (_config.WithTransparentStructs.ContainsKey(typeName) || parameters.Skip(index).Any((parmVarDecl) => { var type = parmVarDecl.Type; @@ -1227,19 +1267,17 @@ void ForFunctionDecl(ParmVarDecl parmVarDecl, FunctionDecl functionDecl) return _config.WithTransparentStructs.ContainsKey(typeName); }))) { - desc.CustomAttrGeneratorData = (parmVarDecl, this, csharpOutputBuilder, isExprDefaultValue ? null : parmVarDecl.DefaultArg); + desc.CustomAttrGeneratorData = (parmVarDecl, this, csharpOutputBuilder, isExprDefaultValue ? null : defaultArg); handledDefaultArg = true; } } _outputBuilder.BeginParameter(in desc); - if (parmVarDecl.HasDefaultArg && !handledDefaultArg) + if (defaultArg != null && !handledDefaultArg) { _outputBuilder.BeginParameterDefault(); - var defaultArg = parmVarDecl.DefaultArg; - if (IsTypePointerOrReference(parmVarDecl) && (defaultArg.Handle.Evaluate.Kind == CXEval_UnExposed)) { if (!isExprDefaultValue) @@ -1253,7 +1291,7 @@ void ForFunctionDecl(ParmVarDecl parmVarDecl, FunctionDecl functionDecl) } else { - Visit(parmVarDecl.DefaultArg); + Visit(defaultArg); } _outputBuilder.EndParameterDefault(); @@ -1304,10 +1342,10 @@ void ForTypedefDecl(ParmVarDecl parmVarDecl, TypedefDecl typedefDecl) _outputBuilder.BeginParameter(in desc); - if (parmVarDecl.HasDefaultArg) + if (parmVarDecl.HasDefaultArg && !parmVarDecl.HasUnparsedDefaultArg) { _outputBuilder.BeginParameterDefault(); - Visit(parmVarDecl.DefaultArg); + Visit(parmVarDecl.HasUninstantiatedDefaultArg ? parmVarDecl.UninstantiatedDefaultArg : parmVarDecl.DefaultArg); _outputBuilder.EndParameterDefault(); } @@ -1640,11 +1678,9 @@ private void VisitRecordDecl(RecordDecl recordDecl) var cxxBaseSpecifier = cxxRecordDecl.Bases[index]; var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - if (HasField(baseCxxRecordDecl)) + if (HasField(baseCxxRecordDecl) && !IsBaseExcluded(cxxRecordDecl, baseCxxRecordDecl, cxxBaseSpecifier, out var baseFieldName)) { var parent = GetRemappedCursorName(baseCxxRecordDecl); - var baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); - baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); var fieldDesc = new FieldDesc { AccessSpecifier = GetAccessSpecifier(baseCxxRecordDecl, matchStar: true), @@ -1772,14 +1808,26 @@ private void VisitRecordDecl(RecordDecl recordDecl) { foreach (var cxxConstructorDecl in cxxRecordDecl.Ctors) { - Visit(cxxConstructorDecl); - _outputBuilder.WriteDivider(); + if (!IsExcluded(cxxConstructorDecl)) + { + Visit(cxxConstructorDecl); + _outputBuilder.WriteDivider(); + } } - if (cxxRecordDecl.HasUserDeclaredDestructor && !cxxRecordDecl.Destructor.IsVirtual) + if (cxxRecordDecl.HasUserDeclaredDestructor) { - Visit(cxxRecordDecl.Destructor); - _outputBuilder.WriteDivider(); + var cxxDestructorDecl = cxxRecordDecl.Destructor; + + if (cxxDestructorDecl == null) + { + AddDiagnostic(DiagnosticLevel.Warning, "Record has user declared destructor, but Destructor property was null. Generated bindings may be incomplete.", cxxRecordDecl); + } + else if (!cxxDestructorDecl.IsVirtual && !IsExcluded(cxxDestructorDecl)) + { + Visit(cxxDestructorDecl); + _outputBuilder.WriteDivider(); + } } if (hasVtbl || hasBaseVtbl) @@ -3046,14 +3094,17 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co code.AddUsingDirective("System"); code.AddUsingDirective("System.Runtime.InteropServices"); - code.WriteIndented("return ref AsSpan("); + code.WriteIndented("return ref "); if (arraySize == 1) { - code.Write("int.MaxValue"); + code.Write("Unsafe.Add(ref e0, index)"); + } + else + { + code.Write("AsSpan()[index]"); } - code.Write(")[index]"); code.WriteSemicolon(); code.WriteNewline(); _outputBuilder.EndCSharpCode(code); @@ -3336,7 +3387,7 @@ private void VisitVarDecl(VarDecl varDecl) _ = nativeTypeNameBuilder.Append(' '); var macroValue = GetSourceRangeContents(varDecl.TranslationUnit.Handle, varDecl.Init.Extent); - _ = nativeTypeNameBuilder.Append(macroValue); + _ = nativeTypeNameBuilder.Append(macroValue.Replace(@"\\", "\\", StringComparison.Ordinal)); nativeTypeName = nativeTypeNameBuilder.ToString(); } @@ -3360,33 +3411,33 @@ private void VisitVarDecl(VarDecl varDecl) switch (stringLiteral.Kind) { - case CX_CLK_Ascii: - case CX_CLK_UTF8: + case CX_SLK_Ordinary: + case CX_SLK_UTF8: { typeName = flags.HasFlag(ValueFlags.Constant) ? "ReadOnlySpan" : "byte[]"; break; } - case CX_CLK_Wide: + case CX_SLK_Wide: { if (_config.GenerateUnixTypes) { - goto case CX_CLK_UTF32; + goto case CX_SLK_UTF32; } else { - goto case CX_CLK_UTF16; + goto case CX_SLK_UTF16; } } - case CX_CLK_UTF16: + case CX_SLK_UTF16: { kind = ValueKind.Primitive; typeName = "string"; break; } - case CX_CLK_UTF32: + case CX_SLK_UTF32: { typeName = (_config.GenerateLatestCode && flags.HasFlag(ValueFlags.Constant)) ? "ReadOnlySpan" : "uint[]"; break; @@ -3712,14 +3763,14 @@ private bool IsConstant(string targetTypeName, Expr initExpr) case CX_StmtClass_CStyleCastExpr: case CX_StmtClass_CXXStaticCastExpr: case CX_StmtClass_CXXFunctionalCastExpr: + case CX_StmtClass_CXXConstCastExpr: + case CX_StmtClass_CXXDynamicCastExpr: + case CX_StmtClass_CXXReinterpretCastExpr: { var cxxFunctionalCastExpr = (ExplicitCastExpr)initExpr; return IsConstant(targetTypeName, cxxFunctionalCastExpr.SubExprAsWritten); } - // case CX_StmtClass_CXXConstCastExpr: - // case CX_StmtClass_CXXDynamicCastExpr: - // case CX_StmtClass_CXXReinterpretCastExpr: // case CX_StmtClass_ObjCBridgedCastExpr: case CX_StmtClass_ImplicitCastExpr: @@ -3917,7 +3968,7 @@ private bool IsConstant(string targetTypeName, Expr initExpr) } } - private bool IsPrimitiveValue(Cursor? cursor, Type type) + private static bool IsPrimitiveValue(Cursor? cursor, Type type) { if (IsType(cursor, type, out var builtinType)) { diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs index 7c8ee972..e216d889 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs @@ -14,6 +14,7 @@ using static ClangSharp.Interop.CX_CastKind; using static ClangSharp.Interop.CX_CharacterKind; using static ClangSharp.Interop.CX_StmtClass; +using static ClangSharp.Interop.CX_StringKind; using static ClangSharp.Interop.CX_UnaryExprOrTypeTrait; using static ClangSharp.Interop.CXUnaryOperatorKind; using static ClangSharp.Interop.CXEvalResultKind; @@ -124,14 +125,39 @@ private void VisitCallExpr(CallExpr callExpr) } } + var functionName = ""; var isUnusedValue = false; + var parentName = ""; + var parentNamespace = ""; + + if (calleeDecl is FunctionDecl functionDecl) + { + functionName = functionDecl.Name; + + if (functionDecl.IsStatic && (functionDecl.Parent is CXXRecordDecl parent)) + { + parentName = GetRemappedCursorName(parent); + parentNamespace = GetNamespace(parentName, parent); + + if (IsPrevContextDecl(out var functionDeclContext, out _) && (functionDeclContext.Parent is CXXRecordDecl parentContext)) + { + var contextName = GetRemappedCursorName(parentContext); + + if (string.Equals(parentName, contextName, StringComparison.Ordinal)) + { + parentName = ""; + parentNamespace = ""; + } + } + } + } if (!IsTypeVoid(callExpr, callExpr.Type)) { isUnusedValue = IsPrevContextStmt(out _, out _) || IsPrevContextStmt(out _, out _); - if ((calleeDecl is FunctionDecl functionDecl) && (functionDecl.Name is "memcpy" or "memset")) + if (functionName is "memcpy" or "memset") { isUnusedValue = false; } @@ -142,6 +168,14 @@ private void VisitCallExpr(CallExpr callExpr) outputBuilder.Write("_ = "); } + if (!string.IsNullOrWhiteSpace(parentName)) + { + AddUsingDirective(outputBuilder, parentNamespace); + + outputBuilder.Write(parentName); + outputBuilder.Write('.'); + } + if (calleeDecl is null) { Visit(callExpr.Callee); @@ -152,15 +186,34 @@ private void VisitCallExpr(CallExpr callExpr) Visit(callExpr.Callee); VisitArgs(callExpr); } - else if (calleeDecl is FunctionDecl functionDecl) + else if (calleeDecl is FunctionDecl) { - switch (functionDecl.Name) + switch (functionName) { case "memcpy": { - outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); - outputBuilder.Write("Unsafe.CopyBlockUnaligned"); - VisitArgs(callExpr); + var args = callExpr.Args; + + if (Config.GenerateLatestCode) + { + outputBuilder.AddUsingDirective("System.Runtime.InteropServices"); + outputBuilder.Write("NativeMemory.Copy"); + + if (args.Count == 3) + { + // Swap the operands around: + // * NativeMemory.Copy takes: source, dest, count + // * memcpy takes: dest, source, count + args = [args[1], args[0], args[2]]; + } + } + else + { + outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); + outputBuilder.Write("Unsafe.CopyBlockUnaligned"); + } + + VisitArgs(callExpr, args); break; } @@ -168,6 +221,8 @@ private void VisitCallExpr(CallExpr callExpr) { NamedDecl? namedDecl = null; + var args = callExpr.Args; + if (callExpr.NumArgs == 3) { if (IsStmtAsWritten(callExpr.Args[1], out var integerLiteralExpr, removeParens: true) && (integerLiteralExpr.Value == 0) && @@ -197,11 +252,25 @@ private void VisitCallExpr(CallExpr callExpr) outputBuilder.Write(" = default"); break; } + + if (Config.GenerateLatestCode) + { + args = [args[0], args[2], args[1]]; + } } - outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); - outputBuilder.Write("Unsafe.InitBlockUnaligned"); - VisitArgs(callExpr); + if (Config.GenerateLatestCode) + { + outputBuilder.AddUsingDirective("System.Runtime.InteropServices"); + outputBuilder.Write("NativeMemory.Fill"); + } + else + { + outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); + outputBuilder.Write("Unsafe.InitBlockUnaligned"); + } + + VisitArgs(callExpr, args); break; } @@ -243,7 +312,7 @@ private void VisitCallExpr(CallExpr callExpr) AddDiagnostic(DiagnosticLevel.Error, $"Unsupported callee declaration: '{calleeDecl.DeclKindName}'. Generated bindings may be incomplete.", calleeDecl); } - void VisitArgs(CallExpr callExpr) + void VisitArgs(CallExpr callExpr, IReadOnlyList? args = null) { var callExprType = (callExpr.Callee is MemberExpr memberExpr) ? memberExpr.MemberDecl.Type @@ -256,9 +325,13 @@ void VisitArgs(CallExpr callExpr) outputBuilder.Write('('); - var args = callExpr.Args; + args ??= callExpr.Args; var needsComma = false; + var paramCount = IsType(callExpr, callExprType, out var functionProtoType) + ? (int)functionProtoType.NumParams + : args.Count; + for (var i = 0; i < args.Count; i++) { var arg = args[i]; @@ -268,13 +341,28 @@ void VisitArgs(CallExpr callExpr) outputBuilder.Write(", "); } - if (IsType(callExpr, callExprType, out var functionProtoType)) + if ((functionProtoType is not null) && (i < paramCount)) { - if (IsType(callExpr, functionProtoType.ParamTypes[i])) + if (IsType(callExpr, functionProtoType.ParamTypes[i], out var referenceType)) { if (IsStmtAsWritten(arg, out var unaryOperator, removeParens: true) && (unaryOperator.Opcode == CXUnaryOperator_Deref)) { - arg = unaryOperator.SubExpr; + var subExpr = unaryOperator.SubExpr; + + if (subExpr is CXXThisExpr) + { + var referenceTypeName = GetTypeName(callExpr, context: null, type: referenceType, ignoreTransparentStructsWhereRequired: true, isTemplate: false, nativeTypeName: out _); + + outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); + outputBuilder.Write('('); + outputBuilder.Write(referenceTypeName); + outputBuilder.Write(")Unsafe.AsPointer(ref this)"); + + needsComma = true; + continue; + } + + arg = subExpr; } else if (IsStmtAsWritten(arg, out var declRefExpr, removeParens: true)) { @@ -288,6 +376,14 @@ void VisitArgs(CallExpr callExpr) outputBuilder.Write('&'); } } + else if (IsStmtAsWritten(arg, out _) && (functionName == "memcpy")) + { + outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); + outputBuilder.Write("Unsafe.AsPointer(ref this)"); + + needsComma = true; + continue; + } } Visit(arg); @@ -358,6 +454,12 @@ private void VisitCharacterLiteral(CharacterLiteral characterLiteral) targetTypeName = GetRemappedTypeName(implicitCastExpr, context: null, targetType, out _, skipUsing: true); targetTypeNumBits = targetType.Handle.NumBits; } + else if (IsPrevContextStmt(out var binaryOperator, out _)) + { + var targetType = binaryOperator.Type; + targetTypeName = GetRemappedTypeName(implicitCastExpr, context: null, targetType, out _, skipUsing: true); + targetTypeNumBits = targetType.Handle.NumBits; + } else if (PreviousContext.Cursor is VarDecl varDecl) { var targetType = varDecl.Type; @@ -509,12 +611,24 @@ private void VisitCXXConstructExpr(CXXConstructExpr cxxConstructExpr) { outputBuilder.Write("ref "); } - Visit(args[0]); - for (var i = 1; i < args.Count; i++) + var needsComma = false; + + for (var i = 0; i < args.Count; i++) { - outputBuilder.Write(", "); - Visit(args[i]); + var arg = args[i]; + + if (needsComma && (arg is not CXXDefaultArgExpr)) + { + outputBuilder.Write(", "); + } + + Visit(arg); + + if (arg is not CXXDefaultArgExpr) + { + needsComma = true; + } } } @@ -624,12 +738,6 @@ private void VisitCXXOperatorCallExpr(CXXOperatorCallExpr cxxOperatorCallExpr) var functionDeclName = GetCursorName(functionDecl); var args = cxxOperatorCallExpr.Args; - if (functionDecl.DeclContext is CXXRecordDecl) - { - Visit(cxxOperatorCallExpr.Args[0]); - outputBuilder.Write('.'); - } - if (IsEnumOperator(functionDecl, functionDeclName)) { switch (functionDeclName) @@ -666,23 +774,75 @@ private void VisitCXXOperatorCallExpr(CXXOperatorCallExpr cxxOperatorCallExpr) } var name = GetRemappedCursorName(functionDecl); - outputBuilder.Write(name); + var firstIndex = 0; - outputBuilder.Write('('); - var firstIndex = (functionDecl.DeclContext is CXXRecordDecl) ? 1 : 0; + if (functionDecl.DeclContext is CXXRecordDecl) + { + Visit(cxxOperatorCallExpr.Args[0]); + firstIndex++; + } - if (args.Count > firstIndex) + switch (name) { - Visit(args[firstIndex]); + case "operator=": + { + if (!functionDecl.IsDefaulted) + { + goto default; + } + + var expr = args[firstIndex]; + + if (firstIndex != 0) + { + outputBuilder.Write(" = "); - for (var i = firstIndex + 1; i < args.Count; i++) + if (!IsTypePointerOrReference(args[firstIndex - 1])) + { + if (IsType(expr)) + { + outputBuilder.Write('*'); + } + else if (IsStmtAsWritten(expr, out var declRefExpr, removeParens: true)) + { + if (IsTypePointerOrReference(declRefExpr.Decl)) + { + outputBuilder.Write('*'); + } + } + } + } + + Visit(expr); + break; + } + + default: { - outputBuilder.Write(", "); - Visit(args[i]); + if (firstIndex != 0) + { + outputBuilder.Write('.'); + } + + outputBuilder.Write(name); + + outputBuilder.Write('('); + + if (args.Count > firstIndex) + { + Visit(args[firstIndex]); + + for (var i = firstIndex + 1; i < args.Count; i++) + { + outputBuilder.Write(", "); + Visit(args[i]); + } + } + + outputBuilder.Write(')'); + break; } } - - outputBuilder.Write(')'); } else { @@ -701,7 +861,8 @@ private static void VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr cxxPseu private void VisitCXXThisExpr(CXXThisExpr cxxThisExpr) { - StartCSharpCode().Write("this"); + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("this"); StopCSharpCode(); } @@ -1330,6 +1491,7 @@ void ForRecordType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr, var typeName = GetRemappedTypeName(initListExpr, context: null, type, out _); var isUnmanagedConstant = false; var escapedName = ""; + var skipInitializer = false; if (IsPrevContextDecl(out _, out var userData)) { @@ -1339,6 +1501,13 @@ void ForRecordType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr, isUnmanagedConstant = (valueDesc.Kind == ValueKind.Unmanaged) && valueDesc.IsConstant; } } + else if (IsPrevContextDecl(out _, out userData, includeLast: true)) + { + if (userData is bool boolValue) + { + skipInitializer = boolValue; + } + } if (_config.GenerateUnmanagedConstants && isUnmanagedConstant && (_testStmtOutputBuilder is null)) { @@ -1346,8 +1515,11 @@ void ForRecordType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr, } else { - outputBuilder.Write("new "); - outputBuilder.Write(typeName); + if (!skipInitializer) + { + outputBuilder.Write("new "); + outputBuilder.Write(typeName); + } if (typeName.Equals("Guid", StringComparison.Ordinal)) { @@ -1373,8 +1545,11 @@ void ForRecordType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr, } else { - outputBuilder.WriteNewline(); - outputBuilder.WriteBlockStart(); + if (!skipInitializer) + { + outputBuilder.WriteNewline(); + outputBuilder.WriteBlockStart(); + } var decl = recordType.Decl; @@ -1387,17 +1562,42 @@ void ForRecordType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr, continue; } - var fieldName = GetRemappedCursorName(decl.Fields[i]); + var fieldDecl = decl.Fields[i]; + var fieldName = GetRemappedCursorName(fieldDecl); outputBuilder.WriteIndented(fieldName); outputBuilder.Write(" = "); + + if (!IsTypePointerOrReference(fieldDecl) && (init is Expr initExpr)) + { + if ((initExpr is CXXConstructExpr cxxConstructExpr) && cxxConstructExpr.Constructor.IsDefaulted) + { + initExpr = cxxConstructExpr.Args[0]; + } + + if (IsType(initExpr)) + { + outputBuilder.Write('*'); + } + else if (IsStmtAsWritten(initExpr, out var declRefExpr, removeParens: true)) + { + if (IsTypePointerOrReference(declRefExpr.Decl)) + { + outputBuilder.Write('*'); + } + } + } + Visit(init); - outputBuilder.WriteLine(','); + outputBuilder.WriteLine(skipInitializer ? ';' : ','); } - outputBuilder.DecreaseIndentation(); - outputBuilder.WriteIndented('}'); - outputBuilder.NeedsSemicolon = true; + if (!skipInitializer) + { + outputBuilder.DecreaseIndentation(); + outputBuilder.WriteIndented('}'); + outputBuilder.NeedsSemicolon = true; + } } } } @@ -1703,11 +1903,7 @@ private void VisitIntegerLiteral(IntegerLiteral integerLiteral) { var valueString = integerLiteral.ValueString; - if (valueString.EndsWith('l') || valueString.EndsWith('L')) - { - valueString = valueString[0..^1]; - } - else if (valueString.EndsWith("ui8", StringComparison.OrdinalIgnoreCase)) + if (valueString.EndsWith("ui8", StringComparison.OrdinalIgnoreCase)) { valueString = valueString[0..^3]; } @@ -1723,28 +1919,47 @@ private void VisitIntegerLiteral(IntegerLiteral integerLiteral) { valueString = valueString[0..^3]; } + else if (valueString.EndsWith("ui32", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^4] + "U"; + } else if (valueString.EndsWith("i32", StringComparison.OrdinalIgnoreCase)) { valueString = valueString[0..^3]; } + else if (valueString.EndsWith("ui64", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^4] + "UL"; + } else if (valueString.EndsWith("i64", StringComparison.OrdinalIgnoreCase)) { valueString = valueString[0..^3] + "L"; } - - if (valueString.EndsWith("ul", StringComparison.OrdinalIgnoreCase)) + else if ( + valueString.EndsWith("ull", StringComparison.OrdinalIgnoreCase) || + valueString.EndsWith("llu", StringComparison.OrdinalIgnoreCase)) { - valueString = valueString[0..^2] + "UL"; + valueString = valueString[0..^3] + "UL"; } - else if (valueString.EndsWith('l') || valueString.EndsWith('L')) + else if (valueString.EndsWith("ll", StringComparison.OrdinalIgnoreCase)) { - valueString = valueString[0..^1] + "L"; + valueString = valueString[0..^2] + "L"; + } + else if ( + valueString.EndsWith("ul", StringComparison.OrdinalIgnoreCase) || + valueString.EndsWith("lu", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^2] + "U"; } else if (valueString.EndsWith('u') || valueString.EndsWith('U')) { valueString = valueString[0..^1] + "U"; } - + else if (valueString.EndsWith('l') || valueString.EndsWith('L')) + { + valueString = valueString[0..^1]; + } + var outputBuilder = StartCSharpCode(); outputBuilder.Write(valueString); StopCSharpCode(); @@ -1780,10 +1995,9 @@ private void VisitMemberExpr(MemberExpr memberExpr) { var cxxBaseSpecifier = _cxxRecordDeclContext.Bases.Where((baseSpecifier) => baseSpecifier.Referenced == parent).SingleOrDefault(); - if (cxxBaseSpecifier is not null) + if ((cxxBaseSpecifier is not null) && IsBaseExcluded(_cxxRecordDeclContext, GetRecordDecl(cxxBaseSpecifier), cxxBaseSpecifier, out baseFieldName)) { - baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); - baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); + baseFieldName = ""; } } } @@ -1796,10 +2010,9 @@ private void VisitMemberExpr(MemberExpr memberExpr) { var cxxBaseSpecifier = _cxxRecordDeclContext.Bases.Where((baseSpecifier) => baseSpecifier.Referenced == parent).SingleOrDefault(); - if (cxxBaseSpecifier is not null) + if ((cxxBaseSpecifier is not null) && IsBaseExcluded(_cxxRecordDeclContext, GetRecordDecl(cxxBaseSpecifier), cxxBaseSpecifier, out baseFieldName)) { - baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); - baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); + baseFieldName = ""; } } } @@ -1892,17 +2105,40 @@ private void VisitReturnStmt(ReturnStmt returnStmt) if (IsPrevContextDecl(out var functionDecl, out _) && !IsTypeVoid(functionDecl, functionDecl.ReturnType)) { outputBuilder.Write("return"); + var retValue = returnStmt.RetValue; - if (returnStmt.RetValue != null) + if (retValue != null) { outputBuilder.Write(' '); - if (!IsTypePointerOrReference(functionDecl) && IsType(returnStmt.RetValue)) + if (!IsTypePointerOrReference(functionDecl) && IsType(retValue)) { outputBuilder.Write('*'); } + else if (IsType(functionDecl, functionDecl.ReturnType, out var referenceType)) + { + if (IsStmtAsWritten(retValue, out var unaryOperator, removeParens: true) && (unaryOperator.Opcode == CXUnaryOperator_Deref)) + { + var subExpr = unaryOperator.SubExpr; + + if (subExpr is CXXThisExpr) + { + var referenceTypeName = GetTypeName(returnStmt, context: null, type: referenceType, ignoreTransparentStructsWhereRequired: true, isTemplate: false, nativeTypeName: out _); + + outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); + outputBuilder.Write('('); + outputBuilder.Write(referenceTypeName); + outputBuilder.Write(")Unsafe.AsPointer(ref this)"); + + StopCSharpCode(); + return; + } + + retValue = subExpr; + } + } - Visit(returnStmt.RetValue); + Visit(retValue); } } else if (returnStmt.RetValue != null) @@ -2492,8 +2728,8 @@ private void VisitStringLiteral(StringLiteral stringLiteral) var outputBuilder = StartCSharpCode(); switch (stringLiteral.Kind) { - case CX_CLK_Ascii: - case CX_CLK_UTF8: + case CX_SLK_Ordinary: + case CX_SLK_UTF8: { if (Config.GenerateLatestCode) { @@ -2531,19 +2767,19 @@ private void VisitStringLiteral(StringLiteral stringLiteral) break; } - case CX_CLK_Wide: + case CX_SLK_Wide: { if (_config.GenerateUnixTypes) { - goto case CX_CLK_UTF32; + goto case CX_SLK_UTF32; } else { - goto case CX_CLK_UTF16; + goto case CX_SLK_UTF16; } } - case CX_CLK_UTF16: + case CX_SLK_UTF16: { outputBuilder.Write('"'); outputBuilder.Write(EscapeString(stringLiteral.String)); @@ -2551,7 +2787,7 @@ private void VisitStringLiteral(StringLiteral stringLiteral) break; } - case CX_CLK_UTF32: + case CX_SLK_UTF32: { if (_config.GenerateLatestCode) { diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index b5013b87..6edb8098 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -37,8 +37,8 @@ public sealed partial class PInvokeGenerator : IDisposable private static readonly string[] s_doubleColonSeparator = ["::"]; private static readonly char[] s_doubleQuoteSeparator = ['"']; - private const string ExpectedClangVersion = "version 17.0"; - private const string ExpectedClangSharpVersion = "version 17.0"; + private const string ExpectedClangVersion = "version 18.1"; + private const string ExpectedClangSharpVersion = "version 18.1"; private readonly CXIndex _index; private readonly OutputBuilderFactory _outputBuilderFactory; @@ -127,8 +127,9 @@ public PInvokeGenerator(PInvokeGeneratorConfiguration config, Func { var directoryPath = Path.GetDirectoryName(path) ?? ""; _ = Directory.CreateDirectory(directoryPath); @@ -138,12 +139,11 @@ public PInvokeGenerator(PInvokeGeneratorConfiguration config, Func(); - _config = config; _uuidsToGenerate = []; _generatedUuids = []; _cursorNames = []; - _cursorQualifiedNames = new Dictionary<(NamedDecl, bool), string>(); - _typeNames = new Dictionary<(Cursor?, Cursor?, Type), (string, string)>(); + _cursorQualifiedNames = []; + _typeNames = []; _allValidNameRemappings = new Dictionary>() { ["intptr_t"] = ["IntPtr", "nint"], ["ptrdiff_t"] = ["IntPtr", "nint"], @@ -239,9 +239,6 @@ public void Close() var outputPath = _config.OutputLocation; stream = _outputStreamFactory(outputPath); - var testOutputPath = _config.TestOutputLocation; - testStream = _outputStreamFactory(testOutputPath); - leaveStreamOpen = true; var usingDirectives = new SortedSet(StringComparer.Ordinal); @@ -333,6 +330,9 @@ public void Close() if (testHasAnyContents) { + var testOutputPath = _config.TestOutputLocation; + testStream = _outputStreamFactory(testOutputPath); + using var sw = new StreamWriter(testStream, s_defaultStreamWriterEncoding, DefaultStreamWriterBufferSize, leaveStreamOpen); sw.NewLine = "\n"; @@ -358,7 +358,7 @@ public void Close() } else { - testStream = null; + Debug.Assert(testStream is null); } } @@ -513,7 +513,7 @@ static void GenerateDisableRuntimeMarshallingAttribute(PInvokeGenerator generato sw.WriteLine("using System.Runtime.CompilerServices;"); sw.WriteLine(); sw.WriteLine("[assembly: DisableRuntimeMarshalling]"); - + if (!leaveStreamOpen) { stream = null; @@ -1451,24 +1451,21 @@ static void GenerateTransparentStructs(PInvokeGenerator generator, Stream? strea static (int srcSize, int dstSize, int sign) GetSizeAndSignOf(string type) { - if (type.Contains('*', StringComparison.Ordinal)) - { - return (8, 4, +1); - } - - return type switch { - "sbyte" => (1, 1, -1), - "byte" => (1, 1, +1), - "short" => (2, 2, -1), - "ushort" => (2, 2, +1), - "int" => (4, 4, -1), - "uint" => (4, 4, +1), - "nint" => (8, 4, -1), - "nuint" => (8, 4, +1), - "long" => (8, 8, -1), - "ulong" => (8, 8, +1), - _ => (0, 0, 0), - }; + return type.Contains('*', StringComparison.Ordinal) + ? (8, 4, +1) + : type switch { + "sbyte" => (1, 1, -1), + "byte" => (1, 1, +1), + "short" => (2, 2, -1), + "ushort" => (2, 2, +1), + "int" => (4, 4, -1), + "uint" => (4, 4, +1), + "nint" => (8, 4, -1), + "nuint" => (8, 4, +1), + "long" => (8, 8, -1), + "ulong" => (8, 8, +1), + _ => (0, 0, 0), + }; } static void OutputConversions(StreamWriter sw, string indentString, string name, string type, PInvokeGeneratorTransparentStructKind kind, string target) @@ -1582,7 +1579,7 @@ public void GenerateBindings(TranslationUnit translationUnit, string filePath, s if (translationUnit.Handle.NumDiagnostics != 0) { var errorDiagnostics = new StringBuilder(); - errorDiagnostics.AppendLine($"The provided {nameof(CXTranslationUnit)} has the following diagnostics which prevent its use:"); + _ = errorDiagnostics.AppendLine($"The provided {nameof(CXTranslationUnit)} has the following diagnostics which prevent its use:"); var invalidTranslationUnitHandle = false; for (uint i = 0; i < translationUnit.Handle.NumDiagnostics; ++i) @@ -1592,8 +1589,8 @@ public void GenerateBindings(TranslationUnit translationUnit, string filePath, s if (diagnostic.Severity is CXDiagnostic_Error or CXDiagnostic_Fatal) { invalidTranslationUnitHandle = true; - errorDiagnostics.Append(' ', 4); - errorDiagnostics.AppendLine(diagnostic.Format(CXDiagnostic.DefaultDisplayOptions).ToString()); + _ = errorDiagnostics.Append(' ', 4); + _ = errorDiagnostics.AppendLine(diagnostic.Format(CXDiagnostic.DefaultDisplayOptions).ToString()); } } @@ -1613,12 +1610,9 @@ public void GenerateBindings(TranslationUnit translationUnit, string filePath, s var file = translationUnitHandle.GetFile(_filePath); var fileContents = translationUnitHandle.GetFileContents(file, out var size); + var fileContentsBuilder = _fileContentsBuilder; -#if NETCOREAPP - _fileContentsBuilder.Append(Encoding.UTF8.GetString(fileContents)); -#else - _fileContentsBuilder.Append(Encoding.UTF8.GetString(fileContents.ToArray())); -#endif + _ = fileContentsBuilder.Append(Encoding.UTF8.GetString(fileContents)); foreach (var cursor in translationUnit.TranslationUnitDecl.CursorChildren) { @@ -1628,8 +1622,8 @@ public void GenerateBindings(TranslationUnit translationUnit, string filePath, s } } - var unsavedFileContents = _fileContentsBuilder.ToString(); - _fileContentsBuilder.Clear(); + var unsavedFileContents = fileContentsBuilder.ToString(); + _ = fileContentsBuilder.Clear(); using var unsavedFile = CXUnsavedFile.Create(_filePath, unsavedFileContents); var unsavedFiles = new CXUnsavedFile[] { unsavedFile }; @@ -1652,6 +1646,16 @@ public void GenerateBindings(TranslationUnit translationUnit, string filePath, s var name = kvp.Key; var remappings = kvp.Value; + if (name.Contains('<', StringComparison.OrdinalIgnoreCase)) + { + var parts = name.Split('<'); + + if (parts.Length >= 2) + { + name = parts[0]; + } + } + if (!_config.RemappedNames.TryGetValue(name, out _)) { var addDiag = false; @@ -1841,7 +1845,7 @@ static string GetFoundRemappingString(string name, HashSet remappings) if (remappings.Count == 1) { - remainingRemappings = Array.Empty(); + remainingRemappings = []; } else { @@ -2344,8 +2348,7 @@ private string EscapeAndStripName(string name) // We first replace already escaped characters with their raw counterpart // We then re-escape any raw characters. This ensures we don't end up with double escaped backslashes - internal static string EscapeString(string value) => value.Replace(@"\\", "\\", StringComparison.Ordinal) - .Replace(@"\0", "\0", StringComparison.Ordinal) + internal static string EscapeString(string value) => value.Replace(@"\0", "\0", StringComparison.Ordinal) .Replace(@"\r", "\r", StringComparison.Ordinal) .Replace(@"\n", "\n", StringComparison.Ordinal) .Replace(@"\t", "\t", StringComparison.Ordinal) @@ -2687,6 +2690,14 @@ private string GetCursorName(NamedDecl namedDecl) name = name[6..]; } + var anonymousNameStartIndex = name.IndexOf("::(", StringComparison.Ordinal); + + if (anonymousNameStartIndex != -1) + { + anonymousNameStartIndex += 2; + name = name[anonymousNameStartIndex..]; + } + if (namedDecl is CXXConstructorDecl cxxConstructorDecl) { var parent = cxxConstructorDecl.Parent; @@ -2717,7 +2728,7 @@ private string GetCursorName(NamedDecl namedDecl) { name = (typeDecl is TagDecl tagDecl) && tagDecl.Handle.IsAnonymous ? GetAnonymousName(tagDecl, tagDecl.TypeForDecl.KindSpelling) - : GetTypeName(namedDecl, context: null, typeDecl.TypeForDecl, ignoreTransparentStructsWhereRequired: false, out _); + : GetTypeName(namedDecl, context: null, type: typeDecl.TypeForDecl, ignoreTransparentStructsWhereRequired: false, isTemplate: false, nativeTypeName: out _); } else if (namedDecl is ParmVarDecl) { @@ -3159,9 +3170,9 @@ string AddUsingDirectiveIfNeeded(IOutputBuilder? outputBuilder, string remappedN } } - private string GetRemappedTypeName(Cursor? cursor, Cursor? context, Type type, out string nativeTypeName, bool skipUsing = false, bool ignoreTransparentStructsWhereRequired = false) + private string GetRemappedTypeName(Cursor? cursor, Cursor? context, Type type, out string nativeTypeName, bool skipUsing = false, bool ignoreTransparentStructsWhereRequired = false, bool isTemplate = false) { - var name = GetTypeName(cursor, context, type, ignoreTransparentStructsWhereRequired, out nativeTypeName); + var name = GetTypeName(cursor, context, type, ignoreTransparentStructsWhereRequired, isTemplate: isTemplate, nativeTypeName: out nativeTypeName); var nameToCheck = nativeTypeName; var remappedName = GetRemappedName(nameToCheck, cursor, tryRemapOperatorName: false, out var wasRemapped, skipUsing, skipUsingIfNotRemapped: true); @@ -3266,22 +3277,17 @@ private string GetRemappedTypeName(Cursor? cursor, Cursor? context, Type type, o private static string GetSourceRangeContents(CXTranslationUnit translationUnit, CXSourceRange sourceRange) { - sourceRange.Start.GetFileLocation(out var startFile, out var startLine, out var startColumn, out var startOffset); - sourceRange.End.GetFileLocation(out var endFile, out var endLine, out var endColumn, out var endOffset); + sourceRange.Start.GetFileLocation(out var startFile, out _, out _, out var startOffset); + sourceRange.End.GetFileLocation(out var endFile, out _, out _, out var endOffset); if (startFile != endFile) { return string.Empty; } - var fileContents = translationUnit.GetFileContents(startFile, out var fileSize); + var fileContents = translationUnit.GetFileContents(startFile, out _); fileContents = fileContents.Slice(unchecked((int)startOffset), unchecked((int)(endOffset - startOffset))); - -#if NETCOREAPP return Encoding.UTF8.GetString(fileContents); -#else - return Encoding.UTF8.GetString(fileContents.ToArray()); -#endif } private string GetTargetTypeName(Cursor cursor, out string nativeTypeName) @@ -3344,7 +3350,7 @@ private string GetTargetTypeName(Cursor cursor, out string nativeTypeName) return targetTypeName; } - private string GetTypeName(Cursor? cursor, Cursor? context, Type type, bool ignoreTransparentStructsWhereRequired, out string nativeTypeName) + private string GetTypeName(Cursor? cursor, Cursor? context, Type type, bool ignoreTransparentStructsWhereRequired, bool isTemplate, out string nativeTypeName) { if (_typeNames.TryGetValue((cursor, context, type), out var result)) { @@ -3367,11 +3373,11 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type type, bool igno } else { - return GetTypeName(cursor, context, type, type, ignoreTransparentStructsWhereRequired, out nativeTypeName); + return GetTypeName(cursor, context, type, type, ignoreTransparentStructsWhereRequired, isTemplate, out nativeTypeName); } } - private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type type, bool ignoreTransparentStructsWhereRequired, out string nativeTypeName) + private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type type, bool ignoreTransparentStructsWhereRequired, bool isTemplate, out string nativeTypeName) { if (!_typeNames.TryGetValue((cursor, context, type), out var result)) { @@ -3396,7 +3402,7 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type } else if (type is AttributedType attributedType) { - result.typeName = GetTypeName(cursor, context, rootType, attributedType.ModifiedType, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, attributedType.ModifiedType, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else if (type is BuiltinType) { @@ -3539,17 +3545,17 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type } else if (type is DecltypeType decltypeType) { - result.typeName = GetTypeName(cursor, context, rootType, decltypeType.UnderlyingType, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, decltypeType.UnderlyingType, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else if (type is DeducedType deducedType) { - result.typeName = GetTypeName(cursor, context, rootType, deducedType.GetDeducedType, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, deducedType.GetDeducedType, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else if (type is DependentNameType dependentNameType) { if (dependentNameType.IsSugared) { - result.typeName = GetTypeName(cursor, context, rootType, dependentNameType.Desugar, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, dependentNameType.Desugar, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else { @@ -3558,7 +3564,7 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type } else if (type is ElaboratedType elaboratedType) { - result.typeName = GetTypeName(cursor, context, rootType, elaboratedType.NamedType, ignoreTransparentStructsWhereRequired, out var nativeNamedTypeName); + result.typeName = GetTypeName(cursor, context, rootType, elaboratedType.NamedType, ignoreTransparentStructsWhereRequired, isTemplate, out var nativeNamedTypeName); if (!string.IsNullOrWhiteSpace(nativeNamedTypeName) && !result.nativeTypeName.StartsWith("const ", StringComparison.Ordinal) && @@ -3571,19 +3577,19 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type } else if (type is FunctionType functionType) { - result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, functionType, ignoreTransparentStructsWhereRequired, out _, out _); + result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, functionType, ignoreTransparentStructsWhereRequired, isTemplate, out _, out _); } else if (type is InjectedClassNameType injectedClassNameType) { - result.typeName = GetTypeName(cursor, context, rootType, injectedClassNameType.InjectedTST, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, injectedClassNameType.InjectedTST, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else if (type is PackExpansionType packExpansionType) { - result.typeName = GetTypeName(cursor, context, rootType, packExpansionType.Pattern, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, packExpansionType.Pattern, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else if (type is PointerType pointerType) { - result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, pointerType.PointeeType, ignoreTransparentStructsWhereRequired, out var nativePointeeTypeName, out var isAdjusted); + result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, pointerType.PointeeType, ignoreTransparentStructsWhereRequired, isTemplate, out var nativePointeeTypeName, out var isAdjusted); if (isAdjusted) { @@ -3592,7 +3598,7 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type } else if (type is ReferenceType referenceType) { - result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, referenceType.PointeeType, ignoreTransparentStructsWhereRequired, out var nativePointeeTypeName, out var isAdjusted); + result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, referenceType.PointeeType, ignoreTransparentStructsWhereRequired, isTemplate, out var nativePointeeTypeName, out var isAdjusted); if (isAdjusted) { @@ -3601,7 +3607,7 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type } else if (type is SubstTemplateTypeParmType substTemplateTypeParmType) { - result.typeName = GetTypeName(cursor, context, rootType, substTemplateTypeParmType.ReplacementType, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, substTemplateTypeParmType.ReplacementType, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else if (type is TagType tagType) { @@ -3616,7 +3622,7 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type } else if (tagType.Handle.IsConstQualified) { - result.typeName = GetTypeName(cursor, context, rootType, tagType.Decl.TypeForDecl, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, tagType.Decl.TypeForDecl, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else { @@ -3684,14 +3690,14 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type { case CXTemplateArgumentKind_Type: { - typeName = GetRemappedTypeName(cursor, context: null, arg.AsType, out var nativeAsTypeName, skipUsing: true); + typeName = GetRemappedTypeName(cursor, context: null, arg.AsType, out var nativeAsTypeName, skipUsing: true, isTemplate: true); break; } case CXTemplateArgumentKind_Expression: { var oldOutputBuilder = _outputBuilder; - _outputBuilder = new CSharpOutputBuilder("ClangSharp_TemplateSpecializationType_AsExpr", _config); + _outputBuilder = new CSharpOutputBuilder("ClangSharp_TemplateSpecializationType_AsExpr", this); Visit(arg.AsExpr); typeName = _outputBuilder.ToString() ?? ""; @@ -3716,6 +3722,11 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type if (typeName.EndsWith('*') || typeName.Contains("delegate*", StringComparison.Ordinal)) { + if (Config.GenerateGenericPointerWrapper) + { + AddDiagnostic(DiagnosticLevel.Warning, $"Unhandled pointer in template: '{typeName}'. Falling back 'IntPtr'.", cursor); + } + // Pointers are not yet supported as generic arguments; remap to IntPtr typeName = "IntPtr"; _outputBuilder?.EmitSystemSupport(); @@ -3737,7 +3748,7 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type { if (templateTypeParmType.IsSugared) { - result.typeName = GetTypeName(cursor, context, rootType, templateTypeParmType.Desugar, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, templateTypeParmType.Desugar, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else { @@ -3751,11 +3762,11 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type // platform size, based on whatever parameters were passed into clang. var remappedName = GetRemappedName(result.typeName, cursor, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true); - result.typeName = wasRemapped ? remappedName : GetTypeName(cursor, context, rootType, typedefType.Decl.UnderlyingType, ignoreTransparentStructsWhereRequired, out _); + result.typeName = wasRemapped ? remappedName : GetTypeName(cursor, context, rootType, typedefType.Decl.UnderlyingType, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else if (type is UsingType usingType) { - result.typeName = GetTypeName(cursor, context, rootType, usingType.Desugar, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, usingType.Desugar, ignoreTransparentStructsWhereRequired, isTemplate, out _); } else { @@ -3777,7 +3788,7 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type return result.typeName; } - private string GetTypeNameForPointeeType(Cursor? cursor, Cursor? context, Type rootType, Type pointeeType, bool ignoreTransparentStructsWhereRequired, out string nativePointeeTypeName, out bool isAdjusted) + private string GetTypeNameForPointeeType(Cursor? cursor, Cursor? context, Type rootType, Type pointeeType, bool ignoreTransparentStructsWhereRequired, bool isTemplate, out string nativePointeeTypeName, out bool isAdjusted) { var name = pointeeType.AsString; @@ -3789,11 +3800,11 @@ private string GetTypeNameForPointeeType(Cursor? cursor, Cursor? context, Type r if (pointeeType is AttributedType attributedType) { - name = GetTypeNameForPointeeType(cursor, context, rootType, attributedType.ModifiedType, ignoreTransparentStructsWhereRequired, out var nativeModifiedTypeName, out isAdjusted); + name = GetTypeNameForPointeeType(cursor, context, rootType, attributedType.ModifiedType, ignoreTransparentStructsWhereRequired, isTemplate, out var nativeModifiedTypeName, out isAdjusted); } else if (pointeeType is ElaboratedType elaboratedType) { - name = GetTypeNameForPointeeType(cursor, context, rootType, elaboratedType.NamedType, ignoreTransparentStructsWhereRequired, out var nativeNamedTypeName, out isAdjusted); + name = GetTypeNameForPointeeType(cursor, context, rootType, elaboratedType.NamedType, ignoreTransparentStructsWhereRequired, isTemplate, out var nativeNamedTypeName, out isAdjusted); if (!string.IsNullOrWhiteSpace(nativeNamedTypeName) && !nativePointeeTypeName.StartsWith("const ", StringComparison.Ordinal) && @@ -3933,19 +3944,23 @@ private string GetTypeNameForPointeeType(Cursor? cursor, Cursor? context, Type r if (wasRemapped) { - name = remappedName; - name += '*'; + name = isTemplate && Config.GenerateGenericPointerWrapper + ? $"Pointer<{remappedName}>" + : $"{remappedName}*"; } else { - name = GetTypeNameForPointeeType(cursor, context, rootType, typedefType.Decl.UnderlyingType, ignoreTransparentStructsWhereRequired, out var nativeUnderlyingTypeName, out isAdjusted); + name = GetTypeNameForPointeeType(cursor, context, rootType, typedefType.Decl.UnderlyingType, ignoreTransparentStructsWhereRequired, isTemplate, out var nativeUnderlyingTypeName, out isAdjusted); } } else { // Otherwise fields that point at anonymous structs get the wrong name - name = GetRemappedTypeName(cursor, context, pointeeType, out nativePointeeTypeName, skipUsing: true); - name += '*'; + var remappedName = GetRemappedTypeName(cursor, context, pointeeType, out nativePointeeTypeName, skipUsing: true); + + name = isTemplate && Config.GenerateGenericPointerWrapper + ? $"Pointer<{remappedName}>" + : $"{remappedName}*"; } return name; @@ -4343,7 +4358,7 @@ private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref lon // can be treated correctly. Otherwise, they will resolve to a particular // platform size, based on whatever parameters were passed into clang. - var name = GetTypeName(cursor, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + var name = GetTypeName(cursor, context: null, type: type, ignoreTransparentStructsWhereRequired: false, isTemplate: false, nativeTypeName: out _); var remappedName = GetRemappedTypeName(cursor, context: null, type, out _, skipUsing: true, ignoreTransparentStructsWhereRequired: false); if ((remappedName == name) && _config.WithTransparentStructs.TryGetValue(remappedName, out var transparentStruct) && (transparentStruct.Name.Equals("long", StringComparison.Ordinal) || transparentStruct.Name.Equals("ulong", StringComparison.Ordinal))) @@ -4511,7 +4526,7 @@ private bool HasVtbl(CXXRecordDecl cxxRecordDecl, out bool hasBaseVtbl) return hasVtbl; } - private bool IsEnumOperator(FunctionDecl functionDecl, string name) + private static bool IsEnumOperator(FunctionDecl functionDecl, string name) { if (name.StartsWith("operator", StringComparison.Ordinal) && ((functionDecl.Parameters.Count == 1) || (functionDecl.Parameters.Count == 2))) { @@ -4558,7 +4573,7 @@ private bool IsExcluded(Cursor cursor, out bool isExcludedByConflictingDefinitio { if (!_isExcluded.TryGetValue(cursor, out var isExcludedValue)) { - isExcludedValue |= (!IsAlwaysIncluded(cursor) && (IsExcludedByConfig(cursor) || IsExcludedByFile(cursor) || IsExcludedByName(cursor, ref isExcludedValue))) ? 0b01u : 0b00u; + isExcludedValue |= (!IsAlwaysIncluded(cursor) && (IsExcludedByConfig(cursor) || IsExcludedByFile(cursor) || IsExcludedByName(cursor, ref isExcludedValue) || IsExcludedByAttributes(cursor))) ? 0b01u : 0b00u; _isExcluded.Add(cursor, isExcludedValue); } isExcludedByConflictingDefinition = (isExcludedValue & 0b10) != 0; @@ -4572,7 +4587,7 @@ bool IsAlwaysIncluded(Cursor cursor) bool IsExcludedByConfig(Cursor cursor) { return (_config.ExcludeFunctionsWithBody && (cursor is FunctionDecl functionDecl) && functionDecl.HasBody) - || (!_config.GenerateTemplateBindings && (cursor is TemplateDecl)); + || (!_config.GenerateTemplateBindings && ((cursor is TemplateDecl) || (cursor is ClassTemplateSpecializationDecl))); } bool IsExcludedByFile(Cursor cursor) @@ -4839,7 +4854,7 @@ bool IsComProxy(FunctionDecl functionDecl, string name) if ((parmVarDecl is not null) && IsType(parmVarDecl, out var pointerType)) { - var typeName = GetTypeName(parmVarDecl, context: null, pointerType.PointeeType, ignoreTransparentStructsWhereRequired: false, out var nativeTypeName); + var typeName = GetTypeName(parmVarDecl, context: null, type: pointerType.PointeeType, ignoreTransparentStructsWhereRequired: false, isTemplate: false, nativeTypeName: out var nativeTypeName); return name.StartsWith($"{nativeTypeName}_", StringComparison.Ordinal) || name.StartsWith($"{typeName}_", StringComparison.Ordinal) || typeName.Equals("IRpcStubBuffer", StringComparison.Ordinal); } return false; @@ -5027,6 +5042,34 @@ bool IsEmptyRecord(RecordDecl recordDecl) return !TryGetUuid(recordDecl, out _); } + + bool IsExcludedByAttributes(Cursor cursor) + { + if (cursor is NamedDecl namedDecl) + { + foreach (var attr in GetAttributesFor(namedDecl)) + { + switch (attr.Kind) + { + case CX_AttrKind_Builtin: + return true; + } + } + } + + return false; + } + } + + private bool IsBaseExcluded(CXXRecordDecl cxxRecordDecl, CXXRecordDecl baseCxxRecordDecl, CXXBaseSpecifier cxxBaseSpecifier, out string baseFieldName) + { + baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); + baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out _, skipUsing: true); + + var qualifiedName = $"{GetCursorQualifiedName(cxxRecordDecl)}::{baseFieldName}"; + var dottedQualifiedName = qualifiedName.Replace("::", ".", StringComparison.Ordinal); + + return _config.ExcludedNames.Contains(qualifiedName) || _config.ExcludedNames.Contains(dottedQualifiedName); } private bool IsFixedSize(Cursor cursor, Type type) @@ -5079,7 +5122,7 @@ private bool IsFixedSize(Cursor cursor, Type type) } else if (type is TypedefType typedefType) { - var name = GetTypeName(cursor, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + var name = GetTypeName(cursor, context: null, type: type, ignoreTransparentStructsWhereRequired: false, isTemplate: false, nativeTypeName: out _); var remappedName = GetRemappedTypeName(cursor, context: null, type, out _, skipUsing: true, ignoreTransparentStructsWhereRequired: false); return !remappedName.Equals("IntPtr", StringComparison.Ordinal) @@ -5101,18 +5144,23 @@ private static bool IsNativeTypeNameEquivalent(string nativeTypeName, string typ || nativeTypeName.Replace(" ", "", StringComparison.Ordinal).Equals(typeName, StringComparison.OrdinalIgnoreCase); } - private bool IsPrevContextDecl([MaybeNullWhen(false)] out T cursor, out object? userData) + private bool IsPrevContextDecl([MaybeNullWhen(false)] out T cursor, out object? userData, bool includeLast = false) where T : Decl { var previousContext = _context.Last; Debug.Assert(previousContext != null); - do + if (!includeLast) + { + previousContext = previousContext.Previous; + Debug.Assert(previousContext != null); + } + + while (previousContext.Value.Cursor is not Decl) { previousContext = previousContext.Previous; Debug.Assert(previousContext != null); } - while (previousContext.Value.Cursor is not Decl); var value = previousContext.Value; @@ -5195,22 +5243,22 @@ private static bool IsStmtAsWritten(Stmt stmt, Stmt expectedStmt, bool removePar return expr == expectedStmt; } - private bool IsType(Expr expr) + private static bool IsType(Expr expr) where T : Type => IsType(expr, out _); - private bool IsType(Expr expr, [MaybeNullWhen(false)] out T value) + private static bool IsType(Expr expr, [MaybeNullWhen(false)] out T value) where T : Type => IsType(expr, expr.Type, out value); - private bool IsType(ValueDecl valueDecl) + private static bool IsType(ValueDecl valueDecl) where T : Type => IsType(valueDecl, out _); - private bool IsType(ValueDecl typeDecl, [MaybeNullWhen(false)] out T value) + private static bool IsType(ValueDecl typeDecl, [MaybeNullWhen(false)] out T value) where T : Type => IsType(typeDecl, typeDecl.Type, out value); - private bool IsType(Cursor? cursor, Type type) + private static bool IsType(Cursor? cursor, Type type) where T : Type => IsType(cursor, type, out _); - private bool IsType(Cursor? cursor, Type type, [MaybeNullWhen(false)] out T value) + private static bool IsType(Cursor? cursor, Type type, [MaybeNullWhen(false)] out T value) where T : Type { if (type is T t) @@ -5294,40 +5342,40 @@ private bool IsType(Cursor? cursor, Type type, [MaybeNullWhen(false)] out T v return false; } - private bool IsTypeConstantOrIncompleteArray(Expr expr) + private static bool IsTypeConstantOrIncompleteArray(Expr expr) => IsTypeConstantOrIncompleteArray(expr, out _); - private bool IsTypeConstantOrIncompleteArray(Expr expr, [MaybeNullWhen(false)] out ArrayType arrayType) + private static bool IsTypeConstantOrIncompleteArray(Expr expr, [MaybeNullWhen(false)] out ArrayType arrayType) => IsTypeConstantOrIncompleteArray(expr, expr.Type, out arrayType); private bool IsTypeConstantOrIncompleteArray(ValueDecl valueDecl) => IsTypeConstantOrIncompleteArray(valueDecl, out _); - private bool IsTypeConstantOrIncompleteArray(ValueDecl valueDecl, [MaybeNullWhen(false)] out ArrayType arrayType) + private static bool IsTypeConstantOrIncompleteArray(ValueDecl valueDecl, [MaybeNullWhen(false)] out ArrayType arrayType) => IsTypeConstantOrIncompleteArray(valueDecl, valueDecl.Type, out arrayType); - private bool IsTypeConstantOrIncompleteArray(Cursor? cursor, Type type) + private static bool IsTypeConstantOrIncompleteArray(Cursor? cursor, Type type) => IsTypeConstantOrIncompleteArray(cursor, type, out _); - private bool IsTypeConstantOrIncompleteArray(Cursor? cursor, Type type, [MaybeNullWhen(false)] out ArrayType arrayType) + private static bool IsTypeConstantOrIncompleteArray(Cursor? cursor, Type type, [MaybeNullWhen(false)] out ArrayType arrayType) => IsType(cursor, type, out arrayType) && (arrayType is ConstantArrayType or IncompleteArrayType); - private bool IsTypePointerOrReference(Expr expr) + private static bool IsTypePointerOrReference(Expr expr) => IsTypePointerOrReference(expr, expr.Type); - private bool IsTypePointerOrReference(ValueDecl valueDecl) + private static bool IsTypePointerOrReference(ValueDecl valueDecl) => IsTypePointerOrReference(valueDecl, valueDecl.Type); - private bool IsTypePointerOrReference(Cursor? cursor, Type type) + private static bool IsTypePointerOrReference(Cursor? cursor, Type type) => IsType(cursor, type) || IsType(cursor, type); - private bool IsTypeVoid(Cursor? cursor, Type type) + private static bool IsTypeVoid(Cursor? cursor, Type type) => IsType(cursor, type, out var builtinType) && (builtinType.Kind == CXType_Void); - internal static bool IsSupportedFixedSizedBufferType(string typeName) + internal bool IsSupportedFixedSizedBufferType(string typeName) { switch (typeName) { @@ -5344,7 +5392,8 @@ internal static bool IsSupportedFixedSizedBufferType(string typeName) case "uint": case "ulong": { - return true; + // We want to prefer InlineArray in modern code, as it is safer and supports more features + return !Config.GenerateLatestCode; } default: @@ -5515,15 +5564,14 @@ private bool IsUnchecked(string targetTypeName, Stmt stmt) || (IsUnsigned(targetTypeName) != IsUnsigned(explicitCastExprTypeName)); } - // case CX_StmtClass_CXXConstCastExpr: - // case CX_StmtClass_CXXDynamicCastExpr: - + case CX_StmtClass_CXXConstCastExpr: + case CX_StmtClass_CXXDynamicCastExpr: case CX_StmtClass_CXXReinterpretCastExpr: { - var reinterpretCastExpr = (CXXReinterpretCastExpr)stmt; + var namedCastExpr = (CXXNamedCastExpr)stmt; - return IsUnchecked(targetTypeName, reinterpretCastExpr.SubExprAsWritten) - || IsUnchecked(targetTypeName, reinterpretCastExpr.Handle.Evaluate); + return IsUnchecked(targetTypeName, namedCastExpr.SubExprAsWritten) + || IsUnchecked(targetTypeName, namedCastExpr.Handle.Evaluate); } // case CX_StmtClass_ObjCBridgedCastExpr: @@ -5760,7 +5808,7 @@ private bool IsUnchecked(string targetTypeName, Stmt stmt) return true; } - var sourceTypeName = GetTypeName(stmt, context: null, unaryOperator.SubExpr.Type, ignoreTransparentStructsWhereRequired: false, out _); + var sourceTypeName = GetTypeName(stmt, context: null, type: unaryOperator.SubExpr.Type, ignoreTransparentStructsWhereRequired: false, isTemplate: false, nativeTypeName: out _); switch (unaryOperator.Opcode) { @@ -6448,7 +6496,19 @@ private void UncheckStmt(string targetTypeName, Stmt stmt) { _outputBuilder.BeginUnchecked(); - var needsCast = IsStmtAsWritten(stmt, out _, removeParens: true) && (stmt.DeclContext is EnumDecl); + var needsCast = false; + + if (stmt.DeclContext is EnumDecl) + { + if (IsStmtAsWritten(stmt, out _, removeParens: true)) + { + needsCast = true; + } + else if (stmt is ImplicitCastExpr) + { + needsCast = true; + } + } if (IsStmtAsWritten(stmt, out var unaryExprOrTypeTraitExpr, removeParens: true) && ((CurrentContext.Cursor is VarDecl) || IsPrevContextDecl(out _, out _))) { @@ -6554,6 +6614,32 @@ private void Visit(IEnumerable cursors) private void Visit(IEnumerable cursors, IEnumerable excludedCursors) => Visit(cursors.Except(excludedCursors)); + private static IEnumerable GetAttributesFor(NamedDecl namedDecl) + { + var declAttrs = namedDecl.HasAttrs + ? namedDecl.Attrs + : Enumerable.Empty(); + + if (namedDecl is FieldDecl fieldDecl) + { + if (IsType(fieldDecl, out var typedefType)) + { + declAttrs = declAttrs.Concat(typedefType.Decl.Attrs); + } + } + else if (namedDecl is RecordDecl recordDecl) + { + var typedefName = recordDecl.TypedefNameForAnonDecl; + + if ((typedefName is not null) && typedefName.HasAttrs) + { + declAttrs = declAttrs.Concat(typedefName.Attrs); + } + } + + return declAttrs; + } + private void WithAttributes(NamedDecl namedDecl, bool onlySupportedOSPlatform = false, bool isTestOutput = false) { var outputBuilder = isTestOutput ? _testOutputBuilder : _outputBuilder; @@ -6569,30 +6655,9 @@ private void WithAttributes(NamedDecl namedDecl, bool onlySupportedOSPlatform = if (!isTestOutput) { - var declAttrs = namedDecl.HasAttrs - ? namedDecl.Attrs - : Enumerable.Empty(); - - if (namedDecl is FieldDecl fieldDecl) - { - if (IsType(fieldDecl, out var typedefType)) - { - declAttrs = declAttrs.Concat(typedefType.Decl.Attrs); - } - } - else if (namedDecl is RecordDecl recordDecl) - { - var typedefName = recordDecl.TypedefNameForAnonDecl; - - if ((typedefName is not null) && typedefName.HasAttrs) - { - declAttrs = declAttrs.Concat(typedefName.Attrs); - } - } - var obsoleteEmitted = false; - foreach (var attr in declAttrs) + foreach (var attr in GetAttributesFor(namedDecl)) { switch (attr.Kind) { @@ -6635,7 +6700,9 @@ private void WithAttributes(NamedDecl namedDecl, bool onlySupportedOSPlatform = case CX_AttrKind_MSNoVTable: case CX_AttrKind_MSAllocator: case CX_AttrKind_MaxFieldAlignment: + case CX_AttrKind_NoThrow: case CX_AttrKind_SelectAny: + case CX_AttrKind_TypeVisibility: case CX_AttrKind_Uuid: { // Nothing to handle @@ -6945,7 +7012,7 @@ private void WithUsings(NamedDecl namedDecl) { Debug.Assert(_outputBuilder is not null); - if (TryGetRemappedValue(namedDecl, _config.WithUsings, out var usings)) + if (TryGetRemappedValue(namedDecl, _config.WithUsings, out var usings, matchStar: true)) { foreach (var @using in usings) { diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs index 485b3d55..3dfb786b 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs @@ -42,6 +42,7 @@ public sealed class PInvokeGeneratorConfiguration private readonly SortedDictionary _withCallConvs; private readonly SortedDictionary _withClasses; private readonly SortedDictionary _withGuids; + private readonly SortedDictionary _withLengths; private readonly SortedDictionary _withLibraryPaths; private readonly SortedDictionary _withNamespaces; private readonly SortedDictionary _withTransparentStructs; @@ -95,6 +96,7 @@ public PInvokeGeneratorConfiguration(string language, string languageStandard, s _withCallConvs = []; _withClasses = []; _withGuids = []; + _withLengths = []; _withLibraryPaths = []; _withNamespaces = []; _withTransparentStructs = []; @@ -225,6 +227,8 @@ public IReadOnlyCollection ExcludedNames public bool GenerateFileScopedNamespaces => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); + public bool GenerateGenericPointerWrapper => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateGenericPointerWrapper); + public bool GenerateGuidMember => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateGuidMember); public bool GenerateHelperTypes => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateHelperTypes); @@ -452,6 +456,20 @@ public IReadOnlyDictionary WithGuids } } + [AllowNull] + public IReadOnlyDictionary WithLengths + { + get + { + return _withLengths; + } + + init + { + AddRange(_withLengths, value); + } + } + [AllowNull] public IReadOnlyDictionary WithLibraryPaths { diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs index 60343e0b..db91ccd4 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs @@ -84,4 +84,6 @@ public enum PInvokeGeneratorConfigurationOptions : long GenerateDisableRuntimeMarshalling = 1L << 36, GenerateCallConvMemberFunction = 1L << 37, + + GenerateGenericPointerWrapper = 1L << 38, } diff --git a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs index 8138dfb6..4b9ca7a2 100644 --- a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs @@ -307,7 +307,7 @@ public void EmitSystemSupport() public CSharpOutputBuilder BeginCSharpCode() { _ = _sb.Append(""); - return new CSharpOutputBuilder("__Internal", _config, markerMode: MarkerMode.Xml); + return new CSharpOutputBuilder("__Internal", _generator, markerMode: MarkerMode.Xml); } public void EndCSharpCode(CSharpOutputBuilder output) @@ -396,7 +396,7 @@ private void AddNativeTypeNameAttribute(string? nativeTypeName) return; } - foreach (var entry in _config.NativeTypeNamesToStrip) + foreach (var entry in _generator.Config.NativeTypeNamesToStrip) { nativeTypeName = nativeTypeName.Replace(entry, "", StringComparison.Ordinal); } diff --git a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.cs b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.cs index 0d8d5126..c2526530 100644 --- a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.cs +++ b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.cs @@ -8,9 +8,9 @@ namespace ClangSharp.XML; -internal partial class XmlOutputBuilder(string name, PInvokeGeneratorConfiguration config) : IOutputBuilder +internal partial class XmlOutputBuilder(string name, PInvokeGenerator generator) : IOutputBuilder { - private readonly PInvokeGeneratorConfiguration _config = config; + private readonly PInvokeGenerator _generator = generator; public string Name { get; } = name; public string Extension { get; } = ".xml"; diff --git a/sources/ClangSharp/Cursors/Attrs/Attr.cs b/sources/ClangSharp/Cursors/Attrs/Attr.cs index 4d4578b2..435f3832 100644 --- a/sources/ClangSharp/Cursors/Attrs/Attr.cs +++ b/sources/ClangSharp/Cursors/Attrs/Attr.cs @@ -20,11 +20,17 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_Invalid => new Attr(handle), CX_AttrKind_AddressSpace => new TypeAttr(handle), CX_AttrKind_AnnotateType => new TypeAttr(handle), + CX_AttrKind_ArmIn => new TypeAttr(handle), + CX_AttrKind_ArmInOut => new TypeAttr(handle), CX_AttrKind_ArmMveStrictPolymorphism => new TypeAttr(handle), + CX_AttrKind_ArmOut => new TypeAttr(handle), + CX_AttrKind_ArmPreserves => new TypeAttr(handle), CX_AttrKind_ArmStreaming => new TypeAttr(handle), + CX_AttrKind_ArmStreamingCompatible => new TypeAttr(handle), CX_AttrKind_BTFTypeTag => new TypeAttr(handle), CX_AttrKind_CmseNSCall => new TypeAttr(handle), CX_AttrKind_HLSLGroupSharedAddressSpace => new TypeAttr(handle), + CX_AttrKind_HLSLParamModifier => new TypeAttr(handle), CX_AttrKind_NoDeref => new TypeAttr(handle), CX_AttrKind_ObjCGC => new TypeAttr(handle), CX_AttrKind_ObjCInertUnsafeUnretained => new TypeAttr(handle), @@ -45,15 +51,16 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_TypeNullableResult => new TypeAttr(handle), CX_AttrKind_UPtr => new TypeAttr(handle), CX_AttrKind_WebAssemblyFuncref => new TypeAttr(handle), + CX_AttrKind_CodeAlign => new StmtAttr(handle), CX_AttrKind_FallThrough => new StmtAttr(handle), CX_AttrKind_Likely => new StmtAttr(handle), CX_AttrKind_MustTail => new StmtAttr(handle), CX_AttrKind_OpenCLUnrollHint => new StmtAttr(handle), - CX_AttrKind_Suppress => new StmtAttr(handle), CX_AttrKind_Unlikely => new StmtAttr(handle), CX_AttrKind_AlwaysInline => new DeclOrStmtAttr(handle), CX_AttrKind_NoInline => new DeclOrStmtAttr(handle), CX_AttrKind_NoMerge => new DeclOrStmtAttr(handle), + CX_AttrKind_Suppress => new DeclOrStmtAttr(handle), CX_AttrKind_AArch64SVEPcs => new InheritableAttr(handle), CX_AttrKind_AArch64VectorPcs => new InheritableAttr(handle), CX_AttrKind_AMDGPUKernelCall => new InheritableAttr(handle), @@ -63,6 +70,7 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_FastCall => new InheritableAttr(handle), CX_AttrKind_IntelOclBicc => new InheritableAttr(handle), CX_AttrKind_LifetimeBound => new InheritableAttr(handle), + CX_AttrKind_M68kRTD => new InheritableAttr(handle), CX_AttrKind_MSABI => new InheritableAttr(handle), CX_AttrKind_NSReturnsRetained => new InheritableAttr(handle), CX_AttrKind_ObjCOwnership => new InheritableAttr(handle), @@ -114,6 +122,8 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_ArcWeakrefUnavailable => new InheritableAttr(handle), CX_AttrKind_ArgumentWithTypeTag => new InheritableAttr(handle), CX_AttrKind_ArmBuiltinAlias => new InheritableAttr(handle), + CX_AttrKind_ArmLocallyStreaming => new InheritableAttr(handle), + CX_AttrKind_ArmNew => new InheritableAttr(handle), CX_AttrKind_Artificial => new InheritableAttr(handle), CX_AttrKind_AsmLabel => new InheritableAttr(handle), CX_AttrKind_AssertCapability => new InheritableAttr(handle), @@ -124,6 +134,7 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_Availability => new InheritableAttr(handle), CX_AttrKind_AvailableOnlyInDefaultEvalMethod => new InheritableAttr(handle), CX_AttrKind_BPFPreserveAccessIndex => new InheritableAttr(handle), + CX_AttrKind_BPFPreserveStaticOffset => new InheritableAttr(handle), CX_AttrKind_BTFDeclTag => new InheritableAttr(handle), CX_AttrKind_Blocks => new InheritableAttr(handle), CX_AttrKind_Builtin => new InheritableAttr(handle), @@ -152,6 +163,7 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_CapturedRecord => new InheritableAttr(handle), CX_AttrKind_Cleanup => new InheritableAttr(handle), CX_AttrKind_CmseNSEntry => new InheritableAttr(handle), + CX_AttrKind_CodeModel => new InheritableAttr(handle), CX_AttrKind_CodeSeg => new InheritableAttr(handle), CX_AttrKind_Cold => new InheritableAttr(handle), CX_AttrKind_Common => new InheritableAttr(handle), @@ -162,6 +174,12 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_ConsumableAutoCast => new InheritableAttr(handle), CX_AttrKind_ConsumableSetOnRead => new InheritableAttr(handle), CX_AttrKind_Convergent => new InheritableAttr(handle), + CX_AttrKind_CoroDisableLifetimeBound => new InheritableAttr(handle), + CX_AttrKind_CoroLifetimeBound => new InheritableAttr(handle), + CX_AttrKind_CoroOnlyDestroyWhenComplete => new InheritableAttr(handle), + CX_AttrKind_CoroReturnType => new InheritableAttr(handle), + CX_AttrKind_CoroWrapper => new InheritableAttr(handle), + CX_AttrKind_CountedBy => new InheritableAttr(handle), CX_AttrKind_DLLExport => new InheritableAttr(handle), CX_AttrKind_DLLExportStaticLocal => new InheritableAttr(handle), CX_AttrKind_DLLImport => new InheritableAttr(handle), @@ -209,6 +227,7 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_M68kInterrupt => new InheritableAttr(handle), CX_AttrKind_MIGServerRoutine => new InheritableAttr(handle), CX_AttrKind_MSAllocator => new InheritableAttr(handle), + CX_AttrKind_MSConstexpr => new InheritableAttr(handle), CX_AttrKind_MSInheritance => new InheritableAttr(handle), CX_AttrKind_MSNoVTable => new InheritableAttr(handle), CX_AttrKind_MSP430Interrupt => new InheritableAttr(handle), @@ -291,6 +310,7 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_PragmaClangRodataSection => new InheritableAttr(handle), CX_AttrKind_PragmaClangTextSection => new InheritableAttr(handle), CX_AttrKind_PreferredName => new InheritableAttr(handle), + CX_AttrKind_PreferredType => new InheritableAttr(handle), CX_AttrKind_PtGuardedBy => new InheritableAttr(handle), CX_AttrKind_PtGuardedVar => new InheritableAttr(handle), CX_AttrKind_Pure => new InheritableAttr(handle), @@ -325,6 +345,8 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_SwiftBridge => new InheritableAttr(handle), CX_AttrKind_SwiftBridgedTypedef => new InheritableAttr(handle), CX_AttrKind_SwiftError => new InheritableAttr(handle), + CX_AttrKind_SwiftImportAsNonGeneric => new InheritableAttr(handle), + CX_AttrKind_SwiftImportPropertyAsAccessors => new InheritableAttr(handle), CX_AttrKind_SwiftName => new InheritableAttr(handle), CX_AttrKind_SwiftNewType => new InheritableAttr(handle), CX_AttrKind_SwiftPrivate => new InheritableAttr(handle), @@ -389,6 +411,8 @@ private protected Attr(CXCursor handle) : base(handle, handle.Kind) CX_AttrKind_Overloadable => new Attr(handle), CX_AttrKind_RenderScriptKernel => new Attr(handle), CX_AttrKind_SwiftObjCMembers => new Attr(handle), + CX_AttrKind_SwiftVersionedAddition => new Attr(handle), + CX_AttrKind_SwiftVersionedRemoval => new Attr(handle), CX_AttrKind_Thread => new Attr(handle), _ => new Attr(handle), }; diff --git a/sources/ClangSharp/Cursors/Cursor.cs b/sources/ClangSharp/Cursors/Cursor.cs index e5ddef9f..95783bcb 100644 --- a/sources/ClangSharp/Cursors/Cursor.cs +++ b/sources/ClangSharp/Cursors/Cursor.cs @@ -48,15 +48,7 @@ public IReadOnlyList CursorChildren TranslationUnit.Handle.Handle }; -#if NET6_0_OR_GREATER _ = clang.visitChildren(Handle, &Visitor, client_data); -#else - var visitor = (CXCursorVisitor)Visitor; - var pVisitor = (delegate* unmanaged[Cdecl])Marshal.GetFunctionPointerForDelegate(visitor); - - _ = clang.visitChildren(Handle, pVisitor, client_data); - GC.KeepAlive(visitor); -#endif var cursorChildren = (List?)cursorChildrenHandle.Target; Debug.Assert(cursorChildren is not null); @@ -64,9 +56,7 @@ public IReadOnlyList CursorChildren _cursorChildren = cursorChildren; cursorChildrenHandle.Free(); -#if NET6_0_OR_GREATER - [UnmanagedCallersOnly(CallConvs = new System.Type[] { typeof(CallConvCdecl) })] -#endif + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])] static CXChildVisitResult Visitor(CXCursor cursor, CXCursor parent, void* client_data) { var cursorChildren = (List?)GCHandle.FromIntPtr(((nint*)client_data)[0]).Target; diff --git a/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs index 3faaea16..a508f38a 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs @@ -14,7 +14,7 @@ public class CXXRecordDecl : RecordDecl private readonly Lazy> _ctors; private readonly Lazy _dependentLambdaCallOperator; private readonly Lazy _describedClassTemplate; - private readonly Lazy _destructor; + private readonly Lazy _destructor; private readonly Lazy> _friends; private readonly Lazy _instantiatedFromMemberClass; private readonly Lazy _lambdaCallOperator; @@ -63,7 +63,10 @@ private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind _dependentLambdaCallOperator = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DependentLambdaCallOperator)); _describedClassTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DescribedCursorTemplate)); - _destructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Destructor)); + _destructor = new Lazy(() => { + var destructor = Handle.Destructor; + return destructor.IsNull ? null : TranslationUnit.GetOrCreate(Handle.Destructor); + }); _friends = new Lazy>(() => { var numFriends = Handle.NumFriends; @@ -126,7 +129,7 @@ private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind public ClassTemplateDecl DescribedClassTemplate => _describedClassTemplate.Value; - public CXXDestructorDecl Destructor => _destructor.Value; + public CXXDestructorDecl? Destructor => _destructor.Value; public IReadOnlyList Friends => _friends.Value; diff --git a/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs deleted file mode 100644 index 00750683..00000000 --- a/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using ClangSharp.Interop; -using static ClangSharp.Interop.CXCursorKind; -using static ClangSharp.Interop.CX_DeclKind; - -namespace ClangSharp; - -public sealed class ClassScopeFunctionSpecializationDecl : Decl -{ - private readonly Lazy _specialization; - private readonly Lazy> _templateArgs; - - internal ClassScopeFunctionSpecializationDecl(CXCursor handle) : base(handle, CXCursor_UnexposedDecl, CX_DeclKind_ClassScopeFunctionSpecialization) - { - _specialization = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSpecialization(0))); - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); - - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); - templateArgs.Add(templateArg); - } - - return templateArgs; - }); - } - - public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; - - public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); - - public CXXMethodDecl Specialization => _specialization.Value; - - public IReadOnlyList TemplateArgs => _templateArgs.Value; -} diff --git a/sources/ClangSharp/Cursors/Decls/Decl.cs b/sources/ClangSharp/Cursors/Decls/Decl.cs index e509e4a5..741afb59 100644 --- a/sources/ClangSharp/Cursors/Decls/Decl.cs +++ b/sources/ClangSharp/Cursors/Decls/Decl.cs @@ -15,7 +15,7 @@ public class Decl : Cursor private readonly Lazy _body; private readonly Lazy _canonicalDecl; private readonly Lazy> _decls; - private readonly Lazy _describedTemplate; + private readonly Lazy _describedTemplate; private readonly Lazy _mostRecentDecl; private readonly Lazy _nextDeclInContext; private readonly Lazy _nonClosureContext; @@ -62,7 +62,11 @@ private protected Decl(CXCursor handle, CXCursorKind expectedCursorKind, CX_Decl return decls; }); ; - _describedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DescribedTemplate)); + _describedTemplate = new Lazy(() => + { + CXCursor describedTemplate = Handle.DescribedTemplate; + return describedTemplate.IsNull ? null : TranslationUnit.GetOrCreate(describedTemplate); + }); _mostRecentDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.MostRecentDecl)); _nextDeclInContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NextDeclInContext)); _nonClosureContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NonClosureContext)); @@ -90,7 +94,11 @@ private protected Decl(CXCursor handle, CXCursorKind expectedCursorKind, CX_Decl public IReadOnlyList Decls => _decls.Value; - public TemplateDecl DescribedTemplate => _describedTemplate.Value; + /// + /// Per clang documentation: This returns null for partial specializations, because they are not modeled as TemplateDecls. + /// Use DescribedTemplateParams to handle those cases. + /// + public TemplateDecl? DescribedTemplate => _describedTemplate.Value; public bool HasAttrs => Handle.HasAttrs; @@ -167,93 +175,92 @@ public bool IsStdNamespace internal static new Decl Create(CXCursor handle) => handle.DeclKind switch { CX_DeclKind_Invalid => new Decl(handle, handle.kind, handle.DeclKind), - CX_DeclKind_AccessSpec => new AccessSpecDecl(handle), - CX_DeclKind_Block => new BlockDecl(handle), - CX_DeclKind_Captured => new CapturedDecl(handle), - CX_DeclKind_ClassScopeFunctionSpecialization => new ClassScopeFunctionSpecializationDecl(handle), - CX_DeclKind_Empty => new EmptyDecl(handle), - CX_DeclKind_Export => new ExportDecl(handle), - CX_DeclKind_ExternCContext => new ExternCContextDecl(handle), - CX_DeclKind_FileScopeAsm => new FileScopeAsmDecl(handle), - CX_DeclKind_Friend => new FriendDecl(handle), - CX_DeclKind_FriendTemplate => new FriendTemplateDecl(handle), - CX_DeclKind_ImplicitConceptSpecialization => new ImplicitConceptSpecializationDecl(handle), - CX_DeclKind_Import => new ImportDecl(handle), - CX_DeclKind_LifetimeExtendedTemporary => new LifetimeExtendedTemporaryDecl(handle), + CX_DeclKind_TranslationUnit => new TranslationUnitDecl(handle), + CX_DeclKind_RequiresExprBody => new RequiresExprBodyDecl(handle), CX_DeclKind_LinkageSpec => new LinkageSpecDecl(handle), - CX_DeclKind_Using => new UsingDecl(handle), - CX_DeclKind_UsingEnum => new UsingEnumDecl(handle), - CX_DeclKind_Label => new LabelDecl(handle), - CX_DeclKind_HLSLBuffer => new HLSLBufferDecl(handle), - CX_DeclKind_Namespace => new NamespaceDecl(handle), - CX_DeclKind_NamespaceAlias => new NamespaceAliasDecl(handle), - CX_DeclKind_ObjCCompatibleAlias => new ObjCCompatibleAliasDecl(handle), - CX_DeclKind_ObjCCategory => new ObjCCategoryDecl(handle), - CX_DeclKind_ObjCCategoryImpl => new ObjCCategoryImplDecl(handle), - CX_DeclKind_ObjCImplementation => new ObjCImplementationDecl(handle), - CX_DeclKind_ObjCInterface => new ObjCInterfaceDecl(handle), - CX_DeclKind_ObjCProtocol => new ObjCProtocolDecl(handle), + CX_DeclKind_ExternCContext => new ExternCContextDecl(handle), + CX_DeclKind_Export => new ExportDecl(handle), + CX_DeclKind_Captured => new CapturedDecl(handle), + CX_DeclKind_Block => new BlockDecl(handle), + CX_DeclKind_TopLevelStmt => new TopLevelStmtDecl(handle), + CX_DeclKind_StaticAssert => new StaticAssertDecl(handle), + CX_DeclKind_PragmaDetectMismatch => new PragmaDetectMismatchDecl(handle), + CX_DeclKind_PragmaComment => new PragmaCommentDecl(handle), + CX_DeclKind_ObjCPropertyImpl => new ObjCPropertyImplDecl(handle), + CX_DeclKind_OMPThreadPrivate => new OMPThreadPrivateDecl(handle), + CX_DeclKind_OMPRequires => new OMPRequiresDecl(handle), + CX_DeclKind_OMPAllocate => new OMPAllocateDecl(handle), CX_DeclKind_ObjCMethod => new ObjCMethodDecl(handle), - CX_DeclKind_ObjCProperty => new ObjCPropertyDecl(handle), - CX_DeclKind_BuiltinTemplate => new BuiltinTemplateDecl(handle), - CX_DeclKind_Concept => new ConceptDecl(handle), - CX_DeclKind_ClassTemplate => new ClassTemplateDecl(handle), - CX_DeclKind_FunctionTemplate => new FunctionTemplateDecl(handle), - CX_DeclKind_TypeAliasTemplate => new TypeAliasTemplateDecl(handle), - CX_DeclKind_VarTemplate => new VarTemplateDecl(handle), - CX_DeclKind_TemplateTemplateParm => new TemplateTemplateParmDecl(handle), - CX_DeclKind_Enum => new EnumDecl(handle), - CX_DeclKind_Record => new RecordDecl(handle), - CX_DeclKind_CXXRecord => new CXXRecordDecl(handle), - CX_DeclKind_ClassTemplateSpecialization => new ClassTemplateSpecializationDecl(handle), - CX_DeclKind_ClassTemplatePartialSpecialization => new ClassTemplatePartialSpecializationDecl(handle), - CX_DeclKind_TemplateTypeParm => new TemplateTypeParmDecl(handle), - CX_DeclKind_ObjCTypeParam => new ObjCTypeParamDecl(handle), - CX_DeclKind_TypeAlias => new TypeAliasDecl(handle), - CX_DeclKind_Typedef => new TypedefDecl(handle), - CX_DeclKind_UnresolvedUsingTypename => new UnresolvedUsingTypenameDecl(handle), - CX_DeclKind_UnresolvedUsingIfExists => new UnresolvedUsingIfExistsDecl(handle), - CX_DeclKind_UsingDirective => new UsingDirectiveDecl(handle), - CX_DeclKind_UsingPack => new UsingPackDecl(handle), - CX_DeclKind_UsingShadow => new UsingShadowDecl(handle), - CX_DeclKind_ConstructorUsingShadow => new ConstructorUsingShadowDecl(handle), - CX_DeclKind_Binding => new BindingDecl(handle), - CX_DeclKind_Field => new FieldDecl(handle), - CX_DeclKind_ObjCAtDefsField => new ObjCAtDefsFieldDecl(handle), - CX_DeclKind_ObjCIvar => new ObjCIvarDecl(handle), + CX_DeclKind_ObjCProtocol => new ObjCProtocolDecl(handle), + CX_DeclKind_ObjCInterface => new ObjCInterfaceDecl(handle), + CX_DeclKind_ObjCImplementation => new ObjCImplementationDecl(handle), + CX_DeclKind_ObjCCategoryImpl => new ObjCCategoryImplDecl(handle), + CX_DeclKind_ObjCCategory => new ObjCCategoryDecl(handle), + CX_DeclKind_Namespace => new NamespaceDecl(handle), + CX_DeclKind_HLSLBuffer => new HLSLBufferDecl(handle), + CX_DeclKind_OMPDeclareReduction => new OMPDeclareReductionDecl(handle), + CX_DeclKind_OMPDeclareMapper => new OMPDeclareMapperDecl(handle), + CX_DeclKind_UnresolvedUsingValue => new UnresolvedUsingValueDecl(handle), + CX_DeclKind_UnnamedGlobalConstant => new UnnamedGlobalConstantDecl(handle), + CX_DeclKind_TemplateParamObject => new TemplateParamObjectDecl(handle), + CX_DeclKind_MSGuid => new MSGuidDecl(handle), + CX_DeclKind_IndirectField => new IndirectFieldDecl(handle), + CX_DeclKind_EnumConstant => new EnumConstantDecl(handle), CX_DeclKind_Function => new FunctionDecl(handle), - CX_DeclKind_CXXDeductionGuide => new CXXDeductionGuideDecl(handle), CX_DeclKind_CXXMethod => new CXXMethodDecl(handle), - CX_DeclKind_CXXConstructor => new CXXConstructorDecl(handle), - CX_DeclKind_CXXConversion => new CXXConversionDecl(handle), CX_DeclKind_CXXDestructor => new CXXDestructorDecl(handle), - CX_DeclKind_MSProperty => new MSPropertyDecl(handle), - CX_DeclKind_NonTypeTemplateParm => new NonTypeTemplateParmDecl(handle), + CX_DeclKind_CXXConversion => new CXXConversionDecl(handle), + CX_DeclKind_CXXConstructor => new CXXConstructorDecl(handle), + CX_DeclKind_CXXDeductionGuide => new CXXDeductionGuideDecl(handle), CX_DeclKind_Var => new VarDecl(handle), - CX_DeclKind_Decomposition => new DecompositionDecl(handle), - CX_DeclKind_ImplicitParam => new ImplicitParamDecl(handle), - CX_DeclKind_OMPCapturedExpr => new OMPCapturedExprDecl(handle), - CX_DeclKind_ParmVar => new ParmVarDecl(handle), CX_DeclKind_VarTemplateSpecialization => new VarTemplateSpecializationDecl(handle), CX_DeclKind_VarTemplatePartialSpecialization => new VarTemplatePartialSpecializationDecl(handle), - CX_DeclKind_EnumConstant => new EnumConstantDecl(handle), - CX_DeclKind_IndirectField => new IndirectFieldDecl(handle), - CX_DeclKind_MSGuid => new MSGuidDecl(handle), - CX_DeclKind_OMPDeclareMapper => new OMPDeclareMapperDecl(handle), - CX_DeclKind_OMPDeclareReduction => new OMPDeclareReductionDecl(handle), - CX_DeclKind_TemplateParamObject => new TemplateParamObjectDecl(handle), - CX_DeclKind_UnnamedGlobalConstant => new UnnamedGlobalConstantDecl(handle), - CX_DeclKind_UnresolvedUsingValue => new UnresolvedUsingValueDecl(handle), - CX_DeclKind_OMPAllocate => new OMPAllocateDecl(handle), - CX_DeclKind_OMPRequires => new OMPRequiresDecl(handle), - CX_DeclKind_OMPThreadPrivate => new OMPThreadPrivateDecl(handle), - CX_DeclKind_ObjCPropertyImpl => new ObjCPropertyImplDecl(handle), - CX_DeclKind_PragmaComment => new PragmaCommentDecl(handle), - CX_DeclKind_PragmaDetectMismatch => new PragmaDetectMismatchDecl(handle), - CX_DeclKind_RequiresExprBody => new RequiresExprBodyDecl(handle), - CX_DeclKind_StaticAssert => new StaticAssertDecl(handle), - CX_DeclKind_TopLevelStmt => new TopLevelStmtDecl(handle), - CX_DeclKind_TranslationUnit => new TranslationUnitDecl(handle), + CX_DeclKind_ParmVar => new ParmVarDecl(handle), + CX_DeclKind_OMPCapturedExpr => new OMPCapturedExprDecl(handle), + CX_DeclKind_ImplicitParam => new ImplicitParamDecl(handle), + CX_DeclKind_Decomposition => new DecompositionDecl(handle), + CX_DeclKind_NonTypeTemplateParm => new NonTypeTemplateParmDecl(handle), + CX_DeclKind_MSProperty => new MSPropertyDecl(handle), + CX_DeclKind_Field => new FieldDecl(handle), + CX_DeclKind_ObjCIvar => new ObjCIvarDecl(handle), + CX_DeclKind_ObjCAtDefsField => new ObjCAtDefsFieldDecl(handle), + CX_DeclKind_Binding => new BindingDecl(handle), + CX_DeclKind_UsingShadow => new UsingShadowDecl(handle), + CX_DeclKind_ConstructorUsingShadow => new ConstructorUsingShadowDecl(handle), + CX_DeclKind_UsingPack => new UsingPackDecl(handle), + CX_DeclKind_UsingDirective => new UsingDirectiveDecl(handle), + CX_DeclKind_UnresolvedUsingIfExists => new UnresolvedUsingIfExistsDecl(handle), + CX_DeclKind_Record => new RecordDecl(handle), + CX_DeclKind_CXXRecord => new CXXRecordDecl(handle), + CX_DeclKind_ClassTemplateSpecialization => new ClassTemplateSpecializationDecl(handle), + CX_DeclKind_ClassTemplatePartialSpecialization => new ClassTemplatePartialSpecializationDecl(handle), + CX_DeclKind_Enum => new EnumDecl(handle), + CX_DeclKind_UnresolvedUsingTypename => new UnresolvedUsingTypenameDecl(handle), + CX_DeclKind_Typedef => new TypedefDecl(handle), + CX_DeclKind_TypeAlias => new TypeAliasDecl(handle), + CX_DeclKind_ObjCTypeParam => new ObjCTypeParamDecl(handle), + CX_DeclKind_TemplateTypeParm => new TemplateTypeParmDecl(handle), + CX_DeclKind_TemplateTemplateParm => new TemplateTemplateParmDecl(handle), + CX_DeclKind_VarTemplate => new VarTemplateDecl(handle), + CX_DeclKind_TypeAliasTemplate => new TypeAliasTemplateDecl(handle), + CX_DeclKind_FunctionTemplate => new FunctionTemplateDecl(handle), + CX_DeclKind_ClassTemplate => new ClassTemplateDecl(handle), + CX_DeclKind_Concept => new ConceptDecl(handle), + CX_DeclKind_BuiltinTemplate => new BuiltinTemplateDecl(handle), + CX_DeclKind_ObjCProperty => new ObjCPropertyDecl(handle), + CX_DeclKind_ObjCCompatibleAlias => new ObjCCompatibleAliasDecl(handle), + CX_DeclKind_NamespaceAlias => new NamespaceAliasDecl(handle), + CX_DeclKind_Label => new LabelDecl(handle), + CX_DeclKind_UsingEnum => new UsingEnumDecl(handle), + CX_DeclKind_Using => new UsingDecl(handle), + CX_DeclKind_LifetimeExtendedTemporary => new LifetimeExtendedTemporaryDecl(handle), + CX_DeclKind_Import => new ImportDecl(handle), + CX_DeclKind_ImplicitConceptSpecialization => new ImplicitConceptSpecializationDecl(handle), + CX_DeclKind_FriendTemplate => new FriendTemplateDecl(handle), + CX_DeclKind_Friend => new FriendDecl(handle), + CX_DeclKind_FileScopeAsm => new FileScopeAsmDecl(handle), + CX_DeclKind_Empty => new EmptyDecl(handle), + CX_DeclKind_AccessSpec => new AccessSpecDecl(handle), _ => new Decl(handle, handle.kind, handle.DeclKind), }; } diff --git a/sources/ClangSharp/Cursors/Decls/FieldDecl.cs b/sources/ClangSharp/Cursors/Decls/FieldDecl.cs index 42123daa..35448425 100644 --- a/sources/ClangSharp/Cursors/Decls/FieldDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FieldDecl.cs @@ -4,6 +4,7 @@ using ClangSharp.Interop; using static ClangSharp.Interop.CXCursorKind; using static ClangSharp.Interop.CX_DeclKind; +using System.Diagnostics; namespace ClangSharp; @@ -11,6 +12,7 @@ public class FieldDecl : DeclaratorDecl, IMergeable { private readonly Lazy _bitWidth; private readonly Lazy _inClassInitializer; + private readonly Lazy _isAnonymousField; internal FieldDecl(CXCursor handle) : this(handle, CXCursor_FieldDecl, CX_DeclKind_Field) { @@ -25,6 +27,38 @@ private protected FieldDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX _bitWidth = new Lazy(() => TranslationUnit.GetOrCreate(Handle.BitWidth)); _inClassInitializer = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InClassInitializer)); + _isAnonymousField = new Lazy(() => { + var name = Name; + + if (string.IsNullOrWhiteSpace(name)) + { + return true; + } + + var anonymousNameStartIndex = name.IndexOf("::(", StringComparison.Ordinal); + + if (anonymousNameStartIndex != -1) + { + anonymousNameStartIndex += 2; + name = name[anonymousNameStartIndex..]; + } + + if (name.StartsWith('(')) + { + Debug.Assert(name.StartsWith("(anonymous enum at ", StringComparison.Ordinal) || + name.StartsWith("(anonymous struct at ", StringComparison.Ordinal) || + name.StartsWith("(anonymous union at ", StringComparison.Ordinal) || + name.StartsWith("(unnamed enum at ", StringComparison.Ordinal) || + name.StartsWith("(unnamed struct at ", StringComparison.Ordinal) || + name.StartsWith("(unnamed union at ", StringComparison.Ordinal) || + name.StartsWith("(unnamed at ", StringComparison.Ordinal)); + Debug.Assert(name.EndsWith(')')); + + return true; + } + + return false; + }); } public Expr BitWidth => _bitWidth.Value; @@ -37,7 +71,7 @@ private protected FieldDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX public Expr InClassInitializer => _inClassInitializer.Value; - public bool IsAnonymousField => string.IsNullOrWhiteSpace(Name); + public bool IsAnonymousField => _isAnonymousField.Value; public bool IsAnonymousStructOrUnion => Handle.IsAnonymousStructOrUnion; diff --git a/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs b/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs index 0f083446..c1054c26 100644 --- a/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs @@ -107,7 +107,7 @@ private protected FunctionDecl(CXCursor handle, CXCursorKind expectedCursorKind, public bool IsOverloadedOperator => Handle.IsOverloadedOperator; - public bool IsPure => Handle.IsPure; + public bool IsPure => Handle.IsPureVirtual; public bool IsStatic => Handle.IsStatic; diff --git a/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs b/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs index 99c5b809..d8d64f90 100644 --- a/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs @@ -28,6 +28,10 @@ internal ParmVarDecl(CXCursor handle) : base(handle, CXCursor_ParmDecl, CX_DeclK public bool HasDefaultArg => Handle.HasDefaultArg; + public bool HasUnparsedDefaultArg => Handle.HasUnparsedDefaultArg; + + public bool HasUninstantiatedDefaultArg => Handle.HasUninstantiatedDefaultArg; + public bool HasInheritedDefaultArg => Handle.HasInheritedDefaultArg; public Type OriginalType => _originalType.Value; diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs index 53a94e41..c4180a7d 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs @@ -21,8 +21,6 @@ internal CXXDefaultArgExpr(CXCursor handle) : base(handle, CXCursor_UnexposedExp _usedContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UsedContext) as IDeclContext); } - public Expr Expr => Param.DefaultArg; - public ParmVarDecl Param => _param.Value; public IDeclContext? UsedContext => _usedContext.Value; diff --git a/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs b/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs index 384d543c..3d340dd2 100644 --- a/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs @@ -4,8 +4,8 @@ using System.Runtime.InteropServices; using ClangSharp.Interop; using static ClangSharp.Interop.CXCursorKind; -using static ClangSharp.Interop.CX_CharacterKind; using static ClangSharp.Interop.CX_StmtClass; +using static ClangSharp.Interop.CX_StringKind; namespace ClangSharp; @@ -15,7 +15,7 @@ internal StringLiteral(CXCursor handle) : base(handle, CXCursor_StringLiteral, C { } - public CX_CharacterKind Kind => Handle.CharacterLiteralKind; + public CX_StringKind Kind => Handle.StringLiteralKind; public unsafe string String { @@ -33,28 +33,28 @@ public unsafe string String switch (Kind) { - case CX_CLK_Ascii: - case CX_CLK_UTF8: + case CX_SLK_Ordinary: + case CX_SLK_UTF8: { return new ReadOnlySpan(pCString, length).AsString(); } - case CX_CLK_Wide: + case CX_SLK_Wide: { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - goto case CX_CLK_UTF16; + goto case CX_SLK_UTF16; } - goto case CX_CLK_UTF32; + goto case CX_SLK_UTF32; } - case CX_CLK_UTF16: + case CX_SLK_UTF16: { return new ReadOnlySpan(pCString, length).AsString(); } - case CX_CLK_UTF32: + case CX_SLK_UTF32: { return new ReadOnlySpan(pCString, length).AsString(); } diff --git a/sources/ClangSharp/Cursors/Refs/OverloadedDeclRef.cs b/sources/ClangSharp/Cursors/Refs/OverloadedDeclRef.cs new file mode 100644 index 00000000..47e82638 --- /dev/null +++ b/sources/ClangSharp/Cursors/Refs/OverloadedDeclRef.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using ClangSharp.Interop; +using static ClangSharp.Interop.CXCursorKind; + +namespace ClangSharp; + +public sealed class OverloadedDeclRef : Ref +{ + private readonly Lazy> _overloadedDecls; + + internal OverloadedDeclRef(CXCursor handle) : base(handle, CXCursor_OverloadedDeclRef) + { + _overloadedDecls = new Lazy>(() => { + var num = Handle.NumOverloadedDecls; + return Enumerable.Range(0, (int)num) + .Select(i => Handle.GetOverloadedDecl((uint)i)) + .Select(c => TranslationUnit.GetOrCreate(c)) + .ToArray(); + }); + } + + public IEnumerable OverloadedDecls => _overloadedDecls.Value; +} diff --git a/sources/ClangSharp/Cursors/Refs/Ref.cs b/sources/ClangSharp/Cursors/Refs/Ref.cs index b4dfe8f6..8a8901fb 100644 --- a/sources/ClangSharp/Cursors/Refs/Ref.cs +++ b/sources/ClangSharp/Cursors/Refs/Ref.cs @@ -34,6 +34,12 @@ private protected Ref(CXCursor handle, CXCursorKind expectedCursorKind) : base(h break; } + case CXCursor_OverloadedDeclRef: + { + result = new OverloadedDeclRef(handle); + break; + } + case CXCursor_ObjCSuperClassRef: case CXCursor_ObjCProtocolRef: case CXCursor_ObjCClassRef: @@ -42,7 +48,6 @@ private protected Ref(CXCursor handle, CXCursorKind expectedCursorKind) : base(h case CXCursor_NamespaceRef: case CXCursor_MemberRef: case CXCursor_LabelRef: - case CXCursor_OverloadedDeclRef: case CXCursor_VariableRef: { result = new Ref(handle, handle.Kind); diff --git a/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs b/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs index be7de161..db229dab 100644 --- a/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs @@ -9,12 +9,8 @@ namespace ClangSharp; -public sealed class CompoundStmt : Stmt +public sealed class CompoundStmt(CXCursor handle) : Stmt(handle, CXCursor_CompoundStmt, CX_StmtClass_CompoundStmt) { - public CompoundStmt(CXCursor handle) : base(handle, CXCursor_CompoundStmt, CX_StmtClass_CompoundStmt) - { - } - public IReadOnlyList Body => Children; public Stmt? BodyBack diff --git a/sources/ClangSharp/Cursors/Stmts/OMPScopeDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPScopeDirective.cs new file mode 100644 index 00000000..6af67eb6 --- /dev/null +++ b/sources/ClangSharp/Cursors/Stmts/OMPScopeDirective.cs @@ -0,0 +1,14 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using ClangSharp.Interop; +using static ClangSharp.Interop.CXCursorKind; +using static ClangSharp.Interop.CX_StmtClass; + +namespace ClangSharp; + +public sealed class OMPScopeDirective : OMPExecutableDirective +{ + internal OMPScopeDirective(CXCursor handle) : base(handle, CXCursor_OMPScopeDirective, CX_StmtClass_OMPScopeDirective) + { + } +} diff --git a/sources/ClangSharp/Cursors/Stmts/Stmt.cs b/sources/ClangSharp/Cursors/Stmts/Stmt.cs index 24e49ab3..bab15c8e 100644 --- a/sources/ClangSharp/Cursors/Stmts/Stmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/Stmt.cs @@ -124,239 +124,240 @@ public Stmt StripLabelLikeStatements() internal static new Stmt Create(CXCursor handle) => handle.StmtClass switch { CX_StmtClass_Invalid => new Stmt(handle, handle.Kind, handle.StmtClass), - CX_StmtClass_GCCAsmStmt => new GCCAsmStmt(handle), - CX_StmtClass_MSAsmStmt => new MSAsmStmt(handle), - CX_StmtClass_BreakStmt => new BreakStmt(handle), - CX_StmtClass_CXXCatchStmt => new CXXCatchStmt(handle), - CX_StmtClass_CXXForRangeStmt => new CXXForRangeStmt(handle), - CX_StmtClass_CXXTryStmt => new CXXTryStmt(handle), - CX_StmtClass_CapturedStmt => new CapturedStmt(handle), - CX_StmtClass_CompoundStmt => new CompoundStmt(handle), - CX_StmtClass_ContinueStmt => new ContinueStmt(handle), - CX_StmtClass_CoreturnStmt => new CoreturnStmt(handle), - CX_StmtClass_CoroutineBodyStmt => new CoroutineBodyStmt(handle), - CX_StmtClass_DeclStmt => new DeclStmt(handle), - CX_StmtClass_DoStmt => new DoStmt(handle), - CX_StmtClass_ForStmt => new ForStmt(handle), - CX_StmtClass_GotoStmt => new GotoStmt(handle), - CX_StmtClass_IfStmt => new IfStmt(handle), - CX_StmtClass_IndirectGotoStmt => new IndirectGotoStmt(handle), - CX_StmtClass_MSDependentExistsStmt => new MSDependentExistsStmt(handle), - CX_StmtClass_NullStmt => new NullStmt(handle), - CX_StmtClass_OMPCanonicalLoop => new OMPCanonicalLoop(handle), - CX_StmtClass_OMPAtomicDirective => new OMPAtomicDirective(handle), - CX_StmtClass_OMPBarrierDirective => new OMPBarrierDirective(handle), - CX_StmtClass_OMPCancelDirective => new OMPCancelDirective(handle), - CX_StmtClass_OMPCancellationPointDirective => new OMPCancellationPointDirective(handle), - CX_StmtClass_OMPCriticalDirective => new OMPCriticalDirective(handle), - CX_StmtClass_OMPDepobjDirective => new OMPDepobjDirective(handle), - CX_StmtClass_OMPDispatchDirective => new OMPDispatchDirective(handle), - CX_StmtClass_OMPErrorDirective => new OMPErrorDirective(handle), - CX_StmtClass_OMPFlushDirective => new OMPFlushDirective(handle), - CX_StmtClass_OMPInteropDirective => new OMPInteropDirective(handle), - CX_StmtClass_OMPDistributeDirective => new OMPDistributeDirective(handle), - CX_StmtClass_OMPDistributeParallelForDirective => new OMPDistributeParallelForDirective(handle), - CX_StmtClass_OMPDistributeParallelForSimdDirective => new OMPDistributeParallelForSimdDirective(handle), - CX_StmtClass_OMPDistributeSimdDirective => new OMPDistributeSimdDirective(handle), - CX_StmtClass_OMPForDirective => new OMPForDirective(handle), - CX_StmtClass_OMPForSimdDirective => new OMPForSimdDirective(handle), - CX_StmtClass_OMPGenericLoopDirective => new OMPGenericLoopDirective(handle), - CX_StmtClass_OMPMaskedTaskLoopDirective => new OMPMaskedTaskLoopDirective(handle), - CX_StmtClass_OMPMaskedTaskLoopSimdDirective => new OMPMaskedTaskLoopSimdDirective(handle), - CX_StmtClass_OMPMasterTaskLoopDirective => new OMPMasterTaskLoopDirective(handle), - CX_StmtClass_OMPMasterTaskLoopSimdDirective => new OMPMasterTaskLoopSimdDirective(handle), - CX_StmtClass_OMPParallelForDirective => new OMPParallelForDirective(handle), - CX_StmtClass_OMPParallelForSimdDirective => new OMPParallelForSimdDirective(handle), - CX_StmtClass_OMPParallelGenericLoopDirective => new OMPParallelGenericLoopDirective(handle), - CX_StmtClass_OMPParallelMaskedTaskLoopDirective => new OMPParallelMaskedTaskLoopDirective(handle), - CX_StmtClass_OMPParallelMaskedTaskLoopSimdDirective => new OMPParallelMaskedTaskLoopSimdDirective(handle), - CX_StmtClass_OMPParallelMasterTaskLoopDirective => new OMPParallelMasterTaskLoopDirective(handle), - CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective => new OMPParallelMasterTaskLoopSimdDirective(handle), - CX_StmtClass_OMPSimdDirective => new OMPSimdDirective(handle), - CX_StmtClass_OMPTargetParallelForSimdDirective => new OMPTargetParallelForSimdDirective(handle), - CX_StmtClass_OMPTargetParallelGenericLoopDirective => new OMPTargetParallelGenericLoopDirective(handle), - CX_StmtClass_OMPTargetSimdDirective => new OMPTargetSimdDirective(handle), - CX_StmtClass_OMPTargetTeamsDistributeDirective => new OMPTargetTeamsDistributeDirective(handle), - CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective => new OMPTargetTeamsDistributeParallelForDirective(handle), - CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective => new OMPTargetTeamsDistributeParallelForSimdDirective(handle), - CX_StmtClass_OMPTargetTeamsDistributeSimdDirective => new OMPTargetTeamsDistributeSimdDirective(handle), - CX_StmtClass_OMPTargetTeamsGenericLoopDirective => new OMPTargetTeamsGenericLoopDirective(handle), - CX_StmtClass_OMPTaskLoopDirective => new OMPTaskLoopDirective(handle), - CX_StmtClass_OMPTaskLoopSimdDirective => new OMPTaskLoopSimdDirective(handle), - CX_StmtClass_OMPTeamsDistributeDirective => new OMPTeamsDistributeDirective(handle), - CX_StmtClass_OMPTeamsDistributeParallelForDirective => new OMPTeamsDistributeParallelForDirective(handle), - CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective => new OMPTeamsDistributeParallelForSimdDirective(handle), - CX_StmtClass_OMPTeamsDistributeSimdDirective => new OMPTeamsDistributeSimdDirective(handle), - CX_StmtClass_OMPTeamsGenericLoopDirective => new OMPTeamsGenericLoopDirective(handle), - CX_StmtClass_OMPTileDirective => new OMPTileDirective(handle), - CX_StmtClass_OMPUnrollDirective => new OMPUnrollDirective(handle), - CX_StmtClass_OMPMaskedDirective => new OMPMaskedDirective(handle), - CX_StmtClass_OMPMasterDirective => new OMPMasterDirective(handle), - CX_StmtClass_OMPMetaDirective => new OMPMetaDirective(handle), - CX_StmtClass_OMPOrderedDirective => new OMPOrderedDirective(handle), - CX_StmtClass_OMPParallelDirective => new OMPParallelDirective(handle), - CX_StmtClass_OMPParallelMaskedDirective => new OMPParallelMaskedDirective(handle), - CX_StmtClass_OMPParallelMasterDirective => new OMPParallelMasterDirective(handle), - CX_StmtClass_OMPParallelSectionsDirective => new OMPParallelSectionsDirective(handle), - CX_StmtClass_OMPScanDirective => new OMPScanDirective(handle), - CX_StmtClass_OMPSectionDirective => new OMPSectionDirective(handle), - CX_StmtClass_OMPSectionsDirective => new OMPSectionsDirective(handle), - CX_StmtClass_OMPSingleDirective => new OMPSingleDirective(handle), - CX_StmtClass_OMPTargetDataDirective => new OMPTargetDataDirective(handle), - CX_StmtClass_OMPTargetDirective => new OMPTargetDirective(handle), - CX_StmtClass_OMPTargetEnterDataDirective => new OMPTargetEnterDataDirective(handle), - CX_StmtClass_OMPTargetExitDataDirective => new OMPTargetExitDataDirective(handle), - CX_StmtClass_OMPTargetParallelDirective => new OMPTargetParallelDirective(handle), - CX_StmtClass_OMPTargetParallelForDirective => new OMPTargetParallelForDirective(handle), - CX_StmtClass_OMPTargetTeamsDirective => new OMPTargetTeamsDirective(handle), - CX_StmtClass_OMPTargetUpdateDirective => new OMPTargetUpdateDirective(handle), - CX_StmtClass_OMPTaskDirective => new OMPTaskDirective(handle), - CX_StmtClass_OMPTaskgroupDirective => new OMPTaskgroupDirective(handle), - CX_StmtClass_OMPTaskwaitDirective => new OMPTaskwaitDirective(handle), - CX_StmtClass_OMPTaskyieldDirective => new OMPTaskyieldDirective(handle), - CX_StmtClass_OMPTeamsDirective => new OMPTeamsDirective(handle), - CX_StmtClass_ObjCAtCatchStmt => new ObjCAtCatchStmt(handle), - CX_StmtClass_ObjCAtFinallyStmt => new ObjCAtFinallyStmt(handle), - CX_StmtClass_ObjCAtSynchronizedStmt => new ObjCAtSynchronizedStmt(handle), - CX_StmtClass_ObjCAtThrowStmt => new ObjCAtThrowStmt(handle), - CX_StmtClass_ObjCAtTryStmt => new ObjCAtTryStmt(handle), - CX_StmtClass_ObjCAutoreleasePoolStmt => new ObjCAutoreleasePoolStmt(handle), - CX_StmtClass_ObjCForCollectionStmt => new ObjCForCollectionStmt(handle), - CX_StmtClass_ReturnStmt => new ReturnStmt(handle), - CX_StmtClass_SEHExceptStmt => new SEHExceptStmt(handle), - CX_StmtClass_SEHFinallyStmt => new SEHFinallyStmt(handle), - CX_StmtClass_SEHLeaveStmt => new SEHLeaveStmt(handle), - CX_StmtClass_SEHTryStmt => new SEHTryStmt(handle), - CX_StmtClass_CaseStmt => new CaseStmt(handle), - CX_StmtClass_DefaultStmt => new DefaultStmt(handle), - CX_StmtClass_SwitchStmt => new SwitchStmt(handle), - CX_StmtClass_AttributedStmt => new AttributedStmt(handle), - CX_StmtClass_BinaryConditionalOperator => new BinaryConditionalOperator(handle), - CX_StmtClass_ConditionalOperator => new ConditionalOperator(handle), - CX_StmtClass_AddrLabelExpr => new AddrLabelExpr(handle), - CX_StmtClass_ArrayInitIndexExpr => new ArrayInitIndexExpr(handle), - CX_StmtClass_ArrayInitLoopExpr => new ArrayInitLoopExpr(handle), - CX_StmtClass_ArraySubscriptExpr => new ArraySubscriptExpr(handle), - CX_StmtClass_ArrayTypeTraitExpr => new ArrayTypeTraitExpr(handle), - CX_StmtClass_AsTypeExpr => new AsTypeExpr(handle), - CX_StmtClass_AtomicExpr => new AtomicExpr(handle), - CX_StmtClass_BinaryOperator => new BinaryOperator(handle), - CX_StmtClass_CompoundAssignOperator => new CompoundAssignOperator(handle), - CX_StmtClass_BlockExpr => new BlockExpr(handle), - CX_StmtClass_CXXBindTemporaryExpr => new CXXBindTemporaryExpr(handle), - CX_StmtClass_CXXBoolLiteralExpr => new CXXBoolLiteralExpr(handle), - CX_StmtClass_CXXConstructExpr => new CXXConstructExpr(handle), - CX_StmtClass_CXXTemporaryObjectExpr => new CXXTemporaryObjectExpr(handle), - CX_StmtClass_CXXDefaultArgExpr => new CXXDefaultArgExpr(handle), - CX_StmtClass_CXXDefaultInitExpr => new CXXDefaultInitExpr(handle), - CX_StmtClass_CXXDeleteExpr => new CXXDeleteExpr(handle), - CX_StmtClass_CXXDependentScopeMemberExpr => new CXXDependentScopeMemberExpr(handle), - CX_StmtClass_CXXFoldExpr => new CXXFoldExpr(handle), - CX_StmtClass_CXXInheritedCtorInitExpr => new CXXInheritedCtorInitExpr(handle), - CX_StmtClass_CXXNewExpr => new CXXNewExpr(handle), - CX_StmtClass_CXXNoexceptExpr => new CXXNoexceptExpr(handle), - CX_StmtClass_CXXNullPtrLiteralExpr => new CXXNullPtrLiteralExpr(handle), - CX_StmtClass_CXXParenListInitExpr => new CXXParenListInitExpr(handle), - CX_StmtClass_CXXPseudoDestructorExpr => new CXXPseudoDestructorExpr(handle), - CX_StmtClass_CXXRewrittenBinaryOperator => new CXXRewrittenBinaryOperator(handle), - CX_StmtClass_CXXScalarValueInitExpr => new CXXScalarValueInitExpr(handle), - CX_StmtClass_CXXStdInitializerListExpr => new CXXStdInitializerListExpr(handle), - CX_StmtClass_CXXThisExpr => new CXXThisExpr(handle), - CX_StmtClass_CXXThrowExpr => new CXXThrowExpr(handle), - CX_StmtClass_CXXTypeidExpr => new CXXTypeidExpr(handle), - CX_StmtClass_CXXUnresolvedConstructExpr => new CXXUnresolvedConstructExpr(handle), - CX_StmtClass_CXXUuidofExpr => new CXXUuidofExpr(handle), + CX_StmtClass_WhileStmt => new WhileStmt(handle), + CX_StmtClass_LabelStmt => new LabelStmt(handle), + CX_StmtClass_VAArgExpr => new VAArgExpr(handle), + CX_StmtClass_UnaryOperator => new UnaryOperator(handle), + CX_StmtClass_UnaryExprOrTypeTraitExpr => new UnaryExprOrTypeTraitExpr(handle), + CX_StmtClass_TypoExpr => new TypoExpr(handle), + CX_StmtClass_TypeTraitExpr => new TypeTraitExpr(handle), + CX_StmtClass_SubstNonTypeTemplateParmPackExpr => new SubstNonTypeTemplateParmPackExpr(handle), + CX_StmtClass_SubstNonTypeTemplateParmExpr => new SubstNonTypeTemplateParmExpr(handle), + CX_StmtClass_StringLiteral => new StringLiteral(handle), + CX_StmtClass_StmtExpr => new StmtExpr(handle), + CX_StmtClass_SourceLocExpr => new SourceLocExpr(handle), + CX_StmtClass_SizeOfPackExpr => new SizeOfPackExpr(handle), + CX_StmtClass_ShuffleVectorExpr => new ShuffleVectorExpr(handle), + CX_StmtClass_SYCLUniqueStableNameExpr => new SYCLUniqueStableNameExpr(handle), + CX_StmtClass_RequiresExpr => new RequiresExpr(handle), + CX_StmtClass_RecoveryExpr => new RecoveryExpr(handle), + CX_StmtClass_PseudoObjectExpr => new PseudoObjectExpr(handle), + CX_StmtClass_PredefinedExpr => new PredefinedExpr(handle), + CX_StmtClass_ParenListExpr => new ParenListExpr(handle), + CX_StmtClass_ParenExpr => new ParenExpr(handle), + CX_StmtClass_PackExpansionExpr => new PackExpansionExpr(handle), + CX_StmtClass_UnresolvedMemberExpr => new UnresolvedMemberExpr(handle), + CX_StmtClass_UnresolvedLookupExpr => new UnresolvedLookupExpr(handle), + CX_StmtClass_OpaqueValueExpr => new OpaqueValueExpr(handle), + CX_StmtClass_OffsetOfExpr => new OffsetOfExpr(handle), + CX_StmtClass_ObjCSubscriptRefExpr => new ObjCSubscriptRefExpr(handle), + CX_StmtClass_ObjCStringLiteral => new ObjCStringLiteral(handle), + CX_StmtClass_ObjCSelectorExpr => new ObjCSelectorExpr(handle), + CX_StmtClass_ObjCProtocolExpr => new ObjCProtocolExpr(handle), + CX_StmtClass_ObjCPropertyRefExpr => new ObjCPropertyRefExpr(handle), + CX_StmtClass_ObjCMessageExpr => new ObjCMessageExpr(handle), + CX_StmtClass_ObjCIvarRefExpr => new ObjCIvarRefExpr(handle), + CX_StmtClass_ObjCIsaExpr => new ObjCIsaExpr(handle), + CX_StmtClass_ObjCIndirectCopyRestoreExpr => new ObjCIndirectCopyRestoreExpr(handle), + CX_StmtClass_ObjCEncodeExpr => new ObjCEncodeExpr(handle), + CX_StmtClass_ObjCDictionaryLiteral => new ObjCDictionaryLiteral(handle), + CX_StmtClass_ObjCBoxedExpr => new ObjCBoxedExpr(handle), + CX_StmtClass_ObjCBoolLiteralExpr => new ObjCBoolLiteralExpr(handle), + CX_StmtClass_ObjCAvailabilityCheckExpr => new ObjCAvailabilityCheckExpr(handle), + CX_StmtClass_ObjCArrayLiteral => new ObjCArrayLiteral(handle), + CX_StmtClass_OMPIteratorExpr => new OMPIteratorExpr(handle), + CX_StmtClass_OMPArrayShapingExpr => new OMPArrayShapingExpr(handle), + CX_StmtClass_OMPArraySectionExpr => new OMPArraySectionExpr(handle), + CX_StmtClass_NoInitExpr => new NoInitExpr(handle), + CX_StmtClass_MemberExpr => new MemberExpr(handle), + CX_StmtClass_MatrixSubscriptExpr => new MatrixSubscriptExpr(handle), + CX_StmtClass_MaterializeTemporaryExpr => new MaterializeTemporaryExpr(handle), + CX_StmtClass_MSPropertySubscriptExpr => new MSPropertySubscriptExpr(handle), + CX_StmtClass_MSPropertyRefExpr => new MSPropertyRefExpr(handle), + CX_StmtClass_LambdaExpr => new LambdaExpr(handle), + CX_StmtClass_IntegerLiteral => new IntegerLiteral(handle), + CX_StmtClass_InitListExpr => new InitListExpr(handle), + CX_StmtClass_ImplicitValueInitExpr => new ImplicitValueInitExpr(handle), + CX_StmtClass_ImaginaryLiteral => new ImaginaryLiteral(handle), + CX_StmtClass_GenericSelectionExpr => new GenericSelectionExpr(handle), + CX_StmtClass_GNUNullExpr => new GNUNullExpr(handle), + CX_StmtClass_FunctionParmPackExpr => new FunctionParmPackExpr(handle), + CX_StmtClass_ExprWithCleanups => new ExprWithCleanups(handle), + CX_StmtClass_ConstantExpr => new ConstantExpr(handle), + CX_StmtClass_FloatingLiteral => new FloatingLiteral(handle), + CX_StmtClass_FixedPointLiteral => new FixedPointLiteral(handle), + CX_StmtClass_ExtVectorElementExpr => new ExtVectorElementExpr(handle), + CX_StmtClass_ExpressionTraitExpr => new ExpressionTraitExpr(handle), + CX_StmtClass_DesignatedInitUpdateExpr => new DesignatedInitUpdateExpr(handle), + CX_StmtClass_DesignatedInitExpr => new DesignatedInitExpr(handle), + CX_StmtClass_DependentScopeDeclRefExpr => new DependentScopeDeclRefExpr(handle), + CX_StmtClass_DependentCoawaitExpr => new DependentCoawaitExpr(handle), + CX_StmtClass_DeclRefExpr => new DeclRefExpr(handle), + CX_StmtClass_CoyieldExpr => new CoyieldExpr(handle), + CX_StmtClass_CoawaitExpr => new CoawaitExpr(handle), + CX_StmtClass_ConvertVectorExpr => new ConvertVectorExpr(handle), + CX_StmtClass_ConceptSpecializationExpr => new ConceptSpecializationExpr(handle), + CX_StmtClass_CompoundLiteralExpr => new CompoundLiteralExpr(handle), + CX_StmtClass_ChooseExpr => new ChooseExpr(handle), + CX_StmtClass_CharacterLiteral => new CharacterLiteral(handle), + CX_StmtClass_ImplicitCastExpr => new ImplicitCastExpr(handle), + CX_StmtClass_ObjCBridgedCastExpr => new ObjCBridgedCastExpr(handle), + CX_StmtClass_CXXStaticCastExpr => new CXXStaticCastExpr(handle), + CX_StmtClass_CXXReinterpretCastExpr => new CXXReinterpretCastExpr(handle), + CX_StmtClass_CXXDynamicCastExpr => new CXXDynamicCastExpr(handle), + CX_StmtClass_CXXConstCastExpr => new CXXConstCastExpr(handle), + CX_StmtClass_CXXAddrspaceCastExpr => new CXXAddrspaceCastExpr(handle), + CX_StmtClass_CXXFunctionalCastExpr => new CXXFunctionalCastExpr(handle), + CX_StmtClass_CStyleCastExpr => new CStyleCastExpr(handle), + CX_StmtClass_BuiltinBitCastExpr => new BuiltinBitCastExpr(handle), CX_StmtClass_CallExpr => new CallExpr(handle), - CX_StmtClass_CUDAKernelCallExpr => new CUDAKernelCallExpr(handle), - CX_StmtClass_CXXMemberCallExpr => new CXXMemberCallExpr(handle), - CX_StmtClass_CXXOperatorCallExpr => new CXXOperatorCallExpr(handle), CX_StmtClass_UserDefinedLiteral => new UserDefinedLiteral(handle), - CX_StmtClass_BuiltinBitCastExpr => new BuiltinBitCastExpr(handle), - CX_StmtClass_CStyleCastExpr => new CStyleCastExpr(handle), - CX_StmtClass_CXXFunctionalCastExpr => new CXXFunctionalCastExpr(handle), - CX_StmtClass_CXXAddrspaceCastExpr => new CXXAddrspaceCastExpr(handle), - CX_StmtClass_CXXConstCastExpr => new CXXConstCastExpr(handle), - CX_StmtClass_CXXDynamicCastExpr => new CXXDynamicCastExpr(handle), - CX_StmtClass_CXXReinterpretCastExpr => new CXXReinterpretCastExpr(handle), - CX_StmtClass_CXXStaticCastExpr => new CXXStaticCastExpr(handle), - CX_StmtClass_ObjCBridgedCastExpr => new ObjCBridgedCastExpr(handle), - CX_StmtClass_ImplicitCastExpr => new ImplicitCastExpr(handle), - CX_StmtClass_CharacterLiteral => new CharacterLiteral(handle), - CX_StmtClass_ChooseExpr => new ChooseExpr(handle), - CX_StmtClass_CompoundLiteralExpr => new CompoundLiteralExpr(handle), - CX_StmtClass_ConceptSpecializationExpr => new ConceptSpecializationExpr(handle), - CX_StmtClass_ConvertVectorExpr => new ConvertVectorExpr(handle), - CX_StmtClass_CoawaitExpr => new CoawaitExpr(handle), - CX_StmtClass_CoyieldExpr => new CoyieldExpr(handle), - CX_StmtClass_DeclRefExpr => new DeclRefExpr(handle), - CX_StmtClass_DependentCoawaitExpr => new DependentCoawaitExpr(handle), - CX_StmtClass_DependentScopeDeclRefExpr => new DependentScopeDeclRefExpr(handle), - CX_StmtClass_DesignatedInitExpr => new DesignatedInitExpr(handle), - CX_StmtClass_DesignatedInitUpdateExpr => new DesignatedInitUpdateExpr(handle), - CX_StmtClass_ExpressionTraitExpr => new ExpressionTraitExpr(handle), - CX_StmtClass_ExtVectorElementExpr => new ExtVectorElementExpr(handle), - CX_StmtClass_FixedPointLiteral => new FixedPointLiteral(handle), - CX_StmtClass_FloatingLiteral => new FloatingLiteral(handle), - CX_StmtClass_ConstantExpr => new ConstantExpr(handle), - CX_StmtClass_ExprWithCleanups => new ExprWithCleanups(handle), - CX_StmtClass_FunctionParmPackExpr => new FunctionParmPackExpr(handle), - CX_StmtClass_GNUNullExpr => new GNUNullExpr(handle), - CX_StmtClass_GenericSelectionExpr => new GenericSelectionExpr(handle), - CX_StmtClass_ImaginaryLiteral => new ImaginaryLiteral(handle), - CX_StmtClass_ImplicitValueInitExpr => new ImplicitValueInitExpr(handle), - CX_StmtClass_InitListExpr => new InitListExpr(handle), - CX_StmtClass_IntegerLiteral => new IntegerLiteral(handle), - CX_StmtClass_LambdaExpr => new LambdaExpr(handle), - CX_StmtClass_MSPropertyRefExpr => new MSPropertyRefExpr(handle), - CX_StmtClass_MSPropertySubscriptExpr => new MSPropertySubscriptExpr(handle), - CX_StmtClass_MaterializeTemporaryExpr => new MaterializeTemporaryExpr(handle), - CX_StmtClass_MatrixSubscriptExpr => new MatrixSubscriptExpr(handle), - CX_StmtClass_MemberExpr => new MemberExpr(handle), - CX_StmtClass_NoInitExpr => new NoInitExpr(handle), - CX_StmtClass_OMPArraySectionExpr => new OMPArraySectionExpr(handle), - CX_StmtClass_OMPArrayShapingExpr => new OMPArrayShapingExpr(handle), - CX_StmtClass_OMPIteratorExpr => new OMPIteratorExpr(handle), - CX_StmtClass_ObjCArrayLiteral => new ObjCArrayLiteral(handle), - CX_StmtClass_ObjCAvailabilityCheckExpr => new ObjCAvailabilityCheckExpr(handle), - CX_StmtClass_ObjCBoolLiteralExpr => new ObjCBoolLiteralExpr(handle), - CX_StmtClass_ObjCBoxedExpr => new ObjCBoxedExpr(handle), - CX_StmtClass_ObjCDictionaryLiteral => new ObjCDictionaryLiteral(handle), - CX_StmtClass_ObjCEncodeExpr => new ObjCEncodeExpr(handle), - CX_StmtClass_ObjCIndirectCopyRestoreExpr => new ObjCIndirectCopyRestoreExpr(handle), - CX_StmtClass_ObjCIsaExpr => new ObjCIsaExpr(handle), - CX_StmtClass_ObjCIvarRefExpr => new ObjCIvarRefExpr(handle), - CX_StmtClass_ObjCMessageExpr => new ObjCMessageExpr(handle), - CX_StmtClass_ObjCPropertyRefExpr => new ObjCPropertyRefExpr(handle), - CX_StmtClass_ObjCProtocolExpr => new ObjCProtocolExpr(handle), - CX_StmtClass_ObjCSelectorExpr => new ObjCSelectorExpr(handle), - CX_StmtClass_ObjCStringLiteral => new ObjCStringLiteral(handle), - CX_StmtClass_ObjCSubscriptRefExpr => new ObjCSubscriptRefExpr(handle), - CX_StmtClass_OffsetOfExpr => new OffsetOfExpr(handle), - CX_StmtClass_OpaqueValueExpr => new OpaqueValueExpr(handle), - CX_StmtClass_UnresolvedLookupExpr => new UnresolvedLookupExpr(handle), - CX_StmtClass_UnresolvedMemberExpr => new UnresolvedMemberExpr(handle), - CX_StmtClass_PackExpansionExpr => new PackExpansionExpr(handle), - CX_StmtClass_ParenExpr => new ParenExpr(handle), - CX_StmtClass_ParenListExpr => new ParenListExpr(handle), - CX_StmtClass_PredefinedExpr => new PredefinedExpr(handle), - CX_StmtClass_PseudoObjectExpr => new PseudoObjectExpr(handle), - CX_StmtClass_RecoveryExpr => new RecoveryExpr(handle), - CX_StmtClass_RequiresExpr => new RequiresExpr(handle), - CX_StmtClass_SYCLUniqueStableNameExpr => new SYCLUniqueStableNameExpr(handle), - CX_StmtClass_ShuffleVectorExpr => new ShuffleVectorExpr(handle), - CX_StmtClass_SizeOfPackExpr => new SizeOfPackExpr(handle), - CX_StmtClass_SourceLocExpr => new SourceLocExpr(handle), - CX_StmtClass_StmtExpr => new StmtExpr(handle), - CX_StmtClass_StringLiteral => new StringLiteral(handle), - CX_StmtClass_SubstNonTypeTemplateParmExpr => new SubstNonTypeTemplateParmExpr(handle), - CX_StmtClass_SubstNonTypeTemplateParmPackExpr => new SubstNonTypeTemplateParmPackExpr(handle), - CX_StmtClass_TypeTraitExpr => new TypeTraitExpr(handle), - CX_StmtClass_TypoExpr => new TypoExpr(handle), - CX_StmtClass_UnaryExprOrTypeTraitExpr => new UnaryExprOrTypeTraitExpr(handle), - CX_StmtClass_UnaryOperator => new UnaryOperator(handle), - CX_StmtClass_VAArgExpr => new VAArgExpr(handle), - CX_StmtClass_LabelStmt => new LabelStmt(handle), - CX_StmtClass_WhileStmt => new WhileStmt(handle), + CX_StmtClass_CXXOperatorCallExpr => new CXXOperatorCallExpr(handle), + CX_StmtClass_CXXMemberCallExpr => new CXXMemberCallExpr(handle), + CX_StmtClass_CUDAKernelCallExpr => new CUDAKernelCallExpr(handle), + CX_StmtClass_CXXUuidofExpr => new CXXUuidofExpr(handle), + CX_StmtClass_CXXUnresolvedConstructExpr => new CXXUnresolvedConstructExpr(handle), + CX_StmtClass_CXXTypeidExpr => new CXXTypeidExpr(handle), + CX_StmtClass_CXXThrowExpr => new CXXThrowExpr(handle), + CX_StmtClass_CXXThisExpr => new CXXThisExpr(handle), + CX_StmtClass_CXXStdInitializerListExpr => new CXXStdInitializerListExpr(handle), + CX_StmtClass_CXXScalarValueInitExpr => new CXXScalarValueInitExpr(handle), + CX_StmtClass_CXXRewrittenBinaryOperator => new CXXRewrittenBinaryOperator(handle), + CX_StmtClass_CXXPseudoDestructorExpr => new CXXPseudoDestructorExpr(handle), + CX_StmtClass_CXXParenListInitExpr => new CXXParenListInitExpr(handle), + CX_StmtClass_CXXNullPtrLiteralExpr => new CXXNullPtrLiteralExpr(handle), + CX_StmtClass_CXXNoexceptExpr => new CXXNoexceptExpr(handle), + CX_StmtClass_CXXNewExpr => new CXXNewExpr(handle), + CX_StmtClass_CXXInheritedCtorInitExpr => new CXXInheritedCtorInitExpr(handle), + CX_StmtClass_CXXFoldExpr => new CXXFoldExpr(handle), + CX_StmtClass_CXXDependentScopeMemberExpr => new CXXDependentScopeMemberExpr(handle), + CX_StmtClass_CXXDeleteExpr => new CXXDeleteExpr(handle), + CX_StmtClass_CXXDefaultInitExpr => new CXXDefaultInitExpr(handle), + CX_StmtClass_CXXDefaultArgExpr => new CXXDefaultArgExpr(handle), + CX_StmtClass_CXXConstructExpr => new CXXConstructExpr(handle), + CX_StmtClass_CXXTemporaryObjectExpr => new CXXTemporaryObjectExpr(handle), + CX_StmtClass_CXXBoolLiteralExpr => new CXXBoolLiteralExpr(handle), + CX_StmtClass_CXXBindTemporaryExpr => new CXXBindTemporaryExpr(handle), + CX_StmtClass_BlockExpr => new BlockExpr(handle), + CX_StmtClass_BinaryOperator => new BinaryOperator(handle), + CX_StmtClass_CompoundAssignOperator => new CompoundAssignOperator(handle), + CX_StmtClass_AtomicExpr => new AtomicExpr(handle), + CX_StmtClass_AsTypeExpr => new AsTypeExpr(handle), + CX_StmtClass_ArrayTypeTraitExpr => new ArrayTypeTraitExpr(handle), + CX_StmtClass_ArraySubscriptExpr => new ArraySubscriptExpr(handle), + CX_StmtClass_ArrayInitLoopExpr => new ArrayInitLoopExpr(handle), + CX_StmtClass_ArrayInitIndexExpr => new ArrayInitIndexExpr(handle), + CX_StmtClass_AddrLabelExpr => new AddrLabelExpr(handle), + CX_StmtClass_ConditionalOperator => new ConditionalOperator(handle), + CX_StmtClass_BinaryConditionalOperator => new BinaryConditionalOperator(handle), + CX_StmtClass_AttributedStmt => new AttributedStmt(handle), + CX_StmtClass_SwitchStmt => new SwitchStmt(handle), + CX_StmtClass_DefaultStmt => new DefaultStmt(handle), + CX_StmtClass_CaseStmt => new CaseStmt(handle), + CX_StmtClass_SEHTryStmt => new SEHTryStmt(handle), + CX_StmtClass_SEHLeaveStmt => new SEHLeaveStmt(handle), + CX_StmtClass_SEHFinallyStmt => new SEHFinallyStmt(handle), + CX_StmtClass_SEHExceptStmt => new SEHExceptStmt(handle), + CX_StmtClass_ReturnStmt => new ReturnStmt(handle), + CX_StmtClass_ObjCForCollectionStmt => new ObjCForCollectionStmt(handle), + CX_StmtClass_ObjCAutoreleasePoolStmt => new ObjCAutoreleasePoolStmt(handle), + CX_StmtClass_ObjCAtTryStmt => new ObjCAtTryStmt(handle), + CX_StmtClass_ObjCAtThrowStmt => new ObjCAtThrowStmt(handle), + CX_StmtClass_ObjCAtSynchronizedStmt => new ObjCAtSynchronizedStmt(handle), + CX_StmtClass_ObjCAtFinallyStmt => new ObjCAtFinallyStmt(handle), + CX_StmtClass_ObjCAtCatchStmt => new ObjCAtCatchStmt(handle), + CX_StmtClass_OMPTeamsDirective => new OMPTeamsDirective(handle), + CX_StmtClass_OMPTaskyieldDirective => new OMPTaskyieldDirective(handle), + CX_StmtClass_OMPTaskwaitDirective => new OMPTaskwaitDirective(handle), + CX_StmtClass_OMPTaskgroupDirective => new OMPTaskgroupDirective(handle), + CX_StmtClass_OMPTaskDirective => new OMPTaskDirective(handle), + CX_StmtClass_OMPTargetUpdateDirective => new OMPTargetUpdateDirective(handle), + CX_StmtClass_OMPTargetTeamsDirective => new OMPTargetTeamsDirective(handle), + CX_StmtClass_OMPTargetParallelForDirective => new OMPTargetParallelForDirective(handle), + CX_StmtClass_OMPTargetParallelDirective => new OMPTargetParallelDirective(handle), + CX_StmtClass_OMPTargetExitDataDirective => new OMPTargetExitDataDirective(handle), + CX_StmtClass_OMPTargetEnterDataDirective => new OMPTargetEnterDataDirective(handle), + CX_StmtClass_OMPTargetDirective => new OMPTargetDirective(handle), + CX_StmtClass_OMPTargetDataDirective => new OMPTargetDataDirective(handle), + CX_StmtClass_OMPSingleDirective => new OMPSingleDirective(handle), + CX_StmtClass_OMPSectionsDirective => new OMPSectionsDirective(handle), + CX_StmtClass_OMPSectionDirective => new OMPSectionDirective(handle), + CX_StmtClass_OMPScopeDirective => new OMPScopeDirective(handle), + CX_StmtClass_OMPScanDirective => new OMPScanDirective(handle), + CX_StmtClass_OMPParallelSectionsDirective => new OMPParallelSectionsDirective(handle), + CX_StmtClass_OMPParallelMasterDirective => new OMPParallelMasterDirective(handle), + CX_StmtClass_OMPParallelMaskedDirective => new OMPParallelMaskedDirective(handle), + CX_StmtClass_OMPParallelDirective => new OMPParallelDirective(handle), + CX_StmtClass_OMPOrderedDirective => new OMPOrderedDirective(handle), + CX_StmtClass_OMPMetaDirective => new OMPMetaDirective(handle), + CX_StmtClass_OMPMasterDirective => new OMPMasterDirective(handle), + CX_StmtClass_OMPMaskedDirective => new OMPMaskedDirective(handle), + CX_StmtClass_OMPUnrollDirective => new OMPUnrollDirective(handle), + CX_StmtClass_OMPTileDirective => new OMPTileDirective(handle), + CX_StmtClass_OMPTeamsGenericLoopDirective => new OMPTeamsGenericLoopDirective(handle), + CX_StmtClass_OMPTeamsDistributeSimdDirective => new OMPTeamsDistributeSimdDirective(handle), + CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective => new OMPTeamsDistributeParallelForSimdDirective(handle), + CX_StmtClass_OMPTeamsDistributeParallelForDirective => new OMPTeamsDistributeParallelForDirective(handle), + CX_StmtClass_OMPTeamsDistributeDirective => new OMPTeamsDistributeDirective(handle), + CX_StmtClass_OMPTaskLoopSimdDirective => new OMPTaskLoopSimdDirective(handle), + CX_StmtClass_OMPTaskLoopDirective => new OMPTaskLoopDirective(handle), + CX_StmtClass_OMPTargetTeamsGenericLoopDirective => new OMPTargetTeamsGenericLoopDirective(handle), + CX_StmtClass_OMPTargetTeamsDistributeSimdDirective => new OMPTargetTeamsDistributeSimdDirective(handle), + CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective => new OMPTargetTeamsDistributeParallelForSimdDirective(handle), + CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective => new OMPTargetTeamsDistributeParallelForDirective(handle), + CX_StmtClass_OMPTargetTeamsDistributeDirective => new OMPTargetTeamsDistributeDirective(handle), + CX_StmtClass_OMPTargetSimdDirective => new OMPTargetSimdDirective(handle), + CX_StmtClass_OMPTargetParallelGenericLoopDirective => new OMPTargetParallelGenericLoopDirective(handle), + CX_StmtClass_OMPTargetParallelForSimdDirective => new OMPTargetParallelForSimdDirective(handle), + CX_StmtClass_OMPSimdDirective => new OMPSimdDirective(handle), + CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective => new OMPParallelMasterTaskLoopSimdDirective(handle), + CX_StmtClass_OMPParallelMasterTaskLoopDirective => new OMPParallelMasterTaskLoopDirective(handle), + CX_StmtClass_OMPParallelMaskedTaskLoopSimdDirective => new OMPParallelMaskedTaskLoopSimdDirective(handle), + CX_StmtClass_OMPParallelMaskedTaskLoopDirective => new OMPParallelMaskedTaskLoopDirective(handle), + CX_StmtClass_OMPParallelGenericLoopDirective => new OMPParallelGenericLoopDirective(handle), + CX_StmtClass_OMPParallelForSimdDirective => new OMPParallelForSimdDirective(handle), + CX_StmtClass_OMPParallelForDirective => new OMPParallelForDirective(handle), + CX_StmtClass_OMPMasterTaskLoopSimdDirective => new OMPMasterTaskLoopSimdDirective(handle), + CX_StmtClass_OMPMasterTaskLoopDirective => new OMPMasterTaskLoopDirective(handle), + CX_StmtClass_OMPMaskedTaskLoopSimdDirective => new OMPMaskedTaskLoopSimdDirective(handle), + CX_StmtClass_OMPMaskedTaskLoopDirective => new OMPMaskedTaskLoopDirective(handle), + CX_StmtClass_OMPGenericLoopDirective => new OMPGenericLoopDirective(handle), + CX_StmtClass_OMPForSimdDirective => new OMPForSimdDirective(handle), + CX_StmtClass_OMPForDirective => new OMPForDirective(handle), + CX_StmtClass_OMPDistributeSimdDirective => new OMPDistributeSimdDirective(handle), + CX_StmtClass_OMPDistributeParallelForSimdDirective => new OMPDistributeParallelForSimdDirective(handle), + CX_StmtClass_OMPDistributeParallelForDirective => new OMPDistributeParallelForDirective(handle), + CX_StmtClass_OMPDistributeDirective => new OMPDistributeDirective(handle), + CX_StmtClass_OMPInteropDirective => new OMPInteropDirective(handle), + CX_StmtClass_OMPFlushDirective => new OMPFlushDirective(handle), + CX_StmtClass_OMPErrorDirective => new OMPErrorDirective(handle), + CX_StmtClass_OMPDispatchDirective => new OMPDispatchDirective(handle), + CX_StmtClass_OMPDepobjDirective => new OMPDepobjDirective(handle), + CX_StmtClass_OMPCriticalDirective => new OMPCriticalDirective(handle), + CX_StmtClass_OMPCancellationPointDirective => new OMPCancellationPointDirective(handle), + CX_StmtClass_OMPCancelDirective => new OMPCancelDirective(handle), + CX_StmtClass_OMPBarrierDirective => new OMPBarrierDirective(handle), + CX_StmtClass_OMPAtomicDirective => new OMPAtomicDirective(handle), + CX_StmtClass_OMPCanonicalLoop => new OMPCanonicalLoop(handle), + CX_StmtClass_NullStmt => new NullStmt(handle), + CX_StmtClass_MSDependentExistsStmt => new MSDependentExistsStmt(handle), + CX_StmtClass_IndirectGotoStmt => new IndirectGotoStmt(handle), + CX_StmtClass_IfStmt => new IfStmt(handle), + CX_StmtClass_GotoStmt => new GotoStmt(handle), + CX_StmtClass_ForStmt => new ForStmt(handle), + CX_StmtClass_DoStmt => new DoStmt(handle), + CX_StmtClass_DeclStmt => new DeclStmt(handle), + CX_StmtClass_CoroutineBodyStmt => new CoroutineBodyStmt(handle), + CX_StmtClass_CoreturnStmt => new CoreturnStmt(handle), + CX_StmtClass_ContinueStmt => new ContinueStmt(handle), + CX_StmtClass_CompoundStmt => new CompoundStmt(handle), + CX_StmtClass_CapturedStmt => new CapturedStmt(handle), + CX_StmtClass_CXXTryStmt => new CXXTryStmt(handle), + CX_StmtClass_CXXForRangeStmt => new CXXForRangeStmt(handle), + CX_StmtClass_CXXCatchStmt => new CXXCatchStmt(handle), + CX_StmtClass_BreakStmt => new BreakStmt(handle), + CX_StmtClass_MSAsmStmt => new MSAsmStmt(handle), + CX_StmtClass_GCCAsmStmt => new GCCAsmStmt(handle), _ => new Stmt(handle, handle.Kind, handle.StmtClass), }; } diff --git a/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj b/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj index 3f6bda3d..9f8590ea 100644 --- a/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj +++ b/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj @@ -36,7 +36,7 @@ C:\Program Files\LLVM\include - /usr/lib/llvm-17/include + /usr/lib/llvm-18/include diff --git a/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs b/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs index 92182781..5c6ba64e 100644 --- a/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs +++ b/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs @@ -9,16 +9,8 @@ namespace ClangSharp; -internal sealed class CustomHelpBuilder : HelpBuilder +internal sealed class CustomHelpBuilder(IConsole console, LocalizationResources localizationResources, int maxWidth = int.MaxValue) : HelpBuilder(localizationResources, maxWidth) { - private IConsole Console { get; } - - public CustomHelpBuilder(IConsole console, LocalizationResources localizationResources, int maxWidth = int.MaxValue) - : base(localizationResources, maxWidth) - { - Console = console; - } - public void Write(Option option) { Write(string.Join(", ", option.Aliases)); @@ -27,17 +19,17 @@ public void Write(Option option) WriteLine(); } - public void Write(string value) => Console.Out.Write(value); + public void Write(string value) => console.Out.Write(value); public void Write(params TwoColumnHelpRow[] helpItems) { WriteLine("Options:"); var _ = new Command("unused"); - WriteColumns(helpItems, new HelpContext(this, _, Console.Out.CreateTextWriter())); + WriteColumns(helpItems, new HelpContext(this, _, console.Out.CreateTextWriter())); WriteLine(); } - public void WriteLine() => Console.Out.WriteLine(); + public void WriteLine() => console.Out.WriteLine(); - public void WriteLine(string value) => Console.Out.WriteLine(value); + public void WriteLine(string value) => console.Out.WriteLine(value); } diff --git a/sources/ClangSharpPInvokeGenerator/Program.cs b/sources/ClangSharpPInvokeGenerator/Program.cs index 6b355de1..6dd06fee 100644 --- a/sources/ClangSharpPInvokeGenerator/Program.cs +++ b/sources/ClangSharpPInvokeGenerator/Program.cs @@ -49,6 +49,7 @@ public static class Program private static readonly string[] s_withCallConvOptionAliases = ["--with-callconv", "-wcc"]; private static readonly string[] s_withClassOptionAliases = ["--with-class", "-wc"]; private static readonly string[] s_withGuidOptionAliases = ["--with-guid", "-wg"]; + private static readonly string[] s_withLengthOptionAliases = ["--with-length", "-wl"]; private static readonly string[] s_withLibraryPathOptionAliases = ["--with-librarypath", "-wlb"]; private static readonly string[] s_withManualImportOptionAliases = ["--with-manual-import", "-wmi"]; private static readonly string[] s_withNamespaceOptionAliases = ["--with-namespace", "-wn"]; @@ -86,6 +87,7 @@ public static class Program private static readonly Option s_withCallConvNameValuePairs = GetWithCallConvOption(); private static readonly Option s_withClassNameValuePairs = GetWithClassOption(); private static readonly Option s_withGuidNameValuePairs = GetWithGuidOption(); + private static readonly Option s_withLengthNameValuePairs = GetWithLengthOption(); private static readonly Option s_withLibraryPathNameValuePairs = GetWithLibraryPathOption(); private static readonly Option s_withManualImports = GetWithManualImportOption(); private static readonly Option s_withNamespaceNameValuePairs = GetWithNamespaceOption(); @@ -169,6 +171,7 @@ public static class Program new TwoColumnHelpRow("generate-marker-interfaces", "Bindings for marker interfaces representing native inheritance hierarchies should be generated."), new TwoColumnHelpRow("generate-native-bitfield-attribute", "[NativeBitfield(\"\", offset: #, length: #)] attribute should be generated to document the encountered bitfield layout."), new TwoColumnHelpRow("generate-native-inheritance-attribute", "[NativeInheritance(\"\")] attribute should be generated to document the encountered C++ base type."), + new TwoColumnHelpRow("generate-generic-pointer-wrapper", "Pointer should be used for limited generic type support."), new TwoColumnHelpRow("generate-setslastsystemerror-attribute", "[SetsLastSystemError] attribute should be generated rather than using SetLastError = true."), new TwoColumnHelpRow("generate-template-bindings", "Bindings for template-definitions should be generated. This is currently experimental."), new TwoColumnHelpRow("generate-unmanaged-constants", "Unmanaged constants should be generated using static ref readonly properties. This is currently experimental."), @@ -242,6 +245,7 @@ public static void Run(InvocationContext context) var withCallConvNameValuePairs = context.ParseResult.GetValueForOption(s_withCallConvNameValuePairs) ?? []; var withClassNameValuePairs = context.ParseResult.GetValueForOption(s_withClassNameValuePairs) ?? []; var withGuidNameValuePairs = context.ParseResult.GetValueForOption(s_withGuidNameValuePairs) ?? []; + var withLengthNameValuePairs = context.ParseResult.GetValueForOption(s_withLengthNameValuePairs) ?? []; var withLibraryPathNameValuePairs = context.ParseResult.GetValueForOption(s_withLibraryPathNameValuePairs) ?? []; var withManualImports = context.ParseResult.GetValueForOption(s_withManualImports) ?? []; var withNamespaceNameValuePairs = context.ParseResult.GetValueForOption(s_withNamespaceNameValuePairs) ?? []; @@ -256,7 +260,7 @@ public static void Run(InvocationContext context) if (versionResult is not null) { - context.Console.WriteLine($"{s_rootCommand.Description} version 17.0.4"); + context.Console.WriteLine($"{s_rootCommand.Description} version 18.1.3"); context.Console.WriteLine($" {clang.getClangVersion()}"); context.Console.WriteLine($" {clangsharp.getVersion()}"); context.ExitCode = -1; @@ -286,6 +290,7 @@ public static void Run(InvocationContext context) ParseKeyValuePairs(withCallConvNameValuePairs, errorList, out Dictionary withCallConvs); ParseKeyValuePairs(withClassNameValuePairs, errorList, out Dictionary withClasses); ParseKeyValuePairs(withGuidNameValuePairs, errorList, out Dictionary withGuids); + ParseKeyValuePairs(withLengthNameValuePairs, errorList, out Dictionary withLengths); ParseKeyValuePairs(withLibraryPathNameValuePairs, errorList, out Dictionary withLibraryPaths); ParseKeyValuePairs(withNamespaceNameValuePairs, errorList, out Dictionary withNamespaces); ParseKeyValuePairs(withTransparentStructNameValuePairs, errorList, out Dictionary withTransparentStructs); @@ -562,6 +567,12 @@ public static void Run(InvocationContext context) break; } + case "generate-generic-pointer-wrapper": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateGenericPointerWrapper; + break; + } + case "generate-setslastsystemerror-attribute": { configOptions |= PInvokeGeneratorConfigurationOptions.GenerateSetsLastSystemErrorAttribute; @@ -693,6 +704,7 @@ public static void Run(InvocationContext context) WithCallConvs = withCallConvs, WithClasses = withClasses, WithGuids = withGuids, + WithLengths = withLengths, WithLibraryPaths = withLibraryPaths, WithManualImports = withManualImports, WithNamespaces = withNamespaces, @@ -717,7 +729,7 @@ public static void Run(InvocationContext context) { var filePath = Path.Combine(fileDirectory, file); - var translationUnitError = CXTranslationUnit.TryParse(pinvokeGenerator.IndexHandle, filePath, clangCommandLineArgs, Array.Empty(), translationFlags, out var handle); + var translationUnitError = CXTranslationUnit.TryParse(pinvokeGenerator.IndexHandle, filePath, clangCommandLineArgs, [], translationFlags, out var handle); var skipProcessing = false; if (translationUnitError != CXError_Success) @@ -1164,6 +1176,7 @@ private static RootCommand GetRootCommand() s_withCallConvNameValuePairs, s_withClassNameValuePairs, s_withGuidNameValuePairs, + s_withLengthNameValuePairs, s_withLibraryPathNameValuePairs, s_withManualImports, s_withNamespaceNameValuePairs, @@ -1272,6 +1285,17 @@ private static Option GetWithGuidOption() }; } + private static Option GetWithLengthOption() + { + return new Option( + aliases: s_withLengthOptionAliases, + description: "A length to be used for the given declaration during binding generation. Supports wildcards.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } + private static Option GetWithLibraryPathOption() { return new Option( diff --git a/sources/ClangSharpPInvokeGenerator/Properties/GenerateClang-LICENSE.txt b/sources/ClangSharpPInvokeGenerator/Properties/GenerateClang-LICENSE.txt index 7431a75c..21246cb4 100644 --- a/sources/ClangSharpPInvokeGenerator/Properties/GenerateClang-LICENSE.txt +++ b/sources/ClangSharpPInvokeGenerator/Properties/GenerateClang-LICENSE.txt @@ -1,4 +1,4 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/include/clang-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. diff --git a/sources/ClangSharpPInvokeGenerator/Properties/GenerateClangSharp.rsp b/sources/ClangSharpPInvokeGenerator/Properties/GenerateClangSharp.rsp index ceb8bff4..4acc2629 100644 --- a/sources/ClangSharpPInvokeGenerator/Properties/GenerateClangSharp.rsp +++ b/sources/ClangSharpPInvokeGenerator/Properties/GenerateClangSharp.rsp @@ -38,6 +38,6 @@ ClangSharp.Interop --prefixStrip clangsharp_ --remap -MSGuidDeclParts=Guid +MSGuidDeclParts=@Guid --test-output ./tests/ClangSharp.UnitTests/InteropTests diff --git a/sources/ClangSharpPInvokeGenerator/Properties/GenerateLLVM-LICENSE.txt b/sources/ClangSharpPInvokeGenerator/Properties/GenerateLLVM-LICENSE.txt index d4def299..37cc4487 100644 --- a/sources/ClangSharpPInvokeGenerator/Properties/GenerateLLVM-LICENSE.txt +++ b/sources/ClangSharpPInvokeGenerator/Properties/GenerateLLVM-LICENSE.txt @@ -1,4 +1,4 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/llvm/include/llvm-c +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/llvm/include/llvm-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. diff --git a/sources/ClangSharpPInvokeGenerator/Properties/GenerateLLVM.rsp b/sources/ClangSharpPInvokeGenerator/Properties/GenerateLLVM.rsp index 42a4361b..e54d8869 100644 --- a/sources/ClangSharpPInvokeGenerator/Properties/GenerateLLVM.rsp +++ b/sources/ClangSharpPInvokeGenerator/Properties/GenerateLLVM.rsp @@ -86,12 +86,16 @@ LLVM_BLAKE3_MAX_DEPTH=@BLAKE3_MAX_DEPTH LLVM_BLAKE3_OUT_LEN=@BLAKE3_OUT_LEN llvm_blake3_version=@blake3_version LLVM_BLAKE3_VERSION_STRING=@BLAKE3_VERSION_STRING -__AnonymousEnum_Core_L463_C1=@LLVMAttributeIndex -__AnonymousEnum_DebugInfo_L146_C1=@LLVMMetadataKind +LLVMOpaqueValueMetadataEntry=LLVMValueMetadataEntry +LLVMOpaqueModuleFlagEntry=LLVMModuleFlagEntry +__AnonymousEnum_Core_L462_C1=@LLVMAttributeIndex +__AnonymousEnum_Core_L486_C1=@LLVMFastMathFlags +__AnonymousEnum_DebugInfo_L147_C1=@LLVMMetadataKind --test-output ./tests/LLVMSharp.UnitTests/Interop --with-attribute LLVMDIFlags=Flags LLVMJITSymbolGenericFlags=Flags +LLVMFastMathFlags=Flags LLVMOrcJITDylibLookupFlags=Flags LLVMOrcSymbolLookupFlags=Flags diff --git a/sources/libClangSharp/CIndexDiagnostic.cpp b/sources/libClangSharp/CIndexDiagnostic.cpp index 0ff00b12..28196bfc 100644 --- a/sources/libClangSharp/CIndexDiagnostic.cpp +++ b/sources/libClangSharp/CIndexDiagnostic.cpp @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #include "CIndexDiagnostic.h" diff --git a/sources/libClangSharp/CIndexDiagnostic.h b/sources/libClangSharp/CIndexDiagnostic.h index b098dae0..fc64b057 100644 --- a/sources/libClangSharp/CIndexDiagnostic.h +++ b/sources/libClangSharp/CIndexDiagnostic.h @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #ifndef LIBCLANGSHARP_CINDEXDIAGNOSTIC_H diff --git a/sources/libClangSharp/CXCursor.cpp b/sources/libClangSharp/CXCursor.cpp index ad818b0b..40bcd24a 100644 --- a/sources/libClangSharp/CXCursor.cpp +++ b/sources/libClangSharp/CXCursor.cpp @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #include "ClangSharp.h" diff --git a/sources/libClangSharp/CXCursor.h b/sources/libClangSharp/CXCursor.h index a9aa68f7..9056296e 100644 --- a/sources/libClangSharp/CXCursor.h +++ b/sources/libClangSharp/CXCursor.h @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #ifndef LIBCLANGSHARP_CXCURSOR_H diff --git a/sources/libClangSharp/CXLoadedDiagnostic.cpp b/sources/libClangSharp/CXLoadedDiagnostic.cpp index 7c1cb5e1..01061133 100644 --- a/sources/libClangSharp/CXLoadedDiagnostic.cpp +++ b/sources/libClangSharp/CXLoadedDiagnostic.cpp @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #include "CXLoadedDiagnostic.h" diff --git a/sources/libClangSharp/CXLoadedDiagnostic.h b/sources/libClangSharp/CXLoadedDiagnostic.h index 0b5c5132..d5e38c2f 100644 --- a/sources/libClangSharp/CXLoadedDiagnostic.h +++ b/sources/libClangSharp/CXLoadedDiagnostic.h @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #ifndef LIBCLANGSHARP_CXLOADEDDIAGNOSTIC_H diff --git a/sources/libClangSharp/CXSourceLocation.cpp b/sources/libClangSharp/CXSourceLocation.cpp index 5043d5bb..f87eb701 100644 --- a/sources/libClangSharp/CXSourceLocation.cpp +++ b/sources/libClangSharp/CXSourceLocation.cpp @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #include "ClangSharp.h" diff --git a/sources/libClangSharp/CXSourceLocation.h b/sources/libClangSharp/CXSourceLocation.h index b822e333..b81c055c 100644 --- a/sources/libClangSharp/CXSourceLocation.h +++ b/sources/libClangSharp/CXSourceLocation.h @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #ifndef LIBCLANGSHARP_CXSOURCELOCATION_H diff --git a/sources/libClangSharp/CXString.cpp b/sources/libClangSharp/CXString.cpp index 32d92d93..189b97db 100644 --- a/sources/libClangSharp/CXString.cpp +++ b/sources/libClangSharp/CXString.cpp @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #include "CXString.h" diff --git a/sources/libClangSharp/CXString.h b/sources/libClangSharp/CXString.h index 78189d54..320f2a2b 100644 --- a/sources/libClangSharp/CXString.h +++ b/sources/libClangSharp/CXString.h @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #ifndef LIBCLANGSHARP_CXSTRING_H diff --git a/sources/libClangSharp/CXTranslationUnit.cpp b/sources/libClangSharp/CXTranslationUnit.cpp index 3c6a69bc..67f9d3d0 100644 --- a/sources/libClangSharp/CXTranslationUnit.cpp +++ b/sources/libClangSharp/CXTranslationUnit.cpp @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #include "CXTranslationUnit.h" diff --git a/sources/libClangSharp/CXTranslationUnit.h b/sources/libClangSharp/CXTranslationUnit.h index b9137238..41c29247 100644 --- a/sources/libClangSharp/CXTranslationUnit.h +++ b/sources/libClangSharp/CXTranslationUnit.h @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #ifndef LIBCLANGSHARP_CXTRANSLATIONUNIT_H diff --git a/sources/libClangSharp/CXType.cpp b/sources/libClangSharp/CXType.cpp index eecf5eab..78de4834 100644 --- a/sources/libClangSharp/CXType.cpp +++ b/sources/libClangSharp/CXType.cpp @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #include "ClangSharp.h" diff --git a/sources/libClangSharp/CXType.h b/sources/libClangSharp/CXType.h index cdb3b166..9d5bf292 100644 --- a/sources/libClangSharp/CXType.h +++ b/sources/libClangSharp/CXType.h @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-17.0.4/clang/tools/libclang +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-18.1.3/clang/tools/libclang // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. #ifndef LIBCLANGSHARP_CXTYPE_H diff --git a/sources/libClangSharp/ClangSharp.cpp b/sources/libClangSharp/ClangSharp.cpp index 605c1490..5880900c 100644 --- a/sources/libClangSharp/ClangSharp.cpp +++ b/sources/libClangSharp/ClangSharp.cpp @@ -675,15 +675,23 @@ CX_CharacterKind clangsharp_Cursor_getCharacterLiteralKind(CXCursor C) { const Stmt* S = getCursorStmt(C); if (const CharacterLiteral* CL = dyn_cast(S)) { - return static_cast(CL->getKind() + 1); + return static_cast(static_cast(CL->getKind()) + 1); } + } + + return CX_CLK_Invalid; +} + +CX_StringKind clangsharp_Cursor_getStringLiteralKind(CXCursor C) { + if (isStmtOrExpr(C.kind)) { + const Stmt* S = getCursorStmt(C); if (const StringLiteral* SL = dyn_cast(S)) { - return static_cast(SL->getKind() + 1); + return static_cast(static_cast(SL->getKind()) + 1); } } - return CX_CLK_Invalid; + return CX_SLK_Invalid; } unsigned clangsharp_Cursor_getCharacterLiteralValue(CXCursor C) { @@ -780,7 +788,7 @@ CX_ConstructionKind clangsharp_Cursor_getConstructionKind(CXCursor C) { const Stmt* S = getCursorStmt(C); if (const CXXConstructExpr* CXXCE = dyn_cast(S)) { - return static_cast(CXXCE->getConstructionKind() + 1); + return static_cast(static_cast(CXXCE->getConstructionKind()) + 1); } } @@ -1458,27 +1466,43 @@ unsigned clangsharp_Cursor_getHasDefaultArg(CXCursor C) { return 0; } -unsigned clangsharp_Cursor_getHasElseStorage(CXCursor C) { - if (isStmtOrExpr(C.kind)) { - const Stmt* S = getCursorStmt(C); +unsigned clangsharp_Cursor_getHasUnparsedDefaultArg(CXCursor C) { + if (isDeclOrTU(C.kind)) { + const Decl* D = getCursorDecl(C); - if (const IfStmt* IS = dyn_cast(S)) { - return IS->hasElseStorage(); + if (const ParmVarDecl* PVD = dyn_cast(D)) { + return PVD->hasUnparsedDefaultArg(); } } return 0; } -unsigned clangsharp_Cursor_getHasExplicitTemplateArgs(CXCursor C) { +unsigned clangsharp_Cursor_getHasUninstantiatedDefaultArg(CXCursor C) { if (isDeclOrTU(C.kind)) { const Decl* D = getCursorDecl(C); - if (const ClassScopeFunctionSpecializationDecl* CSFSD = dyn_cast(D)) { - return CSFSD->hasExplicitTemplateArgs(); + if (const ParmVarDecl* PVD = dyn_cast(D)) { + return PVD->hasUninstantiatedDefaultArg(); + } + } + + return 0; +} + +unsigned clangsharp_Cursor_getHasElseStorage(CXCursor C) { + if (isStmtOrExpr(C.kind)) { + const Stmt* S = getCursorStmt(C); + + if (const IfStmt* IS = dyn_cast(S)) { + return IS->hasElseStorage(); } } + return 0; +} + +unsigned clangsharp_Cursor_getHasExplicitTemplateArgs(CXCursor C) { if (isStmtOrExpr(C.kind)) { const Stmt* S = getCursorStmt(C); @@ -2507,12 +2531,12 @@ unsigned clangsharp_Cursor_getIsPotentiallyEvaluated(CXCursor C) { return 0; } -unsigned clangsharp_Cursor_getIsPure(CXCursor C) { +unsigned clangsharp_Cursor_getIsPureVirtual(CXCursor C) { if (isDeclOrTU(C.kind)) { const Decl* D = getCursorDecl(C); if (const FunctionDecl* FD = dyn_cast(D)) { - return FD->isPure(); + return FD->isPureVirtual(); } } @@ -2813,6 +2837,11 @@ CXCursor clangsharp_Cursor_getLambdaStaticInvoker(CXCursor C) { const Decl* D = getCursorDecl(C); if (const CXXRecordDecl* CRD = dyn_cast(D)) { + CXXMethodDecl *CallOp = CRD->getLambdaCallOperator(); + // Work around a Clang bug: CRD->getLambdaStaticInvoker will crash if getLambdaCallOperator returns null. + if (CallOp == nullptr) { + return clang_getNullCursor(); + } return MakeCXCursor(CRD->getLambdaStaticInvoker(), getCursorTU(C)); } } @@ -3088,6 +3117,9 @@ int clangsharp_Cursor_getNumAssociatedConstraints(CXCursor C) { int clangsharp_Cursor_getNumAttrs(CXCursor C) { if (isDeclOrTU(C.kind)) { const Decl* D = getCursorDecl(C); + if (!D->hasAttrs()) { + return 0; + } return D->getAttrs().size(); } @@ -3363,10 +3395,6 @@ int clangsharp_Cursor_getNumSpecializations(CXCursor C) { if (isDeclOrTU(C.kind)) { const Decl* D = getCursorDecl(C); - if (const ClassScopeFunctionSpecializationDecl* CSFSD = dyn_cast(D)) { - return 1; - } - if (const ClassTemplateDecl* CTD = dyn_cast(D)) { unsigned n = 0; @@ -3395,10 +3423,6 @@ int clangsharp_Cursor_getNumTemplateArguments(CXCursor C) { if (isDeclOrTU(C.kind)) { const Decl* D = getCursorDecl(C); - if (const ClassScopeFunctionSpecializationDecl* CSFSD = dyn_cast(D)) { - return CSFSD->getTemplateArgsAsWritten()->getNumTemplateArgs(); - } - if (const ClassTemplateSpecializationDecl* CTSD = dyn_cast(D)) { return CTSD->getTemplateArgs().size(); } @@ -3913,12 +3937,6 @@ CXCursor clangsharp_Cursor_getSpecialization(CXCursor C, unsigned i) { if (isDeclOrTU(C.kind)) { const Decl* D = getCursorDecl(C); - if (const ClassScopeFunctionSpecializationDecl* CSFSD = dyn_cast(D)) { - if (i == 0) { - return MakeCXCursor(CSFSD->getSpecialization(), getCursorTU(C)); - } - } - if (const ClassTemplateDecl* CTD = dyn_cast(D)) { unsigned n = 0; @@ -4261,13 +4279,6 @@ CX_TemplateArgumentLoc clangsharp_Cursor_getTemplateArgumentLoc(CXCursor C, unsi if (isDeclOrTU(C.kind)) { const Decl* D = getCursorDecl(C); - if (const ClassScopeFunctionSpecializationDecl* CSFSD = dyn_cast(D)) { - if (i < CSFSD->getTemplateArgsAsWritten()->getNumTemplateArgs()) { - const TemplateArgumentLoc* TAL = &CSFSD->getTemplateArgsAsWritten()->getTemplateArgs()[i]; - return MakeCXTemplateArgumentLoc(TAL, getCursorTU(C)); - } - } - if (const TemplateTemplateParmDecl* TTPD = dyn_cast(D)) { if (i == 0) { const TemplateArgumentLoc* TAL = &TTPD->getDefaultArgument(); @@ -4517,7 +4528,7 @@ CXType clangsharp_Cursor_getThisObjectType(CXCursor C) { const Decl* D = getCursorDecl(C); if (const CXXMethodDecl* CMD = dyn_cast(D)) { - return MakeCXType(CMD->getThisObjectType(), getCursorTU(C)); + return MakeCXType(CMD->getThisType(), getCursorTU(C)); } } @@ -4776,7 +4787,7 @@ int64_t clangsharp_Cursor_getVtblIdx(CXCursor C) { } CXString clangsharp_getVersion() { - return cxstring::createDup("clangsharp version 17.0.4"); + return cxstring::createDup("clangsharp version 18.1.3"); } void clangsharp_TemplateArgument_dispose(CX_TemplateArgument T) { diff --git a/sources/libClangSharp/ClangSharp.h b/sources/libClangSharp/ClangSharp.h index a79013e7..01120c2b 100644 --- a/sources/libClangSharp/ClangSharp.h +++ b/sources/libClangSharp/ClangSharp.h @@ -58,19 +58,19 @@ enum CX_CastKind { enum CX_CharacterKind { CX_CLK_Invalid, - CX_CLK_Ascii = clang::CharacterLiteral::Ascii + 1, - CX_CLK_Wide = clang::CharacterLiteral::Wide + 1, - CX_CLK_UTF8 = clang::CharacterLiteral::UTF8 + 1, - CX_CLK_UTF16 = clang::CharacterLiteral::UTF16 + 1, - CX_CLK_UTF32 = clang::CharacterLiteral::UTF32 + 1, + CX_CLK_Ascii = static_cast(clang::CharacterLiteralKind::Ascii) + 1, + CX_CLK_Wide = static_cast(clang::CharacterLiteralKind::Wide) + 1, + CX_CLK_UTF8 = static_cast(clang::CharacterLiteralKind::UTF8) + 1, + CX_CLK_UTF16 = static_cast(clang::CharacterLiteralKind::UTF16) + 1, + CX_CLK_UTF32 = static_cast(clang::CharacterLiteralKind::UTF32) + 1, }; enum CX_ConstructionKind { _CX_CK_Invalid, - CX_CK_Complete = clang::CXXConstructExpr::CK_Complete + 1, - CX_CK_NonVirtualBase = clang::CXXConstructExpr::CK_NonVirtualBase + 1, - CX_CK_VirtualBase = clang::CXXConstructExpr::CK_VirtualBase + 1, - CX_CK_Delegating = clang::CXXConstructExpr::CK_Delegating + 1 + CX_CK_Complete = static_cast(clang::CXXConstructionKind::Complete) + 1, + CX_CK_NonVirtualBase = static_cast(clang::CXXConstructionKind::NonVirtualBase) + 1, + CX_CK_VirtualBase = static_cast(clang::CXXConstructionKind::VirtualBase) + 1, + CX_CK_Delegating = static_cast(clang::CXXConstructionKind::Delegating) + 1 }; enum CX_DeclKind { @@ -104,9 +104,16 @@ enum CX_FloatingSemantics { CX_FLK_BFloat = llvm::APFloatBase::S_BFloat + 1, CX_FLK_IEEEsingle = llvm::APFloatBase::S_IEEEsingle + 1, CX_FLK_IEEEdouble = llvm::APFloatBase::S_IEEEdouble + 1, - CX_FLK_x87DoubleExtended = llvm::APFloatBase::S_x87DoubleExtended + 1, CX_FLK_IEEEquad = llvm::APFloatBase::S_IEEEquad + 1, CX_FLK_PPCDoubleDouble = llvm::APFloatBase::S_PPCDoubleDouble + 1, + CX_FLK_Float8E5M2 = llvm::APFloatBase::S_Float8E5M2 + 1, + CX_FLK_Float8E5M2FNUZ = llvm::APFloatBase::S_Float8E5M2FNUZ + 1, + CX_FLK_Float8E4M3FN = llvm::APFloatBase::S_Float8E4M3FN + 1, + CX_FLK_Float8E4M3FNUZ = llvm::APFloatBase::S_Float8E4M3FNUZ + 1, + CX_FLK_Float8E4M3B11FNUZ = llvm::APFloatBase::S_Float8E4M3B11FNUZ + 1, + CX_FLK_FloatTF32 = llvm::APFloatBase::S_FloatTF32 + 1, + CX_FLK_x87DoubleExtended = llvm::APFloatBase::S_x87DoubleExtended + 1, + CX_FLK_MaxSemantics = llvm::APFloatBase::S_MaxSemantics + 1, }; enum CX_OverloadedOperatorKind { @@ -125,6 +132,16 @@ enum CX_StmtClass { #include }; +enum CX_StringKind { + CX_SLK_Invalid, + CX_SLK_Ordinary = static_cast(clang::StringLiteralKind::Ordinary) + 1, + CX_SLK_Wide = static_cast(clang::StringLiteralKind::Wide) + 1, + CX_SLK_UTF8 = static_cast(clang::StringLiteralKind::UTF8) + 1, + CX_SLK_UTF16 = static_cast(clang::StringLiteralKind::UTF16) + 1, + CX_SLK_UTF32 = static_cast(clang::StringLiteralKind::UTF32) + 1, + CX_SLK_Unevaluated = static_cast(clang::StringLiteralKind::Unevaluated) + 1, +}; + enum CX_TemplateArgumentDependence { CX_TAD_None = clang::TemplateArgumentDependenceScope::None, CX_TAD_UnexpandedPack = clang::TemplateArgumentDependenceScope::UnexpandedPack, @@ -143,7 +160,8 @@ enum CX_TemplateNameKind { CX_TNK_QualifiedTemplate = clang::TemplateName::QualifiedTemplate + 1, CX_TNK_DependentTemplate = clang::TemplateName::DependentTemplate + 1, CX_TNK_SubstTemplateTemplateParm = clang::TemplateName::SubstTemplateTemplateParm + 1, - CX_TNK_SubstTemplateTemplateParmPack = clang::TemplateName::SubstTemplateTemplateParmPack + 1 + CX_TNK_SubstTemplateTemplateParmPack = clang::TemplateName::SubstTemplateTemplateParmPack + 1, + CX_TNK_UsingTemplate = clang::TemplateName::UsingTemplate + 1, }; enum CX_TemplateSpecializationKind { @@ -371,6 +389,10 @@ CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getHasBody(CXCursor C); CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getHasDefaultArg(CXCursor C); +CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getHasUnparsedDefaultArg(CXCursor C); + +CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getHasUninstantiatedDefaultArg(CXCursor C); + CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getHasElseStorage(CXCursor C); CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getHasExplicitTemplateArgs(CXCursor C); @@ -509,7 +531,7 @@ CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getIsPartiallySubstituted(CXCursor CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getIsPotentiallyEvaluated(CXCursor C); -CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getIsPure(CXCursor C); +CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getIsPureVirtual(CXCursor C); CLANGSHARP_LINKAGE unsigned clangsharp_Cursor_getIsResultDependent(CXCursor C); @@ -661,6 +683,8 @@ CLANGSHARP_LINKAGE CXCursor clangsharp_Cursor_getSpecialization(CXCursor C, unsi CLANGSHARP_LINKAGE CX_StmtClass clangsharp_Cursor_getStmtClass(CXCursor C); +CLANGSHARP_LINKAGE CX_StringKind clangsharp_Cursor_getStringLiteralKind(CXCursor C); + CLANGSHARP_LINKAGE CXString clangsharp_Cursor_getStringLiteralValue(CXCursor C); CLANGSHARP_LINKAGE CXCursor clangsharp_Cursor_getSubDecl(CXCursor C, unsigned i); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs index a553add5..05f77d4c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs @@ -16,6 +16,9 @@ public abstract class CXXMethodDeclarationTest : PInvokeGeneratorTest [Test] public Task ConversionTest() => ConversionTestImpl(); + [Test] + public Task DefaultParameterInheritedFromTemplateTest() => DefaultParameterInheritedFromTemplateTestImpl(); + [Test] public Task DestructorTest() => DestructorTestImpl(); @@ -107,6 +110,8 @@ public static int buf_close(void* pContext) protected abstract Task ConversionTestImpl(); + protected abstract Task DefaultParameterInheritedFromTemplateTestImpl(); + protected abstract Task DestructorTestImpl(); protected abstract Task InstanceTestImpl(); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs index dede50f2..763a04f9 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs @@ -78,6 +78,9 @@ public abstract class FunctionDeclarationDllImportTest : PInvokeGeneratorTest [Test] public Task VarargsTest() => VarargsTestImpl(); + [Test] + public Task IntrinsicsTest() => IntrinsicsTestImpl(); + protected abstract Task BasicTestImpl(); protected abstract Task ArrayParameterTestImpl(); @@ -113,4 +116,6 @@ public abstract class FunctionDeclarationDllImportTest : PInvokeGeneratorTest protected abstract Task SourceLocationTestImpl(); protected abstract Task VarargsTestImpl(); + + protected abstract Task IntrinsicsTestImpl(); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs index 1433a5c7..0f3b3e46 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs @@ -92,7 +92,6 @@ public abstract class StructDeclarationTest : PInvokeGeneratorTest [TestCase("unsigned short", "ushort")] [TestCase("unsigned int", "uint")] [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTestImpl(nativeType, expectedManagedType); [TestCase("unsigned char", "byte")] @@ -105,7 +104,6 @@ public abstract class StructDeclarationTest : PInvokeGeneratorTest [TestCase("unsigned short", "ushort")] [TestCase("unsigned int", "uint")] [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); [TestCase("unsigned char", "byte")] @@ -118,7 +116,6 @@ public abstract class StructDeclarationTest : PInvokeGeneratorTest [TestCase("unsigned short", "ushort")] [TestCase("unsigned int", "uint")] [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTypedefTestImpl(nativeType, expectedManagedType); [Test] diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs index cd36e8ab..3f64c858 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs @@ -80,7 +80,6 @@ public abstract class UnionDeclarationTest : PInvokeGeneratorTest [TestCase("unsigned short", "ushort")] [TestCase("unsigned int", "uint")] [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTestImpl(nativeType, expectedManagedType); [TestCase("unsigned char", "byte")] @@ -93,7 +92,6 @@ public abstract class UnionDeclarationTest : PInvokeGeneratorTest [TestCase("unsigned short", "ushort")] [TestCase("unsigned int", "uint")] [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); [TestCase("unsigned char", "byte")] @@ -106,7 +104,6 @@ public abstract class UnionDeclarationTest : PInvokeGeneratorTest [TestCase("unsigned short", "ushort")] [TestCase("unsigned int", "uint")] [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTypedefTestImpl(nativeType, expectedManagedType); [Test] diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs index 13137540..864cd583 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs @@ -31,6 +31,7 @@ public abstract class VarDeclarationTest : PInvokeGeneratorTest [TestCase("0U", "uint", "0U")] [TestCase("0LL", "long", "0L")] [TestCase("0ULL", "ulong", "0UL")] + [TestCase("0LLU", "ulong", "0UL")] [TestCase("0.0", "double", "0.0")] [TestCase("0.f", "float", "0.0f")] public Task MacroTest(string nativeValue, string expectedManagedType, string expectedManagedValue) => MacroTestImpl(nativeValue, expectedManagedType, expectedManagedValue); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs index 92ec9bb7..afc4704c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs @@ -125,6 +125,40 @@ public int ToInt32() return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{{ + [NativeTypeName(""struct MyStruct : MyTemplate"")] + public unsafe partial struct MyStruct + {{ + [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + }} +}} +"; + + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs index 3933f23a..f6a5c169 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs @@ -225,7 +225,7 @@ public enum MyEnum2 var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -261,7 +261,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -297,7 +297,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -334,8 +334,8 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs index 6a976236..0b969f31 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs @@ -399,4 +399,14 @@ public static partial class Methods } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs index 4f390096..49c6c171 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs @@ -1948,7 +1948,7 @@ protected override Task WithPackingTestImpl() struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1960,12 +1960,13 @@ namespace ClangSharp.Test [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] public partial struct MyStruct { - [NativeTypeName(""size_t[1]"")] + [NativeTypeName(""size_t[2]"")] public _FixedBuffer_e__FixedBuffer FixedBuffer; public partial struct _FixedBuffer_e__FixedBuffer { public UIntPtr e0; + public UIntPtr e1; public unsafe ref UIntPtr this[int index] { diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs index a2bd365b..14249777 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs @@ -125,6 +125,40 @@ public int ToInt32() return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{{ + [NativeTypeName(""struct MyStruct : MyTemplate"")] + public unsafe partial struct MyStruct + {{ + [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + }} +}} +"; + + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -170,14 +204,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@"using System.Runtime.InteropServices; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs index c0a0a7a3..2b345d91 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs @@ -225,7 +225,7 @@ public enum MyEnum2 var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -261,7 +261,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -297,7 +297,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -334,8 +334,8 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs index 765ce399..5b04ad84 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs @@ -416,4 +416,14 @@ public static partial class Methods return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents); } + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs index f7c5ef99..d3eb663f 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs @@ -1954,7 +1954,7 @@ protected override Task WithPackingTestImpl() { const string InputContents = @"struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1966,12 +1966,13 @@ namespace ClangSharp.Test [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] public partial struct MyStruct { - [NativeTypeName(""size_t[1]"")] + [NativeTypeName(""size_t[2]"")] public _FixedBuffer_e__FixedBuffer FixedBuffer; public partial struct _FixedBuffer_e__FixedBuffer { public UIntPtr e0; + public UIntPtr e1; public unsafe ref UIntPtr this[int index] { diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs index f5f02549..47e77d51 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs @@ -125,6 +125,40 @@ public int ToInt32() return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{{ + [NativeTypeName(""struct MyStruct : MyTemplate"")] + public unsafe partial struct MyStruct + {{ + [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + }} +}} +"; + + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -170,14 +204,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@"using System.Runtime.InteropServices; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs index 3ab6e291..422a15b0 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs @@ -68,8 +68,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -227,7 +225,7 @@ public enum MyEnum2 var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -263,7 +261,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -299,7 +297,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -336,8 +334,8 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs index 8e082149..e738ed82 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs @@ -398,4 +398,14 @@ public static partial class Methods } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs index 6ab069d9..8b519a65 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs @@ -1926,7 +1926,7 @@ protected override Task WithPackingTestImpl() struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1938,22 +1938,23 @@ namespace ClangSharp.Test [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] public partial struct MyStruct { - [NativeTypeName(""size_t[1]"")] + [NativeTypeName(""size_t[2]"")] public _FixedBuffer_e__FixedBuffer FixedBuffer; public partial struct _FixedBuffer_e__FixedBuffer { public nuint e0; + public nuint e1; public ref nuint this[int index] { get { - return ref AsSpan(int.MaxValue)[index]; + return ref AsSpan()[index]; } } - public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 2); } } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs index bf88b54a..01f769a5 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs @@ -125,6 +125,40 @@ public int ToInt32() return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{{ + [NativeTypeName(""struct MyStruct : MyTemplate"")] + public unsafe partial struct MyStruct + {{ + [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + }} +}} +"; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs index 92117a16..5b394eed 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs @@ -68,8 +68,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -227,7 +225,7 @@ public enum MyEnum2 var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -263,7 +261,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -299,7 +297,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -336,8 +334,8 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs index 0c5f180e..4c72b3f4 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Collections.Generic; +using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; using NUnit.Framework; @@ -415,4 +416,14 @@ public static partial class Methods return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); } + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs index 0102a48f..cff1dc8f 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs @@ -1932,7 +1932,7 @@ protected override Task WithPackingTestImpl() { const string InputContents = @"struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1944,22 +1944,23 @@ namespace ClangSharp.Test [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] public partial struct MyStruct { - [NativeTypeName(""size_t[1]"")] + [NativeTypeName(""size_t[2]"")] public _FixedBuffer_e__FixedBuffer FixedBuffer; public partial struct _FixedBuffer_e__FixedBuffer { public nuint e0; + public nuint e1; public ref nuint this[int index] { get { - return ref AsSpan(int.MaxValue)[index]; + return ref AsSpan()[index]; } } - public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 2); } } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs index 5554781f..9ac0558a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs @@ -125,6 +125,40 @@ public int ToInt32() return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{{ + [NativeTypeName(""struct MyStruct : MyTemplate"")] + public unsafe partial struct MyStruct + {{ + [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + }} +}} +"; + + return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -170,14 +204,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@"using System.Runtime.InteropServices; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs index dc2ddb04..a29d6522 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs @@ -68,8 +68,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -227,7 +225,7 @@ public enum MyEnum2 var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -263,7 +261,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -299,7 +297,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -336,8 +334,8 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs index d989b804..f79b003e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs @@ -398,4 +398,14 @@ public static partial class Methods } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs index 179b83fb..b0d04972 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs @@ -19,12 +19,33 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[]"")] - public fixed {expectedManagedType} x[1]; + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + {{ + public {expectedManagedType} e0; + + [UnscopedRef] + public ref {expectedManagedType} this[int index] + {{ + get + {{ + return ref Unsafe.Add(ref e0, index); + }} + }} + + [UnscopedRef] + public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + }} }} }} "; @@ -784,12 +805,20 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -805,12 +834,20 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0_0_0_0; + }} }} }} "; @@ -828,12 +865,20 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -1056,7 +1101,7 @@ public partial struct MyUnion public {expectedManagedType} value; }} - public unsafe partial struct MyStruct + public partial struct MyStruct {{ public {expectedManagedType} x; @@ -1124,7 +1169,7 @@ public Span<{expectedManagedType}> buffer1 {{ get {{ - return MemoryMarshal.CreateSpan(ref Anonymous.buffer1[0], 4); + return Anonymous.buffer1; }} }} @@ -1133,11 +1178,11 @@ public Span buffer2 {{ get {{ - return Anonymous.buffer2.AsSpan(); + return Anonymous.buffer2; }} }} - public unsafe partial struct _Anonymous_e__Struct + public partial struct _Anonymous_e__Struct {{ public {expectedManagedType} z; @@ -1153,7 +1198,7 @@ public unsafe partial struct _Anonymous_e__Struct public MyUnion u; [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer1[4]; + public _buffer1_e__FixedBuffer buffer1; [NativeTypeName(""MyUnion[4]"")] public _buffer2_e__FixedBuffer buffer2; @@ -1183,6 +1228,12 @@ public partial struct _Anonymous2_e__Union public {expectedManagedType} value2; }} + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} + [InlineArray(4)] public partial struct _buffer2_e__FixedBuffer {{ @@ -1847,12 +1898,11 @@ protected override Task WithPackingTestImpl() struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; - const string ExpectedOutputContents = @"using System; -using System.Diagnostics.CodeAnalysis; + const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1860,24 +1910,13 @@ namespace ClangSharp.Test [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] public partial struct MyStruct { - [NativeTypeName(""size_t[1]"")] + [NativeTypeName(""size_t[2]"")] public _FixedBuffer_e__FixedBuffer FixedBuffer; + [InlineArray(2)] public partial struct _FixedBuffer_e__FixedBuffer { public nuint e0; - - [UnscopedRef] - public ref nuint this[int index] - { - get - { - return ref AsSpan(int.MaxValue)[index]; - } - } - - [UnscopedRef] - public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); } } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs index 8976884a..b1a9584e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs @@ -567,16 +567,23 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -592,16 +599,23 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0_0_0_0; + }} }} }} "; @@ -619,16 +633,23 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -714,6 +735,7 @@ union MyUnion var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -724,7 +746,7 @@ public partial struct MyStruct }} [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] public {expectedManagedType} r; @@ -762,12 +784,12 @@ public Span<{expectedManagedType}> buffer {{ get {{ - return MemoryMarshal.CreateSpan(ref Anonymous.buffer[0], 4); + return Anonymous.buffer; }} }} [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _Anonymous_e__Union + public partial struct _Anonymous_e__Union {{ [FieldOffset(0)] public {expectedManagedType} a; @@ -777,7 +799,13 @@ public unsafe partial struct _Anonymous_e__Union [FieldOffset(0)] [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer[4]; + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs index 2881a195..e37b13e8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs @@ -125,6 +125,40 @@ public int ToInt32() return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{{ + [NativeTypeName(""struct MyStruct : MyTemplate"")] + public unsafe partial struct MyStruct + {{ + [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + }} +}} +"; + + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -170,14 +204,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@"using System.Runtime.InteropServices; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs index 9fe2b8d7..86a75eb2 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs @@ -68,8 +68,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -227,7 +225,7 @@ public enum MyEnum2 var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -263,7 +261,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -299,7 +297,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -336,8 +334,8 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs index 7dd8e3c7..522c1ff5 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs @@ -415,4 +415,14 @@ public static partial class Methods return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents); } + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs index 381c0f4d..b54c00f2 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs @@ -19,12 +19,33 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[]"")] - public fixed {expectedManagedType} x[1]; + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + {{ + public {expectedManagedType} e0; + + [UnscopedRef] + public ref {expectedManagedType} this[int index] + {{ + get + {{ + return ref Unsafe.Add(ref e0, index); + }} + }} + + [UnscopedRef] + public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + }} }} }} "; @@ -792,12 +813,20 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -813,12 +842,20 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0_0_0_0; + }} }} }} "; @@ -836,12 +873,20 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -1064,7 +1109,7 @@ public partial struct MyUnion public {expectedManagedType} value; }} - public unsafe partial struct MyStruct + public partial struct MyStruct {{ public {expectedManagedType} x; @@ -1132,7 +1177,7 @@ public Span<{expectedManagedType}> buffer1 {{ get {{ - return MemoryMarshal.CreateSpan(ref Anonymous.buffer1[0], 4); + return Anonymous.buffer1; }} }} @@ -1141,11 +1186,11 @@ public Span buffer2 {{ get {{ - return Anonymous.buffer2.AsSpan(); + return Anonymous.buffer2; }} }} - public unsafe partial struct _Anonymous_e__Struct + public partial struct _Anonymous_e__Struct {{ public {expectedManagedType} z; @@ -1161,7 +1206,7 @@ public unsafe partial struct _Anonymous_e__Struct public MyUnion u; [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer1[4]; + public _buffer1_e__FixedBuffer buffer1; [NativeTypeName(""MyUnion[4]"")] public _buffer2_e__FixedBuffer buffer2; @@ -1191,6 +1236,12 @@ public partial struct _Anonymous2_e__Union public {expectedManagedType} value2; }} + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} + [InlineArray(4)] public partial struct _buffer2_e__FixedBuffer {{ @@ -1853,12 +1904,11 @@ protected override Task WithPackingTestImpl() { const string InputContents = @"struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; - const string ExpectedOutputContents = @"using System; -using System.Diagnostics.CodeAnalysis; + const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1866,24 +1916,13 @@ namespace ClangSharp.Test [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] public partial struct MyStruct { - [NativeTypeName(""size_t[1]"")] + [NativeTypeName(""size_t[2]"")] public _FixedBuffer_e__FixedBuffer FixedBuffer; + [InlineArray(2)] public partial struct _FixedBuffer_e__FixedBuffer { public nuint e0; - - [UnscopedRef] - public ref nuint this[int index] - { - get - { - return ref AsSpan(int.MaxValue)[index]; - } - } - - [UnscopedRef] - public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); } } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs index 736cbed5..d3379efa 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs @@ -573,16 +573,23 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -598,16 +605,23 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0_0_0_0; + }} }} }} "; @@ -625,16 +639,23 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -720,6 +741,7 @@ union MyUnion var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -730,7 +752,7 @@ public partial struct MyStruct }} [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] public {expectedManagedType} r; @@ -768,12 +790,12 @@ public Span<{expectedManagedType}> buffer {{ get {{ - return MemoryMarshal.CreateSpan(ref Anonymous.buffer[0], 4); + return Anonymous.buffer; }} }} [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _Anonymous_e__Union + public partial struct _Anonymous_e__Union {{ [FieldOffset(0)] public {expectedManagedType} a; @@ -783,7 +805,13 @@ public unsafe partial struct _Anonymous_e__Union [FieldOffset(0)] [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer[4]; + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs index d055bbb1..e9f3cb58 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs @@ -125,6 +125,40 @@ public int ToInt32() return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{{ + [NativeTypeName(""struct MyStruct : MyTemplate"")] + public unsafe partial struct MyStruct + {{ + [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + }} +}} +"; + + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -170,14 +204,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@"using System.Runtime.InteropServices; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs index 3d485f8b..374662e5 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs @@ -68,8 +68,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -227,7 +225,7 @@ public enum MyEnum2 var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -263,7 +261,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -299,7 +297,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -336,8 +334,8 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs index e079637d..98c598ff 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs @@ -398,4 +398,14 @@ public static partial class Methods } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs index 3716ac26..fb7cf492 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs @@ -19,12 +19,33 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[]"")] - public fixed {expectedManagedType} x[1]; + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + {{ + public {expectedManagedType} e0; + + [UnscopedRef] + public ref {expectedManagedType} this[int index] + {{ + get + {{ + return ref Unsafe.Add(ref e0, index); + }} + }} + + [UnscopedRef] + public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + }} }} }} "; @@ -784,12 +805,20 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -805,12 +834,20 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0_0_0_0; + }} }} }} "; @@ -828,12 +865,20 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -1056,7 +1101,7 @@ public partial struct MyUnion public {expectedManagedType} value; }} - public unsafe partial struct MyStruct + public partial struct MyStruct {{ public {expectedManagedType} x; @@ -1124,7 +1169,7 @@ public Span<{expectedManagedType}> buffer1 {{ get {{ - return MemoryMarshal.CreateSpan(ref Anonymous.buffer1[0], 4); + return Anonymous.buffer1; }} }} @@ -1133,11 +1178,11 @@ public Span buffer2 {{ get {{ - return Anonymous.buffer2.AsSpan(); + return Anonymous.buffer2; }} }} - public unsafe partial struct _Anonymous_e__Struct + public partial struct _Anonymous_e__Struct {{ public {expectedManagedType} z; @@ -1153,7 +1198,7 @@ public unsafe partial struct _Anonymous_e__Struct public MyUnion u; [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer1[4]; + public _buffer1_e__FixedBuffer buffer1; [NativeTypeName(""MyUnion[4]"")] public _buffer2_e__FixedBuffer buffer2; @@ -1183,6 +1228,12 @@ public partial struct _Anonymous2_e__Union public {expectedManagedType} value2; }} + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} + [InlineArray(4)] public partial struct _buffer2_e__FixedBuffer {{ @@ -1847,12 +1898,11 @@ protected override Task WithPackingTestImpl() struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; - const string ExpectedOutputContents = @"using System; -using System.Diagnostics.CodeAnalysis; + const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1860,24 +1910,13 @@ namespace ClangSharp.Test [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] public partial struct MyStruct { - [NativeTypeName(""size_t[1]"")] + [NativeTypeName(""size_t[2]"")] public _FixedBuffer_e__FixedBuffer FixedBuffer; + [InlineArray(2)] public partial struct _FixedBuffer_e__FixedBuffer { public nuint e0; - - [UnscopedRef] - public ref nuint this[int index] - { - get - { - return ref AsSpan(int.MaxValue)[index]; - } - } - - [UnscopedRef] - public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); } } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs index 9a54276b..b8f83b3a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs @@ -567,16 +567,23 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -592,16 +599,23 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0_0_0_0; + }} }} }} "; @@ -619,16 +633,23 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -714,6 +735,7 @@ union MyUnion var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -724,7 +746,7 @@ public partial struct MyStruct }} [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] public {expectedManagedType} r; @@ -762,12 +784,12 @@ public Span<{expectedManagedType}> buffer {{ get {{ - return MemoryMarshal.CreateSpan(ref Anonymous.buffer[0], 4); + return Anonymous.buffer; }} }} [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _Anonymous_e__Union + public partial struct _Anonymous_e__Union {{ [FieldOffset(0)] public {expectedManagedType} a; @@ -777,7 +799,13 @@ public unsafe partial struct _Anonymous_e__Union [FieldOffset(0)] [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer[4]; + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs index 59ed024a..28f1de68 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs @@ -125,6 +125,40 @@ public int ToInt32() return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{{ + [NativeTypeName(""struct MyStruct : MyTemplate"")] + public unsafe partial struct MyStruct + {{ + [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + }} +}} +"; + + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -170,14 +204,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@"using System.Runtime.InteropServices; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs index b435b243..b1322b9f 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs @@ -68,8 +68,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -227,7 +225,7 @@ public enum MyEnum2 var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -263,7 +261,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -299,7 +297,7 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -336,8 +334,8 @@ public enum MyEnum2 var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs index 4fbeb1e4..2ebba7ad 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs @@ -415,4 +415,14 @@ public static partial class Methods return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents); } + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs index 3a43d637..8299bd09 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs @@ -19,12 +19,33 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[]"")] - public fixed {expectedManagedType} x[1]; + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + {{ + public {expectedManagedType} e0; + + [UnscopedRef] + public ref {expectedManagedType} this[int index] + {{ + get + {{ + return ref Unsafe.Add(ref e0, index); + }} + }} + + [UnscopedRef] + public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + }} }} }} "; @@ -792,12 +813,20 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -813,12 +842,20 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0_0_0_0; + }} }} }} "; @@ -836,12 +873,20 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System.Runtime.CompilerServices; + +namespace ClangSharp.Test {{ - public unsafe partial struct MyStruct + public partial struct MyStruct {{ [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -1064,7 +1109,7 @@ public partial struct MyUnion public {expectedManagedType} value; }} - public unsafe partial struct MyStruct + public partial struct MyStruct {{ public {expectedManagedType} x; @@ -1132,7 +1177,7 @@ public Span<{expectedManagedType}> buffer1 {{ get {{ - return MemoryMarshal.CreateSpan(ref Anonymous.buffer1[0], 4); + return Anonymous.buffer1; }} }} @@ -1141,11 +1186,11 @@ public Span buffer2 {{ get {{ - return Anonymous.buffer2.AsSpan(); + return Anonymous.buffer2; }} }} - public unsafe partial struct _Anonymous_e__Struct + public partial struct _Anonymous_e__Struct {{ public {expectedManagedType} z; @@ -1161,7 +1206,7 @@ public unsafe partial struct _Anonymous_e__Struct public MyUnion u; [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer1[4]; + public _buffer1_e__FixedBuffer buffer1; [NativeTypeName(""MyUnion[4]"")] public _buffer2_e__FixedBuffer buffer2; @@ -1191,6 +1236,12 @@ public partial struct _Anonymous2_e__Union public {expectedManagedType} value2; }} + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} + [InlineArray(4)] public partial struct _buffer2_e__FixedBuffer {{ @@ -1853,12 +1904,11 @@ protected override Task WithPackingTestImpl() { const string InputContents = @"struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; - const string ExpectedOutputContents = @"using System; -using System.Diagnostics.CodeAnalysis; + const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1866,24 +1916,13 @@ namespace ClangSharp.Test [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] public partial struct MyStruct { - [NativeTypeName(""size_t[1]"")] + [NativeTypeName(""size_t[2]"")] public _FixedBuffer_e__FixedBuffer FixedBuffer; + [InlineArray(2)] public partial struct _FixedBuffer_e__FixedBuffer { public nuint e0; - - [UnscopedRef] - public ref nuint this[int index] - { - get - { - return ref AsSpan(int.MaxValue)[index]; - } - } - - [UnscopedRef] - public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); } } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs index 7e8302e6..238748cc 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs @@ -573,16 +573,23 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -598,16 +605,23 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0_0_0_0; + }} }} }} "; @@ -625,16 +639,23 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ClangSharp.Test {{ [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} "; @@ -720,6 +741,7 @@ union MyUnion var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -730,7 +752,7 @@ public partial struct MyStruct }} [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion + public partial struct MyUnion {{ [FieldOffset(0)] public {expectedManagedType} r; @@ -768,12 +790,12 @@ public Span<{expectedManagedType}> buffer {{ get {{ - return MemoryMarshal.CreateSpan(ref Anonymous.buffer[0], 4); + return Anonymous.buffer; }} }} [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _Anonymous_e__Union + public partial struct _Anonymous_e__Union {{ [FieldOffset(0)] public {expectedManagedType} a; @@ -783,7 +805,13 @@ public unsafe partial struct _Anonymous_e__Union [FieldOffset(0)] [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer[4]; + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + {{ + public {expectedManagedType} e0; + }} }} }} }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/OptionsTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/OptionsTest.cs new file mode 100644 index 00000000..5ceeceaf --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/OptionsTest.cs @@ -0,0 +1,57 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests; + +public sealed class OptionsTest : PInvokeGeneratorTest +{ + [Test] + public Task WithUsings() + { + var inputContents = @"struct StructA {}; +namespace NS +{ + struct StructB {}; + struct StructC {}; +} +struct StructD {}; +"; + var expectedOutputContents = @"using ForStar; +using ForStructA1; +using ForStructA2; +using ForStructBWithDoubleColon; +using ForStructCWithDot; + +namespace ClangSharp.Test +{ + public partial struct StructA + { + } + + public partial struct StructB + { + } + + public partial struct StructC + { + } + + public partial struct StructD + { + } +} +"; + var withUsings = new Dictionary> { + ["StructA"] = ["ForStructA1", "ForStructA2"], + ["*"] = ["ForStar"], + ["NS::StructB"] = ["ForStructBWithDoubleColon"], + ["NS.StructC"] = ["ForStructCWithDot"], + ["DoesNotExist"] = ["ErrorShouldNotBeInOutput"], + }; + + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withUsings); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs index c64a0a52..34fb1b26 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs @@ -89,7 +89,7 @@ protected static Task ValidateGeneratedXmlCompatibleUnixBindingsAsync(string inp private static async Task ValidateGeneratedBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorOutputMode outputMode, PInvokeGeneratorConfigurationOptions configOptions, string[]? excludedNames, IReadOnlyDictionary? remappedNames, IReadOnlyDictionary? withAccessSpecifiers, IReadOnlyDictionary>? withAttributes, IReadOnlyDictionary? withCallConvs, IReadOnlyDictionary? withClasses, IReadOnlyDictionary? withLibraryPaths, IReadOnlyDictionary? withNamespaces, string[]? withSetLastErrors, IReadOnlyDictionary? withTransparentStructs, IReadOnlyDictionary? withTypes, IReadOnlyDictionary>? withUsings, IReadOnlyDictionary? withPackings, IEnumerable? expectedDiagnostics, string libraryPath, string[]? commandLineArgs, string language, string languageStandard) { - Assert.True(File.Exists(DefaultInputFileName)); + Assert.That(DefaultInputFileName, Does.Exist); commandLineArgs ??= DefaultCppClangCommandLineArgs; configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMacroBindings; @@ -133,17 +133,17 @@ private static async Task ValidateGeneratedBindingsAsync(string inputContents, s if (expectedDiagnostics is null) { - Assert.IsEmpty(pinvokeGenerator.Diagnostics); + Assert.That(pinvokeGenerator.Diagnostics, Is.Empty); } else { - Assert.AreEqual(expectedDiagnostics, pinvokeGenerator.Diagnostics); + Assert.That(pinvokeGenerator.Diagnostics, Is.EqualTo(expectedDiagnostics)); } } outputStream.Position = 0; using var streamReader = new StreamReader(outputStream); var actualOutputContents = await streamReader.ReadToEndAsync().ConfigureAwait(false); - Assert.AreEqual(expectedOutputContents, actualOutputContents); + Assert.That(actualOutputContents, Is.EqualTo(expectedOutputContents)); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs index b4ed6c64..0403f89d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs @@ -165,6 +165,47 @@ operator int() return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; + + var expectedOutputContents = $@" + + + + + int* + + MyStruct* + + + int* + + null + + + + + + +"; + + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -212,14 +253,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@" diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs index 6beadedb..dab1c96c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs @@ -87,8 +87,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -230,7 +228,7 @@ enum MyEnum2 : int var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -275,7 +273,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -320,7 +318,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -365,8 +363,8 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs index d1ff401d..4df425ee 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs @@ -451,4 +451,14 @@ protected override Task SourceLocationTestImpl() } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs index ef5026d4..17a8ed66 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs @@ -1911,7 +1911,7 @@ protected override Task WithPackingTestImpl() struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1920,12 +1920,15 @@ struct MyStruct - UIntPtr + UIntPtr UIntPtr + + UIntPtr + ref UIntPtr diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs index 189d2622..20c1ee5c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs @@ -165,6 +165,48 @@ operator int() return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; + + var expectedOutputContents = $@" + + + + + int* + + MyStruct* + + + int* + + null + + + + + + +"; + + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -212,14 +254,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@" diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs index 856c2edd..c196d58e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs @@ -87,8 +87,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -230,7 +228,7 @@ enum MyEnum2 : int var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -275,7 +273,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -320,7 +318,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -365,8 +363,8 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs index 28508ac3..a6f62ac8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs @@ -451,4 +451,14 @@ protected override Task SourceLocationTestImpl() } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs index 1425181e..263ba30c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs @@ -1920,7 +1920,7 @@ protected override Task WithPackingTestImpl() { const string InputContents = @"struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1929,12 +1929,15 @@ protected override Task WithPackingTestImpl() - UIntPtr + UIntPtr UIntPtr + + UIntPtr + ref UIntPtr diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/CXXMethodDeclarationTest.cs index 0f0f5e63..a27fcb0a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/CXXMethodDeclarationTest.cs @@ -165,6 +165,48 @@ operator int() return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; + + var expectedOutputContents = $@" + + + + + int* + + MyStruct* + + + int* + + null + + + + + + +"; + + return ValidateGeneratedXmlDefaultUnixBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -212,14 +254,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@" diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs index 7e116390..ae891ca8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs @@ -87,8 +87,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -230,7 +228,7 @@ enum MyEnum2 : int var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -275,7 +273,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -320,7 +318,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -365,8 +363,8 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs index ad2a82a8..8ef79a6b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs @@ -451,4 +451,14 @@ protected override Task SourceLocationTestImpl() } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs index 3c8b5a83..a3cca916 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs @@ -1891,7 +1891,7 @@ protected override Task WithPackingTestImpl() struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1900,27 +1900,27 @@ struct MyStruct - nuint + nuint nuint + + nuint + ref nuint int - return ref AsSpan(int.MaxValue)[index]; + return ref AsSpan()[index]; Span<nuint> - - int - - MemoryMarshal.CreateSpan(ref e0, length); + MemoryMarshal.CreateSpan(ref e0, 2); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/CXXMethodDeclarationTest.cs index 82435999..68d12ca2 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/CXXMethodDeclarationTest.cs @@ -165,6 +165,48 @@ operator int() return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; + + var expectedOutputContents = $@" + + + + + int* + + MyStruct* + + + int* + + null + + + + + + +"; + + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -212,14 +254,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@" diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs index d42f3d2b..685f8e36 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs @@ -87,8 +87,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -230,7 +228,7 @@ enum MyEnum2 : int var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -275,7 +273,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -320,7 +318,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -365,8 +363,8 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs index 79a1ea0d..39c1c6fa 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs @@ -451,4 +451,14 @@ protected override Task SourceLocationTestImpl() } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs index 128bfc45..6873e848 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs @@ -1901,7 +1901,7 @@ protected override Task WithPackingTestImpl() { const string InputContents = @"struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1910,27 +1910,27 @@ protected override Task WithPackingTestImpl() - nuint + nuint nuint + + nuint + ref nuint int - return ref AsSpan(int.MaxValue)[index]; + return ref AsSpan()[index]; Span<nuint> - - int - - MemoryMarshal.CreateSpan(ref e0, length); + MemoryMarshal.CreateSpan(ref e0, 2); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs index c71b11b2..6f9e9e76 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs @@ -165,6 +165,48 @@ operator int() return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; + + var expectedOutputContents = $@" + + + + + int* + + MyStruct* + + + int* + + null + + + + + + +"; + + return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -212,14 +254,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@" diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs index ce063a40..6161c739 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs @@ -87,8 +87,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -230,7 +228,7 @@ enum MyEnum2 : int var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -275,7 +273,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -320,7 +318,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -365,8 +363,8 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs index ce5041aa..d3222b5d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs @@ -451,4 +451,14 @@ protected override Task SourceLocationTestImpl() } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs index 5e523142..c195d55d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs @@ -22,10 +22,31 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex var expectedOutputContents = $@" - + {expectedManagedType} + + + {expectedManagedType} + + + ref {expectedManagedType} + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<{expectedManagedType}> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + @@ -730,10 +751,16 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -753,10 +780,16 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(2 * 1 * 3 * 4) + + {expectedManagedType} + + @@ -778,10 +811,16 @@ struct MyStruct var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -992,7 +1031,7 @@ struct MyStruct {expectedManagedType} - + {expectedManagedType} @@ -1023,16 +1062,16 @@ struct MyStruct Span<{expectedManagedType}> - return MemoryMarshal.CreateSpan(ref Anonymous.buffer1[0], 4); + return Anonymous.buffer1; Span<MyUnion> - return Anonymous.buffer2.AsSpan(); + return Anonymous.buffer2; - + {expectedManagedType} @@ -1053,6 +1092,12 @@ struct MyStruct {expectedManagedType} + + InlineArray(4) + + {expectedManagedType} + + InlineArray(4) @@ -1735,7 +1780,7 @@ protected override Task WithPackingTestImpl() struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1744,28 +1789,13 @@ struct MyStruct - nuint + nuint + InlineArray(2) nuint - - ref nuint - - int - - - return ref AsSpan(int.MaxValue)[index]; - - - - Span<nuint> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs index 2a04f051..456dea7c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs @@ -497,10 +497,16 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -520,10 +526,16 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(2 * 1 * 3 * 4) + + {expectedManagedType} + + @@ -545,10 +557,16 @@ union MyUnion var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -632,7 +650,7 @@ union MyUnion {expectedManagedType} - + {expectedManagedType} @@ -660,10 +678,10 @@ union MyUnion Span<{expectedManagedType}> - return MemoryMarshal.CreateSpan(ref Anonymous.buffer[0], 4); + return Anonymous.buffer; - + {expectedManagedType} @@ -673,6 +691,12 @@ union MyUnion {expectedManagedType} + + InlineArray(4) + + {expectedManagedType} + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs index 947e12c8..56aa6a01 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs @@ -165,6 +165,48 @@ operator int() return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; + + var expectedOutputContents = $@" + + + + + int* + + MyStruct* + + + int* + + null + + + + + + +"; + + return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -212,14 +254,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@" diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs index 32dfb994..cb6bf487 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs @@ -87,8 +87,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -230,7 +228,7 @@ enum MyEnum2 : int var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -275,7 +273,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -320,7 +318,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -365,8 +363,8 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs index 43f39925..83365118 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs @@ -451,4 +451,14 @@ protected override Task SourceLocationTestImpl() } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs index dfcf8a15..173ae57e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs @@ -22,10 +22,31 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex var expectedOutputContents = $@" - + {expectedManagedType} + + + {expectedManagedType} + + + ref {expectedManagedType} + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<{expectedManagedType}> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + @@ -742,10 +763,16 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -765,10 +792,16 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(2 * 1 * 3 * 4) + + {expectedManagedType} + + @@ -790,10 +823,16 @@ struct MyStruct var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -1004,7 +1043,7 @@ struct MyStruct {expectedManagedType} - + {expectedManagedType} @@ -1035,16 +1074,16 @@ struct MyStruct Span<{expectedManagedType}> - return MemoryMarshal.CreateSpan(ref Anonymous.buffer1[0], 4); + return Anonymous.buffer1; Span<MyUnion> - return Anonymous.buffer2.AsSpan(); + return Anonymous.buffer2; - + {expectedManagedType} @@ -1065,6 +1104,12 @@ struct MyStruct {expectedManagedType} + + InlineArray(4) + + {expectedManagedType} + + InlineArray(4) @@ -1745,7 +1790,7 @@ protected override Task WithPackingTestImpl() { const string InputContents = @"struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1754,28 +1799,13 @@ protected override Task WithPackingTestImpl() - nuint + nuint + InlineArray(2) nuint - - ref nuint - - int - - - return ref AsSpan(int.MaxValue)[index]; - - - - Span<nuint> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs index e1116cb6..85d7ac1e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs @@ -503,10 +503,16 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -526,10 +532,16 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(2 * 1 * 3 * 4) + + {expectedManagedType} + + @@ -551,10 +563,16 @@ union MyUnion var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -638,7 +656,7 @@ union MyUnion {expectedManagedType} - + {expectedManagedType} @@ -666,10 +684,10 @@ union MyUnion Span<{expectedManagedType}> - return MemoryMarshal.CreateSpan(ref Anonymous.buffer[0], 4); + return Anonymous.buffer; - + {expectedManagedType} @@ -679,6 +697,12 @@ union MyUnion {expectedManagedType} + + InlineArray(4) + + {expectedManagedType} + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs index 630770a9..6f753d62 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs @@ -165,6 +165,46 @@ operator int() return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; + var expectedOutputContents = $@" + + + + + int* + + MyStruct* + + + int* + + null + + + + + + +"; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -212,14 +252,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@" diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs index 76537a1f..cb00d940 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs @@ -87,8 +87,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -230,7 +228,7 @@ enum MyEnum2 : int var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -275,7 +273,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -320,7 +318,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -365,8 +363,8 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs index ed3a3bad..7816a51b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs @@ -451,4 +451,14 @@ protected override Task SourceLocationTestImpl() } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs index 3aaa163e..d11a6c97 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs @@ -22,10 +22,31 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex var expectedOutputContents = $@" - + {expectedManagedType} + + + {expectedManagedType} + + + ref {expectedManagedType} + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<{expectedManagedType}> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + @@ -730,10 +751,16 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -753,10 +780,16 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(2 * 1 * 3 * 4) + + {expectedManagedType} + + @@ -778,10 +811,16 @@ struct MyStruct var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -992,7 +1031,7 @@ struct MyStruct {expectedManagedType} - + {expectedManagedType} @@ -1023,16 +1062,16 @@ struct MyStruct Span<{expectedManagedType}> - return MemoryMarshal.CreateSpan(ref Anonymous.buffer1[0], 4); + return Anonymous.buffer1; Span<MyUnion> - return Anonymous.buffer2.AsSpan(); + return Anonymous.buffer2; - + {expectedManagedType} @@ -1053,6 +1092,12 @@ struct MyStruct {expectedManagedType} + + InlineArray(4) + + {expectedManagedType} + + InlineArray(4) @@ -1735,7 +1780,7 @@ protected override Task WithPackingTestImpl() struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1744,28 +1789,13 @@ struct MyStruct - nuint + nuint + InlineArray(2) nuint - - ref nuint - - int - - - return ref AsSpan(int.MaxValue)[index]; - - - - Span<nuint> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs index 3188695b..f2b921fb 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs @@ -497,10 +497,16 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -520,10 +526,16 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(2 * 1 * 3 * 4) + + {expectedManagedType} + + @@ -545,10 +557,16 @@ union MyUnion var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -632,7 +650,7 @@ union MyUnion {expectedManagedType} - + {expectedManagedType} @@ -660,10 +678,10 @@ union MyUnion Span<{expectedManagedType}> - return MemoryMarshal.CreateSpan(ref Anonymous.buffer[0], 4); + return Anonymous.buffer; - + {expectedManagedType} @@ -673,6 +691,12 @@ union MyUnion {expectedManagedType} + + InlineArray(4) + + {expectedManagedType} + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs index 6a341edf..e942b31a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs @@ -165,6 +165,47 @@ operator int() return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } + protected override Task DefaultParameterInheritedFromTemplateTestImpl() + { + // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. + const string InputContents = @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"; + + var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; + + var expectedOutputContents = $@" + + + + + int* + + MyStruct* + + + int* + + null + + + + + + +"; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); + } + protected override Task DestructorTestImpl() { var inputContents = @"struct MyStruct @@ -212,14 +253,9 @@ int MyInt32Method() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = Environment.Is64BitProcess + ? "?MyVoidMethod@MyStruct@@QEAAXXZ" + : "?MyVoidMethod@MyStruct@@QAEXXZ"; } var expectedOutputContents = $@" diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs index babf4a06..0f1d75a1 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs @@ -87,8 +87,6 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } @@ -230,7 +228,7 @@ enum MyEnum2 : int var withAttributes = new Dictionary> { - ["MyEnum1"] = new List() { "Flags" } + ["MyEnum1"] = ["Flags"] }; return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); } @@ -275,7 +273,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -320,7 +318,7 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + ["*"] = ["static ClangSharp.Test.MyEnum1"] }; return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } @@ -365,8 +363,8 @@ enum MyEnum2 : int var withNamespaces = new Dictionary> { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] }; return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs index 613f479f..6258e963 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs @@ -451,4 +451,14 @@ protected override Task SourceLocationTestImpl() } protected override Task VarargsTestImpl() => Task.CompletedTask; + + protected override Task IntrinsicsTestImpl() + { + const string InputContents = @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"; + + const string ExpectedOutputContents = @""; + + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); + } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs index 6045543f..75b64af4 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs @@ -22,10 +22,31 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex var expectedOutputContents = $@" - + {expectedManagedType} + + + {expectedManagedType} + + + ref {expectedManagedType} + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<{expectedManagedType}> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + @@ -742,10 +763,16 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -765,10 +792,16 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(2 * 1 * 3 * 4) + + {expectedManagedType} + + @@ -790,10 +823,16 @@ struct MyStruct var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -1004,7 +1043,7 @@ struct MyStruct {expectedManagedType} - + {expectedManagedType} @@ -1035,16 +1074,16 @@ struct MyStruct Span<{expectedManagedType}> - return MemoryMarshal.CreateSpan(ref Anonymous.buffer1[0], 4); + return Anonymous.buffer1; Span<MyUnion> - return Anonymous.buffer2.AsSpan(); + return Anonymous.buffer2; - + {expectedManagedType} @@ -1065,6 +1104,12 @@ struct MyStruct {expectedManagedType} + + InlineArray(4) + + {expectedManagedType} + + InlineArray(4) @@ -1745,7 +1790,7 @@ protected override Task WithPackingTestImpl() { const string InputContents = @"struct MyStruct { - size_t FixedBuffer[1]; + size_t FixedBuffer[2]; }; "; @@ -1754,28 +1799,13 @@ protected override Task WithPackingTestImpl() - nuint + nuint + InlineArray(2) nuint - - ref nuint - - int - - - return ref AsSpan(int.MaxValue)[index]; - - - - Span<nuint> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs index 8809aa70..d9cdd573 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs @@ -503,10 +503,16 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -526,10 +532,16 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(2 * 1 * 3 * 4) + + {expectedManagedType} + + @@ -551,10 +563,16 @@ union MyUnion var expectedOutputContents = $@" - + {expectedManagedType} + + InlineArray(3) + + {expectedManagedType} + + @@ -638,7 +656,7 @@ union MyUnion {expectedManagedType} - + {expectedManagedType} @@ -666,10 +684,10 @@ union MyUnion Span<{expectedManagedType}> - return MemoryMarshal.CreateSpan(ref Anonymous.buffer[0], 4); + return Anonymous.buffer; - + {expectedManagedType} @@ -679,6 +697,12 @@ union MyUnion {expectedManagedType} + + InlineArray(4) + + {expectedManagedType} + + diff --git a/tests/ClangSharp.UnitTests/CXModuleMapDescriptorTest.cs b/tests/ClangSharp.UnitTests/CXModuleMapDescriptorTest.cs index 1a1700a8..10509fcf 100644 --- a/tests/ClangSharp.UnitTests/CXModuleMapDescriptorTest.cs +++ b/tests/ClangSharp.UnitTests/CXModuleMapDescriptorTest.cs @@ -23,7 +23,7 @@ public void Basic() _ = mmd.SetUmbrellaHeader("TestFrame.h"); var buffer = mmd.WriteToBuffer(options: 0, errorCode: out _); - Assert.AreEqual(contents, buffer.AsString()); + Assert.That(buffer.AsString(), Is.EqualTo(contents)); buffer.ClangFree(); } } diff --git a/tests/ClangSharp.UnitTests/CXTranslationUnitTest.cs b/tests/ClangSharp.UnitTests/CXTranslationUnitTest.cs index 3c44d6b7..99edf98d 100644 --- a/tests/ClangSharp.UnitTests/CXTranslationUnitTest.cs +++ b/tests/ClangSharp.UnitTests/CXTranslationUnitTest.cs @@ -1,6 +1,5 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -using System; using System.IO; using ClangSharp.Interop; using NUnit.Framework; @@ -27,9 +26,9 @@ public void Basic(string name) File.WriteAllText(file.FullName, "int main() { return 0; }"); using var index = CXIndex.Create(); - using var translationUnit = CXTranslationUnit.Parse(index, file.FullName, Array.Empty(), Array.Empty(), CXTranslationUnit_None); + using var translationUnit = CXTranslationUnit.Parse(index, file.FullName, [], [], CXTranslationUnit_None); var clangFile = translationUnit.GetFile(file.FullName); - Assert.AreEqual(file.FullName, clangFile.Name.CString); + Assert.That(clangFile.Name.CString, Is.EqualTo(file.FullName)); } finally { @@ -53,12 +52,12 @@ public void BasicWrapper(string name) File.WriteAllText(file.FullName, "int main() { return 0; }"); var index = CXIndex.Create(); - var translationUnit = CXTranslationUnit.Parse(index, file.FullName, Array.Empty(), Array.Empty(), CXTranslationUnit_None); + var translationUnit = CXTranslationUnit.Parse(index, file.FullName, [], [], CXTranslationUnit_None); var clangFile = translationUnit.GetFile(file.FullName); var clangFileName = clangFile.Name; var clangFileNameString = clangFileName.CString; - Assert.AreEqual(file.FullName, clangFileNameString); + Assert.That(clangFileNameString, Is.EqualTo(file.FullName)); } finally { diff --git a/tests/ClangSharp.UnitTests/CXVirtualFileOverlayTest.cs b/tests/ClangSharp.UnitTests/CXVirtualFileOverlayTest.cs index 1e2b3132..dc8e2266 100644 --- a/tests/ClangSharp.UnitTests/CXVirtualFileOverlayTest.cs +++ b/tests/ClangSharp.UnitTests/CXVirtualFileOverlayTest.cs @@ -33,7 +33,7 @@ public void Map(string? vPath, string? rPath) rPath = Fix(rPath); var err = VFO.AddFileMapping(vPath, rPath); - Assert.AreEqual(CXError_Success, err); + Assert.That(err, Is.EqualTo(CXError_Success)); } public void MapError(string? vPath, string? rPath, CXErrorCode expErr) @@ -42,7 +42,7 @@ public void MapError(string? vPath, string? rPath, CXErrorCode expErr) rPath = Fix(rPath); var err = VFO.AddFileMapping(vPath, rPath); - Assert.AreEqual(expErr, err); + Assert.That(err, Is.EqualTo(expErr)); } private static string? Fix(string? text) @@ -73,7 +73,7 @@ private void Dispose(bool isDisposing) if (_contents != null) { var buffer = VFO.WriteToBuffer(options: 0, errorCode: out _); - Assert.AreEqual(_contents, buffer.AsString()); + Assert.That(buffer.AsString(), Is.EqualTo(_contents)); buffer.ClangFree(); } diff --git a/tests/ClangSharp.UnitTests/CursorTests/DeclTest.cs b/tests/ClangSharp.UnitTests/CursorTests/DeclTest.cs index 96317468..067280f1 100644 --- a/tests/ClangSharp.UnitTests/CursorTests/DeclTest.cs +++ b/tests/ClangSharp.UnitTests/CursorTests/DeclTest.cs @@ -26,7 +26,7 @@ public void AccessSpecDeclTest(string accessSpecifier, CX_CXXAccessSpecifier exp var recordDecl = translationUnit.TranslationUnitDecl.Decls.OfType().Where((recordDecl) => recordDecl.Name.Equals("MyStruct", StringComparison.Ordinal)).Single(); var accessSpecDecl = recordDecl.Decls.OfType().Single(); - Assert.AreEqual(expectedAccessSpecifier, accessSpecDecl.Access); + Assert.That(accessSpecDecl.Access, Is.EqualTo(expectedAccessSpecifier)); } [Test] @@ -42,10 +42,10 @@ class MyClass using var translationUnit = CreateTranslationUnit(inputContents); var classTemplateDecl = translationUnit.TranslationUnitDecl.Decls.OfType().Single(); - Assert.AreEqual("MyClass", classTemplateDecl.Name); + Assert.That(classTemplateDecl.Name, Is.EqualTo("MyClass")); var templateParameter = classTemplateDecl.TemplateParameters.Single(); - Assert.AreEqual("T", templateParameter.Name); + Assert.That(templateParameter.Name, Is.EqualTo("T")); } [Test] @@ -69,9 +69,9 @@ class MyClass using var translationUnit = CreateTranslationUnit(inputContents); var classTemplatePartialSpecializationDecl = translationUnit.TranslationUnitDecl.Decls.OfType().Single(); - Assert.AreEqual("MyClass", classTemplatePartialSpecializationDecl.Name); + Assert.That(classTemplatePartialSpecializationDecl.Name, Is.EqualTo("MyClass")); var templateParameter = classTemplatePartialSpecializationDecl.TemplateParameters.Single(); - Assert.AreEqual("U", templateParameter.Name); + Assert.That(templateParameter.Name, Is.EqualTo("U")); } } diff --git a/tests/ClangSharp.UnitTests/TranslationUnitTest.cs b/tests/ClangSharp.UnitTests/TranslationUnitTest.cs index 68b22ce6..4f210251 100644 --- a/tests/ClangSharp.UnitTests/TranslationUnitTest.cs +++ b/tests/ClangSharp.UnitTests/TranslationUnitTest.cs @@ -1,6 +1,5 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -using System.IO; using System.Text; using ClangSharp.Interop; using NUnit.Framework; @@ -26,7 +25,7 @@ public abstract class TranslationUnitTest protected static TranslationUnit CreateTranslationUnit(string inputContents) { - Assert.True(File.Exists(DefaultInputFileName)); + Assert.That(DefaultInputFileName, Does.Exist); using var unsavedFile = CXUnsavedFile.Create(DefaultInputFileName, inputContents); var unsavedFiles = new CXUnsavedFile[] { unsavedFile }; @@ -52,7 +51,7 @@ protected static TranslationUnit CreateTranslationUnit(string inputContents) } } - Assert.False(invalidTranslationUnitHandle, errorDiagnostics.ToString()); + Assert.That(invalidTranslationUnitHandle, Is.False, errorDiagnostics.ToString()); } return TranslationUnit.GetOrCreate(translationUnit);