[all-commits] [llvm/llvm-project] 3e6ea8: [Sema] Return primary merged decl as canonical for...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Mon Aug 8 11:32:27 PDT 2022


  Branch: refs/heads/release/15.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 3e6ea8aff3d534c56e04e39424a27761facc4101
      https://github.com/llvm/llvm-project/commit/3e6ea8aff3d534c56e04e39424a27761facc4101
  Author: Ilya Biryukov <ibiryukov at google.com>
  Date:   2022-08-08 (Mon, 08 Aug 2022)

  Changed paths:
    M clang/include/clang/AST/DeclTemplate.h
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/test/Modules/merge-concepts.cpp

  Log Message:
  -----------
  [Sema] Return primary merged decl as canonical for concepts

Otherwise we get invalid results for ODR checks. See changed test for an
example: despite the fact that we merge the first concept, its **uses**
were considered different by `Profile`, leading to redefinition errors.

After this change, canonical decl for a concept can come from a
different module and may not be visible. This behavior looks suspicious,
but does not break any tests. We might want to add a mechanism to make
the canonical concept declaration visible if we find code that relies on
this invariant.

Additionally make sure we always merge with the canonical declaration to
avoid chains of merged concepts being reported as redefinitions. An
example was added to the test.

Also change the order of includes in the test. Importing a moduralized
header before its textual part causes the include guard macro to be
exported and the corresponding `#include` becomes a no-op.

Reviewed By: ChuanqiXu

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

(cherry picked from commit 42f87bb62d0719848842da60d2a8180b9e4d7c52)


  Commit: b2a385f2613c497353a43f2053f897348af14dca
      https://github.com/llvm/llvm-project/commit/b2a385f2613c497353a43f2053f897348af14dca
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2022-08-08 (Mon, 08 Aug 2022)

  Changed paths:
    M clang/include/clang/Basic/Module.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    A clang/test/Modules/merge-concepts.cppm

  Log Message:
  -----------
  [C++20] [Modules] Merge same concept decls in global module fragment

According to [basic.def.odr]p14, the same redeclarations in different TU
but not attached to a named module are allowed. But we didn't take care
of concept decl for this condition. This patch tries to fix this
problem.

Reviewed By: ilya-biryukov

Differention Revision: https://reviews.llvm.org/D130614

(cherry picked from commit 4d9251bd780d20eebbcb124608b36a69787d5575)


  Commit: 786a4f426c0f9402a802560cccd466a773e708ac
      https://github.com/llvm/llvm-project/commit/786a4f426c0f9402a802560cccd466a773e708ac
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2022-08-08 (Mon, 08 Aug 2022)

  Changed paths:
    M clang/lib/CodeGen/CGDeclCXX.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    A clang/test/CodeGenCXX/module-initializer-header.cppm

  Log Message:
  -----------
  [C++20] [Modules] Handle initializer for Header Units

Previously when we add module initializer, we forget to handle header
units. This results that we couldn't compile a Hello World Example with
Header Units. This patch tries to fix this.

Reviewed By: iains

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

(cherry picked from commit 6d10733d445506c02ebec9faa54658431857bb49)


Compare: https://github.com/llvm/llvm-project/compare/207f96e8fac0...786a4f426c0f


More information about the All-commits mailing list