ChuanqiXu9 / clangd-for-modules

A preview for C++20 Named Modules Support in clangd.
Other
19 stars 0 forks source link

clangd assertion failed: hasODRHash() #5

Open linuxnyasha opened 4 months ago

linuxnyasha commented 4 months ago
I[17:37:17.354] clangd version 19.0.0git13b00fff+libcxx
I[17:37:17.354] Features: linux+debug
I[17:37:17.354] PID: 18743
I[17:37:17.354] Working directory: /home/sha512sum/reproduce
I[17:37:17.354] argv[0]: /usr/lib/llvm/19/bin/clangd
I[17:37:17.354] argv[1]: --check=some.cppm
I[17:37:17.354] argv[2]: -log=verbose
V[17:37:17.354] User config file is /home/sha512sum/.config/clangd/config.yaml
I[17:37:17.354] Entering check mode (no LSP server)
I[17:37:17.354] Testing on source file /home/sha512sum/reproduce/some.cppm
V[17:37:17.354] config note at /home/sha512sum/.config/clangd/config.yaml:1:0: Parsing config fragment
V[17:37:17.354] config note at /home/sha512sum/.config/clangd/config.yaml:1:0: Parsed 1 fragments from file
V[17:37:17.354] Config fragment: compiling /home/sha512sum/.config/clangd/config.yaml:1 -> 0x00007F3913ADC368 (trusted=true)
V[17:37:17.354] Config fragment: compiling <unknown>:0 -> 0x00007F3913ADC458 (trusted=false)
I[17:37:17.354] Loading compilation database...
I[17:37:17.354] Loaded compilation database from /home/sha512sum/reproduce/compile_commands.json
V[17:37:17.355] Broadcasting compilation database from /home/sha512sum/reproduce
I[17:37:17.355] Compile command from CDB is: [/home/sha512sum/reproduce] /usr/lib/llvm/19/bin/clang++-19 --driver-mode=g++ -std=c++23 -fmodule-file=other=/home/sha512sum/reproduce/other.pcm -o some.o -c -std=c++23 -resource-dir=/usr/lib/llvm/19/bin/../../../../lib/clang/19 -- /home/sha512sum/reproduce/some.cppm
I[17:37:17.355] Parsing command...
I[17:37:17.356] internal (cc1) args are: -cc1 -triple x86_64-pc-linux-musl -fsyntax-only -disable-free -clear-ast-before-backend -main-file-name some.cppm -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/sha512sum/reproduce -fcoverage-compilation-dir=/home/sha512sum/reproduce -resource-dir /usr/lib/llvm/19/bin/../../../../lib/clang/19 -include /usr/include/gentoo/fortify.h -include /usr/include/gentoo/maybe-stddefs.h -D _GLIBCXX_ASSERTIONS -D _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -internal-isystem /usr/include/c++/v1 -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /usr/lib/llvm/19/bin/../../../../lib/clang/19/include -std=c++23 -fdeprecated-macro -ferror-limit 19 -fmessage-length=170 -stack-protector 2 -fstack-clash-protection -fcf-protection=none -fgnuc-version=4.2.1 -fno-implicit-modules -fmodule-file=other=/home/sha512sum/reproduce/other.pcm -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -no-round-trip-args -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /home/sha512sum/reproduce/some.cppm
I[17:37:17.356] Building preamble...
I[17:37:18.718] Built preamble of size 16404480 for file /home/sha512sum/reproduce/some.cppm version null in 1.36 seconds
I[17:37:18.718] Indexing headers...
V[17:37:18.883] indexed preamble AST for /home/sha512sum/reproduce/some.cppm version null:
  symbol slab: 11128 symbols, 3028280 bytes
  ref slab: 0 symbols, 0 refs, 128 bytes
  relations slab: 534 relations, 17432 bytes
V[17:37:18.918] Build dynamic index for header symbols with estimated memory usage of 7701696 bytes
I[17:37:18.927] Building AST...
Assertion failed: hasODRHash() (/var/tmp/portage/sys-devel/clang-19.0.0.9999/work/clang/lib/AST/Decl.cpp: getODRHash: 4501)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /usr/lib/llvm/19/bin/clangd --check=some.cppm -log=verbose
1.  <eof> parser at end of file
Aborted

other.cppm:

module;
#include <gtest/gtest.h>
export module other;

some.cppm:

module;
#include <gtest/gtest.h>
export module some;
import other;

other_preprocessed.txt some_preprocessed.txt

ChuanqiXu9 commented 4 months ago

@linuxnyasha can you try again with newest commit?

linuxnyasha commented 4 months ago

@linuxnyasha can you try again with newest commit?

The error is gone, but the ODR check remains

I[15:06:14.902] Building AST...
E[15:06:14.929] [module_odr_violation_record] Line 4: in included file: 'testing::internal::ParameterizedTestSuiteInfoBase' has different definitions in different modules; first difference is definition in module 'other.<global>' found constructor with body
I[15:06:14.929] Indexing AST...
V[15:06:14.930] indexed file AST for /home/sha512sum/reproduce/some.cppm version null:
  symbol slab: 0 symbols, 120 bytes
  ref slab: 0 symbols, 0 refs, 128 bytes
  relations slab: 0 relations, 24 bytes
