Skip to content

Commit

Permalink
Warnings for uninitialized values (#4530)
Browse files Browse the repository at this point in the history
This extends the code for handling uninitialized output parameters.
Still needs to handle generic templates and assignment of uninitialized
values more carefully.

The file containing the relevant code are now in

    source/slang/slang-ir-use-uninitialized-values.cpp

rather than the previous

    source/slang/slang-ir-use-uninitialized-out-param.h

and the top-level function is now checkForUsingUinitializedValues.

Additionally a rudimentary test shader has been added for this case, which replaces the old file for out params only; tests/diagnositcs/uninitialized-out.slang becomes tests/diagnositcs/uninitialized.slang.

What this does not implement (could be future PRs):
* Checking uninitialized fields within constructors
* Partially uninitialized values with respect to data structure (e.g. arrays/structs/vector types)
* Partially uninitialized values with respect to control flow (e.g. if/else/loop)
  • Loading branch information
venkataram-nv authored Jul 9, 2024
1 parent 1caef59 commit 0e6c5c5
Show file tree
Hide file tree
Showing 12 changed files with 687 additions and 242 deletions.
4 changes: 2 additions & 2 deletions build/visual-studio/slang/slang.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ IF EXIST ..\..\..\external\slang-glslang\bin\windows-aarch64\release\slang-glsla
<ClInclude Include="..\..\..\source\slang\slang-ir-synthesize-active-mask.h" />
<ClInclude Include="..\..\..\source\slang\slang-ir-translate-glsl-global-var.h" />
<ClInclude Include="..\..\..\source\slang\slang-ir-uniformity.h" />
<ClInclude Include="..\..\..\source\slang\slang-ir-use-uninitialized-out-param.h" />
<ClInclude Include="..\..\..\source\slang\slang-ir-use-uninitialized-values.h" />
<ClInclude Include="..\..\..\source\slang\slang-ir-user-type-hint.h" />
<ClInclude Include="..\..\..\source\slang\slang-ir-util.h" />
<ClInclude Include="..\..\..\source\slang\slang-ir-validate.h" />
Expand Down Expand Up @@ -737,7 +737,7 @@ IF EXIST ..\..\..\external\slang-glslang\bin\windows-aarch64\release\slang-glsla
<ClCompile Include="..\..\..\source\slang\slang-ir-synthesize-active-mask.cpp" />
<ClCompile Include="..\..\..\source\slang\slang-ir-translate-glsl-global-var.cpp" />
<ClCompile Include="..\..\..\source\slang\slang-ir-uniformity.cpp" />
<ClCompile Include="..\..\..\source\slang\slang-ir-use-uninitialized-out-param.cpp" />
<ClCompile Include="..\..\..\source\slang\slang-ir-use-uninitialized-values.cpp" />
<ClCompile Include="..\..\..\source\slang\slang-ir-user-type-hint.cpp" />
<ClCompile Include="..\..\..\source\slang\slang-ir-util.cpp" />
<ClCompile Include="..\..\..\source\slang\slang-ir-validate.cpp" />
Expand Down
4 changes: 2 additions & 2 deletions build/visual-studio/slang/slang.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
<ClInclude Include="..\..\..\source\slang\slang-ir-uniformity.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\slang\slang-ir-use-uninitialized-out-param.h">
<ClInclude Include="..\..\..\source\slang\slang-ir-use-uninitialized-values.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\slang\slang-ir-user-type-hint.h">
Expand Down Expand Up @@ -1295,7 +1295,7 @@
<ClCompile Include="..\..\..\source\slang\slang-ir-uniformity.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\slang\slang-ir-use-uninitialized-out-param.cpp">
<ClCompile Include="..\..\..\source\slang\slang-ir-use-uninitialized-values.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\slang\slang-ir-user-type-hint.cpp">
Expand Down
10 changes: 6 additions & 4 deletions source/slang/slang-diagnostic-defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ DIAGNOSTIC(39999, Error, unableToFindSymbolInModule, "unable to find the mangled

DIAGNOSTIC(39999, Error, overloadedParameterToHigherOrderFunction, "passing overloaded functions to higher order functions is not supported")

// 38xxx
// 38xxx

DIAGNOSTIC(38000, Error, entryPointFunctionNotFound, "no function found matching entry point name '$0'")
DIAGNOSTIC(38001, Error, ambiguousEntryPoint, "more than one function matches entry point name '$0'")
Expand Down Expand Up @@ -735,9 +735,11 @@ DIAGNOSTIC(41010, Warning, missingReturn, "control flow may reach end of non-'vo
DIAGNOSTIC(41011, Error, profileIncompatibleWithTargetSwitch, "__target_switch has no compatable target with current profile '$0'")
DIAGNOSTIC(41012, Warning, profileImplicitlyUpgraded, "user set `profile` had an implicit upgrade applied to it, atoms added: '$0'")
DIAGNOSTIC(41012, Error, profileImplicitlyUpgradedRestrictive, "user set `profile` had an implicit upgrade applied to it, atoms added: '$0'")
DIAGNOSTIC(41015, Error, usingUninitializedValue, "use of uninitialized value '$0'")
DIAGNOSTIC(41016, Warning, returningWithUninitializedOut, "returning without initializing out parameter '$0'")
DIAGNOSTIC(41017, Warning, returningWithPartiallyUninitializedOut, "returning without fully initializing out parameter '$0'")
DIAGNOSTIC(41015, Warning, usingUninitializedOut, "use of uninitialized out parameter '$0'")
DIAGNOSTIC(41016, Warning, usingUninitializedVariable, "use of uninitialized variable '$0'")
DIAGNOSTIC(41017, Warning, usingUninitializedGlobalVariable, "use of uninitialized global variable '$0'")
DIAGNOSTIC(41018, Warning, returningWithUninitializedOut, "returning without initializing out parameter '$0'")
DIAGNOSTIC(41019, Warning, returningWithPartiallyUninitializedOut, "returning without fully initializing out parameter '$0'")

DIAGNOSTIC(41011, Error, typeDoesNotFitAnyValueSize, "type '$0' does not fit in the size required by its conforming interface.")
DIAGNOSTIC(41012, Note, typeAndLimit, "sizeof($0) is $1, limit is $2")
Expand Down
150 changes: 0 additions & 150 deletions source/slang/slang-ir-use-uninitialized-out-param.cpp

This file was deleted.

Loading

0 comments on commit 0e6c5c5

Please sign in to comment.