21
21
-- imports
22
22
import (" core.base.option" )
23
23
import (" core.base.task" )
24
+ import (" core.base.semver" )
24
25
import (" core.project.config" )
25
26
import (" core.project.project" )
26
27
import (" lib.detect.find_tool" )
@@ -108,13 +109,35 @@ function _check_sourcefiles(clang_tidy, sourcefiles, opt)
108
109
if opt .quiet then
109
110
table.insert (argv , " --quiet" )
110
111
end
111
- for _ , sourcefile in ipairs (sourcefiles ) do
112
- if not path .is_absolute (sourcefile ) then
113
- sourcefile = path .absolute (sourcefile , projectdir )
112
+ -- https://github.com/llvm/llvm-project/pull/120547
113
+ if clang_tidy .version and semver .compare (clang_tidy .version , " 19.1.6" ) > 0 and # sourcefiles > 32 then
114
+ for _ , sourcefile in ipairs (sourcefiles ) do
115
+ if not path .is_absolute (sourcefile ) then
116
+ sourcefile = path .absolute (sourcefile , projectdir )
117
+ end
118
+ table.insert (argv , sourcefile )
119
+ end
120
+ local argsfile = os .tmpfile () .. " .args.txt"
121
+ io .writefile (argsfile , os .args (argv ))
122
+ argv = {" @" .. argsfile }
123
+ os .execv (clang_tidy .program , argv , {curdir = projectdir })
124
+ os .rm (argsfile )
125
+ elseif # sourcefiles <= 32 then
126
+ for _ , sourcefile in ipairs (sourcefiles ) do
127
+ if not path .is_absolute (sourcefile ) then
128
+ sourcefile = path .absolute (sourcefile , projectdir )
129
+ end
130
+ table.insert (argv , sourcefile )
131
+ end
132
+ os .execv (clang_tidy .program , argv , {curdir = projectdir })
133
+ else
134
+ for _ , sourcefile in ipairs (sourcefiles ) do
135
+ if not path .is_absolute (sourcefile ) then
136
+ sourcefile = path .absolute (sourcefile , projectdir )
137
+ end
138
+ os .execv (clang_tidy .program , table .join (argv , sourcefile ), {curdir = projectdir })
114
139
end
115
- table.insert (argv , sourcefile )
116
140
end
117
- os .execv (clang_tidy , argv , {curdir = projectdir })
118
141
end
119
142
120
143
-- do check
@@ -167,7 +190,7 @@ function main(argv)
167
190
168
191
-- find clang-tidy
169
192
local packages = {}
170
- local clang_tidy = find_tool (" clang-tidy" )
193
+ local clang_tidy = find_tool (" clang-tidy" , { version = true } )
171
194
if not clang_tidy then
172
195
table .join2 (packages , install_packages (" llvm" ))
173
196
end
@@ -179,17 +202,18 @@ function main(argv)
179
202
180
203
-- we need to force detect and flush detect cache after loading all environments
181
204
if not clang_tidy then
182
- clang_tidy = find_tool (" clang-tidy" , {force = true })
205
+ clang_tidy = find_tool (" clang-tidy" , {force = true , version = true })
183
206
end
184
207
assert (clang_tidy , " clang-tidy not found!" )
208
+ print (clang_tidy )
185
209
186
210
-- list checks
187
211
if args .list then
188
212
_show_list (clang_tidy .program )
189
213
elseif args .create then
190
214
_create_config (clang_tidy .program , args )
191
215
else
192
- _check (clang_tidy . program , args )
216
+ _check (clang_tidy , args )
193
217
end
194
218
os .setenvs (oldenvs )
195
219
end
0 commit comments