[llvm] r287470 - Demangle: replace custom typedef for std::string with std::string
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 19 16:20:23 PST 2016
Author: compnerd
Date: Sat Nov 19 18:20:23 2016
New Revision: 287470
URL: http://llvm.org/viewvc/llvm-project?rev=287470&view=rev
Log:
Demangle: replace custom typedef for std::string with std::string
We created a local typedef for `std::basic_string<char, std::char_traits<char>>`
which is just `std::string`. Remove the local typedef and propagate the type
information through the rest of the demangler. NFC.
Modified:
llvm/trunk/lib/Demangle/ItaniumDemangle.cpp
Modified: llvm/trunk/lib/Demangle/ItaniumDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/ItaniumDemangle.cpp?rev=287470&r1=287469&r2=287470&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/ItaniumDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/ItaniumDemangle.cpp Sat Nov 19 18:20:23 2016
@@ -142,7 +142,7 @@ static const char *parse_floating_number
int n = snprintf(num, sizeof(num), float_data<Float>::spec, value);
if (static_cast<std::size_t>(n) >= sizeof(num))
return first;
- db.names.push_back(typename C::String(num, static_cast<std::size_t>(n)));
+ db.names.push_back(std::string(num, static_cast<std::size_t>(n)));
first = t + 1;
}
}
@@ -165,7 +165,7 @@ static const char *parse_source_name(con
return first;
}
if (static_cast<size_t>(last - t) >= n) {
- typename C::String r(t, n);
+ std::string r(t, n);
if (r.substr(0, 10) == "_GLOBAL__N")
db.names.push_back("(anonymous namespace)");
else
@@ -486,7 +486,7 @@ static const char *parse_template_param(
db.names.push_back(temp);
first = t + 1;
} else {
- db.names.push_back(typename C::String(first, t + 1));
+ db.names.push_back(std::string(first, t + 1));
first = t + 1;
db.fix_forward_references = true;
}
@@ -657,7 +657,7 @@ static const char *parse_sizeof_param_pa
const char *t = parse_template_param(first + 2, last, db);
size_t k1 = db.names.size();
if (t != first + 2) {
- typename C::String tmp("sizeof...(");
+ std::string tmp("sizeof...(");
size_t k = k0;
if (k != k1) {
tmp += db.names[k].move_full();
@@ -692,7 +692,7 @@ static const char *parse_function_param(
const char *t = parse_cv_qualifiers(first + 2, last, cv);
const char *t1 = parse_number(t, last);
if (t1 != last && *t1 == '_') {
- db.names.push_back("fp" + typename C::String(t, t1));
+ db.names.push_back("fp" + std::string(t, t1));
first = t1 + 1;
}
} else if (first[1] == 'L') {
@@ -703,7 +703,7 @@ static const char *parse_function_param(
const char *t = parse_cv_qualifiers(t0, last, cv);
const char *t1 = parse_number(t, last);
if (t1 != last && *t1 == '_') {
- db.names.push_back("fp" + typename C::String(t, t1));
+ db.names.push_back("fp" + std::string(t, t1));
first = t1 + 1;
}
}
@@ -1147,7 +1147,7 @@ static const char *parse_call_expr(const
if (db.names.empty())
return first;
db.names.back().first += db.names.back().second;
- db.names.back().second = typename C::String();
+ db.names.back().second = std::string();
db.names.back().first.append("(");
bool first_expr = true;
while (*t != 'E') {
@@ -1256,7 +1256,7 @@ static const char *parse_new_expr(const
}
if (*t != 'E')
return first;
- typename C::String init_list;
+ std::string init_list;
if (has_init) {
if (db.names.empty())
return first;
@@ -1267,14 +1267,14 @@ static const char *parse_new_expr(const
return first;
auto type = db.names.back().move_full();
db.names.pop_back();
- typename C::String expr_list;
+ std::string expr_list;
if (has_expr_list) {
if (db.names.empty())
return first;
expr_list = db.names.back().move_full();
db.names.pop_back();
}
- typename C::String r;
+ std::string r;
if (parsed_gs)
r = "::";
if (is_array)
@@ -1395,7 +1395,7 @@ static const char *parse_function_type(c
const char *t1 = parse_type(t, last, db);
if (t1 != t) {
t = t1;
- typename C::String sig("(");
+ std::string sig("(");
int ref_qual = 0;
while (true) {
if (t == last) {
@@ -1511,8 +1511,8 @@ static const char *parse_array_type(cons
return first;
if (db.names.back().second.substr(0, 2) == " [")
db.names.back().second.erase(0, 1);
- db.names.back().second.insert(
- 0, " [" + typename C::String(first + 1, t) + "]");
+ db.names.back().second.insert(0,
+ " [" + std::string(first + 1, t) + "]");
first = t2;
}
}
@@ -1585,19 +1585,17 @@ static const char *parse_vector_type(con
if (t1 != t) {
if (db.names.empty())
return first;
- db.names.back().first +=
- " vector[" + typename C::String(num, sz) + "]";
+ db.names.back().first += " vector[" + std::string(num, sz) + "]";
first = t1;
}
} else {
++t;
- db.names.push_back("pixel vector[" + typename C::String(num, sz) +
- "]");
+ db.names.push_back("pixel vector[" + std::string(num, sz) + "]");
first = t;
}
}
} else {
- typename C::String num;
+ std::string num;
const char *t1 = first + 2;
if (*t1 != '_') {
const char *t = parse_expression(t1, last, db);
@@ -2311,7 +2309,7 @@ static const char *parse_operator_name(c
template <class C>
static const char *parse_integer_literal(const char *first, const char *last,
- const typename C::String &lit, C &db) {
+ const std::string &lit, C &db) {
const char *t = parse_number(first, last);
if (t != first && t != last && *t == 'E') {
if (lit.size() > 3)
@@ -2472,8 +2470,8 @@ static const char *parse_expr_primary(co
if (n != t && n != last && *n == 'E') {
if (db.names.empty())
return first;
- db.names.back() = "(" + db.names.back().move_full() + ")" +
- typename C::String(t, n);
+ db.names.back() =
+ "(" + db.names.back().move_full() + ")" + std::string(t, n);
first = n + 1;
break;
}
@@ -2488,7 +2486,7 @@ static const char *parse_expr_primary(co
return first;
}
-template <class String> static String base_name(String &s) {
+static std::string base_name(std::string &s) {
if (s.empty())
return s;
if (s == "std::string") {
@@ -2514,7 +2512,7 @@ template <class String> static String ba
unsigned c = 1;
while (true) {
if (--pe == pf)
- return String();
+ return std::string();
if (pe[-1] == '<') {
if (--c == 0) {
--pe;
@@ -2525,7 +2523,7 @@ template <class String> static String ba
}
}
if (pe - pf <= 1)
- return String();
+ return std::string();
const char *p0 = pe - 1;
for (; p0 != pf; --p0) {
if (*p0 == ':') {
@@ -2533,7 +2531,7 @@ template <class String> static String ba
break;
}
}
- return String(p0, pe);
+ return std::string(p0, pe);
}
// <ctor-dtor-name> ::= C1 # complete object constructor
@@ -2598,7 +2596,7 @@ static const char *parse_unnamed_type_na
char type = first[1];
switch (type) {
case 't': {
- db.names.push_back(typename C::String("'unnamed"));
+ db.names.push_back(std::string("'unnamed"));
const char *t0 = first + 2;
if (t0 == last) {
db.names.pop_back();
@@ -2619,7 +2617,7 @@ static const char *parse_unnamed_type_na
first = t0 + 1;
} break;
case 'l': {
- db.names.push_back(typename C::String("'lambda'("));
+ db.names.push_back(std::string("'lambda'("));
const char *t0 = first + 2;
if (first[2] == 'v') {
db.names.back().first += ')';
@@ -2809,7 +2807,7 @@ static const char *parse_noexcept_expres
template <class C>
static const char *parse_prefix_expression(const char *first, const char *last,
- const typename C::String &op,
+ const std::string &op,
C &db) {
const char *t1 = parse_expression(first, last, db);
if (t1 != first) {
@@ -2823,7 +2821,7 @@ static const char *parse_prefix_expressi
template <class C>
static const char *parse_binary_expression(const char *first, const char *last,
- const typename C::String &op,
+ const std::string &op,
C &db) {
const char *t1 = parse_expression(first, last, db);
if (t1 != first) {
@@ -3014,8 +3012,8 @@ static const char *parse_expression(cons
if (db.names.empty())
return first;
db.names.back().first =
- (parsed_gs ? typename C::String("::") : typename C::String()) +
- "delete[] " + db.names.back().move_full();
+ (parsed_gs ? std::string("::") : std::string()) + "delete[] " +
+ db.names.back().move_full();
first = t1;
}
} break;
@@ -3033,8 +3031,8 @@ static const char *parse_expression(cons
if (db.names.empty())
return first;
db.names.back().first =
- (parsed_gs ? typename C::String("::") : typename C::String()) +
- "delete " + db.names.back().move_full();
+ (parsed_gs ? std::string("::") : std::string()) + "delete " +
+ db.names.back().move_full();
first = t1;
}
} break;
@@ -3442,7 +3440,7 @@ static const char *parse_template_args(c
if (db.tag_templates)
db.template_param.back().clear();
const char *t = first + 1;
- typename C::String args("<");
+ std::string args("<");
while (*t != 'E') {
if (db.tag_templates)
db.template_param.emplace_back(db.names.get_allocator());
@@ -4035,10 +4033,10 @@ static const char *parse_encoding(const
save_value<bool> sb2(db.tag_templates);
db.tag_templates = false;
const char *t2;
- typename C::String ret2;
+ std::string ret2;
if (db.names.empty())
return first;
- const typename C::String &nm = db.names.back().first;
+ const std::string &nm = db.names.back().first;
if (nm.empty())
return first;
if (!db.parsed_ctor_dtor_cv && ends_with_template_args) {
@@ -4070,7 +4068,7 @@ static const char *parse_encoding(const
if (t2 == t)
break;
if (k1 > k0) {
- typename C::String tmp;
+ std::string tmp;
for (size_t k = k0; k < k1; ++k) {
if (!tmp.empty())
tmp += ", ";
@@ -4161,7 +4159,7 @@ static const char *parse_dot_suffix(cons
if (first != last && *first == '.') {
if (db.names.empty())
return first;
- db.names.back().first += " (" + typename C::String(first, last) + ")";
+ db.names.back().first += " (" + std::string(first, last) + ")";
first = last;
}
return first;
@@ -4226,9 +4224,7 @@ template <class StrT> struct string_pair
};
struct Db {
- typedef std::basic_string<char, std::char_traits<char>>
- String;
- typedef Vector<string_pair<String>> sub_type;
+ typedef Vector<string_pair<std::string>> sub_type;
typedef Vector<sub_type> template_param_type;
sub_type names;
template_param_type subs;
More information about the llvm-commits
mailing list