[clang] [Clang][NFC] Remove unnecessary copy (PR #100688)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 25 20:42:13 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (smanna12)

<details>
<summary>Changes</summary>

Reported by Static Analyzer Tool:

In Sema::checkIncorrectVTablePointerAuthenticationAttribute(): Using the auto keyword without an & causes the copy of an object of type CXXBaseSpecifier.

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


1 Files Affected:

- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-1) 


``````````diff
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 1cca8ac9b9343..5782daa041f32 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -10385,7 +10385,7 @@ void Sema::checkIncorrectVTablePointerAuthenticationAttribute(
   while (1) {
     assert(PrimaryBase);
     const CXXRecordDecl *Base = nullptr;
-    for (auto BasePtr : PrimaryBase->bases()) {
+    for (const CXXBaseSpecifier &BasePtr : PrimaryBase->bases()) {
       if (!BasePtr.getType()->getAsCXXRecordDecl()->isDynamicClass())
         continue;
       Base = BasePtr.getType()->getAsCXXRecordDecl();

``````````

</details>


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


More information about the cfe-commits mailing list