lint's parse splits the compile command at spaces, where the shell that runs it honours quotes: a quoted flag with a space is one argument to the compile and two to the parse #59
Labels
No labels
bug
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Build#59
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
lint hands libclang the compile command as
CommandToArgssplits it: at every space, undoing only\"(implementations/Crafter.Build-Lint.cpp:358-383). The build runs the same string throughsh, which honours quotes. So acfg.compileFlagsentry that quotes a space for the shell is one argument to the compile, and since 6.4.2 to the scan, and two to lint's parse.Reproduce
project.cpp, with<dir>an absolute directory:<dir>/inc dir/greeting.h:main.cpp:crafter-build -rbuilds the program and runs it, which exits 0.crafter-build lintthen exits 1:Reproduced with
cb8914d(6.4.3) built natively. A-Dvalue quoted the same way,-DGREETING="hello world", is split as well, but libclang took the two halves without an error and lint passed.The comment on
CommandToArgssays a path containing a space "is already unsupported upstream of here" (:360-361). A flag the project quotes itself works everywhere but in lint.6.4.3's
Toolchain::InstalledClangxxreads the command's words the same way, split at spaces only (implementations/Crafter.Build-Toolchain.cpp:154-170), to find the last of-canonical-prefixesand-no-canonical-prefixes. clang's driver reads them from its arguments, after the shell has split the command and after it has expanded@filearguments (LLVM 23.1.2clang/tools/driver/driver.cpp:265,:280-291). So a-no-canonical-prefixesthat only a response file holds, or that acompileFlagsentry puts after a tab, is seen by the compile and not by the scan and the parse.Found by the pre-push review of 6.4.3.
Line numbers refer to
cb8914d(6.4.3).Proposal
Split the command as the shell does, single and double quotes and backslashes included, in one function that
CommandToArgsandInstalledClangxxboth use. Or keep the compile command as a list of arguments, from which the shell command and libclang's argv are both made, so that nothing has to split it back.