r338165 - [Sema] Use a TreeTransform to extract deduction guide parameter types

Galina Kistanova via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 27 17:46:33 PDT 2018


Hello Erik,

This commit broke build step on one of our builders:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/11300

. . .
FAILED: tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaTemplate.cpp.obj
C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe  /nologo /TP -DEXPENSIVE_CHECKS
-DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_DEBUG -D_GNU_SOURCE
-D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
-D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -Itools\clang\lib\Sema
-IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema
-IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\include
-Itools\clang\include -Iinclude
-IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\include
/DWIN32 /D_WINDOWS   /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4
-wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351
-wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800
-wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706
-wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091
-wd4592 -wd4319 -wd4324 -w14062 -we4238 /MDd /Zi /Ob0 /Od /RTC1    /EHs-c-
/GR- /showIncludes
/Fotools\clang\lib\Sema\CMakeFiles\clangSema.dir\SemaTemplate.cpp.obj
/Fdtools\clang\lib\Sema\CMakeFiles\clangSema.dir\clangSema.pdb /FS -c
C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema\SemaTemplate.cpp
C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema\SemaTemplate.cpp
: fatal error C1128: number of sections exceeded object file format limit:
compile with /bigobj
ninja: build stopped: subcommand failed.


Please have a look?
The builder was already red and did not sent notifications.

Thanks

Galina

On Fri, Jul 27, 2018 at 2:23 PM, Erik Pilkington via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: epilk
> Date: Fri Jul 27 14:23:48 2018
> New Revision: 338165
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338165&view=rev
> Log:
> [Sema] Use a TreeTransform to extract deduction guide parameter types
>
> Previously, we just canonicalized the type, but this lead to crashes with
> parameter types that referred to ParmVarDecls of the constructor. There
> may be
> more cases that this TreeTransform needs to handle though, such as a
> constructor
> parameter type referring to a member in an unevaluated context.
> Canonicalization
> doesn't address these cases either though, so we can address them
> as-needed in
> follow-up commits.
>
> rdar://41330135
>
> Differential revision: https://reviews.llvm.org/D49439
>
> Modified:
>     cfe/trunk/lib/Sema/SemaTemplate.cpp
>     cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaTemplate.cpp?rev=338165&r1=338164&r2=338165&view=diff
> ============================================================
> ==================
> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Jul 27 14:23:48 2018
> @@ -1659,6 +1659,23 @@ DeclResult Sema::CheckClassTemplate(
>  }
>
>  namespace {
> +/// Tree transform to "extract" a transformed type from a class template's
> +/// constructor to a deduction guide.
> +class ExtractTypeForDeductionGuide
> +  : public TreeTransform<ExtractTypeForDeductionGuide> {
> +public:
> +  typedef TreeTransform<ExtractTypeForDeductionGuide> Base;
> +  ExtractTypeForDeductionGuide(Sema &SemaRef) : Base(SemaRef) {}
> +
> +  TypeSourceInfo *transform(TypeSourceInfo *TSI) { return
> TransformType(TSI); }
> +
> +  QualType TransformTypedefType(TypeLocBuilder &TLB, TypedefTypeLoc TL) {
> +    return TransformType(
> +        TLB,
> +        TL.getTypedefNameDecl()->getTypeSourceInfo()->getTypeLoc());
> +  }
> +};
> +
>  /// Transform to convert portions of a constructor declaration into the
>  /// corresponding deduction guide, per C++1z [over.match.class.deduct]p1.
>  struct ConvertConstructorToDeductionGuideTransform {
> @@ -1880,9 +1897,7 @@ private:
>                               MultiLevelTemplateArgumentList &Args) {
>      TypeSourceInfo *OldDI = OldParam->getTypeSourceInfo();
>      TypeSourceInfo *NewDI;
> -    if (!Args.getNumLevels())
> -      NewDI = OldDI;
> -    else if (auto PackTL = OldDI->getTypeLoc().getAs<PackExpansionTypeLoc>())
> {
> +    if (auto PackTL = OldDI->getTypeLoc().getAs<PackExpansionTypeLoc>())
> {
>        // Expand out the one and only element in each inner pack.
>        Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, 0);
>        NewDI =
> @@ -1898,23 +1913,17 @@ private:
>      if (!NewDI)
>        return nullptr;
>
> -    // Canonicalize the type. This (for instance) replaces references to
> -    // typedef members of the current instantiations with the definitions
> of
> -    // those typedefs, avoiding triggering instantiation of the deduced
> type
> -    // during deduction.
> -    // FIXME: It would be preferable to retain type sugar and source
> -    // information here (and handle this in substitution instead).
> -    NewDI = SemaRef.Context.getTrivialTypeSourceInfo(
> -        SemaRef.Context.getCanonicalType(NewDI->getType()),
> -        OldParam->getLocation());
> +    // Extract the type. This (for instance) replaces references to
> typedef
> +    // members of the current instantiations with the definitions of those
> +    // typedefs, avoiding triggering instantiation of the deduced type
> during
> +    // deduction.
> +    NewDI = ExtractTypeForDeductionGuide(SemaRef).transform(NewDI);
>
>      // Resolving a wording defect, we also inherit default arguments from
> the
>      // constructor.
>      ExprResult NewDefArg;
>      if (OldParam->hasDefaultArg()) {
> -      NewDefArg = Args.getNumLevels()
> -                      ? SemaRef.SubstExpr(OldParam->getDefaultArg(),
> Args)
> -                      : OldParam->getDefaultArg();
> +      NewDefArg = SemaRef.SubstExpr(OldParam->getDefaultArg(), Args);
>        if (NewDefArg.isInvalid())
>          return nullptr;
>      }
> @@ -1929,6 +1938,7 @@ private:
>                                                  NewDefArg.get());
>      NewParam->setScopeInfo(OldParam->getFunctionScopeDepth(),
>                             OldParam->getFunctionScopeIndex());
> +    SemaRef.CurrentInstantiationScope->InstantiatedLocal(OldParam,
> NewParam);
>      return NewParam;
>    }
>
>
> Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-
> deduction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=
> 338165&r1=338164&r2=338165&view=diff
> ============================================================
> ==================
> --- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
> (original)
> +++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
> Fri Jul 27 14:23:48 2018
> @@ -373,6 +373,35 @@ void bar(D<int>& d) {
>  }
>  }
>
> +namespace rdar41330135 {
> +template <int> struct A {};
> +template <class T>
> +struct S {
> +  template <class U>
> +  S(T a, U t, A<sizeof(t)>);
> +};
> +template <class T> struct D {
> +  D(T t, A<sizeof(t)>);
> +};
> +int f() {
> +  S s(0, 0, A<sizeof(int)>());
> +  D d(0, A<sizeof(int)>());
> +}
> +
> +namespace test_dupls {
> +template<unsigned long> struct X {};
> +template<typename T> struct A {
> +  A(T t, X<sizeof(t)>);
> +};
> +A a(0, {});
> +template<typename U> struct B {
> +  B(U u, X<sizeof(u)>);
> +};
> +B b(0, {});
> +}
> +
> +}
> +
>  #else
>
>  // expected-no-diagnostics
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180727/e4b69f37/attachment-0001.html>


More information about the cfe-commits mailing list