forked from OSchip/llvm-project
TableGen/SearchableTables: Cast enums to unsigned in generated code
Summary: This should fix signedness warnings when compiling with MSVC. Change-Id: I4664cce0ba91e9b42d21a86fd4a7e82f2320c451 Reviewers: RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51097 llvm-svn: 340518
This commit is contained in:
parent
daab25b8fd
commit
ba9eee5fad
|
@ -430,6 +430,15 @@ void SearchableTableEmitter::emitLookupFunction(const GenericTable &Table,
|
|||
<< ").compare(RHS." << Field.Name << ");\n";
|
||||
OS << " if (Cmp" << Field.Name << " < 0) return true;\n";
|
||||
OS << " if (Cmp" << Field.Name << " > 0) return false;\n";
|
||||
} else if (Field.Enum) {
|
||||
// Explicitly cast to unsigned, because the signedness of enums is
|
||||
// compiler-dependent.
|
||||
OS << " if ((unsigned)LHS." << Field.Name << " < (unsigned)RHS."
|
||||
<< Field.Name << ")\n";
|
||||
OS << " return true;\n";
|
||||
OS << " if ((unsigned)LHS." << Field.Name << " > (unsigned)RHS."
|
||||
<< Field.Name << ")\n";
|
||||
OS << " return false;\n";
|
||||
} else {
|
||||
OS << " if (LHS." << Field.Name << " < RHS." << Field.Name << ")\n";
|
||||
OS << " return true;\n";
|
||||
|
|
Loading…
Reference in New Issue