Skip to content

Commit 8e30ff3

Browse files
author
Pavel Samolysov
authored
[sycl-post-link] Initialize the integer Value variable (#5585)
A static analysis tool emits a warning about uninitialized integer variable 'Value' in the CompileTimePropertiesPass.h header. Actually, the variable is used just to pass a reference to it as an output parameter into the 'getAsInteger()' function and will be initialized there, but if an error occurs, the variable will remain uninitialized. Although there is a check for the error, let the variable be initialized is the best strategy.
1 parent 841384e commit 8e30ff3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/tools/sycl-post-link/CompileTimePropertiesPass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ inline bool hasProperty(const Attribute &Attr) {
6363
template <typename Int> Int getAttributeAsInteger(const Attribute &Attr) {
6464
assert(Attr.isStringAttribute() &&
6565
"The attribute Attr must be a string attribute");
66-
Int Value;
66+
Int Value = 0;
6767
bool Error = Attr.getValueAsString().getAsInteger(10, Value);
6868
assert(!Error && "The attribute's value is not a number");
6969
(void)Error;

0 commit comments

Comments
 (0)