clang-check generating plist files
In one of the recent (last couple of weeks) something changed and when I open a cpp file a new file is always generated. It always is a match for the cpp file IE. helper.cpp generates helper.plist. I did some digging and I think it is because clang-check isn't run on a tmp file but the original file itself. I ran clang-check using the arguments it runs with (Found those using ALEInfo) and the same bahaviour happens.
This has been mentioned before in other plugins: https://github.com/kumar8600/flycheck-clangcheck/issues/5
I don't know much about clang-check, but maybe you can just .gitignore those files. I don't know if you can disable generation of plist files or not.
I did some digging and if you add the arguments -extra-arg -Xanalyzer -extra-arg -analyzer-output=text to clang-check it will the the errors without generating the plist files. This will pass the -analyzer-output=text to the static analyzer. These args need to be beside each other and in that order.
I don't understand this behaviour. Can you point me where you found the solution and confirm the issue ?
I couldn't reproduce the behaviour on a project of mine, and running clang-check filename --analyze -p path/to/build or clang-check --analyze filename -p path/to/build only output the errors as expected and did not create new files in the folder where the file was (and my terminal/vim session was in the same folder)
For info :
$ clang-check --version
LLVM (http://llvm.org/):
LLVM version 5.0.0svn
Optimized build with assertions.
Default target: x86_64-unknown-linux-gnu
Host CPU: skylake
I built llvm from versioned source on Feb 6th
The issue occures when you don't have a build directory. This is the default implementation of clang-check in ale. It could be probably tuned for a case by case basis but that is very cumbersome especially if are editing multiple small projects. The invokation for clang-check in ale is (from ALEInfo)
/bin/bash -c clang-check -analyze <filename>
You could create a build directory or .gitignore the plist files.
Maybe those arguments for disabling the plist files could be added if no build directory is detected.
Personal opinion so please take it with a grain of salt. I think making it so that if no build directory is detected it adds those arguments is the best way to approach this problem. I'll try and learn som vim script to see if I can figure out how to fix this but vim script is a language I've never worked with.
It doesn't look too difficult to do then. As of now all clang linters check for l:user_build_dir twice :
- It starts by testing the presence of
ale_c_build_dir, and fills the local variable if ale_c_build_dir was set for the buffer - if
l:user_build_diris still empty, it looks for a folder containing the compilation database json in one of theale_c_build_dir_names - Then, if
l:user_build_diris still empty it uses the default behaviour (aka options for when no build directory is found)
So the block where to add these default options is clearly defined if I'm not mistaken :
Clang-check needs a little more work, since there is a ternary conditional operator instead of having a true if !empty(l:user_build_dir) block, but it should not be very hard to implement, I'll eventually do it when I have time, but if you want to play with a little vimscript and do proper PRs, this feels like a good example to try :)
Yeah, I think setting those options if the build directory isn't detected is the way to go. If we find one, then we won't generate the files because we're using the build directory. If we don't, then we won't generate those files because those options are set.
@mkarpoff I pushed a commit for this now with some tests. Give it a try, and let me know if it works properly. Now those arguments should be added if and only if there's no build directory set.
Looks good so far. Thankyou so much for the fix and for this plugin it is amazing.