This revision was automatically updated to reflect the committed changes.
Closed by commit rL292098: [clang-move] Dump enum and type alias declarations. 
(authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D28293?vs=83054&id=84525#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28293

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp


Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -535,6 +535,10 @@
                             "namespace b {\n"
                             "class Move1 { public : void f(); };\n"
                             "void f() {}\n"
+                            "enum E1 { Green };\n"
+                            "enum class E2 { Red };\n"
+                            "typedef int Int2;\n"
+                            "using Int = int;\n"
                             "} // namespace b\n"
                             "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -545,22 +549,16 @@
   Spec.NewHeader = "new_foo.h";
   Spec.NewCC = "new_foo.cc";
   DeclarationReporter Reporter;
-  std::vector<DeclarationReporter::DeclarationPair> ExpectedDeclarations = {
+  std::set<DeclarationReporter::DeclarationPair> ExpectedDeclarations = {
       {"A", "Class"},         {"B", "Class"},        {"a::Move1", "Class"},
       {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
-      {"a::b::f", "Function"}};
+      {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
+      {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
   runClangMoveOnCode(Spec, TestHeader, TestCode, &Reporter);
-  const auto& Results = Reporter.getDeclarationList();
-  auto ActualDeclIter = Results.begin();
-  auto ExpectedDeclIter = ExpectedDeclarations.begin();
-  while (ActualDeclIter != Results.end() &&
-         ExpectedDeclIter != ExpectedDeclarations.end()) {
-    EXPECT_EQ(*ActualDeclIter, *ExpectedDeclIter);
-    ++ActualDeclIter;
-    ++ExpectedDeclIter;
-  }
-  ASSERT_TRUE(ActualDeclIter == Results.end());
-  ASSERT_TRUE(ExpectedDeclIter == ExpectedDeclarations.end());
+  std::set<DeclarationReporter::DeclarationPair> Results;
+  for (const auto& DelPair : Reporter.getDeclarationList())
+    Results.insert(DelPair);
+  EXPECT_EQ(ExpectedDeclarations, Results);
 }
 
 } // namespace
Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp
===================================================================
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp
@@ -841,6 +841,12 @@
       else if (Kind == Decl::Kind::ClassTemplate ||
                Kind == Decl::Kind::CXXRecord)
         Reporter->reportDeclaration(QualifiedName, "Class");
+      else if (Kind == Decl::Kind::Enum)
+        Reporter->reportDeclaration(QualifiedName, "Enum");
+      else if (Kind == Decl::Kind::Typedef ||
+               Kind == Decl::Kind::TypeAlias ||
+               Kind == Decl::Kind::TypeAliasTemplate)
+        Reporter->reportDeclaration(QualifiedName, "TypeAlias");
     }
     return;
   }


Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -535,6 +535,10 @@
                             "namespace b {\n"
                             "class Move1 { public : void f(); };\n"
                             "void f() {}\n"
+                            "enum E1 { Green };\n"
+                            "enum class E2 { Red };\n"
+                            "typedef int Int2;\n"
+                            "using Int = int;\n"
                             "} // namespace b\n"
                             "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -545,22 +549,16 @@
   Spec.NewHeader = "new_foo.h";
   Spec.NewCC = "new_foo.cc";
   DeclarationReporter Reporter;
-  std::vector<DeclarationReporter::DeclarationPair> ExpectedDeclarations = {
+  std::set<DeclarationReporter::DeclarationPair> ExpectedDeclarations = {
       {"A", "Class"},         {"B", "Class"},        {"a::Move1", "Class"},
       {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
-      {"a::b::f", "Function"}};
+      {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
+      {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
   runClangMoveOnCode(Spec, TestHeader, TestCode, &Reporter);
-  const auto& Results = Reporter.getDeclarationList();
-  auto ActualDeclIter = Results.begin();
-  auto ExpectedDeclIter = ExpectedDeclarations.begin();
-  while (ActualDeclIter != Results.end() &&
-         ExpectedDeclIter != ExpectedDeclarations.end()) {
-    EXPECT_EQ(*ActualDeclIter, *ExpectedDeclIter);
-    ++ActualDeclIter;
-    ++ExpectedDeclIter;
-  }
-  ASSERT_TRUE(ActualDeclIter == Results.end());
-  ASSERT_TRUE(ExpectedDeclIter == ExpectedDeclarations.end());
+  std::set<DeclarationReporter::DeclarationPair> Results;
+  for (const auto& DelPair : Reporter.getDeclarationList())
+    Results.insert(DelPair);
+  EXPECT_EQ(ExpectedDeclarations, Results);
 }
 
 } // namespace
Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp
===================================================================
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp
@@ -841,6 +841,12 @@
       else if (Kind == Decl::Kind::ClassTemplate ||
                Kind == Decl::Kind::CXXRecord)
         Reporter->reportDeclaration(QualifiedName, "Class");
+      else if (Kind == Decl::Kind::Enum)
+        Reporter->reportDeclaration(QualifiedName, "Enum");
+      else if (Kind == Decl::Kind::Typedef ||
+               Kind == Decl::Kind::TypeAlias ||
+               Kind == Decl::Kind::TypeAliasTemplate)
+        Reporter->reportDeclaration(QualifiedName, "TypeAlias");
     }
     return;
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to