@@ -1179,8 +1179,8 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
1179
1179
// const std::string& Ref(const std::string& a [[clang::lifetimebound]]);
1180
1180
// string_view abc = Ref(std::string());
1181
1181
// 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 .
1184
1184
if (Path.back ().Kind == IndirectLocalPathEntry::LifetimeBoundCall) {
1185
1185
// The lifetimebound applies to the implicit object parameter of a method.
1186
1186
const FunctionDecl *FD =
@@ -1195,10 +1195,13 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
1195
1195
// We still respect this case even the type S is not an owner.
1196
1196
return Report;
1197
1197
}
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 ())))
1202
1205
return Report;
1203
1206
1204
1207
return Abandon;
0 commit comments