r219101 - DebugInfo: Don't include implicit special members in the list of class members

Yaron Keren yaron.keren at gmail.com
Sun Oct 5 23:53:50 PDT 2014


Hi David,

This does not compile on VC 2013:

1>  CGDebugInfo.cpp
1>..\..\..\..\..\tools\clang\lib\CodeGen\CGDebugInfo.cpp(1181): error
C2446: ':' : no conversion from 'llvm::WeakVH' to 'llvm::DISubprogram'
1>          No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called

refers to:

    EltTys.push_back(MI == SPCache.end()
                         ? CreateCXXMemberFunction(Method, Unit, RecordTy)
                         : MI->second);

Yaron


2014-10-06 8:18 GMT+03:00 David Blaikie <dblaikie at gmail.com>:

> Author: dblaikie
> Date: Mon Oct  6 00:18:55 2014
> New Revision: 219101
>
> URL: http://llvm.org/viewvc/llvm-project?rev=219101&view=rev
> Log:
> DebugInfo: Don't include implicit special members in the list of class
> members
>
> By leaving these members out of the member list, we avoid them being
> emitted into type unit definitions - while still allowing the
> definition/declaration to be injected into the compile unit as expected.
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>     cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=219101&r1=219100&r2=219101&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Oct  6 00:18:55 2014
> @@ -1157,24 +1157,23 @@ CollectCXXMemberFunctions(const CXXRecor
>    // have templated functions iterate over every declaration to gather
>    // the functions.
>    for(const auto *I : RD->decls()) {
> -    if (const auto *Method = dyn_cast<CXXMethodDecl>(I)) {
> -      // Reuse the existing member function declaration if it exists.
> -      // It may be associated with the declaration of the type & should be
> -      // reused as we're building the definition.
> -      //
> -      // This situation can arise in the vtable-based debug info
> reduction where
> -      // implicit members are emitted in a non-vtable TU.
> -      llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =
> -          SPCache.find(Method->getCanonicalDecl());
> -      if (MI == SPCache.end()) {
> -        // If the member is implicit, lazily create it when we see the
> -        // definition, not before. (an ODR-used implicit default ctor
> that's
> -        // never actually code generated should not produce debug info)
> -        if (!Method->isImplicit())
> -          EltTys.push_back(CreateCXXMemberFunction(Method, Unit,
> RecordTy));
> -      } else
> -        EltTys.push_back(MI->second);
> -    }
> +    const auto *Method = dyn_cast<CXXMethodDecl>(I);
> +    // If the member is implicit, don't add it to the member list. This
> avoids
> +    // the member being added to type units by LLVM, while still allowing
> it
> +    // to be emitted into the type declaration/reference inside the
> compile
> +    // unit.
> +    if (!Method || Method->isImplicit())
> +      continue;
> +    // Reuse the existing member function declaration if it exists.
> +    // It may be associated with the declaration of the type & should be
> +    // reused as we're building the definition.
> +    //
> +    // This situation can arise in the vtable-based debug info reduction
> where
> +    // implicit members are emitted in a non-vtable TU.
> +    auto MI = SPCache.find(Method->getCanonicalDecl());
> +    EltTys.push_back(MI == SPCache.end()
> +                         ? CreateCXXMemberFunction(Method, Unit, RecordTy)
> +                         : MI->second);
>    }
>  }
>
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp?rev=219101&r1=219100&r2=219101&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp Mon Oct  6
> 00:18:55 2014
> @@ -28,21 +28,22 @@ inline int add3(int x) {
>  // CHECK: [[VIRT_T]] = metadata !{metadata !"0x2f\00T\000\000"{{,
> [^,]+}}, metadata !"_ZTS4elem", {{.*}} ; [ DW_TAG_template_type_parameter ]
>
>  // CHECK: [[C:![0-9]*]] = {{.*}}, metadata [[C_MEM:![0-9]*]], metadata
> !"_ZTS7MyClass", null, metadata !"_ZTS7MyClass"} ; [ DW_TAG_structure_type
> ] [MyClass]
> -// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata
> [[C_FUNC:![0-9]*]], metadata [[C_CTOR:![0-9]*]]}
> +// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata
> [[C_FUNC:![0-9]*]]}
>  // CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$MyClass]
>
>  // CHECK: [[C_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] [line 7] [func]
> -// CHECK: [[C_CTOR]] = {{.*}} ; [ DW_TAG_subprogram ] [line 0] [MyClass]
>
>  // CHECK: [[ELEM:![0-9]*]] = {{.*}}, metadata [[ELEM_MEM:![0-9]*]], null,
> null, metadata !"_ZTS4elem"} ; [ DW_TAG_structure_type ] [elem] {{.*}} [def]
>  // CHECK: [[ELEM_MEM]] = metadata !{metadata [[ELEM_X:![0-9]*]]}
>  // CHECK: [[ELEM_X]] = {{.*}} ; [ DW_TAG_member ] [x] {{.*}} [static]
> [from _ZTS4virtI4elemE]
>
> -// Check that the member function template specialization refers to its
> class by
> -// scope, even though it didn't appear in the class's member list
> (C_MEM). This
> -// prevents the function from being added to type units, while still
> appearing
> -// in the type declaration/reference in the compile unit.
> +// Check that the member function template specialization and implicit
> special
> +// members (the default ctor) refer to their class by scope, even though
> they
> +// didn't appear in the class's member list (C_MEM). This prevents the
> functions
> +// from being added to type units, while still appearing in the type
> +// declaration/reference in the compile unit.
>  // CHECK: metadata !"_ZTS7MyClass", {{.*}} ; [ DW_TAG_subprogram ] [line
> 4] [add<2>]
> +// CHECK: metadata !"_ZTS7MyClass", {{.*}} ; [ DW_TAG_subprogram ] [line
> 0] [MyClass]
>
>  template<typename T>
>  struct outer {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141006/d0ac5df3/attachment.html>


More information about the cfe-commits mailing list