[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: unittests/AST/ASTTraverserTest.cpp:75
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;

steveire wrote:
> aaron.ballman wrote:
> > Did clang-format produce this formatting? (If not, run through 
> > clang-format.)
> Yep, clang-format made it like this.
Weird that it added the extra whitespace -- I think this is the only instance 
where we have whitespace to either side of the adornments, which is what caught 
me by surprise.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61834



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


[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
steveire marked an inline comment as done.
Closed by commit rL361033: Add a Visit overload for DynTypedNode to 
ASTNodeTraverser (authored by steveire, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61834?vs=12=200036#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61834

Files:
  cfe/trunk/include/clang/AST/ASTNodeTraverser.h
  cfe/trunk/unittests/AST/ASTTraverserTest.cpp
  cfe/trunk/unittests/AST/CMakeLists.txt

Index: cfe/trunk/unittests/AST/CMakeLists.txt
===
--- cfe/trunk/unittests/AST/CMakeLists.txt
+++ cfe/trunk/unittests/AST/CMakeLists.txt
@@ -12,6 +12,7 @@
   ASTImporterTest.cpp
   ASTImporterGenericRedeclTest.cpp
   ASTImporterVisibilityTest.cpp
+  ASTTraverserTest.cpp
   ASTTypeTraitsTest.cpp
   ASTVectorTest.cpp
   CommentLexer.cpp
Index: cfe/trunk/unittests/AST/ASTTraverserTest.cpp
===
--- cfe/trunk/unittests/AST/ASTTraverserTest.cpp
+++ cfe/trunk/unittests/AST/ASTTraverserTest.cpp
@@ -0,0 +1,220 @@
+//===- unittests/AST/ASTTraverserTest.h===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTNodeTraverser.h"
+#include "clang/AST/TextNodeDumper.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang::tooling;
+using namespace clang::ast_matchers;
+
+namespace clang {
+
+class NodeTreePrinter : public TextTreeStructure {
+  llvm::raw_ostream 
+
+public:
+  NodeTreePrinter(llvm::raw_ostream )
+  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
+
+  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
+
+  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
+
+  void Visit(QualType QT) {
+OS << "QualType " << QT.split().Quals.getAsString();
+  }
+
+  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
+
+  void Visit(const comments::Comment *C, const comments::FullComment *FC) {
+OS << C->getCommentKindName();
+  }
+
+  void Visit(const CXXCtorInitializer *Init) { OS << "CXXCtorInitializer"; }
+
+  void Visit(const Attr *A) {
+switch (A->getKind()) {
+#define ATTR(X)\
+  case attr::X:\
+OS << #X;  \
+break;
+#include "clang/Basic/AttrList.inc"
+}
+OS << "Attr";
+  }
+
+  void Visit(const OMPClause *C) { OS << "OMPClause"; }
+  void Visit(const TemplateArgument , SourceRange R = {},
+ const Decl *From = nullptr, const char *Label = nullptr) {
+OS << "TemplateArgument";
+  }
+
+  template  void Visit(T...) {}
+};
+
+class TestASTDumper : public ASTNodeTraverser {
+
+  NodeTreePrinter MyNodeRecorder;
+
+public:
+  TestASTDumper(llvm::raw_ostream ) : MyNodeRecorder(OS) {}
+  NodeTreePrinter () { return MyNodeRecorder; }
+};
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+
+  TestASTDumper Dumper(OS);
+
+  OS << "\n";
+
+  Dumper.Visit(std::forward(N)...);
+
+  return OS.str();
+}
+
+const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
+const std::string ) {
+  auto Result = ast_matchers::match(functionDecl(hasName(Name)).bind("fn"),
+AST->getASTContext());
+  EXPECT_EQ(Result.size(), 1u);
+  return Result[0].getNodeAs("fn");
+}
+
+template  struct Verifier {
+  static void withDynNode(T Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(Node)),
+  DumpString);
+  }
+};
+
+template  struct Verifier {
+  static void withDynNode(T *Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(*Node)),
+  DumpString);
+  }
+};
+
+template 
+void verifyWithDynNode(T Node, const std::string ) {
+  EXPECT_EQ(dumpASTString(Node), DumpString);
+
+  Verifier::withDynNode(Node, DumpString);
+}
+
+TEST(Traverse, Dump) {
+
+  auto AST = buildASTFromCode(R"cpp(
+struct A {
+  int m_number;
+
+  /// CTor
+  A() : m_number(42) {}
+
+  [[nodiscard]] const int func() {
+return 42;
+  }
+
+};
+
+template
+struct templ
+{ 
+};
+

[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked 5 inline comments as done.
steveire added inline comments.



Comment at: unittests/AST/ASTTraverserTest.cpp:75
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;

aaron.ballman wrote:
> Did clang-format produce this formatting? (If not, run through clang-format.)
Yep, clang-format made it like this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834



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


[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In D61834#1505418 , @steveire wrote:

> In D61834#1505124 , @aaron.ballman 
> wrote:
>
> > In D61834#1505056 , @steveire 
> > wrote:
> >
> > > In D61834#1504665 , 
> > > @aaron.ballman wrote:
> > >
> > > > What will be making use of/testing this new functionality?
> > >
> > >
> > > Any code which has a `DynTypedNode` and wishes to traverse it.
> > >
> > > I envisage this as a more-flexible `DynTypedNode::dump` that the user 
> > > does not have to implement themselves in order to use the 
> > > `ASTNodeTraverser`.
> >
> >
> > Do we currently have any such code that's using this functionality, though? 
> > I'm mostly concerned that this is dead code with no testing, currently. The 
> > functionality itself seems reasonable enough and the code looks correct 
> > enough, so if this is part of a series of planned changes, that'd be good 
> > information to have for the review.
>
>
> Ah, yes. This is supposed to be 'useful public API' like the other Visit 
> methods for use inside and outside the codebase. A follow-up patch will use 
> it, but it's provided for external use too anyway.
>
> I'll add a unit test.


Ahh, thank you! It makes a lot more sense to me now. LGTM aside from some nits.




Comment at: include/clang/AST/ASTNodeTraverser.h:208
 
+  void Visit(const ast_type_traits::DynTypedNode ) {
+if (const auto *D = N.get())

Can you add a comment here: `// FIXME: Improve this with a switch or a visitor 
pattern.` (We have a similar comment in similar-looking code in 
ASTMatchFinder.cpp:476.)



Comment at: unittests/AST/ASTTraverserTest.cpp:75
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;

Did clang-format produce this formatting? (If not, run through clang-format.)



Comment at: unittests/AST/ASTTraverserTest.cpp:89
+const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
+const std::string ) {
+  auto Result = ast_matchers::match(functionDecl(hasName(name)).bind("fn"),

`Name` instead



Comment at: unittests/AST/ASTTraverserTest.cpp:97
+template  struct Verifier {
+  static void withDynNode(T Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(Node)),

`DumpString` -- same elsewhere.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834



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


[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 12.
steveire added a comment.

Update


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834

Files:
  include/clang/AST/ASTNodeTraverser.h
  unittests/AST/ASTTraverserTest.cpp
  unittests/AST/CMakeLists.txt

Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -12,6 +12,7 @@
   ASTImporterTest.cpp
   ASTImporterGenericRedeclTest.cpp
   ASTImporterVisibilityTest.cpp
+  ASTTraverserTest.cpp
   ASTTypeTraitsTest.cpp
   ASTVectorTest.cpp
   CommentLexer.cpp
Index: unittests/AST/ASTTraverserTest.cpp
===
--- /dev/null
+++ unittests/AST/ASTTraverserTest.cpp
@@ -0,0 +1,220 @@
+//===- unittests/AST/ASTTraverserTest.h===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTNodeTraverser.h"
+#include "clang/AST/TextNodeDumper.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang::tooling;
+using namespace clang::ast_matchers;
+
+namespace clang {
+
+class NodeTreePrinter : public TextTreeStructure {
+  llvm::raw_ostream 
+
+public:
+  NodeTreePrinter(llvm::raw_ostream )
+  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
+
+  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
+
+  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
+
+  void Visit(QualType QT) {
+OS << "QualType " << QT.split().Quals.getAsString();
+  }
+
+  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
+
+  void Visit(const comments::Comment *C, const comments::FullComment *FC) {
+OS << C->getCommentKindName();
+  }
+
+  void Visit(const CXXCtorInitializer *Init) { OS << "CXXCtorInitializer"; }
+
+  void Visit(const Attr *A) {
+switch (A->getKind()) {
+#define ATTR(X)\
+  case attr::X:\
+OS << #X;  \
+break;
+#include "clang/Basic/AttrList.inc"
+}
+OS << "Attr";
+  }
+
+  void Visit(const OMPClause *C) { OS << "OMPClause"; }
+  void Visit(const TemplateArgument , SourceRange R = {},
+ const Decl *From = nullptr, const char *Label = nullptr) {
+OS << "TemplateArgument";
+  }
+
+  template  void Visit(T...) {}
+};
+
+class TestASTDumper : public ASTNodeTraverser {
+
+  NodeTreePrinter MyNodeRecorder;
+
+public:
+  TestASTDumper(llvm::raw_ostream ) : MyNodeRecorder(OS) {}
+  NodeTreePrinter () { return MyNodeRecorder; }
+};
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+
+  TestASTDumper Dumper(OS);
+
+  OS << "\n";
+
+  Dumper.Visit(std::forward(N)...);
+
+  return OS.str();
+}
+
+const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
+const std::string ) {
+  auto Result = ast_matchers::match(functionDecl(hasName(name)).bind("fn"),
+AST->getASTContext());
+  EXPECT_EQ(Result.size(), 1u);
+  return Result[0].getNodeAs("fn");
+}
+
+template  struct Verifier {
+  static void withDynNode(T Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(Node)),
+  dumpString);
+  }
+};
+
+template  struct Verifier {
+  static void withDynNode(T *Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(*Node)),
+  dumpString);
+  }
+};
+
+template 
+void verifyWithDynNode(T Node, const std::string ) {
+  EXPECT_EQ(dumpASTString(Node), dumpString);
+
+  Verifier::withDynNode(Node, dumpString);
+}
+
+TEST(Traverse, Dump) {
+
+  auto AST = buildASTFromCode(R"cpp(
+struct A {
+  int m_number;
+
+  /// CTor
+  A() : m_number(42) {}
+
+  [[nodiscard]] const int func() {
+return 42;
+  }
+
+};
+
+template
+struct templ
+{ 
+};
+
+template<>
+struct templ
+{ 
+};
+
+)cpp");
+
+  const FunctionDecl *Func = getFunctionNode(AST.get(), "func");
+
+  verifyWithDynNode(Func,
+R"cpp(
+CXXMethodDecl
+|-CompoundStmt
+| `-ReturnStmt
+|   `-IntegerLiteral
+`-WarnUnusedResultAttr
+)cpp");
+
+  Stmt *Body = Func->getBody();
+
+  verifyWithDynNode(Body,
+R"cpp(
+CompoundStmt
+`-ReturnStmt
+  `-IntegerLiteral
+)cpp");
+
+  

[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 199922.
steveire added a comment.
Herald added a subscriber: mgorny.

Add basic traverser test


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834

Files:
  include/clang/AST/ASTNodeTraverser.h
  unittests/AST/ASTTraverserTest.cpp
  unittests/AST/CMakeLists.txt

Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -12,6 +12,7 @@
   ASTImporterTest.cpp
   ASTImporterGenericRedeclTest.cpp
   ASTImporterVisibilityTest.cpp
+  ASTTraverserTest.cpp
   ASTTypeTraitsTest.cpp
   ASTVectorTest.cpp
   CommentLexer.cpp
Index: unittests/AST/ASTTraverserTest.cpp
===
--- /dev/null
+++ unittests/AST/ASTTraverserTest.cpp
@@ -0,0 +1,220 @@
+//===- unittests/AST/ASTTraverserTest.h===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTNodeTraverser.h"
+#include "clang/AST/TextNodeDumper.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang::tooling;
+using namespace clang::ast_matchers;
+
+namespace clang {
+
+class NodeTreePrinter : public TextTreeStructure {
+  llvm::raw_ostream 
+
+public:
+  NodeTreePrinter(llvm::raw_ostream )
+  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
+
+  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
+
+  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
+
+  void Visit(QualType QT) {
+OS << "QualType " << QT.split().Quals.getAsString();
+  }
+
+  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
+
+  void Visit(const comments::Comment *C, const comments::FullComment *FC) {
+OS << C->getCommentKindName();
+  }
+
+  void Visit(const CXXCtorInitializer *Init) { OS << "CXXCtorInitializer"; }
+
+  void Visit(const Attr *A) {
+switch (A->getKind()) {
+#define ATTR(X)\
+  case attr::X:\
+OS << #X;  \
+break;
+#include "clang/Basic/AttrList.inc"
+}
+OS << "Attr";
+  }
+
+  void Visit(const OMPClause *C) { OS << "OMPClause"; }
+  void Visit(const TemplateArgument , SourceRange R = {},
+ const Decl *From = nullptr, const char *Label = nullptr) {
+OS << "TemplateArgument";
+  }
+
+  template  void Visit(T...) {}
+};
+
+class TestASTDumper : public ASTNodeTraverser {
+
+  NodeTreePrinter MyNodeRecorder;
+
+public:
+  TestASTDumper(llvm::raw_ostream ) : MyNodeRecorder(OS) {}
+  NodeTreePrinter () { return MyNodeRecorder; }
+};
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+
+  TestASTDumper Dumper(OS);
+
+  OS << "\n";
+
+  Dumper.Visit(std::forward(N)...);
+
+  return OS.str();
+}
+
+const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
+const std::string ) {
+  auto Result = ast_matchers::match(functionDecl(hasName(name)).bind("fn"),
+AST->getASTContext());
+  EXPECT_EQ(Result.size(), 1u);
+  return Result[0].getNodeAs("fn");
+}
+
+template  struct Verifier {
+  static void withDynNode(T Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(Node)),
+  dumpString);
+  }
+};
+
+template  struct Verifier {
+  static void withDynNode(T *Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(*Node)),
+  dumpString);
+  }
+};
+
+template 
+void verifyWithDynNode(T Node, const std::string ) {
+  EXPECT_EQ(dumpASTString(Node), dumpString);
+
+  Verifier::withDynNode(Node, dumpString);
+}
+
+TEST(Traverse, Dump) {
+
+  auto AST = buildASTFromCode(R"cpp(
+struct A {
+  int m_number;
+
+  /// CTor
+  A() : m_number(42) {}
+
+  [[nodiscard]] const int func() {
+return 42;
+  }
+
+};
+
+template
+struct templ
+{ 
+};
+
+template<>
+struct templ
+{ 
+};
+
+)cpp");
+
+  const FunctionDecl *Func = getFunctionNode(AST.get(), "func");
+
+  verifyWithDynNode(Func,
+R"cpp(
+CXXMethodDecl
+|-CompoundStmt
+| `-ReturnStmt
+|   `-IntegerLiteral
+`-WarnUnusedResultAttr
+)cpp");
+
+  Stmt *Body = Func->getBody();
+
+  verifyWithDynNode(Body,
+R"cpp(
+CompoundStmt

[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D61834#1505124 , @aaron.ballman 
wrote:

> In D61834#1505056 , @steveire wrote:
>
> > In D61834#1504665 , @aaron.ballman 
> > wrote:
> >
> > > What will be making use of/testing this new functionality?
> >
> >
> > Any code which has a `DynTypedNode` and wishes to traverse it.
> >
> > I envisage this as a more-flexible `DynTypedNode::dump` that the user does 
> > not have to implement themselves in order to use the `ASTNodeTraverser`.
>
>
> Do we currently have any such code that's using this functionality, though? 
> I'm mostly concerned that this is dead code with no testing, currently. The 
> functionality itself seems reasonable enough and the code looks correct 
> enough, so if this is part of a series of planned changes, that'd be good 
> information to have for the review.


Ah, yes. This is supposed to be 'useful public API' like the other Visit 
methods for use inside and outside the codebase. A follow-up patch will use it, 
but it's provided for external use too anyway.

I'll add a unit test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834



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


[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D61834#1505056 , @steveire wrote:

> In D61834#1504665 , @aaron.ballman 
> wrote:
>
> > What will be making use of/testing this new functionality?
>
>
> Any code which has a `DynTypedNode` and wishes to traverse it.
>
> I envisage this as a more-flexible `DynTypedNode::dump` that the user does 
> not have to implement themselves in order to use the `ASTNodeTraverser`.


Do we currently have any such code that's using this functionality, though? I'm 
mostly concerned that this is dead code with no testing, currently. The 
functionality itself seems reasonable enough and the code looks correct enough, 
so if this is part of a series of planned changes, that'd be good information 
to have for the review.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834



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


[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-16 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D61834#1504665 , @aaron.ballman 
wrote:

> What will be making use of/testing this new functionality?


Any code which has a `DynTypedNode` and wishes to traverse it.

I envisage this as a more-flexible `DynTypedNode::dump` that the user does not 
have to implement themselves in order to use the `ASTNodeTraverser`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834



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


[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

What will be making use of/testing this new functionality?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834



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


[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 199178.
steveire added a comment.

Format


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834

Files:
  include/clang/AST/ASTNodeTraverser.h


Index: include/clang/AST/ASTNodeTraverser.h
===
--- include/clang/AST/ASTNodeTraverser.h
+++ include/clang/AST/ASTNodeTraverser.h
@@ -205,6 +205,27 @@
 });
   }
 
+  void Visit(const ast_type_traits::DynTypedNode ) {
+if (const auto *D = N.get())
+  Visit(D);
+else if (const auto *S = N.get())
+  Visit(S);
+else if (const auto *QT = N.get())
+  Visit(*QT);
+else if (const auto *T = N.get())
+  Visit(T);
+else if (const auto *A = N.get())
+  Visit(A);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *C = N.get())
+  Visit(C, C);
+else if (const auto *T = N.get())
+  Visit(*T);
+  }
+
   void dumpDeclContext(const DeclContext *DC) {
 if (!DC)
   return;


Index: include/clang/AST/ASTNodeTraverser.h
===
--- include/clang/AST/ASTNodeTraverser.h
+++ include/clang/AST/ASTNodeTraverser.h
@@ -205,6 +205,27 @@
 });
   }
 
+  void Visit(const ast_type_traits::DynTypedNode ) {
+if (const auto *D = N.get())
+  Visit(D);
+else if (const auto *S = N.get())
+  Visit(S);
+else if (const auto *QT = N.get())
+  Visit(*QT);
+else if (const auto *T = N.get())
+  Visit(T);
+else if (const auto *A = N.get())
+  Visit(A);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *C = N.get())
+  Visit(C, C);
+else if (const auto *T = N.get())
+  Visit(*T);
+  }
+
   void dumpDeclContext(const DeclContext *DC) {
 if (!DC)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D61834

Files:
  include/clang/AST/ASTNodeTraverser.h


Index: include/clang/AST/ASTNodeTraverser.h
===
--- include/clang/AST/ASTNodeTraverser.h
+++ include/clang/AST/ASTNodeTraverser.h
@@ -205,6 +205,27 @@
 });
   }
 
+  void Visit(const ast_type_traits::DynTypedNode& N) {
+if (const auto *D = N.get())
+  Visit(D);
+else if (const auto *S = N.get())
+  Visit(S);
+else if (const auto* QT = N.get())
+  Visit(*QT);
+else if (const auto *T = N.get())
+  Visit(T);
+else if (const auto *A = N.get())
+  Visit(A);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *C = N.get())
+  Visit(C, C);
+else if (const auto* T = N.get())
+  Visit(*T);
+  }
+
   void dumpDeclContext(const DeclContext *DC) {
 if (!DC)
   return;


Index: include/clang/AST/ASTNodeTraverser.h
===
--- include/clang/AST/ASTNodeTraverser.h
+++ include/clang/AST/ASTNodeTraverser.h
@@ -205,6 +205,27 @@
 });
   }
 
+  void Visit(const ast_type_traits::DynTypedNode& N) {
+if (const auto *D = N.get())
+  Visit(D);
+else if (const auto *S = N.get())
+  Visit(S);
+else if (const auto* QT = N.get())
+  Visit(*QT);
+else if (const auto *T = N.get())
+  Visit(T);
+else if (const auto *A = N.get())
+  Visit(A);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *C = N.get())
+  Visit(C, C);
+else if (const auto* T = N.get())
+  Visit(*T);
+  }
+
   void dumpDeclContext(const DeclContext *DC) {
 if (!DC)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits