@@ -1120,8 +1120,8 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
11201120 // const std::string& Ref(const std::string& a [[clang::lifetimebound]]);
11211121 // string_view abc = Ref(std::string());
11221122 // The "Path" is [GSLPointerInit, LifetimeboundCall], where "L" is the
1123- // temporary "std::string()" object. We need to check if the function with the
1124- // lifetimebound attribute returns a "owner" type .
1123+ // temporary "std::string()" object. We need to check the return type of the
1124+ // function with the lifetimebound attribute .
11251125 if (Path.back ().Kind == IndirectLocalPathEntry::LifetimeBoundCall) {
11261126 // The lifetimebound applies to the implicit object parameter of a method.
11271127 const FunctionDecl *FD =
@@ -1136,10 +1136,13 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
11361136 // We still respect this case even the type S is not an owner.
11371137 return Report;
11381138 }
1139- // Check if the return type has an Owner attribute.
1140- // e.g., const GSLOwner& func(const Foo& foo [[clang::lifetimebound]])
1141- if (FD && FD->getReturnType ()->isReferenceType () &&
1142- isRecordWithAttr<OwnerAttr>(FD->getReturnType ()->getPointeeType ()))
1139+ // Check the return type, e.g.
1140+ // const GSLOwner& func(const Foo& foo [[clang::lifetimebound]])
1141+ // GSLPointer func(const Foo& foo [[clang::lifetimebound]])
1142+ if (FD &&
1143+ ((FD->getReturnType ()->isReferenceType () &&
1144+ isRecordWithAttr<OwnerAttr>(FD->getReturnType ()->getPointeeType ())) ||
1145+ isRecordWithAttr<PointerAttr>(FD->getReturnType ())))
11431146 return Report;
11441147
11451148 return Abandon;
0 commit comments