[llvm-bugs] [Bug 34570] New: Reparse leads to extra diagnostic and removes skipped ranges

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 12 02:12:58 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34570

            Bug ID: 34570
           Summary: Reparse leads to extra diagnostic and removes skipped
                    ranges
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nikolai.kosjar at qt.io
                CC: klimek at google.com, llvm-bugs at lists.llvm.org

The following code outlines the problems in the comments:

    #ifdef MYCPLUSPLUS
    extern "C" { // On parse this is skipped as expected. On reparse, this is
surprisingly not skipped anymore.
    #endif

    #ifdef MYCPLUSPLUS
    }
    #endif

    int main()
    {
        return 0;
    } // On reparse a diagnostic is added here: "expected '}' to match this '{'
(line 2)"

Here are some c-index-test invocations for this to make this
testable/reproducible ($FILE does not contain the above comments):

Do a parse and save the tokens:

    % ./c-index-test -test-annotate-tokens=$FILE:1:1:7:1 $FILE > /tmp/1

No diagnostics are emitted as expected.

Do a parse and reparse and save also the tokens:

    % CINDEXTEST_EDITING=1 ./c-index-test -test-annotate-tokens=$FILE:1:1:7:1
$FILE > /tmp/2
    $FILE:12:2: error: expected '}'
    Number FIX-ITs = 0
    $FILE:2:12: note: to match this '{'
    Number FIX-ITs = 0

Note that a new diagnostic is emitted on reparse at the bottom of the file
(issue1).
Also, the first skipped source range is not skipped anymore on reparse
(issue2):

    % diff -u /tmp/{1,2}
    --- /tmp/1  2017-09-12 09:33:42.210204021 +0200
    +++ /tmp/2  2017-09-12 09:33:51.458334870 +0200
    @@ -1,4 +1,3 @@
    -Skipping: [1:2 - 3:7]
     Skipping: [5:2 - 7:7]
     Punctuation: "#" [1:1 - 1:2] preprocessing directive=
     Identifier: "ifdef" [1:2 - 1:7] preprocessing directive=

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170912/4bf14cc9/attachment.html>


More information about the llvm-bugs mailing list