llvm.org GIT mirror llvm / ed1b025
Demangle: use named values for CV qualifiers Rather than hard-coding magic values of 1, 2, 4 (bit-field), use an enum to name the values. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292975 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 2 years ago
1 changed file(s) with 18 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
3333 invalid_mangled_name,
3434 memory_alloc_failure,
3535 success
36 };
37
38 enum {
39 CV_const = (1 << 0),
40 CV_volatile = (1 << 1),
41 CV_restrict = (1 << 2),
3642 };
3743
3844 template
435441 cv = 0;
436442 if (first != last) {
437443 if (*first == 'r') {
438 cv |= 4;
444 cv |= CV_restrict;
439445 ++first;
440446 }
441447 if (*first == 'V') {
442 cv |= 2;
448 cv |= CV_volatile;
443449 ++first;
444450 }
445451 if (*first == 'K') {
446 cv |= 1;
452 cv |= CV_const;
447453 ++first;
448454 }
449455 }
16671673 p -= 2;
16681674 else if (db.names[k].second.back() == '&')
16691675 p -= 1;
1670 if (cv & 1) {
1676 if (cv & CV_const) {
16711677 db.names[k].second.insert(p, " const");
16721678 p += 6;
16731679 }
1674 if (cv & 2) {
1680 if (cv & CV_volatile) {
16751681 db.names[k].second.insert(p, " volatile");
16761682 p += 9;
16771683 }
1678 if (cv & 4)
1684 if (cv & CV_restrict)
16791685 db.names[k].second.insert(p, " restrict");
16801686 } else {
1681 if (cv & 1)
1687 if (cv & CV_const)
16821688 db.names[k].first.append(" const");
1683 if (cv & 2)
1689 if (cv & CV_volatile)
16841690 db.names[k].first.append(" volatile");
1685 if (cv & 4)
1691 if (cv & CV_restrict)
16861692 db.names[k].first.append(" restrict");
16871693 }
16881694 db.subs.back().push_back(db.names[k]);
40734079 if (db.names.empty())
40744080 return first;
40754081 db.names.back().first += ')';
4076 if (cv & 1)
4082 if (cv & CV_const)
40774083 db.names.back().first.append(" const");
4078 if (cv & 2)
4084 if (cv & CV_volatile)
40794085 db.names.back().first.append(" volatile");
4080 if (cv & 4)
4086 if (cv & CV_restrict)
40814087 db.names.back().first.append(" restrict");
40824088 if (ref == 1)
40834089 db.names.back().first.append(" &");