Skip to content

fix: source file paths are normalized - #1318

Open
gennaroprota wants to merge 1 commit into
cppalliance:developfrom
gennaroprota:fix/source_file_paths_are_normalized
Open

gennaroprota wants to merge 1 commit into
cppalliance:developfrom
gennaroprota:fix/source_file_paths_are_normalized

Conversation

@gennaroprota

@gennaroprota gennaroprota commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

This fixes a bug for which an include file reached from an input directory through e.g. #include "../vendor/x.hpp" was taken to lie inside that directory. Its symbols were documented as the project's own, exclude could not reach it, and its path read api/../vendor/x.hpp.

The compiler records the includer's directory joined with what the include spells out, ".." and all. Such an unnormalized path was normalized when the compiler recorded it as relative, on its way to being made absolute, but not when it recorded it as absolute, which is what a compilation database produces, as does the one synthesized from the configuration. This normalizes it there, too. The normalization is lexical, like the one already applied to relative paths, so it resolves no symlinks, and exclude still matches a path only as written.

Changes

  • Source: ASTVisitor::buildFileInfo normalizes a source file path the compiler recorded as absolute, as it already did for one recorded as relative.
  • Tests: Unit tests that build a real corpus over a temporary tree, one for an include file outside the inputs and one for an include file inside an exclusion.
  • Breaking changes: The reference of a project with include files reached through ".." can change. Symbols from files outside input that were documented by mistake disappear, exclude now applies to such files, and their paths are shown normalized.

Testing

tests/unit/AST/FileFilters.cpp adds testUnnormalizedPathOutsideTheInputs and testUnnormalizedPathInsideAnExclusion, and both fail without the fix. The golden harness cannot cover this: it hands the compiler each fixture by a relative name, so every path the compiler records is relative, and those were normalized already. The golden output is unchanged.

Documentation

None needed. input and exclude are documented as selecting "files in these directories", which is what they now do for an include file reached through "..".

This fixes a bug for which an include file reached from an input
directory through e.g. `#include "../vendor/x.hpp"` was taken to lie
inside that directory. Its symbols were documented as the project's own,
`exclude` could not reach it, and its path read `api/../vendor/x.hpp`.

The compiler records the includer's directory joined with what the
include spells out, ".." and all. Such an unnormalized path was
normalized when the compiler recorded it as relative, on its way to
being made absolute, but not when it recorded it as absolute, which is
what a compilation database produces, as does the one synthesized from
the configuration. Normalize it there, too.

The golden harness names each fixture relatively, so it never sees such
a path; the new tests build a real corpus instead.
@github-actions

Copy link
Copy Markdown
Contributor

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🧪 Unit Tests 94% 132 132 - 1 1 - - -
🛠️ Source 6% 9 9 - 1 - 1 - -
Total 100% 141 141 - 2 1 1 - -

Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)

🔝 Top Files

  • tests/unit/AST/FileFilters.cpp (Unit Tests): 132 lines Δ (+132 / -0)
  • src/mrdocs/AST/ASTVisitor.cpp (Source): 9 lines Δ (+9 / -0)

Generated by 🚫 dangerJS against 2f893bf

@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.12%. Comparing base (1a0bbac) to head (2f893bf).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1318   +/-   ##
========================================
  Coverage    83.12%   83.12%           
========================================
  Files           35       35           
  Lines         3662     3662           
  Branches       844      844           
========================================
  Hits          3044     3044           
  Misses         410      410           
  Partials       208      208           
Flag Coverage Δ
bootstrap 83.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1318.mrdocs.prtest2.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-09-23 09:35:29 UTC

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants