|
8 | 8 | #include <clang/Basic/SourceManager.h> |
9 | 9 | #include <clang/Lex/Lexer.h> |
10 | 10 |
|
11 | | -#include <array> |
12 | 11 | #include <cctype> |
13 | 12 | #include <format> |
14 | | -#include <regex> |
15 | 13 | #include <string_view> |
16 | 14 | #include <utility> |
17 | 15 |
|
@@ -78,24 +76,6 @@ clang::QualType normalizeQualType(clang::ASTContext &ctx, |
78 | 76 | ctx); |
79 | 77 | } |
80 | 78 |
|
81 | | -std::string normalizeTranslationRule(std::string rule) { |
82 | | - // Detach pointer from double reference. Useful for matching translation |
83 | | - // rules. |
84 | | - ReplaceAll(rule, "*&&", "* &&"); |
85 | | - |
86 | | - static const std::array<std::pair<std::regex, std::string>, 1> |
87 | | - normalization_rules{{ |
88 | | - // Ignore constant template parameters, i.e. replace them with _. |
89 | | - {std::regex(R"(\b\d+\b)"), "_"}, |
90 | | - }}; |
91 | | - |
92 | | - for (const auto &r : normalization_rules) { |
93 | | - rule = std::regex_replace(rule, r.first, r.second); |
94 | | - } |
95 | | - |
96 | | - return rule; |
97 | | -} |
98 | | - |
99 | 79 | } // namespace |
100 | 80 |
|
101 | 81 | std::string ToRustName(std::string name) { |
@@ -171,7 +151,7 @@ std::string ToString(clang::ASTContext &ctx, clang::QualType qual_type, |
171 | 151 | std::string out; |
172 | 152 | llvm::raw_string_ostream os(out); |
173 | 153 | ctx.getPointerType(pointee).print(os, getPrintPolicy(ctx)); |
174 | | - return normalizeTranslationRule(std::move(out)); |
| 154 | + return out; |
175 | 155 | } |
176 | 156 | } |
177 | 157 |
|
@@ -200,7 +180,7 @@ std::string ToString(clang::ASTContext &ctx, clang::QualType qual_type, |
200 | 180 | std::string type; |
201 | 181 | llvm::raw_string_ostream os(type); |
202 | 182 | normalizeQualType(ctx, qual_type).print(os, getPrintPolicy(ctx)); |
203 | | - return normalizeTranslationRule(std::move(type)); |
| 183 | + return type; |
204 | 184 | } |
205 | 185 |
|
206 | 186 | std::string ToString(clang::ASTContext &ctx, const clang::NamedDecl *decl) { |
@@ -237,7 +217,7 @@ std::string ToString(clang::ASTContext &ctx, const clang::NamedDecl *decl) { |
237 | 217 |
|
238 | 218 | if (!func_decl) { |
239 | 219 | decl->printQualifiedName(os, getPrintPolicy(ctx)); |
240 | | - return normalizeTranslationRule(std::move(out)); |
| 220 | + return out; |
241 | 221 | } |
242 | 222 |
|
243 | 223 | os << ToString(ctx, func_decl->getReturnType()) << ' '; |
@@ -324,7 +304,7 @@ std::string ToString(clang::ASTContext &ctx, const clang::NamedDecl *decl) { |
324 | 304 | } |
325 | 305 | } |
326 | 306 |
|
327 | | - return normalizeTranslationRule(std::move(out)); |
| 307 | + return out; |
328 | 308 | } |
329 | 309 |
|
330 | 310 | std::string ToString(clang::ASTContext &ctx, const clang::Expr *expr) { |
|
0 commit comments