Skip to content

[Clang][NFC] Remove unnecessary copy #97902

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

Merged
merged 5 commits into from
Jul 17, 2024
Merged

[Clang][NFC] Remove unnecessary copy #97902

merged 5 commits into from
Jul 17, 2024

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
@smanna12 smanna12 requested review from tahonermann and rapidsna July 6, 2024 16:06
@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
Member

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();

@smanna12 smanna12 requested a review from JOE1994 July 16, 2024 12:51
@smanna12
Copy link
Contributor Author

Thank you, @cor3ntin for reviews!

@rapidsna rapidsna requested a review from AaronBallman July 16, 2024 14:59
Copy link
Contributor

@rapidsna rapidsna left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this issue! I left a minor comment. Other than that, LGTM.

Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

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

Can you add a NFC tag to the subject? (patch subject; commit message are completely ignored since we use "Squash and merge")

@smanna12 smanna12 changed the title [Clang] Remove unnecessary copy [Clang][NFC] Remove unnecessary copy Jul 16, 2024
@smanna12
Copy link
Contributor Author

Thank you everyone for reviews!

@smanna12 smanna12 merged commit e9fdc68 into llvm:main Jul 17, 2024
7 checks passed
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary:
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

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60251598
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.

6 participants