diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 13:59:28 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 13:59:28 +0800 |
| commit | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (patch) | |
| tree | 9580072eb0d796b51c04ad5be95230a747709150 /source/compiler-core | |
| parent | a15d770242f88aa4b33cd7d3a97de9c8d86a2315 (diff) | |
preparation for clang format (#5422)
* Clang-format excludes
* Add .clang-format
* Don't clang-format in external
* Missing includes and forward declarations
* Replace wonky include-once macro name
* neaten include naming
* Add clang-format to formatting script
* Add xargs and diff to required binaries
* add clang-format to ci formatting check
* Add max version check to formatting script
* temporarily disable checking formatting for cpp files
Diffstat (limited to 'source/compiler-core')
| -rw-r--r-- | source/compiler-core/slang-artifact-desc-util.cpp | 2 | ||||
| -rw-r--r-- | source/compiler-core/slang-dxc-compiler.cpp | 47 | ||||
| -rw-r--r-- | source/compiler-core/slang-nvrtc-compiler.cpp | 2 |
3 files changed, 31 insertions, 20 deletions
diff --git a/source/compiler-core/slang-artifact-desc-util.cpp b/source/compiler-core/slang-artifact-desc-util.cpp index 907a953ce..7c2622f70 100644 --- a/source/compiler-core/slang-artifact-desc-util.cpp +++ b/source/compiler-core/slang-artifact-desc-util.cpp @@ -154,6 +154,7 @@ bool isDerivedFrom(ENUM_TYPE kind, ENUM_TYPE base) { return g_table##ENUM_TYPE.i /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!! ArtifactKind !!!!!!!!!!!!!!!!!!!!!!! */ +// clang-format off #define SLANG_ARTIFACT_KIND(x) \ x(Invalid, Invalid) \ x(Base, Invalid) \ @@ -245,6 +246,7 @@ SLANG_HIERARCHICAL_ENUM(ArtifactPayload, SLANG_ARTIFACT_PAYLOAD, SLANG_ARTIFACT_ x(Kernel, CodeLike) \ x(Host, CodeLike) \ x(Obfuscated, Base) +// clang-format on #define SLANG_ARTIFACT_STYLE_ENTRY(TYPE, PARENT) { Index(ArtifactStyle::TYPE), Index(ArtifactStyle::PARENT), #TYPE }, diff --git a/source/compiler-core/slang-dxc-compiler.cpp b/source/compiler-core/slang-dxc-compiler.cpp index 3a949b3bd..30bf71968 100644 --- a/source/compiler-core/slang-dxc-compiler.cpp +++ b/source/compiler-core/slang-dxc-compiler.cpp @@ -37,26 +37,33 @@ // generate code on Windows. #if SLANG_ENABLE_DXIL_SUPPORT -# ifdef _WIN32 -# include <windows.h> -# include <unknwn.h> -# include "../../external/dxc/dxcapi.h" -# else -# include "../../external/dxc/dxcapi.h" - -# ifdef __uuidof - // DXC's WinAdapter.h defines __uuidof(T) over types, but the existing - // usage in this file is over values (both are accepted on MSVC.) - // We also need to decay through Slang::ComPtr, hence the helper struct - template <typename T> - struct StripSlangComPtr { using type = T; }; - template <typename T> - struct StripSlangComPtr<Slang::ComPtr<T>> { using type = T; }; -# undef __uuidof -# define __uuidof(x) __emulated_uuidof<StripSlangComPtr<std::decay_t<decltype(x)>>::type>() -# endif -# endif - +# ifdef _WIN32 +# include <unknwn.h> +# include <windows.h> +# endif + +# include "../../external/dxc/dxcapi.h" + +# ifndef _WIN32 +# ifdef __uuidof +// DXC's WinAdapter.h defines __uuidof(T) over types, but the existing +// usage in this file is over values (both are accepted on MSVC.) +// We also need to decay through Slang::ComPtr, hence the helper struct +template<typename T> +struct StripSlangComPtr +{ + using type = T; +}; +template<typename T> +struct StripSlangComPtr<Slang::ComPtr<T>> +{ + using type = T; +}; +# undef __uuidof +# define __uuidof(x) \ + __emulated_uuidof<StripSlangComPtr<std::decay_t<decltype(x)>>::type>() +# endif +# endif #endif namespace Slang diff --git a/source/compiler-core/slang-nvrtc-compiler.cpp b/source/compiler-core/slang-nvrtc-compiler.cpp index 80fde277b..8e234e634 100644 --- a/source/compiler-core/slang-nvrtc-compiler.cpp +++ b/source/compiler-core/slang-nvrtc-compiler.cpp @@ -41,6 +41,7 @@ typedef enum { typedef struct _nvrtcProgram *nvrtcProgram; +// clang-format off #define SLANG_NVRTC_FUNCS(x) \ x(const char*, nvrtcGetErrorString, (nvrtcResult result)) \ x(nvrtcResult, nvrtcVersion, (int *major, int *minor)) \ @@ -53,6 +54,7 @@ typedef struct _nvrtcProgram *nvrtcProgram; x(nvrtcResult, nvrtcGetProgramLog, (nvrtcProgram prog, char *log))\ x(nvrtcResult, nvrtcAddNameExpression, (nvrtcProgram prog, const char * const name_expression)) \ x(nvrtcResult, nvrtcGetLoweredName, (nvrtcProgram prog, const char *const name_expression, const char** lowered_name)) +// clang-format on } // namespace nvrtc |
