Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/18.x: [Serialization] Record whether the ODR is skipped (#82302) #82309

Merged
merged 1 commit into from
Feb 21, 2024

Commits on Feb 21, 2024

  1. [Serialization] Record whether the ODR is skipped (llvm#82302)

    Close llvm#80570.
    
    In
    
    llvm@a0b6747,
    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.
    
    (cherry picked from commit 49775b1)
    ChuanqiXu9 authored and tstellar committed Feb 21, 2024
    Configuration menu
    Copy the full SHA
    66351a5 View commit details
    Browse the repository at this point in the history