[PATCH] AST: Mangle templated local classes instead of crashing

Richard Smith richard at metafoo.co.uk
Mon Oct 14 10:17:00 PDT 2013


Does this also affect generic lambdas? If not, this is in conflict with
another patch out for review that makes us reject template members of local
classes.
On 14 Oct 2013 03:19, "David Majnemer" <david.majnemer at gmail.com> wrote:

> Hi eli.friedman, rsmith, rjmccall,
>
> On builds of clang compiled with asserts, we would crash during
> mangling.
> On builds of clang compiler without asserts, we would mangle in an extra
> prefix.
>
> i.e. Funtion()::Function::Type<void>[...] rather than
> Funtion()::Type<void>[...]
>
> http://llvm-reviews.chandlerc.com/D1932
>
> Files:
>   lib/AST/ItaniumMangle.cpp
>   test/CodeGenCXX/mangle-local-class-names.cpp
>
> Index: lib/AST/ItaniumMangle.cpp
> ===================================================================
> --- lib/AST/ItaniumMangle.cpp
> +++ lib/AST/ItaniumMangle.cpp
> @@ -1504,18 +1504,16 @@
>    if (NoFunction && isLocalContainerContext(DC))
>      return;
>
> -  assert(!isLocalContainerContext(DC));
> -
> -  const NamedDecl *ND = cast<NamedDecl>(DC);
> +  const NamedDecl *ND = cast<NamedDecl>(DC);
>    if (mangleSubstitution(ND))
>      return;
>
>    // Check if we have a template.
>    const TemplateArgumentList *TemplateArgs = 0;
>    if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
>      mangleTemplatePrefix(TD);
>      mangleTemplateArgs(*TemplateArgs);
> -  } else {
> +  } else if (!isLocalContainerContext(DC)) {
>      manglePrefix(getEffectiveDeclContext(ND), NoFunction);
>      mangleUnqualifiedName(ND);
>    }
> Index: test/CodeGenCXX/mangle-local-class-names.cpp
> ===================================================================
> --- test/CodeGenCXX/mangle-local-class-names.cpp
> +++ test/CodeGenCXX/mangle-local-class-names.cpp
> @@ -95,3 +95,23 @@
>    y.g();
>  }
>  void CallLocalAnonStruct() { LocalAnonStruct(); }
> +
> +// CHECK: @_ZZ4Fun1vEN5Type15Type2IvE4Fun2Ev
> +// CHECK: @_ZZZ4Fun1vEN5Type15Type2IvE4Fun2EvEN5Type35Type4IvE4Fun3Ev
> +void Fun1() {
> +  struct Type1 {
> +    template <typename = void>
> +    struct Type2 {
> +      static void Fun2() {
> +        struct Type3 {
> +          template <typename = void>
> +          struct Type4 {
> +            static void Fun3() {}
> +          };
> +        };
> +        Type3::template Type4<>::Fun3();
> +      }
> +    };
> +  };
> +  Type1::Type2<>::Fun2();
> +}
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131014/25723faa/attachment.html>


More information about the cfe-commits mailing list