[flang-commits] [PATCH] D153910: [flang] Honor #line and related preprocessing directives

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Jun 28 08:03:11 PDT 2023


klausler added inline comments.


================
Comment at: flang/include/flang/Parser/source.h:75
+  struct SourcePositionOrigin {
+    const std::string &path;
+    int line;
----------------
domada wrote:
> nit: llvm::StringRef?
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.


================
Comment at: flang/lib/Parser/preprocessor.cpp:1131
+  const std::string *linePath{nullptr};
+  std::optional<int> lineNumber, thisTrueLineNumber;
+  SourceFile *sourceFile{nullptr};
----------------
kiranchandramohan wrote:
> Nit: `thisTrueLineNumber` is unused.
It is now indeed superfluous; thanks for noticing.


================
Comment at: flang/test/Parser/line-directive.f90:2
+! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s
+!CHECK: #line "{{.*}}/line-directive.f90" 3
+subroutine s
----------------
domada wrote:
> 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
DOS backslashes strike again.  Will fix.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153910/new/

https://reviews.llvm.org/D153910



More information about the flang-commits mailing list