<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Reparse leads to extra diagnostic and removes skipped ranges"
href="https://bugs.llvm.org/show_bug.cgi?id=34570">34570</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Reparse leads to extra diagnostic and removes skipped ranges
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>libclang
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nikolai.kosjar@qt.io
</td>
</tr>
<tr>
<th>CC</th>
<td>klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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=</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>