cpp_code_analysis 0.2.0

The analysis layer of cpp_ls: the preprocessor, symbol scopes, type inference and the semantic checks.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
//! **A measurement of the C++ corpus** — one line per file, one line per member question, one line per type question.
//!
//! ```text
//! cargo test --release -p cpp_code_analysis --test cpp_corpus -- --ignored --nocapture
//! $env:CPPLS_CPP_CORPUS = "C:\Users\zc\Desktop\cpp_project"   # the default
//! ```
//!
//! The corpus is a real project: `CMakeLists.txt` builds it with MinGW's g++ 15 in C++23 mode, and
//! `build/compile_commands.json` carries `-std=c++23`. Every construct in it is one the compiler accepted, which is
//! what makes a diagnostic here a defect of the analysis rather than of the file.
//!
//! # The three questions
//!
//! ```text
//! parse     does each file read without a syntax error, and how many declarations did it produce?
//! members   for each `x.member` / `x->member` a reader is likely to ask about, is `member` in the list the editor shows?
//! types     for each declaration, is the declared name's type the one the file wrote?
//! ```

use std::collections::BTreeMap;
use std::path::{Path, PathBuf};

use cpp_code_analysis::file::coordinates::FileOffset;
use cpp_code_analysis::{DiskFiles, Known, OpenDocuments, Session, SessionFiles, WatchFilter};

fn corpus_root() -> Option<PathBuf> {
    let named = std::env::var_os("CPPLS_CPP_CORPUS")
        .map(PathBuf::from)
        .unwrap_or_else(|| PathBuf::from(r"C:\Users\zc\Desktop\cpp_project"));
    named.join("main.cpp").is_file().then_some(named)
}

/// **One member question**: the file, the expression whose operator the cursor goes after, and the member expected.
struct MemberRow {
    file: &'static str,
    needle: &'static str,
    expected: &'static str,
}

/// **One type question**: the file, a piece of text that contains the declared name, the name itself, and what the
/// type is expected to contain.
struct TypeRow {
    file: &'static str,
    needle: &'static str,
    name: &'static str,
    expected: &'static str,
}

const MEMBERS: &[MemberRow] = &[
    // **SFINAE and the detection idiom**: the class template`'s own members, and a partially specialised one.
    MemberRow {
        file: "src/techniques.cpp",
        needle: "box.get()",
        expected: "get",
    },
    MemberRow {
        file: "src/techniques.cpp",
        needle: "box.set(9)",
        expected: "set",
    },
    MemberRow {
        file: "src/techniques.cpp",
        needle: "first.self()",
        expected: "self",
    },
    // The deduced `Box box(7)`: the deduction guide is what gives it a type at all.
    MemberRow {
        file: "src/techniques.cpp",
        needle: "box.get()",
        expected: "get",
    },
    // A standard container, through the template function that deduced it.
    MemberRow {
        file: "src/techniques.cpp",
        needle: "numbers.front()",
        expected: "front",
    },
    // **The shapes a reader meets next** — `std::optional`'s own members, and a `std::function` called.
    MemberRow {
        file: "src/techniques.cpp",
        needle: "maybe.has_value()",
        expected: "has_value",
    },
    MemberRow {
        file: "src/techniques.cpp",
        needle: "maybe->size()",
        expected: "size",
    },
    MemberRow {
        file: "src/techniques.cpp",
        needle: "number.value_or(0)",
        expected: "value_or",
    },
    MemberRow {
        file: "src/techniques.cpp",
        needle: "maybe.value()",
        expected: "value",
    },
    // **An inherited member**, reached through the instance of the derived class.
    MemberRow {
        file: "src/techniques.cpp",
        needle: "derived.base_value",
        expected: "base_value",
    },
];

const TYPES: &[TypeRow] = &[
    TypeRow {
        file: "src/techniques.cpp",
        needle: "techniques::Box<int> box",
        name: "box",
        expected: "Box<int>",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "const std::vector<int> numbers",
        name: "numbers",
        expected: "vector<int>",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "techniques::Box box(7)",
        name: "box",
        expected: "Box<int>",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "Widget widget;",
        name: "widget",
        expected: "Widget",
    },
    // The two `std::optional` declarations: what the *name* is typed as, before any member question.
    TypeRow {
        file: "src/techniques.cpp",
        needle: "std::optional<std::string> maybe",
        name: "maybe",
        expected: "optional",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "std::optional<int> number",
        name: "number",
        expected: "optional",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "std::function<int(int, int)> operation",
        name: "operation",
        expected: "function",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto copied = box.copy_of()",
        name: "copied",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto doubled = box.doubled()",
        name: "doubled",
        expected: "int",
    },
    // **A fold expression over a pack**: `(values + ...)` of four `int`s is an `int`, and of `int + double` a `double`.
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto total = techniques::sum_of(1, 2, 3, 4)",
        name: "total",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto mixed = techniques::sum_of(1, 2.5)",
        name: "mixed",
        expected: "double",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto [number, fraction] = pair",
        name: "number",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto result = doubler(3)",
        name: "result",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto found = counts[\"a\"]",
        name: "found",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto widened = true ? 1 : 2.0",
        name: "widened",
        expected: "double",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto allocated = new Closing{}",
        name: "allocated",
        expected: "Closing*",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "for (const auto& [key, value] : table)",
        name: "value",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "decltype(auto) same = widen_gently(1)",
        name: "same",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto through_pointer = fp(3)",
        name: "through_pointer",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto cut = text.substr(1, 2)",
        name: "cut",
        // **The instantiation, not the alias**: `substr` is declared to return `basic_string`, the injected-class-name,
        // so the answer is the class with the receiver's own arguments.
        expected: "basic_string<char",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto shared = Holder::instances",
        name: "shared",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto nine = operation(3, 6)",
        name: "nine",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto held = std::get<int>(either)",
        name: "held",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "constexpr int kMax = 10",
        name: "kMax",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto from_constant = doubled_constant(kMax)",
        name: "from_constant",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "constinit static int counter = 0",
        name: "counter",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "Count count = 3",
        name: "count",
        // **The alias name is the answer**: a C++ toolchain shows `Count` here, because that is the spelling the
        // declaration used and the name the reader wrote.
        expected: "Count",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "Fraction fraction = 0.5",
        name: "fraction",
        expected: "Fraction",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto colour = Colour::Red",
        name: "colour",
        expected: "Colour",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto bytes = sizeof(int)",
        name: "bytes",
        expected: "size_t",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto printed = std::to_string(count)",
        name: "printed",
        expected: "string",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "Outer::Inner nested",
        name: "nested",
        expected: "Inner",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto owned = std::make_unique<Closing>()",
        name: "owned",
        expected: "unique_ptr",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto described = derived.describe()",
        name: "described",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto sum = a + b",
        name: "sum",
        expected: "Money",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto same = (a == b)",
        name: "same",
        expected: "bool",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto one_pair = pairs.front()",
        name: "one_pair",
        expected: "pair<int, double>",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto raw = widget.raw()",
        name: "raw",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto stored = the_widget().stored",
        name: "stored",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto first = pair.first",
        name: "first",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto second = pair.second",
        name: "second",
        expected: "double",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto first_fixed = fixed.front()",
        name: "first_fixed",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto view_size = view.size()",
        name: "view_size",
        expected: "size_t",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto inside = maybe.has_value()",
        name: "inside",
        expected: "bool",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto squared = square_of(3)",
        name: "squared",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto from_the_macro = techniques_macros::doubled(21)",
        name: "from_the_macro",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto owned_size = owned->reason.size()",
        name: "owned_size",
        expected: "size_t",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto called = doubler(5)",
        name: "called",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto found = counts.at(\"x\")",
        name: "found",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto taken = maybe.value_or(7)",
        name: "taken",
        expected: "int",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto total = techniques_app::total_area(shapes)",
        name: "total",
        expected: "double",
    },
    TypeRow {
        file: "src/techniques.cpp",
        needle: "auto described = techniques_app::describe(*shapes.front())",
        name: "described",
        expected: "int",
    },
];

fn corpus_files(root: &Path) -> Vec<PathBuf> {
    let opened = Session::open(
        root.to_path_buf(),
        SessionFiles::new(OpenDocuments::new(), DiskFiles),
        WatchFilter::new(root),
    );
    let mut files: Vec<PathBuf> = opened
        .project_files()
        .iter()
        .filter(|path| {
            matches!(
                path.extension().and_then(|extension| extension.to_str()),
                Some("cpp" | "h")
            )
        })
        .filter(|path| !path.components().any(|part| part.as_os_str() == "build"))
        .cloned()
        .collect();
    files.sort();
    files
}

fn name_of(path: &Path) -> String {
    path.strip_prefix(path.ancestors().nth(2).unwrap_or(path))
        .unwrap_or(path)
        .display()
        .to_string()
        .replace('\\', "/")
}

fn member_labels(session: &Session<DiskFiles>, path: &Path, cursor: usize) -> Vec<String> {
    let Some(view) = session.view(path) else {
        return Vec::new();
    };
    session
        .completions(&view, FileOffset::new(cursor))
        .items
        .into_iter()
        .map(|item| item.label)
        .collect()
}

fn declared_type(session: &Session<DiskFiles>, path: &Path, cursor: usize) -> Option<String> {
    let view = session.view(path)?;
    let reading = view.reading_offset_of(FileOffset::new(cursor))?;
    match session.type_at(&view, reading) {
        Known::Yes(found) => Some(found.type_of.to_string()),
        // **An unknown is not a type**: the probe's pass rule is "the answer contains the expected spelling", and
        // `<unknown: `std::get<int>` is declared more than once…>` contains `int` — so an unknown answer passed a row that
        // asked for `int`. Measured: it did exactly that.
        Known::Unknown(_) => None,
        Known::No => None,
    }
}

#[test]
#[ignore = "opens a real project; run with --ignored"]
fn the_cpp_corpus_parses_and_its_members_resolve() {
    let Some(root) = corpus_root() else {
        eprintln!("skipped: no corpus (set CPPLS_CPP_CORPUS to the cpp_project project)");
        return;
    };
    let files = corpus_files(&root);
    println!(
        "\n=== the corpus: {} file(s) under {}",
        files.len(),
        root.display()
    );

    let mut session = Session::open(
        root.clone(),
        SessionFiles::new(OpenDocuments::new(), DiskFiles),
        WatchFilter::new(&root),
    );
    session.add_project_files(files.clone());
    let indexing = std::time::Instant::now();
    session.index_everything();
    let mut steps = 0usize;
    while session.pending_work() > 0 && steps < 20_000 {
        session.advance(64);
        steps += 1;
    }
    println!("indexed in {:?} ({steps} step(s))", indexing.elapsed());

    println!("\n--- parse: one line per file");
    let mut files_with_errors = 0usize;
    let mut total_errors = 0usize;
    let mut declarations = 0usize;
    for path in &files {
        let Ok(text) = std::fs::read_to_string(path) else {
            println!("  {:<30} unreadable", name_of(path));
            continue;
        };
        let started = std::time::Instant::now();
        let cooked = session.cook(path).is_some();
        // **The pump, between the cook and the questions.** The design note's contract is "answer from L1, ask for L2":
        // a reading that is still shape-only becomes exact once the pump has run. `CPPLS_CORPUS_PUMP=1` asks the
        // questions after it, which is the difference between "this session cannot refine" and "it has not yet".
        if std::env::var_os("CPPLS_CORPUS_PUMP").is_some() {
            session.catch_up(path);
            let mut slices = 0usize;
            while session.pending_work() > 0 && slices < 400 {
                if session.advance(64).is_empty() {
                    break;
                }
                slices += 1;
            }
            let _ = session.cook(path);
        }
        let cooking = started.elapsed();
        let found = session.diagnostics(path);
        let errors = found.as_ref().map(|found| found.errors.len()).unwrap_or(0);
        let checks = found.as_ref().map(|found| found.checks.len()).unwrap_or(0);
        total_errors += errors;
        if errors > 0 {
            files_with_errors += 1;
        }
        let bound = session
            .parsed_summary(path)
            .map(|summary| summary.declarations.len())
            .unwrap_or(0);
        declarations += bound;
        println!(
            "  {:<30} {:>3} error(s)  {:>3} finding(s)  {:>5} decl  {:>5} ms  {:>4} line(s){}",
            name_of(path),
            errors,
            checks,
            bound,
            cooking.as_millis(),
            text.lines().count(),
            if cooked { "" } else { "  NOT COOKED" }
        );
        if let Some(found) = &found {
            let mut by_code: BTreeMap<&str, Vec<&cpp_code_analysis::Finding>> = BTreeMap::new();
            for check in &found.checks {
                by_code.entry(check.code.name()).or_default().push(check);
            }
            let all = std::env::var_os("CPPLS_C_ALL").is_some();
            for (code, entries) in by_code {
                println!("      [{code}] {} finding(s)", entries.len());
                let shown = if all { entries.len() } else { 3 };
                for check in entries.iter().take(shown) {
                    let from = check.range.start_offset.saturating_sub(48).min(text.len());
                    println!(
                        "        …{}«{}»…  ← {}",
                        text[from..check.range.start_offset].replace('\n', " "),
                        text[check.range.start_offset..check.range.end_offset().min(text.len())]
                            .replace('\n', " "),
                        check.message.chars().take(80).collect::<String>()
                    );
                }
            }
            for error in found.errors.iter().take(6) {
                // **The line, not a byte window.** A parse error's offset can sit on a newline or at the end of the
                // token that failed, and a window then shows nothing around it; the line the offset is on is what a
                // reader can point at.
                let at = error.start.min(text.len());
                let line = text[..at].bytes().filter(|byte| *byte == b'\n').count() + 1;
                let from = text[..at].rfind('\n').map_or(0, |newline| newline + 1);
                let to = text[at..]
                    .find('\n')
                    .map_or(text.len(), |newline| at + newline);
                println!(
                    "      parse: line {line}: {}  ← {}",
                    text[from..to].trim(),
                    error.message.chars().take(90).collect::<String>()
                );
            }
        }
    }
    println!(
        "  totals: {} file(s), {} with a syntax error, {} error(s), {} declaration(s)",
        files.len(),
        files_with_errors,
        total_errors,
        declarations
    );

    for path in &files {
        if session.view(path).is_none() && session.cook(path).is_none() {
            println!("  WARN  {} has no reading to ask about", path.display());
        }
    }

    println!("\n--- members: the completion at the position right after `.` / `->`");
    let mut member_failures = 0usize;
    for row in MEMBERS {
        let path = root.join(row.file);
        let Ok(text) = std::fs::read_to_string(&path) else {
            println!("  SKIP  {:<24} {} (unreadable)", row.file, row.needle);
            continue;
        };
        let Some(found_at) = text.find(row.needle) else {
            println!("  SKIP  {:<24} {} (not written)", row.file, row.needle);
            member_failures += 1;
            continue;
        };
        let operator_at = row
            .needle
            .find("->")
            .or_else(|| row.needle.find('.'))
            .expect("every member row names an operator");
        let width = if row.needle[operator_at..].starts_with("->") {
            2
        } else {
            1
        };
        let cursor = found_at + operator_at + width;

        if session.view(&path).is_none() {
            session.cook(&path);
        }
        let labels = member_labels(&session, &path, cursor);
        let pass = labels.iter().any(|label| label == row.expected);
        if !pass {
            member_failures += 1;
        }
        println!(
            "  {:<4}  {:<28} {:<26} {:>3} offered  {}",
            if pass { "PASS" } else { "FAIL" },
            row.file,
            row.needle,
            labels.len(),
            if pass {
                String::new()
            } else if labels.is_empty() {
                format!("nothing offered — `{}` is not reachable", row.expected)
            } else {
                format!(
                    "`{}` missing from {:?}",
                    row.expected,
                    labels.iter().take(10).collect::<Vec<_>>()
                )
            }
        );
    }

    println!("\n--- types: `type_at` with the cursor inside the declared name");
    let mut type_failures = 0usize;
    for row in TYPES {
        let path = root.join(row.file);
        let Ok(text) = std::fs::read_to_string(&path) else {
            println!("  SKIP  {:<24} {}", row.file, row.needle);
            continue;
        };
        let Some(found_at) = text.find(row.needle) else {
            println!("  SKIP  {:<24} {} (not written)", row.file, row.needle);
            type_failures += 1;
            continue;
        };
        let Some(name_at) = row.needle.find(row.name) else {
            println!(
                "  SKIP  {:<24} {} (the name is not in the needle)",
                row.file, row.needle
            );
            continue;
        };
        let cursor = found_at + name_at + 1;
        if session.view(&path).is_none() {
            session.cook(&path);
        }
        let answer = declared_type(&session, &path, cursor);
        let pass = answer
            .as_deref()
            .is_some_and(|answ| answ.contains(row.expected));
        if !pass {
            type_failures += 1;
        }
        println!(
            "  {:<4}  {:<28} {:<20} → {}",
            if pass { "PASS" } else { "FAIL" },
            row.file,
            row.name,
            answer.unwrap_or_else(|| "<no type>".to_string())
        );
    }

    if std::env::var_os("CPPLS_C_MEMBERS").is_some()
        && let Some(view) = session.view(root.join("src/strings.cpp"))
    {
        println!(
            "\n[members] config standard: {:?}",
            session.config().standard
        );
        for spelling in ["std::string_view", "std::string", "std::future"] {
            match session.members_of(&view, spelling) {
                Known::Yes(list) => println!(
                    "\n[members] {spelling}: {} member(s), unlisted={}, has starts_with={}",
                    list.members.len(),
                    list.unlisted.len(),
                    list.members
                        .iter()
                        .any(|member| member.fact.name == "starts_with")
                ),
                Known::Unknown(reason) => println!("\n[members] {spelling}: unknown ({reason:?})"),
                Known::No => println!("\n[members] {spelling}: no"),
            }
        }
    }

    println!(
        "\n=== summary: {} file(s) ({} with errors), {}/{} members, {}/{} types",
        files.len(),
        files_with_errors,
        MEMBERS.len() - member_failures,
        MEMBERS.len(),
        TYPES.len() - type_failures,
        TYPES.len()
    );
}