[PATCH] D27181: [ASTImporter] Support for importing UsingDecl and UsingShadowDecl

Aleksei Sidorin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 3 08:04:47 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL319632: [ASTImporter] Add unit tests for UsingDecl and UsingShadowDecl (authored by a.sidorin).

Changed prior to commit:
  https://reviews.llvm.org/D27181?vs=79488&id=125290#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27181

Files:
  cfe/trunk/unittests/AST/ASTImporterTest.cpp


Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===================================================================
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -583,5 +583,46 @@
                      callExpr(has(cxxPseudoDestructorExpr()))))))));
 }
 
+TEST(ImportDecl, ImportUsingDecl) {
+  MatchVerifier<Decl> Verifier;
+  EXPECT_TRUE(
+        testImport(
+          "namespace foo { int bar; }"
+          "int declToImport(){ using foo::bar; }",
+          Lang_CXX, "", Lang_CXX, Verifier,
+          functionDecl(
+            has(
+              compoundStmt(
+                has(
+                  declStmt(
+                    has(
+                      usingDecl()))))))));
+}
+
+/// \brief Matches shadow declarations introduced into a scope by a
+///        (resolved) using declaration.
+///
+/// Given
+/// \code
+///   namespace n { int f; }
+///   namespace declToImport { using n::f; }
+/// \endcode
+/// usingShadowDecl()
+///   matches \code f \endcode
+const internal::VariadicDynCastAllOfMatcher<Decl,
+                                            UsingShadowDecl> usingShadowDecl;
+
+TEST(ImportDecl, ImportUsingShadowDecl) {
+  MatchVerifier<Decl> Verifier;
+  EXPECT_TRUE(
+        testImport(
+          "namespace foo { int bar; }"
+          "namespace declToImport { using foo::bar; }",
+          Lang_CXX, "", Lang_CXX, Verifier,
+          namespaceDecl(
+            has(
+              usingShadowDecl()))));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27181.125290.patch
Type: text/x-patch
Size: 1569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171203/6a54dfe0/attachment.bin>


More information about the cfe-commits mailing list