[clang] Fix false positive regression for lifetime analysis warning. … · llvm/llvm-project@6b57839 (original) (raw)

Original file line number Diff line number Diff line change
@@ -1239,11 +1239,12 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
1239 1239 }
1240 1240 // Check the return type, e.g.
1241 1241 // const GSLOwner& func(const Foo& foo [[clang::lifetimebound]])
1242 +// GSLOwner* func(cosnt Foo& foo [[clang::lifetimebound]])
1242 1243 // GSLPointer func(const Foo& foo [[clang::lifetimebound]])
1243 1244 if (FD &&
1244 - ((FD->getReturnType()->isReferenceType() &&
1245 + ((FD->getReturnType()->isPointerOrReferenceType() &&
1245 1246 isRecordWithAttr(FD->getReturnType()->getPointeeType())) |
1246 -isPointerLikeType(FD->getReturnType())))
1247 +isGLSPointerType(FD->getReturnType())))
1247 1248 return Report;
1248 1249
1249 1250 return Abandon;