[all-commits] [llvm/llvm-project] 49775b: [Serialization] Record whether the ODR is skipped ...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Mon Feb 19 21:31:40 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 49775b1dc0cdb3a9d18811f67f268e3b3a381669
      https://github.com/llvm/llvm-project/commit/49775b1dc0cdb3a9d18811f67f268e3b3a381669
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2024-02-20 (Tue, 20 Feb 2024)

  Changed paths:
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/lib/Serialization/ASTWriter.cpp
    M clang/lib/Serialization/ASTWriterDecl.cpp
    M clang/unittests/Serialization/CMakeLists.txt
    A clang/unittests/Serialization/PreambleInNamedModulesTest.cpp

  Log Message:
  -----------
  [Serialization] Record whether the ODR is skipped (#82302)

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

In

https://github.com/llvm/llvm-project/commit/a0b6747804e46665ecfd00295b60432bfe1775b6,
we skipped ODR checks for decls in GMF. Then it should be natural to
skip storing the ODR values in BMI.

Generally it should be fine as long as the writer and the reader keep
consistent.

However, the use of preamble in clangd shows the tricky part.

For,

```
// test.cpp
module;

// any one off these is enough to crash clangd
// #include <iostream>
// #include <string_view>
// #include <cmath>
// #include <system_error>
// #include <new>
// #include <bit>
// probably many more

// only ok with libc++, not the system provided libstdc++ 13.2.1

// these are ok

export module test;
```

clangd will store the headers as preamble to speedup the parsing and the
preamble reuses the serialization techniques. (Generally we'd call the
preamble as PCH. However it is not true strictly. I've tested the PCH
wouldn't be problematic.) However, the tricky part is that the preamble
is not modules. It literally serialiaze and deserialize things. So
before clangd parsing the above test module, clangd will serialize the
headers into the preamble. Note that there is no concept like GMF now.
So the ODR bits are stored. However, when clangd parse the file
actually, the decls from preamble are thought as in GMF literally, then
hte ODR bits are skipped. Then mismatch happens.

To solve the problem, this patch adds another bit for decls to record
whether or not the ODR bits are skipped.



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