File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -290,15 +290,15 @@ static bool isContainerOfPointer(const RecordDecl *Container) {
290
290
return false ;
291
291
}
292
292
static bool isContainerOfOwner (const RecordDecl *Container) {
293
- if ( const auto *CTSD =
294
- dyn_cast_if_present<ClassTemplateSpecializationDecl>(Container)) {
295
- if (!CTSD-> hasAttr <OwnerAttr>()) // Container must be a GSL owner type.
296
- return false ;
297
- const auto &TAs = CTSD->getTemplateArgs ();
298
- return TAs. size () > 0 && TAs[ 0 ]. getKind () == TemplateArgument::Type &&
299
- isRecordWithAttr<OwnerAttr>(TAs[ 0 ]. getAsType () );
300
- }
301
- return false ;
293
+ const auto *CTSD =
294
+ dyn_cast_if_present<ClassTemplateSpecializationDecl>(Container);
295
+ if (!CTSD)
296
+ return false ;
297
+ if (! CTSD->hasAttr <OwnerAttr>()) // Container must be a GSL owner type.
298
+ return false ;
299
+ const auto &TAs = CTSD-> getTemplateArgs ( );
300
+ return TAs. size () > 0 && TAs[ 0 ]. getKind () == TemplateArgument::Type &&
301
+ isRecordWithAttr<OwnerAttr>(TAs[ 0 ]. getAsType ()) ;
302
302
}
303
303
304
304
// Returns true if the given Record is `std::initializer_list<pointer>`.
@@ -383,7 +383,7 @@ static bool isCopyLikeConstructor(const CXXConstructorDecl *Ctor) {
383
383
if (!ParamRefType)
384
384
return false ;
385
385
386
- // Check if the first parameter type "Owner<U>".
386
+ // Check if the first parameter type is "Owner<U>".
387
387
if (const auto *TST =
388
388
ParamRefType->getPointeeType ()->getAs <TemplateSpecializationType>())
389
389
return TST->getTemplateName ()
Original file line number Diff line number Diff line change @@ -769,4 +769,11 @@ const int& test12(Span<int> a) {
769
769
return a.getFieldNoLB (); // OK.
770
770
}
771
771
772
+ void test13 () {
773
+ // FIXME: RHS is Owner<Pointer>, we skip this case to avoid false positives.
774
+ std::optional<Span<int *>> abc = std::vector<int *>{};
775
+
776
+ std::optional<Span<int >> t = std::vector<int > {}; // expected-warning {{object backing the pointer will be destroyed}}
777
+ }
778
+
772
779
} // namespace GH100526
You can’t perform that action at this time.
0 commit comments