-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] unused-function diagnostic regression? #109
Comments
It was deleted by us because some people said that this diagnostic is trouble and there is no such diagnostic on MSVC. I'm thinking of a compatible solution |
Isn't the compatible solution to default to or implicitly set For context, I'm building code that was previously only ever compiled with MSVC. I'm building with warnings-as-errors but have toggled off or no-error'd some warnings which I want to address later, like unused-function. Also going through the exercise of figuring out how to get clang or the linker warn about which public symbols are unused (or if its even possible) since unused-function only seems to apply to static linkage or LLVM's nature of omitting unused symbols short circuits any additional reporting. |
I will figure it out. |
Sorry, haven't had time to setup a test until today. I tested with v3.0.8 and it still is silent about unused functions and variables, even though I have them explicitly set as warnings. I realize that in my original post that I mentioned I had these set as errors, but for iteration of catching the list of everything that appears as unused (at least in 2.8.2, before the change you mentioned on August 8th) I set these to show up as warnings still, while not changing the overall default of warnings-as-errors. Here's a subset of what I have in a .props file: <ClangClAdditionalOptions>
-Wno-unused-value
-Wno-error=unused-variable
-Wno-error=unused-function
-Wno-error=unused-member-function
-Wno-error=unused-const-variable
-Wno-unused-but-set-variable
-Wno-unused-local-typedef
-Wno-unused-but-set-parameter
$(ClangClAdditionalOptions)
</ClangClAdditionalOptions> Here's the current output, for what it is worth (names have been changed to protect the innocent):
But when I compile with 2.8.2 there is of course much more output (and takes ~12s less time to rebuild, whatever that anecdote may mean to you). |
Can you provide some code so that I can reproduce something like "unused-function" |
#include <cstdio>
static void this_function_is_unused();
int main()
{
puts("Hello, World");
}
static void this_function_is_unused()
{
// This function should generate a -Wunused-function warning under ClangCL
}
In the attached minimal repro vcxproj file, if you change
Even though I have the warning level set to 4, with warnings as error, and <PropertyGroup Label="LLVM" Condition="$(PlatformToolset)=='ClangCL'">
<ClangClAdditionalOptions>
-Wno-error=unused-variable
-Wno-error=unused-function
-Wno-error=unused-member-function
-Wno-error=unused-const-variable
-Wno-unused-but-set-variable
-Wno-unused-local-typedef
-Wno-unused-but-set-parameter
$(ClangClAdditionalOptions)
</ClangClAdditionalOptions>
</PropertyGroup> |
Thanks for the feedback, I'll take care of this problem right away. |
Did you miss parameters?( |
Ah, okay, if I have the following: <PropertyGroup Label="LLVM" Condition="$(PlatformToolset)=='ClangCL'">
<ClangClAdditionalOptions>
-Wunused-function
-Wno-error=unused-function
$(ClangClAdditionalOptions)
</ClangClAdditionalOptions>
</PropertyGroup> Where For reference, where in llvm-msvc's code do you configure these normally-on-by-default warnings to be off by default for the sake of MSVC users that don't expect them? Is it in llvm-msvc specific code, or do you modify the llvm code where the warning is defined directly? Thanks! |
The latest version of |
I recently downloaded 2.9.2, after using 2.8.2. I was using
-Werror=unused-function
to remove some dead code but noticed I was not hitting any errors after performing a rebuild on a library. After switching back to 2.8.2 in my msbuild .props files I once again get errors about unused functions as expected.For 2.8.2, I'm setting LLVMInstallDir to my local llvm-msvc 2.8.2 copy and LLVMToolsVersion to 17.
For 2.9.2, I'm setting LLVMInstallDir to my local llvm-msvc 2.9.2 copy and LLVMToolsVersion to 18.
I'm using the latest VS2022 Preview (17.8 Preview 1) in the event that it matters.
Note, I have not tried stock LLVM v18 - may be possible it was regressed there?
The text was updated successfully, but these errors were encountered: