Extend the SourceFile class to take account of #line directives
when computing source file positions for error messages.
Adjust the output of #line directives to -E output so that they
reflect any #line directives that were in the input.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM.
Thank you for your patch.
I tested it, and it solves all issues connected with -save-temps flag, which were mentioned on LLVM discourse.
Could you fix one check statement in flang/test/Parser/line-directive.f90 which fails on Windows?
flang/include/flang/Parser/source.h | ||
---|---|---|
75 | nit: llvm::StringRef? | |
flang/test/Parser/line-directive.f90 | ||
3 | This check fails on Windows. Input was: <<<<<< 1: #line "C:\ws\w3\llvm-project\premerge-checks\flang\test\Parser\line-directive.f90" 3 check:2'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found check:2'1 ? possible intended match 2: subroutine s check:2'0 ~~~~~~~~~~~~~~ 3: implicit none check:2'0 ~~~~~~~~~~~~~~~ 4: a = 1. check:2'0 ~~~~~~~~ 5: #line 101 check:2'0 ~~~~~~~~~~ 6: b = 2. check:2'0 ~~~~~~~~ . . . >>>>>> Source: https://buildkite.com/llvm-project/premerge-checks/builds/160946#0188fefb-5134-482b-bece-1e8c7632b903 log line: 6653 |
flang/lib/Parser/preprocessor.cpp | ||
---|---|---|
1131 | Nit: thisTrueLineNumber is unused. |
flang/include/flang/Parser/source.h | ||
---|---|---|
75 | I use only standard C++ library features in parts of the compiler that people may want to use to build tooling outside the LLVM ecosystem, when those features are universally portable. | |
flang/lib/Parser/preprocessor.cpp | ||
1131 | It is now indeed superfluous; thanks for noticing. | |
flang/test/Parser/line-directive.f90 | ||
3 | DOS backslashes strike again. Will fix. |
Why? Nobody stops you from building flang-tools-extras with LSP-servers, refactoring, Flang-tidy you name it. Flang is in the LLVM monorepo. Why do you refuse to use LLVM data structures?
This kind of testing is the most useful kind of code review; thanks for confirming that your problem will be solved. I've updated the patch and it should now clear the pre-merge testing.
nit: llvm::StringRef?