[llvm] 4b46509 - [JSON] Fix uninitialized variable warning
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 7 14:02:47 PDT 2023
Author: Jonas Devlieghere
Date: 2023-04-07T14:02:42-07:00
New Revision: 4b4650948af347c73fcf812645c2afd1955bc083
URL: https://github.com/llvm/llvm-project/commit/4b4650948af347c73fcf812645c2afd1955bc083
DIFF: https://github.com/llvm/llvm-project/commit/4b4650948af347c73fcf812645c2afd1955bc083.diff
LOG: [JSON] Fix uninitialized variable warning
Fix uninitialized variable warning when deserializing a std::optional<E>
where is an enum type.
JSON.h:771:20: warning: variable 'Result' is uninitialized when used here [-Wuninitialized]
if (!fromJSON(E, Result, P))
^~~~~~
Added:
Modified:
llvm/include/llvm/Support/JSON.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h
index d35089122941..97f32dffb4f6 100644
--- a/llvm/include/llvm/Support/JSON.h
+++ b/llvm/include/llvm/Support/JSON.h
@@ -767,7 +767,7 @@ bool fromJSON(const Value &E, std::optional<T> &Out, Path P) {
Out = std::nullopt;
return true;
}
- T Result;
+ T Result = {};
if (!fromJSON(E, Result, P))
return false;
Out = std::move(Result);
More information about the llvm-commits
mailing list