mirror of
https://github.com/RPCSX/llvm.git
synced 2025-03-03 18:37:56 +00:00
Fix some undefined behavior when parsing YAML input: don't try to compare an
uninitialized value against a default value. Found by -fsanitize=enum. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170970 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2b45dd58b2
commit
9679a04da6
@ -360,7 +360,7 @@ public:
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void enumCase(T &Val, const char* Str, const T ConstVal) {
|
void enumCase(T &Val, const char* Str, const T ConstVal) {
|
||||||
if ( matchEnumScalar(Str, (Val == ConstVal)) ) {
|
if ( matchEnumScalar(Str, outputting() && Val == ConstVal) ) {
|
||||||
Val = ConstVal;
|
Val = ConstVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,14 +368,14 @@ public:
|
|||||||
// allow anonymous enum values to be used with LLVM_YAML_STRONG_TYPEDEF
|
// allow anonymous enum values to be used with LLVM_YAML_STRONG_TYPEDEF
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void enumCase(T &Val, const char* Str, const uint32_t ConstVal) {
|
void enumCase(T &Val, const char* Str, const uint32_t ConstVal) {
|
||||||
if ( matchEnumScalar(Str, (Val == static_cast<T>(ConstVal))) ) {
|
if ( matchEnumScalar(Str, outputting() && Val == static_cast<T>(ConstVal)) ) {
|
||||||
Val = ConstVal;
|
Val = ConstVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void bitSetCase(T &Val, const char* Str, const T ConstVal) {
|
void bitSetCase(T &Val, const char* Str, const T ConstVal) {
|
||||||
if ( bitSetMatch(Str, ((Val & ConstVal) == ConstVal)) ) {
|
if ( bitSetMatch(Str, outputting() && (Val & ConstVal) == ConstVal) ) {
|
||||||
Val = Val | ConstVal;
|
Val = Val | ConstVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ public:
|
|||||||
// allow anonymous enum values to be used with LLVM_YAML_STRONG_TYPEDEF
|
// allow anonymous enum values to be used with LLVM_YAML_STRONG_TYPEDEF
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void bitSetCase(T &Val, const char* Str, const uint32_t ConstVal) {
|
void bitSetCase(T &Val, const char* Str, const uint32_t ConstVal) {
|
||||||
if ( bitSetMatch(Str, ((Val & ConstVal) == ConstVal)) ) {
|
if ( bitSetMatch(Str, outputting() && (Val & ConstVal) == ConstVal) ) {
|
||||||
Val = Val | ConstVal;
|
Val = Val | ConstVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,7 +423,7 @@ private:
|
|||||||
bool Required) {
|
bool Required) {
|
||||||
void *SaveInfo;
|
void *SaveInfo;
|
||||||
bool UseDefault;
|
bool UseDefault;
|
||||||
const bool sameAsDefault = (Val == DefaultValue);
|
const bool sameAsDefault = outputting() && Val == DefaultValue;
|
||||||
if ( this->preflightKey(Key, Required, sameAsDefault, UseDefault,
|
if ( this->preflightKey(Key, Required, sameAsDefault, UseDefault,
|
||||||
SaveInfo) ) {
|
SaveInfo) ) {
|
||||||
yamlize(*this, Val, Required);
|
yamlize(*this, Val, Required);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user