[PATCH] D51898: Revert "[clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer"

2018-09-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

i had an issue with msvc before, where `-fno-delayed-template-parsing` had to 
be added to the compilation, because MSVC did not have uninstantiated 
templates. Maybe this could be similar? But i am not sure how to resolve the 
issue here, as you probably can't pass in flags.
Maybe calling the template functions to instantiate them would be a possibility.


Repository:
  rL LLVM

https://reviews.llvm.org/D51898



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


[PATCH] D51898: Revert "[clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer"

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341886: Revert [clang-tidy] Handle unresolved 
expressions in ExprMutationAnalyzer (authored by shuaiwang, committed by 
).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51898

Files:
  clang-tools-extra/trunk/clang-tidy/utils/ExprMutationAnalyzer.cpp
  clang-tools-extra/trunk/unittests/clang-tidy/ExprMutationAnalyzerTest.cpp

Index: clang-tools-extra/trunk/unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
@@ -114,26 +114,6 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
 }
 
-TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) {
-  auto AST = tooling::buildASTFromCode(
-  "struct X { template  void mf(); };"
-  "template  void f() { X x; x.mf(); }");
-  auto Results =
-  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
-
-  AST =
-  tooling::buildASTFromCode("template  void f() { T x; x.mf(); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
-
-  AST = tooling::buildASTFromCode(
-  "template  struct X;"
-  "template  void f() { X x; x.mf(); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
-}
-
 TEST(ExprMutationAnalyzerTest, ConstMemberFunc) {
   const auto AST = tooling::buildASTFromCode(
   "void f() { struct Foo { void mf() const; }; Foo x; x.mf(); }");
@@ -312,51 +292,6 @@
   ElementsAre("std::forward(x)"));
 }
 
-TEST(ExprMutationAnalyzerTest, CallUnresolved) {
-  auto AST =
-  tooling::buildASTFromCode("template  void f() { T x; g(x); }");
-  auto Results =
-  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f() { char x[N]; g(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f(T t) { int x; g(t, x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(t, x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f(T t) { int x; t.mf(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("t.mf(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  struct S;"
-  "template  void f() { S s; int x; s.mf(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("s.mf(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "struct S { template  void mf(); };"
-  "template  void f(S s) { int x; s.mf(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("s.mf(x)"));
-
-  AST = tooling::buildASTFromCode("template "
-  "void g(F f) { int x; f(x); } ");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("f(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f() { int x; (void)T(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("T(x)"));
-}
-
 TEST(ExprMutationAnalyzerTest, ReturnAsValue) {
   const auto AST = tooling::buildASTFromCode("int f() { int x; return x; }");
   const auto Results =
@@ -412,21 +347,6 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x"));
 }
 
-TEST(ExprMutationAnalyzerTest, TemplateWithArrayToPointerDecay) {
-  const auto AST = tooling::buildASTFromCode(
-  "template  struct S { static constexpr int v = 8; };"
-  "template <> struct S { static constexpr int v = 4; };"
-  "void g(char*);"
-  "template  void f() { char x[S::v]; g(x); }"
-  "template <> void f() { char y[S::v]; g(y); }");
-  const auto ResultsX =
-  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(ResultsX, AST.get()), ElementsAre("g(x)"));
-  const auto ResultsY =
-  

[PATCH] D51898: Revert "[clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer"

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 164773.
shuaiwang added a comment.

rebase


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51898

Files:
  clang-tidy/utils/ExprMutationAnalyzer.cpp
  unittests/clang-tidy/ExprMutationAnalyzerTest.cpp

Index: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
===
--- unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
+++ unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
@@ -114,26 +114,6 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
 }
 
-TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) {
-  auto AST = tooling::buildASTFromCode(
-  "struct X { template  void mf(); };"
-  "template  void f() { X x; x.mf(); }");
-  auto Results =
-  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
-
-  AST =
-  tooling::buildASTFromCode("template  void f() { T x; x.mf(); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
-
-  AST = tooling::buildASTFromCode(
-  "template  struct X;"
-  "template  void f() { X x; x.mf(); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
-}
-
 TEST(ExprMutationAnalyzerTest, ConstMemberFunc) {
   const auto AST = tooling::buildASTFromCode(
   "void f() { struct Foo { void mf() const; }; Foo x; x.mf(); }");
@@ -312,51 +292,6 @@
   ElementsAre("std::forward(x)"));
 }
 
-TEST(ExprMutationAnalyzerTest, CallUnresolved) {
-  auto AST =
-  tooling::buildASTFromCode("template  void f() { T x; g(x); }");
-  auto Results =
-  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f() { char x[N]; g(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f(T t) { int x; g(t, x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(t, x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f(T t) { int x; t.mf(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("t.mf(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  struct S;"
-  "template  void f() { S s; int x; s.mf(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("s.mf(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "struct S { template  void mf(); };"
-  "template  void f(S s) { int x; s.mf(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("s.mf(x)"));
-
-  AST = tooling::buildASTFromCode("template "
-  "void g(F f) { int x; f(x); } ");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("f(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f() { int x; (void)T(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("T(x)"));
-}
-
 TEST(ExprMutationAnalyzerTest, ReturnAsValue) {
   const auto AST = tooling::buildASTFromCode("int f() { int x; return x; }");
   const auto Results =
@@ -412,21 +347,6 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x"));
 }
 
-TEST(ExprMutationAnalyzerTest, TemplateWithArrayToPointerDecay) {
-  const auto AST = tooling::buildASTFromCode(
-  "template  struct S { static constexpr int v = 8; };"
-  "template <> struct S { static constexpr int v = 4; };"
-  "void g(char*);"
-  "template  void f() { char x[S::v]; g(x); }"
-  "template <> void f() { char y[S::v]; g(y); }");
-  const auto ResultsX =
-  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(ResultsX, AST.get()), ElementsAre("g(x)"));
-  const auto ResultsY =
-  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(ResultsY, AST.get()), ElementsAre("y"));
-}
-
 TEST(ExprMutationAnalyzerTest, FollowRefModified) {
   const auto AST = tooling::buildASTFromCode(
   "void f() { int x; int& r0 = x; int& r1 = r0; int& r2 = r1; "
@@ -478,43 +398,21 @@
 }
 
 TEST(ExprMutationAnalyzerTest, NestedMemberModified) {
-  

[PATCH] D51898: Revert "[clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer"

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision.
Herald added subscribers: cfe-commits, Szelethus, a.sidorin, xazax.hun.
Herald added a reviewer: george.karpenkov.

Tests somehow break on windows (and only on windows)
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/13003
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/13747

I have yet figure out why so reverting to unbreak first.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51898

Files:
  clang-tidy/utils/ExprMutationAnalyzer.cpp
  unittests/clang-tidy/ExprMutationAnalyzerTest.cpp

Index: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
===
--- unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
+++ unittests/clang-tidy/ExprMutationAnalyzerTest.cpp
@@ -114,26 +114,6 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
 }
 
-TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) {
-  auto AST = tooling::buildASTFromCode(
-  "struct X { template  void mf(); };"
-  "template  void f() { X x; x.mf(); }");
-  auto Results =
-  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
-
-  AST =
-  tooling::buildASTFromCode("template  void f() { T x; x.mf(); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
-
-  AST = tooling::buildASTFromCode(
-  "template  struct X;"
-  "template  void f() { X x; x.mf(); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
-}
-
 TEST(ExprMutationAnalyzerTest, ConstMemberFunc) {
   const auto AST = tooling::buildASTFromCode(
   "void f() { struct Foo { void mf() const; }; Foo x; x.mf(); }");
@@ -312,51 +292,6 @@
   ElementsAre("std::forward(x)"));
 }
 
-TEST(ExprMutationAnalyzerTest, CallUnresolved) {
-  auto AST =
-  tooling::buildASTFromCode("template  void f() { T x; g(x); }");
-  auto Results =
-  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f() { char x[N]; g(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f(T t) { int x; g(t, x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(t, x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f(T t) { int x; t.mf(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("t.mf(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  struct S;"
-  "template  void f() { S s; int x; s.mf(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("s.mf(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "struct S { template  void mf(); };"
-  "template  void f(S s) { int x; s.mf(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("s.mf(x)"));
-
-  AST = tooling::buildASTFromCode("template "
-  "void g(F f) { int x; f(x); } ");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("f(x)"));
-
-  AST = tooling::buildASTFromCode(
-  "template  void f() { int x; (void)T(x); }");
-  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("T(x)"));
-}
-
 TEST(ExprMutationAnalyzerTest, ReturnAsValue) {
   const auto AST = tooling::buildASTFromCode("int f() { int x; return x; }");
   const auto Results =
@@ -412,21 +347,6 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x"));
 }
 
-TEST(ExprMutationAnalyzerTest, TemplateWithArrayToPointerDecay) {
-  const auto AST = tooling::buildASTFromCode(
-  "template  struct S { static constexpr int v = 8; };"
-  "template <> struct S { static constexpr int v = 4; };"
-  "void g(char*);"
-  "template  void f() { char x[S::v]; g(x); }"
-  "template <> void f() { char y[S::v]; g(y); }");
-  const auto ResultsX =
-  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
-  EXPECT_THAT(mutatedBy(ResultsX, AST.get()), ElementsAre("g(x)"));
-  const auto ResultsY =
-  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
-