llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.65k stars 11.85k forks source link

[preamble] Skipped ranges vanish after reparse (#ifdef with #include) #34319

Closed llvmbot closed 5 years ago

llvmbot commented 7 years ago
Bugzilla Link 34971
Resolution FIXED
Resolved on May 28, 2019 03:33
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @cameron314

Extended Description

Source file is:

% cat $FILE

ifdef SOMETHING

include

endif

Parse and save the tokens/skipping ranges:

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

Reparse and do the same:

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

Compare:

% diff -u /tmp/{1,2}
--- /tmp/1  2017-10-17 08:31:36.391408230 +0200
+++ /tmp/2  2017-10-17 08:32:01.215708503 +0200
@@ -1,4 +1,3 @@
-Skipping: [1:1 - 3:7]
 Punctuation: "#" [1:1 - 1:2] preprocessing directive=
 Identifier: "ifdef" [1:2 - 1:7] preprocessing directive=
 Identifier: "SOMETHING" [1:8 - 1:17] preprocessing directive=
zsh: exit 1     colordiff -u /tmp/{1,2}
% 

==> Ops, skipped ranges are removed after reparse.

llvmbot commented 5 years ago

Looks like this is fixed in clang-8.

cameron314 commented 7 years ago

Perhaps my patch at https://reviews.llvm.org/D20124 is of interest.