From 904bef7bab37c680f0f1ca5c612c9d3df712426b Mon Sep 17 00:00:00 2001 From: Pavel Samolysov Date: Wed, 16 Feb 2022 10:27:36 +0300 Subject: [PATCH] [sycl-post-link] Initialize the integer Value variable 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. --- llvm/tools/sycl-post-link/CompileTimePropertiesPass.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/tools/sycl-post-link/CompileTimePropertiesPass.h b/llvm/tools/sycl-post-link/CompileTimePropertiesPass.h index 15b3896472716..6a8e26dbbd9a1 100644 --- a/llvm/tools/sycl-post-link/CompileTimePropertiesPass.h +++ b/llvm/tools/sycl-post-link/CompileTimePropertiesPass.h @@ -63,7 +63,7 @@ inline bool hasProperty(const Attribute &Attr) { template Int getAttributeAsInteger(const Attribute &Attr) { assert(Attr.isStringAttribute() && "The attribute Attr must be a string attribute"); - Int Value; + Int Value = 0; bool Error = Attr.getValueAsString().getAsInteger(10, Value); assert(!Error && "The attribute's value is not a number"); (void)Error;