JonasToth created this revision. JonasToth added reviewers: aaron.ballman, sammccall, rsmith. Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, a.sidorin, baloghadamsoftware. Herald added a reviewer: george.karpenkov.
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. Repository: rC Clang 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,48 @@ EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()")); } +TEST(ExprMutationAnalyzerTest, ReproduceFailure11) { + const std::string Reproducer = + "namespace std {" + "template <class a> a&& forward(a & A) { return static_cast<a&&>(A); }" + "template <class _Fp> struct __bind {" + "_Fp d;" + "template <class e> __bind(_Fp f, e &&) : d(forward(f)) {}" + "};" + "template <class _Fp, class h> void bind(_Fp f, h && g) {" + "__bind<_Fp>(f, g);" + "}" + "template <typename i, typename j> void async(i f, j && g) {" + "bind(f, g);" + "}" + "}" + "void k() {" + "int x = 42;" + "std::async([] {}, x);" + "}"; + auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"}); + auto Results11 = + match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext()); + EXPECT_FALSE(isMutated(Results11, AST11.get())); +} + +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
Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp =================================================================== --- unittests/Analysis/ExprMutationAnalyzerTest.cpp +++ unittests/Analysis/ExprMutationAnalyzerTest.cpp @@ -1109,4 +1109,48 @@ EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()")); } +TEST(ExprMutationAnalyzerTest, ReproduceFailure11) { + const std::string Reproducer = + "namespace std {" + "template <class a> a&& forward(a & A) { return static_cast<a&&>(A); }" + "template <class _Fp> struct __bind {" + "_Fp d;" + "template <class e> __bind(_Fp f, e &&) : d(forward(f)) {}" + "};" + "template <class _Fp, class h> void bind(_Fp f, h && g) {" + "__bind<_Fp>(f, g);" + "}" + "template <typename i, typename j> void async(i f, j && g) {" + "bind(f, g);" + "}" + "}" + "void k() {" + "int x = 42;" + "std::async([] {}, x);" + "}"; + auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"}); + auto Results11 = + match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext()); + EXPECT_FALSE(isMutated(Results11, AST11.get())); +} + +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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits