4 Commits
Author SHA1 Message Date
Martin Vogel b87d067637 fix(cpp): one spelling per template specialization in the preprocessed pass
The preprocessed second pass rebuilt the expanded source with simplecpp's
TokenList::stringify(), which puts one space between every pair of tokens:
`template<> struct bitonic<int64_t, AVX2>` became
`bitonic < int64_t , AVX2 >`. Every QN builder takes the class segment from
node text, so a definition the #961 rescue re-adopted from that buffer
(vxsort's INLINE/NOINLINE macros break the raw parse on every method line)
got a second, token-spaced QN, and the QN-equality dedup kept both. CALLS
split across the two spellings (dotnet/runtime: 902 compact + 996 spaced
into the bitonic sorters).

The expanded buffer now keeps the source spacing: tokens that touched in
the source (same file and line, no macro expansion between them) stay
touching, every other gap is still one space, and the line structure and
#line directives are unchanged, so every line remap holds. One fix point
instead of a normaliser at each QN builder; no vendored code changes.

Proof (macOS arm64, dotnet/runtime 60108ba6, two identical runs each):
- duplicate definition groups 706 -> 217 (v0.11.0: 545); nodes with a
  token-spaced QN 495 -> 0; CALLS into bitonic 902 + 996 -> 998, one
  spelling. The remaining groups are coreclr gc.cpp's SVR/WKS builds (184)
  and 33 scope disagreements between the two parses.
- Side effect: rapidjson document.h's GenericValue members now exist once,
  with the raw parse's scope (the token-spaced copy that carried the
  nested scope is gone); `operator[]` / `operator()` in the expanded pass
  now parse as single tokens.
- New test (RED without the change): extraction
  extract_cpp_template_specialization_preprocessed_qn_single_spelling.
  Three c_lsp collision fixtures recalibrated to the new byte offsets
  (comment padding and offsets only, assertions unchanged).
- extraction, c_lsp, pipeline, edge_types_probe, parse_coverage,
  conditional_variants, lsp_resolution_probe: 1852 passed.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-13 18:33:40 +02:00
XIYBHK fcf451c6a6 fix(parsing): recover export-macro-hidden type definitions (#1989)
Collect a bounded set of conventional export macro candidates and inject empty definitions into the existing C/C++ preprocessing second pass without overriding explicit caller definitions.

Conservatively reconcile remapped definitions to recover hidden classes, structs, enums, free functions, and inline methods while suppressing matching base-class phantom callables.

Add focused regression coverage for supported suffixes, ordinary all-caps negative controls, candidate limits, comments, strings, raw strings, overlong names, explicit define priority, and C/C++ extraction.

Rebase onto main 92abefa3 and route the temporary superseded-definition bitmap through the extraction memory class to comply with the current allocation contract. Preserve the error-region dropped counter initialization.

Signed-off-by: XIYBHK <xiybhk@163.com>
2026-09-20 23:36:54 +08:00
Blank_Answer 99d39192cd fix(cpp): remap preprocessed recovery lines
Signed-off-by: Blank_Answer <97771966+blankanswer@users.noreply.github.com>
2026-07-13 05:21:54 +00:00
Martin Vogel a8daedf759 Add C/C++ hybrid LSP resolver with type-aware call resolution
Implement a tree-sitter-based type evaluator for C/C++ that resolves
method calls, template instantiations, and cross-file references without
requiring a full compiler. Covers ~95% of C and ~93% of moderate C++.

Key features:
- Type-aware overload resolution scoring by parameter types
- Lambda return type inference (trailing return + body deduction)
- Inline namespace normalization (__1, __cxx11, __gnu_cxx)
- Implicit conversions (char*->string, numeric promotions)
- Virtual dispatch with override preference
- CRTP detection and self-type resolution
- Range-for iterator protocol (maps, custom containers)
- Smart pointer arrow dispatch (unique_ptr, shared_ptr)
- Dependent member calls in templates via pending call resolution
- Explicit template argument substitution (make_shared<T>)
- Nested class scope resolution
- C/C++ stdlib type stubs (containers, strings, I/O, smart ptrs)
- Cross-file LSP with compile_commands.json support
- C/C++ parameter extraction via declarator chain traversal

63+ test cases covering all resolution strategies.
2026-03-13 00:07:28 +01:00