Skip to content

[clang] NFC, simplify the code in CheckExprLifetime.cpp #99637

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 1 commit into from
Jul 19, 2024

Conversation

hokein
Copy link
Collaborator

@hokein hokein commented Jul 19, 2024

No need to get the Owner/Pointer attr via the type. The Decl has this attr information.

No need to get the Owner/Pointer attr via the type. The Decl has these attr
information.
@hokein hokein requested a review from Xazax-hun July 19, 2024 11:37
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jul 19, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 19, 2024

@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)

Changes

No need to get the Owner/Pointer attr via the type. The Decl has this attr information.


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

1 Files Affected:

  • (modified) clang/lib/Sema/CheckExprLifetime.cpp (+1-2)
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp b/clang/lib/Sema/CheckExprLifetime.cpp
index d9031256f235f..5c8ef564f30aa 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -308,8 +308,7 @@ static bool shouldTrackFirstArgument(const FunctionDecl *FD) {
   const auto *RD = FD->getParamDecl(0)->getType()->getPointeeCXXRecordDecl();
   if (!FD->isInStdNamespace() || !RD || !RD->isInStdNamespace())
     return false;
-  if (!isRecordWithAttr<PointerAttr>(QualType(RD->getTypeForDecl(), 0)) &&
-      !isRecordWithAttr<OwnerAttr>(QualType(RD->getTypeForDecl(), 0)))
+  if (!RD->hasAttr<PointerAttr>() && !RD->hasAttr<OwnerAttr>())
     return false;
   if (FD->getReturnType()->isPointerType() ||
       isRecordWithAttr<PointerAttr>(FD->getReturnType())) {

Copy link
Collaborator

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

LGTM!

@hokein hokein merged commit 71e2b8d into llvm:main Jul 19, 2024
10 checks passed
@hokein hokein deleted the no-type branch July 19, 2024 14:46
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary:
No need to get the Owner/Pointer attr via the type. The Decl has this
attr information.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


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

3 participants