This revision was automatically updated to reflect the committed changes.
Closed by commit rL321285: [ASTImporterTest] Add mandatory testing with 
'-fdelayed-template-parsing' (authored by a.sidorin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41444?vs=127748&id=127903#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41444

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
@@ -22,38 +22,50 @@
 namespace clang {
 namespace ast_matchers {
 
-typedef std::vector<std::string> StringVector;
+typedef std::vector<std::string> ArgVector;
+typedef std::vector<ArgVector> RunOptions;
 
-void getLangArgs(Language Lang, StringVector &Args) {
+static bool isCXX(Language Lang) {
+  return Lang == Lang_CXX || Lang == Lang_CXX11;
+}
+
+static RunOptions getRunOptionsForLanguage(Language Lang) {
+  ArgVector BasicArgs;
+  // Test with basic arguments.
   switch (Lang) {
   case Lang_C:
-    Args.insert(Args.end(), { "-x", "c", "-std=c99" });
+    BasicArgs = {"-x", "c", "-std=c99"};
     break;
   case Lang_C89:
-    Args.insert(Args.end(), { "-x", "c", "-std=c89" });
+    BasicArgs = {"-x", "c", "-std=c89"};
     break;
   case Lang_CXX:
-    Args.push_back("-std=c++98");
+    BasicArgs = {"-std=c++98"};
     break;
   case Lang_CXX11:
-    Args.push_back("-std=c++11");
+    BasicArgs = {"-std=c++11"};
     break;
   case Lang_OpenCL:
   case Lang_OBJCXX:
-    break;
+    llvm_unreachable("Not implemented yet!");
   }
+
+  // For C++, test with "-fdelayed-template-parsing" enabled to handle MSVC
+  // default behaviour.
+  if (isCXX(Lang)) {
+    ArgVector ArgsForDelayedTemplateParse = BasicArgs;
+    ArgsForDelayedTemplateParse.emplace_back("-fdelayed-template-parsing");
+    return {BasicArgs, ArgsForDelayedTemplateParse};
+  }
+
+  return {BasicArgs};
 }
 
 template<typename NodeType, typename MatcherType>
 testing::AssertionResult
-testImport(const std::string &FromCode, Language FromLang,
-           const std::string &ToCode, Language ToLang,
-           MatchVerifier<NodeType> &Verifier,
-           const MatcherType &AMatcher) {
-  StringVector FromArgs, ToArgs;
-  getLangArgs(FromLang, FromArgs);
-  getLangArgs(ToLang, ToArgs);
-
+testImport(const std::string &FromCode, const ArgVector &FromArgs,
+           const std::string &ToCode, const ArgVector &ToArgs,
+           MatchVerifier<NodeType> &Verifier, const MatcherType &AMatcher) {
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
@@ -92,7 +104,7 @@
     return testing::AssertionFailure() << "Import failed, nullptr returned!";
 
   // This should dump source locations and assert if some source locations
-  // were not imported
+  // were not imported.
   SmallString<1024> ImportChecker;
   llvm::raw_svector_ostream ToNothing(ImportChecker);
   ToCtx.getTranslationUnitDecl()->print(ToNothing);
@@ -104,148 +116,154 @@
   return Verifier.match(Imported, AMatcher);
 }
 
+template<typename NodeType, typename MatcherType>
+void testImport(const std::string &FromCode, Language FromLang,
+                const std::string &ToCode, Language ToLang,
+                MatchVerifier<NodeType> &Verifier,
+                const MatcherType &AMatcher) {
+  auto RunOptsFrom = getRunOptionsForLanguage(FromLang);
+  auto RunOptsTo = getRunOptionsForLanguage(ToLang);
+  for (const auto &FromArgs : RunOptsFrom)
+    for (const auto &ToArgs : RunOptsTo)
+      EXPECT_TRUE(testImport(FromCode, FromArgs, ToCode, ToArgs,
+                             Verifier, AMatcher));
+}
+
+
 TEST(ImportExpr, ImportStringLiteral) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { \"foo\"; }",
-                         Lang_CXX, "", Lang_CXX, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 stringLiteral(
-                                   hasType(
-                                     asString("const char [4]")))))))));
-  EXPECT_TRUE(testImport("void declToImport() { L\"foo\"; }",
-                         Lang_CXX, "", Lang_CXX, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 stringLiteral(
-                                   hasType(
-                                     asString("const wchar_t [4]")))))))));
-  EXPECT_TRUE(testImport("void declToImport() { \"foo\" \"bar\"; }",
-                         Lang_CXX, "", Lang_CXX, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 stringLiteral(
-                                   hasType(
-                                     asString("const char [7]")))))))));
+  testImport("void declToImport() { \"foo\"; }",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     stringLiteral(
+                       hasType(
+                         asString("const char [4]"))))))));
+  testImport("void declToImport() { L\"foo\"; }",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     stringLiteral(
+                       hasType(
+                        asString("const wchar_t [4]"))))))));
+  testImport("void declToImport() { \"foo\" \"bar\"; }",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     stringLiteral(
+                       hasType(
+                         asString("const char [7]"))))))));
 }
 
 TEST(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { __null; }",
-                         Lang_CXX, "", Lang_CXX, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 gnuNullExpr(
-                                   hasType(isInteger()))))))));
+  testImport("void declToImport() { __null; }",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     gnuNullExpr(
+                       hasType(isInteger())))))));
 }
 
 TEST(ImportExpr, ImportCXXNullPtrLiteralExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { nullptr; }",
-                         Lang_CXX11, "", Lang_CXX11, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 cxxNullPtrLiteralExpr()))))));
+  testImport("void declToImport() { nullptr; }",
+             Lang_CXX11, "", Lang_CXX11, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     cxxNullPtrLiteralExpr())))));
 }
 
 
 TEST(ImportExpr, ImportFloatinglLiteralExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { 1.0; }",
-                         Lang_CXX, "", Lang_CXX, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 floatLiteral(
-                                   equals(1.0),
-                                   hasType(asString("double")))))))));
-  EXPECT_TRUE(testImport("void declToImport() { 1.0e-5f; }",
-                         Lang_CXX, "", Lang_CXX, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 floatLiteral(
-                                   equals(1.0e-5f),
-                                   hasType(asString("float")))))))));
+  testImport("void declToImport() { 1.0; }",
+             Lang_C, "", Lang_C, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     floatLiteral(
+                       equals(1.0),
+                       hasType(asString("double"))))))));
+  testImport("void declToImport() { 1.0e-5f; }",
+              Lang_C, "", Lang_C, Verifier,
+              functionDecl(
+                hasBody(
+                  compoundStmt(
+                    has(
+                      floatLiteral(
+                        equals(1.0e-5f),
+                        hasType(asString("float"))))))));
 }
 
 TEST(ImportExpr, ImportCompoundLiteralExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(
-        testImport(
-          "void declToImport() {"
-          "  struct s { int x; long y; unsigned z; }; "
-          "  (struct s){ 42, 0L, 1U }; }",
-          Lang_CXX, "", Lang_CXX, Verifier,
-          functionDecl(
-            hasBody(
-              compoundStmt(
-                has(
-                  compoundLiteralExpr(
-                    hasType(asString("struct s")),
-                    has(initListExpr(
-                      hasType(asString("struct s")),
-                      has(integerLiteral(
-                            equals(42), hasType(asString("int")))),
-                      has(integerLiteral(
-                            equals(0), hasType(asString("long")))),
-                      has(integerLiteral(
-                            equals(1),
-                            hasType(asString("unsigned int"))))
-                      )))))))));
+  testImport("void declToImport() {"
+             "  struct s { int x; long y; unsigned z; }; "
+             "  (struct s){ 42, 0L, 1U }; }",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     compoundLiteralExpr(
+                       hasType(asString("struct s")),
+                       has(initListExpr(
+                         hasType(asString("struct s")),
+                         has(integerLiteral(
+                               equals(42), hasType(asString("int")))),
+                         has(integerLiteral(
+                               equals(0), hasType(asString("long")))),
+                         has(integerLiteral(
+                               equals(1),
+                               hasType(asString("unsigned int"))))
+                         ))))))));
 }
 
 TEST(ImportExpr, ImportCXXThisExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(
-        testImport("class declToImport { void f() { this; } };",
-                   Lang_CXX, "", Lang_CXX, Verifier,
-                   cxxRecordDecl(
-                     hasMethod(
-                       hasBody(
-                         compoundStmt(
-                           has(
-                             cxxThisExpr(
-                               hasType(
-                                 asString("class declToImport *"))))))))));
+  testImport("class declToImport { void f() { this; } };",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             cxxRecordDecl(
+               hasMethod(
+                 hasBody(
+                   compoundStmt(
+                     has(
+                       cxxThisExpr(
+                         hasType(
+                           asString("class declToImport *")))))))));
 }
 
 TEST(ImportExpr, ImportAtomicExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport(
-      "void declToImport() { int *ptr; __atomic_load_n(ptr, 1); }", Lang_CXX,
-      "", Lang_CXX, Verifier,
-      functionDecl(hasBody(compoundStmt(has(atomicExpr(
-          has(ignoringParenImpCasts(
-              declRefExpr(hasDeclaration(varDecl(hasName("ptr"))),
-                          hasType(asString("int *"))))),
-          has(integerLiteral(equals(1), hasType(asString("int")))))))))));
+  testImport("void declToImport() { int *ptr; __atomic_load_n(ptr, 1); }",
+             Lang_C, "", Lang_C, Verifier,
+             functionDecl(hasBody(compoundStmt(has(atomicExpr(
+                 has(ignoringParenImpCasts(
+                     declRefExpr(hasDeclaration(varDecl(hasName("ptr"))),
+                                 hasType(asString("int *"))))),
+                 has(integerLiteral(equals(1), hasType(asString("int"))))))))));
 }
 
 TEST(ImportExpr, ImportLabelDeclAndAddrLabelExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(
-        testImport(
-          "void declToImport() { loop: goto loop; &&loop; }",
-          Lang_CXX, "", Lang_CXX, Verifier,
-          functionDecl(
-            hasBody(
-              compoundStmt(
-                has(labelStmt(hasDeclaration(labelDecl(hasName("loop"))))),
-                has(addrLabelExpr(hasDeclaration(labelDecl(hasName("loop")))))
-                )))));
+  testImport(
+      "void declToImport() { loop: goto loop; &&loop; }", Lang_C, "", Lang_C,
+      Verifier,
+      functionDecl(hasBody(compoundStmt(
+          has(labelStmt(hasDeclaration(labelDecl(hasName("loop"))))),
+          has(addrLabelExpr(hasDeclaration(labelDecl(hasName("loop")))))))));
 }
 
 AST_MATCHER_P(TemplateDecl, hasTemplateDecl,
@@ -256,7 +274,7 @@
 
 TEST(ImportExpr, ImportParenListExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport(
+  testImport(
       "template<typename T> class dummy { void f() { dummy X(*this); } };"
       "typedef dummy<int> declToImport;"
       "template class dummy<int>;",
@@ -268,261 +286,252 @@
                   hasBody(compoundStmt(has(declStmt(hasSingleDecl(
                       varDecl(hasInitializer(parenListExpr(has(unaryOperator(
                           hasOperatorName("*"),
-                          hasUnaryOperand(cxxThisExpr()))))))))))))))))))))))));
+                          hasUnaryOperand(cxxThisExpr())))))))))))))))))))))));
 }
 
 TEST(ImportExpr, ImportSwitch) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(
-      testImport("void declToImport() { int b; switch (b) { case 1: break; } }",
-                 Lang_CXX, "", Lang_CXX, Verifier,
-                 functionDecl(hasBody(compoundStmt(
-                     has(switchStmt(has(compoundStmt(has(caseStmt()))))))))));
+  testImport("void declToImport() { int b; switch (b) { case 1: break; } }",
+             Lang_C, "", Lang_C, Verifier,
+             functionDecl(hasBody(compoundStmt(
+                 has(switchStmt(has(compoundStmt(has(caseStmt())))))))));
 }
 
 TEST(ImportExpr, ImportStmtExpr) {
   MatchVerifier<Decl> Verifier;
   // NOTE: has() ignores implicit casts, using hasDescendant() to match it
-  EXPECT_TRUE(
-        testImport(
-          "void declToImport() { int b; int a = b ?: 1; int C = ({int X=4; X;}); }",
-          Lang_CXX, "", Lang_CXX, Verifier,
-          functionDecl(
-            hasBody(
-              compoundStmt(
-                has(
-                  declStmt(
-                    hasSingleDecl(
-                      varDecl(
-                        hasName("C"),
-                        hasType(asString("int")),
-                        hasInitializer(
-                          stmtExpr(
-                            hasAnySubstatement(
-                              declStmt(
-                                hasSingleDecl(
-                                  varDecl(
-                                    hasName("X"),
-                                    hasType(asString("int")),
-                                    hasInitializer(
-                                      integerLiteral(equals(4))))))),
-                            hasDescendant(
-                              implicitCastExpr()
-                              ))))))))))));
+  testImport(
+    "void declToImport() { int b; int a = b ?: 1; int C = ({int X=4; X;}); }",
+    Lang_C, "", Lang_C, Verifier,
+    functionDecl(
+      hasBody(
+        compoundStmt(
+          has(
+            declStmt(
+              hasSingleDecl(
+                varDecl(
+                  hasName("C"),
+                  hasType(asString("int")),
+                  hasInitializer(
+                    stmtExpr(
+                      hasAnySubstatement(
+                        declStmt(
+                          hasSingleDecl(
+                            varDecl(
+                              hasName("X"),
+                              hasType(asString("int")),
+                              hasInitializer(
+                                integerLiteral(equals(4))))))),
+                      hasDescendant(
+                        implicitCastExpr()
+                        )))))))))));
 }
 
 TEST(ImportExpr, ImportConditionalOperator) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(
-        testImport(
-          "void declToImport() { true ? 1 : -5; }",
-          Lang_CXX, "", Lang_CXX, Verifier,
-          functionDecl(
-            hasBody(
-              compoundStmt(
-                has(
-                  conditionalOperator(
-                    hasCondition(cxxBoolLiteral(equals(true))),
-                    hasTrueExpression(integerLiteral(equals(1))),
-                    hasFalseExpression(
-                      unaryOperator(hasUnaryOperand(integerLiteral(equals(5))))
-                      ))))))));
+  testImport(
+    "void declToImport() { true ? 1 : -5; }",
+    Lang_CXX, "", Lang_CXX, Verifier,
+    functionDecl(
+      hasBody(
+        compoundStmt(
+          has(
+            conditionalOperator(
+              hasCondition(cxxBoolLiteral(equals(true))),
+              hasTrueExpression(integerLiteral(equals(1))),
+              hasFalseExpression(
+                unaryOperator(hasUnaryOperand(integerLiteral(equals(5))))
+                )))))));
 }
 
 TEST(ImportExpr, ImportBinaryConditionalOperator) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(
-        testImport(
-          "void declToImport() { 1 ?: -5; }",
-          Lang_CXX, "", Lang_CXX, Verifier,
-          functionDecl(
-            hasBody(
-              compoundStmt(
-                has(
-                  binaryConditionalOperator(
-                    hasCondition(
-                      implicitCastExpr(
-                        hasSourceExpression(
-                          opaqueValueExpr(
-                            hasSourceExpression(integerLiteral(equals(1))))),
-                        hasType(booleanType()))),
-                    hasTrueExpression(
-                      opaqueValueExpr(hasSourceExpression(
-                                        integerLiteral(equals(1))))),
-                    hasFalseExpression(
-                      unaryOperator(hasOperatorName("-"),
-                                    hasUnaryOperand(integerLiteral(equals(5)))))
-                      )))))));
+  testImport(
+    "void declToImport() { 1 ?: -5; }", Lang_CXX, "", Lang_CXX, Verifier,
+    functionDecl(
+      hasBody(
+        compoundStmt(
+          has(
+            binaryConditionalOperator(
+              hasCondition(
+                implicitCastExpr(
+                  hasSourceExpression(
+                    opaqueValueExpr(
+                      hasSourceExpression(integerLiteral(equals(1))))),
+                  hasType(booleanType()))),
+              hasTrueExpression(
+                opaqueValueExpr(hasSourceExpression(
+                                  integerLiteral(equals(1))))),
+              hasFalseExpression(
+                unaryOperator(hasOperatorName("-"),
+                              hasUnaryOperand(integerLiteral(equals(5)))))
+                ))))));
 }
 
 TEST(ImportExpr, ImportDesignatedInitExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("void declToImport() {"
-                         "  struct point { double x; double y; };"
-                         "  struct point ptarray[10] = "
-                                "{ [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; }",
-                         Lang_C, "", Lang_C, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 declStmt(
-                                   hasSingleDecl(
-                                     varDecl(
-                                       hasInitializer(
-                                         initListExpr(
-                                           hasSyntacticForm(
-                                             initListExpr(
-                                               has(
-                                                 designatedInitExpr(
-                                                   designatorCountIs(2),
-                                                   has(floatLiteral(
-                                                         equals(1.0))),
-                                                   has(integerLiteral(
-                                                         equals(2))))),
-                                               has(
-                                                 designatedInitExpr(
-                                                   designatorCountIs(2),
-                                                   has(floatLiteral(
-                                                         equals(2.0))),
-                                                   has(integerLiteral(
-                                                         equals(2))))),
-                                               has(
-                                                 designatedInitExpr(
-                                                   designatorCountIs(2),
-                                                   has(floatLiteral(
-                                                         equals(1.0))),
-                                                   has(integerLiteral(
-                                                         equals(0)))))
-                                               )))))))))))));
+  testImport("void declToImport() {"
+             "  struct point { double x; double y; };"
+             "  struct point ptarray[10] = "
+                    "{ [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; }",
+             Lang_C, "", Lang_C, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     declStmt(
+                       hasSingleDecl(
+                         varDecl(
+                           hasInitializer(
+                             initListExpr(
+                               hasSyntacticForm(
+                                 initListExpr(
+                                   has(
+                                     designatedInitExpr(
+                                       designatorCountIs(2),
+                                       has(floatLiteral(
+                                             equals(1.0))),
+                                       has(integerLiteral(
+                                             equals(2))))),
+                                   has(
+                                     designatedInitExpr(
+                                       designatorCountIs(2),
+                                       has(floatLiteral(
+                                             equals(2.0))),
+                                       has(integerLiteral(
+                                             equals(2))))),
+                                   has(
+                                     designatedInitExpr(
+                                       designatorCountIs(2),
+                                       has(floatLiteral(
+                                             equals(1.0))),
+                                       has(integerLiteral(
+                                             equals(0)))))
+                                   ))))))))))));
 }
 
 
 TEST(ImportExpr, ImportPredefinedExpr) {
   MatchVerifier<Decl> Verifier;
   // __func__ expands as StringLiteral("declToImport")
-  EXPECT_TRUE(testImport("void declToImport() { __func__; }",
-                         Lang_CXX, "", Lang_CXX, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 predefinedExpr(
-                                   hasType(
-                                     asString("const char [13]")),
-                                   has(
-                                     stringLiteral(
-                                       hasType(
-                                         asString("const char [13]")))))))))));
+  testImport("void declToImport() { __func__; }",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     predefinedExpr(
+                       hasType(
+                         asString("const char [13]")),
+                       has(
+                         stringLiteral(
+                           hasType(
+                             asString("const char [13]"))))))))));
 }
 
 TEST(ImportExpr, ImportInitListExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(
-        testImport(
-          "void declToImport() {"
-          "  struct point { double x; double y; };"
-          "  point ptarray[10] = { [2].y = 1.0, [2].x = 2.0,"
-          "                        [0].x = 1.0 }; }",
-          Lang_CXX, "", Lang_CXX, Verifier,
-          functionDecl(
-            hasBody(
-              compoundStmt(
-                has(
-                  declStmt(
-                    hasSingleDecl(
-                      varDecl(
-                        hasInitializer(
-                          initListExpr(
-                            has(
-                              cxxConstructExpr(
-                                requiresZeroInitialization())),
-                            has(
-                              initListExpr(
-                                hasType(asString("struct point")),
-                                has(floatLiteral(equals(1.0))),
-                                has(implicitValueInitExpr(
-                                      hasType(asString("double")))))),
-                            has(
-                              initListExpr(
-                                hasType(asString("struct point")),
-                                has(floatLiteral(equals(2.0))),
-                                has(floatLiteral(equals(1.0)))))
-                              )))))))))));
+  testImport(
+    "void declToImport() {"
+    "  struct point { double x; double y; };"
+    "  point ptarray[10] = { [2].y = 1.0, [2].x = 2.0,"
+    "                        [0].x = 1.0 }; }",
+    Lang_CXX, "", Lang_CXX, Verifier,
+    functionDecl(
+      hasBody(
+        compoundStmt(
+          has(
+            declStmt(
+              hasSingleDecl(
+                varDecl(
+                  hasInitializer(
+                    initListExpr(
+                      has(
+                        cxxConstructExpr(
+                          requiresZeroInitialization())),
+                      has(
+                        initListExpr(
+                          hasType(asString("struct point")),
+                          has(floatLiteral(equals(1.0))),
+                          has(implicitValueInitExpr(
+                                hasType(asString("double")))))),
+                      has(
+                        initListExpr(
+                          hasType(asString("struct point")),
+                          has(floatLiteral(equals(2.0))),
+                          has(floatLiteral(equals(1.0)))))
+                        ))))))))));
 }
 
 
 const internal::VariadicDynCastAllOfMatcher<Expr, VAArgExpr> vaArgExpr;
 
 TEST(ImportExpr, ImportVAArgExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(
-        testImport(
-          "void declToImport(__builtin_va_list list, ...) {"
-          "  (void)__builtin_va_arg(list, int); }",
-          Lang_CXX, "", Lang_CXX, Verifier,
-          functionDecl(
-            hasBody(
-              compoundStmt(
-                has(
-                  cStyleCastExpr(
-                    hasSourceExpression(
-                      vaArgExpr()))))))));
+  testImport("void declToImport(__builtin_va_list list, ...) {"
+             "  (void)__builtin_va_arg(list, int); }",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     cStyleCastExpr(
+                       hasSourceExpression(
+                         vaArgExpr())))))));
 }
 
 
 TEST(ImportType, ImportAtomicType) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { typedef _Atomic(int) a_int; }",
