Re: r371182 - Reland [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

2019-09-06 Thread Matthias Gehre via cfe-commits
Yvan, sorry!
Should be fixed now.

Am Fr., 6. Sept. 2019 um 16:40 Uhr schrieb Yvan Roux :

> Hi Matthias,
>
> this commit broke AArch64 bots, logs are available here:
>
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/19917/steps/ninja%20check%201/logs/stdio
>
> Thanks,
> Yvan
>
> On Fri, 6 Sep 2019 at 10:54, Matthias Gehre via cfe-commits
>  wrote:
> >
> > Author: mgehre
> > Date: Fri Sep  6 01:56:30 2019
> > New Revision: 371182
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=371182=rev
> > Log:
> > Reland [LifetimeAnalysis] Support more STL idioms (template forward
> declaration and DependentNameType)
> >
> > Reland after https://reviews.llvm.org/D66806 fixed the false-positive
> diagnostics.
> >
> > Summary:
> > This fixes inference of gsl::Pointer on std::set::iterator with
> libstdc++ (the typedef for iterator
> > on the template is a DependentNameType - we can only put the
> gsl::Pointer attribute
> > on the underlaying record after instantiation)
> >
> > inference of gsl::Pointer on std::vector::iterator with libc++ (the
> class was forward-declared,
> > we added the gsl::Pointer on the canonical decl (the forward decl), and
> later when the
> > template was instantiated, there was no attribute on the definition so
> it was not instantiated).
> >
> > and a duplicate gsl::Pointer on some class with libstdc++ (we first
> added an attribute to
> > a incomplete instantiation, and then another was copied from the
> template definition
> > when the instantiation was completed).
> >
> > We now add the attributes to all redeclarations to fix thos issues and
> make their usage easier.
> >
> > Reviewers: gribozavr
> >
> > Subscribers: Szelethus, xazax.hun, cfe-commits
> >
> > Tags: #clang
> >
> > Differential Revision: https://reviews.llvm.org/D66179
> >
> > Added:
> > cfe/trunk/unittests/Sema/GslOwnerPointerInference.cpp
> > Modified:
> > cfe/trunk/lib/Sema/SemaAttr.cpp
> > cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> > cfe/trunk/lib/Sema/SemaInit.cpp
> > cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> > cfe/trunk/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
> > cfe/trunk/test/SemaCXX/attr-gsl-owner-pointer.cpp
> > cfe/trunk/unittests/Sema/CMakeLists.txt
> >
> > Modified: cfe/trunk/lib/Sema/SemaAttr.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAttr.cpp?rev=371182=371181=371182=diff
> >
> ==
> > --- cfe/trunk/lib/Sema/SemaAttr.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaAttr.cpp Fri Sep  6 01:56:30 2019
> > @@ -88,13 +88,11 @@ void Sema::AddMsStructLayoutForRecord(Re
> >  template 
> >  static void addGslOwnerPointerAttributeIfNotExisting(ASTContext
> ,
> >   CXXRecordDecl
> *Record) {
> > -  CXXRecordDecl *Canonical = Record->getCanonicalDecl();
> > -  if (Canonical->hasAttr() ||
> Canonical->hasAttr())
> > +  if (Record->hasAttr() || Record->hasAttr())
> >  return;
> >
> > -  Canonical->addAttr(::new (Context) Attribute(SourceRange{}, Context,
> > -   /*DerefType*/ nullptr,
> > -   /*Spelling=*/0));
> > +  for (Decl *Redecl : Record->redecls())
> > +Redecl->addAttr(Attribute::CreateImplicit(Context,
> /*DerefType=*/nullptr));
> >  }
> >
> >  void Sema::inferGslPointerAttribute(NamedDecl *ND,
> > @@ -189,8 +187,7 @@ void Sema::inferGslOwnerPointerAttribute
> >
> >// Handle classes that directly appear in std namespace.
> >if (Record->isInStdNamespace()) {
> > -CXXRecordDecl *Canonical = Record->getCanonicalDecl();
> > -if (Canonical->hasAttr() ||
> Canonical->hasAttr())
> > +if (Record->hasAttr() || Record->hasAttr())
> >return;
> >
> >  if (StdOwners.count(Record->getName()))
> >
> > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=371182=371181=371182=diff
> >
> ==
> > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Sep  6 01:56:30 2019
> > @@ -4592,9 +4592,11 @@ static void handleLifetimeCategoryAttr(S
> >}
> >return;
> >  }
> > -D->addAttr(::new (S.Context)
> > -   OwnerAttr(AL.getRange(), S.Context, DerefTypeLoc,
> > - AL.getAttributeSpellingListIndex()));
> > +for (Decl *Redecl : D->redecls()) {
> > +  Redecl->addAttr(::new (S.Context)
> > +  OwnerAttr(AL.getRange(), S.Context,
> DerefTypeLoc,
> > +
> AL.getAttributeSpellingListIndex()));
> > +}
> >} else {
> >  if (checkAttrMutualExclusion(S, D, AL))
> >return;
> > @@ -4609,9 +4611,11 @@ static void handleLifetimeCategoryAttr(S
> >}
> >return;
> >  }
> > -

Re: r371182 - Reland [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

2019-09-06 Thread Yvan Roux via cfe-commits
Hi Matthias,

this commit broke AArch64 bots, logs are available here:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/19917/steps/ninja%20check%201/logs/stdio

Thanks,
Yvan

On Fri, 6 Sep 2019 at 10:54, Matthias Gehre via cfe-commits
 wrote:
>
> Author: mgehre
> Date: Fri Sep  6 01:56:30 2019
> New Revision: 371182
>
> URL: http://llvm.org/viewvc/llvm-project?rev=371182=rev
> Log:
> Reland [LifetimeAnalysis] Support more STL idioms (template forward 
> declaration and DependentNameType)
>
> Reland after https://reviews.llvm.org/D66806 fixed the false-positive 
> diagnostics.
>
> Summary:
> This fixes inference of gsl::Pointer on std::set::iterator with libstdc++ 
> (the typedef for iterator
> on the template is a DependentNameType - we can only put the gsl::Pointer 
> attribute
> on the underlaying record after instantiation)
>
> inference of gsl::Pointer on std::vector::iterator with libc++ (the class was 
> forward-declared,
> we added the gsl::Pointer on the canonical decl (the forward decl), and later 
> when the
> template was instantiated, there was no attribute on the definition so it was 
> not instantiated).
>
> and a duplicate gsl::Pointer on some class with libstdc++ (we first added an 
> attribute to
> a incomplete instantiation, and then another was copied from the template 
> definition
> when the instantiation was completed).
>
> We now add the attributes to all redeclarations to fix thos issues and make 
> their usage easier.
>
> Reviewers: gribozavr
>
> Subscribers: Szelethus, xazax.hun, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D66179
>
> Added:
> cfe/trunk/unittests/Sema/GslOwnerPointerInference.cpp
> Modified:
> cfe/trunk/lib/Sema/SemaAttr.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
> cfe/trunk/test/SemaCXX/attr-gsl-owner-pointer.cpp
> cfe/trunk/unittests/Sema/CMakeLists.txt
>
> Modified: cfe/trunk/lib/Sema/SemaAttr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAttr.cpp?rev=371182=371181=371182=diff
> ==
> --- cfe/trunk/lib/Sema/SemaAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaAttr.cpp Fri Sep  6 01:56:30 2019
> @@ -88,13 +88,11 @@ void Sema::AddMsStructLayoutForRecord(Re
>  template 
>  static void addGslOwnerPointerAttributeIfNotExisting(ASTContext ,
>   CXXRecordDecl *Record) {
> -  CXXRecordDecl *Canonical = Record->getCanonicalDecl();
> -  if (Canonical->hasAttr() || Canonical->hasAttr())
> +  if (Record->hasAttr() || Record->hasAttr())
>  return;
>
> -  Canonical->addAttr(::new (Context) Attribute(SourceRange{}, Context,
> -   /*DerefType*/ nullptr,
> -   /*Spelling=*/0));
> +  for (Decl *Redecl : Record->redecls())
> +Redecl->addAttr(Attribute::CreateImplicit(Context, 
> /*DerefType=*/nullptr));
>  }
>
>  void Sema::inferGslPointerAttribute(NamedDecl *ND,
> @@ -189,8 +187,7 @@ void Sema::inferGslOwnerPointerAttribute
>
>// Handle classes that directly appear in std namespace.
>if (Record->isInStdNamespace()) {
> -CXXRecordDecl *Canonical = Record->getCanonicalDecl();
> -if (Canonical->hasAttr() || Canonical->hasAttr())
> +if (Record->hasAttr() || Record->hasAttr())
>return;
>
>  if (StdOwners.count(Record->getName()))
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=371182=371181=371182=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Sep  6 01:56:30 2019
> @@ -4592,9 +4592,11 @@ static void handleLifetimeCategoryAttr(S
>}
>return;
>  }
> -D->addAttr(::new (S.Context)
> -   OwnerAttr(AL.getRange(), S.Context, DerefTypeLoc,
> - AL.getAttributeSpellingListIndex()));
> +for (Decl *Redecl : D->redecls()) {
> +  Redecl->addAttr(::new (S.Context)
> +  OwnerAttr(AL.getRange(), S.Context, DerefTypeLoc,
> +AL.getAttributeSpellingListIndex()));
> +}
>} else {
>  if (checkAttrMutualExclusion(S, D, AL))
>return;
> @@ -4609,9 +4611,11 @@ static void handleLifetimeCategoryAttr(S
>}
>return;
>  }
> -D->addAttr(::new (S.Context)
> -   PointerAttr(AL.getRange(), S.Context, DerefTypeLoc,
> -   AL.getAttributeSpellingListIndex()));
> +for (Decl *Redecl : D->redecls()) {
> +  Redecl->addAttr(::new (S.Context)
> +