fix: source file paths are normalized - #1318
Open
gennaroprota wants to merge 1 commit into
Open
gennaroprota wants to merge 1 commit into
gennaroprota wants to merge 1 commit into
Conversation
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.
Contributor
🧾 Changes by Scope
🔝 Top Files
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,excludecould not reach it, and its path readapi/../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
excludestill matches a path only as written.Changes
ASTVisitor::buildFileInfonormalizes a source file path the compiler recorded as absolute, as it already did for one recorded as relative.inputthat were documented by mistake disappear,excludenow applies to such files, and their paths are shown normalized.Testing
tests/unit/AST/FileFilters.cpp adds
testUnnormalizedPathOutsideTheInputsandtestUnnormalizedPathInsideAnExclusion, 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.
inputandexcludeare documented as selecting "files in these directories", which is what they now do for an include file reached through "..".