-                         Lang_CXX11, "", Lang_CXX11, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 declStmt(
-                                   has(
-                                     typedefDecl(
-                                       has(atomicType()))))))))));
+  testImport("void declToImport() { typedef _Atomic(int) a_int; }",
+             Lang_CXX11, "", Lang_CXX11, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     declStmt(
+                       has(
+                         typedefDecl(
+                           has(atomicType())))))))));
 }
 
 
 TEST(ImportType, ImportTypeAliasTemplate) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("template <int K>"
-                         "struct dummy { static const int i = K; };"
-                         "template <int K> using dummy2 = dummy<K>;"
-                         "int declToImport() { return dummy2<3>::i; }",
-                         Lang_CXX11, "", Lang_CXX11, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 returnStmt(
-                                   has(
-                                     implicitCastExpr(
-                                       has(
-                                         declRefExpr()))))))))));
+  testImport("template <int K>"
+             "struct dummy { static const int i = K; };"
+             "template <int K> using dummy2 = dummy<K>;"
+             "int declToImport() { return dummy2<3>::i; }",
+             Lang_CXX11, "", Lang_CXX11, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     returnStmt(
+                       has(
+                         implicitCastExpr(
+                           has(
+                             declRefExpr())))))))));
 }
 
-
 TEST(ImportType, ImportPackExpansion) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("template <typename... Args>"
-                         "struct dummy {"
-                         "  dummy(Args... args) {}"
-                         "  static const int i = 4;"
-                         "};"
-                         "int declToImport() { return dummy<int>::i; }",
-                         Lang_CXX11, "", Lang_CXX11, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 returnStmt(
-                                   has(
-                                     implicitCastExpr(
-                                       has(
-                                         declRefExpr()))))))))));
+  testImport("template <typename... Args>"
+             "struct dummy {"
+             "  dummy(Args... args) {}"
+             "  static const int i = 4;"
+             "};"
+             "int declToImport() { return dummy<int>::i; }",
+             Lang_CXX11, "", Lang_CXX11, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     returnStmt(
+                       has(
+                         implicitCastExpr(
+                           has(
+                             declRefExpr())))))))));
 }
 
 /// \brief Matches __builtin_types_compatible_p:
