[PATCH] Skip some unnecessary type checks.

Manuel Klimek klimek at google.com
Tue Dec 2 06:33:06 PST 2014


lg with comment added :)

================
Comment at: include/clang/AST/ASTTypeTraits.h:264
@@ -253,4 +263,3 @@
   bool operator==(const DynTypedNode &Other) const {
-    if (!NodeKind.isBaseOf(Other.NodeKind) &&
-        !Other.NodeKind.isBaseOf(NodeKind))
+    if (!NodeKind.isSame(Other.NodeKind))
       return false;
----------------
sbenza wrote:
> klimek wrote:
> > Why doesn't this change behavior? -> can we not get the same node with a different more or less specific type?
> It used to be that DynTypedNode::create() stored the static type of the node in NodeKind.
> Recently we added ASTNodeKind::getFromNode() to get the dynamic type of the node and we store that on the DTN.
> This was necessary for the RestrictKind optimizations.
> Now that we store the exact node kind, we can compare them directly. This is also why we can drop the dyn_cast<> in favor of just cast<> in DynCastPtrConverter::get() below. The node kind check is enough.
> Do you want a comment here?
Yse please :)

http://reviews.llvm.org/D6468






More information about the cfe-commits mailing list