[PATCH] [clang] Optimized ASTNodeKind::isBaseOf

Manuel Klimek klimek at google.com
Thu Oct 2 05:27:39 PDT 2014


================
Comment at: lib/AST/ASTTypeTraits.cpp:47
@@ +46,3 @@
+      for (unsigned Parent = NKI_None; Parent < NKI_NumberOfKinds; ++Parent)
+        ParentDistances[Node][Parent] = -1U;
+      unsigned Distance = 0;
----------------
Also, perhaps declare a constant to std::numeric_limits<unsigned>::max()?

================
Comment at: lib/AST/ASTTypeTraits.cpp:61
@@ +60,3 @@
+bool ASTNodeKind::isBaseOf(ASTNodeKind Other) const {
+  static const NodeParentMap *Map = new NodeParentMap;
+  return Map->ParentDistances[Other.KindId][KindId] != -1U;
----------------
Not sure whether we care about thread safety here (and VS <= 2013 still not providing it).

http://reviews.llvm.org/D5577






More information about the cfe-commits mailing list