[clang] 71e2b8d - [clang] NFC, simplify the code in CheckExprLifetime.cpp (#99637)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 19 07:46:35 PDT 2024


Author: Haojian Wu
Date: 2024-07-19T16:46:31+02:00
New Revision: 71e2b8df30ad78f5f86bf0d6729296282e061a5c

URL: https://github.com/llvm/llvm-project/commit/71e2b8df30ad78f5f86bf0d6729296282e061a5c
DIFF: https://github.com/llvm/llvm-project/commit/71e2b8df30ad78f5f86bf0d6729296282e061a5c.diff

LOG: [clang] NFC, simplify the code in CheckExprLifetime.cpp (#99637)

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

Added: 
    

Modified: 
    clang/lib/Sema/CheckExprLifetime.cpp

Removed: 
    


################################################################################
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())) {


        


More information about the cfe-commits mailing list