@@ -12,10 +12,11 @@ |
|
|
12 |
12 |
//===----------------------------------------------------------------------===// |
13 |
13 |
|
14 |
14 |
#include "clang/AST/ParentMapContext.h" |
15 |
|
-#include "clang/AST/RecursiveASTVisitor.h" |
16 |
15 |
#include "clang/AST/Decl.h" |
17 |
16 |
#include "clang/AST/Expr.h" |
|
17 |
+#include "clang/AST/RecursiveASTVisitor.h" |
18 |
18 |
#include "clang/AST/TemplateBase.h" |
|
19 |
+#include "llvm/ADT/SmallPtrSet.h" |
19 |
20 |
|
20 |
21 |
using namespace clang; |
21 |
22 |
|
@@ -69,17 +70,21 @@ class ParentMapContext::ParentMap { |
|
|
69 |
70 |
for (; N > 0; --N) |
70 |
71 |
push_back(Value); |
71 |
72 |
} |
72 |
|
-bool contains(const DynTypedNode &Value) { |
73 |
|
-return Seen.contains(Value); |
|
73 |
+bool contains(const DynTypedNode &Value) const { |
|
74 |
+const void *Identity = Value.getMemoizationData(); |
|
75 |
+assert(Identity); |
|
76 |
+return Dedup.contains(Identity); |
74 |
77 |
} |
75 |
78 |
void push_back(const DynTypedNode &Value) { |
76 |
|
-if (!Value.getMemoizationData() | |
|
79 |
+const void *Identity = Value.getMemoizationData(); |
|
80 |
+if (!Identity | |
77 |
81 |
Items.push_back(Value); |
|
82 |
+ } |
78 |
83 |
} |
79 |
84 |
llvm::ArrayRef view() const { return Items; } |
80 |
85 |
private: |
81 |
|
- llvm::SmallVector<DynTypedNode, 2> Items; |
82 |
|
- llvm::SmallDenseSet<DynTypedNode, 2> Seen; |
|
86 |
+ llvm::SmallVector<DynTypedNode, 1> Items; |
|
87 |
+ llvm::SmallPtrSet<const void *, 2> Dedup; |
83 |
88 |
}; |
84 |
89 |
|
85 |
90 |
/// Maps from a node to its parents. This is used for nodes that have |