Skip to content

Commit 8586772

Browse files
committedJan 16, 2017
[clang-move] Dump enum and type alias declarations.
Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28293 llvm-svn: 292098
1 parent f4770ea commit 8586772

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed
 

‎clang-tools-extra/clang-move/ClangMove.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,12 @@ void ClangMoveTool::onEndOfTranslationUnit() {
841841
else if (Kind == Decl::Kind::ClassTemplate ||
842842
Kind == Decl::Kind::CXXRecord)
843843
Reporter->reportDeclaration(QualifiedName, "Class");
844+
else if (Kind == Decl::Kind::Enum)
845+
Reporter->reportDeclaration(QualifiedName, "Enum");
846+
else if (Kind == Decl::Kind::Typedef ||
847+
Kind == Decl::Kind::TypeAlias ||
848+
Kind == Decl::Kind::TypeAliasTemplate)
849+
Reporter->reportDeclaration(QualifiedName, "TypeAlias");
844850
}
845851
return;
846852
}

‎clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp

+11-13
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,10 @@ TEST(ClangMove, DumpDecls) {
535535
"namespace b {\n"
536536
"class Move1 { public : void f(); };\n"
537537
"void f() {}\n"
538+
"enum E1 { Green };\n"
539+
"enum class E2 { Red };\n"
540+
"typedef int Int2;\n"
541+
"using Int = int;\n"
538542
"} // namespace b\n"
539543
"} // namespace a\n";
540544
const char TestCode[] = "#include \"foo.h\"\n";
@@ -545,22 +549,16 @@ TEST(ClangMove, DumpDecls) {
545549
Spec.NewHeader = "new_foo.h";
546550
Spec.NewCC = "new_foo.cc";
547551
DeclarationReporter Reporter;
548-
std::vector<DeclarationReporter::DeclarationPair> ExpectedDeclarations = {
552+
std::set<DeclarationReporter::DeclarationPair> ExpectedDeclarations = {
549553
{"A", "Class"}, {"B", "Class"}, {"a::Move1", "Class"},
550554
{"a::f1", "Function"}, {"a::f2", "Function"}, {"a::b::Move1", "Class"},
551-
{"a::b::f", "Function"}};
555+
{"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
556+
{"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
552557
runClangMoveOnCode(Spec, TestHeader, TestCode, &Reporter);
553-
const auto& Results = Reporter.getDeclarationList();
554-
auto ActualDeclIter = Results.begin();
555-
auto ExpectedDeclIter = ExpectedDeclarations.begin();
556-
while (ActualDeclIter != Results.end() &&
557-
ExpectedDeclIter != ExpectedDeclarations.end()) {
558-
EXPECT_EQ(*ActualDeclIter, *ExpectedDeclIter);
559-
++ActualDeclIter;
560-
++ExpectedDeclIter;
561-
}
562-
ASSERT_TRUE(ActualDeclIter == Results.end());
563-
ASSERT_TRUE(ExpectedDeclIter == ExpectedDeclarations.end());
558+
std::set<DeclarationReporter::DeclarationPair> Results;
559+
for (const auto& DelPair : Reporter.getDeclarationList())
560+
Results.insert(DelPair);
561+
EXPECT_EQ(ExpectedDeclarations, Results);
564562
}
565563

566564
} // namespace

0 commit comments

Comments
 (0)
Please sign in to comment.