@@ -1120,8 +1120,8 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
1120
1120
// const std::string& Ref(const std::string& a [[clang::lifetimebound]]);
1121
1121
// string_view abc = Ref(std::string());
1122
1122
// 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 .
1125
1125
if (Path.back ().Kind == IndirectLocalPathEntry::LifetimeBoundCall) {
1126
1126
// The lifetimebound applies to the implicit object parameter of a method.
1127
1127
const FunctionDecl *FD =
@@ -1136,10 +1136,13 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
1136
1136
// We still respect this case even the type S is not an owner.
1137
1137
return Report;
1138
1138
}
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 ())))
1143
1146
return Report;
1144
1147
1145
1148
return Abandon;
0 commit comments