Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang analysis] ExprMutationAnalyzer avoid infinite recursion for recursive forwarding reference #87954

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

HerrCai0907
Copy link
Contributor

Partialy fixes: #60895

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:analysis labels Apr 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 8, 2024

@llvm/pr-subscribers-clang-tools-extra
@llvm/pr-subscribers-clang-tidy
@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang

Author: Congcong Cai (HerrCai0907)

Changes

Partialy fixes: #60895


Full diff: https://github.com/llvm/llvm-project/pull/87954.diff

3 Files Affected:

  • (modified) clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h (+33-7)
  • (modified) clang/lib/Analysis/ExprMutationAnalyzer.cpp (+14-8)
  • (modified) clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp (+30)
diff --git a/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h b/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
index 1ceef944fbc34e..af6106fe303afd 100644
--- a/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
+++ b/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
@@ -8,11 +8,10 @@
 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_EXPRMUTATIONANALYZER_H
 #define LLVM_CLANG_ANALYSIS_ANALYSES_EXPRMUTATIONANALYZER_H
 
-#include <type_traits>
-
 #include "clang/AST/AST.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "llvm/ADT/DenseMap.h"
+#include <variant>
 
 namespace clang {
 
@@ -22,8 +21,15 @@ class FunctionParmMutationAnalyzer;
 /// a given statement.
 class ExprMutationAnalyzer {
 public:
+  friend class FunctionParmMutationAnalyzer;
+  struct Cache {
+    llvm::DenseMap<const FunctionDecl *,
+                   std::unique_ptr<FunctionParmMutationAnalyzer>>
+        FuncParmAnalyzer;
+  };
+
   ExprMutationAnalyzer(const Stmt &Stm, ASTContext &Context)
-      : Stm(Stm), Context(Context) {}
+      : ExprMutationAnalyzer(Stm, Context, nullptr) {}
 
   bool isMutated(const Expr *Exp) { return findMutation(Exp) != nullptr; }
   bool isMutated(const Decl *Dec) { return findMutation(Dec) != nullptr; }
@@ -45,6 +51,19 @@ class ExprMutationAnalyzer {
   using MutationFinder = const Stmt *(ExprMutationAnalyzer::*)(const Expr *);
   using ResultMap = llvm::DenseMap<const Expr *, const Stmt *>;
 
+  ExprMutationAnalyzer(const Stmt &Stm, ASTContext &Context, Cache *ParentCache)
+      : Stm(Stm), Context(Context) {
+    if (ParentCache != nullptr) {
+      CrossAnalysisCache = ParentCache;
+    } else {
+      CrossAnalysisCache = std::make_unique<Cache>();
+    }
+  }
+  ExprMutationAnalyzer(const Stmt &Stm, ASTContext &Context,
+                       std::unique_ptr<Cache> CrossAnalysisCache)
+      : Stm(Stm), Context(Context),
+        CrossAnalysisCache(std::move(CrossAnalysisCache)) {}
+
   const Stmt *findMutationMemoized(const Expr *Exp,
                                    llvm::ArrayRef<MutationFinder> Finders,
                                    ResultMap &MemoizedResults);
@@ -67,11 +86,15 @@ class ExprMutationAnalyzer {
   const Stmt *findReferenceMutation(const Expr *Exp);
   const Stmt *findFunctionArgMutation(const Expr *Exp);
 
+  Cache *getCache() {
+    return std::holds_alternative<Cache *>(CrossAnalysisCache)
+               ? std::get<Cache *>(CrossAnalysisCache)
+               : std::get<std::unique_ptr<Cache>>(CrossAnalysisCache).get();
+  }
+
   const Stmt &Stm;
   ASTContext &Context;
-  llvm::DenseMap<const FunctionDecl *,
-                 std::unique_ptr<FunctionParmMutationAnalyzer>>
-      FuncParmAnalyzer;
+  std::variant<Cache *, std::unique_ptr<Cache>> CrossAnalysisCache;
   ResultMap Results;
   ResultMap PointeeResults;
 };
@@ -80,7 +103,10 @@ class ExprMutationAnalyzer {
 // params.
 class FunctionParmMutationAnalyzer {
 public:
-  FunctionParmMutationAnalyzer(const FunctionDecl &Func, ASTContext &Context);
+  FunctionParmMutationAnalyzer(const FunctionDecl &Func, ASTContext &Context)
+      : FunctionParmMutationAnalyzer(Func, Context, nullptr) {}
+  FunctionParmMutationAnalyzer(const FunctionDecl &Func, ASTContext &Context,
+                               ExprMutationAnalyzer::Cache *CrossAnalysisCache);
 
   bool isMutated(const ParmVarDecl *Parm) {
     return findMutation(Parm) != nullptr;
diff --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index bb042760d297a7..dba6f2a3c02112 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -638,9 +638,10 @@ const Stmt *ExprMutationAnalyzer::findFunctionArgMutation(const Expr *Exp) {
       if (!RefType->getPointeeType().getQualifiers() &&
           RefType->getPointeeType()->getAs<TemplateTypeParmType>()) {
         std::unique_ptr<FunctionParmMutationAnalyzer> &Analyzer =
-            FuncParmAnalyzer[Func];
+            getCache()->FuncParmAnalyzer[Func];
         if (!Analyzer)
-          Analyzer.reset(new FunctionParmMutationAnalyzer(*Func, Context));
+          Analyzer.reset(
+              new FunctionParmMutationAnalyzer(*Func, Context, getCache()));
         if (Analyzer->findMutation(Parm))
           return Exp;
         continue;
@@ -653,13 +654,15 @@ const Stmt *ExprMutationAnalyzer::findFunctionArgMutation(const Expr *Exp) {
 }
 
 FunctionParmMutationAnalyzer::FunctionParmMutationAnalyzer(
-    const FunctionDecl &Func, ASTContext &Context)
-    : BodyAnalyzer(*Func.getBody(), Context) {
+    const FunctionDecl &Func, ASTContext &Context,
+    ExprMutationAnalyzer::Cache *CrossAnalysisCache)
+    : BodyAnalyzer(*Func.getBody(), Context, CrossAnalysisCache) {
   if (const auto *Ctor = dyn_cast<CXXConstructorDecl>(&Func)) {
     // CXXCtorInitializer might also mutate Param but they're not part of
     // function body, check them eagerly here since they're typically trivial.
     for (const CXXCtorInitializer *Init : Ctor->inits()) {
-      ExprMutationAnalyzer InitAnalyzer(*Init->getInit(), Context);
+      ExprMutationAnalyzer InitAnalyzer(*Init->getInit(), Context,
+                                        CrossAnalysisCache);
       for (const ParmVarDecl *Parm : Ctor->parameters()) {
         if (Results.contains(Parm))
           continue;
@@ -675,11 +678,14 @@ FunctionParmMutationAnalyzer::findMutation(const ParmVarDecl *Parm) {
   const auto Memoized = Results.find(Parm);
   if (Memoized != Results.end())
     return Memoized->second;
-
+  // To handle call A -> call B -> call A. Assume parameters of A is not mutated
+  // before analyzing parameters of A. Then when analyzing the second "call A",
+  // FunctionParmMutationAnalyzer can use this memoized value to avoid infinite
+  // recursion.
+  Results[Parm] = nullptr;
   if (const Stmt *S = BodyAnalyzer.findMutation(Parm))
     return Results[Parm] = S;
-
-  return Results[Parm] = nullptr;
+  return Results[Parm];
 }
 
 } // namespace clang
diff --git a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
index f58ce4aebcbfc8..9c1dc1a76db63d 100644
--- a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -977,6 +977,36 @@ TEST(ExprMutationAnalyzerTest, FollowFuncArgModified) {
                          "void f() { int x; g(x); }");
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("g(x)"));
+
+  AST = buildASTFromCode(
+      StdRemoveReference + StdForward +
+      "template <class T> void f1(T &&a);"
+      "template <class T> void f2(T &&a);"
+      "template <class T> void f1(T &&a) { f2<T>(std::forward<T>(a)); }"
+      "template <class T> void f2(T &&a) { f1<T>(std::forward<T>(a)); }"
+      "void f() { int x; f1(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = buildASTFromCode(
+      StdRemoveReference + StdForward +
+      "template <class T> void f1(T &&a);"
+      "template <class T> void f2(T &&a);"
+      "template <class T> void f1(T &&a) { f2<T>(std::forward<T>(a)); }"
+      "template <class T> void f2(T &&a) { f1<T>(std::forward<T>(a)); a++; }"
+      "void f() { int x; f1(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("f1(x)"));
+
+  AST = buildASTFromCode(
+      StdRemoveReference + StdForward +
+      "template <class T> void f1(T &&a);"
+      "template <class T> void f2(T &&a);"
+      "template <class T> void f1(T &&a) { f2<T>(std::forward<T>(a)); a++; }"
+      "template <class T> void f2(T &&a) { f1<T>(std::forward<T>(a)); }"
+      "void f() { int x; f1(x); }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("f1(x)"));
 }
 
 TEST(ExprMutationAnalyzerTest, FollowFuncArgNotModified) {

@HerrCai0907 HerrCai0907 changed the title [clang analysis] ExprMutationAnalyzer support recursive forwarding reference [clang analysis] ExprMutationAnalyzer avoid infinite recursion for recursive forwarding reference Apr 8, 2024
@HerrCai0907 HerrCai0907 requested a review from usama54321 April 8, 2024 04:29
Copy link
Member

@PiotrZSL PiotrZSL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HerrCai0907 HerrCai0907 merged commit 8095b9c into llvm:main Apr 15, 2024
5 checks passed
@HerrCai0907 HerrCai0907 deleted the fix/expr-mutation branch April 15, 2024 11:39
bazuzi pushed a commit to bazuzi/llvm-project that referenced this pull request Apr 15, 2024
@fmayer
Copy link
Contributor

fmayer commented Apr 15, 2024

This broke the sanitizer bots, e.g. https://lab.llvm.org/buildbot/#/builders/239/builds/6587/steps/10/logs/stdio

[==========] Running 2 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 2 tests from ExprMutationAnalyzerTest
[ RUN      ] ExprMutationAnalyzerTest.UnresolvedOperator
[       OK ] ExprMutationAnalyzerTest.UnresolvedOperator (59 ms)
[ RUN      ] ExprMutationAnalyzerTest.ReproduceFailureMinimal
input.cc:1:166: warning: unqualified call to 'std::forward' [-Wunqualified-std-cast-call]
    1 | 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);}
      |                                                                                                                                                                      ^
      |                                                                                                                                                                      std::
input.cc:1:230: note: in instantiation of function template specialization 'std::__bind<(lambda at input.cc:1:222)>::__bind<int &>' requested here
    1 | 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);}
      |                                                                                                                                                                                                                                      ^
[       OK ] ExprMutationAnalyzerTest.ReproduceFailureMinimal (46 ms)
[----------] 2 tests from ExprMutationAnalyzerTest (106 ms total)
[----------] Global test environment tear-down
[==========] 2 tests from 1 test suite ran. (107 ms total)
[  PASSED  ] 2 tests.
=================================================================
==946027==ERROR: LeakSanitizer: detected memory leaks
Indirect leak of 1024 byte(s) in 1 object(s) allocated from:
    #0 0xaaaac90ddce4 in operator new(unsigned long, std::align_val_t) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:98:3
    #1 0xaaaaca15f590 in allocateBuckets /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:899:9
    #2 0xaaaaca15f590 in llvm::DenseMap<clang::ParmVarDecl const*, clang::Stmt const*, llvm::DenseMapInfo<clang::ParmVarDecl const*, void>, llvm::detail::DenseMapPair<clang::ParmVarDecl const*, clang::Stmt const*>>::grow(unsigned int) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:833:5
    #3 0xaaaaca15f428 in grow /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:564:36
    #4 0xaaaaca15f428 in InsertIntoBucketImpl<const clang::ParmVarDecl *> /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h
    #5 0xaaaaca15f428 in llvm::detail::DenseMapPair<clang::ParmVarDecl const*, clang::Stmt const*>* llvm::DenseMapBase<llvm::DenseMap<clang::ParmVarDecl const*, clang::Stmt const*, llvm::DenseMapInfo<clang::ParmVarDecl const*, void>, llvm::detail::DenseMapPair<clang::ParmVarDecl const*, clang::Stmt const*>>, clang::ParmVarDecl const*, clang::Stmt const*, llvm::DenseMapInfo<clang::ParmVarDecl const*, void>, llvm::detail::DenseMapPair<clang::ParmVarDecl const*, clang::Stmt const*>>::InsertIntoBucket<clang::ParmVarDecl const* const&>(llvm::detail::DenseMapPair<clang::ParmVarDecl const*, clang::Stmt const*>*, clang::ParmVarDecl const* const&) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:574:17
    #6 0xaaaaca104ee8 in FindAndConstruct /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:353:13
    #7 0xaaaaca104ee8 in operator[] /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:357:12
    #8 0xaaaaca104ee8 in clang::FunctionParmMutationAnalyzer::findMutation(clang::ParmVarDecl const*) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/lib/Analysis/ExprMutationAnalyzer.cpp:685:3
    #9 0xaaaaca0f64d4 in clang::ExprMutationAnalyzer::findFunctionArgMutation(clang::Expr const*) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/lib/Analysis/ExprMutationAnalyzer.cpp:645:23
    #10 0xaaaaca0d5b30 in clang::ExprMutationAnalyzer::findMutationMemoized(clang::Expr const*, llvm::ArrayRef<clang::Stmt const* (clang::ExprMutationAnalyzer::*)(clang::Expr const*)>, llvm::DenseMap<clang::Expr const*, clang::Stmt const*, llvm::DenseMapInfo<clang::Expr const*, void>, llvm::detail::DenseMapPair<clang::Expr const*, clang::Stmt const*>>&) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/lib/Analysis/ExprMutationAnalyzer.cpp:237:25
    #11 0xaaaaca0d5864 in clang::ExprMutationAnalyzer::findMutation(clang::Expr const*) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/lib/Analysis/ExprMutationAnalyzer.cpp:203:10
    #12 0xaaaac9176f08 in isMutated /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h:34:44
    #13 0xaaaac9176f08 in clang::(anonymous namespace)::isMutated(llvm::SmallVectorImpl<clang::ast_matchers::BoundNodes> const&, clang::ASTUnit*) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp:57:57
    #14 0xaaaac91c2980 in clang::ExprMutationAnalyzerTest_ReproduceFailureMinimal_Test::TestBody() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp:1588:3
    #15 0xaaaac93abff8 in HandleExceptionsInMethodIfSupported<testing::Test, void> /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #16 0xaaaac93abff8 in testing::Test::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:2687:5
    #17 0xaaaac93ae3b8 in testing::TestInfo::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:2836:11
    #18 0xaaaac93afc88 in testing::TestSuite::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:3015:30
    #19 0xaaaac93d0038 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:5920:44
    #20 0xaaaac93ce870 in HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #21 0xaaaac93ce870 in testing::UnitTest::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:5484:10
    #22 0xaaaac938e498 in RUN_ALL_TESTS /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:2317:73
    #23 0xaaaac938e498 in main /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/UnitTestMain/TestMain.cpp:55:10
    #24 0xffff96327580  (/lib/aarch64-linux-gnu/libc.so.6+0x27580) (BuildId: b9b95c4f6e0feae95b758633cb6a2881fa8eac30)
    #25 0xffff96327654 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x27654) (BuildId: b9b95c4f6e0feae95b758633cb6a2881fa8eac30)
    #26 0xaaaac900b6ac in _start (/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/unittests/Analysis/ClangAnalysisTests+0x240b6ac)
Indirect leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0xaaaac90dd8c4 in operator new(unsigned long) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:86:3
    #1 0xaaaaca0f64f8 in clang::ExprMutationAnalyzer::findFunctionArgMutation(clang::Expr const*) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/lib/Analysis/ExprMutationAnalyzer.cpp:643:26
    #2 0xaaaaca0d5b30 in clang::ExprMutationAnalyzer::findMutationMemoized(clang::Expr const*, llvm::ArrayRef<clang::Stmt const* (clang::ExprMutationAnalyzer::*)(clang::Expr const*)>, llvm::DenseMap<clang::Expr const*, clang::Stmt const*, llvm::DenseMapInfo<clang::Expr const*, void>, llvm::detail::DenseMapPair<clang::Expr const*, clang::Stmt const*>>&) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/lib/Analysis/ExprMutationAnalyzer.cpp:237:25
    #3 0xaaaaca0d5864 in clang::ExprMutationAnalyzer::findMutation(clang::Expr const*) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/lib/Analysis/ExprMutationAnalyzer.cpp:203:10
    #4 0xaaaac9176f08 in isMutated /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h:34:44
    #5 0xaaaac9176f08 in clang::(anonymous namespace)::isMutated(llvm::SmallVectorImpl<clang::ast_matchers::BoundNodes> const&, clang::ASTUnit*) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp:57:57
    #6 0xaaaac91c2980 in clang::ExprMutationAnalyzerTest_ReproduceFailureMinimal_Test::TestBody() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp:1588:3
    #7 0xaaaac93abff8 in HandleExceptionsInMethodIfSupported<testing::Test, void> /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #8 0xaaaac93abff8 in testing::Test::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:2687:5
    #9 0xaaaac93ae3b8 in testing::TestInfo::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:2836:11
    #10 0xaaaac93afc88 in testing::TestSuite::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:3015:30
    #11 0xaaaac93d0038 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:5920:44
    #12 0xaaaac93ce870 in HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #13 0xaaaac93ce870 in testing::UnitTest::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:5484:10
    #14 0xaaaac938e498 in RUN_ALL_TESTS /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:2317:73
    #15 0xaaaac938e498 in main /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/UnitTestMain/TestMain.cpp:55:10
    #16 0xffff96327580  (/lib/aarch64-linux-gnu/libc.so.6+0x27580) (BuildId: b9b95c4f6e0feae95b758633cb6a2881fa8eac30)
    #17 0xffff96327654 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x27654) (BuildId: b9b95c4f6e0feae95b758633cb6a2881fa8eac30)
    #18 0xaaaac900b6ac in _start (/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/unittests/Analysis/ClangAnalysisTests+0x240b6ac)
Indirect leak of 104 byte(s) in 1 object(s) allocated from:
    #0 0xaaaac90dd8c4 in operator new(unsigned long) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:86:3
    #1 0xaaaac9176e10 in __libcpp_operator_new<unsigned long> /b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:270:10
    #2 0xaaaac9176e10 in __libcpp_allocate /b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:294:10
    #3 0xaaaac9176e10 in allocate /b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator.h:119:32
    #4 0xaaaac9176e10 in allocate /b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator_traits.h:280:16
    #5 0xaaaac9176e10 in __allocation_guard<std::__1::allocator<clang::ExprMutationAnalyzer::Cache> > /b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocation_guard.h:56:16
    #6 0xaaaac9176e10 in allocate_shared<clang::ExprMutationAnalyzer::Cache, std::__1::allocator<clang::ExprMutationAnalyzer::Cache>, 0> /b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/shared_ptr.h:824:46
    #7 0xaaaac9176e10 in make_shared<clang::ExprMutationAnalyzer::Cache, 0> /b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/shared_ptr.h:833:10
    #8 0xaaaac9176e10 in ExprMutationAnalyzer /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h:32:44
    #9 0xaaaac9176e10 in clang::(anonymous namespace)::isMutated(llvm::SmallVectorImpl<clang::ast_matchers::BoundNodes> const&, clang::ASTUnit*) /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp:57:10
    #10 0xaaaac91c2980 in clang::ExprMutationAnalyzerTest_ReproduceFailureMinimal_Test::TestBody() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp:1588:3
    #11 0xaaaac93abff8 in HandleExceptionsInMethodIfSupported<testing::Test, void> /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #12 0xaaaac93abff8 in testing::Test::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:2687:5
    #13 0xaaaac93ae3b8 in testing::TestInfo::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:2836:11
    #14 0xaaaac93afc88 in testing::TestSuite::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:3015:30
    #15 0xaaaac93d0038 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:5920:44
    #16 0xaaaac93ce870 in HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #17 0xaaaac93ce870 in testing::UnitTest::Run() /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/src/gtest.cc:5484:10
    #18 0xaaaac938e498 in RUN_ALL_TESTS /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:2317:73
    #19 0xaaaac938e498 in main /b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/third-party/unittest/UnitTestMain/TestMain.cpp:55:10
    #20 0xffff96327580  (/lib/aarch64-linux-gnu/libc.so.6+0x27580) (BuildId: b9b95c4f6e0feae95b758633cb6a2881fa8eac30)
    #21 0xffff96327654 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x27654) (BuildId: b9b95c4f6e0feae95b758633cb6a2881fa8eac30)
    #22 0xaaaac900b6ac in _start (/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/unittests/Analysis/ClangAnalysisTests+0x240b6ac)
SUMMARY: AddressSanitizer: 1256 byte(s) leaked in 3 allocation(s).
--
exit: 1
--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:analysis clang Clang issues not falling into any other category clang-tidy clang-tools-extra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Clang-Tidy] misc-const-correctness crash due to seemingly infinite recursion
4 participants