|
20 | 20 |
|
21 | 21 | using namespace clang; |
22 | 22 |
|
23 | | -ParentMapContext::ParentMapContext(ASTContext &Ctx) : ASTCtx(Ctx) {} |
24 | | - |
25 | | -ParentMapContext::~ParentMapContext() = default; |
26 | | - |
27 | | -void ParentMapContext::clear() { Parents.reset(); } |
28 | | - |
29 | | -const Expr *ParentMapContext::traverseIgnored(const Expr *E) const { |
30 | | - return traverseIgnored(const_cast<Expr *>(E)); |
31 | | -} |
32 | | - |
33 | | -Expr *ParentMapContext::traverseIgnored(Expr *E) const { |
34 | | - if (!E) |
35 | | - return nullptr; |
36 | | - |
37 | | - switch (Traversal) { |
38 | | - case TK_AsIs: |
39 | | - return E; |
40 | | - case TK_IgnoreUnlessSpelledInSource: |
41 | | - return E->IgnoreUnlessSpelledInSource(); |
42 | | - } |
43 | | - llvm_unreachable("Invalid Traversal type!"); |
44 | | -} |
45 | | - |
46 | | -DynTypedNode ParentMapContext::traverseIgnored(const DynTypedNode &N) const { |
47 | | - if (const auto *E = N.get<Expr>()) { |
48 | | - return DynTypedNode::create(*traverseIgnored(E)); |
49 | | - } |
50 | | - return N; |
51 | | -} |
52 | | - |
53 | 23 | template <typename T, typename... U> |
54 | 24 | static std::tuple<bool, DynTypedNodeList, const T *, const U *...> |
55 | 25 | matchParents(const DynTypedNodeList &NodeList, |
@@ -334,6 +304,36 @@ matchParents(const DynTypedNodeList &NodeList, |
334 | 304 | return MatchParents<T, U...>::match(NodeList, ParentMap); |
335 | 305 | } |
336 | 306 |
|
| 307 | +ParentMapContext::ParentMapContext(ASTContext &Ctx) : ASTCtx(Ctx) {} |
| 308 | + |
| 309 | +ParentMapContext::~ParentMapContext() = default; |
| 310 | + |
| 311 | +void ParentMapContext::clear() { Parents.reset(); } |
| 312 | + |
| 313 | +const Expr *ParentMapContext::traverseIgnored(const Expr *E) const { |
| 314 | + return traverseIgnored(const_cast<Expr *>(E)); |
| 315 | +} |
| 316 | + |
| 317 | +Expr *ParentMapContext::traverseIgnored(Expr *E) const { |
| 318 | + if (!E) |
| 319 | + return nullptr; |
| 320 | + |
| 321 | + switch (Traversal) { |
| 322 | + case TK_AsIs: |
| 323 | + return E; |
| 324 | + case TK_IgnoreUnlessSpelledInSource: |
| 325 | + return E->IgnoreUnlessSpelledInSource(); |
| 326 | + } |
| 327 | + llvm_unreachable("Invalid Traversal type!"); |
| 328 | +} |
| 329 | + |
| 330 | +DynTypedNode ParentMapContext::traverseIgnored(const DynTypedNode &N) const { |
| 331 | + if (const auto *E = N.get<Expr>()) { |
| 332 | + return DynTypedNode::create(*traverseIgnored(E)); |
| 333 | + } |
| 334 | + return N; |
| 335 | +} |
| 336 | + |
337 | 337 | /// Template specializations to abstract away from pointers and TypeLocs. |
338 | 338 | /// @{ |
339 | 339 | template <typename T> static DynTypedNode createDynTypedNode(const T &Node) { |
|
0 commit comments