aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/SequenceToOffsetTable.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/TableGen/SequenceToOffsetTable.h')
-rw-r--r--utils/TableGen/SequenceToOffsetTable.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/utils/TableGen/SequenceToOffsetTable.h b/utils/TableGen/SequenceToOffsetTable.h
index 09dccbb108..97c764e61d 100644
--- a/utils/TableGen/SequenceToOffsetTable.h
+++ b/utils/TableGen/SequenceToOffsetTable.h
@@ -21,6 +21,7 @@
#include <algorithm>
#include <vector>
#include <cassert>
+#include <cctype>
namespace llvm {
@@ -120,6 +121,19 @@ public:
}
};
+// Helper function for SequenceToOffsetTable<string>.
+static inline void printChar(raw_ostream &OS, char C) {
+ unsigned char UC(C);
+ if (isalnum(UC) || ispunct(UC)) {
+ OS << '\'';
+ if (C == '\\' || C == '\'')
+ OS << '\\';
+ OS << C << '\'';
+ } else {
+ OS << unsigned(UC);
+ }
+}
+
} // end namespace llvm
#endif