@@ -536,67 +545,64 @@
 
 TEST(ImportExpr, ImportTypeTraitExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { "
-                         "  __builtin_types_compatible_p(int, int);"
-                         "}",
-                         Lang_C, "", Lang_C, Verifier,
-                         functionDecl(
-                           hasBody(
-                             compoundStmt(
-                               has(
-                                 typeTraitExpr(hasType(asString("int")))))))));
+  testImport("void declToImport() { "
+             "  __builtin_types_compatible_p(int, int);"
+             "}",
+             Lang_C, "", Lang_C, Verifier,
+             functionDecl(
+               hasBody(
+                 compoundStmt(
+                   has(
+                     typeTraitExpr(hasType(asString("int"))))))));
 }
 
 TEST(ImportExpr, ImportTypeTraitExprValDep) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(testImport("template<typename T> struct declToImport {"
-                         "  void m() { __is_pod(T); }"
-                         "};"
-                         "void f() { declToImport<int>().m(); }",
-                         Lang_CXX11, "", Lang_CXX11, Verifier,
-                         classTemplateDecl(
+  testImport("template<typename T> struct declToImport {"
+             "  void m() { __is_pod(T); }"
+             "};"
+             "void f() { declToImport<int>().m(); }",
+             Lang_CXX11, "", Lang_CXX11, Verifier,
+             classTemplateDecl(
+               has(
+                 cxxRecordDecl(
+                   has(
+                     functionDecl(
+                       hasBody(
+                         compoundStmt(
                            has(
-                             cxxRecordDecl(
-                               has(
-                                 functionDecl(
-                                   hasBody(
-                                     compoundStmt(
-                                       has(
-                                         typeTraitExpr(
-                                           hasType(booleanType())
-                                           )))))))))));
+                             typeTraitExpr(
+                               hasType(booleanType())
+                               ))))))))));
 }
 
 const internal::VariadicDynCastAllOfMatcher<Expr, CXXPseudoDestructorExpr>
     cxxPseudoDestructorExpr;
 
 TEST(ImportExpr, ImportCXXPseudoDestructorExpr) {
   MatchVerifier<Decl> Verifier;
-  EXPECT_TRUE(
-      testImport("typedef int T;"
-                 "void declToImport(int *p) {"
-                 "  T t;"
-                 "  p->T::~T();"
-                 "}",
-                 Lang_CXX, "", Lang_CXX, Verifier,
-                 functionDecl(has(compoundStmt(has(
-                     callExpr(has(cxxPseudoDestructorExpr()))))))));
+  testImport("typedef int T;"
+             "void declToImport(int *p) {"
+             "  T t;"
+             "  p->T::~T();"
+             "}",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             functionDecl(has(compoundStmt(has(
+                 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()))))))));
+  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
@@ -614,14 +620,10 @@
 
 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()))));
+  testImport("namespace foo { int bar; }"
+             "namespace declToImport { using foo::bar; }",
+             Lang_CXX, "", Lang_CXX, Verifier,
+             namespaceDecl(has(usingShadowDecl())));
 }
 
 } // end namespace ast_matchers
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to