[clang] [-Wunsafe-buffer-usage] Fix debug notes for unclaimed DREs (PR #80787)

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 5 18:54:38 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 8f80df0f52c4294d23d0510b01be6d6491714058 90e7145fe0133828b4abc16730b9786fc68df8b9 -- clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 6feff1d508..a6dcf16b92 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -2879,27 +2879,27 @@ void clang::checkUnsafeBufferUsage(const Decl *D,
                                     "' : init capture"));
 #endif
         it = FixablesForAllVars.byVar.erase(it);
-      }else {
-      ++it;
-    }
+      } else {
+        ++it;
+      }
   }
 
 #ifndef NDEBUG
-  for (const auto& it : UnsafeOps.byVar) {
-    const VarDecl* const UnsafeVD = it.first;
+  for (const auto &it : UnsafeOps.byVar) {
+    const VarDecl *const UnsafeVD = it.first;
     auto UnclaimedDREs = Tracker.getUnclaimedUses(UnsafeVD);
     if (UnclaimedDREs.empty())
       continue;
     const auto UnfixedVDName = UnsafeVD->getNameAsString();
-    for (const clang::DeclRefExpr* UnclaimedDRE : UnclaimedDREs) {
+    for (const clang::DeclRefExpr *UnclaimedDRE : UnclaimedDREs) {
       std::string UnclaimedUseTrace =
           getDREAncestorString(UnclaimedDRE, D->getASTContext());
 
       Handler.addDebugNoteForVar(
           UnsafeVD, UnclaimedDRE->getBeginLoc(),
           ("failed to produce fixit for '" + UnfixedVDName +
-            "' : has an unclaimed use\nThe unclaimed DRE trace: " +
-            UnclaimedUseTrace));
+           "' : has an unclaimed use\nThe unclaimed DRE trace: " +
+           UnclaimedUseTrace));
     }
   }
 #endif

``````````

</details>


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


More information about the cfe-commits mailing list