================
@@ -34,13 +43,26 @@ template <typename T> bool MapASTVisitor::mapDecl(const T 
*D) {
   // If there is an error generating a USR for the decl, skip this decl.
   if (index::generateUSRForDecl(D, USR))
     return true;
+
+  // Prevent Visiting USR twice
+  {
+    std::lock_guard<llvm::sys::Mutex> Guard(USRVisitedGuard);
+    std::string Visited = USR.str().str();
+    if (USRVisited.count(Visited))
+      return true;
+    // We considered a USR to be visited only when its defined
+    if (IsDefinition)
+      USRVisited.insert(Visited);
----------------
PeterChou1 wrote:

Good point, I hadn't considered that this was my clumsy attempt at trying to 
remove the redundant work done by the ASTVisitor. Since we are undeniably doing 
some redundant work. if you take a look at the Shape class from the e2e test 
you'll see that we visit the declaration 3 times once for parsing the initial 
file and the twice more for each subclass. Is there any other mechanism that 
prevents this type of behaviour? This essentially what this patch is trying to 
accomplish 

https://github.com/llvm/llvm-project/pull/96809
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to