[clang] [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto keyword (PR #86808)

Cyndy Ishida via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 27 07:58:08 PDT 2024


================
@@ -255,7 +255,7 @@ bool InstallAPIVisitor::VisitFunctionDecl(const FunctionDecl *D) {
       return true;
 
     // Skip methods in CXX RecordDecls.
-    for (auto P : D->getASTContext().getParents(*M)) {
+    for (const auto &P : D->getASTContext().getParents(*M)) {
----------------
cyndyishida wrote:

```suggestion
    for (const DynTypedNode &P : D->getASTContext().getParents(*M)) {
```
An improvement would be to be explicit about the type.

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


More information about the cfe-commits mailing list