[clang] [clang] Diagnose dangling issues for the "Container<GSLPointer>" case. (PR #107213)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 4 07:49:49 PDT 2024


================
@@ -363,10 +363,14 @@ static bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD) {
     if (ATL.getAttrAs<LifetimeBoundAttr>())
       return true;
   }
-
   return isNormalAsisgnmentOperator(FD);
 }
 
+bool isFirstTemplateArgumentGSLPointer(const TemplateArgumentList &TAs) {
+  return TAs.size() > 0 && TAs[0].getKind() == TemplateArgument::Type &&
+         isRecordWithAttr<PointerAttr>(TAs[0].getAsType());
+}
+
----------------
usx95 wrote:

The motivation for checking this for first template args might not be immediately clear without seeing the usage.
I would suggest moving the `CTSD->hasAttr<OwnerAttr>())`  to this function and have a function `isContainerOfPointer(ClassTemplateSpecializationDecl*)` instead. Here we can document in this function that we are checking for "Owner<Pointer, ...>"

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


More information about the cfe-commits mailing list