[clang] [alpha.webkit.UncountedLocalVarsChecker] Allow uncounted object references within trivial statements (PR #82229)

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 19 01:35:20 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff ead0a9777f8ccb5c26d50d96bade6cd5b47f496b 32d0e658edee46f99f8b9c9f09945079df8862df -- clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp clang/test/Analysis/Checkers/WebKit/mock-types.h clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 9be1f10d09..16789bc3f0 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -252,7 +252,7 @@ class TrivialFunctionAnalysisVisitor
       return true;
     });
   }
-  
+
   bool VisitSubExpr(const Expr *E) {
     return withCachedResult(E, [&]() {
       if (!Visit(E))
@@ -277,9 +277,7 @@ public:
 
   TrivialFunctionAnalysisVisitor(FunctionCacheTy &FunctionCache,
                                  StatementCacheTy &StatementCache)
-    : FunctionCache(FunctionCache)
-    , StatementCache(StatementCache) {
-  }
+      : FunctionCache(FunctionCache), StatementCache(StatementCache) {}
 
   bool VisitStmt(const Stmt *S) {
     // All statements are non-trivial unless overriden later.
@@ -335,9 +333,8 @@ public:
 
   bool VisitBinaryOperator(const BinaryOperator *BO) {
     // Binary operators are trivial if their operands are trivial.
-    return withCachedResult(BO, [&]() {
-      return Visit(BO->getLHS()) && Visit(BO->getRHS());
-    });
+    return withCachedResult(
+        BO, [&]() { return Visit(BO->getLHS()) && Visit(BO->getRHS()); });
   }
 
   bool VisitConditionalOperator(const ConditionalOperator *CO) {
@@ -425,9 +422,8 @@ public:
       }
 
       // Recursively descend into the callee to confirm that it's trivial.
-      return TrivialFunctionAnalysis::isTrivialImpl(CE->getConstructor(),
-                                                    FunctionCache,
-                                                    StatementCache);
+      return TrivialFunctionAnalysis::isTrivialImpl(
+          CE->getConstructor(), FunctionCache, StatementCache);
     });
   }
 
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp
index 547e7fc089..4068b472cc 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp
@@ -195,7 +195,7 @@ public:
               if (MaybeGuardian->isLocalVarDecl() &&
                   (isRefCounted(MaybeGuardianArgCXXRecord) ||
                    isRefcountedStringsHack(MaybeGuardian)) &&
-                   isGuardedScopeEmbeddedInGuardianScope(V, MaybeGuardian))
+                  isGuardedScopeEmbeddedInGuardianScope(V, MaybeGuardian))
                 return;
             }
           }

``````````

</details>


https://github.com/llvm/llvm-project/pull/82229


More information about the cfe-commits mailing list