[clang] 9b21d4b - Revert "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas."

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 28 16:44:27 PST 2021


On Thu, 28 Jan 2021 at 16:41, Amy Huang via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

>
> Author: Amy Huang
> Date: 2021-01-28T16:41:26-08:00
> New Revision: 9b21d4b9434d2d4796b0d60d64f6ded9bac95441
>
> URL:
> https://github.com/llvm/llvm-project/commit/9b21d4b9434d2d4796b0d60d64f6ded9bac95441
> DIFF:
> https://github.com/llvm/llvm-project/commit/9b21d4b9434d2d4796b0d60d64f6ded9bac95441.diff
>
> LOG: Revert "[DebugInfo][CodeView] Use <lambda_n> as the display name for
> lambdas."
> for test failures.
>
> This reverts commit d73564c510036b2d4f5858effdcd23fe54fc1063.
>

Please include a reason for the revert in the commit message in future
reverts -- this helps people looking back over the history to understand
what happened and why. Thanks!


> Added:
>
>
> Modified:
>     clang/include/clang/AST/Mangle.h
>     clang/lib/AST/ItaniumMangle.cpp
>     clang/lib/AST/MicrosoftMangle.cpp
>     clang/lib/CodeGen/CGDebugInfo.cpp
>     clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
>     clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/clang/include/clang/AST/Mangle.h
> b/clang/include/clang/AST/Mangle.h
> index f8f44853567f..0e8d6dd53d8a 100644
> --- a/clang/include/clang/AST/Mangle.h
> +++ b/clang/include/clang/AST/Mangle.h
> @@ -89,17 +89,6 @@ class MangleContext {
>      return Result.first->second;
>    }
>
> -  uint64_t getAnonymousStructIdForDebugInfo(const NamedDecl *D) {
> -    llvm::DenseMap<const NamedDecl *, uint64_t>::iterator Result =
> -        AnonStructIds.find(D);
> -    // The decl should already be inserted, but return 0 in case it is
> not.
> -    if (Result == AnonStructIds.end())
> -      return 0;
> -    return Result->second;
> -  }
> -
> -  virtual StringRef getLambdaString(const CXXRecordDecl *Lambda) = 0;
> -
>    /// @name Mangler Entry Points
>    /// @{
>
>
> diff  --git a/clang/lib/AST/ItaniumMangle.cpp
> b/clang/lib/AST/ItaniumMangle.cpp
> index 265c2172801c..4420f6a2c1c3 100644
> --- a/clang/lib/AST/ItaniumMangle.cpp
> +++ b/clang/lib/AST/ItaniumMangle.cpp
> @@ -203,36 +203,6 @@ class ItaniumMangleContextImpl : public
> ItaniumMangleContext {
>      disc = discriminator-2;
>      return true;
>    }
> -
> -  StringRef getLambdaString(const CXXRecordDecl *Lambda) override {
> -    // This function matches the one in MicrosoftMangle, which returns
> -    // the string that is used in lambda mangled names.
> -    assert(Lambda->isLambda() && "RD must be a lambda!");
> -    llvm::SmallString<10> Name("<lambda");
> -    Decl *LambdaContextDecl = Lambda->getLambdaContextDecl();
> -    unsigned LambdaManglingNumber = Lambda->getLambdaManglingNumber();
> -    unsigned LambdaId;
> -    const ParmVarDecl *Parm =
> dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
> -    const FunctionDecl *Func =
> -        Parm ? dyn_cast<FunctionDecl>(Parm->getDeclContext()) : nullptr;
> -
> -    if (Func) {
> -      unsigned DefaultArgNo =
> -          Func->getNumParams() - Parm->getFunctionScopeIndex();
> -      Name += llvm::utostr(DefaultArgNo);
> -      Name += "_";
> -    }
> -
> -    if (LambdaManglingNumber)
> -      LambdaId = LambdaManglingNumber;
> -    else
> -      LambdaId = getAnonymousStructIdForDebugInfo(Lambda);
> -
> -    Name += llvm::utostr(LambdaId);
> -    Name += '>';
> -    return StringRef(Name);
> -  }
> -
>    /// @}
>  };
>
>
> diff  --git a/clang/lib/AST/MicrosoftMangle.cpp
> b/clang/lib/AST/MicrosoftMangle.cpp
> index aaaba62a0fd4..9eac3586c871 100644
> --- a/clang/lib/AST/MicrosoftMangle.cpp
> +++ b/clang/lib/AST/MicrosoftMangle.cpp
> @@ -228,34 +228,6 @@ class MicrosoftMangleContextImpl : public
> MicrosoftMangleContext {
>      return true;
>    }
>
> -  StringRef getLambdaString(const CXXRecordDecl *Lambda) override {
> -    assert(Lambda->isLambda() && "RD must be a lambda!");
> -    llvm::SmallString<10> Name("<lambda_");
> -
> -    Decl *LambdaContextDecl = Lambda->getLambdaContextDecl();
> -    unsigned LambdaManglingNumber = Lambda->getLambdaManglingNumber();
> -    unsigned LambdaId;
> -    const ParmVarDecl *Parm =
> dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
> -    const FunctionDecl *Func =
> -        Parm ? dyn_cast<FunctionDecl>(Parm->getDeclContext()) : nullptr;
> -
> -    if (Func) {
> -      unsigned DefaultArgNo =
> -          Func->getNumParams() - Parm->getFunctionScopeIndex();
> -      Name += llvm::utostr(DefaultArgNo);
> -      Name += "_";
> -    }
> -
> -    if (LambdaManglingNumber)
> -      LambdaId = LambdaManglingNumber;
> -    else
> -      LambdaId = getLambdaIdForDebugInfo(Lambda);
> -
> -    Name += llvm::utostr(LambdaId);
> -    Name += ">";
> -    return StringRef(Name);
> -  }
> -
>    unsigned getLambdaId(const CXXRecordDecl *RD) {
>      assert(RD->isLambda() && "RD must be a lambda!");
>      assert(!RD->isExternallyVisible() && "RD must not be visible!");
> @@ -266,19 +238,6 @@ class MicrosoftMangleContextImpl : public
> MicrosoftMangleContext {
>      return Result.first->second;
>    }
>
> -  unsigned getLambdaIdForDebugInfo(const CXXRecordDecl *RD) {
> -    assert(RD->isLambda() && "RD must be a lambda!");
> -    assert(!RD->isExternallyVisible() && "RD must not be visible!");
> -    assert(RD->getLambdaManglingNumber() == 0 &&
> -           "RD must not have a mangling number!");
> -    llvm::DenseMap<const CXXRecordDecl *, unsigned>::iterator Result =
> -        LambdaIds.find(RD);
> -    // The lambda should exist, but return 0 in case it doesn't.
> -    if (Result == LambdaIds.end())
> -      return 0;
> -    return Result->second;
> -  }
> -
>    /// Return a character sequence that is (somewhat) unique to the TU
> suitable
>    /// for mangling anonymous namespaces.
>    StringRef getAnonymousNamespaceHash() const {
>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index fb1d465fca4e..99944afaad14 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -317,9 +317,8 @@ StringRef CGDebugInfo::getClassName(const RecordDecl
> *RD) {
>    if (const IdentifierInfo *II = RD->getIdentifier())
>      return II->getName();
>
> -  // The CodeView printer in LLVM wants to see the names of unnamed types
> -  // because they need to have a unique identifier.
> -  // These names are used to reconstruct the fully qualified type names.
> +  // The CodeView printer in LLVM wants to see the names of unnamed
> types: it is
> +  // used to reconstruct the fully qualified type names.
>    if (CGM.getCodeGenOpts().EmitCodeView) {
>      if (const TypedefNameDecl *D = RD->getTypedefNameForAnonDecl()) {
>        assert(RD->getDeclContext() == D->getDeclContext() &&
> @@ -343,14 +342,6 @@ StringRef CGDebugInfo::getClassName(const RecordDecl
> *RD) {
>          // associate typedef mangled in if they have one.
>          Name = TND->getName();
>
> -      // Give lambdas a display name based on their name mangling.
> -      if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD))
> -        if (CXXRD->isLambda()) {
> -          StringRef LambdaName =
> -              CGM.getCXXABI().getMangleContext().getLambdaString(CXXRD);
> -          return internString(LambdaName);
> -        }
> -
>        if (!Name.empty()) {
>          SmallString<256> UnnamedType("<unnamed-type-");
>          UnnamedType += Name;
>
> diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
> b/clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
> index b4c79936ab33..dd4cc9cb4787 100644
> --- a/clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
> +++ b/clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
> @@ -100,7 +100,7 @@ int main(int argc, char* argv[], char* arge[]) {
>    // MSVC-SAME:      )
>    // MSVC:       [[TYPE_OF_FOUR]] = distinct !DICompositeType
>    // MSVC-SAME:      tag: DW_TAG_class_type
> -  // MSVC-SAME:      name: "<lambda_0>"
> +  // MSVC-NOT:       name:
>    // MSVC-SAME:      identifier: ".?AV<lambda_0>@?0??main@@9@"
>    // MSVC-SAME:      )
>
>
> diff  --git
> a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
> b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
> index e3ca6bf8a187..409b62da62c1 100644
> --- a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
> +++ b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
> @@ -1,26 +1,17 @@
> -// RUN: %clang_cc1 %s -gcodeview -debug-info-kind=line-tables-only
> -emit-llvm \
> -// RUN:   -o - | FileCheck %s
> +// RUN: %clang_cc1 %s -gcodeview -debug-info-kind=line-tables-only -S \
> +// RUN:   -emit-llvm -o - | FileCheck %s
>  // Checks that clang with "-gline-tables-only" with CodeView emits some
> debug
>  // info for variables and types when they appear in function scopes.
>
>  namespace NS {
>  struct C {
>    void m() {}
> -  // Test externally visible lambda.
> -  void lambda2() { []() {}(); }
> -
> -  // Test naming for function parameters.
> -  void lambda_params(int x = [](){ return 0; }(), int y = [](){ return 1;
> }()) {}
>  };
>  void f() {}
>  }
>
> -// Test non- externally visible lambda.
> -auto lambda1 = []() { return 1; };
> -
>  NS::C c;
>
> -
>  void test() {
>    // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
>    // CHECK-SAME:          type: ![[F:[0-9]+]]
> @@ -30,30 +21,10 @@ void test() {
>    NS::f();
>
>    // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope:
> ![[C:[0-9]+]],
> -  // CHECK-SAME:                                   type:
> ![[MTYPE:[0-9]+]],
> +  // CHECK-SAME:                                   type: ![[MTYPE:[0-9]+]]
>    // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name:
> "C",
>    // CHECK-SAME:                      flags: DIFlagFwdDecl
>    // CHECK-NOT: identifier
>    // CHECK: ![[MTYPE]] = !DISubroutineType({{.*}}types: !{{.*}})
>    c.m();
> -
> -  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA0:[0-9]+]],
> -  // CHECK: ![[LAMBDA0]] = !DICompositeType(tag: DW_TAG_class_type,
> -  // CHECK-SAME:                            name: "<lambda_0>",
> -  // CHECK-SAME:                            flags: DIFlagFwdDecl
> -  lambda1();
> -
> -  // CHECK: !DISubprogram(name: "operator()", scope:
> ![[LAMBDA1_1:[0-9]+]],
> -  // CHECK: ![[LAMBDA1_1]] = !DICompositeType(tag: DW_TAG_class_type,
> -  // CHECK-SAME:                              name: "<lambda_1_1>",
> -  // CHECK: !DISubprogram(name: "operator()", scope:
> ![[LAMBDA2_1:[0-9]+]],
> -  // CHECK: ![[LAMBDA2_1]] = !DICompositeType(tag: DW_TAG_class_type,
> -  // CHECK-SAME:                              name: "<lambda_2_1>",
> -  c.lambda_params();
> -
> -  // CHECK: !DISubprogram(name: "operator()", scope: ![[LAMBDA1:[0-9]+]],
> -  // CHECK: ![[LAMBDA1]] = !DICompositeType(tag: DW_TAG_class_type,
> -  // CHECK-SAME:                            name: "<lambda_1>",
> -  // CHECK-SAME:                            flags: DIFlagFwdDecl
> -  c.lambda2();
>  }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://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/20210128/19d65b91/attachment-0001.html>


More information about the cfe-commits mailing list