[PATCH] D133298: [clang-rename] RecursiveSymbolVisitor - visit namespace aliases and using directives

2022-09-05 Thread imctrading via Phabricator via cfe-commits
imctrading created this revision.
imctrading added reviewers: klimek, dcastagna, arphaman.
Herald added a subscriber: jeroen.dobbelaere.
Herald added a project: All.
imctrading requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`RecursiveSymbolVisitor` - used by clang-rename does not visit namespace 
aliases and using directives. This patch fixes that.
This allows the tool to be used to rename namespaces.

Fixes https://github.com/llvm/llvm-project/issues/57194


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133298

Files:
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  clang/test/clang-rename/Namespace.cpp


Index: clang/test/clang-rename/Namespace.cpp
===
--- clang/test/clang-rename/Namespace.cpp
+++ clang/test/clang-rename/Namespace.cpp
@@ -6,6 +6,9 @@
   gcc::x = 42;// CHECK: clang::x = 42;
 }
 
+namespace gcc_alias = gcc; // CHECK: namespace gcc_alias = clang;
+using namespace gcc; // CHECK: using namespace clang;
+
 // Test 1.
 // RUN: clang-rename -offset=10 -new-name=clang %s -- | sed 's,//.*,,' | 
FileCheck %s
 
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -133,6 +133,14 @@
 return true;
   }
 
+  bool VisitNamespaceAliasDecl(NamespaceAliasDecl *Declaration) {
+return visit(Declaration->getAliasedNamespace(), 
Declaration->getTargetNameLoc(), Declaration->getEndLoc());
+  }
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *Declaration) {
+return visit(Declaration->getNominatedNamespace(), 
Declaration->getIdentLocation(), Declaration->getEndLoc());
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;


Index: clang/test/clang-rename/Namespace.cpp
===
--- clang/test/clang-rename/Namespace.cpp
+++ clang/test/clang-rename/Namespace.cpp
@@ -6,6 +6,9 @@
   gcc::x = 42;// CHECK: clang::x = 42;
 }
 
+namespace gcc_alias = gcc; // CHECK: namespace gcc_alias = clang;
+using namespace gcc; // CHECK: using namespace clang;
+
 // Test 1.
 // RUN: clang-rename -offset=10 -new-name=clang %s -- | sed 's,//.*,,' | FileCheck %s
 
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -133,6 +133,14 @@
 return true;
   }
 
+  bool VisitNamespaceAliasDecl(NamespaceAliasDecl *Declaration) {
+return visit(Declaration->getAliasedNamespace(), Declaration->getTargetNameLoc(), Declaration->getEndLoc());
+  }
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *Declaration) {
+return visit(Declaration->getNominatedNamespace(), Declaration->getIdentLocation(), Declaration->getEndLoc());
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133298: [clang-rename] RecursiveSymbolVisitor - visit namespace aliases and using directives

2022-09-05 Thread imctrading via Phabricator via cfe-commits
imctrading updated this revision to Diff 457978.
imctrading added a comment.

Fix formatting in the test.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133298/new/

https://reviews.llvm.org/D133298

Files:
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  clang/test/clang-rename/Namespace.cpp


Index: clang/test/clang-rename/Namespace.cpp
===
--- clang/test/clang-rename/Namespace.cpp
+++ clang/test/clang-rename/Namespace.cpp
@@ -6,6 +6,9 @@
   gcc::x = 42;// CHECK: clang::x = 42;
 }
 
+namespace gcc_alias = gcc;// CHECK: namespace gcc_alias = clang;
+using namespace gcc;  // CHECK: using namespace clang;
+
 // Test 1.
 // RUN: clang-rename -offset=10 -new-name=clang %s -- | sed 's,//.*,,' | 
FileCheck %s
 
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -133,6 +133,14 @@
 return true;
   }
 
