[all-commits] [llvm/llvm-project] c5e4af: [C++20] [Modules] Support module level lookup (#12...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Thu Jan 16 21:42:06 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c5e4afe6733c58e24023ede04275bbed3bde8240
      https://github.com/llvm/llvm-project/commit/c5e4afe6733c58e24023ede04275bbed3bde8240
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2025-01-17 (Fri, 17 Jan 2025)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/DeclBase.h
    M clang/include/clang/Serialization/ASTBitCodes.h
    M clang/include/clang/Serialization/ASTReader.h
    M clang/include/clang/Serialization/ASTWriter.h
    M clang/lib/AST/DeclBase.cpp
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/lib/Serialization/ASTReaderInternals.h
    M clang/lib/Serialization/ASTWriter.cpp
    M clang/lib/Serialization/ASTWriterDecl.cpp
    M clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
    M clang/test/CXX/module/basic/basic.link/p2.cppm
    M clang/test/CXX/module/module.import/p2.cpp
    M clang/test/CXX/module/module.interface/p7.cpp
    M clang/test/CXX/module/module.reach/p5.cpp
    M clang/test/Modules/Reachability-template-default-arg.cpp
    M clang/test/Modules/cxx20-10-1-ex2.cpp
    M clang/test/Modules/deduction-guide3.cppm
    A clang/test/Modules/module-local-with-templates.cppm
    A clang/test/Modules/pr90154.cppm

  Log Message:
  -----------
  [C++20] [Modules] Support module level lookup (#122887) (#123281)

Close https://github.com/llvm/llvm-project/issues/90154

This patch is also an optimization to the lookup process to utilize the
information provided by `export` keyword.

Previously, in the lookup process, the `export` keyword only takes part
in the check part, it doesn't get involved in the lookup process. That
said, previously, in a name lookup for 'name', we would load all of
declarations with the name 'name' and check if these declarations are
valid or not. It works well. But it is inefficient since it may load
declarations that may not be wanted.

Note that this patch actually did a trick in the lookup process instead
of bring module information to DeclarationName or considering module
information when deciding if two declarations are the same. So it may
not be a surprise to me if there are missing cases. But it is not a
regression. It should be already the case. Issue reports are welcomed.

In this patch, I tried to split the big lookup table into a lookup table
as before and a module local lookup table, which takes a combination of
the ID of the DeclContext and hash value of the primary module name as
the key. And refactored `DeclContext::lookup()` method to take the
module information. So that a lookup in a DeclContext won't load
declarations that are local to **other** modules.

And also I think it is already beneficial to split the big lookup table
since it may reduce the conflicts during lookups in the hash table.

BTW, this patch introduced a **regression** for a reachability rule in
C++20 but it was false-negative. See
'clang/test/CXX/module/module.interface/p7.cpp' for details.

This patch is not expected to introduce any other
regressions for non-c++20-modules users since the module local lookup
table should be empty for them.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list