[PATCH] D51097: TableGen/SearchableTables: Cast enums to unsigned in generated code
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 23 01:02:58 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340518: TableGen/SearchableTables: Cast enums to unsigned in generated code (authored by nha, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D51097?vs=161918&id=162140#toc
Repository:
rL LLVM
https://reviews.llvm.org/D51097
Files:
llvm/trunk/utils/TableGen/SearchableTableEmitter.cpp
Index: llvm/trunk/utils/TableGen/SearchableTableEmitter.cpp
===================================================================
--- llvm/trunk/utils/TableGen/SearchableTableEmitter.cpp
+++ llvm/trunk/utils/TableGen/SearchableTableEmitter.cpp
@@ -430,6 +430,15 @@
<< ").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";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51097.162140.patch
Type: text/x-patch
Size: 1028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180823/eabccce5/attachment.bin>
More information about the llvm-commits
mailing list