diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..e40f7ac1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.13) + +project(ClangSharp VERSION 9.0.0) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +add_subdirectory(sources) diff --git a/Directory.Build.targets b/Directory.Build.targets index 08cbe1b0..cb58e739 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -27,7 +27,8 @@ - + + diff --git a/packages/libClangSharp.runtime.freebsd.11-x64/libClangSharp.runtime.freebsd.11-x64.nuspec b/packages/libClangSharp.runtime.freebsd.11-x64/libClangSharp.runtime.freebsd.11-x64.nuspec new file mode 100644 index 00000000..620052b6 --- /dev/null +++ b/packages/libClangSharp.runtime.freebsd.11-x64/libClangSharp.runtime.freebsd.11-x64.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.freebsd.11-x64 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + freebsd 11 x64 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.freebsd.11-x86/libClangSharp.runtime.freebsd.11-x86.nuspec b/packages/libClangSharp.runtime.freebsd.11-x86/libClangSharp.runtime.freebsd.11-x86.nuspec new file mode 100644 index 00000000..9b91c142 --- /dev/null +++ b/packages/libClangSharp.runtime.freebsd.11-x86/libClangSharp.runtime.freebsd.11-x86.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.freebsd.11-x86 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + freebsd 11 x86 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.linux-arm/libClangSharp.runtime.linux-arm.nuspec b/packages/libClangSharp.runtime.linux-arm/libClangSharp.runtime.linux-arm.nuspec new file mode 100644 index 00000000..f47a8ef2 --- /dev/null +++ b/packages/libClangSharp.runtime.linux-arm/libClangSharp.runtime.linux-arm.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.linux-arm + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + linux arm native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.linux-arm64/libClangSharp.runtime.linux-arm64.nuspec b/packages/libClangSharp.runtime.linux-arm64/libClangSharp.runtime.linux-arm64.nuspec new file mode 100644 index 00000000..7b489538 --- /dev/null +++ b/packages/libClangSharp.runtime.linux-arm64/libClangSharp.runtime.linux-arm64.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.linux-arm64 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + linux arm64 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.osx-x64/libClangSharp.runtime.osx-x64.nuspec b/packages/libClangSharp.runtime.osx-x64/libClangSharp.runtime.osx-x64.nuspec new file mode 100644 index 00000000..3226a594 --- /dev/null +++ b/packages/libClangSharp.runtime.osx-x64/libClangSharp.runtime.osx-x64.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.osx-x64 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + osx x64 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.sles-x64/libClangSharp.runtime.sles-x64.nuspec b/packages/libClangSharp.runtime.sles-x64/libClangSharp.runtime.sles-x64.nuspec new file mode 100644 index 00000000..7b4d3719 --- /dev/null +++ b/packages/libClangSharp.runtime.sles-x64/libClangSharp.runtime.sles-x64.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.sles-x64 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + sles x64 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.ubuntu.14.04-x64/libClangSharp.runtime.ubuntu.14.04-x64.nuspec b/packages/libClangSharp.runtime.ubuntu.14.04-x64/libClangSharp.runtime.ubuntu.14.04-x64.nuspec new file mode 100644 index 00000000..9b3b07dc --- /dev/null +++ b/packages/libClangSharp.runtime.ubuntu.14.04-x64/libClangSharp.runtime.ubuntu.14.04-x64.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.ubuntu.14.04-x64 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + ubuntu 14.04 x64 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.ubuntu.16.04-x64/libClangSharp.runtime.ubuntu.16.04-x64.nuspec b/packages/libClangSharp.runtime.ubuntu.16.04-x64/libClangSharp.runtime.ubuntu.16.04-x64.nuspec new file mode 100644 index 00000000..cd2697aa --- /dev/null +++ b/packages/libClangSharp.runtime.ubuntu.16.04-x64/libClangSharp.runtime.ubuntu.16.04-x64.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.ubuntu.16.04-x64 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + ubuntu 16.04 x64 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.ubuntu.18.04-x64/libClangSharp.runtime.ubuntu.18.04-x64.nuspec b/packages/libClangSharp.runtime.ubuntu.18.04-x64/libClangSharp.runtime.ubuntu.18.04-x64.nuspec new file mode 100644 index 00000000..5742b4e6 --- /dev/null +++ b/packages/libClangSharp.runtime.ubuntu.18.04-x64/libClangSharp.runtime.ubuntu.18.04-x64.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.ubuntu.18.04-x64 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + ubuntu 18.04 x64 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.ubuntu.19.04-x64/libClangSharp.runtime.ubuntu.19.04-x64.nuspec b/packages/libClangSharp.runtime.ubuntu.19.04-x64/libClangSharp.runtime.ubuntu.19.04-x64.nuspec new file mode 100644 index 00000000..9da14f3f --- /dev/null +++ b/packages/libClangSharp.runtime.ubuntu.19.04-x64/libClangSharp.runtime.ubuntu.19.04-x64.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.ubuntu.19.04-x64 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + ubuntu 19.04 x64 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.win-x64/libClangSharp.runtime.win-x64.nuspec b/packages/libClangSharp.runtime.win-x64/libClangSharp.runtime.win-x64.nuspec new file mode 100644 index 00000000..4a1b39bb --- /dev/null +++ b/packages/libClangSharp.runtime.win-x64/libClangSharp.runtime.win-x64.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.win-x64 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + win x64 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp.runtime.win-x86/libClangSharp.runtime.win-x86.nuspec b/packages/libClangSharp.runtime.win-x86/libClangSharp.runtime.win-x86.nuspec new file mode 100644 index 00000000..373e91fd --- /dev/null +++ b/packages/libClangSharp.runtime.win-x86/libClangSharp.runtime.win-x86.nuspec @@ -0,0 +1,20 @@ + + + + libClangSharp.runtime.win-x86 + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + win x86 native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + diff --git a/packages/libClangSharp/LICENSE.TXT b/packages/libClangSharp/LICENSE.TXT new file mode 100644 index 00000000..fa8b2681 --- /dev/null +++ b/packages/libClangSharp/LICENSE.TXT @@ -0,0 +1,12 @@ +University of Illinois/NCSA Open Source License +Copyright (c) Microsoft and Contributors +All rights reserved. + +Developed by: Microsoft and Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. +Neither the names of Microsoft, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. diff --git a/packages/libClangSharp/NOTICE.txt b/packages/libClangSharp/NOTICE.txt new file mode 100644 index 00000000..d6e4cf8d --- /dev/null +++ b/packages/libClangSharp/NOTICE.txt @@ -0,0 +1,280 @@ +# The LLVM Project + +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2007-2019 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. diff --git a/packages/libClangSharp/libClangSharp.nuspec b/packages/libClangSharp/libClangSharp.nuspec new file mode 100644 index 00000000..567c0679 --- /dev/null +++ b/packages/libClangSharp/libClangSharp.nuspec @@ -0,0 +1,25 @@ + + + + libClangSharp + 9.0.0-beta1 + Microsoft and Contributors + Microsoft and Contributors + true + NCSA + https://github.com/microsoft/clangsharp + Multi-platform native library for libClangSharp. + Copyright © Microsoft and Contributors + + + + + + + + + + + + + diff --git a/packages/libClangSharp/runtime.json b/packages/libClangSharp/runtime.json new file mode 100644 index 00000000..fcefb50d --- /dev/null +++ b/packages/libClangSharp/runtime.json @@ -0,0 +1,64 @@ +{ + "runtimes": { + "freebsd.11-x64": { + "libClangSharp": { + "libClangSharp.runtime.freebsd.11-x64": "9.0.0-beta1" + } + }, + "freebsd.11-x86": { + "libClangSharp": { + "libClangSharp.runtime.freebsd.11-x86": "9.0.0-beta1" + } + }, + "linux-arm": { + "libClangSharp": { + "libClangSharp.runtime.linux-arm": "9.0.0-beta1" + } + }, + "linux-arm64": { + "libClangSharp": { + "libClangSharp.runtime.linux-arm64": "9.0.0-beta1" + } + }, + "osx-x64": { + "libClangSharp": { + "libClangSharp.runtime.osx-x64": "9.0.0-beta1" + } + }, + "sles-x64": { + "libClangSharp": { + "libClangSharp.runtime.sles-x64": "9.0.0-beta1" + } + }, + "ubuntu.14.04-x64": { + "libClangSharp": { + "libClangSharp.runtime.ubuntu.14.04-x64": "9.0.0-beta1" + } + }, + "ubuntu.16.04-x64": { + "libClangSharp": { + "libClangSharp.runtime.ubuntu.16.04-x64": "9.0.0-beta1" + } + }, + "ubuntu.18.04-x64": { + "libClangSharp": { + "libClangSharp.runtime.ubuntu.18.04-x64": "9.0.0-beta1" + } + }, + "ubuntu.19.04-x64": { + "libClangSharp": { + "libClangSharp.runtime.ubuntu.19.04-x64": "9.0.0-beta1" + } + }, + "win-x64": { + "libClangSharp": { + "libClangSharp.runtime.win-x64": "9.0.0-beta1" + } + }, + "win-x86": { + "libClangSharp": { + "libClangSharp.runtime.win-x86": "9.0.0-beta1" + } + } + } +} diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt new file mode 100644 index 00000000..6e1e5d53 --- /dev/null +++ b/sources/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(libClangSharp) diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index e056d17d..106f275e 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -588,7 +588,7 @@ private string GetCursorName(NamedDecl namedDecl) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported anonymous named declaration: '{namedDecl.KindSpelling}'.", namedDecl); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported anonymous named declaration: '{namedDecl.CursorKindSpelling}'.", namedDecl); } } @@ -968,7 +968,7 @@ private void Visit(Cursor cursor) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported cursor: '{cursor.KindSpelling}'. Generated bindings may be incomplete.", cursor); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported cursor: '{cursor.CursorKindSpelling}'. Generated bindings may be incomplete.", cursor); } } @@ -981,7 +981,7 @@ private void VisitBinaryOperator(BinaryOperator binaryOperator) { Visit(binaryOperator.LHS); _outputBuilder.Write(' '); - _outputBuilder.Write(binaryOperator.Opcode); + _outputBuilder.Write(binaryOperator.OpcodeStr); _outputBuilder.Write(' '); Visit(binaryOperator.RHS); } @@ -1006,7 +1006,7 @@ private void VisitCallExpr(CallExpr callExpr) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported callee declaration: '{calleeDecl.KindSpelling}'. Generated bindings may be incomplete.", calleeDecl); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported callee declaration: '{calleeDecl.CursorKindSpelling}'. Generated bindings may be incomplete.", calleeDecl); } } @@ -1033,13 +1033,13 @@ private void VisitDecl(Decl decl) { VisitNamedDecl(namedDecl); } - else if (decl.Kind == CXCursorKind.CXCursor_UnexposedDecl) + else if (decl.CursorKind == CXCursorKind.CXCursor_UnexposedDecl) { VisitUnexposedDecl(decl); } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported declaration: '{decl.KindSpelling}'. Generated bindings may be incomplete.", decl); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported declaration: '{decl.CursorKindSpelling}'. Generated bindings may be incomplete.", decl); } } @@ -1059,7 +1059,7 @@ private void VisitDeclaratorDecl(DeclaratorDecl declaratorDecl) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported declarator declaration: '{declaratorDecl.KindSpelling}'. Generated bindings may be incomplete.", declaratorDecl); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported declarator declaration: '{declaratorDecl.CursorKindSpelling}'. Generated bindings may be incomplete.", declaratorDecl); } } @@ -1154,13 +1154,13 @@ private void VisitExpr(Expr expr) { VisitUnaryOperator(unaryOperator); } - else if (expr.Kind == CXCursorKind.CXCursor_UnexposedExpr) + else if (expr.CursorKind == CXCursorKind.CXCursor_UnexposedExpr) { VisitUnexposedExpr(expr); } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported expression: '{expr.KindSpelling}'. Generated bindings may be incomplete.", expr); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported expression: '{expr.CursorKindSpelling}'. Generated bindings may be incomplete.", expr); } } @@ -1330,7 +1330,7 @@ private void VisitNamedDecl(NamedDecl namedDecl) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported named declaration: '{namedDecl.KindSpelling}'. Generated bindings may be incomplete.", namedDecl); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported named declaration: '{namedDecl.CursorKindSpelling}'. Generated bindings may be incomplete.", namedDecl); } } @@ -1355,7 +1355,7 @@ private void VisitParmVarDecl(ParmVarDecl parmVarDecl) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported parameter variable declaration parent: '{cursorParent.KindSpelling}'. Generated bindings may be incomplete.", cursorParent); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported parameter variable declaration parent: '{cursorParent.CursorKindSpelling}'. Generated bindings may be incomplete.", cursorParent); } } @@ -1532,7 +1532,7 @@ private void VisitRecordDecl(RecordDecl recordDecl) private void VisitRef(Ref @ref) { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported reference: '{@ref.KindSpelling}'. Generated bindings may be incomplete.", @ref); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported reference: '{@ref.CursorKindSpelling}'. Generated bindings may be incomplete.", @ref); } private void VisitReturnStmt(ReturnStmt returnStmt) @@ -1562,7 +1562,7 @@ private void VisitStmt(Stmt stmt) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported statement: '{stmt.KindSpelling}'. Generated bindings may be incomplete.", stmt); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported statement: '{stmt.CursorKindSpelling}'. Generated bindings may be incomplete.", stmt); } } @@ -1589,7 +1589,7 @@ private void VisitTagDecl(TagDecl tagDecl) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported tag declaration: '{tagDecl.KindSpelling}'. Generated bindings may be incomplete.", tagDecl); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported tag declaration: '{tagDecl.CursorKindSpelling}'. Generated bindings may be incomplete.", tagDecl); } } @@ -1605,7 +1605,7 @@ private void VisitTypeDecl(TypeDecl typeDecl) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported type declaration: '{typeDecl.KindSpelling}'. Generated bindings may be incomplete.", typeDecl); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported type declaration: '{typeDecl.CursorKindSpelling}'. Generated bindings may be incomplete.", typeDecl); } } @@ -1617,7 +1617,7 @@ private void VisitTypedefNameDecl(TypedefNameDecl typedefNameDecl) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported typedef name declaration: '{typedefNameDecl.KindSpelling}'. Generated bindings may be incomplete.", typedefNameDecl); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported typedef name declaration: '{typedefNameDecl.CursorKindSpelling}'. Generated bindings may be incomplete.", typedefNameDecl); } } @@ -1705,15 +1705,35 @@ private void VisitTypedefDeclForPointeeType(TypedefDecl typedefDecl, Type pointe private void VisitUnaryOperator(UnaryOperator unaryOperator) { - if (unaryOperator.IsPrefix) + switch (unaryOperator.Opcode) { - _outputBuilder.Write(unaryOperator.Opcode); - Visit(unaryOperator.SubExpr); - } - else - { - Visit(unaryOperator.SubExpr); - _outputBuilder.Write(unaryOperator.Opcode); + case CX_UnaryOperatorKind.CX_UO_PostInc: + case CX_UnaryOperatorKind.CX_UO_PostDec: + { + Visit(unaryOperator.SubExpr); + _outputBuilder.Write(unaryOperator.OpcodeStr); + break; + } + + case CX_UnaryOperatorKind.CX_UO_PreInc: + case CX_UnaryOperatorKind.CX_UO_PreDec: + case CX_UnaryOperatorKind.CX_UO_AddrOf: + case CX_UnaryOperatorKind.CX_UO_Deref: + case CX_UnaryOperatorKind.CX_UO_Plus: + case CX_UnaryOperatorKind.CX_UO_Minus: + case CX_UnaryOperatorKind.CX_UO_Not: + case CX_UnaryOperatorKind.CX_UO_LNot: + { + _outputBuilder.Write(unaryOperator.OpcodeStr); + Visit(unaryOperator.SubExpr); + break; + } + + default: + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported unary operator opcode: '{unaryOperator.OpcodeStr}'. Generated bindings may be incomplete.", unaryOperator); + break; + } } } @@ -1729,7 +1749,7 @@ private void VisitValueDecl(ValueDecl valueDecl) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported value declaration: '{valueDecl.KindSpelling}'. Generated bindings may be incomplete.", valueDecl); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported value declaration: '{valueDecl.CursorKindSpelling}'. Generated bindings may be incomplete.", valueDecl); } } @@ -1741,7 +1761,7 @@ private void VisitValueStmt(ValueStmt valueStmt) } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported value statement: '{valueStmt.KindSpelling}'. Generated bindings may be incomplete.", valueStmt); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported value statement: '{valueStmt.CursorKindSpelling}'. Generated bindings may be incomplete.", valueStmt); } } @@ -1774,7 +1794,7 @@ private void VisitVarDecl(VarDecl varDecl) private void VisitUnexposedDecl(Decl unexposedDecl) { - Debug.Assert(unexposedDecl.Kind == CXCursorKind.CXCursor_UnexposedDecl); + Debug.Assert(unexposedDecl.CursorKind == CXCursorKind.CXCursor_UnexposedDecl); foreach (var decl in unexposedDecl.CursorChildren.OfType()) { @@ -1784,7 +1804,7 @@ private void VisitUnexposedDecl(Decl unexposedDecl) private void VisitUnexposedExpr(Expr unexposedExpr) { - Debug.Assert(unexposedExpr.Kind == CXCursorKind.CXCursor_UnexposedExpr); + Debug.Assert(unexposedExpr.CursorKind == CXCursorKind.CXCursor_UnexposedExpr); foreach (var stmt in unexposedExpr.Children) { diff --git a/sources/ClangSharp/ClangSharp.csproj b/sources/ClangSharp/ClangSharp.csproj index 32811139..9fd06f8e 100644 --- a/sources/ClangSharp/ClangSharp.csproj +++ b/sources/ClangSharp/ClangSharp.csproj @@ -7,6 +7,7 @@ + diff --git a/sources/ClangSharp/Cursors/Attrs/Attr.cs b/sources/ClangSharp/Cursors/Attrs/Attr.cs index 34b96281..21e3cc38 100644 --- a/sources/ClangSharp/Cursors/Attrs/Attr.cs +++ b/sources/ClangSharp/Cursors/Attrs/Attr.cs @@ -1,124 +1,306 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. -using System.Diagnostics; +using System; using ClangSharp.Interop; namespace ClangSharp { public class Attr : Cursor { - private protected Attr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected Attr(CXCursor handle) : base(handle, handle.Kind) { + if (handle.AttrKind == CX_AttrKind.CX_AttrKind_Invalid) + { + throw new ArgumentException(nameof(handle)); + } } - internal static new Attr Create(CXCursor handle) + internal static new Attr Create(CXCursor handle) => handle.AttrKind switch { - Attr result; - - switch (handle.Kind) - { - case CXCursorKind.CXCursor_UnexposedAttr: - { - result = new Attr(handle, CXCursorKind.CXCursor_UnexposedAttr); - break; - } - - case CXCursorKind.CXCursor_IBActionAttr: - case CXCursorKind.CXCursor_IBOutletAttr: - case CXCursorKind.CXCursor_IBOutletCollectionAttr: - case CXCursorKind.CXCursor_CXXFinalAttr: - case CXCursorKind.CXCursor_CXXOverrideAttr: - { - result = new InheritableAttr(handle, handle.Kind); - break; - } - - - case CXCursorKind.CXCursor_AnnotateAttr: - { - result = new InheritableParamAttr(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_AsmLabelAttr: - case CXCursorKind.CXCursor_PackedAttr: - case CXCursorKind.CXCursor_PureAttr: - case CXCursorKind.CXCursor_ConstAttr: - case CXCursorKind.CXCursor_NoDuplicateAttr: - case CXCursorKind.CXCursor_CUDAConstantAttr: - case CXCursorKind.CXCursor_CUDADeviceAttr: - case CXCursorKind.CXCursor_CUDAGlobalAttr: - case CXCursorKind.CXCursor_CUDAHostAttr: - case CXCursorKind.CXCursor_CUDASharedAttr: - case CXCursorKind.CXCursor_VisibilityAttr: - case CXCursorKind.CXCursor_DLLExport: - case CXCursorKind.CXCursor_DLLImport: - { - result = new InheritableAttr(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_NSReturnsRetained: - { - result = new DeclOrTypeAttr(handle, handle.Kind); - break; - } + CX_AttrKind.CX_AttrKind_AddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_NoDeref => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCGC => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCInertUnsafeUnretained => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCKindOf => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLConstantAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLGenericAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLGlobalAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLLocalAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLPrivateAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_Ptr32 => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_Ptr64 => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_SPtr => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_TypeNonNull => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_TypeNullUnspecified => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_TypeNullable => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_UPtr => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_FallThrough => new StmtAttr(handle), + CX_AttrKind.CX_AttrKind_Suppress => new StmtAttr(handle), + CX_AttrKind.CX_AttrKind_AArch64VectorPcs => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AnyX86NoCfCheck => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CDecl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_FastCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_IntelOclBicc => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LifetimeBound => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSABI => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NSReturnsRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCOwnership => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Pascal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Pcs => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PreserveAll => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PreserveMost => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_RegCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_StdCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SysVABI => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ThisCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_VectorCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftContext => new ParameterABIAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftErrorResult => new ParameterABIAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftIndirectResult => new ParameterABIAttr(handle), + CX_AttrKind.CX_AttrKind_Annotate => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_CFConsumed => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_CarriesDependency => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_NSConsumed => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_NonNull => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_OSConsumed => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_PassObjectSize => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_AMDGPUFlatWorkGroupSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AMDGPUNumSGPR => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AMDGPUNumVGPR => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AMDGPUWavesPerEU => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ARMInterrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AVRInterrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AVRSignal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AcquireCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AcquiredAfter => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AcquiredBefore => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AlignMac68k => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Aligned => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AllocAlign => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AllocSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AlwaysDestroy => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AlwaysInline => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AnalyzerNoReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AnyX86Interrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AnyX86NoCallerSavedRegisters => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ArcWeakrefUnavailable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ArgumentWithTypeTag => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Artificial => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AsmLabel => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AssertCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AssertExclusiveLock => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AssertSharedLock => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AssumeAligned => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Availability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Blocks => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_C11NoReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFAuditedTransfer => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFReturnsNotRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFReturnsRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFUnknownTransfer => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CPUDispatch => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CPUSpecific => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAConstant => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDADevice => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAGlobal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAHost => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAInvalidTarget => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDALaunchBounds => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAShared => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CXX11NoReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CallableWhen => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Callback => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Capability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CapturedRecord => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Cleanup => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CodeSeg => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Cold => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Common => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Const => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Constructor => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Consumable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ConsumableAutoCast => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ConsumableSetOnRead => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Convergent => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DLLExport => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DLLExportStaticLocal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DLLImport => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DLLImportStaticLocal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Deprecated => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Destructor => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DiagnoseIf => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DisableTailCalls => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_EmptyBases => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_EnableIf => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_EnumExtensibility => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ExcludeFromExplicitInstantiation => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ExclusiveTrylockFunction => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ExternalSourceSymbol => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Final => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_FlagEnum => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Flatten => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Format => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_FormatArg => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_GNUInline => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_GuardedBy => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_GuardedVar => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_HIPPinnedShadow => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Hot => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_IBAction => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_IBOutlet => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_IBOutletCollection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_InitPriority => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_InternalLinkage => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LTOVisibilityPublic => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LayoutVersion => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LockReturned => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LocksExcluded => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MIGServerRoutine => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSAllocator => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSInheritance => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSNoVTable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSP430Interrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSStruct => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSVtorDisp => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MaxFieldAlignment => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MayAlias => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MicroMips => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MinSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MinVectorWidth => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Mips16 => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MipsInterrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MipsLongCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MipsShortCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NSConsumesSelf => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NSReturnsAutoreleased => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NSReturnsNotRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Naked => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoAlias => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoCommon => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoDebug => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoDestroy => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoDuplicate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoInline => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoInstrumentFunction => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoMicroMips => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoMips16 => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoSanitize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoSpeculativeLoadHardening => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoSplitStack => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoStackProtector => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoThreadSafetyAnalysis => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoThrow => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoUniqueAddress => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NotTailCalled => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OMPAllocateDecl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OMPCaptureNoInit => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OMPDeclareTargetDecl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OMPThreadPrivateDecl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSConsumesThis => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSReturnsNotRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSReturnsRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnNonZero => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnZero => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCBridge => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCBridgeMutable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCBridgeRelated => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCException => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCExplicitProtocolImpl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCExternallyRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCIndependentClass => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCMethodFamily => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCNSObject => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCPreciseLifetime => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCRequiresPropertyDefs => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCRequiresSuper => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCReturnsInnerPointer => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCRootClass => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCSubclassingRestricted => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLIntelReqdSubGroupSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLKernel => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLUnrollHint => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OptimizeNone => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Override => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Ownership => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Packed => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ParamTypestate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PragmaClangBSSSection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PragmaClangDataSection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PragmaClangRodataSection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PragmaClangTextSection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PtGuardedBy => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PtGuardedVar => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Pure => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_RISCVInterrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Reinitializes => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReleaseCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReqdWorkGroupSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_RequireConstantInit => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_RequiresCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Restrict => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReturnTypestate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReturnsNonNull => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReturnsTwice => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ScopedLockable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Section => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SelectAny => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Sentinel => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SetTypestate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SharedTrylockFunction => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SpeculativeLoadHardening => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TLSModel => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Target => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TestTypestate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TransparentUnion => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TrivialABI => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TryAcquireCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TypeTagForDatatype => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TypeVisibility => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Unavailable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Uninitialized => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Unused => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Used => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Uuid => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_VecReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_VecTypeHint => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Visibility => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WarnUnused => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WarnUnusedResult => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Weak => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WeakImport => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WeakRef => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WebAssemblyImportModule => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WebAssemblyImportName => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WorkGroupSizeHint => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_X86ForceAlignArgPointer => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_XRayInstrument => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_XRayLogArgs => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AbiTag => new Attr(handle), + CX_AttrKind.CX_AttrKind_Alias => new Attr(handle), + CX_AttrKind.CX_AttrKind_AlignValue => new Attr(handle), + CX_AttrKind.CX_AttrKind_IFunc => new Attr(handle), + CX_AttrKind.CX_AttrKind_InitSeg => new Attr(handle), + CX_AttrKind.CX_AttrKind_LoopHint => new Attr(handle), + CX_AttrKind.CX_AttrKind_Mode => new Attr(handle), + CX_AttrKind.CX_AttrKind_NoEscape => new Attr(handle), + CX_AttrKind.CX_AttrKind_OMPCaptureKind => new Attr(handle), + CX_AttrKind.CX_AttrKind_OMPDeclareSimdDecl => new Attr(handle), + CX_AttrKind.CX_AttrKind_OMPReferencedVar => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCBoxable => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCClassStub => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCDesignatedInitializer => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCNonLazyClass => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCRuntimeName => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCRuntimeVisible => new Attr(handle), + CX_AttrKind.CX_AttrKind_OpenCLAccess => new Attr(handle), + CX_AttrKind.CX_AttrKind_Overloadable => new Attr(handle), + CX_AttrKind.CX_AttrKind_RenderScriptKernel => new Attr(handle), + CX_AttrKind.CX_AttrKind_Thread => new Attr(handle), + _ => new Attr(handle), + }; - case CXCursorKind.CXCursor_NSReturnsNotRetained: - case CXCursorKind.CXCursor_NSReturnsAutoreleased: - case CXCursorKind.CXCursor_NSConsumesSelf: - { - result = new InheritableAttr(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_NSConsumed: - { - result = new InheritableParamAttr(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_ObjCException: - case CXCursorKind.CXCursor_ObjCNSObject: - case CXCursorKind.CXCursor_ObjCIndependentClass: - case CXCursorKind.CXCursor_ObjCPreciseLifetime: - case CXCursorKind.CXCursor_ObjCReturnsInnerPointer: - case CXCursorKind.CXCursor_ObjCRequiresSuper: - case CXCursorKind.CXCursor_ObjCRootClass: - case CXCursorKind.CXCursor_ObjCSubclassingRestricted: - case CXCursorKind.CXCursor_ObjCExplicitProtocolImpl: - { - result = new InheritableAttr(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_ObjCDesignatedInitializer: - case CXCursorKind.CXCursor_ObjCRuntimeVisible: - case CXCursorKind.CXCursor_ObjCBoxable: - { - result = new Attr(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_FlagEnum: - case CXCursorKind.CXCursor_ConvergentAttr: - case CXCursorKind.CXCursor_WarnUnusedAttr: - case CXCursorKind.CXCursor_WarnUnusedResultAttr: - case CXCursorKind.CXCursor_AlignedAttr: - { - result = new InheritableAttr(handle, handle.Kind); - break; - } - - default: - { - Debug.WriteLine($"Unhandled attribute kind: {handle.KindSpelling}."); - result = new Attr(handle, handle.kind); - break; - } - } - - return result; - } + public CX_AttrKind Kind => Handle.AttrKind; } } diff --git a/sources/ClangSharp/Cursors/Attrs/InheritableAttr.cs b/sources/ClangSharp/Cursors/Attrs/InheritableAttr.cs index 1fff50e6..4902aca4 100644 --- a/sources/ClangSharp/Cursors/Attrs/InheritableAttr.cs +++ b/sources/ClangSharp/Cursors/Attrs/InheritableAttr.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class InheritableAttr : Attr { - internal InheritableAttr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + internal InheritableAttr(CXCursor handle) : base(handle) { + if ((CX_AttrKind.CX_AttrKind_LastInheritableAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstInheritableAttr)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Attrs/InheritableParamAttr.cs b/sources/ClangSharp/Cursors/Attrs/InheritableParamAttr.cs index 3d97116b..169333fa 100644 --- a/sources/ClangSharp/Cursors/Attrs/InheritableParamAttr.cs +++ b/sources/ClangSharp/Cursors/Attrs/InheritableParamAttr.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { - public sealed class InheritableParamAttr : InheritableAttr + public class InheritableParamAttr : InheritableAttr { - internal InheritableParamAttr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + internal InheritableParamAttr(CXCursor handle) : base(handle) { + if ((CX_AttrKind.CX_AttrKind_LastInheritableParamAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstInheritableParamAttr)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Attrs/ParameterABIAttr.cs b/sources/ClangSharp/Cursors/Attrs/ParameterABIAttr.cs new file mode 100644 index 00000000..ebc4ecda --- /dev/null +++ b/sources/ClangSharp/Cursors/Attrs/ParameterABIAttr.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using System; +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ParameterABIAttr : InheritableParamAttr + { + internal ParameterABIAttr(CXCursor handle) : base(handle) + { + if ((CX_AttrKind.CX_AttrKind_LastParameterABIAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstParameterABIAttr)) + { + throw new ArgumentException(nameof(handle)); + } + } + } +} diff --git a/sources/ClangSharp/Cursors/Attrs/StmtAttr.cs b/sources/ClangSharp/Cursors/Attrs/StmtAttr.cs new file mode 100644 index 00000000..a2bcf390 --- /dev/null +++ b/sources/ClangSharp/Cursors/Attrs/StmtAttr.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using System; +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class StmtAttr : Attr + { + internal StmtAttr(CXCursor handle) : base(handle) + { + if ((CX_AttrKind.CX_AttrKind_LastStmtAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstStmtAttr)) + { + throw new ArgumentException(nameof(handle)); + } + } + } +} diff --git a/sources/ClangSharp/Cursors/Attrs/TypeAttr.cs b/sources/ClangSharp/Cursors/Attrs/TypeAttr.cs new file mode 100644 index 00000000..1f53cb66 --- /dev/null +++ b/sources/ClangSharp/Cursors/Attrs/TypeAttr.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using System; +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class TypeAttr : Attr + { + internal TypeAttr(CXCursor handle) : base(handle) + { + if ((CX_AttrKind.CX_AttrKind_LastTypeAttr < handle.AttrKind) || (handle.AttrKind < CX_AttrKind.CX_AttrKind_FirstTypeAttr)) + { + throw new ArgumentException(nameof(handle)); + } + } + } +} diff --git a/sources/ClangSharp/Cursors/Cursor.cs b/sources/ClangSharp/Cursors/Cursor.cs index a35fc117..7f61a13b 100644 --- a/sources/ClangSharp/Cursors/Cursor.cs +++ b/sources/ClangSharp/Cursors/Cursor.cs @@ -12,9 +12,9 @@ public unsafe class Cursor : IEquatable private readonly Lazy> _cursorChildren; private readonly Lazy _translationUnit; - private protected Cursor(CXCursor handle, CXCursorKind expectedKind) + private protected Cursor(CXCursor handle, CXCursorKind expectedCursorKind) { - if (handle.kind != expectedKind) + if (handle.kind != expectedCursorKind) { throw new ArgumentException(nameof(handle)); } @@ -38,16 +38,16 @@ private protected Cursor(CXCursor handle, CXCursorKind expectedKind) public IReadOnlyList CursorChildren => _cursorChildren.Value; + public CXCursorKind CursorKind => Handle.Kind; + + public string CursorKindSpelling => Handle.KindSpelling.ToString(); + public Cursor CursorParent { get; private set; } public CXSourceRange Extent => Handle.Extent; public CXCursor Handle { get; } - public CXCursorKind Kind => Handle.Kind; - - public string KindSpelling => Handle.KindSpelling.ToString(); - public CXSourceLocation Location => Handle.Location; public string Spelling => Handle.Spelling.ToString(); @@ -62,7 +62,7 @@ internal static Cursor Create(CXCursor handle) { Cursor result; - if (handle.IsDeclaration) + if (handle.IsDeclaration || handle.IsTranslationUnit) { result = Decl.Create(handle); } @@ -70,18 +70,10 @@ internal static Cursor Create(CXCursor handle) { result = Ref.Create(handle); } - else if (handle.IsExpression) - { - result = Expr.Create(handle); - } - else if (handle.IsStatement) + else if (handle.IsExpression || handle.IsStatement) { result = Stmt.Create(handle); } - else if (handle.IsTranslationUnit) - { - result = new TranslationUnitDecl(handle); - } else if (handle.IsAttribute) { result = Attr.Create(handle); diff --git a/sources/ClangSharp/Cursors/Decls/AccessSpecDecl.cs b/sources/ClangSharp/Cursors/Decls/AccessSpecDecl.cs index 886a6677..a4f05265 100644 --- a/sources/ClangSharp/Cursors/Decls/AccessSpecDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/AccessSpecDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class AccessSpecDecl : Decl { - internal AccessSpecDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXAccessSpecifier) + internal AccessSpecDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXAccessSpecifier, CX_DeclKind.CX_DeclKind_AccessSpec) { } } diff --git a/sources/ClangSharp/Cursors/Decls/BindingDecl.cs b/sources/ClangSharp/Cursors/Decls/BindingDecl.cs new file mode 100644 index 00000000..04853fcd --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/BindingDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class BindingDecl : ValueDecl + { + internal BindingDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Binding) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/BlockDecl.cs b/sources/ClangSharp/Cursors/Decls/BlockDecl.cs new file mode 100644 index 00000000..efcbb93a --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/BlockDecl.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ClangSharp +{ + public sealed class BlockDecl : Decl, IDeclContext + { + private readonly Lazy> _decls; + + internal BlockDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Block) + { + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); + } + + public IReadOnlyList Decls => _decls.Value; + + public IDeclContext LexicalParent => LexicalDeclContext; + + public IDeclContext Parent => DeclContext; + } +} diff --git a/sources/ClangSharp/Cursors/Decls/BuiltinTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/BuiltinTemplateDecl.cs new file mode 100644 index 00000000..15bf8e68 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/BuiltinTemplateDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class BuiltinTemplateDecl : TemplateDecl + { + internal BuiltinTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_BuiltinTemplate) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs index 7b0ae760..f4ba0e91 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXConstructorDecl : CXXMethodDecl { - internal CXXConstructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Constructor) + internal CXXConstructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Constructor, CX_DeclKind.CX_DeclKind_CXXConstructor) { } diff --git a/sources/ClangSharp/Cursors/Decls/CXXConversionDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXConversionDecl.cs index 5d6a3ec3..7376a4ad 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXConversionDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXConversionDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXConversionDecl : CXXMethodDecl { - internal CXXConversionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConversionFunction) + internal CXXConversionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConversionFunction, CX_DeclKind.CX_DeclKind_CXXConversion) { } } diff --git a/sources/ClangSharp/Cursors/Decls/CXXDeductionGuideDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXDeductionGuideDecl.cs new file mode 100644 index 00000000..3cf9a5e5 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/CXXDeductionGuideDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXDeductionGuideDecl : FunctionDecl + { + internal CXXDeductionGuideDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_CXXDeductionGuide) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/CXXDestructorDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXDestructorDecl.cs index 9dd5c16f..0f58e376 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXDestructorDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXDestructorDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXDestructorDecl : CXXMethodDecl { - internal CXXDestructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Destructor) + internal CXXDestructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Destructor, CX_DeclKind.CX_DeclKind_CXXDestructor) { } } diff --git a/sources/ClangSharp/Cursors/Decls/CXXMethodDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXMethodDecl.cs index 211194f2..8534c9ad 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXMethodDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXMethodDecl.cs @@ -1,17 +1,22 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class CXXMethodDecl : FunctionDecl { - internal CXXMethodDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CXXMethod) + internal CXXMethodDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CXXMethod, CX_DeclKind.CX_DeclKind_CXXMethod) { } - private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastCXXMethod < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXMethod)) + { + throw new ArgumentException(nameof(handle)); + } } public bool IsConst => Handle.CXXMethod_IsConst; diff --git a/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs index 9ebbedd9..e2c493c3 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs @@ -16,8 +16,17 @@ public class CXXRecordDecl : RecordDecl private readonly Lazy> _methods; private readonly Lazy> _vbases; - internal CXXRecordDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + internal CXXRecordDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_CXXRecord) { + } + + private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if ((CX_DeclKind.CX_DeclKind_LastCXXRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXRecord)) + { + throw new ArgumentException(nameof(handle)); + } + _bases = new Lazy>(() => CursorChildren.OfType().ToList()); _ctors = new Lazy>(() => Methods.OfType().ToList()); _destructor = new Lazy(() => Methods.OfType().SingleOrDefault()); diff --git a/sources/ClangSharp/Cursors/Decls/CapturedDecl.cs b/sources/ClangSharp/Cursors/Decls/CapturedDecl.cs new file mode 100644 index 00000000..a56f2d6b --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/CapturedDecl.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ClangSharp +{ + public sealed class CapturedDecl : Decl, IDeclContext + { + private readonly Lazy> _decls; + + internal CapturedDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Captured) + { + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); + } + + public IReadOnlyList Decls => _decls.Value; + + public IDeclContext LexicalParent => LexicalDeclContext; + + public IDeclContext Parent => DeclContext; + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs new file mode 100644 index 00000000..7da6b766 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ClassScopeFunctionSpecializationDecl : Decl + { + internal ClassScopeFunctionSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ClassTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/ClassTemplateDecl.cs index 984d8200..22ac3384 100644 --- a/sources/ClangSharp/Cursors/Decls/ClassTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ClassTemplateDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ClassTemplateDecl : RedeclarableTemplateDecl { - internal ClassTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplate) + internal ClassTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplate, CX_DeclKind.CX_DeclKind_ClassTemplate) { } } diff --git a/sources/ClangSharp/Cursors/Decls/ClassTemplatePartialSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/ClassTemplatePartialSpecializationDecl.cs index 411181fe..e3d82dc1 100644 --- a/sources/ClangSharp/Cursors/Decls/ClassTemplatePartialSpecializationDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ClassTemplatePartialSpecializationDecl.cs @@ -11,7 +11,7 @@ public sealed class ClassTemplatePartialSpecializationDecl : ClassTemplateSpecia { private readonly Lazy> _templateParameters; - internal ClassTemplatePartialSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplatePartialSpecialization) + internal ClassTemplatePartialSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplatePartialSpecialization, CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization) { _templateParameters = new Lazy>(() => CursorChildren.Where((cursor) => (cursor is TemplateTypeParmDecl) || (cursor is NonTypeTemplateParmDecl) || (cursor is TemplateTemplateParmDecl)).Cast().ToList()); } diff --git a/sources/ClangSharp/Cursors/Decls/ClassTemplateSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/ClassTemplateSpecializationDecl.cs index 0bf1c2c6..d6714c24 100644 --- a/sources/ClangSharp/Cursors/Decls/ClassTemplateSpecializationDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ClassTemplateSpecializationDecl.cs @@ -2,18 +2,45 @@ using ClangSharp.Interop; using System; +using System.Collections.Generic; namespace ClangSharp { public class ClassTemplateSpecializationDecl : CXXRecordDecl { private readonly Lazy _specializedTemplate; + private readonly Lazy> _templateArgs; - private protected ClassTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + internal ClassTemplateSpecializationDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization) { + } + + private protected ClassTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if ((CX_DeclKind.CX_DeclKind_LastClassTemplateSpecialization < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstClassTemplateSpecialization)) + { + throw new ArgumentException(nameof(handle)); + } + _specializedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); + _templateArgs = new Lazy>(() => { + var templateArgsSize = TemplateArgsSize; + var templateArgs = new List(templateArgsSize); + + for (var index = 0; index < templateArgsSize; index++) + { + var templateArg = TypeForDecl.Handle.GetTemplateArgumentAsType((uint)index); + templateArgs.Add(TranslationUnit.GetOrCreate(templateArg)); + } + + return templateArgs; + }); } + public IReadOnlyList TemplateArgs => _templateArgs.Value; + + public int TemplateArgsSize => TypeForDecl.Handle.NumTemplateArguments; + public ClassTemplateDecl SpecializedTemplate => _specializedTemplate.Value; } } diff --git a/sources/ClangSharp/Cursors/Decls/ConceptDecl.cs b/sources/ClangSharp/Cursors/Decls/ConceptDecl.cs new file mode 100644 index 00000000..b58a8b81 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/ConceptDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ConceptDecl : TemplateDecl, IMergeable + { + internal ConceptDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Concept) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ConstructorUsingShadowDecl.cs b/sources/ClangSharp/Cursors/Decls/ConstructorUsingShadowDecl.cs new file mode 100644 index 00000000..c30917d3 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/ConstructorUsingShadowDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ConstructorUsingShadowDecl : UsingShadowDecl + { + internal ConstructorUsingShadowDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ConstructorUsingShadow) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/Decl.cs b/sources/ClangSharp/Cursors/Decls/Decl.cs index e2e0e984..963fe466 100644 --- a/sources/ClangSharp/Cursors/Decls/Decl.cs +++ b/sources/ClangSharp/Cursors/Decls/Decl.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using ClangSharp.Interop; @@ -16,12 +15,17 @@ public class Decl : Cursor private readonly Lazy _lexicalDeclContext; private readonly Lazy _translationUnitDecl; - private protected Decl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected Decl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind) { + if ((handle.DeclKind == CX_DeclKind.CX_DeclKind_Invalid) || (handle.DeclKind != expectedDeclKind)) + { + throw new ArgumentException(nameof(handle)); + } + _attrs = new Lazy>(() => CursorChildren.OfType().ToList()); _canonicalDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CanonicalCursor)); - _declContext = new Lazy(() => Create(Handle.SemanticParent) as IDeclContext); - _lexicalDeclContext = new Lazy(() => Create(Handle.LexicalParent) as IDeclContext); + _declContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SemanticParent) as IDeclContext); + _lexicalDeclContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LexicalParent) as IDeclContext); _translationUnitDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TranslationUnit.Cursor)); } @@ -41,270 +45,92 @@ private protected Decl(CXCursor handle, CXCursorKind expectedKind) : base(handle public bool IsInvalidDecl => Handle.IsInvalidDeclaration; + public CX_DeclKind Kind => Handle.DeclKind; + public IDeclContext LexicalDeclContext => _lexicalDeclContext.Value; public TranslationUnitDecl TranslationUnitDecl => _translationUnitDecl.Value; - internal static new Decl Create(CXCursor handle) + internal static new Decl Create(CXCursor handle) => handle.DeclKind switch { - Decl result; - - switch (handle.Kind) - { - case CXCursorKind.CXCursor_UnexposedDecl: - { - result = new Decl(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_StructDecl: - case CXCursorKind.CXCursor_UnionDecl: - case CXCursorKind.CXCursor_ClassDecl: - { - if (handle.Language == CXLanguageKind.CXLanguage_CPlusPlus) - { - result = new CXXRecordDecl(handle, handle.Kind); - } - else - { - result = new RecordDecl(handle, handle.Kind); - } - break; - } - - case CXCursorKind.CXCursor_EnumDecl: - { - result = new EnumDecl(handle); - break; - } - - case CXCursorKind.CXCursor_FieldDecl: - { - result = new FieldDecl(handle); - break; - } - - case CXCursorKind.CXCursor_EnumConstantDecl: - { - result = new EnumConstantDecl(handle); - break; - } - - case CXCursorKind.CXCursor_FunctionDecl: - { - result = new FunctionDecl(handle); - break; - } - - case CXCursorKind.CXCursor_VarDecl: - { - result = new VarDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ParmDecl: - { - result = new ParmVarDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCInterfaceDecl: - { - result = new ObjCInterfaceDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCCategoryDecl: - { - result = new ObjCCategoryDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCProtocolDecl: - { - result = new ObjCProtocolDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCPropertyDecl: - { - result = new ObjCPropertyDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCIvarDecl: - { - result = new ObjCIvarDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCInstanceMethodDecl: - case CXCursorKind.CXCursor_ObjCClassMethodDecl: - { - result = new ObjCMethodDecl(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_ObjCImplementationDecl: - { - result = new ObjCImplementationDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCCategoryImplDecl: - { - result = new ObjCCategoryImplDecl(handle); - break; - } - - case CXCursorKind.CXCursor_TypedefDecl: - { - result = new TypedefDecl(handle); - break; - } - - case CXCursorKind.CXCursor_CXXMethod: - { - result = new CXXMethodDecl(handle); - break; - } - - case CXCursorKind.CXCursor_Namespace: - { - result = new NamespaceDecl(handle); - break; - } - - case CXCursorKind.CXCursor_LinkageSpec: - { - result = new LinkageSpecDecl(handle); - break; - } - - case CXCursorKind.CXCursor_Constructor: - { - result = new CXXConstructorDecl(handle); - break; - } - - case CXCursorKind.CXCursor_Destructor: - { - result = new CXXDestructorDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ConversionFunction: - { - result = new CXXConversionDecl(handle); - break; - } - - case CXCursorKind.CXCursor_TemplateTypeParameter: - { - result = new TemplateTypeParmDecl(handle); - break; - } - - case CXCursorKind.CXCursor_NonTypeTemplateParameter: - { - result = new NonTypeTemplateParmDecl(handle); - break; - } - - case CXCursorKind.CXCursor_TemplateTemplateParameter: - { - result = new TemplateTemplateParmDecl(handle); - break; - } - - case CXCursorKind.CXCursor_FunctionTemplate: - { - result = new FunctionTemplateDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ClassTemplate: - { - result = new ClassTemplateDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ClassTemplatePartialSpecialization: - { - result = new ClassTemplatePartialSpecializationDecl(handle); - break; - } - - case CXCursorKind.CXCursor_NamespaceAlias: - { - result = new NamespaceAliasDecl(handle); - break; - } - - case CXCursorKind.CXCursor_UsingDirective: - { - result = new UsingDirectiveDecl(handle); - break; - } - - case CXCursorKind.CXCursor_UsingDeclaration: - { - result = new UsingDecl(handle); - break; - } - - case CXCursorKind.CXCursor_TypeAliasDecl: - { - result = new TypeAliasDecl(handle); - break; - } - - case CXCursorKind.CXCursor_CXXAccessSpecifier: - { - result = new AccessSpecDecl(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCSynthesizeDecl: - case CXCursorKind.CXCursor_ObjCDynamicDecl: - { - result = new ObjCPropertyImplDecl(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_ModuleImportDecl: - { - result = new ImportDecl(handle); - break; - } - - case CXCursorKind.CXCursor_TypeAliasTemplateDecl: - { - result = new TypeAliasTemplateDecl(handle); - break; - } - - case CXCursorKind.CXCursor_StaticAssert: - { - result = new StaticAssertDecl(handle); - break; - } - - case CXCursorKind.CXCursor_FriendDecl: - { - result = new FriendDecl(handle); - break; - } - - default: - { - Debug.WriteLine($"Unhandled declaration kind: {handle.KindSpelling}."); - result = new Decl(handle, handle.Kind); - break; - } - } - - return result; - } + CX_DeclKind.CX_DeclKind_AccessSpec => new AccessSpecDecl(handle), + CX_DeclKind.CX_DeclKind_Block => new BlockDecl(handle), + CX_DeclKind.CX_DeclKind_Captured => new CapturedDecl(handle), + CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization => new ClassScopeFunctionSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_Empty => new EmptyDecl(handle), + CX_DeclKind.CX_DeclKind_Export => new ExportDecl(handle), + CX_DeclKind.CX_DeclKind_ExternCContext => new ExternCContextDecl(handle), + CX_DeclKind.CX_DeclKind_FileScopeAsm => new FileScopeAsmDecl(handle), + CX_DeclKind.CX_DeclKind_Friend => new FriendDecl(handle), + CX_DeclKind.CX_DeclKind_FriendTemplate => new FriendTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_Import => new ImportDecl(handle), + CX_DeclKind.CX_DeclKind_LinkageSpec => new LinkageSpecDecl(handle), + CX_DeclKind.CX_DeclKind_Label => new LabelDecl(handle), + CX_DeclKind.CX_DeclKind_Namespace => new NamespaceDecl(handle), + CX_DeclKind.CX_DeclKind_NamespaceAlias => new NamespaceAliasDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias => new ObjCCompatibleAliasDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCCategory => new ObjCCategoryDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCCategoryImpl => new ObjCCategoryImplDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCImplementation => new ObjCImplementationDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCInterface => new ObjCInterfaceDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCProtocol => new ObjCPropertyDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCMethod => new ObjCMethodDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCProperty => new ObjCPropertyDecl(handle), + CX_DeclKind.CX_DeclKind_BuiltinTemplate => new BuiltinTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_Concept => new ConceptDecl(handle), + CX_DeclKind.CX_DeclKind_ClassTemplate => new ClassTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_FunctionTemplate => new FunctionTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_TypeAliasTemplate => new TypeAliasTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_VarTemplate => new VarTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_TemplateTemplateParm => new TemplateTemplateParmDecl(handle), + CX_DeclKind.CX_DeclKind_Enum => new EnumDecl(handle), + CX_DeclKind.CX_DeclKind_Record => new RecordDecl(handle), + CX_DeclKind.CX_DeclKind_CXXRecord => new CXXRecordDecl(handle), + CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization => new ClassTemplateSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization => new ClassTemplatePartialSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_TemplateTypeParm => new TemplateTypeParmDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCTypeParam => new ObjCTypeParamDecl(handle), + CX_DeclKind.CX_DeclKind_TypeAlias => new TypeAliasDecl(handle), + CX_DeclKind.CX_DeclKind_Typedef => new TypedefDecl(handle), + CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename => new UnresolvedUsingTypenameDecl(handle), + CX_DeclKind.CX_DeclKind_Using => new UsingDecl(handle), + CX_DeclKind.CX_DeclKind_UsingDirective => new UsingDirectiveDecl(handle), + CX_DeclKind.CX_DeclKind_UsingPack => new UsingPackDecl(handle), + CX_DeclKind.CX_DeclKind_UsingShadow => new UsingShadowDecl(handle), + CX_DeclKind.CX_DeclKind_ConstructorUsingShadow => new ConstructorUsingShadowDecl(handle), + CX_DeclKind.CX_DeclKind_Binding => new BindingDecl(handle), + CX_DeclKind.CX_DeclKind_Field => new FieldDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCAtDefsField => new ObjCAtDefsFieldDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCIvar => new ObjCIvarDecl(handle), + CX_DeclKind.CX_DeclKind_Function => new FunctionDecl(handle), + CX_DeclKind.CX_DeclKind_CXXDeductionGuide => new CXXDeductionGuideDecl(handle), + CX_DeclKind.CX_DeclKind_CXXMethod => new CXXMethodDecl(handle), + CX_DeclKind.CX_DeclKind_CXXConstructor => new CXXConstructorDecl(handle), + CX_DeclKind.CX_DeclKind_CXXConversion => new CXXConversionDecl(handle), + CX_DeclKind.CX_DeclKind_CXXDestructor => new CXXDestructorDecl(handle), + CX_DeclKind.CX_DeclKind_MSProperty => new MSPropertyDecl(handle), + CX_DeclKind.CX_DeclKind_NonTypeTemplateParm => new NonTypeTemplateParmDecl(handle), + CX_DeclKind.CX_DeclKind_Var => new VarDecl(handle), + CX_DeclKind.CX_DeclKind_Decomposition => new DecompositionDecl(handle), + CX_DeclKind.CX_DeclKind_ImplicitParam => new ImplicitParamDecl(handle), + CX_DeclKind.CX_DeclKind_OMPCapturedExpr => new OMPCapturedExprDecl(handle), + CX_DeclKind.CX_DeclKind_ParmVar => new ParmVarDecl(handle), + CX_DeclKind.CX_DeclKind_VarTemplateSpecialization => new VarTemplateSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization => new VarTemplatePartialSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_EnumConstant => new EnumConstantDecl(handle), + CX_DeclKind.CX_DeclKind_IndirectField => new IndirectFieldDecl(handle), + CX_DeclKind.CX_DeclKind_OMPDeclareMapper => new OMPDeclareMapperDecl(handle), + CX_DeclKind.CX_DeclKind_OMPDeclareReduction => new OMPDeclareReductionDecl(handle), + CX_DeclKind.CX_DeclKind_UnresolvedUsingValue => new UnresolvedUsingValueDecl(handle), + CX_DeclKind.CX_DeclKind_OMPAllocate => new OMPAllocateDecl(handle), + CX_DeclKind.CX_DeclKind_OMPRequires => new OMPRequiresDecl(handle), + CX_DeclKind.CX_DeclKind_OMPThreadPrivate => new OMPThreadPrivateDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCPropertyImpl => new ObjCPropertyImplDecl(handle), + CX_DeclKind.CX_DeclKind_PragmaComment => new PragmaCommentDecl(handle), + CX_DeclKind.CX_DeclKind_PragmaDetectMismatch => new PragmaDetectMismatchDecl(handle), + CX_DeclKind.CX_DeclKind_StaticAssert => new StaticAssertDecl(handle), + CX_DeclKind.CX_DeclKind_TranslationUnit => new TranslationUnitDecl(handle), + _ => new Decl(handle, handle.kind, handle.DeclKind), + }; } } diff --git a/sources/ClangSharp/Cursors/Decls/DeclaratorDecl.cs b/sources/ClangSharp/Cursors/Decls/DeclaratorDecl.cs index 35fc055f..d8c235ed 100644 --- a/sources/ClangSharp/Cursors/Decls/DeclaratorDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/DeclaratorDecl.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class DeclaratorDecl : ValueDecl { - private protected DeclaratorDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected DeclaratorDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastDeclarator < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstDeclarator)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Decls/DecompositionDecl.cs b/sources/ClangSharp/Cursors/Decls/DecompositionDecl.cs new file mode 100644 index 00000000..9cdee17d --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/DecompositionDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DecompositionDecl : VarDecl + { + internal DecompositionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Decomposition) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/EmptyDecl.cs b/sources/ClangSharp/Cursors/Decls/EmptyDecl.cs new file mode 100644 index 00000000..23ba1241 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/EmptyDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class EmptyDecl : Decl + { + internal EmptyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Empty) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/EnumConstantDecl.cs b/sources/ClangSharp/Cursors/Decls/EnumConstantDecl.cs index 0de0ed7f..6506c32b 100644 --- a/sources/ClangSharp/Cursors/Decls/EnumConstantDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/EnumConstantDecl.cs @@ -10,7 +10,7 @@ public sealed class EnumConstantDecl : ValueDecl, IMergeable { private readonly Lazy _initExpr; - internal EnumConstantDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumConstantDecl) + internal EnumConstantDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumConstantDecl, CX_DeclKind.CX_DeclKind_EnumConstant) { _initExpr = new Lazy(() => CursorChildren.OfType().SingleOrDefault()); } diff --git a/sources/ClangSharp/Cursors/Decls/EnumDecl.cs b/sources/ClangSharp/Cursors/Decls/EnumDecl.cs index cd28f0af..362b60e3 100644 --- a/sources/ClangSharp/Cursors/Decls/EnumDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/EnumDecl.cs @@ -12,7 +12,7 @@ public sealed class EnumDecl : TagDecl private readonly Lazy> _enumerators; private readonly Lazy _integerType; - internal EnumDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumDecl) + internal EnumDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumDecl, CX_DeclKind.CX_DeclKind_Enum) { _enumerators = new Lazy>(() => Decls.OfType().ToList()); _integerType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.EnumDecl_IntegerType)); diff --git a/sources/ClangSharp/Cursors/Decls/ExportDecl.cs b/sources/ClangSharp/Cursors/Decls/ExportDecl.cs new file mode 100644 index 00000000..de98ac79 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/ExportDecl.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ClangSharp +{ + public sealed class ExportDecl : Decl, IDeclContext + { + private readonly Lazy> _decls; + + internal ExportDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Export) + { + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); + } + + public IReadOnlyList Decls => _decls.Value; + + public IDeclContext LexicalParent => LexicalDeclContext; + + public IDeclContext Parent => DeclContext; + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ExternCContextDecl.cs b/sources/ClangSharp/Cursors/Decls/ExternCContextDecl.cs new file mode 100644 index 00000000..2da9b6cc --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/ExternCContextDecl.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ClangSharp +{ + public sealed class ExternCContextDecl : Decl, IDeclContext + { + private readonly Lazy> _decls; + + internal ExternCContextDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ExternCContext) + { + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); + } + + public IReadOnlyList Decls => _decls.Value; + + public IDeclContext LexicalParent => LexicalDeclContext; + + public IDeclContext Parent => DeclContext; + } +} diff --git a/sources/ClangSharp/Cursors/Decls/FieldDecl.cs b/sources/ClangSharp/Cursors/Decls/FieldDecl.cs index 914c756e..239859f3 100644 --- a/sources/ClangSharp/Cursors/Decls/FieldDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FieldDecl.cs @@ -1,17 +1,22 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class FieldDecl : DeclaratorDecl, IMergeable { - internal FieldDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_FieldDecl) + internal FieldDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_FieldDecl, CX_DeclKind.CX_DeclKind_Field) { } - private protected FieldDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected FieldDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastField < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstField)) + { + throw new ArgumentException(nameof(handle)); + } } public int BitWidthValue => Handle.FieldDeclBitWidth; diff --git a/sources/ClangSharp/Cursors/Decls/FileScopeAsmDecl.cs b/sources/ClangSharp/Cursors/Decls/FileScopeAsmDecl.cs new file mode 100644 index 00000000..d89d557a --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/FileScopeAsmDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class FileScopeAsmDecl : Decl + { + internal FileScopeAsmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_FileScopeAsm) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/FriendDecl.cs b/sources/ClangSharp/Cursors/Decls/FriendDecl.cs index 9cbfeccb..d4e21533 100644 --- a/sources/ClangSharp/Cursors/Decls/FriendDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FriendDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class FriendDecl : Decl { - internal FriendDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FriendDecl) + internal FriendDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FriendDecl, CX_DeclKind.CX_DeclKind_Friend) { } } diff --git a/sources/ClangSharp/Cursors/Decls/FriendTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/FriendTemplateDecl.cs new file mode 100644 index 00000000..dd94f154 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/FriendTemplateDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class FriendTemplateDecl : Decl + { + internal FriendTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_FriendTemplate) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs b/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs index baed035e..acb7eebc 100644 --- a/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs @@ -14,12 +14,17 @@ public class FunctionDecl : DeclaratorDecl, IDeclContext, IRedeclarable> _parameters; private readonly Lazy _returnType; - internal FunctionDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_FunctionDecl) + internal FunctionDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_FunctionDecl, CX_DeclKind.CX_DeclKind_Function) { } - private protected FunctionDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected FunctionDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastFunction < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstFunction)) + { + throw new ArgumentException(nameof(handle)); + } + _body = new Lazy(() => CursorChildren.OfType().SingleOrDefault()); _decls = new Lazy>(() => CursorChildren.OfType().ToList()); _parameters = new Lazy>(() => Decls.OfType().ToList()); diff --git a/sources/ClangSharp/Cursors/Decls/FunctionTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/FunctionTemplateDecl.cs index 5d48a615..184d32f2 100644 --- a/sources/ClangSharp/Cursors/Decls/FunctionTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FunctionTemplateDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class FunctionTemplateDecl : RedeclarableTemplateDecl { - internal FunctionTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FunctionTemplate) + internal FunctionTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FunctionTemplate, CX_DeclKind.CX_DeclKind_FunctionTemplate) { } } diff --git a/sources/ClangSharp/Cursors/Decls/ImplicitParamDecl.cs b/sources/ClangSharp/Cursors/Decls/ImplicitParamDecl.cs new file mode 100644 index 00000000..28e9414a --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/ImplicitParamDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ImplicitParamDecl : VarDecl + { + internal ImplicitParamDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ImplicitParam) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ImportDecl.cs b/sources/ClangSharp/Cursors/Decls/ImportDecl.cs index c80bc658..442514e1 100644 --- a/sources/ClangSharp/Cursors/Decls/ImportDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ImportDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ImportDecl : Decl { - internal ImportDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ModuleImportDecl) + internal ImportDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ModuleImportDecl, CX_DeclKind.CX_DeclKind_Import) { } } diff --git a/sources/ClangSharp/Cursors/Decls/IndirectFieldDecl.cs b/sources/ClangSharp/Cursors/Decls/IndirectFieldDecl.cs new file mode 100644 index 00000000..0779f4b6 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/IndirectFieldDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class IndirectFieldDecl : ValueDecl, IMergeable + { + internal IndirectFieldDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_IndirectField) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/LabelDecl.cs b/sources/ClangSharp/Cursors/Decls/LabelDecl.cs new file mode 100644 index 00000000..e9c5bede --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/LabelDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class LabelDecl : NamedDecl + { + internal LabelDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Label) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs b/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs index 99c42899..be162098 100644 --- a/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs @@ -11,9 +11,14 @@ public sealed class LinkageSpecDecl : Decl, IDeclContext { private readonly Lazy> _decls; - internal LinkageSpecDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LinkageSpec) + internal LinkageSpecDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_LinkageSpec) { - _decls = new Lazy>(() => CursorChildren.Where((cursor) => cursor is Decl).Cast().ToList()); + if ((handle.Kind != CXCursorKind.CXCursor_LinkageSpec) && (handle.Kind != CXCursorKind.CXCursor_UnexposedDecl)) + { + throw new ArgumentException(nameof(handle)); + } + + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); } public IReadOnlyList Decls => _decls.Value; diff --git a/sources/ClangSharp/Cursors/Decls/MSPropertyDecl.cs b/sources/ClangSharp/Cursors/Decls/MSPropertyDecl.cs new file mode 100644 index 00000000..7039b8c6 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/MSPropertyDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class MSPropertyDecl : DeclaratorDecl + { + internal MSPropertyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_MSProperty) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/NamedDecl.cs b/sources/ClangSharp/Cursors/Decls/NamedDecl.cs index ef1d7015..530b94f9 100644 --- a/sources/ClangSharp/Cursors/Decls/NamedDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/NamedDecl.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class NamedDecl : Decl { - private protected NamedDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected NamedDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastNamed < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstNamed)) + { + throw new ArgumentException(nameof(handle)); + } } public CXLinkageKind LinkageInternal => Handle.Linkage; diff --git a/sources/ClangSharp/Cursors/Decls/NamespaceAliasDecl.cs b/sources/ClangSharp/Cursors/Decls/NamespaceAliasDecl.cs index c52c2f23..564d26ac 100644 --- a/sources/ClangSharp/Cursors/Decls/NamespaceAliasDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/NamespaceAliasDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class NamespaceAliasDecl : NamedDecl, IRedeclarable { - internal NamespaceAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NamespaceAlias) + internal NamespaceAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NamespaceAlias, CX_DeclKind.CX_DeclKind_NamespaceAlias) { } } diff --git a/sources/ClangSharp/Cursors/Decls/NamespaceDecl.cs b/sources/ClangSharp/Cursors/Decls/NamespaceDecl.cs index 628846e7..979d1a21 100644 --- a/sources/ClangSharp/Cursors/Decls/NamespaceDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/NamespaceDecl.cs @@ -11,7 +11,7 @@ public sealed class NamespaceDecl : NamedDecl, IDeclContext, IRedeclarable> _decls; - internal NamespaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Namespace) + internal NamespaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Namespace, CX_DeclKind.CX_DeclKind_Namespace) { _decls = new Lazy>(() => CursorChildren.OfType().ToList()); } diff --git a/sources/ClangSharp/Cursors/Decls/NonTypeTemplateParmDecl.cs b/sources/ClangSharp/Cursors/Decls/NonTypeTemplateParmDecl.cs index ffc3fc32..1e1e93f3 100644 --- a/sources/ClangSharp/Cursors/Decls/NonTypeTemplateParmDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/NonTypeTemplateParmDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class NonTypeTemplateParmDecl : DeclaratorDecl, ITemplateParmPosition { - internal NonTypeTemplateParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NonTypeTemplateParameter) + internal NonTypeTemplateParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NonTypeTemplateParameter, CX_DeclKind.CX_DeclKind_NonTypeTemplateParm) { } } diff --git a/sources/ClangSharp/Cursors/Decls/OMPAllocateDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPAllocateDecl.cs new file mode 100644 index 00000000..da48b56c --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/OMPAllocateDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class OMPAllocateDecl : Decl + { + internal OMPAllocateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPAllocate) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/OMPCapturedExprDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPCapturedExprDecl.cs new file mode 100644 index 00000000..9c80e981 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/OMPCapturedExprDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class OMPCapturedExprDecl : VarDecl + { + internal OMPCapturedExprDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPCapturedExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/OMPDeclareMapperDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPDeclareMapperDecl.cs new file mode 100644 index 00000000..117179f5 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/OMPDeclareMapperDecl.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ClangSharp +{ + public sealed class OMPDeclareMapperDecl : ValueDecl, IDeclContext + { + private readonly Lazy> _decls; + + internal OMPDeclareMapperDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPDeclareMapper) + { + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); + } + + public IReadOnlyList Decls => _decls.Value; + + public IDeclContext LexicalParent => LexicalDeclContext; + + public IDeclContext Parent => DeclContext; + } +} diff --git a/sources/ClangSharp/Cursors/Decls/OMPDeclareReductionDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPDeclareReductionDecl.cs new file mode 100644 index 00000000..9e206fb9 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/OMPDeclareReductionDecl.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ClangSharp +{ + public sealed class OMPDeclareReductionDecl : ValueDecl, IDeclContext + { + private readonly Lazy> _decls; + + internal OMPDeclareReductionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPDeclareReduction) + { + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); + } + + public IReadOnlyList Decls => _decls.Value; + + public IDeclContext LexicalParent => LexicalDeclContext; + + public IDeclContext Parent => DeclContext; + } +} diff --git a/sources/ClangSharp/Cursors/Decls/OMPRequiresDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPRequiresDecl.cs new file mode 100644 index 00000000..3e675b90 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/OMPRequiresDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class OMPRequiresDecl : Decl + { + internal OMPRequiresDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPRequires) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/OMPThreadPrivateDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPThreadPrivateDecl.cs new file mode 100644 index 00000000..f0c3f8f7 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/OMPThreadPrivateDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class OMPThreadPrivateDecl : Decl + { + internal OMPThreadPrivateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPThreadPrivate) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ObjCAtDefsFieldDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCAtDefsFieldDecl.cs new file mode 100644 index 00000000..8e4584dd --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/ObjCAtDefsFieldDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCAtDefsFieldDecl : FieldDecl + { + internal ObjCAtDefsFieldDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ObjCAtDefsField) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ObjCCategoryDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCCategoryDecl.cs index d8930878..a08c8338 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCCategoryDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCCategoryDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCCategoryDecl : ObjCContainerDecl { - internal ObjCCategoryDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCCategoryDecl) + internal ObjCCategoryDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCCategoryDecl, CX_DeclKind.CX_DeclKind_ObjCCategory) { } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCCategoryImplDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCCategoryImplDecl.cs index 59b850ec..943b6a71 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCCategoryImplDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCCategoryImplDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCCategoryImplDecl : ObjCImplDecl { - internal ObjCCategoryImplDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCCategoryImplDecl) + internal ObjCCategoryImplDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCCategoryImplDecl, CX_DeclKind.CX_DeclKind_ObjCCategoryImpl) { } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCCompatibleAliasDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCCompatibleAliasDecl.cs new file mode 100644 index 00000000..0ffc18eb --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/ObjCCompatibleAliasDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCCompatibleAliasDecl : NamedDecl + { + internal ObjCCompatibleAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ObjCContainerDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCContainerDecl.cs index a614f482..9bd63f7e 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCContainerDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCContainerDecl.cs @@ -11,9 +11,14 @@ public class ObjCContainerDecl : NamedDecl, IDeclContext { private readonly Lazy> _decls; - private protected ObjCContainerDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected ObjCContainerDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { - _decls = new Lazy>(() => CursorChildren.Where((cursor) => cursor is Decl).Cast().ToList()); + if ((CX_DeclKind.CX_DeclKind_LastObjCContainer < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstObjCContainer)) + { + throw new ArgumentException(nameof(handle)); + } + + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); } public IReadOnlyList Decls => _decls.Value; diff --git a/sources/ClangSharp/Cursors/Decls/ObjCImplDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCImplDecl.cs index 5857898d..f3bc9eb4 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCImplDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCImplDecl.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class ObjCImplDecl : ObjCContainerDecl { - private protected ObjCImplDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected ObjCImplDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastObjCImpl < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstObjCImpl)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCImplementationDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCImplementationDecl.cs index 5e6d4cb2..9a94a099 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCImplementationDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCImplementationDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCImplementationDecl : ObjCImplDecl { - internal ObjCImplementationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCImplementationDecl) + internal ObjCImplementationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCImplementationDecl, CX_DeclKind.CX_DeclKind_ObjCImplementation) { } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCInterfaceDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCInterfaceDecl.cs index 4570a5dd..a8c54732 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCInterfaceDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCInterfaceDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCInterfaceDecl : ObjCContainerDecl, IRedeclarable { - internal ObjCInterfaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCInterfaceDecl) + internal ObjCInterfaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCInterfaceDecl, CX_DeclKind.CX_DeclKind_ObjCInterface) { } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCIvarDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCIvarDecl.cs index 65ba99f5..4573bb0c 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCIvarDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCIvarDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCIvarDecl : FieldDecl { - internal ObjCIvarDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCIvarDecl) + internal ObjCIvarDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCIvarDecl, CX_DeclKind.CX_DeclKind_ObjCIvar) { } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCMethodDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCMethodDecl.cs index 563956d0..b6f44d5b 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCMethodDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCMethodDecl.cs @@ -11,16 +11,21 @@ public sealed class ObjCMethodDecl : NamedDecl, IDeclContext { private readonly Lazy> _decls; - internal ObjCMethodDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + internal ObjCMethodDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ObjCMethod) { - _decls = new Lazy>(() => CursorChildren.Where((cursor) => cursor is Decl).Cast().ToList()); + if ((handle.Kind != CXCursorKind.CXCursor_ObjCInstanceMethodDecl) && (handle.Kind != CXCursorKind.CXCursor_ObjCClassMethodDecl)) + { + throw new ArgumentException(nameof(handle)); + } + + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); } public IReadOnlyList Decls => _decls.Value; - public bool IsClassMethod() => Kind == CXCursorKind.CXCursor_ObjCClassMethodDecl; + public bool IsClassMethod() => CursorKind == CXCursorKind.CXCursor_ObjCClassMethodDecl; - public bool IsInstanceMethod() => Kind == CXCursorKind.CXCursor_ObjCInstanceMethodDecl; + public bool IsInstanceMethod() => CursorKind == CXCursorKind.CXCursor_ObjCInstanceMethodDecl; public IDeclContext LexicalParent => LexicalDeclContext; diff --git a/sources/ClangSharp/Cursors/Decls/ObjCPropertyDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCPropertyDecl.cs index 74887544..b8afcd29 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCPropertyDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCPropertyDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCPropertyDecl : NamedDecl { - internal ObjCPropertyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCPropertyDecl) + internal ObjCPropertyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCPropertyDecl, CX_DeclKind.CX_DeclKind_ObjCProperty) { } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCPropertyImplDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCPropertyImplDecl.cs index b6e3136a..990362d5 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCPropertyImplDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCPropertyImplDecl.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public sealed class ObjCPropertyImplDecl : Decl { - internal ObjCPropertyImplDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + internal ObjCPropertyImplDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ObjCPropertyImpl) { + if ((handle.Kind != CXCursorKind.CXCursor_ObjCSynthesizeDecl) && (handle.Kind != CXCursorKind.CXCursor_ObjCDynamicDecl)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCProtocolDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCProtocolDecl.cs index 8961ef2e..d95cd468 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCProtocolDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCProtocolDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCProtocolDecl : ObjCContainerDecl, IRedeclarable { - internal ObjCProtocolDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCProtocolDecl) + internal ObjCProtocolDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCProtocolDecl, CX_DeclKind.CX_DeclKind_ObjCProtocol) { } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCTypeParamDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCTypeParamDecl.cs new file mode 100644 index 00000000..6d66f972 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/ObjCTypeParamDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCTypeParamDecl : TypedefNameDecl + { + internal ObjCTypeParamDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ObjCTypeParam) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs b/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs index 9bc9e28f..ff180188 100644 --- a/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ParmVarDecl : VarDecl { - internal ParmVarDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ParmDecl) + internal ParmVarDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ParmDecl, CX_DeclKind.CX_DeclKind_ParmVar) { } } diff --git a/sources/ClangSharp/Cursors/Decls/PragmaCommentDecl.cs b/sources/ClangSharp/Cursors/Decls/PragmaCommentDecl.cs new file mode 100644 index 00000000..464b7fd4 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/PragmaCommentDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class PragmaCommentDecl : Decl + { + internal PragmaCommentDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_PragmaComment) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/PragmaDetectMismatchDecl.cs b/sources/ClangSharp/Cursors/Decls/PragmaDetectMismatchDecl.cs new file mode 100644 index 00000000..64912fd9 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/PragmaDetectMismatchDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class PragmaDetectMismatchDecl : Decl + { + internal PragmaDetectMismatchDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_PragmaDetectMismatch) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/RecordDecl.cs b/sources/ClangSharp/Cursors/Decls/RecordDecl.cs index e9bafe96..6ea871e5 100644 --- a/sources/ClangSharp/Cursors/Decls/RecordDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/RecordDecl.cs @@ -11,8 +11,22 @@ public class RecordDecl : TagDecl { private readonly Lazy> _fields; - internal RecordDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + internal RecordDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_Record) { + } + + private protected RecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if ((CX_DeclKind.CX_DeclKind_LastRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstRecord)) + { + throw new ArgumentException(nameof(handle)); + } + + if ((handle.Kind != CXCursorKind.CXCursor_StructDecl) && (handle.Kind != CXCursorKind.CXCursor_UnionDecl) && (handle.Kind != CXCursorKind.CXCursor_ClassDecl) && (handle.Kind != CXCursorKind.CXCursor_ClassTemplatePartialSpecialization)) + { + throw new ArgumentException(nameof(handle)); + } + _fields = new Lazy>(() => Decls.OfType().ToList()); } diff --git a/sources/ClangSharp/Cursors/Decls/RedeclarableTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/RedeclarableTemplateDecl.cs index ad880692..cababb06 100644 --- a/sources/ClangSharp/Cursors/Decls/RedeclarableTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/RedeclarableTemplateDecl.cs @@ -9,8 +9,13 @@ public class RedeclarableTemplateDecl : TemplateDecl, IRedeclarable _instantiatedFromMemberTemplate; - private protected RedeclarableTemplateDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected RedeclarableTemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastRedeclarableTemplate < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstRedeclarableTemplate)) + { + throw new ArgumentException(nameof(handle)); + } + _instantiatedFromMemberTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); } diff --git a/sources/ClangSharp/Cursors/Decls/StaticAssertDecl.cs b/sources/ClangSharp/Cursors/Decls/StaticAssertDecl.cs index cecd16cc..23202b0e 100644 --- a/sources/ClangSharp/Cursors/Decls/StaticAssertDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/StaticAssertDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class StaticAssertDecl : Decl { - internal StaticAssertDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StaticAssert) + internal StaticAssertDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StaticAssert, CX_DeclKind.CX_DeclKind_StaticAssert) { } } diff --git a/sources/ClangSharp/Cursors/Decls/TagDecl.cs b/sources/ClangSharp/Cursors/Decls/TagDecl.cs index f928f54f..417d79ab 100644 --- a/sources/ClangSharp/Cursors/Decls/TagDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TagDecl.cs @@ -12,8 +12,13 @@ public unsafe class TagDecl : TypeDecl, IDeclContext, IRedeclarable private readonly Lazy> _decls; private readonly Lazy _definition; - private protected TagDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected TagDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastTag < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstTag)) + { + throw new ArgumentException(nameof(handle)); + } + _decls = new Lazy>(() => CursorChildren.OfType().ToList()); _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); } @@ -22,13 +27,13 @@ private protected TagDecl(CXCursor handle, CXCursorKind expectedKind) : base(han public TagDecl Definition => _definition.Value; - public bool IsClass => Kind == CXCursorKind.CXCursor_ClassDecl; + public bool IsClass => CursorKind == CXCursorKind.CXCursor_ClassDecl; - public bool IsEnum => Kind == CXCursorKind.CXCursor_EnumDecl; + public bool IsEnum => CursorKind == CXCursorKind.CXCursor_EnumDecl; - public bool IsStruct => Kind == CXCursorKind.CXCursor_StructDecl; + public bool IsStruct => CursorKind == CXCursorKind.CXCursor_StructDecl; - public bool IsUnion => Kind == CXCursorKind.CXCursor_UnionDecl; + public bool IsUnion => CursorKind == CXCursorKind.CXCursor_UnionDecl; public IDeclContext LexicalParent => LexicalDeclContext; diff --git a/sources/ClangSharp/Cursors/Decls/TemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/TemplateDecl.cs index 9f17e53e..83dcb841 100644 --- a/sources/ClangSharp/Cursors/Decls/TemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TemplateDecl.cs @@ -11,8 +11,13 @@ public class TemplateDecl : NamedDecl { private readonly Lazy> _templateParameters; - private protected TemplateDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected TemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastTemplate < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstTemplate)) + { + throw new ArgumentException(nameof(handle)); + } + _templateParameters = new Lazy>(() => CursorChildren.Where((cursor) => (cursor is TemplateTypeParmDecl) || (cursor is NonTypeTemplateParmDecl) || (cursor is TemplateTemplateParmDecl)).Cast().ToList()); } diff --git a/sources/ClangSharp/Cursors/Decls/TemplateTemplateParmDecl.cs b/sources/ClangSharp/Cursors/Decls/TemplateTemplateParmDecl.cs index 7fd86492..35836376 100644 --- a/sources/ClangSharp/Cursors/Decls/TemplateTemplateParmDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TemplateTemplateParmDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class TemplateTemplateParmDecl : TemplateDecl, ITemplateParmPosition { - internal TemplateTemplateParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TemplateTemplateParameter) + internal TemplateTemplateParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TemplateTemplateParameter, CX_DeclKind.CX_DeclKind_TemplateTemplateParm) { } } diff --git a/sources/ClangSharp/Cursors/Decls/TemplateTypeParmDecl.cs b/sources/ClangSharp/Cursors/Decls/TemplateTypeParmDecl.cs index 4ba1977d..1c92378a 100644 --- a/sources/ClangSharp/Cursors/Decls/TemplateTypeParmDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TemplateTypeParmDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class TemplateTypeParmDecl : TypeDecl { - internal TemplateTypeParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TemplateTypeParameter) + internal TemplateTypeParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TemplateTypeParameter, CX_DeclKind.CX_DeclKind_TemplateTypeParm) { } } diff --git a/sources/ClangSharp/Cursors/Decls/TranslationUnitDecl.cs b/sources/ClangSharp/Cursors/Decls/TranslationUnitDecl.cs index a06ee29d..184c1a63 100644 --- a/sources/ClangSharp/Cursors/Decls/TranslationUnitDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TranslationUnitDecl.cs @@ -11,7 +11,7 @@ public sealed unsafe class TranslationUnitDecl : Decl, IDeclContext { private readonly Lazy> _decls; - internal TranslationUnitDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TranslationUnit) + internal TranslationUnitDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TranslationUnit, CX_DeclKind.CX_DeclKind_TranslationUnit) { _decls = new Lazy>(() => CursorChildren.OfType().ToList()); } diff --git a/sources/ClangSharp/Cursors/Decls/TypeAliasDecl.cs b/sources/ClangSharp/Cursors/Decls/TypeAliasDecl.cs index e5adf9d3..14242117 100644 --- a/sources/ClangSharp/Cursors/Decls/TypeAliasDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypeAliasDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class TypeAliasDecl : TypedefNameDecl { - internal TypeAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypeAliasDecl) + internal TypeAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypeAliasDecl, CX_DeclKind.CX_DeclKind_TypeAlias) { } } diff --git a/sources/ClangSharp/Cursors/Decls/TypeAliasTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/TypeAliasTemplateDecl.cs index 6e817a65..445bec38 100644 --- a/sources/ClangSharp/Cursors/Decls/TypeAliasTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypeAliasTemplateDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class TypeAliasTemplateDecl : RedeclarableTemplateDecl { - internal TypeAliasTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypeAliasTemplateDecl) + internal TypeAliasTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypeAliasTemplateDecl, CX_DeclKind.CX_DeclKind_TypeAliasTemplate) { } } diff --git a/sources/ClangSharp/Cursors/Decls/TypeDecl.cs b/sources/ClangSharp/Cursors/Decls/TypeDecl.cs index 3ae2be85..291e3f2a 100644 --- a/sources/ClangSharp/Cursors/Decls/TypeDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypeDecl.cs @@ -9,8 +9,13 @@ public class TypeDecl : NamedDecl { private readonly Lazy _typeForDecl; - private protected TypeDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected TypeDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastType < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstType)) + { + throw new ArgumentException(nameof(handle)); + } + _typeForDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); } diff --git a/sources/ClangSharp/Cursors/Decls/TypedefDecl.cs b/sources/ClangSharp/Cursors/Decls/TypedefDecl.cs index c4d1098a..b23d6c4a 100644 --- a/sources/ClangSharp/Cursors/Decls/TypedefDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypedefDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class TypedefDecl : TypedefNameDecl { - internal TypedefDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypedefDecl) + internal TypedefDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypedefDecl, CX_DeclKind.CX_DeclKind_Typedef) { } } diff --git a/sources/ClangSharp/Cursors/Decls/TypedefNameDecl.cs b/sources/ClangSharp/Cursors/Decls/TypedefNameDecl.cs index 38f2ecfe..19c2f93d 100644 --- a/sources/ClangSharp/Cursors/Decls/TypedefNameDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypedefNameDecl.cs @@ -9,8 +9,13 @@ public class TypedefNameDecl : TypeDecl, IRedeclarable { private readonly Lazy _underlyingType; - private protected TypedefNameDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected TypedefNameDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastTypedefName < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstTypedefName)) + { + throw new ArgumentException(nameof(handle)); + } + _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypedefDeclUnderlyingType)); } diff --git a/sources/ClangSharp/Cursors/Decls/UnresolvedUsingTypenameDecl.cs b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingTypenameDecl.cs new file mode 100644 index 00000000..976bf449 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingTypenameDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class UnresolvedUsingTypenameDecl : TypeDecl, IMergeable + { + internal UnresolvedUsingTypenameDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/UnresolvedUsingValueDecl.cs b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingValueDecl.cs new file mode 100644 index 00000000..e9a9bc7b --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingValueDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class UnresolvedUsingValueDecl : ValueDecl, IMergeable + { + internal UnresolvedUsingValueDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_UnresolvedUsingValue) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/UsingDecl.cs b/sources/ClangSharp/Cursors/Decls/UsingDecl.cs index bdf890cd..06254e85 100644 --- a/sources/ClangSharp/Cursors/Decls/UsingDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UsingDecl.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class UsingDecl : NamedDecl, IMergeable { - internal UsingDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration) + internal UsingDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_Using) { } } diff --git a/sources/ClangSharp/Cursors/Decls/UsingDirectiveDecl.cs b/sources/ClangSharp/Cursors/Decls/UsingDirectiveDecl.cs index 9cda195a..c34e6118 100644 --- a/sources/ClangSharp/Cursors/Decls/UsingDirectiveDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UsingDirectiveDecl.cs @@ -4,9 +4,9 @@ namespace ClangSharp { - public class UsingDirectiveDecl : NamedDecl + public sealed class UsingDirectiveDecl : NamedDecl { - internal UsingDirectiveDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDirective) + internal UsingDirectiveDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDirective, CX_DeclKind.CX_DeclKind_UsingDirective) { } } diff --git a/sources/ClangSharp/Cursors/Decls/UsingPackDecl.cs b/sources/ClangSharp/Cursors/Decls/UsingPackDecl.cs new file mode 100644 index 00000000..5feb8917 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/UsingPackDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class UsingPackDecl : NamedDecl, IMergeable + { + internal UsingPackDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_UsingPack) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/UsingShadowDecl.cs b/sources/ClangSharp/Cursors/Decls/UsingShadowDecl.cs new file mode 100644 index 00000000..2f9f5f6d --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/UsingShadowDecl.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using System; +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class UsingShadowDecl : NamedDecl, IRedeclarable + { + internal UsingShadowDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_UsingShadow) + { + } + + private protected UsingShadowDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if ((CX_DeclKind.CX_DeclKind_LastUsingShadow < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstUsingShadow)) + { + throw new ArgumentException(nameof(handle)); + } + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/ValueDecl.cs b/sources/ClangSharp/Cursors/Decls/ValueDecl.cs index 698b4079..f41addd5 100644 --- a/sources/ClangSharp/Cursors/Decls/ValueDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ValueDecl.cs @@ -9,8 +9,13 @@ public class ValueDecl : NamedDecl { private readonly Lazy _type; - private protected ValueDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected ValueDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastValue < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstValue)) + { + throw new ArgumentException(nameof(handle)); + } + _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); } diff --git a/sources/ClangSharp/Cursors/Decls/VarDecl.cs b/sources/ClangSharp/Cursors/Decls/VarDecl.cs index 5851ef73..d67c360f 100644 --- a/sources/ClangSharp/Cursors/Decls/VarDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/VarDecl.cs @@ -9,12 +9,17 @@ public class VarDecl : DeclaratorDecl, IRedeclarable { private readonly Lazy _instantiatedFromStaticDataMember; - internal VarDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_VarDecl) + internal VarDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_VarDecl, CX_DeclKind.CX_DeclKind_Var) { } - private protected VarDecl(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected VarDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { + if ((CX_DeclKind.CX_DeclKind_LastVar < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstVar)) + { + throw new ArgumentException(nameof(handle)); + } + _instantiatedFromStaticDataMember = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); } diff --git a/sources/ClangSharp/Cursors/Decls/VarTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/VarTemplateDecl.cs new file mode 100644 index 00000000..67448c81 --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/VarTemplateDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class VarTemplateDecl : RedeclarableTemplateDecl + { + internal VarTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_VarTemplate) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/VarTemplatePartialSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/VarTemplatePartialSpecializationDecl.cs new file mode 100644 index 00000000..ec7b6b3b --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/VarTemplatePartialSpecializationDecl.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class VarTemplatePartialSpecializationDecl : VarDecl + { + internal VarTemplatePartialSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Decls/VarTemplateSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/VarTemplateSpecializationDecl.cs new file mode 100644 index 00000000..098adb0e --- /dev/null +++ b/sources/ClangSharp/Cursors/Decls/VarTemplateSpecializationDecl.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using System; +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class VarTemplateSpecializationDecl : VarDecl + { + internal VarTemplateSpecializationDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_VarTemplateSpecialization) + { + } + + private protected VarTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if ((CX_DeclKind.CX_DeclKind_LastVarTemplateSpecialization < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstVarTemplateSpecialization)) + { + throw new ArgumentException(nameof(handle)); + } + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/AbstractConditionalOperator.cs b/sources/ClangSharp/Cursors/Exprs/AbstractConditionalOperator.cs index 1445d66e..1956b531 100644 --- a/sources/ClangSharp/Cursors/Exprs/AbstractConditionalOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/AbstractConditionalOperator.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class AbstractConditionalOperator : Expr { - private protected AbstractConditionalOperator(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected AbstractConditionalOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { + if ((CX_StmtClass.CX_StmtClass_LastAbstractConditionalOperator < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstAbstractConditionalOperator)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Exprs/AddrLabelExpr.cs b/sources/ClangSharp/Cursors/Exprs/AddrLabelExpr.cs index 8182312b..4d306509 100644 --- a/sources/ClangSharp/Cursors/Exprs/AddrLabelExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/AddrLabelExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class AddrLabelExpr : Expr { - internal AddrLabelExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_AddrLabelExpr) + internal AddrLabelExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_AddrLabelExpr, CX_StmtClass.CX_StmtClass_AddrLabelExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ArrayInitIndexExpr.cs b/sources/ClangSharp/Cursors/Exprs/ArrayInitIndexExpr.cs new file mode 100644 index 00000000..efdb6822 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ArrayInitIndexExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ArrayInitIndexExpr : Expr + { + internal ArrayInitIndexExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ArrayInitLoopExpr.cs b/sources/ClangSharp/Cursors/Exprs/ArrayInitLoopExpr.cs new file mode 100644 index 00000000..a6a75c5a --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ArrayInitLoopExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ArrayInitLoopExpr : Expr + { + internal ArrayInitLoopExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ArraySubscriptExpr.cs b/sources/ClangSharp/Cursors/Exprs/ArraySubscriptExpr.cs index e64efb7d..400c2824 100644 --- a/sources/ClangSharp/Cursors/Exprs/ArraySubscriptExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ArraySubscriptExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ArraySubscriptExpr : Expr { - internal ArraySubscriptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ArraySubscriptExpr) + internal ArraySubscriptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ArraySubscriptExpr, CX_StmtClass.CX_StmtClass_ArraySubscriptExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ArrayTypeTraitExpr.cs b/sources/ClangSharp/Cursors/Exprs/ArrayTypeTraitExpr.cs new file mode 100644 index 00000000..a01755fd --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ArrayTypeTraitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ArrayTypeTraitExpr : Expr + { + internal ArrayTypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/AsTypeExpr.cs b/sources/ClangSharp/Cursors/Exprs/AsTypeExpr.cs new file mode 100644 index 00000000..84db41ae --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/AsTypeExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class AsTypeExpr : Expr + { + internal AsTypeExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_AsTypeExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/AtomicExpr.cs b/sources/ClangSharp/Cursors/Exprs/AtomicExpr.cs new file mode 100644 index 00000000..dfc3fff7 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/AtomicExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class AtomicExpr : Expr + { + internal AtomicExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_AtomicExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/BinaryConditionalOperator.cs b/sources/ClangSharp/Cursors/Exprs/BinaryConditionalOperator.cs new file mode 100644 index 00000000..d40b1214 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/BinaryConditionalOperator.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class BinaryConditionalOperator : AbstractConditionalOperator + { + internal BinaryConditionalOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_BinaryConditionalOperator) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/BinaryOperator.cs b/sources/ClangSharp/Cursors/Exprs/BinaryOperator.cs index 5b19022c..8000e812 100644 --- a/sources/ClangSharp/Cursors/Exprs/BinaryOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/BinaryOperator.cs @@ -10,39 +10,30 @@ namespace ClangSharp public class BinaryOperator : Expr { private readonly Lazy _lhs; - private readonly Lazy _opcode; private readonly Lazy _rhs; - internal BinaryOperator(CXCursor handle) : this(handle, CXCursorKind.CXCursor_BinaryOperator) + internal BinaryOperator(CXCursor handle) : this(handle, CXCursorKind.CXCursor_BinaryOperator, CX_StmtClass.CX_StmtClass_BinaryOperator) { } - private protected BinaryOperator(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected BinaryOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - Debug.Assert(Children.Where((cursor) => cursor is Expr).Count() == 2); + if ((CX_StmtClass.CX_StmtClass_LastBinaryOperator < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstBinaryOperator)) + { + throw new ArgumentException(nameof(handle)); + } + Debug.Assert(Children.OfType().Count() == 2); _lhs = new Lazy(() => Children.OfType().First()); - _opcode = new Lazy(GetOpcode); _rhs = new Lazy(() => Children.OfType().Last()); } public Expr LHS => _lhs.Value; - public string Opcode => _opcode.Value; + public CX_BinaryOperatorKind Opcode => Handle.BinaryOperatorKind; - public Expr RHS => _rhs.Value; - - protected virtual string GetOpcode() - { - var lhsTokens = Handle.TranslationUnit.Tokenize(LHS.Extent); - - var tokens = Handle.TranslationUnit.Tokenize(Extent); - Debug.Assert(tokens.Length >= 3); + public string OpcodeStr => Handle.BinaryOperatorKindSpelling.ToString(); - int operatorIndex = lhsTokens.Length; - - Debug.Assert(tokens[operatorIndex].Kind == CXTokenKind.CXToken_Punctuation); - return tokens[operatorIndex].GetSpelling(Handle.TranslationUnit).ToString(); - } + public Expr RHS => _rhs.Value; } } diff --git a/sources/ClangSharp/Cursors/Exprs/BlockExpr.cs b/sources/ClangSharp/Cursors/Exprs/BlockExpr.cs index fd5ce417..9260e396 100644 --- a/sources/ClangSharp/Cursors/Exprs/BlockExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/BlockExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class BlockExpr : Expr { - internal BlockExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BlockExpr) + internal BlockExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BlockExpr, CX_StmtClass.CX_StmtClass_BlockExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/BuiltinBitCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/BuiltinBitCastExpr.cs index ad1d91ea..f70cf552 100644 --- a/sources/ClangSharp/Cursors/Exprs/BuiltinBitCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/BuiltinBitCastExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class BuiltinBitCastExpr : ExplicitCastExpr { - internal BuiltinBitCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BuiltinBitCastExpr) + internal BuiltinBitCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BuiltinBitCastExpr, CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CStyleCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CStyleCastExpr.cs index 25274823..ab347c28 100644 --- a/sources/ClangSharp/Cursors/Exprs/CStyleCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CStyleCastExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CStyleCastExpr : ExplicitCastExpr { - internal CStyleCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CStyleCastExpr) + internal CStyleCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CStyleCastExpr, CX_StmtClass.CX_StmtClass_CStyleCastExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CUDAKernelCallExpr.cs b/sources/ClangSharp/Cursors/Exprs/CUDAKernelCallExpr.cs new file mode 100644 index 00000000..0dd45c20 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CUDAKernelCallExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CUDAKernelCallExpr : CallExpr + { + internal CUDAKernelCallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXBindTemporaryExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXBindTemporaryExpr.cs new file mode 100644 index 00000000..02b59ab0 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXBindTemporaryExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXBindTemporaryExpr : Expr + { + internal CXXBindTemporaryExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXBoolLiteralExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXBoolLiteralExpr.cs index e3779e0f..4faa7541 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXBoolLiteralExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXBoolLiteralExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXBoolLiteralExpr : Expr { - internal CXXBoolLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXBoolLiteralExpr) + internal CXXBoolLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXBoolLiteralExpr, CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXConstCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXConstCastExpr.cs index 03586f81..4aaea444 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXConstCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXConstCastExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXConstCastExpr : CXXNamedCastExpr { - internal CXXConstCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXConstCastExpr) + internal CXXConstCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXConstCastExpr, CX_StmtClass.CX_StmtClass_CXXConstCastExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXConstructExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXConstructExpr.cs new file mode 100644 index 00000000..6b0548ce --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXConstructExpr.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using System; +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class CXXConstructExpr : Expr + { + internal CXXConstructExpr(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXConstructExpr) + { + } + + private protected CXXConstructExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if ((CX_StmtClass.CX_StmtClass_LastCXXConstructExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCXXConstructExpr)) + { + throw new ArgumentException(nameof(handle)); + } + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs new file mode 100644 index 00000000..62cd3647 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXDefaultArgExpr : Expr + { + internal CXXDefaultArgExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDefaultInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDefaultInitExpr.cs new file mode 100644 index 00000000..847b6c3f --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXDefaultInitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXDefaultInitExpr : Expr + { + internal CXXDefaultInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDeleteExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDeleteExpr.cs index 314a6c61..1f731be4 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXDeleteExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXDeleteExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXDeleteExpr : Expr { - internal CXXDeleteExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXDeleteExpr) + internal CXXDeleteExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXDeleteExpr, CX_StmtClass.CX_StmtClass_CXXDeleteExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDependentScopeMemberExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDependentScopeMemberExpr.cs new file mode 100644 index 00000000..41a2166f --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXDependentScopeMemberExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXDependentScopeMemberExpr : Expr + { + internal CXXDependentScopeMemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDynamicCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDynamicCastExpr.cs index fac93299..16405a57 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXDynamicCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXDynamicCastExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXDynamicCastExpr : CXXNamedCastExpr { - internal CXXDynamicCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXDynamicCastExpr) + internal CXXDynamicCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXDynamicCastExpr, CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXFoldExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXFoldExpr.cs new file mode 100644 index 00000000..d49d1985 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXFoldExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXFoldExpr : Expr + { + internal CXXFoldExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXFoldExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXFunctionalCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXFunctionalCastExpr.cs index 995185d7..e28fd7aa 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXFunctionalCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXFunctionalCastExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXFunctionalCastExpr : ExplicitCastExpr { - internal CXXFunctionalCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXFunctionalCastExpr) + internal CXXFunctionalCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXFunctionalCastExpr, CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXInheritedCtorInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXInheritedCtorInitExpr.cs new file mode 100644 index 00000000..e7a5d198 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXInheritedCtorInitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXInheritedCtorInitExpr : Expr + { + internal CXXInheritedCtorInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXMemberCallExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXMemberCallExpr.cs new file mode 100644 index 00000000..600fff3f --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXMemberCallExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXMemberCallExpr : CallExpr + { + internal CXXMemberCallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXMemberCallExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXNamedCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXNamedCastExpr.cs index 8a1d61ca..4f44964a 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXNamedCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXNamedCastExpr.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class CXXNamedCastExpr : ExplicitCastExpr { - private protected CXXNamedCastExpr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected CXXNamedCastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { + if ((CX_StmtClass.CX_StmtClass_LastCXXNamedCastExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCXXNamedCastExpr)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXNewExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXNewExpr.cs index 7f83a7c1..bda9f47d 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXNewExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXNewExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXNewExpr : Expr { - internal CXXNewExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXNewExpr) + internal CXXNewExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXNewExpr, CX_StmtClass.CX_StmtClass_CXXNewExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXNoexceptExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXNoexceptExpr.cs new file mode 100644 index 00000000..86607a66 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXNoexceptExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXNoexceptExpr : Expr + { + internal CXXNoexceptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryExpr, CX_StmtClass.CX_StmtClass_CXXNoexceptExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXNullPtrLiteralExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXNullPtrLiteralExpr.cs index d8c609a4..5c34da23 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXNullPtrLiteralExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXNullPtrLiteralExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXNullPtrLiteralExpr : Expr { - internal CXXNullPtrLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXNullPtrLiteralExpr) + internal CXXNullPtrLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXNullPtrLiteralExpr, CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXOperatorCallExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXOperatorCallExpr.cs new file mode 100644 index 00000000..bb0c95a2 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXOperatorCallExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXOperatorCallExpr : CallExpr + { + internal CXXOperatorCallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXPseudoDestructorExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXPseudoDestructorExpr.cs new file mode 100644 index 00000000..1351ee48 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXPseudoDestructorExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXPseudoDestructorExpr : Expr + { + internal CXXPseudoDestructorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXReinterpretCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXReinterpretCastExpr.cs index ab796bd3..c759c767 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXReinterpretCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXReinterpretCastExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXReinterpretCastExpr : CXXNamedCastExpr { - internal CXXReinterpretCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXReinterpretCastExpr) + internal CXXReinterpretCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXReinterpretCastExpr, CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXScalarValueInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXScalarValueInitExpr.cs new file mode 100644 index 00000000..1696ef0a --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXScalarValueInitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXScalarValueInitExpr : Expr + { + internal CXXScalarValueInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXStaticCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXStaticCastExpr.cs index cb05eef1..b2f4bc46 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXStaticCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXStaticCastExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXStaticCastExpr : CXXNamedCastExpr { - internal CXXStaticCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXStaticCastExpr) + internal CXXStaticCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXStaticCastExpr, CX_StmtClass.CX_StmtClass_CXXStaticCastExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXStdInitializerListExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXStdInitializerListExpr.cs new file mode 100644 index 00000000..f623163e --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXStdInitializerListExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXStdInitializerListExpr : Expr + { + internal CXXStdInitializerListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXTemporaryObjectExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXTemporaryObjectExpr.cs new file mode 100644 index 00000000..067f3d15 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXTemporaryObjectExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXTemporaryObjectExpr : CXXConstructExpr + { + internal CXXTemporaryObjectExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXThisExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXThisExpr.cs index 358dcfd9..0e8f3238 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXThisExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXThisExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXThisExpr : Expr { - internal CXXThisExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXThisExpr) + internal CXXThisExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXThisExpr, CX_StmtClass.CX_StmtClass_CXXThisExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXThrowExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXThrowExpr.cs index b655c151..09237c44 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXThrowExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXThrowExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXThrowExpr : Expr { - internal CXXThrowExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXThrowExpr) + internal CXXThrowExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXThrowExpr, CX_StmtClass.CX_StmtClass_CXXThrowExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXTypeidExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXTypeidExpr.cs index ba84313c..b25e95c2 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXTypeidExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXTypeidExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXTypeidExpr : Expr { - internal CXXTypeidExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXTypeidExpr) + internal CXXTypeidExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXTypeidExpr, CX_StmtClass.CX_StmtClass_CXXTypeidExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXUnresolvedConstructExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXUnresolvedConstructExpr.cs new file mode 100644 index 00000000..efc4e726 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXUnresolvedConstructExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXUnresolvedConstructExpr : Expr + { + internal CXXUnresolvedConstructExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CXXUuidofExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXUuidofExpr.cs new file mode 100644 index 00000000..258e12a6 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CXXUuidofExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CXXUuidofExpr : Expr + { + internal CXXUuidofExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXUuidofExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CallExpr.cs b/sources/ClangSharp/Cursors/Exprs/CallExpr.cs index b11a6add..862403af 100644 --- a/sources/ClangSharp/Cursors/Exprs/CallExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CallExpr.cs @@ -6,13 +6,22 @@ namespace ClangSharp { - public sealed class CallExpr : Expr + public class CallExpr : Expr { private readonly Lazy> _args; private readonly Lazy _calleeDecl; - internal CallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr) + internal CallExpr(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CallExpr) { + } + + private protected CallExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if ((CX_StmtClass.CX_StmtClass_LastCallExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCallExpr)) + { + throw new ArgumentException(nameof(handle)); + } + _args = new Lazy>(() => { var numArgs = NumArgs; var args = new List((int)numArgs); diff --git a/sources/ClangSharp/Cursors/Exprs/CastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CastExpr.cs index 400abec7..da17404d 100644 --- a/sources/ClangSharp/Cursors/Exprs/CastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CastExpr.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class CastExpr : Expr { - private protected CastExpr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected CastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { + if ((CX_StmtClass.CX_StmtClass_LastCastExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCastExpr)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CharacterLiteral.cs b/sources/ClangSharp/Cursors/Exprs/CharacterLiteral.cs index 40d4786f..5e99474f 100644 --- a/sources/ClangSharp/Cursors/Exprs/CharacterLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/CharacterLiteral.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CharacterLiteral : Expr { - internal CharacterLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CharacterLiteral) + internal CharacterLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CharacterLiteral, CX_StmtClass.CX_StmtClass_CharacterLiteral) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ChooseExpr.cs b/sources/ClangSharp/Cursors/Exprs/ChooseExpr.cs new file mode 100644 index 00000000..02b0e737 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ChooseExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ChooseExpr : Expr + { + internal ChooseExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ChooseExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CoawaitExpr.cs b/sources/ClangSharp/Cursors/Exprs/CoawaitExpr.cs new file mode 100644 index 00000000..7f8ca4f6 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CoawaitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CoawaitExpr : CoroutineSuspendExpr + { + internal CoawaitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CoawaitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CompoundAssignOperator.cs b/sources/ClangSharp/Cursors/Exprs/CompoundAssignOperator.cs index c71faf1f..f4c67d34 100644 --- a/sources/ClangSharp/Cursors/Exprs/CompoundAssignOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/CompoundAssignOperator.cs @@ -1,79 +1,13 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. -using System.Diagnostics; using ClangSharp.Interop; namespace ClangSharp { public sealed class CompoundAssignOperator : BinaryOperator { - internal CompoundAssignOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundAssignOperator) + internal CompoundAssignOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundAssignOperator, CX_StmtClass.CX_StmtClass_CompoundAssignOperator) { } - - protected override string GetOpcode() - { - var tokens = Handle.TranslationUnit.Tokenize(Extent); - - Debug.Assert(tokens.Length >= 3); - - int operatorIndex = -1; - int parenDepth = 0; - - for (int index = 0; (index < tokens.Length) && (operatorIndex == -1); index++) - { - var token = tokens[index]; - - if (token.Kind != CXTokenKind.CXToken_Punctuation) - { - continue; - } - - var punctuation = tokens[index].GetSpelling(Handle.TranslationUnit).ToString(); - - switch (punctuation) - { - case "%=": - case "&=": - case "*=": - case "+=": - case "-=": - case "/=": - case "<<=": - case ">>=": - case "^=": - case "|=": - { - if (parenDepth == 0) - { - operatorIndex = index; - } - break; - } - - case "(": - { - parenDepth++; - break; - } - - case ")": - { - parenDepth--; - break; - } - - default: - { - Debug.WriteLine($"Unhandled punctuation kind: {punctuation}."); - break; - } - } - } - - Debug.Assert(operatorIndex != -1); - Debug.Assert(tokens[operatorIndex].Kind == CXTokenKind.CXToken_Punctuation); - return tokens[operatorIndex].GetSpelling(Handle.TranslationUnit).ToString(); - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs b/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs index c9647af8..39930402 100644 --- a/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CompoundLiteralExpr : Expr { - internal CompoundLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundLiteralExpr) + internal CompoundLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundLiteralExpr, CX_StmtClass.CX_StmtClass_CompoundLiteralExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ConditionalOperator.cs b/sources/ClangSharp/Cursors/Exprs/ConditionalOperator.cs index 4476926b..d5735fc5 100644 --- a/sources/ClangSharp/Cursors/Exprs/ConditionalOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/ConditionalOperator.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ConditionalOperator : AbstractConditionalOperator { - internal ConditionalOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConditionalOperator) + internal ConditionalOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConditionalOperator, CX_StmtClass.CX_StmtClass_ConditionalOperator) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ConstantExpr.cs b/sources/ClangSharp/Cursors/Exprs/ConstantExpr.cs new file mode 100644 index 00000000..9a233e03 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ConstantExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ConstantExpr : FullExpr + { + internal ConstantExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ConstantExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ConvertVectorExpr.cs b/sources/ClangSharp/Cursors/Exprs/ConvertVectorExpr.cs new file mode 100644 index 00000000..c106e005 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ConvertVectorExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ConvertVectorExpr : Expr + { + internal ConvertVectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ConvertVectorExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CoroutineSuspendExpr.cs b/sources/ClangSharp/Cursors/Exprs/CoroutineSuspendExpr.cs new file mode 100644 index 00000000..f7891e3c --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CoroutineSuspendExpr.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using System; +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class CoroutineSuspendExpr : Expr + { + private protected CoroutineSuspendExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if ((CX_StmtClass.CX_StmtClass_LastCoroutineSuspendExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstCoroutineSuspendExpr)) + { + throw new ArgumentException(nameof(handle)); + } + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/CoyieldExpr.cs b/sources/ClangSharp/Cursors/Exprs/CoyieldExpr.cs new file mode 100644 index 00000000..bf005695 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/CoyieldExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CoyieldExpr : CoroutineSuspendExpr + { + internal CoyieldExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CoyieldExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/DeclRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/DeclRefExpr.cs index 56abd3ff..cbf5a383 100644 --- a/sources/ClangSharp/Cursors/Exprs/DeclRefExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/DeclRefExpr.cs @@ -9,8 +9,13 @@ public sealed class DeclRefExpr : Expr { private readonly Lazy _decl; - internal DeclRefExpr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + internal DeclRefExpr(CXCursor handle) : base(handle, handle.Kind, CX_StmtClass.CX_StmtClass_DeclRefExpr) { + if ((handle.Kind != CXCursorKind.CXCursor_DeclRefExpr) && (handle.Kind != CXCursorKind.CXCursor_ObjCSelfExpr)) + { + throw new ArgumentException(nameof(handle)); + } + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); } diff --git a/sources/ClangSharp/Cursors/Exprs/DependentCoawaitExpr.cs b/sources/ClangSharp/Cursors/Exprs/DependentCoawaitExpr.cs new file mode 100644 index 00000000..54a1d129 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/DependentCoawaitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DependentCoawaitExpr : Expr + { + internal DependentCoawaitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_DependentCoawaitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/DependentScopeDeclRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/DependentScopeDeclRefExpr.cs new file mode 100644 index 00000000..026277e9 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/DependentScopeDeclRefExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DependentScopeDeclRefExpr : Expr + { + internal DependentScopeDeclRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/DesignatedInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/DesignatedInitExpr.cs new file mode 100644 index 00000000..0b3d8fa1 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/DesignatedInitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DesignatedInitExpr : Expr + { + internal DesignatedInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_DesignatedInitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/DesignatedInitUpdateExpr.cs b/sources/ClangSharp/Cursors/Exprs/DesignatedInitUpdateExpr.cs new file mode 100644 index 00000000..caef0b85 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/DesignatedInitUpdateExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DesignatedInitUpdateExpr : Expr + { + internal DesignatedInitUpdateExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ExplicitCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/ExplicitCastExpr.cs index c60a282d..80988dff 100644 --- a/sources/ClangSharp/Cursors/Exprs/ExplicitCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ExplicitCastExpr.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class ExplicitCastExpr : CastExpr { - private protected ExplicitCastExpr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected ExplicitCastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { + if ((CX_StmtClass.CX_StmtClass_LastExplicitCastExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstExplicitCastExpr)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Exprs/Expr.cs b/sources/ClangSharp/Cursors/Exprs/Expr.cs index 55471f21..ffb2df6a 100644 --- a/sources/ClangSharp/Cursors/Exprs/Expr.cs +++ b/sources/ClangSharp/Cursors/Exprs/Expr.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. using System; -using System.Diagnostics; using ClangSharp.Interop; namespace ClangSharp @@ -10,323 +9,16 @@ public class Expr : ValueStmt { private readonly Lazy _type; - private protected Expr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected Expr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); - } - - public Type Type { get; } - - internal static new Expr Create(CXCursor handle) - { - Expr result; - - switch (handle.Kind) + if ((CX_StmtClass.CX_StmtClass_LastExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstExpr)) { - case CXCursorKind.CXCursor_UnexposedExpr: - { - result = new Expr(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_ObjCSelfExpr: - case CXCursorKind.CXCursor_DeclRefExpr: - { - result = new DeclRefExpr(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_MemberRefExpr: - { - result = new MemberExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CallExpr: - { - result = new CallExpr(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCMessageExpr: - { - result = new ObjCMessageExpr(handle); - break; - } - - case CXCursorKind.CXCursor_BlockExpr: - { - result = new BlockExpr(handle); - break; - } - - case CXCursorKind.CXCursor_IntegerLiteral: - { - result = new IntegerLiteral(handle); - break; - } - - case CXCursorKind.CXCursor_FloatingLiteral: - { - result = new FloatingLiteral(handle); - break; - } - - case CXCursorKind.CXCursor_ImaginaryLiteral: - { - result = new ImaginaryLiteral(handle); - break; - } - - case CXCursorKind.CXCursor_StringLiteral: - { - result = new StringLiteral(handle); - break; - } - - case CXCursorKind.CXCursor_CharacterLiteral: - { - result = new CharacterLiteral(handle); - break; - } - - case CXCursorKind.CXCursor_ParenExpr: - { - result = new ParenExpr(handle); - break; - } - - case CXCursorKind.CXCursor_UnaryOperator: - { - result = new UnaryOperator(handle); - break; - } - - case CXCursorKind.CXCursor_ArraySubscriptExpr: - { - result = new ArraySubscriptExpr(handle); - break; - } - - case CXCursorKind.CXCursor_BinaryOperator: - { - result = new BinaryOperator(handle); - break; - } - - case CXCursorKind.CXCursor_CompoundAssignOperator: - { - result = new CompoundAssignOperator(handle); - break; - } - - case CXCursorKind.CXCursor_ConditionalOperator: - { - result = new ConditionalOperator(handle); - break; - } - - case CXCursorKind.CXCursor_CStyleCastExpr: - { - result = new CStyleCastExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CompoundLiteralExpr: - { - result = new CompoundLiteralExpr(handle); - break; - } - - case CXCursorKind.CXCursor_InitListExpr: - { - result = new InitListExpr(handle); - break; - } - - case CXCursorKind.CXCursor_AddrLabelExpr: - { - result = new AddrLabelExpr(handle); - break; - } - - case CXCursorKind.CXCursor_StmtExpr: - { - result = new StmtExpr(handle); - break; - } - - case CXCursorKind.CXCursor_GenericSelectionExpr: - { - result = new GenericSelectionExpr(handle); - break; - } - - case CXCursorKind.CXCursor_GNUNullExpr: - { - result = new GNUNullExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXStaticCastExpr: - { - result = new CXXStaticCastExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXDynamicCastExpr: - { - result = new CXXDynamicCastExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXReinterpretCastExpr: - { - result = new CXXReinterpretCastExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXConstCastExpr: - { - result = new CXXConstCastExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXFunctionalCastExpr: - { - result = new CXXFunctionalCastExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXTypeidExpr: - { - result = new CXXTypeidExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXBoolLiteralExpr: - { - result = new CXXBoolLiteralExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXNullPtrLiteralExpr: - { - result = new CXXNullPtrLiteralExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXThisExpr: - { - result = new CXXThisExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXThrowExpr: - { - result = new CXXThrowExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXNewExpr: - { - result = new CXXNewExpr(handle); - break; - } - - case CXCursorKind.CXCursor_CXXDeleteExpr: - { - result = new CXXDeleteExpr(handle); - break; - } - - case CXCursorKind.CXCursor_UnaryExpr: - { - result = new UnaryExprOrTypeTraitExpr(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCStringLiteral: - { - result = new ObjCStringLiteral(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCEncodeExpr: - { - result = new ObjCEncodeExpr(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCSelectorExpr: - { - result = new ObjCSelectorExpr(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCProtocolExpr: - { - result = new ObjCProtocolExpr(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCBridgedCastExpr: - { - result = new ObjCBridgedCastExpr(handle); - break; - } - - case CXCursorKind.CXCursor_PackExpansionExpr: - { - result = new PackExpansionExpr(handle); - break; - } - - case CXCursorKind.CXCursor_SizeOfPackExpr: - { - result = new SizeOfPackExpr(handle); - break; - } - - case CXCursorKind.CXCursor_LambdaExpr: - { - result = new LambdaExpr(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCBoolLiteralExpr: - { - result = new ObjCBoolLiteralExpr(handle); - break; - } - - case CXCursorKind.CXCursor_OMPArraySectionExpr: - { - result = new OMPArraySectionExpr(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCAvailabilityCheckExpr: - { - result = new ObjCAvailabilityCheckExpr(handle); - break; - } - - case CXCursorKind.CXCursor_FixedPointLiteral: - { - result = new FixedPointLiteral(handle); - break; - } - - default: - { - Debug.WriteLine($"Unhandled expression kind: {handle.KindSpelling}."); - result = new Expr(handle, handle.Kind); - break; - } + throw new ArgumentException(nameof(handle)); } - return result; + _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); } + + public Type Type { get; } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ExprWithCleanups.cs b/sources/ClangSharp/Cursors/Exprs/ExprWithCleanups.cs new file mode 100644 index 00000000..2783478f --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ExprWithCleanups.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ExprWithCleanups : FullExpr + { + internal ExprWithCleanups(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ExprWithCleanups) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ExpressionTraitExpr.cs b/sources/ClangSharp/Cursors/Exprs/ExpressionTraitExpr.cs new file mode 100644 index 00000000..7242c192 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ExpressionTraitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ExpressionTraitExpr : Expr + { + internal ExpressionTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ExpressionTraitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ExtVectorElementExpr.cs b/sources/ClangSharp/Cursors/Exprs/ExtVectorElementExpr.cs new file mode 100644 index 00000000..69063a65 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ExtVectorElementExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ExtVectorElementExpr : Expr + { + internal ExtVectorElementExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ExtVectorElementExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/FixedPointLiteral.cs b/sources/ClangSharp/Cursors/Exprs/FixedPointLiteral.cs index 553f34a0..c9b9055f 100644 --- a/sources/ClangSharp/Cursors/Exprs/FixedPointLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/FixedPointLiteral.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class FixedPointLiteral : Expr { - internal FixedPointLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FixedPointLiteral) + internal FixedPointLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FixedPointLiteral, CX_StmtClass.CX_StmtClass_FixedPointLiteral) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/FloatingLiteral.cs b/sources/ClangSharp/Cursors/Exprs/FloatingLiteral.cs index 736233e0..b46902e0 100644 --- a/sources/ClangSharp/Cursors/Exprs/FloatingLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/FloatingLiteral.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class FloatingLiteral : Expr { - internal FloatingLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FloatingLiteral) + internal FloatingLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FloatingLiteral, CX_StmtClass.CX_StmtClass_FloatingLiteral) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/FullExpr.cs b/sources/ClangSharp/Cursors/Exprs/FullExpr.cs new file mode 100644 index 00000000..9a4652f9 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/FullExpr.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using System; +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class FullExpr : Expr + { + private protected FullExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if ((CX_StmtClass.CX_StmtClass_LastFullExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstFullExpr)) + { + throw new ArgumentException(nameof(handle)); + } + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/FunctionParmPackExpr.cs b/sources/ClangSharp/Cursors/Exprs/FunctionParmPackExpr.cs new file mode 100644 index 00000000..a469c832 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/FunctionParmPackExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class FunctionParmPackExpr : Expr + { + internal FunctionParmPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_FunctionParmPackExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/GNUNullExpr.cs b/sources/ClangSharp/Cursors/Exprs/GNUNullExpr.cs index d265cd4f..f95106ff 100644 --- a/sources/ClangSharp/Cursors/Exprs/GNUNullExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/GNUNullExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class GNUNullExpr : Expr { - internal GNUNullExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GNUNullExpr) + internal GNUNullExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GNUNullExpr, CX_StmtClass.CX_StmtClass_GNUNullExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/GenericSelectionExpr.cs b/sources/ClangSharp/Cursors/Exprs/GenericSelectionExpr.cs index b55daec3..78a04a3e 100644 --- a/sources/ClangSharp/Cursors/Exprs/GenericSelectionExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/GenericSelectionExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class GenericSelectionExpr : Expr { - internal GenericSelectionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GenericSelectionExpr) + internal GenericSelectionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GenericSelectionExpr, CX_StmtClass.CX_StmtClass_GenericSelectionExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ImaginaryLiteral.cs b/sources/ClangSharp/Cursors/Exprs/ImaginaryLiteral.cs index b6bf3e98..c9e5978f 100644 --- a/sources/ClangSharp/Cursors/Exprs/ImaginaryLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/ImaginaryLiteral.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ImaginaryLiteral : Expr { - internal ImaginaryLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ImaginaryLiteral) + internal ImaginaryLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ImaginaryLiteral, CX_StmtClass.CX_StmtClass_ImaginaryLiteral) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ImplicitCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/ImplicitCastExpr.cs new file mode 100644 index 00000000..6583019d --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ImplicitCastExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ImplicitCastExpr : CastExpr + { + internal ImplicitCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ImplicitCastExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ImplicitValueInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/ImplicitValueInitExpr.cs new file mode 100644 index 00000000..3ebadd2b --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ImplicitValueInitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ImplicitValueInitExpr : Expr + { + internal ImplicitValueInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/InitListExpr.cs b/sources/ClangSharp/Cursors/Exprs/InitListExpr.cs index d3ea2169..e8a3ce52 100644 --- a/sources/ClangSharp/Cursors/Exprs/InitListExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/InitListExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class InitListExpr : Expr { - internal InitListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_InitListExpr) + internal InitListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_InitListExpr, CX_StmtClass.CX_StmtClass_InitListExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/IntegerLiteral.cs b/sources/ClangSharp/Cursors/Exprs/IntegerLiteral.cs index 713bcb74..1da9f6e1 100644 --- a/sources/ClangSharp/Cursors/Exprs/IntegerLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/IntegerLiteral.cs @@ -10,7 +10,7 @@ public sealed class IntegerLiteral : Expr { private readonly Lazy _value; - internal IntegerLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IntegerLiteral) + internal IntegerLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IntegerLiteral, CX_StmtClass.CX_StmtClass_IntegerLiteral) { _value = new Lazy(() => { var tokens = Handle.TranslationUnit.Tokenize(Extent); diff --git a/sources/ClangSharp/Cursors/Exprs/LambdaExpr.cs b/sources/ClangSharp/Cursors/Exprs/LambdaExpr.cs index 7346633a..3ae584db 100644 --- a/sources/ClangSharp/Cursors/Exprs/LambdaExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/LambdaExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class LambdaExpr : Expr { - internal LambdaExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LambdaExpr) + internal LambdaExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LambdaExpr, CX_StmtClass.CX_StmtClass_LambdaExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/MSPropertyRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/MSPropertyRefExpr.cs new file mode 100644 index 00000000..8c3f05e3 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/MSPropertyRefExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class MSPropertyRefExpr : Expr + { + internal MSPropertyRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_MSPropertyRefExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/MSPropertySubscriptExpr.cs b/sources/ClangSharp/Cursors/Exprs/MSPropertySubscriptExpr.cs new file mode 100644 index 00000000..21a63ac5 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/MSPropertySubscriptExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class MSPropertySubscriptExpr : Expr + { + internal MSPropertySubscriptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ArraySubscriptExpr, CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/MaterializeTemporaryExpr.cs b/sources/ClangSharp/Cursors/Exprs/MaterializeTemporaryExpr.cs new file mode 100644 index 00000000..e50a4f79 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/MaterializeTemporaryExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class MaterializeTemporaryExpr : Expr + { + internal MaterializeTemporaryExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/MemberExpr.cs b/sources/ClangSharp/Cursors/Exprs/MemberExpr.cs index 9dfede15..dafa7e42 100644 --- a/sources/ClangSharp/Cursors/Exprs/MemberExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/MemberExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class MemberExpr : Expr { - internal MemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr) + internal MemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_MemberExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/NoInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/NoInitExpr.cs new file mode 100644 index 00000000..442dfa4f --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/NoInitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class NoInitExpr : Expr + { + internal NoInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_NoInitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/OMPArraySectionExpr.cs b/sources/ClangSharp/Cursors/Exprs/OMPArraySectionExpr.cs index a5ae6605..17edb705 100644 --- a/sources/ClangSharp/Cursors/Exprs/OMPArraySectionExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/OMPArraySectionExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPArraySectionExpr : Expr { - internal OMPArraySectionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPArraySectionExpr) + internal OMPArraySectionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPArraySectionExpr, CX_StmtClass.CX_StmtClass_OMPArraySectionExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCArrayLiteral.cs b/sources/ClangSharp/Cursors/Exprs/ObjCArrayLiteral.cs new file mode 100644 index 00000000..49780453 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ObjCArrayLiteral.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCArrayLiteral : Expr + { + internal ObjCArrayLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCArrayLiteral) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCAvailabilityCheckExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCAvailabilityCheckExpr.cs index b7b79f7e..68b80c74 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCAvailabilityCheckExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCAvailabilityCheckExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCAvailabilityCheckExpr : Expr { - internal ObjCAvailabilityCheckExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAvailabilityCheckExpr) + internal ObjCAvailabilityCheckExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAvailabilityCheckExpr, CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCBoolLiteralExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCBoolLiteralExpr.cs index 932eb512..4f23c497 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCBoolLiteralExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCBoolLiteralExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCBoolLiteralExpr : Expr { - internal ObjCBoolLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCBoolLiteralExpr) + internal ObjCBoolLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCBoolLiteralExpr, CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCBoxedExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCBoxedExpr.cs new file mode 100644 index 00000000..becb62a6 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ObjCBoxedExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCBoxedExpr : Expr + { + internal ObjCBoxedExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCBoxedExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCBridgedCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCBridgedCastExpr.cs index bb497a28..673fd6d2 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCBridgedCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCBridgedCastExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCBridgedCastExpr : ExplicitCastExpr { - internal ObjCBridgedCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCBridgedCastExpr) + internal ObjCBridgedCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCBridgedCastExpr, CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCDictionaryLiteral.cs b/sources/ClangSharp/Cursors/Exprs/ObjCDictionaryLiteral.cs new file mode 100644 index 00000000..841cf48d --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ObjCDictionaryLiteral.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCDictionaryLiteral : Expr + { + internal ObjCDictionaryLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCEncodeExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCEncodeExpr.cs index 70968291..1905a419 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCEncodeExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCEncodeExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCEncodeExpr : Expr { - internal ObjCEncodeExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCEncodeExpr) + internal ObjCEncodeExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCEncodeExpr, CX_StmtClass.CX_StmtClass_ObjCEncodeExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCIndirectCopyRestoreExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCIndirectCopyRestoreExpr.cs new file mode 100644 index 00000000..3c322d0e --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ObjCIndirectCopyRestoreExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCIndirectCopyRestoreExpr : Expr + { + internal ObjCIndirectCopyRestoreExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCIsaExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCIsaExpr.cs new file mode 100644 index 00000000..ce34e592 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ObjCIsaExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCIsaExpr : Expr + { + internal ObjCIsaExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_ObjCIsaExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCIvarRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCIvarRefExpr.cs new file mode 100644 index 00000000..250b99b7 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ObjCIvarRefExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCIvarRefExpr : Expr + { + internal ObjCIvarRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCMessageExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCMessageExpr.cs index e3caedc7..9d630daf 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCMessageExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCMessageExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCMessageExpr : Expr { - internal ObjCMessageExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCMessageExpr) + internal ObjCMessageExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCMessageExpr, CX_StmtClass.CX_StmtClass_ObjCMessageExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCPropertyRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCPropertyRefExpr.cs new file mode 100644 index 00000000..42064258 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ObjCPropertyRefExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCPropertyRefExpr : Expr + { + internal ObjCPropertyRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCProtocolExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCProtocolExpr.cs index c577602f..dc67fc4d 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCProtocolExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCProtocolExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCProtocolExpr : Expr { - internal ObjCProtocolExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCProtocolExpr) + internal ObjCProtocolExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCProtocolExpr, CX_StmtClass.CX_StmtClass_ObjCProtocolExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCSelectorExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCSelectorExpr.cs index 12775222..601901f4 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCSelectorExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCSelectorExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCSelectorExpr : Expr { - internal ObjCSelectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCSelectorExpr) + internal ObjCSelectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCSelectorExpr, CX_StmtClass.CX_StmtClass_ObjCSelectorExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCStringLiteral.cs b/sources/ClangSharp/Cursors/Exprs/ObjCStringLiteral.cs index 75b77edb..71efde71 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCStringLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCStringLiteral.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCStringLiteral : Expr { - internal ObjCStringLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCStringLiteral) + internal ObjCStringLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCStringLiteral, CX_StmtClass.CX_StmtClass_ObjCStringLiteral) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCSubscriptRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCSubscriptRefExpr.cs new file mode 100644 index 00000000..a5cac9d0 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ObjCSubscriptRefExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCSubscriptRefExpr : Expr + { + internal ObjCSubscriptRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/OffsetOfExpr.cs b/sources/ClangSharp/Cursors/Exprs/OffsetOfExpr.cs new file mode 100644 index 00000000..f36251db --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/OffsetOfExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class OffsetOfExpr : Expr + { + internal OffsetOfExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_OffsetOfExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/OpaqueValueExpr.cs b/sources/ClangSharp/Cursors/Exprs/OpaqueValueExpr.cs new file mode 100644 index 00000000..32287df3 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/OpaqueValueExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class OpaqueValueExpr : Expr + { + internal OpaqueValueExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_OpaqueValueExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/OverloadExpr.cs b/sources/ClangSharp/Cursors/Exprs/OverloadExpr.cs new file mode 100644 index 00000000..a68509c9 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/OverloadExpr.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using System; +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class OverloadExpr : Expr + { + private protected OverloadExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if ((CX_StmtClass.CX_StmtClass_LastOverloadExpr < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstOverloadExpr)) + { + throw new ArgumentException(nameof(handle)); + } + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/PackExpansionExpr.cs b/sources/ClangSharp/Cursors/Exprs/PackExpansionExpr.cs index b3cae564..99e80a28 100644 --- a/sources/ClangSharp/Cursors/Exprs/PackExpansionExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/PackExpansionExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class PackExpansionExpr : Expr { - internal PackExpansionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_PackExpansionExpr) + internal PackExpansionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_PackExpansionExpr, CX_StmtClass.CX_StmtClass_PackExpansionExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/ParenExpr.cs b/sources/ClangSharp/Cursors/Exprs/ParenExpr.cs index caf0912e..3fd8dee6 100644 --- a/sources/ClangSharp/Cursors/Exprs/ParenExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ParenExpr.cs @@ -10,7 +10,7 @@ public sealed class ParenExpr : Expr { private readonly Lazy _subExpr; - internal ParenExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ParenExpr) + internal ParenExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ParenExpr, CX_StmtClass.CX_StmtClass_ParenExpr) { _subExpr = new Lazy(() => Children.OfType().Single()); } diff --git a/sources/ClangSharp/Cursors/Exprs/ParenListExpr.cs b/sources/ClangSharp/Cursors/Exprs/ParenListExpr.cs new file mode 100644 index 00000000..86391762 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ParenListExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ParenListExpr : Expr + { + internal ParenListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ParenListExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/PredefinedExpr.cs b/sources/ClangSharp/Cursors/Exprs/PredefinedExpr.cs new file mode 100644 index 00000000..b7b1ba8b --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/PredefinedExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class PredefinedExpr : Expr + { + internal PredefinedExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_PredefinedExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/PseudoObjectExpr.cs b/sources/ClangSharp/Cursors/Exprs/PseudoObjectExpr.cs new file mode 100644 index 00000000..a5e84496 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/PseudoObjectExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class PseudoObjectExpr : Expr + { + internal PseudoObjectExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_PseudoObjectExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/ShuffleVectorExpr.cs b/sources/ClangSharp/Cursors/Exprs/ShuffleVectorExpr.cs new file mode 100644 index 00000000..cbcadf5d --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/ShuffleVectorExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ShuffleVectorExpr : Expr + { + internal ShuffleVectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ShuffleVectorExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/SizeOfPackExpr.cs b/sources/ClangSharp/Cursors/Exprs/SizeOfPackExpr.cs index 29ce6b9a..4527eb3a 100644 --- a/sources/ClangSharp/Cursors/Exprs/SizeOfPackExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/SizeOfPackExpr.cs @@ -9,7 +9,7 @@ public sealed class SizeOfPackExpr : Expr { private readonly Lazy _pack; - internal SizeOfPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SizeOfPackExpr) + internal SizeOfPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SizeOfPackExpr, CX_StmtClass.CX_StmtClass_SizeOfPackExpr) { _pack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); } diff --git a/sources/ClangSharp/Cursors/Exprs/SourceLocExpr.cs b/sources/ClangSharp/Cursors/Exprs/SourceLocExpr.cs new file mode 100644 index 00000000..1faf444a --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/SourceLocExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class SourceLocExpr : Expr + { + internal SourceLocExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_SourceLocExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/StmtExpr.cs b/sources/ClangSharp/Cursors/Exprs/StmtExpr.cs index 04e07023..daf98e3f 100644 --- a/sources/ClangSharp/Cursors/Exprs/StmtExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/StmtExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class StmtExpr : Expr { - internal StmtExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StmtExpr) + internal StmtExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StmtExpr, CX_StmtClass.CX_StmtClass_StmtExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs b/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs index caa82555..fcccfd2e 100644 --- a/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class StringLiteral : Expr { - internal StringLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StringLiteral) + internal StringLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StringLiteral, CX_StmtClass.CX_StmtClass_StringLiteral) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmExpr.cs b/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmExpr.cs new file mode 100644 index 00000000..d420979f --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class SubstNonTypeTemplateParmExpr : Expr + { + internal SubstNonTypeTemplateParmExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmPackExpr.cs b/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmPackExpr.cs new file mode 100644 index 00000000..b6faa9ed --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmPackExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class SubstNonTypeTemplateParmPackExpr : Expr + { + internal SubstNonTypeTemplateParmPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/TypeTraitExpr.cs b/sources/ClangSharp/Cursors/Exprs/TypeTraitExpr.cs new file mode 100644 index 00000000..31dd36f7 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/TypeTraitExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class TypeTraitExpr : Expr + { + internal TypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_TypeTraitExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/TypoExpr.cs b/sources/ClangSharp/Cursors/Exprs/TypoExpr.cs new file mode 100644 index 00000000..d7e58f39 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/TypoExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class TypoExpr : Expr + { + internal TypoExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_TypoExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/UnaryExprOrTypeTraitExpr.cs b/sources/ClangSharp/Cursors/Exprs/UnaryExprOrTypeTraitExpr.cs index baff9d35..8e9876e8 100644 --- a/sources/ClangSharp/Cursors/Exprs/UnaryExprOrTypeTraitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/UnaryExprOrTypeTraitExpr.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class UnaryExprOrTypeTraitExpr : Expr { - internal UnaryExprOrTypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryExpr) + internal UnaryExprOrTypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryExpr, CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr) { } } diff --git a/sources/ClangSharp/Cursors/Exprs/UnaryOperator.cs b/sources/ClangSharp/Cursors/Exprs/UnaryOperator.cs index 2e45bc7d..3afde240 100644 --- a/sources/ClangSharp/Cursors/Exprs/UnaryOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/UnaryOperator.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. using System; -using System.Diagnostics; using System.Linq; using ClangSharp.Interop; @@ -9,36 +8,21 @@ namespace ClangSharp { public sealed class UnaryOperator : Expr { - private readonly Lazy<(string Opcode, bool IsPrefix)> _opcode; private readonly Lazy _subExpr; - internal UnaryOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryOperator) + internal UnaryOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryOperator, CX_StmtClass.CX_StmtClass_UnaryOperator) { - _opcode = new Lazy<(string Opcode, bool IsPrefix)>(GetOpcode); _subExpr = new Lazy(() => Children.OfType().Single()); } - public bool IsPrefix => _opcode.Value.IsPrefix; + public bool IsPrefix => (Opcode == CX_UnaryOperatorKind.CX_UO_PreInc) || (Opcode == CX_UnaryOperatorKind.CX_UO_PreDec); - public bool IsPostfix => !_opcode.Value.IsPrefix; + public bool IsPostfix => (Opcode == CX_UnaryOperatorKind.CX_UO_PostInc) || (Opcode == CX_UnaryOperatorKind.CX_UO_PostDec); - public string Opcode => _opcode.Value.Opcode; + public CX_UnaryOperatorKind Opcode => Handle.UnaryOperatorKind; - public Expr SubExpr => _subExpr.Value; - - private (string Opcode, bool IsPrefix) GetOpcode() - { - var subExprTokens = Handle.TranslationUnit.Tokenize(SubExpr.Extent); - - var tokens = Handle.TranslationUnit.Tokenize(Extent); - Debug.Assert(tokens.Length >= 2); + public string OpcodeStr => Handle.UnaryOperatorKindSpelling.ToString(); - bool isPrefix = tokens[0] != subExprTokens[0]; - int operatorIndex = isPrefix ? 0 : subExprTokens.Length; - - Debug.Assert(tokens[operatorIndex].Kind == CXTokenKind.CXToken_Punctuation); - var opcode = tokens[operatorIndex].GetSpelling(Handle.TranslationUnit).ToString(); - return (opcode, isPrefix); - } + public Expr SubExpr => _subExpr.Value; } } diff --git a/sources/ClangSharp/Cursors/Exprs/UnresolvedLookupExpr.cs b/sources/ClangSharp/Cursors/Exprs/UnresolvedLookupExpr.cs new file mode 100644 index 00000000..fa185d60 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/UnresolvedLookupExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class UnresolvedLookupExpr : OverloadExpr + { + internal UnresolvedLookupExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/UnresolvedMemberExpr.cs b/sources/ClangSharp/Cursors/Exprs/UnresolvedMemberExpr.cs new file mode 100644 index 00000000..c5eddcdd --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/UnresolvedMemberExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class UnresolvedMemberExpr : OverloadExpr + { + internal UnresolvedMemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/UserDefinedLiteral.cs b/sources/ClangSharp/Cursors/Exprs/UserDefinedLiteral.cs new file mode 100644 index 00000000..b3446833 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/UserDefinedLiteral.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class UserDefinedLiteral : CallExpr + { + internal UserDefinedLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_UserDefinedLiteral) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Exprs/VAArgExpr.cs b/sources/ClangSharp/Cursors/Exprs/VAArgExpr.cs new file mode 100644 index 00000000..16d9d043 --- /dev/null +++ b/sources/ClangSharp/Cursors/Exprs/VAArgExpr.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class VAArgExpr : Expr + { + internal VAArgExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_VAArgExpr) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Preprocessings/PreprocessedEntity.cs b/sources/ClangSharp/Cursors/Preprocessings/PreprocessedEntity.cs index b6343e32..3f891590 100644 --- a/sources/ClangSharp/Cursors/Preprocessings/PreprocessedEntity.cs +++ b/sources/ClangSharp/Cursors/Preprocessings/PreprocessedEntity.cs @@ -7,7 +7,7 @@ namespace ClangSharp { public class PreprocessedEntity : Cursor { - private protected PreprocessedEntity(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected PreprocessedEntity(CXCursor handle, CXCursorKind expectedCursorKind) : base(handle, expectedCursorKind) { } diff --git a/sources/ClangSharp/Cursors/Preprocessings/PreprocessingDirective.cs b/sources/ClangSharp/Cursors/Preprocessings/PreprocessingDirective.cs index 5ebdb02d..c834d8e3 100644 --- a/sources/ClangSharp/Cursors/Preprocessings/PreprocessingDirective.cs +++ b/sources/ClangSharp/Cursors/Preprocessings/PreprocessingDirective.cs @@ -9,7 +9,7 @@ public class PreprocessingDirective : PreprocessedEntity internal PreprocessingDirective(CXCursor handle) : this(handle, CXCursorKind.CXCursor_PreprocessingDirective) { } - private protected PreprocessingDirective(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected PreprocessingDirective(CXCursor handle, CXCursorKind expectedCursorKind) : base(handle, expectedCursorKind) { } } diff --git a/sources/ClangSharp/Cursors/Refs/Ref.cs b/sources/ClangSharp/Cursors/Refs/Ref.cs index fcc2584e..334eddbd 100644 --- a/sources/ClangSharp/Cursors/Refs/Ref.cs +++ b/sources/ClangSharp/Cursors/Refs/Ref.cs @@ -10,7 +10,7 @@ public class Ref : Cursor { private readonly Lazy _type; - private protected Ref(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected Ref(CXCursor handle, CXCursorKind expectedCursorKind) : base(handle, expectedCursorKind) { _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); } diff --git a/sources/ClangSharp/Cursors/Stmts/AsmStmt.cs b/sources/ClangSharp/Cursors/Stmts/AsmStmt.cs index 4e7dc908..fdaf6714 100644 --- a/sources/ClangSharp/Cursors/Stmts/AsmStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/AsmStmt.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class AsmStmt : Stmt { - private protected AsmStmt(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected AsmStmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { + if ((CX_StmtClass.CX_StmtClass_LastAsmStmt < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstAsmStmt)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Stmts/AttributedStmt.cs b/sources/ClangSharp/Cursors/Stmts/AttributedStmt.cs new file mode 100644 index 00000000..18f44325 --- /dev/null +++ b/sources/ClangSharp/Cursors/Stmts/AttributedStmt.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class AttributedStmt : ValueStmt + { + internal AttributedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_AttributedStmt) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Stmts/BreakStmt.cs b/sources/ClangSharp/Cursors/Stmts/BreakStmt.cs index 1e18c653..4278d253 100644 --- a/sources/ClangSharp/Cursors/Stmts/BreakStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/BreakStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class BreakStmt : Stmt { - internal BreakStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BreakStmt) + internal BreakStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BreakStmt, CX_StmtClass.CX_StmtClass_BreakStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/CXXCatchStmt.cs b/sources/ClangSharp/Cursors/Stmts/CXXCatchStmt.cs index 9fa8c6a2..aef43f97 100644 --- a/sources/ClangSharp/Cursors/Stmts/CXXCatchStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CXXCatchStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXCatchStmt : Stmt { - internal CXXCatchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXCatchStmt) + internal CXXCatchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXCatchStmt, CX_StmtClass.CX_StmtClass_CXXCatchStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/CXXForRangeStmt.cs b/sources/ClangSharp/Cursors/Stmts/CXXForRangeStmt.cs index 54259c22..e994736b 100644 --- a/sources/ClangSharp/Cursors/Stmts/CXXForRangeStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CXXForRangeStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXForRangeStmt : Stmt { - internal CXXForRangeStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXForRangeStmt) + internal CXXForRangeStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXForRangeStmt, CX_StmtClass.CX_StmtClass_CXXForRangeStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/CXXTryStmt.cs b/sources/ClangSharp/Cursors/Stmts/CXXTryStmt.cs index 0a397f6b..776b0257 100644 --- a/sources/ClangSharp/Cursors/Stmts/CXXTryStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CXXTryStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CXXTryStmt : Stmt { - internal CXXTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXTryStmt) + internal CXXTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXTryStmt, CX_StmtClass.CX_StmtClass_CXXTryStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/CapturedStmt.cs b/sources/ClangSharp/Cursors/Stmts/CapturedStmt.cs new file mode 100644 index 00000000..42862ccd --- /dev/null +++ b/sources/ClangSharp/Cursors/Stmts/CapturedStmt.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CapturedStmt : Stmt + { + internal CapturedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_CapturedStmt) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Stmts/CaseStmt.cs b/sources/ClangSharp/Cursors/Stmts/CaseStmt.cs index 0ae1ff48..2248e215 100644 --- a/sources/ClangSharp/Cursors/Stmts/CaseStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CaseStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class CaseStmt : SwitchCase { - internal CaseStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CaseStmt) + internal CaseStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CaseStmt, CX_StmtClass.CX_StmtClass_CaseStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs b/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs index c6c181bd..c6fe500e 100644 --- a/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs @@ -7,7 +7,7 @@ namespace ClangSharp { public sealed class CompoundStmt : Stmt { - public CompoundStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundStmt) + public CompoundStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundStmt, CX_StmtClass.CX_StmtClass_CompoundStmt) { } diff --git a/sources/ClangSharp/Cursors/Stmts/ContinueStmt.cs b/sources/ClangSharp/Cursors/Stmts/ContinueStmt.cs index 6e9623ea..ff26ce42 100644 --- a/sources/ClangSharp/Cursors/Stmts/ContinueStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ContinueStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ContinueStmt : Stmt { - internal ContinueStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ContinueStmt) + internal ContinueStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ContinueStmt, CX_StmtClass.CX_StmtClass_ContinueStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/CoreturnStmt.cs b/sources/ClangSharp/Cursors/Stmts/CoreturnStmt.cs new file mode 100644 index 00000000..b2083f1e --- /dev/null +++ b/sources/ClangSharp/Cursors/Stmts/CoreturnStmt.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CoreturnStmt : Stmt + { + internal CoreturnStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_CoreturnStmt) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Stmts/CoroutineBodyStmt.cs b/sources/ClangSharp/Cursors/Stmts/CoroutineBodyStmt.cs new file mode 100644 index 00000000..2a77ca8b --- /dev/null +++ b/sources/ClangSharp/Cursors/Stmts/CoroutineBodyStmt.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class CoroutineBodyStmt : Stmt + { + internal CoroutineBodyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_CoroutineBodyStmt) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Stmts/DeclStmt.cs b/sources/ClangSharp/Cursors/Stmts/DeclStmt.cs index a706ebc5..fae8bac8 100644 --- a/sources/ClangSharp/Cursors/Stmts/DeclStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/DeclStmt.cs @@ -11,7 +11,7 @@ public sealed class DeclStmt : Stmt { private readonly Lazy> _decls; - internal DeclStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclStmt) + internal DeclStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclStmt, CX_StmtClass.CX_StmtClass_DeclStmt) { _decls = new Lazy>(() => CursorChildren.OfType().ToList()); } diff --git a/sources/ClangSharp/Cursors/Stmts/DefaultStmt.cs b/sources/ClangSharp/Cursors/Stmts/DefaultStmt.cs index 12b5f794..c6e6ad37 100644 --- a/sources/ClangSharp/Cursors/Stmts/DefaultStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/DefaultStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class DefaultStmt : SwitchCase { - internal DefaultStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DefaultStmt) + internal DefaultStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DefaultStmt, CX_StmtClass.CX_StmtClass_DefaultStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/DoStmt.cs b/sources/ClangSharp/Cursors/Stmts/DoStmt.cs index a19bed1f..bd82b86e 100644 --- a/sources/ClangSharp/Cursors/Stmts/DoStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/DoStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class DoStmt : Stmt { - internal DoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DoStmt) + internal DoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DoStmt, CX_StmtClass.CX_StmtClass_DoStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ForStmt.cs b/sources/ClangSharp/Cursors/Stmts/ForStmt.cs index 69c926fe..4fa4b713 100644 --- a/sources/ClangSharp/Cursors/Stmts/ForStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ForStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ForStmt : Stmt { - internal ForStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ForStmt) + internal ForStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ForStmt, CX_StmtClass.CX_StmtClass_ForStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/GCCAsmStmt.cs b/sources/ClangSharp/Cursors/Stmts/GCCAsmStmt.cs index 476f605f..42a536d7 100644 --- a/sources/ClangSharp/Cursors/Stmts/GCCAsmStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/GCCAsmStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class GCCAsmStmt : AsmStmt { - internal GCCAsmStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GCCAsmStmt) + internal GCCAsmStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GCCAsmStmt, CX_StmtClass.CX_StmtClass_GCCAsmStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/GotoStmt.cs b/sources/ClangSharp/Cursors/Stmts/GotoStmt.cs index 5a840376..25dd93a2 100644 --- a/sources/ClangSharp/Cursors/Stmts/GotoStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/GotoStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class GotoStmt : Stmt { - internal GotoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GotoStmt) + internal GotoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GotoStmt, CX_StmtClass.CX_StmtClass_GotoStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/IfStmt.cs b/sources/ClangSharp/Cursors/Stmts/IfStmt.cs index cf1ae5cc..cdead8d5 100644 --- a/sources/ClangSharp/Cursors/Stmts/IfStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/IfStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class IfStmt : Stmt { - internal IfStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IfStmt) + internal IfStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IfStmt, CX_StmtClass.CX_StmtClass_IfStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/IndirectGotoStmt.cs b/sources/ClangSharp/Cursors/Stmts/IndirectGotoStmt.cs index 9bbad19b..896d0d9a 100644 --- a/sources/ClangSharp/Cursors/Stmts/IndirectGotoStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/IndirectGotoStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class IndirectGotoStmt : Stmt { - internal IndirectGotoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IndirectGotoStmt) + internal IndirectGotoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IndirectGotoStmt, CX_StmtClass.CX_StmtClass_IndirectGotoStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/LabelStmt.cs b/sources/ClangSharp/Cursors/Stmts/LabelStmt.cs index 6262f426..d069544d 100644 --- a/sources/ClangSharp/Cursors/Stmts/LabelStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/LabelStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class LabelStmt : ValueStmt { - internal LabelStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LabelStmt) + internal LabelStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LabelStmt, CX_StmtClass.CX_StmtClass_LabelStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/MSAsmStmt.cs b/sources/ClangSharp/Cursors/Stmts/MSAsmStmt.cs index df879fb9..89fa610b 100644 --- a/sources/ClangSharp/Cursors/Stmts/MSAsmStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/MSAsmStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class MSAsmStmt : AsmStmt { - internal MSAsmStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MSAsmStmt) + internal MSAsmStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MSAsmStmt, CX_StmtClass.CX_StmtClass_MSAsmStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/MSDependentExistsStmt.cs b/sources/ClangSharp/Cursors/Stmts/MSDependentExistsStmt.cs new file mode 100644 index 00000000..5ca89519 --- /dev/null +++ b/sources/ClangSharp/Cursors/Stmts/MSDependentExistsStmt.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class MSDependentExistsStmt : Stmt + { + internal MSDependentExistsStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_MSDependentExistsStmt) + { + } + } +} diff --git a/sources/ClangSharp/Cursors/Stmts/NullStmt.cs b/sources/ClangSharp/Cursors/Stmts/NullStmt.cs index 95636f1c..eda7a900 100644 --- a/sources/ClangSharp/Cursors/Stmts/NullStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/NullStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class NullStmt : Stmt { - internal NullStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NullStmt) + internal NullStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NullStmt, CX_StmtClass.CX_StmtClass_NullStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPAtomicDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPAtomicDirective.cs index ec35c564..bbcdeec1 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPAtomicDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPAtomicDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPAtomicDirective : OMPExecutableDirective { - internal OMPAtomicDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPAtomicDirective) + internal OMPAtomicDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPAtomicDirective, CX_StmtClass.CX_StmtClass_OMPAtomicDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPBarrierDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPBarrierDirective.cs index a1695b6a..90f749b4 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPBarrierDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPBarrierDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPBarrierDirective : OMPExecutableDirective { - internal OMPBarrierDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPBarrierDirective) + internal OMPBarrierDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPBarrierDirective, CX_StmtClass.CX_StmtClass_OMPBarrierDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPCancelDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPCancelDirective.cs index 18a8a6ec..b6bc2697 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPCancelDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPCancelDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPCancelDirective : OMPExecutableDirective { - internal OMPCancelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCancelDirective) + internal OMPCancelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCancelDirective, CX_StmtClass.CX_StmtClass_OMPCancelDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPCancellationPointDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPCancellationPointDirective.cs index b18a79cc..14e3b620 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPCancellationPointDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPCancellationPointDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPCancellationPointDirective : OMPExecutableDirective { - internal OMPCancellationPointDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCancellationPointDirective) + internal OMPCancellationPointDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCancellationPointDirective, CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPCriticalDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPCriticalDirective.cs index 73637229..d97bc024 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPCriticalDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPCriticalDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPCriticalDirective : OMPExecutableDirective { - internal OMPCriticalDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCriticalDirective) + internal OMPCriticalDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCriticalDirective, CX_StmtClass.CX_StmtClass_OMPCriticalDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDistributeDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDistributeDirective.cs index 2e549ca7..d5158618 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDistributeDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDistributeDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPDistributeDirective : OMPLoopDirective { - internal OMPDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeDirective) + internal OMPDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeDirective, CX_StmtClass.CX_StmtClass_OMPDistributeDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForDirective.cs index 97bdc695..db455158 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPDistributeParallelForDirective : OMPLoopDirective { - internal OMPDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeParallelForDirective) + internal OMPDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeParallelForDirective, CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForSimdDirective.cs index 53faf9a1..ca3a8e1e 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPDistributeParallelForSimdDirective : OMPLoopDirective { - internal OMPDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeParallelForSimdDirective) + internal OMPDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDistributeSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDistributeSimdDirective.cs index 3f01025e..08533074 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDistributeSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDistributeSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPDistributeSimdDirective : OMPLoopDirective { - internal OMPDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeSimdDirective) + internal OMPDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeSimdDirective, CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPExecutableDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPExecutableDirective.cs index d3b9c70f..53244b68 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPExecutableDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPExecutableDirective.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class OMPExecutableDirective : Stmt { - private protected OMPExecutableDirective(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected OMPExecutableDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { + if ((CX_StmtClass.CX_StmtClass_LastOMPExecutableDirective < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstOMPExecutableDirective)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPFlushDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPFlushDirective.cs index f4258d35..0619ab0a 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPFlushDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPFlushDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPFlushDirective : OMPExecutableDirective { - internal OMPFlushDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPFlushDirective) + internal OMPFlushDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPFlushDirective, CX_StmtClass.CX_StmtClass_OMPFlushDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPForDirective.cs index 2a5c9826..694dd0cf 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPForDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPForDirective : OMPLoopDirective { - internal OMPForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPForDirective) + internal OMPForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPForDirective, CX_StmtClass.CX_StmtClass_OMPForDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPForSimdDirective.cs index 0b247a59..24d3a67c 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPForSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPForSimdDirective : OMPLoopDirective { - internal OMPForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPForSimdDirective) + internal OMPForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPForSimdDirective, CX_StmtClass.CX_StmtClass_OMPForSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPLoopDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPLoopDirective.cs index 4c9c0086..17243ef1 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPLoopDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPLoopDirective.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class OMPLoopDirective : OMPExecutableDirective { - private protected OMPLoopDirective(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected OMPLoopDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { + if ((CX_StmtClass.CX_StmtClass_LastOMPLoopDirective < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstOMPLoopDirective)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPMasterDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPMasterDirective.cs index ce3830f9..e09909c1 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPMasterDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPMasterDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPMasterDirective : OMPExecutableDirective { - internal OMPMasterDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMasterDirective) + internal OMPMasterDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMasterDirective, CX_StmtClass.CX_StmtClass_OMPMasterDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPOrderedDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPOrderedDirective.cs index 211617f3..81b86e60 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPOrderedDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPOrderedDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPOrderedDirective : OMPExecutableDirective { - internal OMPOrderedDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPOrderedDirective) + internal OMPOrderedDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPOrderedDirective, CX_StmtClass.CX_StmtClass_OMPOrderedDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelDirective.cs index f396d336..3a031868 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPParallelDirective : OMPExecutableDirective { - internal OMPParallelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelDirective) + internal OMPParallelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelDirective, CX_StmtClass.CX_StmtClass_OMPParallelDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelForDirective.cs index 3665e7df..a3ae1aed 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelForDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPParallelForDirective : OMPLoopDirective { - internal OMPParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelForDirective) + internal OMPParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelForDirective, CX_StmtClass.CX_StmtClass_OMPParallelForDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelForSimdDirective.cs index fe1f8724..bea924da 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelForSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPParallelForSimdDirective : OMPLoopDirective { - internal OMPParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelForSimdDirective) + internal OMPParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelSectionsDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelSectionsDirective.cs index e6e81a1c..44c346bd 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelSectionsDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelSectionsDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPParallelSectionsDirective : OMPExecutableDirective { - internal OMPParallelSectionsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelSectionsDirective) + internal OMPParallelSectionsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelSectionsDirective, CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPSectionDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPSectionDirective.cs index 4cf9866c..0703277f 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPSectionDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPSectionDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPSectionDirective : OMPExecutableDirective { - internal OMPSectionDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSectionDirective) + internal OMPSectionDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSectionDirective, CX_StmtClass.CX_StmtClass_OMPSectionDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPSectionsDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPSectionsDirective.cs index 5f86fee6..9b3d0dca 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPSectionsDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPSectionsDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPSectionsDirective : OMPExecutableDirective { - internal OMPSectionsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSectionsDirective) + internal OMPSectionsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSectionsDirective, CX_StmtClass.CX_StmtClass_OMPSectionsDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPSimdDirective.cs index 4505c4dd..76359ffc 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPSimdDirective : OMPLoopDirective { - internal OMPSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSimdDirective) + internal OMPSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSimdDirective, CX_StmtClass.CX_StmtClass_OMPSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPSingleDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPSingleDirective.cs index f36bd7ed..0edc3ecf 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPSingleDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPSingleDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPSingleDirective : OMPExecutableDirective { - internal OMPSingleDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSingleDirective) + internal OMPSingleDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSingleDirective, CX_StmtClass.CX_StmtClass_OMPSingleDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetDataDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetDataDirective.cs index 5c8c254e..ffc3163a 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetDataDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetDataDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetDataDirective : OMPExecutableDirective { - internal OMPTargetDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetDataDirective) + internal OMPTargetDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetDataDirective, CX_StmtClass.CX_StmtClass_OMPTargetDataDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetDirective.cs index a02c1b83..db5513fc 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetDirective : OMPExecutableDirective { - internal OMPTargetDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetDirective) + internal OMPTargetDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetDirective, CX_StmtClass.CX_StmtClass_OMPTargetDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetEnterDataDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetEnterDataDirective.cs index 23cc7fb9..954ec93b 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetEnterDataDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetEnterDataDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetEnterDataDirective : OMPExecutableDirective { - internal OMPTargetEnterDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetEnterDataDirective) + internal OMPTargetEnterDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetEnterDataDirective, CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetExitDataDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetExitDataDirective.cs index 08e7261a..911be29e 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetExitDataDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetExitDataDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetExitDataDirective : OMPExecutableDirective { - internal OMPTargetExitDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetExitDataDirective) + internal OMPTargetExitDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetExitDataDirective, CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelDirective.cs index 82c0fab9..a77fb47c 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetParallelDirective : OMPExecutableDirective { - internal OMPTargetParallelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelDirective) + internal OMPTargetParallelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelDirective, CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForDirective.cs index 2e471da4..a76efc72 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetParallelForDirective : OMPLoopDirective { - internal OMPTargetParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelForDirective) + internal OMPTargetParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelForDirective, CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForSimdDirective.cs index 9566054c..567c8f6c 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetParallelForSimdDirective : OMPLoopDirective { - internal OMPTargetParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelForSimdDirective) + internal OMPTargetParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetSimdDirective.cs index 031ac7f2..a41d3880 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetSimdDirective : OMPLoopDirective { - internal OMPTargetSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetSimdDirective) + internal OMPTargetSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDirective.cs index c616ba9c..7cd09ab3 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetTeamsDirective : OMPExecutableDirective { - internal OMPTargetTeamsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDirective) + internal OMPTargetTeamsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeDirective.cs index dba5baa3..2635043a 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetTeamsDistributeDirective : OMPLoopDirective { - internal OMPTargetTeamsDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeDirective) + internal OMPTargetTeamsDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForDirective.cs index 7f5c26ec..697539af 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetTeamsDistributeParallelForDirective : OMPLoopDirective { - internal OMPTargetTeamsDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForDirective) + internal OMPTargetTeamsDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForSimdDirective.cs index 1957c13d..f7273bd9 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetTeamsDistributeParallelForSimdDirective : OMPLoopDirective { - internal OMPTargetTeamsDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective) + internal OMPTargetTeamsDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeSimdDirective.cs index 1faa48a7..cc67b71f 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetTeamsDistributeSimdDirective : OMPLoopDirective { - internal OMPTargetTeamsDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeSimdDirective) + internal OMPTargetTeamsDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetUpdateDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetUpdateDirective.cs index 91409c99..8d8007c3 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetUpdateDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetUpdateDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTargetUpdateDirective : OMPExecutableDirective { - internal OMPTargetUpdateDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetUpdateDirective) + internal OMPTargetUpdateDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetUpdateDirective, CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskDirective.cs index 054da20a..5e14a4b6 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTaskDirective : OMPExecutableDirective { - internal OMPTaskDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskDirective) + internal OMPTaskDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskDirective, CX_StmtClass.CX_StmtClass_OMPTaskDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopDirective.cs index c19600a9..7f42152c 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTaskLoopDirective : OMPLoopDirective { - internal OMPTaskLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskLoopDirective) + internal OMPTaskLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskLoopDirective, CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopSimdDirective.cs index f77fb401..f8df1d43 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTaskLoopSimdDirective : OMPLoopDirective { - internal OMPTaskLoopSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskLoopSimdDirective) + internal OMPTaskLoopSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskLoopSimdDirective, CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskgroupDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskgroupDirective.cs index 66d93566..7a22206f 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskgroupDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskgroupDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTaskgroupDirective : OMPExecutableDirective { - internal OMPTaskgroupDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskgroupDirective) + internal OMPTaskgroupDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskgroupDirective, CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskwaitDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskwaitDirective.cs index 68ac1f0c..09b21b4f 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskwaitDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskwaitDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTaskwaitDirective : OMPExecutableDirective { - internal OMPTaskwaitDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskwaitDirective) + internal OMPTaskwaitDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskwaitDirective, CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskyieldDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskyieldDirective.cs index 0b5242b8..343ef61c 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskyieldDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskyieldDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTaskyieldDirective : OMPExecutableDirective { - internal OMPTaskyieldDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskyieldDirective) + internal OMPTaskyieldDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskyieldDirective, CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDirective.cs index 29e42e72..aed4d68d 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTeamsDirective : OMPExecutableDirective { - internal OMPTeamsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDirective) + internal OMPTeamsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeDirective.cs index 943a1e32..6a89a87d 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTeamsDistributeDirective : OMPLoopDirective { - internal OMPTeamsDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeDirective) + internal OMPTeamsDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForDirective.cs index e22bd5ad..110f0b86 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTeamsDistributeParallelForDirective : OMPLoopDirective { - internal OMPTeamsDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeParallelForDirective) + internal OMPTeamsDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeParallelForDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForSimdDirective.cs index 9da916fb..8c1f911e 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTeamsDistributeParallelForSimdDirective : OMPLoopDirective { - internal OMPTeamsDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeParallelForSimdDirective) + internal OMPTeamsDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeSimdDirective.cs index f306546b..7b8d4cd4 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeSimdDirective.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class OMPTeamsDistributeSimdDirective : OMPLoopDirective { - internal OMPTeamsDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeSimdDirective) + internal OMPTeamsDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeSimdDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtCatchStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtCatchStmt.cs index 072cc257..3d6733dc 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtCatchStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtCatchStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCAtCatchStmt : Stmt { - internal ObjCAtCatchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtCatchStmt) + internal ObjCAtCatchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtCatchStmt, CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtFinallyStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtFinallyStmt.cs index 04d96242..d2b70ae1 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtFinallyStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtFinallyStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCAtFinallyStmt : Stmt { - internal ObjCAtFinallyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtFinallyStmt) + internal ObjCAtFinallyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtFinallyStmt, CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtSynchronizedStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtSynchronizedStmt.cs index 8238bec6..9cfe653f 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtSynchronizedStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtSynchronizedStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCAtSynchronizedStmt : Stmt { - internal ObjCAtSynchronizedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtSynchronizedStmt) + internal ObjCAtSynchronizedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtSynchronizedStmt, CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtThrowStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtThrowStmt.cs index 78d8de5c..f6174013 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtThrowStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtThrowStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCAtThrowStmt : Stmt { - internal ObjCAtThrowStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtThrowStmt) + internal ObjCAtThrowStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtThrowStmt, CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs index e4f3747b..f2651b0e 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCAtTryStmt : Stmt { - internal ObjCAtTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtTryStmt) + internal ObjCAtTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtTryStmt, CX_StmtClass.CX_StmtClass_ObjCAtTryStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAutoreleasePoolStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAutoreleasePoolStmt.cs index e84d8a2f..3bc02e34 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAutoreleasePoolStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAutoreleasePoolStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCAutoreleasePoolStmt : Stmt { - internal ObjCAutoreleasePoolStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAutoreleasePoolStmt) + internal ObjCAutoreleasePoolStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAutoreleasePoolStmt, CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCForCollectionStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCForCollectionStmt.cs index 113a87bb..4a57ac40 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCForCollectionStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCForCollectionStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ObjCForCollectionStmt : Stmt { - internal ObjCForCollectionStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCForCollectionStmt) + internal ObjCForCollectionStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCForCollectionStmt, CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ReturnStmt.cs b/sources/ClangSharp/Cursors/Stmts/ReturnStmt.cs index ee61a784..7ec91e8d 100644 --- a/sources/ClangSharp/Cursors/Stmts/ReturnStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ReturnStmt.cs @@ -10,7 +10,7 @@ public sealed class ReturnStmt : Stmt { private readonly Lazy _retValue; - internal ReturnStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ReturnStmt) + internal ReturnStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ReturnStmt, CX_StmtClass.CX_StmtClass_ReturnStmt) { _retValue = new Lazy(() => Children.OfType().Single()); } diff --git a/sources/ClangSharp/Cursors/Stmts/SEHExceptStmt.cs b/sources/ClangSharp/Cursors/Stmts/SEHExceptStmt.cs index 70a2798c..23ac58bd 100644 --- a/sources/ClangSharp/Cursors/Stmts/SEHExceptStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SEHExceptStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class SEHExceptStmt : Stmt { - internal SEHExceptStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHExceptStmt) + internal SEHExceptStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHExceptStmt, CX_StmtClass.CX_StmtClass_SEHExceptStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/SEHFinallyStmt.cs b/sources/ClangSharp/Cursors/Stmts/SEHFinallyStmt.cs index 1b1b74cc..277ebb49 100644 --- a/sources/ClangSharp/Cursors/Stmts/SEHFinallyStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SEHFinallyStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class SEHFinallyStmt : Stmt { - internal SEHFinallyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHFinallyStmt) + internal SEHFinallyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHFinallyStmt, CX_StmtClass.CX_StmtClass_SEHFinallyStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/SEHLeaveStmt.cs b/sources/ClangSharp/Cursors/Stmts/SEHLeaveStmt.cs index d797c5fc..f95318ad 100644 --- a/sources/ClangSharp/Cursors/Stmts/SEHLeaveStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SEHLeaveStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class SEHLeaveStmt : Stmt { - internal SEHLeaveStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHLeaveStmt) + internal SEHLeaveStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHLeaveStmt, CX_StmtClass.CX_StmtClass_SEHLeaveStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/SEHTryStmt.cs b/sources/ClangSharp/Cursors/Stmts/SEHTryStmt.cs index fd6e0b86..5fc9d1c9 100644 --- a/sources/ClangSharp/Cursors/Stmts/SEHTryStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SEHTryStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class SEHTryStmt : Stmt { - internal SEHTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHTryStmt) + internal SEHTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHTryStmt, CX_StmtClass.CX_StmtClass_SEHTryStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/Stmt.cs b/sources/ClangSharp/Cursors/Stmts/Stmt.cs index 0c36399e..2aae49e6 100644 --- a/sources/ClangSharp/Cursors/Stmts/Stmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/Stmt.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using ClangSharp.Interop; @@ -12,514 +11,221 @@ public class Stmt : Cursor { private readonly Lazy> _children; - private protected Stmt(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind) { + if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass)) + { + throw new ArgumentException(nameof(handle)); + } + _children = new Lazy>(() => CursorChildren.OfType().ToList()); } public IReadOnlyList Children => _children.Value; - internal static new Stmt Create(CXCursor handle) - { - Stmt result; - - switch (handle.Kind) - { - case CXCursorKind.CXCursor_UnexposedStmt: - { - result = new Stmt(handle, handle.Kind); - break; - } - - case CXCursorKind.CXCursor_LabelStmt: - { - result = new LabelStmt(handle); - break; - } - - case CXCursorKind.CXCursor_CompoundStmt: - { - result = new CompoundStmt(handle); - break; - } - - case CXCursorKind.CXCursor_CaseStmt: - { - result = new CaseStmt(handle); - break; - } - - case CXCursorKind.CXCursor_DefaultStmt: - { - result = new DefaultStmt(handle); - break; - } - - case CXCursorKind.CXCursor_IfStmt: - { - result = new IfStmt(handle); - break; - } - - case CXCursorKind.CXCursor_SwitchStmt: - { - result = new SwitchStmt(handle); - break; - } - - case CXCursorKind.CXCursor_WhileStmt: - { - result = new WhileStmt(handle); - break; - } - - case CXCursorKind.CXCursor_DoStmt: - { - result = new DoStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ForStmt: - { - result = new ForStmt(handle); - break; - } - - case CXCursorKind.CXCursor_GotoStmt: - { - result = new GotoStmt(handle); - break; - } - - case CXCursorKind.CXCursor_IndirectGotoStmt: - { - result = new IndirectGotoStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ContinueStmt: - { - result = new ContinueStmt(handle); - break; - } - - case CXCursorKind.CXCursor_BreakStmt: - { - result = new BreakStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ReturnStmt: - { - result = new ReturnStmt(handle); - break; - } - - case CXCursorKind.CXCursor_GCCAsmStmt: - { - result = new GCCAsmStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCAtTryStmt: - { - result = new ObjCAtTryStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCAtCatchStmt: - { - result = new ObjCAtCatchStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCAtFinallyStmt: - { - result = new ObjCAtFinallyStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCAtThrowStmt: - { - result = new ObjCAtThrowStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCAtSynchronizedStmt: - { - result = new ObjCAtSynchronizedStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCAutoreleasePoolStmt: - { - result = new ObjCAutoreleasePoolStmt(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCForCollectionStmt: - { - result = new ObjCForCollectionStmt(handle); - break; - } - - case CXCursorKind.CXCursor_CXXCatchStmt: - { - result = new CXXCatchStmt(handle); - break; - } - - case CXCursorKind.CXCursor_CXXTryStmt: - { - result = new CXXTryStmt(handle); - break; - } - - case CXCursorKind.CXCursor_CXXForRangeStmt: - { - result = new CXXForRangeStmt(handle); - break; - } - - case CXCursorKind.CXCursor_SEHTryStmt: - { - result = new SEHTryStmt(handle); - break; - } - - case CXCursorKind.CXCursor_SEHExceptStmt: - { - result = new SEHExceptStmt(handle); - break; - } - - case CXCursorKind.CXCursor_SEHFinallyStmt: - { - result = new SEHFinallyStmt(handle); - break; - } - - case CXCursorKind.CXCursor_MSAsmStmt: - { - result = new MSAsmStmt(handle); - break; - } - - case CXCursorKind.CXCursor_NullStmt: - { - result = new NullStmt(handle); - break; - } - - case CXCursorKind.CXCursor_DeclStmt: - { - result = new DeclStmt(handle); - break; - } - - case CXCursorKind.CXCursor_OMPParallelDirective: - { - result = new OMPParallelDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPSimdDirective: - { - result = new OMPSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPForDirective: - { - result = new OMPForDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPSectionsDirective: - { - result = new OMPSectionsDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPSectionDirective: - { - result = new OMPSectionDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPSingleDirective: - { - result = new OMPSingleDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPParallelForDirective: - { - result = new OMPParallelForDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPParallelSectionsDirective: - { - result = new OMPParallelSectionsDirective(handle); - break; - } + public CX_StmtClass StmtClass => Handle.StmtClass; - case CXCursorKind.CXCursor_OMPTaskDirective: - { - result = new OMPTaskDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPMasterDirective: - { - result = new OMPMasterDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPCriticalDirective: - { - result = new OMPCriticalDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTaskyieldDirective: - { - result = new OMPTaskyieldDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPBarrierDirective: - { - result = new OMPBarrierDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTaskwaitDirective: - { - result = new OMPTaskwaitDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPFlushDirective: - { - result = new OMPFlushDirective(handle); - break; - } - - case CXCursorKind.CXCursor_SEHLeaveStmt: - { - result = new SEHLeaveStmt(handle); - break; - } - - case CXCursorKind.CXCursor_OMPOrderedDirective: - { - result = new OMPOrderedDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPAtomicDirective: - { - result = new OMPAtomicDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPForSimdDirective: - { - result = new OMPForSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPParallelForSimdDirective: - { - result = new OMPParallelForSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetDirective: - { - result = new OMPTargetDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTeamsDirective: - { - result = new OMPTeamsDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTaskgroupDirective: - { - result = new OMPTaskgroupDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPCancellationPointDirective: - { - result = new OMPCancellationPointDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPCancelDirective: - { - result = new OMPCancelDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetDataDirective: - { - result = new OMPTargetDataDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTaskLoopDirective: - { - result = new OMPTaskLoopDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTaskLoopSimdDirective: - { - result = new OMPTaskLoopSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPDistributeDirective: - { - result = new OMPDistributeDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetEnterDataDirective: - { - result = new OMPTargetEnterDataDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetExitDataDirective: - { - result = new OMPTargetExitDataDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetParallelDirective: - { - result = new OMPTargetParallelDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetParallelForDirective: - { - result = new OMPTargetParallelForDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetUpdateDirective: - { - result = new OMPTargetUpdateDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPDistributeParallelForDirective: - { - result = new OMPDistributeParallelForDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPDistributeParallelForSimdDirective: - { - result = new OMPDistributeParallelForSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPDistributeSimdDirective: - { - result = new OMPDistributeSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetParallelForSimdDirective: - { - result = new OMPTargetParallelForSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetSimdDirective: - { - result = new OMPTargetSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTeamsDistributeDirective: - { - result = new OMPTeamsDistributeDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTeamsDistributeSimdDirective: - { - result = new OMPTeamsDistributeSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTeamsDistributeParallelForSimdDirective: - { - result = new OMPTeamsDistributeParallelForSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTeamsDistributeParallelForDirective: - { - result = new OMPTeamsDistributeParallelForDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetTeamsDirective: - { - result = new OMPTargetTeamsDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetTeamsDistributeDirective: - { - result = new OMPTargetTeamsDistributeDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForDirective: - { - result = new OMPTargetTeamsDistributeParallelForDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective: - { - result = new OMPTargetTeamsDistributeParallelForSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_OMPTargetTeamsDistributeSimdDirective: - { - result = new OMPTargetTeamsDistributeSimdDirective(handle); - break; - } - - case CXCursorKind.CXCursor_BuiltinBitCastExpr: - { - result = new BuiltinBitCastExpr(handle); - break; - } - - default: - { - Debug.WriteLine($"Unhandled statement kind: {handle.KindSpelling}."); - result = new Stmt(handle, handle.Kind); - break; - } - } - - return result; - } + internal static new Stmt Create(CXCursor handle) => handle.StmtClass switch + { + CX_StmtClass.CX_StmtClass_GCCAsmStmt => new GCCAsmStmt(handle), + CX_StmtClass.CX_StmtClass_MSAsmStmt => new MSAsmStmt(handle), + CX_StmtClass.CX_StmtClass_BreakStmt => new BreakStmt(handle), + CX_StmtClass.CX_StmtClass_CXXCatchStmt => new CXXCatchStmt(handle), + CX_StmtClass.CX_StmtClass_CXXForRangeStmt => new CXXForRangeStmt(handle), + CX_StmtClass.CX_StmtClass_CXXTryStmt => new CXXTryStmt(handle), + CX_StmtClass.CX_StmtClass_CapturedStmt => new CapturedStmt(handle), + CX_StmtClass.CX_StmtClass_CompoundStmt => new CompoundStmt(handle), + CX_StmtClass.CX_StmtClass_ContinueStmt => new ContinueStmt(handle), + CX_StmtClass.CX_StmtClass_CoreturnStmt => new CoreturnStmt(handle), + CX_StmtClass.CX_StmtClass_CoroutineBodyStmt => new CoroutineBodyStmt(handle), + CX_StmtClass.CX_StmtClass_DeclStmt => new DeclStmt(handle), + CX_StmtClass.CX_StmtClass_DoStmt => new DoStmt(handle), + CX_StmtClass.CX_StmtClass_ForStmt => new ForStmt(handle), + CX_StmtClass.CX_StmtClass_GotoStmt => new GotoStmt(handle), + CX_StmtClass.CX_StmtClass_IfStmt => new IfStmt(handle), + CX_StmtClass.CX_StmtClass_IndirectGotoStmt => new IndirectGotoStmt(handle), + CX_StmtClass.CX_StmtClass_MSDependentExistsStmt => new MSDependentExistsStmt(handle), + CX_StmtClass.CX_StmtClass_NullStmt => new NullStmt(handle), + CX_StmtClass.CX_StmtClass_OMPAtomicDirective => new OMPAtomicDirective(handle), + CX_StmtClass.CX_StmtClass_OMPBarrierDirective => new OMPBarrierDirective(handle), + CX_StmtClass.CX_StmtClass_OMPCancelDirective => new OMPCancelDirective(handle), + CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective => new OMPCancellationPointDirective(handle), + CX_StmtClass.CX_StmtClass_OMPCriticalDirective => new OMPCriticalDirective(handle), + CX_StmtClass.CX_StmtClass_OMPFlushDirective => new OMPFlushDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDistributeDirective => new OMPDistributeDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective => new OMPDistributeParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective => new OMPDistributeParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective => new OMPDistributeSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPForDirective => new OMPForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPForSimdDirective => new OMPForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelForDirective => new OMPParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective => new OMPParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPSimdDirective => new OMPSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective => new OMPTargetParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective => new OMPTargetSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective => new OMPTargetTeamsDistributeDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective => new OMPTargetTeamsDistributeParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective => new OMPTargetTeamsDistributeParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective => new OMPTargetTeamsDistributeSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective => new OMPTaskLoopDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective => new OMPTaskLoopSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective => new OMPTeamsDistributeDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective => new OMPTeamsDistributeParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective => new OMPTeamsDistributeParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective => new OMPTeamsDistributeSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPMasterDirective => new OMPMasterDirective(handle), + CX_StmtClass.CX_StmtClass_OMPOrderedDirective => new OMPOrderedDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelDirective => new OMPParallelDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective => new OMPParallelSectionsDirective(handle), + CX_StmtClass.CX_StmtClass_OMPSectionDirective => new OMPSectionDirective(handle), + CX_StmtClass.CX_StmtClass_OMPSectionsDirective => new OMPSectionsDirective(handle), + CX_StmtClass.CX_StmtClass_OMPSingleDirective => new OMPSingleDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetDataDirective => new OMPTargetDataDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetDirective => new OMPTargetDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective => new OMPTargetEnterDataDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective => new OMPTargetExitDataDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective => new OMPTargetParallelDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective => new OMPTargetParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective => new OMPTargetTeamsDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective => new OMPTargetUpdateDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskDirective => new OMPTaskDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective => new OMPTaskgroupDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective => new OMPTaskwaitDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective => new OMPTaskyieldDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDirective => new OMPTeamsDirective(handle), + CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt => new ObjCAtCatchStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt => new ObjCAtFinallyStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt => new ObjCAtSynchronizedStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt => new ObjCAtThrowStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAtTryStmt => new ObjCAtTryStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt => new ObjCAutoreleasePoolStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt => new ObjCForCollectionStmt(handle), + CX_StmtClass.CX_StmtClass_ReturnStmt => new ReturnStmt(handle), + CX_StmtClass.CX_StmtClass_SEHExceptStmt => new SEHExceptStmt(handle), + CX_StmtClass.CX_StmtClass_SEHFinallyStmt => new SEHFinallyStmt(handle), + CX_StmtClass.CX_StmtClass_SEHLeaveStmt => new SEHLeaveStmt(handle), + CX_StmtClass.CX_StmtClass_SEHTryStmt => new SEHTryStmt(handle), + CX_StmtClass.CX_StmtClass_CaseStmt => new CaseStmt(handle), + CX_StmtClass.CX_StmtClass_DefaultStmt => new DefaultStmt(handle), + CX_StmtClass.CX_StmtClass_SwitchStmt => new SwitchStmt(handle), + CX_StmtClass.CX_StmtClass_AttributedStmt => new AttributedStmt(handle), + CX_StmtClass.CX_StmtClass_BinaryConditionalOperator => new BinaryConditionalOperator(handle), + CX_StmtClass.CX_StmtClass_ConditionalOperator => new ConditionalOperator(handle), + CX_StmtClass.CX_StmtClass_AddrLabelExpr => new AddrLabelExpr(handle), + CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr => new ArrayInitIndexExpr(handle), + CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr => new ArrayInitLoopExpr(handle), + CX_StmtClass.CX_StmtClass_ArraySubscriptExpr => new ArraySubscriptExpr(handle), + CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr => new ArrayTypeTraitExpr(handle), + CX_StmtClass.CX_StmtClass_AsTypeExpr => new AsTypeExpr(handle), + CX_StmtClass.CX_StmtClass_AtomicExpr => new AtomicExpr(handle), + CX_StmtClass.CX_StmtClass_BinaryOperator => new BinaryOperator(handle), + CX_StmtClass.CX_StmtClass_CompoundAssignOperator => new CompoundAssignOperator(handle), + CX_StmtClass.CX_StmtClass_BlockExpr => new BlockExpr(handle), + CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr => new CXXBindTemporaryExpr(handle), + CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr => new CXXBoolLiteralExpr(handle), + CX_StmtClass.CX_StmtClass_CXXConstructExpr => new CXXConstructExpr(handle), + CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr => new CXXTemporaryObjectExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr => new CXXDefaultArgExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr => new CXXDefaultInitExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDeleteExpr => new CXXDeleteExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr => new CXXDependentScopeMemberExpr(handle), + CX_StmtClass.CX_StmtClass_CXXFoldExpr => new CXXFoldExpr(handle), + CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr => new CXXInheritedCtorInitExpr(handle), + CX_StmtClass.CX_StmtClass_CXXNewExpr => new CXXNewExpr(handle), + CX_StmtClass.CX_StmtClass_CXXNoexceptExpr => new CXXNoexceptExpr(handle), + CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr => new CXXNullPtrLiteralExpr(handle), + CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr => new CXXPseudoDestructorExpr(handle), + CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr => new CXXScalarValueInitExpr(handle), + CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr => new CXXStdInitializerListExpr(handle), + CX_StmtClass.CX_StmtClass_CXXThisExpr => new CXXThisExpr(handle), + CX_StmtClass.CX_StmtClass_CXXThrowExpr => new CXXThrowExpr(handle), + CX_StmtClass.CX_StmtClass_CXXTypeidExpr => new CXXTypeidExpr(handle), + CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr => new CXXUnresolvedConstructExpr(handle), + CX_StmtClass.CX_StmtClass_CXXUuidofExpr => new CXXUuidofExpr(handle), + CX_StmtClass.CX_StmtClass_CallExpr => new CallExpr(handle), + CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr => new CUDAKernelCallExpr(handle), + CX_StmtClass.CX_StmtClass_CXXMemberCallExpr => new CXXMemberCallExpr(handle), + CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr => new CXXOperatorCallExpr(handle), + CX_StmtClass.CX_StmtClass_UserDefinedLiteral => new UserDefinedLiteral(handle), + CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr => new BuiltinBitCastExpr(handle), + CX_StmtClass.CX_StmtClass_CStyleCastExpr => new CStyleCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr => new CXXFunctionalCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXConstCastExpr => new CXXConstCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr => new CXXDynamicCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr => new CXXReinterpretCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXStaticCastExpr => new CXXStaticCastExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr => new ObjCBridgedCastExpr(handle), + CX_StmtClass.CX_StmtClass_ImplicitCastExpr => new ImplicitCastExpr(handle), + CX_StmtClass.CX_StmtClass_CharacterLiteral => new CharacterLiteral(handle), + CX_StmtClass.CX_StmtClass_ChooseExpr => new ChooseExpr(handle), + CX_StmtClass.CX_StmtClass_CompoundLiteralExpr => new CompoundLiteralExpr(handle), + CX_StmtClass.CX_StmtClass_ConvertVectorExpr => new ConvertVectorExpr(handle), + CX_StmtClass.CX_StmtClass_CoawaitExpr => new CoawaitExpr(handle), + CX_StmtClass.CX_StmtClass_CoyieldExpr => new CoyieldExpr(handle), + CX_StmtClass.CX_StmtClass_DeclRefExpr => new DeclRefExpr(handle), + CX_StmtClass.CX_StmtClass_DependentCoawaitExpr => new DependentCoawaitExpr(handle), + CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr => new DependentScopeDeclRefExpr(handle), + CX_StmtClass.CX_StmtClass_DesignatedInitExpr => new DesignatedInitExpr(handle), + CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr => new DesignatedInitUpdateExpr(handle), + CX_StmtClass.CX_StmtClass_ExpressionTraitExpr => new ExpressionTraitExpr(handle), + CX_StmtClass.CX_StmtClass_ExtVectorElementExpr => new ExtVectorElementExpr(handle), + CX_StmtClass.CX_StmtClass_FixedPointLiteral => new FixedPointLiteral(handle), + CX_StmtClass.CX_StmtClass_FloatingLiteral => new FloatingLiteral(handle), + CX_StmtClass.CX_StmtClass_ConstantExpr => new ConstantExpr(handle), + CX_StmtClass.CX_StmtClass_ExprWithCleanups => new ExprWithCleanups(handle), + CX_StmtClass.CX_StmtClass_FunctionParmPackExpr => new FunctionParmPackExpr(handle), + CX_StmtClass.CX_StmtClass_GNUNullExpr => new GNUNullExpr(handle), + CX_StmtClass.CX_StmtClass_GenericSelectionExpr => new GenericSelectionExpr(handle), + CX_StmtClass.CX_StmtClass_ImaginaryLiteral => new ImaginaryLiteral(handle), + CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr => new ImplicitValueInitExpr(handle), + CX_StmtClass.CX_StmtClass_InitListExpr => new InitListExpr(handle), + CX_StmtClass.CX_StmtClass_IntegerLiteral => new IntegerLiteral(handle), + CX_StmtClass.CX_StmtClass_LambdaExpr => new LambdaExpr(handle), + CX_StmtClass.CX_StmtClass_MSPropertyRefExpr => new MSPropertyRefExpr(handle), + CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr => new MSPropertySubscriptExpr(handle), + CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr => new MaterializeTemporaryExpr(handle), + CX_StmtClass.CX_StmtClass_MemberExpr => new MemberExpr(handle), + CX_StmtClass.CX_StmtClass_NoInitExpr => new NoInitExpr(handle), + CX_StmtClass.CX_StmtClass_OMPArraySectionExpr => new OMPArraySectionExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCArrayLiteral => new ObjCArrayLiteral(handle), + CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr => new ObjCAvailabilityCheckExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr => new ObjCBoolLiteralExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCBoxedExpr => new ObjCBoxedExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral => new ObjCDictionaryLiteral(handle), + CX_StmtClass.CX_StmtClass_ObjCEncodeExpr => new ObjCEncodeExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr => new ObjCIndirectCopyRestoreExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCIsaExpr => new ObjCIsaExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr => new ObjCIvarRefExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCMessageExpr => new ObjCMessageExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr => new ObjCPropertyRefExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCProtocolExpr => new ObjCProtocolExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCSelectorExpr => new ObjCSelectorExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCStringLiteral => new ObjCStringLiteral(handle), + CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr => new ObjCSubscriptRefExpr(handle), + CX_StmtClass.CX_StmtClass_OffsetOfExpr => new OffsetOfExpr(handle), + CX_StmtClass.CX_StmtClass_OpaqueValueExpr => new OpaqueValueExpr(handle), + CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr => new UnresolvedLookupExpr(handle), + CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr => new UnresolvedMemberExpr(handle), + CX_StmtClass.CX_StmtClass_PackExpansionExpr => new PackExpansionExpr(handle), + CX_StmtClass.CX_StmtClass_ParenExpr => new ParenExpr(handle), + CX_StmtClass.CX_StmtClass_ParenListExpr => new ParenListExpr(handle), + CX_StmtClass.CX_StmtClass_PredefinedExpr => new PredefinedExpr(handle), + CX_StmtClass.CX_StmtClass_PseudoObjectExpr => new PseudoObjectExpr(handle), + CX_StmtClass.CX_StmtClass_ShuffleVectorExpr => new ShuffleVectorExpr(handle), + CX_StmtClass.CX_StmtClass_SizeOfPackExpr => new SizeOfPackExpr(handle), + CX_StmtClass.CX_StmtClass_SourceLocExpr => new SourceLocExpr(handle), + CX_StmtClass.CX_StmtClass_StmtExpr => new StmtExpr(handle), + CX_StmtClass.CX_StmtClass_StringLiteral => new StringLiteral(handle), + CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr => new SubstNonTypeTemplateParmExpr(handle), + CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr => new SubstNonTypeTemplateParmPackExpr(handle), + CX_StmtClass.CX_StmtClass_TypeTraitExpr => new TypeTraitExpr(handle), + CX_StmtClass.CX_StmtClass_TypoExpr => new TypoExpr(handle), + CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr => new UnaryExprOrTypeTraitExpr(handle), + CX_StmtClass.CX_StmtClass_UnaryOperator => new UnaryOperator(handle), + CX_StmtClass.CX_StmtClass_VAArgExpr => new VAArgExpr(handle), + CX_StmtClass.CX_StmtClass_LabelStmt => new LabelStmt(handle), + CX_StmtClass.CX_StmtClass_WhileStmt => new WhileStmt(handle), + _ => new Stmt(handle, handle.Kind, handle.StmtClass), + }; } } diff --git a/sources/ClangSharp/Cursors/Stmts/SwitchCase.cs b/sources/ClangSharp/Cursors/Stmts/SwitchCase.cs index c92ebe0f..5237edff 100644 --- a/sources/ClangSharp/Cursors/Stmts/SwitchCase.cs +++ b/sources/ClangSharp/Cursors/Stmts/SwitchCase.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class SwitchCase : Stmt { - private protected SwitchCase(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected SwitchCase(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { + if ((CX_StmtClass.CX_StmtClass_LastSwitchCase < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstSwitchCase)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Stmts/SwitchStmt.cs b/sources/ClangSharp/Cursors/Stmts/SwitchStmt.cs index bc7359a9..dac7f25c 100644 --- a/sources/ClangSharp/Cursors/Stmts/SwitchStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SwitchStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class SwitchStmt : Stmt { - internal SwitchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SwitchStmt) + internal SwitchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SwitchStmt, CX_StmtClass.CX_StmtClass_SwitchStmt) { } } diff --git a/sources/ClangSharp/Cursors/Stmts/ValueStmt.cs b/sources/ClangSharp/Cursors/Stmts/ValueStmt.cs index 5f740563..13702e44 100644 --- a/sources/ClangSharp/Cursors/Stmts/ValueStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ValueStmt.cs @@ -1,13 +1,18 @@ // Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. +using System; using ClangSharp.Interop; namespace ClangSharp { public class ValueStmt : Stmt { - private protected ValueStmt(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + private protected ValueStmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { + if ((CX_StmtClass.CX_StmtClass_LastValueStmt < handle.StmtClass) || (handle.StmtClass < CX_StmtClass.CX_StmtClass_FirstValueStmt)) + { + throw new ArgumentException(nameof(handle)); + } } } } diff --git a/sources/ClangSharp/Cursors/Stmts/WhileStmt.cs b/sources/ClangSharp/Cursors/Stmts/WhileStmt.cs index f6f086f7..d8869d0c 100644 --- a/sources/ClangSharp/Cursors/Stmts/WhileStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/WhileStmt.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class WhileStmt : Stmt { - internal WhileStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_WhileStmt) + internal WhileStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_WhileStmt, CX_StmtClass.CX_StmtClass_WhileStmt) { } } diff --git a/sources/ClangSharp/Interop.Extensions/CXCursor.cs b/sources/ClangSharp/Interop.Extensions/CXCursor.cs index 6787794c..add47c5f 100644 --- a/sources/ClangSharp/Interop.Extensions/CXCursor.cs +++ b/sources/ClangSharp/Interop.Extensions/CXCursor.cs @@ -9,8 +9,14 @@ public unsafe partial struct CXCursor : IEquatable { public static CXCursor Null => clang.getNullCursor(); + public CX_AttrKind AttrKind => clangsharp.Cursor_getAttrKind(this); + public CXAvailabilityKind Availability => clang.getCursorAvailability(this); + public CX_BinaryOperatorKind BinaryOperatorKind => clangsharp.Cursor_getBinaryOpcode(this); + + public CXString BinaryOperatorKindSpelling => clangsharp.Cursor_getBinaryOpcodeSpelling(BinaryOperatorKind); + public CXString BriefCommentText => clang.Cursor_getBriefCommentText(this); public CXCursor CanonicalCursor => clang.getCanonicalCursor(this); @@ -45,6 +51,8 @@ public unsafe partial struct CXCursor : IEquatable public bool CXXRecord_IsAbstract => clang.CXXRecord_isAbstract(this) != 0; + public CX_DeclKind DeclKind => clangsharp.Cursor_getDeclKind(this); + public CXString DeclObjCTypeEncoding => clang.getDeclObjCTypeEncoding(this); public CXCursor Definition => clang.getCursorDefinition(this); @@ -63,7 +71,7 @@ public unsafe partial struct CXCursor : IEquatable public int ExceptionSpecificationType => clang.getCursorExceptionSpecificationType(this); - public CXSourceRange Extent => clang.getCursorExtent(this); + public CXSourceRange Extent => clangsharp.getCursorExtent(this); public int FieldDeclBitWidth => clang.getFieldDeclBitWidth(this); @@ -187,6 +195,8 @@ public ReadOnlySpan OverriddenCursors public CXString Spelling => clang.getCursorSpelling(this); + public CX_StmtClass StmtClass => clangsharp.Cursor_getStmtClass(this); + public CX_StorageClass StorageClass => clang.Cursor_getStorageClass(this); public CXCursorKind TemplateCursorKind => clang.getTemplateCursorKind(this); @@ -199,6 +209,10 @@ public ReadOnlySpan OverriddenCursors public CXType TypedefDeclUnderlyingType => clang.getTypedefDeclUnderlyingType(this); + public CX_UnaryOperatorKind UnaryOperatorKind => clangsharp.Cursor_getUnaryOpcode(this); + + public CXString UnaryOperatorKindSpelling => clangsharp.Cursor_getUnaryOpcodeSpelling(UnaryOperatorKind); + public CXString Usr => clang.getCursorUSR(this); public CXVisibilityKind Visibility => clang.getCursorVisibility(this); diff --git a/sources/ClangSharp/Interop.Extensions/CXSourceLocation.cs b/sources/ClangSharp/Interop.Extensions/CXSourceLocation.cs index 61404652..a67a0abf 100644 --- a/sources/ClangSharp/Interop.Extensions/CXSourceLocation.cs +++ b/sources/ClangSharp/Interop.Extensions/CXSourceLocation.cs @@ -72,13 +72,13 @@ public void GetSpellingLocation(out CXFile file, out uint line, out uint column, fixed (uint* pColumn = &column) fixed (uint* pOffset = &offset) { - clang.getSpellingLocation(this, (void**)pFile, pLine, pColumn, pOffset); + clangsharp.getSpellingLocation(this, (void**)pFile, pLine, pColumn, pOffset); } } public override string ToString() { - GetFileLocation(out var file, out var line, out var column, out _); + GetSpellingLocation(out var file, out var line, out var column, out _); return $"Line {line}, Column {column} in {file}"; } } diff --git a/sources/ClangSharp/Interop.Extensions/CXSourceRange.cs b/sources/ClangSharp/Interop.Extensions/CXSourceRange.cs index 04028510..b2bf3e86 100644 --- a/sources/ClangSharp/Interop.Extensions/CXSourceRange.cs +++ b/sources/ClangSharp/Interop.Extensions/CXSourceRange.cs @@ -20,7 +20,7 @@ public partial struct CXSourceRange : IEquatable public static bool Equals(CXSourceRange range1, CXSourceRange range2) => clang.equalRanges(range1, range2) != 0; - public static CXSourceRange Create(CXSourceLocation begin, CXSourceLocation end) => clang.getRange(begin, end); + public static CXSourceRange Create(CXSourceLocation begin, CXSourceLocation end) => clangsharp.getRange(begin, end); public override bool Equals(object obj) => (obj is CXSourceRange other) && Equals(other); diff --git a/sources/ClangSharp/Interop.Extensions/CXType.cs b/sources/ClangSharp/Interop.Extensions/CXType.cs index 6347021f..322ff13a 100644 --- a/sources/ClangSharp/Interop.Extensions/CXType.cs +++ b/sources/ClangSharp/Interop.Extensions/CXType.cs @@ -71,6 +71,8 @@ public unsafe partial struct CXType : IEquatable public CXString Spelling => clang.getTypeSpelling(this); + public CX_TypeClass TypeClass => clangsharp.Type_getTypeClass(this); + public CXString TypedefName => clang.getTypedefName(this); public static bool operator ==(CXType left, CXType right) => clang.equalTypes(left, right) != 0; diff --git a/sources/ClangSharp/Interop/CX_AttrKind.cs b/sources/ClangSharp/Interop/CX_AttrKind.cs new file mode 100644 index 00000000..d246253e --- /dev/null +++ b/sources/ClangSharp/Interop/CX_AttrKind.cs @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +{ + public enum CX_AttrKind + { + CX_AttrKind_Invalid, + CX_AttrKind_AddressSpace, + CX_AttrKind_NoDeref, + CX_AttrKind_ObjCGC, + CX_AttrKind_ObjCInertUnsafeUnretained, + CX_AttrKind_ObjCKindOf, + CX_AttrKind_OpenCLConstantAddressSpace, + CX_AttrKind_OpenCLGenericAddressSpace, + CX_AttrKind_OpenCLGlobalAddressSpace, + CX_AttrKind_OpenCLLocalAddressSpace, + CX_AttrKind_OpenCLPrivateAddressSpace, + CX_AttrKind_Ptr32, + CX_AttrKind_Ptr64, + CX_AttrKind_SPtr, + CX_AttrKind_TypeNonNull, + CX_AttrKind_TypeNullUnspecified, + CX_AttrKind_TypeNullable, + CX_AttrKind_UPtr, + CX_AttrKind_FallThrough, + CX_AttrKind_Suppress, + CX_AttrKind_AArch64VectorPcs, + CX_AttrKind_AnyX86NoCfCheck, + CX_AttrKind_CDecl, + CX_AttrKind_FastCall, + CX_AttrKind_IntelOclBicc, + CX_AttrKind_LifetimeBound, + CX_AttrKind_MSABI, + CX_AttrKind_NSReturnsRetained, + CX_AttrKind_ObjCOwnership, + CX_AttrKind_Pascal, + CX_AttrKind_Pcs, + CX_AttrKind_PreserveAll, + CX_AttrKind_PreserveMost, + CX_AttrKind_RegCall, + CX_AttrKind_StdCall, + CX_AttrKind_SwiftCall, + CX_AttrKind_SysVABI, + CX_AttrKind_ThisCall, + CX_AttrKind_VectorCall, + CX_AttrKind_SwiftContext, + CX_AttrKind_SwiftErrorResult, + CX_AttrKind_SwiftIndirectResult, + CX_AttrKind_Annotate, + CX_AttrKind_CFConsumed, + CX_AttrKind_CarriesDependency, + CX_AttrKind_NSConsumed, + CX_AttrKind_NonNull, + CX_AttrKind_OSConsumed, + CX_AttrKind_PassObjectSize, + CX_AttrKind_AMDGPUFlatWorkGroupSize, + CX_AttrKind_AMDGPUNumSGPR, + CX_AttrKind_AMDGPUNumVGPR, + CX_AttrKind_AMDGPUWavesPerEU, + CX_AttrKind_ARMInterrupt, + CX_AttrKind_AVRInterrupt, + CX_AttrKind_AVRSignal, + CX_AttrKind_AcquireCapability, + CX_AttrKind_AcquiredAfter, + CX_AttrKind_AcquiredBefore, + CX_AttrKind_AlignMac68k, + CX_AttrKind_Aligned, + CX_AttrKind_AllocAlign, + CX_AttrKind_AllocSize, + CX_AttrKind_AlwaysDestroy, + CX_AttrKind_AlwaysInline, + CX_AttrKind_AnalyzerNoReturn, + CX_AttrKind_AnyX86Interrupt, + CX_AttrKind_AnyX86NoCallerSavedRegisters, + CX_AttrKind_ArcWeakrefUnavailable, + CX_AttrKind_ArgumentWithTypeTag, + CX_AttrKind_Artificial, + CX_AttrKind_AsmLabel, + CX_AttrKind_AssertCapability, + CX_AttrKind_AssertExclusiveLock, + CX_AttrKind_AssertSharedLock, + CX_AttrKind_AssumeAligned, + CX_AttrKind_Availability, + CX_AttrKind_Blocks, + CX_AttrKind_C11NoReturn, + CX_AttrKind_CFAuditedTransfer, + CX_AttrKind_CFReturnsNotRetained, + CX_AttrKind_CFReturnsRetained, + CX_AttrKind_CFUnknownTransfer, + CX_AttrKind_CPUDispatch, + CX_AttrKind_CPUSpecific, + CX_AttrKind_CUDAConstant, + CX_AttrKind_CUDADevice, + CX_AttrKind_CUDAGlobal, + CX_AttrKind_CUDAHost, + CX_AttrKind_CUDAInvalidTarget, + CX_AttrKind_CUDALaunchBounds, + CX_AttrKind_CUDAShared, + CX_AttrKind_CXX11NoReturn, + CX_AttrKind_CallableWhen, + CX_AttrKind_Callback, + CX_AttrKind_Capability, + CX_AttrKind_CapturedRecord, + CX_AttrKind_Cleanup, + CX_AttrKind_CodeSeg, + CX_AttrKind_Cold, + CX_AttrKind_Common, + CX_AttrKind_Const, + CX_AttrKind_Constructor, + CX_AttrKind_Consumable, + CX_AttrKind_ConsumableAutoCast, + CX_AttrKind_ConsumableSetOnRead, + CX_AttrKind_Convergent, + CX_AttrKind_DLLExport, + CX_AttrKind_DLLExportStaticLocal, + CX_AttrKind_DLLImport, + CX_AttrKind_DLLImportStaticLocal, + CX_AttrKind_Deprecated, + CX_AttrKind_Destructor, + CX_AttrKind_DiagnoseIf, + CX_AttrKind_DisableTailCalls, + CX_AttrKind_EmptyBases, + CX_AttrKind_EnableIf, + CX_AttrKind_EnumExtensibility, + CX_AttrKind_ExcludeFromExplicitInstantiation, + CX_AttrKind_ExclusiveTrylockFunction, + CX_AttrKind_ExternalSourceSymbol, + CX_AttrKind_Final, + CX_AttrKind_FlagEnum, + CX_AttrKind_Flatten, + CX_AttrKind_Format, + CX_AttrKind_FormatArg, + CX_AttrKind_GNUInline, + CX_AttrKind_GuardedBy, + CX_AttrKind_GuardedVar, + CX_AttrKind_HIPPinnedShadow, + CX_AttrKind_Hot, + CX_AttrKind_IBAction, + CX_AttrKind_IBOutlet, + CX_AttrKind_IBOutletCollection, + CX_AttrKind_InitPriority, + CX_AttrKind_InternalLinkage, + CX_AttrKind_LTOVisibilityPublic, + CX_AttrKind_LayoutVersion, + CX_AttrKind_LockReturned, + CX_AttrKind_LocksExcluded, + CX_AttrKind_MIGServerRoutine, + CX_AttrKind_MSAllocator, + CX_AttrKind_MSInheritance, + CX_AttrKind_MSNoVTable, + CX_AttrKind_MSP430Interrupt, + CX_AttrKind_MSStruct, + CX_AttrKind_MSVtorDisp, + CX_AttrKind_MaxFieldAlignment, + CX_AttrKind_MayAlias, + CX_AttrKind_MicroMips, + CX_AttrKind_MinSize, + CX_AttrKind_MinVectorWidth, + CX_AttrKind_Mips16, + CX_AttrKind_MipsInterrupt, + CX_AttrKind_MipsLongCall, + CX_AttrKind_MipsShortCall, + CX_AttrKind_NSConsumesSelf, + CX_AttrKind_NSReturnsAutoreleased, + CX_AttrKind_NSReturnsNotRetained, + CX_AttrKind_Naked, + CX_AttrKind_NoAlias, + CX_AttrKind_NoCommon, + CX_AttrKind_NoDebug, + CX_AttrKind_NoDestroy, + CX_AttrKind_NoDuplicate, + CX_AttrKind_NoInline, + CX_AttrKind_NoInstrumentFunction, + CX_AttrKind_NoMicroMips, + CX_AttrKind_NoMips16, + CX_AttrKind_NoReturn, + CX_AttrKind_NoSanitize, + CX_AttrKind_NoSpeculativeLoadHardening, + CX_AttrKind_NoSplitStack, + CX_AttrKind_NoStackProtector, + CX_AttrKind_NoThreadSafetyAnalysis, + CX_AttrKind_NoThrow, + CX_AttrKind_NoUniqueAddress, + CX_AttrKind_NotTailCalled, + CX_AttrKind_OMPAllocateDecl, + CX_AttrKind_OMPCaptureNoInit, + CX_AttrKind_OMPDeclareTargetDecl, + CX_AttrKind_OMPThreadPrivateDecl, + CX_AttrKind_OSConsumesThis, + CX_AttrKind_OSReturnsNotRetained, + CX_AttrKind_OSReturnsRetained, + CX_AttrKind_OSReturnsRetainedOnNonZero, + CX_AttrKind_OSReturnsRetainedOnZero, + CX_AttrKind_ObjCBridge, + CX_AttrKind_ObjCBridgeMutable, + CX_AttrKind_ObjCBridgeRelated, + CX_AttrKind_ObjCException, + CX_AttrKind_ObjCExplicitProtocolImpl, + CX_AttrKind_ObjCExternallyRetained, + CX_AttrKind_ObjCIndependentClass, + CX_AttrKind_ObjCMethodFamily, + CX_AttrKind_ObjCNSObject, + CX_AttrKind_ObjCPreciseLifetime, + CX_AttrKind_ObjCRequiresPropertyDefs, + CX_AttrKind_ObjCRequiresSuper, + CX_AttrKind_ObjCReturnsInnerPointer, + CX_AttrKind_ObjCRootClass, + CX_AttrKind_ObjCSubclassingRestricted, + CX_AttrKind_OpenCLIntelReqdSubGroupSize, + CX_AttrKind_OpenCLKernel, + CX_AttrKind_OpenCLUnrollHint, + CX_AttrKind_OptimizeNone, + CX_AttrKind_Override, + CX_AttrKind_Ownership, + CX_AttrKind_Packed, + CX_AttrKind_ParamTypestate, + CX_AttrKind_PragmaClangBSSSection, + CX_AttrKind_PragmaClangDataSection, + CX_AttrKind_PragmaClangRodataSection, + CX_AttrKind_PragmaClangTextSection, + CX_AttrKind_PtGuardedBy, + CX_AttrKind_PtGuardedVar, + CX_AttrKind_Pure, + CX_AttrKind_RISCVInterrupt, + CX_AttrKind_Reinitializes, + CX_AttrKind_ReleaseCapability, + CX_AttrKind_ReqdWorkGroupSize, + CX_AttrKind_RequireConstantInit, + CX_AttrKind_RequiresCapability, + CX_AttrKind_Restrict, + CX_AttrKind_ReturnTypestate, + CX_AttrKind_ReturnsNonNull, + CX_AttrKind_ReturnsTwice, + CX_AttrKind_ScopedLockable, + CX_AttrKind_Section, + CX_AttrKind_SelectAny, + CX_AttrKind_Sentinel, + CX_AttrKind_SetTypestate, + CX_AttrKind_SharedTrylockFunction, + CX_AttrKind_SpeculativeLoadHardening, + CX_AttrKind_TLSModel, + CX_AttrKind_Target, + CX_AttrKind_TestTypestate, + CX_AttrKind_TransparentUnion, + CX_AttrKind_TrivialABI, + CX_AttrKind_TryAcquireCapability, + CX_AttrKind_TypeTagForDatatype, + CX_AttrKind_TypeVisibility, + CX_AttrKind_Unavailable, + CX_AttrKind_Uninitialized, + CX_AttrKind_Unused, + CX_AttrKind_Used, + CX_AttrKind_Uuid, + CX_AttrKind_VecReturn, + CX_AttrKind_VecTypeHint, + CX_AttrKind_Visibility, + CX_AttrKind_WarnUnused, + CX_AttrKind_WarnUnusedResult, + CX_AttrKind_Weak, + CX_AttrKind_WeakImport, + CX_AttrKind_WeakRef, + CX_AttrKind_WebAssemblyImportModule, + CX_AttrKind_WebAssemblyImportName, + CX_AttrKind_WorkGroupSizeHint, + CX_AttrKind_X86ForceAlignArgPointer, + CX_AttrKind_XRayInstrument, + CX_AttrKind_XRayLogArgs, + CX_AttrKind_AbiTag, + CX_AttrKind_Alias, + CX_AttrKind_AlignValue, + CX_AttrKind_IFunc, + CX_AttrKind_InitSeg, + CX_AttrKind_LoopHint, + CX_AttrKind_Mode, + CX_AttrKind_NoEscape, + CX_AttrKind_OMPCaptureKind, + CX_AttrKind_OMPDeclareSimdDecl, + CX_AttrKind_OMPReferencedVar, + CX_AttrKind_ObjCBoxable, + CX_AttrKind_ObjCClassStub, + CX_AttrKind_ObjCDesignatedInitializer, + CX_AttrKind_ObjCNonLazyClass, + CX_AttrKind_ObjCRuntimeName, + CX_AttrKind_ObjCRuntimeVisible, + CX_AttrKind_OpenCLAccess, + CX_AttrKind_Overloadable, + CX_AttrKind_RenderScriptKernel, + 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_UPtr, + CX_AttrKind_FirstStmtAttr = CX_AttrKind_FallThrough, + CX_AttrKind_LastStmtAttr = CX_AttrKind_Suppress, + CX_AttrKind_FirstInheritableAttr = CX_AttrKind_AArch64VectorPcs, + CX_AttrKind_LastInheritableAttr = CX_AttrKind_XRayLogArgs, + CX_AttrKind_FirstDeclOrTypeAttr = CX_AttrKind_AArch64VectorPcs, + CX_AttrKind_LastDeclOrTypeAttr = CX_AttrKind_VectorCall, + CX_AttrKind_FirstInheritableParamAttr = CX_AttrKind_SwiftContext, + CX_AttrKind_LastInheritableParamAttr = CX_AttrKind_PassObjectSize, + CX_AttrKind_FirstParameterABIAttr = CX_AttrKind_SwiftContext, + CX_AttrKind_LastParameterABIAttr = CX_AttrKind_SwiftIndirectResult, + } +} diff --git a/sources/ClangSharp/Interop/CX_BinaryOperatorKind.cs b/sources/ClangSharp/Interop/CX_BinaryOperatorKind.cs new file mode 100644 index 00000000..9397c9e3 --- /dev/null +++ b/sources/ClangSharp/Interop/CX_BinaryOperatorKind.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +{ + public enum CX_BinaryOperatorKind + { + CX_BO_Invalid, + CX_BO_PtrMemD, + CX_BO_PtrMemI, + CX_BO_Mul, + CX_BO_Div, + CX_BO_Rem, + CX_BO_Add, + CX_BO_Sub, + CX_BO_Shl, + CX_BO_Shr, + CX_BO_Cmp, + CX_BO_LT, + CX_BO_GT, + CX_BO_LE, + CX_BO_GE, + CX_BO_EQ, + CX_BO_NE, + CX_BO_And, + CX_BO_Xor, + CX_BO_Or, + CX_BO_LAnd, + CX_BO_LOr, + CX_BO_Assign, + CX_BO_MulAssign, + CX_BO_DivAssign, + CX_BO_RemAssign, + CX_BO_AddAssign, + CX_BO_SubAssign, + CX_BO_ShlAssign, + CX_BO_ShrAssign, + CX_BO_AndAssign, + CX_BO_XorAssign, + CX_BO_OrAssign, + CX_BO_Comma, + } +} diff --git a/sources/ClangSharp/Interop/CX_DeclKind.cs b/sources/ClangSharp/Interop/CX_DeclKind.cs new file mode 100644 index 00000000..d84bce8f --- /dev/null +++ b/sources/ClangSharp/Interop/CX_DeclKind.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +{ + 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_Import, + CX_DeclKind_LinkageSpec, + 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_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_Using, + 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_Function, + CX_DeclKind_CXXDeductionGuide, + CX_DeclKind_CXXMethod, + CX_DeclKind_CXXConstructor, + CX_DeclKind_CXXConversion, + CX_DeclKind_CXXDestructor, + CX_DeclKind_FirstCXXMethod = CX_DeclKind_CXXMethod, + CX_DeclKind_LastCXXMethod = CX_DeclKind_CXXDestructor, + CX_DeclKind_FirstFunction = CX_DeclKind_Function, + CX_DeclKind_LastFunction = CX_DeclKind_CXXDestructor, + CX_DeclKind_MSProperty, + CX_DeclKind_NonTypeTemplateParm, + 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_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_OMPDeclareMapper, + CX_DeclKind_OMPDeclareReduction, + CX_DeclKind_UnresolvedUsingValue, + CX_DeclKind_FirstValue = CX_DeclKind_Binding, + CX_DeclKind_LastValue = CX_DeclKind_UnresolvedUsingValue, + CX_DeclKind_FirstNamed = CX_DeclKind_Label, + 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_StaticAssert, + CX_DeclKind_TranslationUnit, + CX_DeclKind_FirstDecl = CX_DeclKind_AccessSpec, + CX_DeclKind_LastDecl = CX_DeclKind_TranslationUnit, + } +} diff --git a/sources/ClangSharp/Interop/CX_StmtClass.cs b/sources/ClangSharp/Interop/CX_StmtClass.cs new file mode 100644 index 00000000..66896304 --- /dev/null +++ b/sources/ClangSharp/Interop/CX_StmtClass.cs @@ -0,0 +1,244 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +{ + 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_OMPAtomicDirective, + CX_StmtClass_OMPBarrierDirective, + CX_StmtClass_OMPCancelDirective, + CX_StmtClass_OMPCancellationPointDirective, + CX_StmtClass_OMPCriticalDirective, + CX_StmtClass_OMPFlushDirective, + CX_StmtClass_OMPDistributeDirective, + CX_StmtClass_OMPDistributeParallelForDirective, + CX_StmtClass_OMPDistributeParallelForSimdDirective, + CX_StmtClass_OMPDistributeSimdDirective, + CX_StmtClass_OMPForDirective, + CX_StmtClass_OMPForSimdDirective, + CX_StmtClass_OMPParallelForDirective, + CX_StmtClass_OMPParallelForSimdDirective, + CX_StmtClass_OMPSimdDirective, + CX_StmtClass_OMPTargetParallelForSimdDirective, + CX_StmtClass_OMPTargetSimdDirective, + CX_StmtClass_OMPTargetTeamsDistributeDirective, + CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective, + CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective, + CX_StmtClass_OMPTargetTeamsDistributeSimdDirective, + CX_StmtClass_OMPTaskLoopDirective, + CX_StmtClass_OMPTaskLoopSimdDirective, + CX_StmtClass_OMPTeamsDistributeDirective, + CX_StmtClass_OMPTeamsDistributeParallelForDirective, + CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective, + CX_StmtClass_OMPTeamsDistributeSimdDirective, + CX_StmtClass_FirstOMPLoopDirective = CX_StmtClass_OMPDistributeDirective, + CX_StmtClass_LastOMPLoopDirective = CX_StmtClass_OMPTeamsDistributeSimdDirective, + CX_StmtClass_OMPMasterDirective, + CX_StmtClass_OMPOrderedDirective, + CX_StmtClass_OMPParallelDirective, + CX_StmtClass_OMPParallelSectionsDirective, + 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_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_CXXPseudoDestructorExpr, + 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_CXXConstCastExpr, + CX_StmtClass_CXXDynamicCastExpr, + CX_StmtClass_CXXReinterpretCastExpr, + CX_StmtClass_CXXStaticCastExpr, + CX_StmtClass_FirstCXXNamedCastExpr = CX_StmtClass_CXXConstCastExpr, + 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_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_MemberExpr, + CX_StmtClass_NoInitExpr, + CX_StmtClass_OMPArraySectionExpr, + 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_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, + } +} diff --git a/sources/ClangSharp/Interop/CX_TypeClass.cs b/sources/ClangSharp/Interop/CX_TypeClass.cs new file mode 100644 index 00000000..b64a29bd --- /dev/null +++ b/sources/ClangSharp/Interop/CX_TypeClass.cs @@ -0,0 +1,58 @@ +namespace ClangSharp.Interop +{ + public enum CX_TypeClass + { + CX_TypeClass_Invalid, + CX_TypeClass_Builtin, + CX_TypeClass_Complex, + CX_TypeClass_Pointer, + CX_TypeClass_BlockPointer, + CX_TypeClass_LValueReference, + CX_TypeClass_RValueReference, + CX_TypeClass_MemberPointer, + CX_TypeClass_ConstantArray, + CX_TypeClass_IncompleteArray, + CX_TypeClass_VariableArray, + CX_TypeClass_DependentSizedArray, + CX_TypeClass_DependentSizedExtVector, + CX_TypeClass_DependentAddressSpace, + CX_TypeClass_Vector, + CX_TypeClass_DependentVector, + CX_TypeClass_ExtVector, + CX_TypeClass_FunctionProto, + CX_TypeClass_FunctionNoProto, + CX_TypeClass_UnresolvedUsing, + CX_TypeClass_Paren, + CX_TypeClass_Typedef, + CX_TypeClass_MacroQualified, + CX_TypeClass_Adjusted, + CX_TypeClass_Decayed, + CX_TypeClass_TypeOfExpr, + CX_TypeClass_TypeOf, + CX_TypeClass_Decltype, + CX_TypeClass_UnaryTransform, + CX_TypeClass_Record, + CX_TypeClass_Enum, + CX_TypeClass_Elaborated, + CX_TypeClass_Attributed, + CX_TypeClass_TemplateTypeParm, + CX_TypeClass_SubstTemplateTypeParm, + CX_TypeClass_SubstTemplateTypeParmPack, + CX_TypeClass_TemplateSpecialization, + CX_TypeClass_Auto, + CX_TypeClass_DeducedTemplateSpecialization, + CX_TypeClass_InjectedClassName, + CX_TypeClass_DependentName, + CX_TypeClass_DependentTemplateSpecialization, + CX_TypeClass_PackExpansion, + CX_TypeClass_ObjCTypeParam, + CX_TypeClass_ObjCObject, + CX_TypeClass_ObjCInterface, + CX_TypeClass_ObjCObjectPointer, + CX_TypeClass_Pipe, + CX_TypeClass_Atomic, + CX_TypeClass_TypeLast = CX_TypeClass_Atomic, + CX_TypeClass_TagFirst = CX_TypeClass_Record, + CX_TypeClass_TagLast = CX_TypeClass_Enum, + } +} diff --git a/sources/ClangSharp/Interop/CX_UnaryOperatorKind.cs b/sources/ClangSharp/Interop/CX_UnaryOperatorKind.cs new file mode 100644 index 00000000..f431096c --- /dev/null +++ b/sources/ClangSharp/Interop/CX_UnaryOperatorKind.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +{ + public enum CX_UnaryOperatorKind + { + CX_UO_Invalid, + CX_UO_PostInc, + CX_UO_PostDec, + CX_UO_PreInc, + CX_UO_PreDec, + CX_UO_AddrOf, + CX_UO_Deref, + CX_UO_Plus, + CX_UO_Minus, + CX_UO_Not, + CX_UO_LNot, + CX_UO_Real, + CX_UO_Imag, + CX_UO_Extension, + CX_UO_Coawait, + } +} diff --git a/sources/ClangSharp/Interop/clangsharp.cs b/sources/ClangSharp/Interop/clangsharp.cs new file mode 100644 index 00000000..0b03b478 --- /dev/null +++ b/sources/ClangSharp/Interop/clangsharp.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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; + +namespace ClangSharp.Interop +{ + public static unsafe partial class clangsharp + { + private const string libraryPath = "libClangSharp"; + + [DllImport(libraryPath, EntryPoint = "clangsharp_Cursor_getAttrKind", CallingConvention = CallingConvention.Cdecl)] + public static extern CX_AttrKind Cursor_getAttrKind(CXCursor C); + + [DllImport(libraryPath, EntryPoint = "clangsharp_Cursor_getBinaryOpcode", CallingConvention = CallingConvention.Cdecl)] + public static extern CX_BinaryOperatorKind Cursor_getBinaryOpcode(CXCursor C); + + [DllImport(libraryPath, EntryPoint = "clangsharp_Cursor_getBinaryOpcodeSpelling", CallingConvention = CallingConvention.Cdecl)] + public static extern CXString Cursor_getBinaryOpcodeSpelling(CX_BinaryOperatorKind Op); + + [DllImport(libraryPath, EntryPoint = "clangsharp_Cursor_getDeclKind", CallingConvention = CallingConvention.Cdecl)] + public static extern CX_DeclKind Cursor_getDeclKind(CXCursor C); + + [DllImport(libraryPath, EntryPoint = "clangsharp_Cursor_getStmtClass", CallingConvention = CallingConvention.Cdecl)] + public static extern CX_StmtClass Cursor_getStmtClass(CXCursor C); + + [DllImport(libraryPath, EntryPoint = "clangsharp_Cursor_getUnaryOpcode", CallingConvention = CallingConvention.Cdecl)] + public static extern CX_UnaryOperatorKind Cursor_getUnaryOpcode(CXCursor C); + + [DllImport(libraryPath, EntryPoint = "clangsharp_Cursor_getUnaryOpcodeSpelling", CallingConvention = CallingConvention.Cdecl)] + public static extern CXString Cursor_getUnaryOpcodeSpelling(CX_UnaryOperatorKind Op); + + [DllImport(libraryPath, EntryPoint = "clangsharp_getCursorExtent", CallingConvention = CallingConvention.Cdecl)] + public static extern CXSourceRange getCursorExtent(CXCursor param0); + + [DllImport(libraryPath, EntryPoint = "clangsharp_getNullRange", CallingConvention = CallingConvention.Cdecl)] + public static extern CXSourceRange getNullRange(); + + [DllImport(libraryPath, EntryPoint = "clangsharp_getRange", CallingConvention = CallingConvention.Cdecl)] + public static extern CXSourceRange getRange(CXSourceLocation begin, CXSourceLocation end); + + [DllImport(libraryPath, EntryPoint = "clangsharp_getSpellingLocation", CallingConvention = CallingConvention.Cdecl)] + public static extern void getSpellingLocation(CXSourceLocation location, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); + + [DllImport(libraryPath, EntryPoint = "clangsharp_isAttribute", CallingConvention = CallingConvention.Cdecl)] + [return: NativeTypeName("unsigned int")] + public static extern uint isAttribute([NativeTypeName("CXCursorKind")] CXCursorKind param0); + + [DllImport(libraryPath, EntryPoint = "clangsharp_isDeclaration", CallingConvention = CallingConvention.Cdecl)] + [return: NativeTypeName("unsigned int")] + public static extern uint isDeclaration([NativeTypeName("CXCursorKind")] CXCursorKind param0); + + [DllImport(libraryPath, EntryPoint = "clangsharp_isExpression", CallingConvention = CallingConvention.Cdecl)] + [return: NativeTypeName("unsigned int")] + public static extern uint isExpression([NativeTypeName("CXCursorKind")] CXCursorKind param0); + + [DllImport(libraryPath, EntryPoint = "clangsharp_isReference", CallingConvention = CallingConvention.Cdecl)] + [return: NativeTypeName("unsigned int")] + public static extern uint isReference([NativeTypeName("CXCursorKind")] CXCursorKind param0); + + [DllImport(libraryPath, EntryPoint = "clangsharp_isStatement", CallingConvention = CallingConvention.Cdecl)] + [return: NativeTypeName("unsigned int")] + public static extern uint isStatement([NativeTypeName("CXCursorKind")] CXCursorKind param0); + + [DllImport(libraryPath, EntryPoint = "clangsharp_isTranslationUnit", CallingConvention = CallingConvention.Cdecl)] + [return: NativeTypeName("unsigned int")] + public static extern uint isTranslationUnit([NativeTypeName("CXCursorKind")] CXCursorKind param0); + + [DllImport(libraryPath, EntryPoint = "clangsharp_Type_getTypeClass", CallingConvention = CallingConvention.Cdecl)] + public static extern CX_TypeClass Type_getTypeClass(CXType CT); + } +} diff --git a/sources/ClangSharp/Types/AdjustedType.cs b/sources/ClangSharp/Types/AdjustedType.cs new file mode 100644 index 00000000..11df223f --- /dev/null +++ b/sources/ClangSharp/Types/AdjustedType.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class AdjustedType : Type + { + internal AdjustedType(CXType handle) : this(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Adjusted) + { + } + + private protected AdjustedType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + } + } +} diff --git a/sources/ClangSharp/Types/ArrayType.cs b/sources/ClangSharp/Types/ArrayType.cs index 598ca086..0b8c9114 100644 --- a/sources/ClangSharp/Types/ArrayType.cs +++ b/sources/ClangSharp/Types/ArrayType.cs @@ -9,7 +9,7 @@ public class ArrayType : Type { private readonly Lazy _elementType; - private protected ArrayType(CXType handle, CXTypeKind expectedKind) : base(handle, expectedKind) + private protected ArrayType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) { _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ArrayElementType)); } diff --git a/sources/ClangSharp/Types/AtomicType.cs b/sources/ClangSharp/Types/AtomicType.cs new file mode 100644 index 00000000..bb7e5b53 --- /dev/null +++ b/sources/ClangSharp/Types/AtomicType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class AtomicType : Type + { + internal AtomicType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Atomic) + { + } + } +} diff --git a/sources/ClangSharp/Types/AttributedType.cs b/sources/ClangSharp/Types/AttributedType.cs index 0d764137..804ac555 100644 --- a/sources/ClangSharp/Types/AttributedType.cs +++ b/sources/ClangSharp/Types/AttributedType.cs @@ -9,7 +9,7 @@ public sealed class AttributedType : Type { private readonly Lazy _modifiedType; - internal AttributedType(CXType handle) : base(handle, CXTypeKind.CXType_Attributed) + internal AttributedType(CXType handle) : base(handle, CXTypeKind.CXType_Attributed, CX_TypeClass.CX_TypeClass_Attributed) { _modifiedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ModifiedType)); } diff --git a/sources/ClangSharp/Cursors/Attrs/DeclOrTypeAttr.cs b/sources/ClangSharp/Types/AutoType.cs similarity index 63% rename from sources/ClangSharp/Cursors/Attrs/DeclOrTypeAttr.cs rename to sources/ClangSharp/Types/AutoType.cs index 777a380d..06eee44d 100644 --- a/sources/ClangSharp/Cursors/Attrs/DeclOrTypeAttr.cs +++ b/sources/ClangSharp/Types/AutoType.cs @@ -4,9 +4,9 @@ namespace ClangSharp { - public sealed class DeclOrTypeAttr : InheritableAttr + public sealed class AutoType : DeducedType { - internal DeclOrTypeAttr(CXCursor handle, CXCursorKind expectedKind) : base(handle, expectedKind) + internal AutoType(CXType handle) : base(handle, CXTypeKind.CXType_Auto, CX_TypeClass.CX_TypeClass_Auto) { } } diff --git a/sources/ClangSharp/Types/BlockPointerType.cs b/sources/ClangSharp/Types/BlockPointerType.cs new file mode 100644 index 00000000..ce4109de --- /dev/null +++ b/sources/ClangSharp/Types/BlockPointerType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class BlockPointerType : Type + { + internal BlockPointerType(CXType handle) : base(handle, CXTypeKind.CXType_BlockPointer, CX_TypeClass.CX_TypeClass_BlockPointer) + { + } + } +} diff --git a/sources/ClangSharp/Types/BuiltinType.cs b/sources/ClangSharp/Types/BuiltinType.cs index 16072288..6fb4b111 100644 --- a/sources/ClangSharp/Types/BuiltinType.cs +++ b/sources/ClangSharp/Types/BuiltinType.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class BuiltinType : Type { - internal BuiltinType(CXType handle, CXTypeKind expectedKind) : base(handle, expectedKind) + internal BuiltinType(CXType handle) : base(handle, handle.kind, CX_TypeClass.CX_TypeClass_Builtin) { } } diff --git a/sources/ClangSharp/Types/ComplexType.cs b/sources/ClangSharp/Types/ComplexType.cs new file mode 100644 index 00000000..f0ac0315 --- /dev/null +++ b/sources/ClangSharp/Types/ComplexType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ComplexType : Type + { + internal ComplexType(CXType handle) : base(handle, CXTypeKind.CXType_Complex, CX_TypeClass.CX_TypeClass_Complex) + { + } + } +} diff --git a/sources/ClangSharp/Types/ConstantArrayType.cs b/sources/ClangSharp/Types/ConstantArrayType.cs index 9cf605bf..e619e453 100644 --- a/sources/ClangSharp/Types/ConstantArrayType.cs +++ b/sources/ClangSharp/Types/ConstantArrayType.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class ConstantArrayType : ArrayType { - internal ConstantArrayType(CXType handle) : base(handle, CXTypeKind.CXType_ConstantArray) + internal ConstantArrayType(CXType handle) : base(handle, CXTypeKind.CXType_ConstantArray, CX_TypeClass.CX_TypeClass_ConstantArray) { } diff --git a/sources/ClangSharp/Types/DecayedType.cs b/sources/ClangSharp/Types/DecayedType.cs new file mode 100644 index 00000000..feb21bab --- /dev/null +++ b/sources/ClangSharp/Types/DecayedType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DecayedType : AdjustedType + { + internal DecayedType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Decayed) + { + } + } +} diff --git a/sources/ClangSharp/Types/DecltypeType.cs b/sources/ClangSharp/Types/DecltypeType.cs new file mode 100644 index 00000000..743a44f9 --- /dev/null +++ b/sources/ClangSharp/Types/DecltypeType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DecltypeType : Type + { + internal DecltypeType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Decltype) + { + } + } +} diff --git a/sources/ClangSharp/Types/DeducedTemplateSpecializationType.cs b/sources/ClangSharp/Types/DeducedTemplateSpecializationType.cs new file mode 100644 index 00000000..576020c4 --- /dev/null +++ b/sources/ClangSharp/Types/DeducedTemplateSpecializationType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DeducedTemplateSpecializationType : DeducedType + { + internal DeducedTemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DeducedTemplateSpecialization) + { + } + } +} diff --git a/sources/ClangSharp/Types/DeducedType.cs b/sources/ClangSharp/Types/DeducedType.cs new file mode 100644 index 00000000..04b59cea --- /dev/null +++ b/sources/ClangSharp/Types/DeducedType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class DeducedType : Type + { + private protected DeducedType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + } + } +} diff --git a/sources/ClangSharp/Types/DependentAddressSpaceType.cs b/sources/ClangSharp/Types/DependentAddressSpaceType.cs new file mode 100644 index 00000000..f78dba47 --- /dev/null +++ b/sources/ClangSharp/Types/DependentAddressSpaceType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DependentAddressSpaceType : Type + { + internal DependentAddressSpaceType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentAddressSpace) + { + } + } +} diff --git a/sources/ClangSharp/Types/DependentNameType.cs b/sources/ClangSharp/Types/DependentNameType.cs new file mode 100644 index 00000000..09309fe4 --- /dev/null +++ b/sources/ClangSharp/Types/DependentNameType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DependentNameType : TypeWithKeyword + { + internal DependentNameType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentName) + { + } + } +} diff --git a/sources/ClangSharp/Types/DependentSizedArrayType.cs b/sources/ClangSharp/Types/DependentSizedArrayType.cs index 62dc9ab5..086a562f 100644 --- a/sources/ClangSharp/Types/DependentSizedArrayType.cs +++ b/sources/ClangSharp/Types/DependentSizedArrayType.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class DependentSizedArrayType : ArrayType { - internal DependentSizedArrayType(CXType handle) : base(handle, CXTypeKind.CXType_DependentSizedArray) + internal DependentSizedArrayType(CXType handle) : base(handle, CXTypeKind.CXType_DependentSizedArray, CX_TypeClass.CX_TypeClass_DependentSizedArray) { } } diff --git a/sources/ClangSharp/Types/DependentSizedExtVectorType.cs b/sources/ClangSharp/Types/DependentSizedExtVectorType.cs new file mode 100644 index 00000000..ade3fcc0 --- /dev/null +++ b/sources/ClangSharp/Types/DependentSizedExtVectorType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DependentSizedExtVectorType : Type + { + internal DependentSizedExtVectorType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentSizedExtVector) + { + } + } +} diff --git a/sources/ClangSharp/Types/DependentTemplateSpecializationType.cs b/sources/ClangSharp/Types/DependentTemplateSpecializationType.cs new file mode 100644 index 00000000..9d772206 --- /dev/null +++ b/sources/ClangSharp/Types/DependentTemplateSpecializationType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DependentTemplateSpecializationType : TypeWithKeyword + { + internal DependentTemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentTemplateSpecialization) + { + } + } +} diff --git a/sources/ClangSharp/Types/DependentVectorType.cs b/sources/ClangSharp/Types/DependentVectorType.cs new file mode 100644 index 00000000..da3e2da4 --- /dev/null +++ b/sources/ClangSharp/Types/DependentVectorType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class DependentVectorType : Type + { + internal DependentVectorType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentVector) + { + } + } +} diff --git a/sources/ClangSharp/Types/ElaboratedType.cs b/sources/ClangSharp/Types/ElaboratedType.cs index 3c0803cd..1fbead53 100644 --- a/sources/ClangSharp/Types/ElaboratedType.cs +++ b/sources/ClangSharp/Types/ElaboratedType.cs @@ -9,7 +9,7 @@ public sealed class ElaboratedType : TypeWithKeyword { private readonly Lazy _namedType; - internal ElaboratedType(CXType handle) : base(handle, CXTypeKind.CXType_Elaborated) + internal ElaboratedType(CXType handle) : base(handle, CXTypeKind.CXType_Elaborated, CX_TypeClass.CX_TypeClass_Elaborated) { _namedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NamedType)); } diff --git a/sources/ClangSharp/Types/EnumType.cs b/sources/ClangSharp/Types/EnumType.cs index fbbacbc2..9d79d3e4 100644 --- a/sources/ClangSharp/Types/EnumType.cs +++ b/sources/ClangSharp/Types/EnumType.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class EnumType : TagType { - internal EnumType(CXType handle) : base(handle, CXTypeKind.CXType_Enum) + internal EnumType(CXType handle) : base(handle, CXTypeKind.CXType_Enum, CX_TypeClass.CX_TypeClass_Enum) { } } diff --git a/sources/ClangSharp/Types/ExtVectorType.cs b/sources/ClangSharp/Types/ExtVectorType.cs new file mode 100644 index 00000000..5cd09546 --- /dev/null +++ b/sources/ClangSharp/Types/ExtVectorType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ExtVectorType : Type + { + internal ExtVectorType(CXType handle) : base(handle, CXTypeKind.CXType_ExtVector, CX_TypeClass.CX_TypeClass_ExtVector) + { + } + } +} diff --git a/sources/ClangSharp/Types/FunctionNoProtoType.cs b/sources/ClangSharp/Types/FunctionNoProtoType.cs new file mode 100644 index 00000000..53a95473 --- /dev/null +++ b/sources/ClangSharp/Types/FunctionNoProtoType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class FunctionNoProtoType : FunctionType + { + internal FunctionNoProtoType(CXType handle) : base(handle, CXTypeKind.CXType_FunctionNoProto, CX_TypeClass.CX_TypeClass_FunctionNoProto) + { + } + } +} diff --git a/sources/ClangSharp/Types/FunctionProtoType.cs b/sources/ClangSharp/Types/FunctionProtoType.cs index eb2fdfcd..ded15ac2 100644 --- a/sources/ClangSharp/Types/FunctionProtoType.cs +++ b/sources/ClangSharp/Types/FunctionProtoType.cs @@ -9,7 +9,7 @@ public sealed class FunctionProtoType : FunctionType { private Type[] _paramTypes; - internal FunctionProtoType(CXType handle) : base(handle, CXTypeKind.CXType_FunctionProto) + internal FunctionProtoType(CXType handle) : base(handle, CXTypeKind.CXType_FunctionProto, CX_TypeClass.CX_TypeClass_FunctionProto) { } diff --git a/sources/ClangSharp/Types/FunctionType.cs b/sources/ClangSharp/Types/FunctionType.cs index 75f9c160..61c07b93 100644 --- a/sources/ClangSharp/Types/FunctionType.cs +++ b/sources/ClangSharp/Types/FunctionType.cs @@ -9,7 +9,7 @@ public class FunctionType : Type { private readonly Lazy _returnType; - private protected FunctionType(CXType handle, CXTypeKind expectedKind) : base(handle, expectedKind) + private protected FunctionType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) { _returnType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ResultType)); } diff --git a/sources/ClangSharp/Types/IncompleteArrayType.cs b/sources/ClangSharp/Types/IncompleteArrayType.cs index 88c03639..a3347fbb 100644 --- a/sources/ClangSharp/Types/IncompleteArrayType.cs +++ b/sources/ClangSharp/Types/IncompleteArrayType.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class IncompleteArrayType : ArrayType { - internal IncompleteArrayType(CXType handle) : base(handle, CXTypeKind.CXType_IncompleteArray) + internal IncompleteArrayType(CXType handle) : base(handle, CXTypeKind.CXType_IncompleteArray, CX_TypeClass.CX_TypeClass_IncompleteArray) { } } diff --git a/sources/ClangSharp/Types/InjectedClassNameType.cs b/sources/ClangSharp/Types/InjectedClassNameType.cs new file mode 100644 index 00000000..1552ba91 --- /dev/null +++ b/sources/ClangSharp/Types/InjectedClassNameType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class InjectedClassNameType : Type + { + internal InjectedClassNameType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_InjectedClassName) + { + } + } +} diff --git a/sources/ClangSharp/Types/LValueReferenceType.cs b/sources/ClangSharp/Types/LValueReferenceType.cs index 0f4e300c..75257b1a 100644 --- a/sources/ClangSharp/Types/LValueReferenceType.cs +++ b/sources/ClangSharp/Types/LValueReferenceType.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class LValueReferenceType : ReferenceType { - internal LValueReferenceType(CXType handle) : base(handle, CXTypeKind.CXType_LValueReference) + internal LValueReferenceType(CXType handle) : base(handle, CXTypeKind.CXType_LValueReference, CX_TypeClass.CX_TypeClass_LValueReference) { } } diff --git a/sources/ClangSharp/Types/MacroQualifiedType.cs b/sources/ClangSharp/Types/MacroQualifiedType.cs new file mode 100644 index 00000000..68303b88 --- /dev/null +++ b/sources/ClangSharp/Types/MacroQualifiedType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class MacroQualifiedType : Type + { + internal MacroQualifiedType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_MacroQualified) + { + } + } +} diff --git a/sources/ClangSharp/Types/MemberPointerType.cs b/sources/ClangSharp/Types/MemberPointerType.cs new file mode 100644 index 00000000..51985279 --- /dev/null +++ b/sources/ClangSharp/Types/MemberPointerType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class MemberPointerType : Type + { + internal MemberPointerType(CXType handle) : base(handle, CXTypeKind.CXType_MemberPointer, CX_TypeClass.CX_TypeClass_MemberPointer) + { + } + } +} diff --git a/sources/ClangSharp/Types/ObjCInterfaceType.cs b/sources/ClangSharp/Types/ObjCInterfaceType.cs new file mode 100644 index 00000000..8b1a7b42 --- /dev/null +++ b/sources/ClangSharp/Types/ObjCInterfaceType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCInterfaceType : ObjCObjectType + { + internal ObjCInterfaceType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCObject, CX_TypeClass.CX_TypeClass_ObjCInterface) + { + } + } +} diff --git a/sources/ClangSharp/Types/ObjCObjectPointerType.cs b/sources/ClangSharp/Types/ObjCObjectPointerType.cs new file mode 100644 index 00000000..ffefdd91 --- /dev/null +++ b/sources/ClangSharp/Types/ObjCObjectPointerType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCObjectPointerType : Type + { + internal ObjCObjectPointerType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCObjectPointer, CX_TypeClass.CX_TypeClass_ObjCObjectPointer) + { + } + } +} diff --git a/sources/ClangSharp/Types/ObjCObjectType.cs b/sources/ClangSharp/Types/ObjCObjectType.cs new file mode 100644 index 00000000..7244a2b8 --- /dev/null +++ b/sources/ClangSharp/Types/ObjCObjectType.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class ObjCObjectType : Type + { + internal ObjCObjectType(CXType handle) : this(handle, CXTypeKind.CXType_ObjCObject, CX_TypeClass.CX_TypeClass_ObjCObject) + { + } + + private protected ObjCObjectType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + } + } +} diff --git a/sources/ClangSharp/Types/ObjCTypeParamType.cs b/sources/ClangSharp/Types/ObjCTypeParamType.cs new file mode 100644 index 00000000..7623ebf3 --- /dev/null +++ b/sources/ClangSharp/Types/ObjCTypeParamType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ObjCTypeParamType : Type + { + internal ObjCTypeParamType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCTypeParam, CX_TypeClass.CX_TypeClass_ObjCTypeParam) + { + } + } +} diff --git a/sources/ClangSharp/Types/PackExpansionType.cs b/sources/ClangSharp/Types/PackExpansionType.cs new file mode 100644 index 00000000..c094f118 --- /dev/null +++ b/sources/ClangSharp/Types/PackExpansionType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class PackExpansionType : Type + { + internal PackExpansionType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_PackExpansion) + { + } + } +} diff --git a/sources/ClangSharp/Types/ParenType.cs b/sources/ClangSharp/Types/ParenType.cs new file mode 100644 index 00000000..0c87108f --- /dev/null +++ b/sources/ClangSharp/Types/ParenType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class ParenType : Type + { + internal ParenType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Paren) + { + } + } +} diff --git a/sources/ClangSharp/Types/PipeType.cs b/sources/ClangSharp/Types/PipeType.cs new file mode 100644 index 00000000..d0fd94fe --- /dev/null +++ b/sources/ClangSharp/Types/PipeType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class PipeType : Type + { + internal PipeType(CXType handle) : base(handle, CXTypeKind.CXType_Pipe, CX_TypeClass.CX_TypeClass_Pipe) + { + } + } +} diff --git a/sources/ClangSharp/Types/PointerType.cs b/sources/ClangSharp/Types/PointerType.cs index 6d5fcba2..c7076e8e 100644 --- a/sources/ClangSharp/Types/PointerType.cs +++ b/sources/ClangSharp/Types/PointerType.cs @@ -9,7 +9,7 @@ public sealed class PointerType : Type { private readonly Lazy _pointeeType; - internal PointerType(CXType handle) : base(handle, CXTypeKind.CXType_Pointer) + internal PointerType(CXType handle) : base(handle, CXTypeKind.CXType_Pointer, CX_TypeClass.CX_TypeClass_Pointer) { _pointeeType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PointeeType)); } diff --git a/sources/ClangSharp/Types/RValueReferenceType.cs b/sources/ClangSharp/Types/RValueReferenceType.cs new file mode 100644 index 00000000..0097b09d --- /dev/null +++ b/sources/ClangSharp/Types/RValueReferenceType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class RValueReferenceType : ReferenceType + { + internal RValueReferenceType(CXType handle) : base(handle, CXTypeKind.CXType_RValueReference, CX_TypeClass.CX_TypeClass_RValueReference) + { + } + } +} diff --git a/sources/ClangSharp/Types/RecordType.cs b/sources/ClangSharp/Types/RecordType.cs index f6507f7d..4b08d0d7 100644 --- a/sources/ClangSharp/Types/RecordType.cs +++ b/sources/ClangSharp/Types/RecordType.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public sealed class RecordType : TagType { - internal RecordType(CXType handle) : base(handle, CXTypeKind.CXType_Record) + internal RecordType(CXType handle) : base(handle, CXTypeKind.CXType_Record, CX_TypeClass.CX_TypeClass_Record) { } } diff --git a/sources/ClangSharp/Types/ReferenceType.cs b/sources/ClangSharp/Types/ReferenceType.cs index 56c567a0..96dc7a94 100644 --- a/sources/ClangSharp/Types/ReferenceType.cs +++ b/sources/ClangSharp/Types/ReferenceType.cs @@ -9,7 +9,7 @@ public class ReferenceType : Type { private readonly Lazy _pointeeType; - private protected ReferenceType(CXType handle, CXTypeKind expectedKind) : base(handle, expectedKind) + private protected ReferenceType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) { _pointeeType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PointeeType)); } diff --git a/sources/ClangSharp/Types/SubstTemplateTypeParmPackType.cs b/sources/ClangSharp/Types/SubstTemplateTypeParmPackType.cs new file mode 100644 index 00000000..170f1383 --- /dev/null +++ b/sources/ClangSharp/Types/SubstTemplateTypeParmPackType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class SubstTemplateTypeParmPackType : Type + { + internal SubstTemplateTypeParmPackType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_SubstTemplateTypeParmPack) + { + } + } +} diff --git a/sources/ClangSharp/Types/SubstTemplateTypeParmType.cs b/sources/ClangSharp/Types/SubstTemplateTypeParmType.cs new file mode 100644 index 00000000..ddbb860c --- /dev/null +++ b/sources/ClangSharp/Types/SubstTemplateTypeParmType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class SubstTemplateTypeParmType : Type + { + internal SubstTemplateTypeParmType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_SubstTemplateTypeParm) + { + } + } +} diff --git a/sources/ClangSharp/Types/TagType.cs b/sources/ClangSharp/Types/TagType.cs index 586fe49f..eded4e7a 100644 --- a/sources/ClangSharp/Types/TagType.cs +++ b/sources/ClangSharp/Types/TagType.cs @@ -9,7 +9,7 @@ public class TagType : Type { private readonly Lazy _decl; - private protected TagType(CXType handle, CXTypeKind expectedKind) : base(handle, expectedKind) + private protected TagType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) { _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); } diff --git a/sources/ClangSharp/Types/TemplateSpecializationType.cs b/sources/ClangSharp/Types/TemplateSpecializationType.cs new file mode 100644 index 00000000..fc22aba0 --- /dev/null +++ b/sources/ClangSharp/Types/TemplateSpecializationType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class TemplateSpecializationType : Type + { + internal TemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TemplateSpecialization) + { + } + } +} diff --git a/sources/ClangSharp/Types/TemplateTypeParmType.cs b/sources/ClangSharp/Types/TemplateTypeParmType.cs new file mode 100644 index 00000000..affdfe3d --- /dev/null +++ b/sources/ClangSharp/Types/TemplateTypeParmType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class TemplateTypeParmType : Type + { + internal TemplateTypeParmType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TemplateTypeParm) + { + } + } +} diff --git a/sources/ClangSharp/Types/Type.cs b/sources/ClangSharp/Types/Type.cs index a9f17067..3d9f7226 100644 --- a/sources/ClangSharp/Types/Type.cs +++ b/sources/ClangSharp/Types/Type.cs @@ -11,12 +11,17 @@ public unsafe class Type : IEquatable private readonly Lazy _canonicalType; private readonly Lazy _translationUnit; - protected Type(CXType handle, CXTypeKind expectedKind) + protected Type(CXType handle, CXTypeKind expectedKind, CX_TypeClass expectedTypeClass) { if (handle.kind != expectedKind) { throw new ArgumentException(nameof(handle)); } + + if ((handle.TypeClass == CX_TypeClass.CX_TypeClass_Invalid) || (handle.TypeClass != expectedTypeClass)) + { + throw new ArgumentException(nameof(handle)); + } Handle = handle; _canonicalType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CanonicalType)); @@ -37,123 +42,64 @@ protected Type(CXType handle, CXTypeKind expectedKind) public TranslationUnit TranslationUnit => _translationUnit.Value; + public CX_TypeClass TypeClass => Handle.TypeClass; + public static bool operator ==(Type left, Type right) => (left is object) ? ((right is object) && (left.Handle == right.Handle)) : (right is null); public static bool operator !=(Type left, Type right) => (left is object) ? ((right is null) || (left.Handle != right.Handle)) : (right is object); - internal static Type Create(CXType handle) + internal static Type Create(CXType handle) => handle.TypeClass switch { - Type result; - - switch (handle.kind) - { - case CXTypeKind.CXType_Unexposed: - { - result = new Type(handle, CXTypeKind.CXType_Unexposed); - break; - } - - case CXTypeKind.CXType_Void: - case CXTypeKind.CXType_Bool: - case CXTypeKind.CXType_Char_U: - case CXTypeKind.CXType_UChar: - case CXTypeKind.CXType_UShort: - case CXTypeKind.CXType_UInt: - case CXTypeKind.CXType_ULong: - case CXTypeKind.CXType_ULongLong: - case CXTypeKind.CXType_Char_S: - case CXTypeKind.CXType_SChar: - case CXTypeKind.CXType_WChar: - case CXTypeKind.CXType_Short: - case CXTypeKind.CXType_Int: - case CXTypeKind.CXType_Long: - case CXTypeKind.CXType_LongLong: - case CXTypeKind.CXType_Float: - case CXTypeKind.CXType_Double: - case CXTypeKind.CXType_LongDouble: - case CXTypeKind.CXType_NullPtr: - case CXTypeKind.CXType_Dependent: - { - result = new BuiltinType(handle, handle.kind); - break; - } - - case CXTypeKind.CXType_Pointer: - { - result = new PointerType(handle); - break; - } - - case CXTypeKind.CXType_LValueReference: - { - result = new LValueReferenceType(handle); - break; - } - - case CXTypeKind.CXType_Record: - { - result = new RecordType(handle); - break; - } - - case CXTypeKind.CXType_Enum: - { - result = new EnumType(handle); - break; - } - - case CXTypeKind.CXType_Typedef: - { - result = new TypedefType(handle); - break; - } - - case CXTypeKind.CXType_FunctionProto: - { - result = new FunctionProtoType(handle); - break; - } - - case CXTypeKind.CXType_ConstantArray: - { - result = new ConstantArrayType(handle); - break; - } - - case CXTypeKind.CXType_IncompleteArray: - { - result = new IncompleteArrayType(handle); - break; - } - - case CXTypeKind.CXType_DependentSizedArray: - { - result = new DependentSizedArrayType(handle); - break; - } - - case CXTypeKind.CXType_Elaborated: - { - result = new ElaboratedType(handle); - break; - } - - case CXTypeKind.CXType_Attributed: - { - result = new AttributedType(handle); - break; - } - - default: - { - Debug.WriteLine($"Unhandled type kind: {handle.KindSpelling}."); - result = new Type(handle, handle.kind); - break; - } - } - - return result; - } + CX_TypeClass.CX_TypeClass_Builtin => new BuiltinType(handle), + CX_TypeClass.CX_TypeClass_Complex => new ComplexType(handle), + CX_TypeClass.CX_TypeClass_Pointer => new PointerType(handle), + CX_TypeClass.CX_TypeClass_BlockPointer => new BlockPointerType(handle), + CX_TypeClass.CX_TypeClass_LValueReference => new LValueReferenceType(handle), + CX_TypeClass.CX_TypeClass_RValueReference => new RValueReferenceType(handle), + CX_TypeClass.CX_TypeClass_MemberPointer => new MemberPointerType(handle), + CX_TypeClass.CX_TypeClass_ConstantArray => new ConstantArrayType(handle), + CX_TypeClass.CX_TypeClass_IncompleteArray => new IncompleteArrayType(handle), + CX_TypeClass.CX_TypeClass_VariableArray => new VariableArrayType(handle), + CX_TypeClass.CX_TypeClass_DependentSizedArray => new DependentSizedArrayType(handle), + CX_TypeClass.CX_TypeClass_DependentSizedExtVector => new DependentSizedExtVectorType(handle), + CX_TypeClass.CX_TypeClass_DependentAddressSpace => new DependentAddressSpaceType(handle), + CX_TypeClass.CX_TypeClass_Vector => new VectorType(handle), + CX_TypeClass.CX_TypeClass_DependentVector => new DependentVectorType(handle), + CX_TypeClass.CX_TypeClass_ExtVector => new ExtVectorType(handle), + CX_TypeClass.CX_TypeClass_FunctionProto => new FunctionProtoType(handle), + CX_TypeClass.CX_TypeClass_FunctionNoProto => new FunctionNoProtoType(handle), + CX_TypeClass.CX_TypeClass_UnresolvedUsing => new UnresolvedUsingType(handle), + CX_TypeClass.CX_TypeClass_Paren => new ParenType(handle), + CX_TypeClass.CX_TypeClass_Typedef => new TypedefType(handle), + CX_TypeClass.CX_TypeClass_MacroQualified => new MacroQualifiedType(handle), + CX_TypeClass.CX_TypeClass_Adjusted => new AdjustedType(handle), + CX_TypeClass.CX_TypeClass_Decayed => new DecayedType(handle), + CX_TypeClass.CX_TypeClass_TypeOfExpr => new TypeOfExprType(handle), + CX_TypeClass.CX_TypeClass_TypeOf => new TypeOfType(handle), + CX_TypeClass.CX_TypeClass_Decltype => new DecltypeType(handle), + CX_TypeClass.CX_TypeClass_UnaryTransform => new UnaryTransformType(handle), + CX_TypeClass.CX_TypeClass_Record => new RecordType(handle), + CX_TypeClass.CX_TypeClass_Enum => new EnumType(handle), + CX_TypeClass.CX_TypeClass_Elaborated => new ElaboratedType(handle), + CX_TypeClass.CX_TypeClass_Attributed => new AttributedType(handle), + CX_TypeClass.CX_TypeClass_TemplateTypeParm => new TemplateTypeParmType(handle), + CX_TypeClass.CX_TypeClass_SubstTemplateTypeParm => new SubstTemplateTypeParmType(handle), + CX_TypeClass.CX_TypeClass_SubstTemplateTypeParmPack => new SubstTemplateTypeParmPackType(handle), + CX_TypeClass.CX_TypeClass_TemplateSpecialization => new TemplateSpecializationType(handle), + CX_TypeClass.CX_TypeClass_Auto => new AutoType(handle), + CX_TypeClass.CX_TypeClass_DeducedTemplateSpecialization => new DeducedTemplateSpecializationType(handle), + CX_TypeClass.CX_TypeClass_InjectedClassName => new InjectedClassNameType(handle), + CX_TypeClass.CX_TypeClass_DependentName => new DependentNameType(handle), + CX_TypeClass.CX_TypeClass_DependentTemplateSpecialization => new DependentTemplateSpecializationType(handle), + CX_TypeClass.CX_TypeClass_PackExpansion => new PackExpansionType(handle), + CX_TypeClass.CX_TypeClass_ObjCTypeParam => new ObjCTypeParamType(handle), + CX_TypeClass.CX_TypeClass_ObjCObject => new ObjCObjectType(handle), + CX_TypeClass.CX_TypeClass_ObjCInterface => new ObjCInterfaceType(handle), + CX_TypeClass.CX_TypeClass_ObjCObjectPointer => new ObjCObjectPointerType(handle), + CX_TypeClass.CX_TypeClass_Pipe => new PipeType(handle), + CX_TypeClass.CX_TypeClass_Atomic => new AtomicType(handle), + _ => new Type(handle, handle.kind, handle.TypeClass), + }; public override bool Equals(object obj) => (obj is Type other) && Equals(other); diff --git a/sources/ClangSharp/Types/TypeOfExprType.cs b/sources/ClangSharp/Types/TypeOfExprType.cs new file mode 100644 index 00000000..8d3ac4c2 --- /dev/null +++ b/sources/ClangSharp/Types/TypeOfExprType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class TypeOfExprType : Type + { + internal TypeOfExprType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TypeOfExpr) + { + } + } +} diff --git a/sources/ClangSharp/Types/TypeOfType.cs b/sources/ClangSharp/Types/TypeOfType.cs new file mode 100644 index 00000000..1ef6a854 --- /dev/null +++ b/sources/ClangSharp/Types/TypeOfType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class TypeOfType : Type + { + internal TypeOfType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TypeOf) + { + } + } +} diff --git a/sources/ClangSharp/Types/TypeWithKeyword.cs b/sources/ClangSharp/Types/TypeWithKeyword.cs index cbfd8718..9e219ab5 100644 --- a/sources/ClangSharp/Types/TypeWithKeyword.cs +++ b/sources/ClangSharp/Types/TypeWithKeyword.cs @@ -6,7 +6,7 @@ namespace ClangSharp { public class TypeWithKeyword : Type { - private protected TypeWithKeyword(CXType handle, CXTypeKind expectedKind) : base(handle, expectedKind) + private protected TypeWithKeyword(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) { } } diff --git a/sources/ClangSharp/Types/TypedefType.cs b/sources/ClangSharp/Types/TypedefType.cs index e9e9c26b..d731d2a0 100644 --- a/sources/ClangSharp/Types/TypedefType.cs +++ b/sources/ClangSharp/Types/TypedefType.cs @@ -9,7 +9,7 @@ public sealed class TypedefType : Type { private readonly Lazy _decl; - internal TypedefType(CXType handle) : base(handle, CXTypeKind.CXType_Typedef) + internal TypedefType(CXType handle) : base(handle, CXTypeKind.CXType_Typedef, CX_TypeClass.CX_TypeClass_Typedef) { _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); } diff --git a/sources/ClangSharp/Types/UnaryTransformType.cs b/sources/ClangSharp/Types/UnaryTransformType.cs new file mode 100644 index 00000000..2654c48d --- /dev/null +++ b/sources/ClangSharp/Types/UnaryTransformType.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class UnaryTransformType : Type + { + internal UnaryTransformType(CXType handle) : this(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_UnaryTransform) + { + } + + private protected UnaryTransformType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + } + } +} diff --git a/sources/ClangSharp/Types/UnresolvedUsingType.cs b/sources/ClangSharp/Types/UnresolvedUsingType.cs new file mode 100644 index 00000000..85d944a4 --- /dev/null +++ b/sources/ClangSharp/Types/UnresolvedUsingType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class UnresolvedUsingType : Type + { + internal UnresolvedUsingType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_UnresolvedUsing) + { + } + } +} diff --git a/sources/ClangSharp/Types/VariableArrayType.cs b/sources/ClangSharp/Types/VariableArrayType.cs new file mode 100644 index 00000000..7e1edc9d --- /dev/null +++ b/sources/ClangSharp/Types/VariableArrayType.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public sealed class VariableArrayType : ArrayType + { + internal VariableArrayType(CXType handle) : base(handle, CXTypeKind.CXType_VariableArray, CX_TypeClass.CX_TypeClass_VariableArray) + { + } + } +} diff --git a/sources/ClangSharp/Types/VectorType.cs b/sources/ClangSharp/Types/VectorType.cs new file mode 100644 index 00000000..042e16e1 --- /dev/null +++ b/sources/ClangSharp/Types/VectorType.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +using ClangSharp.Interop; + +namespace ClangSharp +{ + public class VectorType : Type + { + internal VectorType(CXType handle) : base(handle, CXTypeKind.CXType_Vector, CX_TypeClass.CX_TypeClass_Vector) + { + } + + private protected VectorType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + } + } +} diff --git a/sources/libClangSharp/CIndexDiagnostic.cpp b/sources/libClangSharp/CIndexDiagnostic.cpp new file mode 100644 index 00000000..5f5296f5 --- /dev/null +++ b/sources/libClangSharp/CIndexDiagnostic.cpp @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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" + +namespace clang { + CXDiagnosticSetImpl::~CXDiagnosticSetImpl() { } + + void CXDiagnosticSetImpl::appendDiagnostic(std::unique_ptr D) { + Diagnostics.push_back(std::move(D)); + } + + CXDiagnosticImpl::~CXDiagnosticImpl() { } +} diff --git a/sources/libClangSharp/CIndexDiagnostic.h b/sources/libClangSharp/CIndexDiagnostic.h new file mode 100644 index 00000000..07d464e1 --- /dev/null +++ b/sources/libClangSharp/CIndexDiagnostic.h @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +#define LIBCLANGSHARP_CINDEXDIAGNOSTIC_H + +#include +#include + +#include +#include +#include +#include + +namespace clang { + class CXDiagnosticImpl; + + class CXDiagnosticSetImpl { + std::vector> Diagnostics; + const bool IsExternallyManaged; + + public: + CXDiagnosticSetImpl(bool isManaged = false) + : IsExternallyManaged(isManaged) { } + + virtual ~CXDiagnosticSetImpl(); + + size_t getNumDiagnostics() const { + return Diagnostics.size(); + } + + CXDiagnosticImpl* getDiagnostic(unsigned i) const { + assert(i < getNumDiagnostics()); + return Diagnostics[i].get(); + } + + void appendDiagnostic(std::unique_ptr D); + + bool empty() const { + return Diagnostics.empty(); + } + + bool isExternallyManaged() const { return IsExternallyManaged; } + }; + + class CXDiagnosticImpl { + public: + enum Kind { + StoredDiagnosticKind, LoadedDiagnosticKind, + CustomNoteDiagnosticKind + }; + + virtual ~CXDiagnosticImpl(); + + /// Return the severity of the diagnostic. + virtual CXDiagnosticSeverity getSeverity() const = 0; + + /// Return the location of the diagnostic. + virtual CXSourceLocation getLocation() const = 0; + + /// Return the spelling of the diagnostic. + virtual CXString getSpelling() const = 0; + + /// Return the text for the diagnostic option. + virtual CXString getDiagnosticOption(CXString* Disable) const = 0; + + /// Return the category of the diagnostic. + virtual unsigned getCategory() const = 0; + + /// Return the category string of the diagnostic. + virtual CXString getCategoryText() const = 0; + + /// Return the number of source ranges for the diagnostic. + virtual unsigned getNumRanges() const = 0; + + /// Return the source ranges for the diagnostic. + virtual CXSourceRange getRange(unsigned Range) const = 0; + + /// Return the number of FixIts. + virtual unsigned getNumFixIts() const = 0; + + /// Return the FixIt information (source range and inserted text). + virtual CXString getFixIt(unsigned FixIt, CXSourceRange* ReplacementRange) const = 0; + + Kind getKind() const { return K; } + + CXDiagnosticSetImpl& getChildDiagnostics() { + return ChildDiags; + } + + protected: + CXDiagnosticImpl(Kind k) : K(k) {} + CXDiagnosticSetImpl ChildDiags; + + void append(std::unique_ptr D) { + ChildDiags.appendDiagnostic(std::move(D)); + } + + private: + Kind K; + }; +} + +#endif diff --git a/sources/libClangSharp/CMakeLists.txt b/sources/libClangSharp/CMakeLists.txt new file mode 100644 index 00000000..85072124 --- /dev/null +++ b/sources/libClangSharp/CMakeLists.txt @@ -0,0 +1,47 @@ +set(SOURCES + CIndexDiagnostic.cpp + ClangSharp.cpp + CXCursor.cpp + CXLoadedDiagnostic.cpp + CXSourceLocation.cpp + CXString.cpp + CXTranslationUnit.cpp + CXType.cpp + + CIndexDiagnostic.h + ClangSharp.h + CXCursor.h + CXLoadedDiagnostic.h + CXSourceLocation.h + CXString.h + CXTranslationUnit.h + CXType.h +) + +set(LIBS + clangAST + clangFrontend +) + +set(LLVM_SEARCH_PATHS + ${PATH_TO_LLVM} + ${PATH_TO_LLVM}/lib/cmake + ${PATH_TO_LLVM}/lib/cmake/llvm + ${PATH_TO_LLVM}/lib/cmake/clang + ${PATH_TO_LLVM}/share/clang/cmake/ + ${PATH_TO_LLVM}/share/llvm/cmake/ +) + +find_package(Clang REQUIRED CONFIG + PATHS ${LLVM_SEARCH_PATHS} + NO_DEFAULT_PATH) + +if(WIN32) + add_library(libClangSharp SHARED ${SOURCES}) + target_include_directories(libClangSharp PUBLIC ${LLVM_INCLUDE_DIRS}) + target_link_libraries(libClangSharp ${LIBS}) +else() + add_library(ClangSharp SHARED ${SOURCES}) + target_include_directories(ClangSharp PUBLIC ${LLVM_INCLUDE_DIRS}) + target_link_libraries(ClangSharp ${LIBS}) +endif() diff --git a/sources/libClangSharp/CXCursor.cpp b/sources/libClangSharp/CXCursor.cpp new file mode 100644 index 00000000..b0b68632 --- /dev/null +++ b/sources/libClangSharp/CXCursor.cpp @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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" +#include "CXCursor.h" +#include "CXTranslationUnit.h" + +using namespace clang::cxtu; + +namespace clang::cxcursor { + const IdentifierInfo* MacroExpansionCursor::getName() const { + if (isPseudo()) + return getAsMacroDefinition()->getName(); + return getAsMacroExpansion()->getName(); + } + + const MacroDefinitionRecord* MacroExpansionCursor::getDefinition() const { + if (isPseudo()) + return getAsMacroDefinition(); + return getAsMacroExpansion()->getDefinition(); + } + + SourceRange MacroExpansionCursor::getSourceRange() const { + if (isPseudo()) + return getPseudoLoc(); + return getAsMacroExpansion()->getSourceRange(); + } + + ASTUnit* getCursorASTUnit(CXCursor Cursor) { + CXTranslationUnit TU = getCursorTU(Cursor); + if (!TU) + return nullptr; + return getASTUnit(TU); + } + + ASTContext& getCursorContext(CXCursor Cursor) { + return getCursorASTUnit(Cursor)->getASTContext(); + } + + CXTranslationUnit getCursorTU(CXCursor Cursor) { + return static_cast(const_cast(Cursor.data[2])); + } + + const Attr* getCursorAttr(CXCursor Cursor) { + return static_cast(Cursor.data[1]); + } + + const Decl* getCursorDecl(CXCursor Cursor) { + return static_cast(Cursor.data[0]); + } + + const Expr* getCursorExpr(CXCursor Cursor) { + return dyn_cast_or_null(getCursorStmt(Cursor)); + } + + const Stmt* getCursorStmt(CXCursor Cursor) { + if (Cursor.kind == CXCursor_ObjCSuperClassRef || + Cursor.kind == CXCursor_ObjCProtocolRef || + Cursor.kind == CXCursor_ObjCClassRef) + return nullptr; + + return static_cast(Cursor.data[1]); + } + + const CXXBaseSpecifier* getCursorCXXBaseSpecifier(CXCursor C) { + assert(C.kind == CXCursor_CXXBaseSpecifier); + return static_cast(C.data[0]); + } + + const InclusionDirective* getCursorInclusionDirective(CXCursor C) { + assert(C.kind == CXCursor_InclusionDirective); + return static_cast(C.data[0]); + } + + const MacroDefinitionRecord* getCursorMacroDefinition(CXCursor C) { + assert(C.kind == CXCursor_MacroDefinition); + return static_cast(C.data[0]); + } + + MacroExpansionCursor getCursorMacroExpansion(CXCursor C) { + return C; + } + + SourceRange getCursorPreprocessingDirective(CXCursor C) { + assert(C.kind == CXCursor_PreprocessingDirective); + SourceRange Range(SourceLocation::getFromPtrEncoding(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + ASTUnit* TU = getCursorASTUnit(C); + return TU->mapRangeFromPreamble(Range); + } + + std::pair getCursorLabelRef(CXCursor C) { + assert(C.kind == CXCursor_LabelRef); + return std::make_pair(static_cast(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + std::pair getCursorMemberRef(CXCursor C) { + assert(C.kind == CXCursor_MemberRef); + return std::make_pair(static_cast(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + std::pair getCursorNamespaceRef(CXCursor C) { + assert(C.kind == CXCursor_NamespaceRef); + return std::make_pair(static_cast(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + std::pair getCursorObjCClassRef(CXCursor C) { + assert(C.kind == CXCursor_ObjCClassRef); + return std::make_pair(static_cast(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + std::pair getCursorObjCProtocolRef(CXCursor C) { + assert(C.kind == CXCursor_ObjCProtocolRef); + return std::make_pair(static_cast(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + std::pair getCursorObjCSuperClassRef(CXCursor C) { + assert(C.kind == CXCursor_ObjCSuperClassRef); + return std::make_pair(static_cast(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + std::pair getCursorOverloadedDeclRef(CXCursor C) { + assert(C.kind == CXCursor_OverloadedDeclRef); + return std::make_pair(OverloadedDeclRefStorage::getFromOpaqueValue(const_cast(C.data[0])), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + std::pair getCursorTemplateRef(CXCursor C) { + assert(C.kind == CXCursor_TemplateRef); + return std::make_pair(static_cast(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + std::pair getCursorTypeRef(CXCursor C) { + assert(C.kind == CXCursor_TypeRef); + return std::make_pair(static_cast(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + std::pair getCursorVariableRef(CXCursor C) { + assert(C.kind == CXCursor_VariableRef); + return std::make_pair(static_cast(C.data[0]), SourceLocation::getFromPtrEncoding(C.data[1])); + } + + bool isFirstInDeclGroup(CXCursor C) { + assert(clangsharp_isDeclaration(C.kind)); + return ((uintptr_t)(C.data[1])) != 0; + } +} diff --git a/sources/libClangSharp/CXCursor.h b/sources/libClangSharp/CXCursor.h new file mode 100644 index 00000000..3409a08c --- /dev/null +++ b/sources/libClangSharp/CXCursor.h @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +#define LIBCLANGSHARP_CXCURSOR_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace clang::cxcursor { + typedef llvm::PointerUnion3 OverloadedDeclRefStorage; + + /// Wraps a macro expansion cursor and provides a common interface + /// for a normal macro expansion cursor or a "pseudo" one. + /// + /// "Pseudo" macro expansion cursors (essentially a macro definition along with + /// a source location) are created in special cases, for example they can be + /// created for identifiers inside macro definitions, if these identifiers are + /// macro names. + class MacroExpansionCursor { + CXCursor C; + + bool isPseudo() const { return C.data[1] != nullptr; } + + const MacroDefinitionRecord* getAsMacroDefinition() const { + assert(isPseudo()); + return static_cast(C.data[0]); + } + + const MacroExpansion* getAsMacroExpansion() const { + assert(!isPseudo()); + return static_cast(C.data[0]); + } + + SourceLocation getPseudoLoc() const { + assert(isPseudo()); + return SourceLocation::getFromPtrEncoding(C.data[1]); + } + + public: + MacroExpansionCursor(CXCursor C) : C(C) { + assert(C.kind == CXCursor_MacroExpansion); + } + + const IdentifierInfo* getName() const; + const MacroDefinitionRecord* getDefinition() const; + SourceRange getSourceRange() const; + }; + + ASTUnit* getCursorASTUnit(CXCursor Cursor); + ASTContext& getCursorContext(CXCursor Cursor); + CXTranslationUnit getCursorTU(CXCursor Cursor); + + const Attr* getCursorAttr(CXCursor Cursor); + const Decl* getCursorDecl(CXCursor Cursor); + const Expr* getCursorExpr(CXCursor Cursor); + const Stmt* getCursorStmt(CXCursor Cursor); + + /// Unpack a CXXBaseSpecifier cursor into a CXXBaseSpecifier. + const CXXBaseSpecifier* getCursorCXXBaseSpecifier(CXCursor C); + + /// Unpack a given inclusion directive cursor to retrieve its source range. + const InclusionDirective* getCursorInclusionDirective(CXCursor C); + + /// Unpack a given macro definition cursor to retrieve its source range. + const MacroDefinitionRecord* getCursorMacroDefinition(CXCursor C); + + /// Unpack a given macro expansion cursor to retrieve its info. + MacroExpansionCursor getCursorMacroExpansion(CXCursor C); + + /// Unpack a given preprocessing directive to retrieve its source range. + SourceRange getCursorPreprocessingDirective(CXCursor C); + + /// Unpack a label reference into the label statement it refers to and the location of the reference. + std::pair getCursorLabelRef(CXCursor C); + + /// Unpack a MemberRef cursor into the field it references and the location where the reference occurred. + std::pair getCursorMemberRef(CXCursor C); + + /// Unpack a NamespaceRef cursor into the namespace or namespace alias it references and the location where the reference occurred. + std::pair getCursorNamespaceRef(CXCursor C); + + /// Unpack an ObjCClassRef cursor into the class it references and optionally the location where the reference occurred. + std::pair getCursorObjCClassRef(CXCursor C); + + /// Unpack an ObjCProtocolRef cursor into the protocol it references and optionally the location where the reference occurred. + std::pair getCursorObjCProtocolRef(CXCursor C); + + /// Unpack an ObjCSuperClassRef cursor into the interface it references and optionally the location where the reference occurred. + std::pair getCursorObjCSuperClassRef(CXCursor C); + + /// Unpack an overloaded declaration reference into an expression, declaration, or template name along with the source location. + std::pair getCursorOverloadedDeclRef(CXCursor C); + + /// Unpack a TemplateRef cursor into the template it references and the location where the reference occurred. + std::pair getCursorTemplateRef(CXCursor C); + + /// Unpack a TypeRef cursor into the class it references and optionally the location where the reference occurred. + std::pair getCursorTypeRef(CXCursor C); + + /// Unpack a VariableRef cursor into the variable it references and the location where the where the reference occurred. + std::pair getCursorVariableRef(CXCursor C); + + // FIXME: Remove once we can model DeclGroups and their appropriate ranges properly in the ASTs. + bool isFirstInDeclGroup(CXCursor C); +} + +#endif diff --git a/sources/libClangSharp/CXLoadedDiagnostic.cpp b/sources/libClangSharp/CXLoadedDiagnostic.cpp new file mode 100644 index 00000000..f0caa18a --- /dev/null +++ b/sources/libClangSharp/CXLoadedDiagnostic.cpp @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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" +#include "CXString.h" + +#include +#include + +namespace clang { + CXLoadedDiagnostic::~CXLoadedDiagnostic() { } + + CXDiagnosticSeverity CXLoadedDiagnostic::getSeverity() const { + // FIXME: Fail more softly if the diagnostic level is unknown? + auto severityAsLevel = static_cast(severity); + assert(severity == static_cast(severityAsLevel) && "unknown serialized diagnostic level"); + + switch (severityAsLevel) { +#define CASE(X) case serialized_diags::X: return CXDiagnostic_##X; + CASE(Ignored) + CASE(Note) + CASE(Warning) + CASE(Error) + CASE(Fatal) +#undef CASE + // The 'Remark' level isn't represented in the stable API. + case serialized_diags::Remark: return CXDiagnostic_Warning; + } + + llvm_unreachable("Invalid diagnostic level"); + } + + static CXSourceLocation makeLocation(const CXLoadedDiagnostic::Location* DLoc) { + // The lowest bit of ptr_data[0] is always set to 1 to indicate this + // is a persistent diagnostic. + uintptr_t V = (uintptr_t)DLoc; + V |= 0x1; + CXSourceLocation Loc = { { (void*)V, nullptr }, 0 }; + return Loc; + } + + CXSourceLocation CXLoadedDiagnostic::getLocation() const { + // The lowest bit of ptr_data[0] is always set to 1 to indicate this + // is a persistent diagnostic. + return makeLocation(&DiagLoc); + } + + CXString CXLoadedDiagnostic::getSpelling() const { + return cxstring::createRef(Spelling); + } + + CXString CXLoadedDiagnostic::getDiagnosticOption(CXString* Disable) const { + if (DiagOption.empty()) + return cxstring::createEmpty(); + + // FIXME: possibly refactor with logic in CXStoredDiagnostic. + if (Disable) + *Disable = cxstring::createDup((llvm::Twine("-Wno-") + DiagOption).str()); + return cxstring::createDup((llvm::Twine("-W") + DiagOption).str()); + } + + unsigned CXLoadedDiagnostic::getCategory() const { + return category; + } + + CXString CXLoadedDiagnostic::getCategoryText() const { + return cxstring::createDup(CategoryText); + } + + unsigned CXLoadedDiagnostic::getNumRanges() const { + return Ranges.size(); + } + + CXSourceRange CXLoadedDiagnostic::getRange(unsigned Range) const { + assert(Range < Ranges.size()); + return Ranges[Range]; + } + + unsigned CXLoadedDiagnostic::getNumFixIts() const { + return FixIts.size(); + } + + CXString CXLoadedDiagnostic::getFixIt(unsigned FixIt, CXSourceRange* ReplacementRange) const { + assert(FixIt < FixIts.size()); + if (ReplacementRange) + *ReplacementRange = FixIts[FixIt].first; + return cxstring::createRef(FixIts[FixIt].second); + } + + void CXLoadedDiagnostic::decodeLocation(CXSourceLocation location, CXFile* file, unsigned* line, unsigned* column, unsigned* offset) + { + // CXSourceLocation consists of the following fields: + // + // void *ptr_data[2]; + // unsigned int_data; + // + // The lowest bit of ptr_data[0] is always set to 1 to indicate this + // is a persistent diagnostic. + // + // For now, do the unoptimized approach and store the data in a side + // data structure. We can optimize this case later. + + uintptr_t V = (uintptr_t)location.ptr_data[0]; + assert((V & 0x1) == 1); + V &= ~(uintptr_t)1; + + const Location& Loc = *((Location*)V); + + if (file) + *file = Loc.file; + if (line) + *line = Loc.line; + if (column) + *column = Loc.column; + if (offset) + *offset = Loc.offset; + } +} diff --git a/sources/libClangSharp/CXLoadedDiagnostic.h b/sources/libClangSharp/CXLoadedDiagnostic.h new file mode 100644 index 00000000..c0765631 --- /dev/null +++ b/sources/libClangSharp/CXLoadedDiagnostic.h @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +#define LIBCLANGSHARP_CXLOADEDDIAGNOSTIC_H + +#include "CIndexDiagnostic.h" +#include + +namespace clang { + class CXLoadedDiagnostic : public CXDiagnosticImpl { + public: + CXLoadedDiagnostic() + : CXDiagnosticImpl(LoadedDiagnosticKind), Spelling(nullptr), severity(0), category(0) { } + + ~CXLoadedDiagnostic() override; + + /// Return the severity of the diagnostic. + CXDiagnosticSeverity getSeverity() const override; + + /// Return the location of the diagnostic. + CXSourceLocation getLocation() const override; + + /// Return the spelling of the diagnostic. + CXString getSpelling() const override; + + /// Return the text for the diagnostic option. + CXString getDiagnosticOption(CXString* Disable) const override; + + /// Return the category of the diagnostic. + unsigned getCategory() const override; + + /// Return the category string of the diagnostic. + CXString getCategoryText() const override; + + /// Return the number of source ranges for the diagnostic. + unsigned getNumRanges() const override; + + /// Return the source ranges for the diagnostic. + CXSourceRange getRange(unsigned Range) const override; + + /// Return the number of FixIts. + unsigned getNumFixIts() const override; + + /// Return the FixIt information (source range and inserted text). + CXString getFixIt(unsigned FixIt, CXSourceRange* ReplacementRange) const override; + + static bool classof(const CXDiagnosticImpl* D) { + return D->getKind() == LoadedDiagnosticKind; + } + + /// Decode the CXSourceLocation into file, line, column, and offset. + static void decodeLocation(CXSourceLocation location, CXFile* file, unsigned* line, unsigned* column, unsigned* offset); + + struct Location { + CXFile file; + unsigned line; + unsigned column; + unsigned offset; + + Location() : file(nullptr), line(0), column(0), offset(0) { } + }; + + Location DiagLoc; + + std::vector Ranges; + std::vector > FixIts; + const char* Spelling; + llvm::StringRef DiagOption; + llvm::StringRef CategoryText; + unsigned severity; + unsigned category; + }; +} + +#endif diff --git a/sources/libClangSharp/CXSourceLocation.cpp b/sources/libClangSharp/CXSourceLocation.cpp new file mode 100644 index 00000000..c5bc15a0 --- /dev/null +++ b/sources/libClangSharp/CXSourceLocation.cpp @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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" +#include "CXCursor.h" +#include "CXSourceLocation.h" + +#include +#include +#include + +void createNullLocation(CXFile* file, unsigned* line, unsigned* column, unsigned* offset) +{ + if (file) + *file = nullptr; + if (line) + *line = 0; + if (column) + *column = 0; + if (offset) + *offset = 0; +} + +clang::SourceRange getRawCursorExtent(CXCursor C) { + using namespace clang; + using namespace clang::cxcursor; + + if (clangsharp_isReference(C.kind)) { + switch (C.kind) { + case CXCursor_ObjCSuperClassRef: + return getCursorObjCSuperClassRef(C).second; + + case CXCursor_ObjCProtocolRef: + return getCursorObjCProtocolRef(C).second; + + case CXCursor_ObjCClassRef: + return getCursorObjCClassRef(C).second; + + case CXCursor_TypeRef: + return getCursorTypeRef(C).second; + + case CXCursor_TemplateRef: + return getCursorTemplateRef(C).second; + + case CXCursor_NamespaceRef: + return getCursorNamespaceRef(C).second; + + case CXCursor_MemberRef: + return getCursorMemberRef(C).second; + + case CXCursor_CXXBaseSpecifier: + return getCursorCXXBaseSpecifier(C)->getSourceRange(); + + case CXCursor_LabelRef: + return getCursorLabelRef(C).second; + + case CXCursor_OverloadedDeclRef: + return getCursorOverloadedDeclRef(C).second; + + case CXCursor_VariableRef: + return getCursorVariableRef(C).second; + + default: + // FIXME: Need a way to enumerate all non-reference cases. + llvm_unreachable("Missed a reference kind"); + } + } + + if (clangsharp_isExpression(C.kind)) + return getCursorExpr(C)->getSourceRange(); + + if (clangsharp_isStatement(C.kind)) + return getCursorStmt(C)->getSourceRange(); + + if (clangsharp_isAttribute(C.kind)) + return getCursorAttr(C)->getRange(); + + if (C.kind == CXCursor_PreprocessingDirective) + return getCursorPreprocessingDirective(C); + + if (C.kind == CXCursor_MacroExpansion) { + ASTUnit* TU = getCursorASTUnit(C); + SourceRange Range = getCursorMacroExpansion(C).getSourceRange(); + return TU->mapRangeFromPreamble(Range); + } + + if (C.kind == CXCursor_MacroDefinition) { + ASTUnit* TU = getCursorASTUnit(C); + SourceRange Range = getCursorMacroDefinition(C)->getSourceRange(); + return TU->mapRangeFromPreamble(Range); + } + + if (C.kind == CXCursor_InclusionDirective) { + ASTUnit* TU = getCursorASTUnit(C); + SourceRange Range = getCursorInclusionDirective(C)->getSourceRange(); + return TU->mapRangeFromPreamble(Range); + } + + if (C.kind == CXCursor_TranslationUnit) { + ASTUnit* TU = getCursorASTUnit(C); + FileID MainID = TU->getSourceManager().getMainFileID(); + SourceLocation Start = TU->getSourceManager().getLocForStartOfFile(MainID); + SourceLocation End = TU->getSourceManager().getLocForEndOfFile(MainID); + return SourceRange(Start, End); + } + + if (clangsharp_isDeclaration(C.kind)) { + const Decl* D = getCursorDecl(C); + if (!D) + return SourceRange(); + + SourceRange R = D->getSourceRange(); + // FIXME: Multiple variables declared in a single declaration + // currently lack the information needed to correctly determine their + // ranges when accounting for the type-specifier. We use context + // stored in the CXCursor to determine if the VarDecl is in a DeclGroup, + // and if so, whether it is the first decl. + if (const VarDecl* VD = dyn_cast(D)) { + if (!isFirstInDeclGroup(C)) + R.setBegin(VD->getLocation()); + } + return R; + } + return SourceRange(); +} + +bool isASTUnitSourceLocation(const CXSourceLocation& L) { + // If the lowest bit is clear then the first ptr_data entry is a SourceManager + // pointer, or the CXSourceLocation is a null location. + return ((uintptr_t)L.ptr_data[0] & 0x1) == 0; +} + +namespace clang::cxloc { + CXSourceRange translateSourceRange(ASTContext& Context, SourceRange R) { + return translateSourceRange(Context.getSourceManager(), Context.getLangOpts(), CharSourceRange::getTokenRange(R)); + } + + CXSourceRange translateSourceRange(const SourceManager& SM, const LangOptions& LangOpts, const CharSourceRange& R) { + SourceLocation EndLoc = R.getEnd(); + bool IsTokenRange = R.isTokenRange(); + if (IsTokenRange && EndLoc.isValid()) { + unsigned Length = Lexer::MeasureTokenLength(SM.getSpellingLoc(EndLoc), SM, LangOpts); + EndLoc = EndLoc.getLocWithOffset(Length); + } + + CXSourceRange Result = { + { &SM, &LangOpts }, + R.getBegin().getRawEncoding(), + EndLoc.getRawEncoding() + }; + return Result; + } +} diff --git a/sources/libClangSharp/CXSourceLocation.h b/sources/libClangSharp/CXSourceLocation.h new file mode 100644 index 00000000..e7ded7c6 --- /dev/null +++ b/sources/libClangSharp/CXSourceLocation.h @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +#define LIBCLANGSHARP_CXSOURCELOCATION_H + +#include +#include +#include +#include + +void createNullLocation(CXFile* file, unsigned* line, unsigned* column, unsigned* offset); + +clang::SourceRange getRawCursorExtent(CXCursor C); + +bool isASTUnitSourceLocation(const CXSourceLocation& L); + +namespace clang::cxloc { + CXSourceRange translateSourceRange(ASTContext& Context, SourceRange R); + CXSourceRange translateSourceRange(const SourceManager& SM, const LangOptions& LangOpts, const CharSourceRange& R); +} + +#endif diff --git a/sources/libClangSharp/CXString.cpp b/sources/libClangSharp/CXString.cpp new file mode 100644 index 00000000..c31378df --- /dev/null +++ b/sources/libClangSharp/CXString.cpp @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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" + +namespace clang::cxstring { + CXString createDup(llvm::StringRef String) { + CXString Result; + char* Spelling = static_cast(llvm::safe_malloc(String.size() + 1)); + memmove(Spelling, String.data(), String.size()); + Spelling[String.size()] = 0; + Result.data = Spelling; + Result.private_flags = (unsigned)CXS_Malloc; + return Result; + } + + CXString createEmpty() { + CXString Str; + Str.data = ""; + Str.private_flags = CXS_Unmanaged; + return Str; + } + + CXString createRef(const char* String) { + if (String && String[0] == '\0') + return createEmpty(); + + CXString Str; + Str.data = String; + Str.private_flags = CXS_Unmanaged; + return Str; + } +} diff --git a/sources/libClangSharp/CXString.h b/sources/libClangSharp/CXString.h new file mode 100644 index 00000000..0e01c122 --- /dev/null +++ b/sources/libClangSharp/CXString.h @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +#define LIBCLANGSHARP_CXSTRING_H + +#include +#include + +/// Describes the kind of underlying data in CXString. +enum CXStringFlag { + /// CXString contains a 'const char *' that it doesn't own. + CXS_Unmanaged, + + /// CXString contains a 'const char *' that it allocated with malloc(). + CXS_Malloc, + + /// CXString contains a CXStringBuf that needs to be returned to the + /// CXStringPool. + CXS_StringBuf +}; + +namespace clang::cxstring { + /// Create a CXString object from a StringRef. New CXString will + /// contain a copy of \p String. + /// + /// \p String can be changed or freed by the caller. + CXString createDup(llvm::StringRef String); + + /// Create a CXString object for an empty "" string. + CXString createEmpty(); + + /// Create a CXString object from a nul-terminated C string. New + /// CXString may contain a pointer to \p String. + /// + /// \p String should not be changed by the caller afterwards. + CXString createRef(const char* String); +} + +#endif diff --git a/sources/libClangSharp/CXTranslationUnit.cpp b/sources/libClangSharp/CXTranslationUnit.cpp new file mode 100644 index 00000000..9a3d22fb --- /dev/null +++ b/sources/libClangSharp/CXTranslationUnit.cpp @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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" + +namespace clang::cxtu { + ASTUnit* getASTUnit(CXTranslationUnit TU) { + if (!TU) + return nullptr; + return TU->TheASTUnit; + } +} diff --git a/sources/libClangSharp/CXTranslationUnit.h b/sources/libClangSharp/CXTranslationUnit.h new file mode 100644 index 00000000..7fb68cf1 --- /dev/null +++ b/sources/libClangSharp/CXTranslationUnit.h @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +#define LIBCLANGSHARP_CXTRANSLATIONUNIT_H + +#include +#include + +namespace clang { + class CIndexer; +} + +namespace clang::index { + class CommentToXMLConverter; +} + +namespace clang::cxstring { + class CXStringPool; +} + +struct CXTranslationUnitImpl { + clang::CIndexer* CIdx; + clang::ASTUnit* TheASTUnit; + clang::cxstring::CXStringPool* StringPool; + void* Diagnostics; + void* OverridenCursorsPool; + clang::index::CommentToXMLConverter* CommentToXML; + unsigned ParsingOptions; + std::vector Arguments; +}; + +namespace clang::cxtu { + ASTUnit* getASTUnit(CXTranslationUnit TU); +} + +#endif diff --git a/sources/libClangSharp/CXType.cpp b/sources/libClangSharp/CXType.cpp new file mode 100644 index 00000000..5603f486 --- /dev/null +++ b/sources/libClangSharp/CXType.cpp @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 "CXType.h" + +using namespace clang; + +QualType GetQualType(CXType CT) { + return QualType::getFromOpaquePtr(CT.data[0]); +} diff --git a/sources/libClangSharp/CXType.h b/sources/libClangSharp/CXType.h new file mode 100644 index 00000000..15652fe8 --- /dev/null +++ b/sources/libClangSharp/CXType.h @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +// Ported from https://github.com/llvm/llvm-project/tree/llvmorg-9.0.0/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 +#define LIBCLANGSHARP_CXTYPE_H + +#include +#include + +clang::QualType GetQualType(CXType CT); + +#endif diff --git a/sources/libClangSharp/ClangSharp.cpp b/sources/libClangSharp/ClangSharp.cpp new file mode 100644 index 00000000..39903b59 --- /dev/null +++ b/sources/libClangSharp/ClangSharp.cpp @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +#include "ClangSharp.h" +#include "CXCursor.h" +#include "CXLoadedDiagnostic.h" +#include "CXSourceLocation.h" +#include "CXString.h" +#include "CXType.h" + +#include + +using namespace clang; +using namespace clang::cxcursor; +using namespace clang::cxloc; +using namespace clang::cxstring; + +CX_AttrKind clangsharp_Cursor_getAttrKind(CXCursor C) { + if (clangsharp_isAttribute(C.kind)) { + const Attr* A = getCursorAttr(C); + return static_cast(A->getKind() + 1); + } + + return CX_AttrKind_Invalid; +} + +CX_BinaryOperatorKind clangsharp_Cursor_getBinaryOpcode(CXCursor C) { + if (C.kind == CXCursor_BinaryOperator || C.kind == CXCursor_CompoundAssignOperator) { + const Expr* E = getCursorExpr(C); + if (const BinaryOperator* BinOp = dyn_cast(E)) { + return static_cast(BinOp->getOpcode() + 1); + } + } + + return CX_BO_Invalid; +} + +CXString clangsharp_Cursor_getBinaryOpcodeSpelling(CX_BinaryOperatorKind Op) { + if (Op != CX_BO_Invalid) { + return createDup( + BinaryOperator::getOpcodeStr(static_cast(Op - 1))); + } + + return createEmpty(); +} + +CX_DeclKind clangsharp_Cursor_getDeclKind(CXCursor C) { + if (clangsharp_isDeclaration(C.kind) || clangsharp_isTranslationUnit(C.kind)) { + const Decl* D = getCursorDecl(C); + return static_cast(D->getKind() + 1); + } + + return CX_DeclKind_Invalid; +} + +CX_StmtClass clangsharp_Cursor_getStmtClass(CXCursor C) { + if (clangsharp_isExpression(C.kind) || clangsharp_isStatement(C.kind)) { + const Stmt* S = getCursorStmt(C); + return static_cast(S->getStmtClass()); + } + + return CX_StmtClass_Invalid; +} + +CX_UnaryOperatorKind clangsharp_Cursor_getUnaryOpcode(CXCursor C) { + if (C.kind == CXCursor_UnaryOperator) { + const Expr* E = getCursorExpr(C); + if (const UnaryOperator* UnOp = dyn_cast(E)) { + return static_cast(UnOp->getOpcode() + 1); + } + } + + return CX_UO_Invalid; +} + +CXString clangsharp_Cursor_getUnaryOpcodeSpelling(CX_UnaryOperatorKind Op) { + if (Op != CX_UO_Invalid) { + return createDup( + UnaryOperator::getOpcodeStr(static_cast(Op - 1))); + } + + return createEmpty(); +} + +CXSourceRange clangsharp_getCursorExtent(CXCursor C) { + SourceRange R = getRawCursorExtent(C); + if (R.isInvalid()) + return clangsharp_getNullRange(); + + return translateSourceRange(getCursorContext(C), R); +} + +CXSourceRange clangsharp_getNullRange() { + CXSourceRange Result = { { nullptr, nullptr }, 0, 0 }; + return Result; +} + +CXSourceRange clangsharp_getRange(CXSourceLocation begin, CXSourceLocation end) { + if (!isASTUnitSourceLocation(begin)) { + if (isASTUnitSourceLocation(end)) + return clangsharp_getNullRange(); + CXSourceRange Result = { { begin.ptr_data[0], end.ptr_data[0] }, 0, 0 }; + return Result; + } + + if (begin.ptr_data[0] != end.ptr_data[0] || begin.ptr_data[1] != end.ptr_data[1]) + return clangsharp_getNullRange(); + + CXSourceRange Result = { + { begin.ptr_data[0], begin.ptr_data[1] }, + begin.int_data, end.int_data + }; + return Result; +} + +void clangsharp_getSpellingLocation(CXSourceLocation location, CXFile* file, unsigned* line, unsigned* column, unsigned* offset) { + if (!isASTUnitSourceLocation(location)) { + CXLoadedDiagnostic::decodeLocation(location, file, line, column, offset); + return; + } + + SourceLocation Loc = SourceLocation::getFromRawEncoding(location.int_data); + + if (!location.ptr_data[0] || Loc.isInvalid()) + return createNullLocation(file, line, column, offset); + + const SourceManager& SM = *static_cast(location.ptr_data[0]); + SourceLocation SpellLoc = SM.getSpellingLoc(Loc); + std::pair LocInfo = SM.getDecomposedLoc(SpellLoc); + FileID FID = LocInfo.first; + unsigned FileOffset = LocInfo.second; + + if (FID.isInvalid()) + return createNullLocation(file, line, column, offset); + + if (file) + *file = const_cast(SM.getFileEntryForID(FID)); + if (line) + *line = SM.getLineNumber(FID, FileOffset); + if (column) + *column = SM.getColumnNumber(FID, FileOffset); + if (offset) + *offset = FileOffset; +} + +unsigned clangsharp_isAttribute(CXCursorKind K) { + return K >= CXCursor_FirstAttr && K <= CXCursor_LastAttr; +} + +unsigned clangsharp_isDeclaration(CXCursorKind K) { + return (K >= CXCursor_FirstDecl && K <= CXCursor_LastDecl) || + (K >= CXCursor_FirstExtraDecl && K <= CXCursor_LastExtraDecl); +} + +unsigned clangsharp_isExpression(CXCursorKind K) { + return K >= CXCursor_FirstExpr && K <= CXCursor_LastExpr; +} + +unsigned clangsharp_isReference(CXCursorKind K) { + return K >= CXCursor_FirstRef && K <= CXCursor_LastRef; +} + +unsigned clangsharp_isStatement(CXCursorKind K) { + return K >= CXCursor_FirstStmt && K <= CXCursor_LastStmt; +} + +unsigned clangsharp_isTranslationUnit(CXCursorKind K) { + return K == CXCursor_TranslationUnit; +} + +CX_TypeClass clangsharp_Type_getTypeClass(CXType CT) { + QualType T = GetQualType(CT); + const Type* TP = T.getTypePtrOrNull(); + + if (TP != nullptr) + { + return static_cast(TP->getTypeClass() + 1); + } + + return CX_TypeClass_Invalid; +} diff --git a/sources/libClangSharp/ClangSharp.h b/sources/libClangSharp/ClangSharp.h new file mode 100644 index 00000000..a576b496 --- /dev/null +++ b/sources/libClangSharp/ClangSharp.h @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information. + +#ifndef LIBCLANGSHARP_CLANGSHARP_H +#define LIBCLANGSHARP_CLANGSHARP_H + +#include + +#ifdef __cplusplus +#define EXTERN_C extern "C" +#else +#define EXTERN_C +#endif + +#ifdef _MSC_VER +#ifdef CLANGSHARP_LINKAGE +#define CLANGSHARP_LINKAGE EXTERN_C __declspec(dllexport) +#else +#define CLANGSHARP_LINKAGE EXTERN_C __declspec(dllimport) +#endif +#else +#define CLANGSHARP_LINKAGE EXTERN_C +#endif + +enum CX_AttrKind { + CX_AttrKind_Invalid, +#define ATTR(X) CX_AttrKind_##X, +#define ATTR_RANGE(CLASS, FIRST_NAME, LAST_NAME) CX_AttrKind_First##CLASS = CX_AttrKind_##FIRST_NAME, CX_AttrKind_Last##CLASS = CX_AttrKind_##LAST_NAME, +#include +}; + +enum CX_BinaryOperatorKind { + CX_BO_Invalid, +#define BINARY_OPERATION(Name, Spelling) CX_BO_##Name, +#include +}; + +enum CX_DeclKind { + CX_DeclKind_Invalid, +#define DECL(DERIVED, BASE) CX_DeclKind_##DERIVED, +#define DECL_RANGE(BASE, START, END) CX_DeclKind_First##BASE = CX_DeclKind_##START, CX_DeclKind_Last##BASE = CX_DeclKind_##END, +#define LAST_DECL_RANGE(BASE, START, END) CX_DeclKind_First##BASE = CX_DeclKind_##START, CX_DeclKind_Last##BASE = CX_DeclKind_##END +#define ABSTRACT_DECL(DECL) +#include +}; + +enum CX_StmtClass { + CX_StmtClass_Invalid, +#define STMT(CLASS, PARENT) CX_StmtClass_##CLASS, +#define STMT_RANGE(BASE, FIRST, LAST) CX_StmtClass_First##BASE = CX_StmtClass_##FIRST, CX_StmtClass_Last##BASE = CX_StmtClass_##LAST, +#define LAST_STMT_RANGE(BASE, FIRST, LAST) CX_StmtClass_First##BASE = CX_StmtClass_##FIRST, CX_StmtClass_Last##BASE = CX_StmtClass_##LAST +#define ABSTRACT_STMT(STMT) +#include +}; + +enum CX_TypeClass { + CX_TypeClass_Invalid, +#define TYPE(Class, Base) CX_TypeClass_##Class, +#define LAST_TYPE(Class) CX_TypeClass_TypeLast = CX_TypeClass_##Class, +#define ABSTRACT_TYPE(Class, Base) +#include + CX_TypeClass_TagFirst = CX_TypeClass_Record, CX_TypeClass_TagLast = CX_TypeClass_Enum +}; + +enum CX_UnaryOperatorKind { + CX_UO_Invalid, +#define UNARY_OPERATION(Name, Spelling) CX_UO_##Name, +#include +}; + +CLANGSHARP_LINKAGE CX_AttrKind clangsharp_Cursor_getAttrKind(CXCursor C); + +CLANGSHARP_LINKAGE CX_BinaryOperatorKind clangsharp_Cursor_getBinaryOpcode(CXCursor C); + +CLANGSHARP_LINKAGE CXString clangsharp_Cursor_getBinaryOpcodeSpelling(CX_BinaryOperatorKind Op); + +CLANGSHARP_LINKAGE CX_DeclKind clangsharp_Cursor_getDeclKind(CXCursor C); + +CLANGSHARP_LINKAGE CX_StmtClass clangsharp_Cursor_getStmtClass(CXCursor C); + +CLANGSHARP_LINKAGE CX_UnaryOperatorKind clangsharp_Cursor_getUnaryOpcode(CXCursor C); + +CLANGSHARP_LINKAGE CXString clangsharp_Cursor_getUnaryOpcodeSpelling(CX_UnaryOperatorKind Op); + +/** + * Retrieve the physical extent of the source construct referenced by + * the given cursor. + * + * The extent of a cursor starts with the file/line/column pointing at the + * first character within the source construct that the cursor refers to and + * ends with the last character within that source construct. For a + * declaration, the extent covers the declaration itself. For a reference, + * the extent covers the location of the reference (e.g., where the referenced + * entity was actually used). + */ +CLANGSHARP_LINKAGE CXSourceRange clangsharp_getCursorExtent(CXCursor C); + +/** + * Retrieve a NULL (invalid) source range. + */ +CLANGSHARP_LINKAGE CXSourceRange clangsharp_getNullRange(); + +/** + * Retrieve a source range given the beginning and ending source + * locations. + */ +CLANGSHARP_LINKAGE CXSourceRange clangsharp_getRange(CXSourceLocation begin, CXSourceLocation end); + +/** + * Retrieve the file, line, column, and offset represented by + * the given source location. + * + * If the location refers into a macro instantiation, return where the + * location was originally spelled in the source file. + * + * \param location the location within a source file that will be decomposed + * into its parts. + * + * \param file [out] if non-NULL, will be set to the file to which the given + * source location points. + * + * \param line [out] if non-NULL, will be set to the line to which the given + * source location points. + * + * \param column [out] if non-NULL, will be set to the column to which the given + * source location points. + * + * \param offset [out] if non-NULL, will be set to the offset into the + * buffer to which the given source location points. + */ +CLANGSHARP_LINKAGE void clangsharp_getSpellingLocation(CXSourceLocation location, CXFile* file, unsigned* line, unsigned* column, unsigned* offset); + +/** + * Determine whether the given cursor kind represents an attribute. + */ +CLANGSHARP_LINKAGE unsigned clangsharp_isAttribute(CXCursorKind); + +/** + * Determine whether the given cursor kind represents a declaration. + */ +CLANGSHARP_LINKAGE unsigned clangsharp_isDeclaration(CXCursorKind); + +/** + * Determine whether the given cursor kind represents an expression. + */ +CLANGSHARP_LINKAGE unsigned clangsharp_isExpression(CXCursorKind); + +/** + * Determine whether the given cursor kind represents a simple + * reference. + * + * Note that other kinds of cursors (such as expressions) can also refer to + * other cursors. Use clang_getCursorReferenced() to determine whether a + * particular cursor refers to another entity. + */ +CLANGSHARP_LINKAGE unsigned clangsharp_isReference(CXCursorKind); + +/** + * Determine whether the given cursor kind represents a statement. + */ +CLANGSHARP_LINKAGE unsigned clangsharp_isStatement(CXCursorKind); + +/** + * Determine whether the given cursor kind represents a translation + * unit. + */ +CLANGSHARP_LINKAGE unsigned clangsharp_isTranslationUnit(CXCursorKind); + +CLANGSHARP_LINKAGE CX_TypeClass clangsharp_Type_getTypeClass(CXType CT); + +#endif