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] Remove unnecessary copy #97902

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

smanna12
Copy link
Contributor

@smanna12 smanna12 commented Jul 6, 2024

Reported by Static Analyzer Tool:

In clang::ASTNodeImporter::VisitCountAttributedType(clang::CountAttributedType const *): Using the auto keyword without an & causes the copy of an object of type TypeCoupledDeclRefInfo

Reported by Static Analyzer Tool:

In clang::ASTNodeImporter::VisitCountAttributedType(clang::CountAttributedType const *): Using the auto keyword without an & causes the copy of an object of type TypeCoupledDeclRefInfo
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jul 6, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 6, 2024

@llvm/pr-subscribers-clang

Author: None (smanna12)

Changes

Reported by Static Analyzer Tool:

In clang::ASTNodeImporter::VisitCountAttributedType(clang::CountAttributedType const *): Using the auto keyword without an & causes the copy of an object of type TypeCoupledDeclRefInfo


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

1 Files Affected:

  • (modified) clang/lib/AST/ASTImporter.cpp (+1-1)
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 4e1b3a5a94de7..0c27f6f5df2da 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1551,7 +1551,7 @@ ASTNodeImporter::VisitCountAttributedType(const CountAttributedType *T) {
   Expr *CountExpr = importChecked(Err, T->getCountExpr());
 
   SmallVector<TypeCoupledDeclRefInfo, 1> CoupledDecls;
-  for (auto TI : T->dependent_decls()) {
+  for (const TypeCoupledDeclRefInfo &TI : T->dependent_decls()) {
     Expected<ValueDecl *> ToDeclOrErr = import(TI.getDecl());
     if (!ToDeclOrErr)
       return ToDeclOrErr.takeError();

@@ -1551,7 +1551,7 @@ ASTNodeImporter::VisitCountAttributedType(const CountAttributedType *T) {
Expr *CountExpr = importChecked(Err, T->getCountExpr());

SmallVector<TypeCoupledDeclRefInfo, 1> CoupledDecls;
for (auto TI : T->dependent_decls()) {
for (const TypeCoupledDeclRefInfo &TI : T->dependent_decls()) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for (const TypeCoupledDeclRefInfo &TI : T->dependent_decls()) {
for (const auto &TI : T->dependent_decls()) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants