Re: r342525 - [NFC] Fix uncompilable test cases of ExprMutationAnalyzer.

2018-09-19 Thread David Green via cfe-commits
Thanks!


That sorted us right out.


Dave



From: Shuai Wang
Sent: 19 September 2018 21:32
To: David Green
Cc: cfe-commits@lists.llvm.org
Subject: Re: r342525 - [NFC] Fix uncompilable test cases of 
ExprMutationAnalyzer.



On Wed, Sep 19, 2018 at 3:10 AM David Green 
mailto:david.gr...@arm.com>> wrote:

Hello!


You have some code in here that looks like

 A operator+(A&&, int) {}


which is a non-void function without a return statement. Any reason to use "{}" 
and not ";"? You seem to have deliberately changed them, but that causes us 
some problems downstream. Mind if we change them to A operator+(A&&, int);? or 
will that cause you problems in other places?

You're right, I don't need to define it, fixed in 
https://reviews.llvm.org/rC342586
Thanks for pointing it out!


Cheers

Dave

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


r342525 - [NFC] Fix uncompilable test cases of ExprMutationAnalyzer.

2018-09-18 Thread Shuai Wang via cfe-commits
Author: shuaiwang
Date: Tue Sep 18 20:50:03 2018
New Revision: 342525

URL: http://llvm.org/viewvc/llvm-project?rev=342525=rev
Log:
[NFC] Fix uncompilable test cases of ExprMutationAnalyzer.

And ensure future test cases doesn't have compile errors.

Modified:
cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Modified: cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp?rev=342525=342524=342525=diff
==
--- cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp (original)
+++ cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp Tue Sep 18 
20:50:03 2018
@@ -29,6 +29,18 @@ namespace {
 using ExprMatcher = internal::Matcher;
 using StmtMatcher = internal::Matcher;
 
+std::unique_ptr
+buildASTFromCodeWithArgs(const Twine ,
+ const std::vector ) {
+  auto AST = tooling::buildASTFromCodeWithArgs(Code, Args);
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+  return AST;
+}
+
+std::unique_ptr buildASTFromCode(const Twine ) {
+  return buildASTFromCodeWithArgs(Code, {});
+}
+
 ExprMatcher declRefTo(StringRef Name) {
   return declRefExpr(to(namedDecl(hasName(Name;
 }
@@ -83,12 +95,12 @@ const std::string StdForward =
 "template T&& "
 "forward(typename remove_reference::type& t) noexcept { return t; }"
 "template T&& "
-"forward(typename remove_reference::type&&) noexcept { return t; } }";
+"forward(typename remove_reference::type&& t) noexcept { return t; } }";
 
 } // namespace
 
 TEST(ExprMutationAnalyzerTest, Trivial) {
-  const auto AST = tooling::buildASTFromCode("void f() { int x; x; }");
+  const auto AST = buildASTFromCode("void f() { int x; x; }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_FALSE(isMutated(Results, AST.get()));
@@ -98,8 +110,7 @@ class AssignmentTest : public ::testing:
 
 TEST_P(AssignmentTest, AssignmentModifies) {
   const std::string ModExpr = "x " + GetParam() + " 10";
-  const auto AST =
-  tooling::buildASTFromCode("void f() { int x; " + ModExpr + "; }");
+  const auto AST = buildASTFromCode("void f() { int x; " + ModExpr + "; }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
@@ -113,8 +124,7 @@ class IncDecTest : public ::testing::Tes
 
 TEST_P(IncDecTest, IncDecModifies) {
   const std::string ModExpr = GetParam();
-  const auto AST =
-  tooling::buildASTFromCode("void f() { int x; " + ModExpr + "; }");
+  const auto AST = buildASTFromCode("void f() { int x; " + ModExpr + "; }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
@@ -124,7 +134,7 @@ INSTANTIATE_TEST_CASE_P(AllIncDecOperato
 Values("++x", "--x", "x++", "x--"), );
 
 TEST(ExprMutationAnalyzerTest, NonConstMemberFunc) {
-  const auto AST = tooling::buildASTFromCode(
+  const auto AST = buildASTFromCode(
   "void f() { struct Foo { void mf(); }; Foo x; x.mf(); }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
@@ -132,7 +142,7 @@ TEST(ExprMutationAnalyzerTest, NonConstM
 }
 
 TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) {
-  auto AST = tooling::buildASTFromCodeWithArgs(
+  auto AST = buildASTFromCodeWithArgs(
   "struct X { template  void mf(); };"
   "template  void f() { X x; x.mf(); }",
   {"-fno-delayed-template-parsing"});
@@ -140,13 +150,12 @@ TEST(ExprMutationAnalyzerTest, AssumedNo
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
 
-  AST = tooling::buildASTFromCodeWithArgs(
-  "template  void f() { T x; x.mf(); }",
-  {"-fno-delayed-template-parsing"});
+  AST = buildASTFromCodeWithArgs("template  void f() { T x; x.mf(); 
}",
+ {"-fno-delayed-template-parsing"});
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
 
-  AST = tooling::buildASTFromCodeWithArgs(
+  AST = buildASTFromCodeWithArgs(
   "template  struct X;"
   "template  void f() { X x; x.mf(); }",
   {"-fno-delayed-template-parsing"});
@@ -155,7 +164,7 @@ TEST(ExprMutationAnalyzerTest, AssumedNo
 }
 
 TEST(ExprMutationAnalyzerTest, ConstMemberFunc) {
-  const auto AST = tooling::buildASTFromCode(
+  const auto AST = buildASTFromCode(
   "void f() { struct Foo { void mf() const; }; Foo x; x.mf(); }");
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
@@ -163,7 +172,7 @@