[PATCH] D56917: [clang] add tests to ExprMutAnalyzer that reproduced a crash in ASTMatchers

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 21 05:22:25 PST 2019


JonasToth updated this revision to Diff 182780.
JonasToth added a comment.

- use only the small reproducer


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56917/new/

https://reviews.llvm.org/D56917

Files:
  unittests/Analysis/ExprMutationAnalyzerTest.cpp


Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===================================================================
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1109,4 +1109,23 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()"));
 }
 
+TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) {
+  const std::string Reproducer =
+      "namespace std {"
+      "template <class T> T forward(T & A) { return static_cast<T&&>(A); }"
+      "template <class T> struct __bind {"
+      "  T f;"
+      "  template <class V> __bind(T v, V &&) : f(forward(v)) {}"
+      "};"
+      "}"
+      "void f() {"
+      "  int x = 42;"
+      "  auto Lambda = [] {};"
+      "  std::__bind<decltype(Lambda)>(Lambda, x);"
+      "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+      match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
 } // namespace clang


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56917.182780.patch
Type: text/x-patch
Size: 1055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190121/23449054/attachment.bin>


More information about the cfe-commits mailing list