Skip to content

Commit

Permalink
Demangle: use named values for CV qualifiers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
compnerd committed Jan 24, 2017
1 parent d310857 commit ed1b025
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions lib/Demangle/ItaniumDemangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ enum {
success
};

enum {
CV_const = (1 << 0),
CV_volatile = (1 << 1),
CV_restrict = (1 << 2),
};

template <class C>
static const char *parse_type(const char *first, const char *last, C &db);
template <class C>
Expand Down Expand Up @@ -436,15 +442,15 @@ static const char *parse_cv_qualifiers(const char *first, const char *last,
cv = 0;
if (first != last) {
if (*first == 'r') {
cv |= 4;
cv |= CV_restrict;
++first;
}
if (*first == 'V') {
cv |= 2;
cv |= CV_volatile;
++first;
}
if (*first == 'K') {
cv |= 1;
cv |= CV_const;
++first;
}
}
Expand Down Expand Up @@ -1668,22 +1674,22 @@ static const char *parse_type(const char *first, const char *last, C &db) {
p -= 2;
else if (db.names[k].second.back() == '&')
p -= 1;
if (cv & 1) {
if (cv & CV_const) {
db.names[k].second.insert(p, " const");
p += 6;
}
if (cv & 2) {
if (cv & CV_volatile) {
db.names[k].second.insert(p, " volatile");
p += 9;
}
if (cv & 4)
if (cv & CV_restrict)
db.names[k].second.insert(p, " restrict");
} else {
if (cv & 1)
if (cv & CV_const)
db.names[k].first.append(" const");
if (cv & 2)
if (cv & CV_volatile)
db.names[k].first.append(" volatile");
if (cv & 4)
if (cv & CV_restrict)
db.names[k].first.append(" restrict");
}
db.subs.back().push_back(db.names[k]);
Expand Down Expand Up @@ -4074,11 +4080,11 @@ static const char *parse_encoding(const char *first, const char *last, C &db) {
if (db.names.empty())
return first;
db.names.back().first += ')';
if (cv & 1)
if (cv & CV_const)
db.names.back().first.append(" const");
if (cv & 2)
if (cv & CV_volatile)
db.names.back().first.append(" volatile");
if (cv & 4)
if (cv & CV_restrict)
db.names.back().first.append(" restrict");
if (ref == 1)
db.names.back().first.append(" &");
Expand Down

0 comments on commit ed1b025

Please sign in to comment.