V[15:06:14.930] Build dynamic index for main-file symbols with estimated memory usage of 248 bytes
I[15:06:14.930] Building inlay hints
I[15:06:14.930] Building semantic highlighting
I[15:06:14.930] Testing features at each token (may be slow in large files)
V[15:06:14.930]   0:0 module
V[15:06:14.930]     tweak: ExpandMacro
V[15:06:14.930] Word module under cursor /home/sha512sum/reproduce/some.cppm:1:1 isn't a token (after PP), trying nearby /home/sha512sum/reproduce/some.cppm:3:8
V[15:06:14.930] No definition found using nearby identifier module at /home/sha512sum/reproduce/some.cppm:1:1
V[15:06:14.930] Dex query tree: (LIMIT 1000 (& T=dul T=mod T=odu T=ule (| S= (* 2.000000e-01 true)) (| (* 1.403793e+00 U=file:///) true)))
V[15:06:14.930] No heuristic index definition for module
V[15:06:14.930]     definition: 0
V[15:06:14.930]     hover: false
V[15:06:14.930]     documentHighlight: 0
V[15:06:14.930]   0:6 ;
V[15:06:14.930]     tweak: ExpandMacro
V[15:06:14.930] Word module under cursor /home/sha512sum/reproduce/some.cppm:1:1 isn't a token (after PP), trying nearby /home/sha512sum/reproduce/some.cppm:3:8
V[15:06:14.930] No definition found using nearby identifier module at /home/sha512sum/reproduce/some.cppm:1:1
V[15:06:14.930] Dex query tree: (LIMIT 1000 (& T=dul T=mod T=odu T=ule (| S= (* 2.000000e-01 true)) (| (* 1.403793e+00 U=file:///) true)))
V[15:06:14.930] No heuristic index definition for module
V[15:06:14.930]     definition: 0
V[15:06:14.930]     hover: false
V[15:06:14.930]     documentHighlight: 0
V[15:06:14.930]   1:0 #
V[15:06:14.930]     definition: 1
V[15:06:14.930]     hover: true
V[15:06:14.930]     documentHighlight: 0
V[15:06:14.930]   1:1 include
V[15:06:14.930]     definition: 1
V[15:06:14.930]     hover: true
V[15:06:14.930]     documentHighlight: 0
V[15:06:14.930]   1:9 <
V[15:06:14.930]     definition: 1
V[15:06:14.930]     hover: true
V[15:06:14.930]     documentHighlight: 0
V[15:06:14.930]   1:10 gtest
V[15:06:14.930]     definition: 1
V[15:06:14.930]     hover: true
V[15:06:14.930]     documentHighlight: 0
V[15:06:14.930]   1:15 /
V[15:06:14.930]     definition: 1
V[15:06:14.930]     hover: true
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   1:16 gtest
V[15:06:14.931]     definition: 1
V[15:06:14.931]     hover: true
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   1:21 .
V[15:06:14.931]     definition: 1
V[15:06:14.931]     hover: true
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   1:22 h
V[15:06:14.931]     definition: 1
V[15:06:14.931]     hover: true
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   1:23 >
V[15:06:14.931]     definition: 1
V[15:06:14.931]     hover: true
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   2:0 export
V[15:06:14.931]     definition: 0
V[15:06:14.931]     hover: false
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   2:7 module
V[15:06:14.931]     definition: 0
V[15:06:14.931]     hover: false
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   2:14 some
V[15:06:14.931]     definition: 0
V[15:06:14.931]     hover: false
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   2:18 ;
V[15:06:14.931]     definition: 0
V[15:06:14.931]     hover: false
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   3:0 import
V[15:06:14.931]     definition: 0
V[15:06:14.931]     hover: false
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   3:7 other
V[15:06:14.931]     definition: 0
V[15:06:14.931]     hover: false
V[15:06:14.931]     documentHighlight: 0
V[15:06:14.931]   3:12 ;
V[15:06:14.931]     definition: 0
V[15:06:14.931]     hover: false
V[15:06:14.931]     documentHighlight: 0
I[15:06:14.931] All checks completed, 1 errors
ChuanqiXu9 commented 4 months ago

Could you please pull and try again?

linuxnyasha commented 4 months ago

Fixed

linuxnyasha commented 4 months ago

[module_odr_violation_missing_decl] Line 2: in included file: 'std::basic_ostream::~basic_ostream' from module '' is not present in definition of 'std::basic_ostream' in module 'some.'

I still get errors like these. (Other code)

ChuanqiXu9 commented 3 months ago

[module_odr_violation_missing_decl] Line 2: in included file: 'std::basic_ostream::~basic_ostream' from module '' is not present in definition of 'std::basic_ostream' in module 'some.'

I still get errors like these. (Other code)

What's the reproducer?

linuxnyasha commented 3 months ago

[module_odr_violation_missing_decl] Line 2: in included file: 'std::basic_ostream::~basic_ostream' from module '' is not present in definition of 'std::basic_ostream' in module 'some.' I still get errors like these. (Other code)

What's the reproducer?

https://github.com/linuxnyasha/utempl/blob/main/tests/menu.cpp