Don't use temporary file when creating tag files without running preprocessor
commit8c7081c652bd7a932138b749fd4da3731af01f4a
authorJiří Techet <techet@gmail.com>
Fri, 15 Apr 2022 16:44:18 +0000 (15 18:44 +0200)
committerJiří Techet <techet@gmail.com>
Sun, 28 Aug 2022 21:21:46 +0000 (28 23:21 +0200)
tree1afc57f75ac39b9c6a9b8d947b2af577b3385939
parent30f5514465e1e98383cff9dc7e88627f13aafd41
Don't use temporary file when creating tag files without running preprocessor

The tm_workspace_create_global_tags() function generates tags for
two cases:

1. Source files pre-processed by C pre-processor. It first generates
a file combining the parsed header files by creating a temporary
file in which all the header files are included and this file is passed
to the pre-processor. The result of the pre-processed file is then
parsed by the ctags parser.
2. Source files directly parsed by the ctags parser. In this case all
the source files are concatenated to a single file which is then parsed
by the ctags parser.

This patch leaves (1) more or less unchanged; however, the creation of
the temporary file in (2) is unnecessary - the individual files can
be parsed directly, the tags from all the parses can be combined, sorted
and pruned without creating the temporary file.

The temporary file is a problem for unit tests where some languages
use the file name as the name of module in which the tags are defined
and by using a different name, the unit test generates a different tag
file every time it's run.

Note the changed output of the process_order unit test caused by this
change. The test parses two files, one containing

enum {
I1_E1,
I1_E2,
};

the other contining

enum {
I2_E1,
I2_E2,
};

Previously, because the files were concatenated the enums were different
tags and the anonnymous tag renaming function renamed them to anon_enum_1
and anon_enum_2. Because now the files are parsed separately, the
enum from the first file gets renamed to anon_enum_1 and when parsing
the second file, we get the name anon_enum_1 as well for the second enum.
This however isn't a problem - we don't display global tags in the
symbol tree, autocompletion, and they are also ignored in scope completion
so this shouldn't matter much.
src/tagmanager/tm_workspace.c
tests/ctags/process_order.c.tags