Repository navigation
Commit 55cdc57
committed
Improve performance of virtualDestructor check
CheckClassImpl::virtualDestructor() scanned the whole variable list and
the whole token list for every (derived class, public base class) pair.
With many template instantiations (for example etl) this took up to 26%
of the analysis time.
When the first base class is checked, the pointer variables of each type
are collected and a single pass over the tokens records, for each pointer
variable, the classes 'Derived' of a "ptr = new Derived" that is followed
by a "delete ptr;". Checking a pair is then a lookup.
This also fixes a false negative: the name of a template instantiation
such as 'Derived < int >' is a single token that contains spaces, so the
old pattern "new Derived < int >" never matched it and the pair was never
reported.
On a project using etl, glaze and Catch2 (211 translation units in two
configurations) total CPU time drops from 88.7 to 61.6 minutes, with
identical output for every translation unit.1 parent 07254e9 commit 55cdc57
2 files changed
Lines changed: 72 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2025 | 2025 | | |
2026 | 2026 | | |
2027 | 2027 | | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
2028 | 2061 | | |
2029 | 2062 | | |
2030 | 2063 | | |
| |||
2073 | 2106 | | |
2074 | 2107 | | |
2075 | 2108 | | |
2076 | | - | |
2077 | | - | |
| 2109 | + | |
2078 | 2110 | | |
2079 | | - | |
2080 | | - | |
2081 | | - | |
2082 | | - | |
2083 | | - | |
2084 | | - | |
2085 | | - | |
2086 | | - | |
2087 | | - | |
2088 | | - | |
2089 | | - | |
2090 | | - | |
2091 | | - | |
2092 | | - | |
2093 | | - | |
2094 | | - | |
2095 | | - | |
2096 | | - | |
2097 | | - | |
2098 | | - | |
2099 | | - | |
2100 | | - | |
2101 | | - | |
2102 | | - | |
2103 | | - | |
2104 | | - | |
2105 | | - | |
2106 | | - | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
2107 | 2115 | | |
2108 | 2116 | | |
2109 | | - | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
2110 | 2121 | | |
2111 | 2122 | | |
2112 | 2123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2839 | 2839 | | |
2840 | 2840 | | |
2841 | 2841 | | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
2842 | 2872 | | |
2843 | 2873 | | |
2844 | 2874 | | |
| |||
0 commit comments