Page MenuHomePhabricator

[analyzer] Ignore flex generated files
Needs ReviewPublic

Authored by steakhal on Wed, Nov 24, 12:14 AM.



Some projects [1,2,3] have flex-generated files besides bison-generated ones.
Unfortunately, the comment "/* A lexical scanner generated by flex */"
generated by the tools is not necessarily at the beginning of the file,
thus we need to quickly skim through the file for this needle string.

Luckily, StringRef can do this operation in an efficient way.

That being said, now the bison comment is not required to be at the very
beginning of the file. This allows us to detect a couple more cases

Alternatively, we could say that we only allow whitespace characters
before matching the bison/flex header comment. That would prevent the
(probably) unnecessary string search in the buffer. However, I could not
verify that these tools would actually respect this assumption.

Additionally to this, e.g. the Twin project [1] has other non-whitespace
characters (some preprocessor directives) before the flex-generated
header comment. So the heuristic in the previous paragraph won't work with that.
Thus, I would advocate the current implementation.

According to my measurement, this patch won't introduce measurable performance degradation, even though we will do 2 linear scans.

I introduce the ignore-bison-generated-files and
ignore-flex-generated-files to disable skipping these files.
Both of these options are true by default.



Diff Detail

Event Timeline

steakhal created this revision.Wed, Nov 24, 12:14 AM
steakhal requested review of this revision.Wed, Nov 24, 12:14 AM
steakhal edited the summary of this revision. (Show Details)Wed, Nov 24, 12:19 AM

I wonder if this feature should be part of CodeChecker/scan-build instead (potentially under an option).

steakhal updated this revision to Diff 390010.Fri, Nov 26, 4:36 AM
steakhal edited the summary of this revision. (Show Details)

Added analyzer options disabling the skipping of bison and flex files.