@@ -1179,8 +1179,8 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
11791179 // const std::string& Ref(const std::string& a [[clang::lifetimebound]]);
11801180 // string_view abc = Ref(std::string());
11811181 // The "Path" is [GSLPointerInit, LifetimeboundCall], where "L" is the
1182- // temporary "std::string()" object. We need to check if the function with the
1183- // lifetimebound attribute returns a "owner" type .
1182+ // temporary "std::string()" object. We need to check the return type of the
1183+ // function with the lifetimebound attribute .
11841184 if (Path.back ().Kind == IndirectLocalPathEntry::LifetimeBoundCall) {
11851185 // The lifetimebound applies to the implicit object parameter of a method.
11861186 const FunctionDecl *FD =
@@ -1195,10 +1195,13 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
11951195 // We still respect this case even the type S is not an owner.
11961196 return Report;
11971197 }
1198- // Check if the return type has an Owner attribute.
1199- // e.g., const GSLOwner& func(const Foo& foo [[clang::lifetimebound]])
1200- if (FD && FD->getReturnType ()->isReferenceType () &&
1201- isRecordWithAttr<OwnerAttr>(FD->getReturnType ()->getPointeeType ()))
1198+ // Check the return type, e.g.
1199+ // const GSLOwner& func(const Foo& foo [[clang::lifetimebound]])
1200+ // GSLPointer func(const Foo& foo [[clang::lifetimebound]])
1201+ if (FD &&
1202+ ((FD->getReturnType ()->isReferenceType () &&
1203+ isRecordWithAttr<OwnerAttr>(FD->getReturnType ()->getPointeeType ())) ||
1204+ isRecordWithAttr<PointerAttr>(FD->getReturnType ())))
12021205 return Report;
12031206
12041207 return Abandon;
0 commit comments