================
@@ -470,10 +474,24 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
         VisitGSLPointerArg(Callee, Args[0],
                            !Callee->getReturnType()->isReferenceType());
       } else {
-        if (auto *CCE = dyn_cast<CXXConstructExpr>(Call);
-            CCE && CCE->getConstructor()->getParent()->hasAttr<PointerAttr>())
-          VisitGSLPointerArg(CCE->getConstructor()->getParamDecl(0), Args[0],
-                             true);
+        if (auto *Ctor = dyn_cast<CXXConstructExpr>(Call)) {
+          const auto *ClassD = Ctor->getConstructor()->getParent();
+          // Constructing the Container<GSLPointer> case (e.g.
+          // std::optional<string_view>) case.
+          if (const auto *CTSD =
+                  dyn_cast<ClassTemplateSpecializationDecl>(ClassD)) {
+            if (isFirstTemplateArgumentGSLPointer(CTSD->getTemplateArgs()) &&
+                CTSD->hasAttr<OwnerAttr>()) {
+              VisitGSLPointerArg(Ctor->getConstructor()->getParamDecl(0),
+                                 Args[0], true);
+              return;
+            }
+          }
+          // Constructing the GSLPointer (e.g. std::string_view) case.
+          if (ClassD->hasAttr<PointerAttr>())
+            VisitGSLPointerArg(Ctor->getConstructor()->getParamDecl(0), 
Args[0],
+                               true);
+        }
----------------
hokein wrote:
The logic here is tightly coupled with the lifetimebound attribute. If the 
first argument is already visited due to the lifetimebound attribute, we avoid 
performing the GSL analysis on it again to prevent duplication. Therefore, both 
checks need to remain within the same loop.

https://github.com/llvm/llvm-project/pull/107213
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to