[all-commits] [llvm/llvm-project] 3004a7: [lldb][tests][gmodules] Test for expression evalua...

Michael137 via All-commits all-commits at lists.llvm.org
Fri Sep 16 09:39:08 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3004a759bcdf7b0a2a3a4220ed216d20defbd081
      https://github.com/llvm/llvm-project/commit/3004a759bcdf7b0a2a3a4220ed216d20defbd081
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2022-09-16 (Fri, 16 Sep 2022)

  Changed paths:
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/Makefile
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/TestTemplateWithSameArg.py
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/base_module.cpp
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/base_module.h
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/main.cpp
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/module.modulemap
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/module1.cpp
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/module1.h
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/module2.cpp
    A lldb/test/API/lang/cpp/gmodules/template-with-same-arg/module2.h

  Log Message:
  -----------
  [lldb][tests][gmodules] Test for expression evaluator crash for types referencing the same template

The problem here is that the ASTImporter adds
the template class member FieldDecl to
the DeclContext twice. This happens because
we don't construct a `LookupPtr` for decls
that originate from modules and thus the
ASTImporter never realizes that the FieldDecl
has already been imported. These duplicate
decls then break the assumption of the LayoutBuilder
which expects only a single member decl to
exist.

The test will be fixed by a follow-up revision
and is thus skipped for now.

Differential Revision: https://reviews.llvm.org/D133944


  Commit: e456d2ba8bcadaa63386b339a4f2abcb39505502
      https://github.com/llvm/llvm-project/commit/e456d2ba8bcadaa63386b339a4f2abcb39505502
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2022-09-16 (Fri, 16 Sep 2022)

  Changed paths:
    M clang/lib/AST/DeclBase.cpp
    M clang/unittests/AST/ASTImporterTest.cpp
    M lldb/test/API/lang/cpp/gmodules/template-with-same-arg/TestTemplateWithSameArg.py

  Log Message:
  -----------
  [clang][ASTImporter] DeclContext::localUncachedLookup: Continue lookup into decl chain when regular lookup fails

The uncached lookup is mainly used in the ASTImporter/LLDB code-path
where we're not allowed to load from external storage. When importing
a FieldDecl with a DeclContext that had no external visible storage
(but came from a Clang module or PCH) the above call to `lookup(Name)`
the regular `DeclContext::lookup` fails because:
1. `DeclContext::buildLookup` doesn't set `LookupPtr` for decls
   that came from a module
2. LLDB doesn't use the `SharedImporterState`

In such a case we would never continue with the "slow" path of iterating
through the decl chain on the DeclContext. In some cases this means that
ASTNodeImporter::VisitFieldDecl ends up importing a decl into the
DeclContext a second time.

The patch removes the short-circuit in the case where we don't find
any decls via the regular lookup.

**Tests**

* Un-skip the failing LLDB API tests

Differential Revision: https://reviews.llvm.org/D133945


Compare: https://github.com/llvm/llvm-project/compare/44754705290a...e456d2ba8bca


More information about the All-commits mailing list