Convert diagnostics to new format#10079
Draft
expipiplus1 wants to merge 88 commits intoshader-slang:masterfrom
Draft
Convert diagnostics to new format#10079expipiplus1 wants to merge 88 commits intoshader-slang:masterfrom
expipiplus1 wants to merge 88 commits intoshader-slang:masterfrom
Conversation
Revert the diagnostic conversions to slang-diagnostics.lua while keeping the infrastructure changes: - Optional primary_span support for locationless diagnostics - Renderer handling for locationless diagnostics (0,0 locations) - Test infrastructure for locationless diagnostic annotations - Documentation and helper scripts Update command-line test expected files for new "command line(1):" format in diagnostic output.
The diagnostic annotation system now requires a colon after the prefix (e.g., //CHECK: instead of //CHECK). This avoids confusion with simple substring matching where the text after the prefix could be mistaken as part of the prefix name. Changes: - diagnostic-annotation-util.cpp: Update pattern matching to require colon - diagnostic-annotation-util.h: Update documentation examples - slang-test-main.cpp: Add -enable-machine-readable-diagnostics before test options so it takes effect during option parsing - diagnostic-conversion-guide.md: Update documentation examples - Update all test files to use colon format (//CHECK:, /*CHECK:, etc.)
…, 361xx) to Lua format - Create slang-diagnostics-semantic-checking-3.lua with 31 converted diagnostics - Update call sites to use struct-based diagnostic format - Add template overload for maybeDiagnose to support struct-based diagnostics - Convert all affected tests from filecheck to diag=CHECK format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Convert 9 tests from traditional expected output to diag=CHECK format - Fix caret span positions to match actual diagnostic output - Remove obsolete .expected files for converted tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Convert diagnostics from lines 102-302 of slang-diagnostic-defs.h to the new Lua-based rich diagnostic format: - Create slang-diagnostics-semantic-checking-2.lua with 37 diagnostics - Add Modifier* type support to slang-rich-diagnostics.h.lua - Update call sites in slang-check-*.cpp files to use new struct syntax - Convert tests to use diag=CHECK annotation system - Fix column range annotations in existing tests Diagnostics converted include: - dyn interface errors (33072-33082) - Conversion warnings/errors (30080-30082) - try/throw errors (30090-30095, 30113-30116) - Differentiable errors (30096-30098, 30102) - sizeof/countof errors (30099, 30083) - Float bit cast errors (30084-30085) - Type pack errors (30103-30107) - Defer statement errors (30108-30110) - Lambda errors (30111-30112) - Generic constraint error (30117) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove unnecessary non-exhaustive from discard-in-compute.slang - Remove non-exhaustive from discard-in-rt.slang by adding missing annotation - Add comments explaining why non-exhaustive is necessary for remaining tests: - Cascading errors from different files - Many repeated cascading notes (10-20+) - Notes from internal meta.slang files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update test expectations and annotations to match the new rich diagnostic format which uses box-drawing characters and structured output instead of the traditional single-line format. Changes: - Update .expected files for SIMPLE tests to match new format - Convert keyword-undefined-identifier.slang to use diag= annotations - Fix column span annotations in incomplete-member-decl.slang - Disable color output in slang-test for consistent test results 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Convert 20 diagnostics from slang-diagnostic-defs.h lines 200-300: - COM Interface diagnostics (31124) - DerivativeMember Attribute diagnostics (31130-31132) - Extern Decl diagnostics (31140-31143) - DeclAlreadyHasAttribute (31146) - Custom Derivative diagnostics (31147-31157) Also fix a bug in slang-diagnostics-helpers.lua where sentence-ending periods were incorrectly parsed as member access operators. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Convert diagnostics 31000-31125 (Attributes category) from the old macro-based system to the new Lua-based rich diagnostic system: - unknownAttributeName (31000) - attributeArgumentCountMismatch (31001) - attributeNotApplicable (31002) - badlyDefinedPatchConstantFunc (31003) - expectedSingleIntArg (31004) - expectedSingleStringArg (31005) - attributeFunctionNotFound (31006) - attributeExpectedIntArg (31007) - attributeExpectedStringArg (31008) - expectedSingleFloatArg (31009) - unknownStageName (31100) - unknownImageFormatName (31101) - unknownDiagnosticName (31101) - nonPositiveNumThreads (31102) - invalidWaveSize (31103) - explicitUniformLocation (31104) - imageFormatUnsupportedByBackend (31105) - invalidAttributeTarget (31120) - anyValueSizeExceedsLimit (31121) - associatedTypeNotAllowedInComInterface (31122) - invalidGuid (31123) - structCannotImplementComInterface (31124) - interfaceInheritingComMustBeCom (31124) - attributeUsageAttributeMustBeOnNonGenericStruct (31125) Updated call sites in slang-check-modifier.cpp, slang-check-stmt.cpp, slang-check-shader.cpp, slang-check-decl.cpp, slang-check-expr.cpp, slang-diagnostics.cpp, slang-emit-wgsl.cpp, slang-emit-glsl.cpp, slang-emit-spirv.cpp, and slang-parameter-binding.cpp. Converted tests to use diag= caret-based annotations: - tests/diagnostics/wavesize-invalid-size.slang - tests/diagnostics/attribute-error.slang - tests/diagnostics/vk-offset.slang - tests/diagnostics/image-format-unsupported-by-backend.slang 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…OM/derivative diagnostics (part 5) Resolved merge conflicts from both sides converting diagnostics to the rich diagnostic system: - Side 1 (part 4): Converted attribute diagnostics 31000-31123 - Side 2 (part 5): Converted COM interface, DerivativeMember, Extern Decl, and Custom Derivative diagnostics 31124-31157 Both lua files are now loaded in slang-diagnostics.lua. The 31124 diagnostics (structCannotImplementComInterface, interfaceInheritingComMustBeCom) are kept only in part 5 to avoid duplication.
…rors - Add template overload for diagnoseOnce() that accepts rich diagnostic structs, building the dedup key from diagnostic ID, location, and message - Add template overload for diagnoseCapabilityErrors() that accepts rich diagnostic structs - Fix getDiagnosticPos() usage for Decl-typed locations in rich diagnostics to ensure proper fallback when getNameLoc() returns invalid location These infrastructure changes enable converting more diagnostics to the rich diagnostic system. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Converts diagnostics from slang-diagnostic-defs.h (lines 340-542) to the new Lua-based rich diagnostic system: - Link time specialization (310xx) - Cyclic references (39xxx) - Generics (304xx) - Initializer lists (305xx) - Variables (3062x) - Parameters (307xx) - Inheritance (308xx) - Extensions (308xx) - Subscripts (309xx) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update test files to match new rich diagnostic output format for semantic checking diagnostics (part 7): - tests/diagnostics/uninitialized-resource-type.slang: Convert to diag= annotations - tests/diagnostics/shader-slanggh-1374.slang.expected: Update expected output format - tests/bugs/9191-interface-initialization.slang: Add annotation for both summary and span messages - tests/library/ambiguous-extern-export-entry.slang.expected: Update format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add support for the 'modifier' parameter type in rich diagnostics, allowing diagnostic messages to include modifier names. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Convert ~56 diagnostics from slang-diagnostic-defs.h (lines 127-339) to the new Lua-based rich diagnostic system in a new file slang-diagnostics-semantic-checking-6.lua. Diagnostics converted include: - Modifier validation (duplicate, not allowed, missing, etc.) - Generic value parameter validation - Constraint checking (invalid, equality type mismatch) - For loop warnings (wrong direction, zero step, zero iterations) - Autodiff differentiability checking - Interface requirement validation - Variable initialization errors (circular, groupshared, interface) - Type usage errors (generic without arguments, cannot specialize) - Deprecation warnings - And many more semantic checking diagnostics Updated all affected test files to use the diag= annotation format with proper column positions for the new rich diagnostic output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
… conversions Resolve conflicts where both conversions touched the same diagnostics: - Use field names from semantic-checking-7.lua (type_exp instead of sup, decl instead of decl_ref) - Remove duplicate diagnostics from semantic-checking-6.lua that are now in semantic-checking-7.lua - Load both lua modules in slang-diagnostics.lua - Update slang-diagnostic-defs.h to reference both lua files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update diagnostic test annotations to match the new rich diagnostic system output format. The changes include: - Adding duplicate annotations where diagnostics are now emitted twice (once for header, once for span message) - Replacing old short-form header messages with the actual span messages - Updating expected output files to match new diagnostic format Tests fixed: - tests/bugs/static-const-init-expr-with-interface-2.slang - tests/diagnostics/accessors.slang - tests/diagnostics/generic-constraint-equality-right-hand-side.slang - tests/diagnostics/generic-constraint-left-hand-side.slang - tests/diagnostics/generic-value-parameter-float-type.slang - tests/diagnostics/generic-value-parameter-must-have-type.slang - tests/diagnostics/shader-slanggh-1374.slang - tests/diagnostics/invalid-buffer.slang - tests/diagnostics/invalid-constraint.slang - tests/diagnostics/invalid-tuple.slang - tests/language-feature/generics/where-optional-1.slang - tests/language-feature/generics/where-optional-5.slang - tests/language-feature/shared-memory-initializer-error.slang - tests/library/ambiguous-extern-export-entry.slang.expected
Convert diagnostics from slang-diagnostic-defs.h lines 135-227 to the new Lua-based rich diagnostic system: - Accessors (311xx): accessor location, set accessor params, param types - Bit fields (313xx): field width, integral type requirements - Various (39999): integer constants, raytracing payload, overload resolution, switch statements, generics, ambiguous references, declarations Updated use sites in: - slang-check-decl.cpp, slang-check-modifier.cpp, slang-check-expr.cpp - slang-check-stmt.cpp, slang-check-overload.cpp, slang-check-conversion.cpp - slang-parser.cpp, slang-ir-early-raytracing-intrinsic-simplification.cpp - slang-ir-glsl-legalize.cpp Updated tests for new rich diagnostic output format. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Convert diagnostics from slang-diagnostic-defs.h lines 229-333 to the new Lua-based rich diagnostic system. This includes operators, literals, entry points, and specialization-related diagnostics. Diagnostics converted (19 total): - ExpectedPostfixOperator, NotEnoughArguments, TooManyArguments (39999) - InvalidIntegerLiteralSuffix, InvalidFloatingPointLiteralSuffix (39999) - IntegerLiteralTooLarge, IntegerLiteralTruncated (39999) - FloatLiteralUnrepresentable, FloatLiteralTooSmall (39999) - MatrixColumnOrRowCountIsOne (39999) - EntryPointFunctionNotFound (38000) - ExpectedTypeForSpecializationArg (38005) - SpecifiedStageDoesntMatchAttribute (38006) - EntryPointHasNoStage (38007) - SpecializationParameterOfNameNotSpecialized (38008) - SpecializationParameterNotSpecialized (38008) - ExpectedValueOfTypeForSpecializationArg (38009) - UnhandledModOnEntryPointParameter (38010) - EntryPointCannotReturnResourceType (38011) Tests updated to use diag= annotations instead of .expected files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…stead of Expr The diagnostic was incorrectly defined to take an Expr* but should take a SourceLoc for the span location. Updated all call sites to pass expr->loc or sourceLoc instead of the expression pointer. Also updated test expectations for the new diagnostic output format. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The rich diagnostic system was generating SLANG_ASSERT for all pointer-type parameters, but some types like Type*, Name*, QualType, and Modifier* have null-safe conversion functions (typeToPrintableString, nameToPrintableString, etc.) that handle null gracefully by returning placeholder strings like "<unknown type>". Changes: - Updated slang-diagnostics-helpers.lua to only generate assertions for decl, expr, stmt, and val types which would crash if null - Removed overly strict assertion in machine-readable diagnostic rendering that prevented locationless spans with messages This fixes crashes when compiling code with interface default generic methods and other scenarios where Type* parameters could legitimately be null. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Change the 'int' type mapping to 'int64_t' in the diagnostic code generator to avoid narrowing warnings when passing Count/Index values (which are long int on Linux) to diagnostic struct fields. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…stem
This converts 24 diagnostics in the 39xxx range (type layout and parameter
binding) from the legacy DIAGNOSTIC macro system to the new Lua-based rich
diagnostic system.
## New diagnostic definitions
Created slang-diagnostics-semantic-checking-11.lua with the following
diagnostics:
- ConflictingExplicitBindingsForParameter (39000)
- ParameterBindingsOverlap (39001) - with note pointing to conflicting decl
- UnknownRegisterClass (39007)
- ExpectedARegisterIndex (39008)
- ExpectedSpace (39009)
- ExpectedSpaceIndex (39010)
- InvalidComponentMask (39011)
- RequestedBindlessSpaceIndexUnavailable (39012)
- RegisterModifierButNoVulkanLayout (39013)
- UnexpectedSpecifierAfterSpace (39014)
- WholeSpaceParameterRequiresZeroBinding (39015)
- DontExpectOutParametersForStage (39017)
- DontExpectInParametersForStage (39018)
- GlobalUniformNotExpected (39019)
- TooManyShaderRecordConstantBuffers (39020)
- VkIndexWithoutVkLocation (39022)
- MixingImplicitAndExplicitBindingForVaryingParams (39023)
- ConflictingVulkanInferredBindingForParameter (39025)
- MatrixLayoutModifierOnNonMatrixType (39026)
- GetAttributeAtVertexMustReferToPerVertexInput (39027)
- NotValidVaryingParameter (39028)
- TargetDoesNotSupportDescriptorHandle (39029)
- RegisterModifierButNoVkBindingNorShift (39029)
- BindingAttributeIgnoredOnUniform (39071)
## Code changes beyond diagnostic conversion
### slang-parameter-binding.cpp
- Converted all diagnostic call sites to use new struct-based syntax
- Changed shouldDisableDiagnostic() calls to use getInfo() method on the
new diagnostic struct (e.g., Diagnostics::ParameterBindingsOverlap::getInfo())
- Simplified ParameterBindingsOverlap handling by removing manual note emission
(the note is now automatically generated from the Lua definition)
- Added getText() calls to convert Name* to String where needed
- Used type->toString() for Type* to String conversion in NotValidVaryingParameter
### slang-check-modifier.cpp
- Converted UnknownRegisterClass and InvalidComponentMask call sites
- Used getContent() on Token to get string values for the new struct fields
### slang-check-expr.cpp
- Converted GetAttributeAtVertexMustReferToPerVertexInput and
MatrixLayoutModifierOnNonMatrixType call sites
### slang-ir-lower-dynamic-resource-heap.cpp
- Added #include "slang-rich-diagnostics.h" (was missing)
- Converted TargetDoesNotSupportDescriptorHandle call site
## Test updates
Updated 8 test files to accommodate the new diagnostic output format. The rich
diagnostic system outputs diagnostics in a different format:
- Old: "warning 39001: message"
- New: "warning[E39001]: short title" followed by multi-line detailed message
Tests updated to use regex patterns ({{.*}}) to match the new format:
- tests/bugs/binding-attribute-ignored.slang
- tests/bugs/shader-slanggh-8937.slang
- tests/diagnostics/get-vertex-attribute.slang
- tests/diagnostics/vk-binding-with-register-no-warning.slang
- tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error*.slang
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
…stem Convert diagnostics from slang-diagnostic-defs.h lines 147-313 to the new rich diagnostic system in slang-diagnostics-semantic-checking-10.lua. This includes diagnostics for: - Interface requirements (38100-38108) - this/init/return_val expressions (38101-38104) - Generics and type arguments (38021-38029) - Differentiation modifiers (38031-38034) - Entry point parameters (38040-38041) - Module imports (38200-38201, 39999) - Vector and buffer types (38203-38205) Also fixes null source manager handling in rich diagnostics rendering to prevent crashes during bootstrap compilation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.