Skip to content

Name the source file in error messages by the path it was given - #1457

Open
helixsolara wants to merge 1 commit into
hsutter:mainfrom
helixsolara:error-path-as-given
Open

helixsolara wants to merge 1 commit into
hsutter:mainfrom
helixsolara:error-path-as-given

Conversation

@helixsolara

Copy link
Copy Markdown

cppfront prints errors with strip_path(sourcefile), the file name without its folder. Build systems run cppfront in an output folder (a CMake custom command, an MSBuild step), so an IDE reading the build output, such as Visual Studio's Error List or a VS Code problem matcher, can't find the file an error names.

Change
Errors now print the source path as cppfront was given it: a full path stays full, a relative one stays relative. strip_path had no other caller and is removed.

Given the full path to sub\bad.cpp2:

before: bad.cpp2(3,14): error: empty statement is not allowed - remove extra semicolon (at ';')
after:  C:\...\sub\bad.cpp2(3,14): error: empty statement is not allowed - remove extra semicolon (at ';')

Tests
All 191 regression tests transpile to the same .cpp and .cpp2.output as before, since run-tests.sh passes bare file names. No regression test covers a path with folders, which run-tests.sh doesn't have a way to express; happy to add one if you'd like a particular form.

🤖 Generated with Claude Code

cppfront printed errors with strip_path(sourcefile), the file name without its folder. Build systems run cppfront in an output folder (CMake custom commands, MSBuild steps), so an IDE reading the build output, such as Visual Studio's Error List or VS Code's problem matchers, can't find the file an error names. Errors now print the source path as cppfront was given it, so a full path stays full and a relative one stays relative. strip_path had no other caller and is removed.

Given the full path to sub\bad.cpp2, cppfront used to print "bad.cpp2(3,14): error: ..."; it now prints the full path, and given sub/bad.cpp2 it prints that. All 191 regression tests transpile to the same .cpp and .cpp2.output, since run-tests.sh passes bare file names. No regression test covers a path with folders, which run-tests.sh can't express.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

1 participant