llvm.org GIT mirror llvm / a2df2ba
Add llvm::getOrdinalSuffix to get the appropriate -st, -nd, -rd, -th suffix. Used by clang to print parameter indexes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164440 91177308-0d34-0410-b5e6-96231b3b80d8 Jordan Rose 7 years ago
1 changed file(s) with 19 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
128128 return Result;
129129 }
130130
131 /// Returns the English suffix for an ordinal integer (-st, -nd, -rd, -th).
132 static inline StringRef getOrdinalSuffix(unsigned Val) {
133 // It is critically important that we do this perfectly for
134 // user-written sequences with over 100 elements.
135 switch (Val % 100) {
136 case 11:
137 case 12:
138 case 13:
139 return "th";
140 default:
141 switch (Val % 10) {
142 case 1: return "st";
143 case 2: return "nd";
144 case 3: return "rd";
145 default: return "th";
146 }
147 }
148 }
149
131150 } // End llvm namespace
132151
133152 #endif