[llvm] ee43259 - Initialize output parameters
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 7 15:21:36 PST 2022
Author: Vitaly Buka
Date: 2022-01-07T15:21:21-08:00
New Revision: ee43259cbce46a5b979f06710dcfe664473f6a8d
URL: https://github.com/llvm/llvm-project/commit/ee43259cbce46a5b979f06710dcfe664473f6a8d
DIFF: https://github.com/llvm/llvm-project/commit/ee43259cbce46a5b979f06710dcfe664473f6a8d.diff
LOG: Initialize output parameters
If the function returns true, it should
set all output paremeters, similar to Output::preflightElement, or we
have UB on code like:
```
void *SaveInfo;
if (io.preflightFlowElement(i, SaveInfo))
io.postflightFlowElement(SaveInfo);
```
It's going to be detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1
Differential Revision: https://reviews.llvm.org/D116826
Added:
Modified:
llvm/lib/Support/YAMLTraits.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp
index 10ff020ad972f..416423298bc6d 100644
--- a/llvm/lib/Support/YAMLTraits.cpp
+++ b/llvm/lib/Support/YAMLTraits.cpp
@@ -629,7 +629,7 @@ void Output::endFlowSequence() {
outputUpToEndOfLine(" ]");
}
-bool Output::preflightFlowElement(unsigned, void *&) {
+bool Output::preflightFlowElement(unsigned, void *&SaveInfo) {
if (NeedFlowSequenceComma)
output(", ");
if (WrapColumn && Column > WrapColumn) {
@@ -639,6 +639,7 @@ bool Output::preflightFlowElement(unsigned, void *&) {
Column = ColumnAtFlowStart;
output(" ");
}
+ SaveInfo = nullptr;
return true;
}
More information about the llvm-commits
mailing list