summaryrefslogtreecommitdiff
path: root/lib/Demangle
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-01-24 20:04:56 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-01-24 20:04:56 +0000
commited1b025f1b2d8ea4a5b2023a2dfbde85c020e050 (patch)
treed7e5bf62abd90c031401c54b8365087445ca84c3 /lib/Demangle
parentd3108576035a59b6d56af70d068bc30b94b9bdb6 (diff)
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
Diffstat (limited to 'lib/Demangle')
-rw-r--r--lib/Demangle/ItaniumDemangle.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/Demangle/ItaniumDemangle.cpp b/lib/Demangle/ItaniumDemangle.cpp
index c7a151bd27f..9f808d6cb6d 100644
--- a/lib/Demangle/ItaniumDemangle.cpp
+++ b/lib/Demangle/ItaniumDemangle.cpp
@@ -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>
@@ -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;
}
}
@@ -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]);
@@ -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(" &");