diff options
author | Jonas Toth <jonas.toth@gmail.com> | 2019-01-21 13:26:18 +0000 |
---|---|---|
committer | Jonas Toth <jonas.toth@gmail.com> | 2019-01-21 13:26:18 +0000 |
commit | feea0777eb17077ee12b9da94ea43a92e49ff57c (patch) | |
tree | 966930951da3ef55219c65349d2fb76284c1f7ed | |
parent | e33706e16e8f884773da963313d1cd6fc44c4b62 (diff) |
[clang] add tests to ExprMutAnalyzer that reproduced a crash in ASTMatchers
Summary:
This patch adds two unit-tests that are the result of reducing a crashing TU
when running ExprMutAnalyzer over it. They are added only to ensure the regression
that has been fixed with https://reviews.llvm.org/D56444 don't creep back.
Reviewers: aaron.ballman, sammccall, rsmith, george.karpenkov
Reviewed By: sammccall
Subscribers: baloghadamsoftware, a.sidorin, Szelethus, donat.nagy, dkrupp, cfe-commits
Differential Revision: https://reviews.llvm.org/D56917
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351743 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | unittests/Analysis/ExprMutationAnalyzerTest.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/unittests/Analysis/ExprMutationAnalyzerTest.cpp b/unittests/Analysis/ExprMutationAnalyzerTest.cpp index b4a22629a4..871c915149 100644 --- a/unittests/Analysis/ExprMutationAnalyzerTest.cpp +++ b/unittests/Analysis/ExprMutationAnalyzerTest.cpp @@ -1108,4 +1108,23 @@ TEST(ExprMutationAnalyzerTest, UniquePtr) { 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 |