+  bool VisitNamespaceAliasDecl(NamespaceAliasDecl *Declaration) {
+return visit(Declaration->getAliasedNamespace(), 
Declaration->getTargetNameLoc(), Declaration->getEndLoc());
+  }
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *Declaration) {
+return visit(Declaration->getNominatedNamespace(), 
Declaration->getIdentLocation(), Declaration->getEndLoc());
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;


Index: clang/test/clang-rename/Namespace.cpp
===
--- clang/test/clang-rename/Namespace.cpp
+++ clang/test/clang-rename/Namespace.cpp
@@ -6,6 +6,9 @@
   gcc::x = 42;// CHECK: clang::x = 42;
 }
 
+namespace gcc_alias = gcc;// CHECK: namespace gcc_alias = clang;
+using namespace gcc;  // CHECK: using namespace clang;
+
 // Test 1.
 // RUN: clang-rename -offset=10 -new-name=clang %s -- | sed 's,//.*,,' | FileCheck %s
 
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -133,6 +133,14 @@
 return true;
   }
 
+  bool VisitNamespaceAliasDecl(NamespaceAliasDecl *Declaration) {
+return visit(Declaration->getAliasedNamespace(), Declaration->getTargetNameLoc(), Declaration->getEndLoc());
+  }
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *Declaration) {
+return visit(Declaration->getNominatedNamespace(), Declaration->getIdentLocation(), Declaration->getEndLoc());
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133298: [clang-rename] RecursiveSymbolVisitor - visit namespace aliases and using directives

2022-09-05 Thread imctrading via Phabricator via cfe-commits
imctrading updated this revision to Diff 458010.
imctrading added a comment.

Fix formatting in `RecursiveSymbolVisitor.h`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133298/new/

https://reviews.llvm.org/D133298

Files:
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  clang/test/clang-rename/Namespace.cpp


Index: clang/test/clang-rename/Namespace.cpp
===
--- clang/test/clang-rename/Namespace.cpp
+++ clang/test/clang-rename/Namespace.cpp
@@ -6,6 +6,9 @@
   gcc::x = 42;// CHECK: clang::x = 42;
 }
 
+namespace gcc_alias = gcc;// CHECK: namespace gcc_alias = clang;
+using namespace gcc;  // CHECK: using namespace clang;
+
 // Test 1.
 // RUN: clang-rename -offset=10 -new-name=clang %s -- | sed 's,//.*,,' | 
FileCheck %s
 
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -133,6 +133,16 @@
 return true;
   }
 
+  bool VisitNamespaceAliasDecl(NamespaceAliasDecl *Declaration) {
+return visit(Declaration->getAliasedNamespace(),
+ Declaration->getTargetNameLoc(), Declaration->getEndLoc());
+  }
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *Declaration) {
+return visit(Declaration->getNominatedNamespace(),
+ Declaration->getIdentLocation(), Declaration->getEndLoc());
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;


Index: clang/test/clang-rename/Namespace.cpp
===
--- clang/test/clang-rename/Namespace.cpp
+++ clang/test/clang-rename/Namespace.cpp
@@ -6,6 +6,9 @@
   gcc::x = 42;// CHECK: clang::x = 42;
 }
 
+namespace gcc_alias = gcc;// CHECK: namespace gcc_alias = clang;
+using namespace gcc;  // CHECK: using namespace clang;
+
 // Test 1.
 // RUN: clang-rename -offset=10 -new-name=clang %s -- | sed 's,//.*,,' | FileCheck %s
 
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -133,6 +133,16 @@
 return true;
   }
 
+  bool VisitNamespaceAliasDecl(NamespaceAliasDecl *Declaration) {
+return visit(Declaration->getAliasedNamespace(),
+ Declaration->getTargetNameLoc(), Declaration->getEndLoc());
+  }
+
+  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *Declaration) {
+return visit(Declaration->getNominatedNamespace(),
+ Declaration->getIdentLocation(), Declaration->getEndLoc());
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133298: [clang-rename] RecursiveSymbolVisitor - visit namespace aliases and using directives

2022-09-12 Thread imctrading via Phabricator via cfe-commits
imctrading added a comment.

ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133298/new/

https://reviews.llvm.org/D133298

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits