microsoft / microsoft/vscode-cmake-tools

Identical compiler warnings in problems panel

Open
#1,385 10 comments 1 reaction 0 assignees View on GitHub
bug Feature: build
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary
When compiling a project with multiple translation units that have warnings in some common include file they are shown multiple times. All of them work and open the same file in the same position.
![image](https://user-images.githubusercontent.com/11685338/88466160-35d7a380-ced2-11ea-9b55-4e99005f3f2e.png)

### Expected:

There are no identical warnings.

### Apparent Behavior:

Identical warnings are shown.

Minimal project to reproduce:
CmakeLists.txt:
```cmake
cmake_minimum_required(VERSION 3.16)
project(Test)

add_executable(Test main.cpp Foo.cpp)
target_compile_options(Test PRIVATE -Wextra)
```
main.cpp:
```cpp
#include "Foo.hpp"
#include "Duplicate.hpp"

int main() { return 0; }
```
Foo.hpp:
```cpp
#pragma once

#include "Duplicate.hpp"
```
Foo.cpp:
```cpp
#include "Foo.hpp"
```
Duplicate.hpp:
```cpp
#pragma once

class Duplicate {
public:
void test(int i) {}
};
```
Multiple unused-parameter warnings should be shown in problems pannel.
![image](https://user-images.githubusercontent.com/11685338/88466085-8ac6ea00-ced1-11ea-93a0-4bbff3737fac.png)

Build output:
```
[main] Building folder: Test clean
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /mnt/media/dev/projects/Test/build/Clang-linux/Debug --config Debug --target clean --
[build] [1/1 100% :: 0.003] Cleaning all built files...
[build] Cleaning... 3 files.
[build] Build finished with exit code 0
[main] Building folder: Test
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /mnt/media/dev/projects/Test/build/Clang-linux/Debug --config Debug --target all -- -j 18
[build] [2/3 33% :: 0.022] Building CXX object CMakeFiles/Test.dir/Foo.cpp.o
[build] In file included from ../../../Foo.cpp:1:
[build] In file included from ../../../Foo.hpp:3:
[build] ../../../Duplicate.hpp:5:17: warning: unused parameter 'i' [-Wunused-parameter]
[build] void test(int i) {}
[build] ^
[build] 1 warning generated.
[build] [2/3 66% :: 0.022] Building CXX object CMakeFiles/Test.dir/main.cpp.o
[build] In file included from ../../../main.cpp:1:
[build] In file included from ../../../Foo.hpp:3:
[build] ../../../Duplicate.hpp:5:17: warning: unused parameter 'i' [-Wunused-parameter]
[build] void test(int i) {}
[build] ^
[build] 1 warning generated.
[build] [3/3 100% :: 0.330] Linking CXX executable Test
[build] Build finished with exit code 0
```

### Platform and Versions

- **Operating System**: Arch Linux
- **CMake Version**: 3.17.3
- **VSCode Version**: Latest insiders
- **CMake Tools Extension Version**: 1.4.1
- **Compiler/Toolchain**: Clang 10.0.0

### Other Notes/Information

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided CMakeLists.txt and main.cpp, Foo.cpp, Foo.hpp, and Duplicate.hpp files using the shown Clang build. Start from how compiler warnings are surfaced in the problems panel and compare entries from the two translation units. Done means identical warnings appear only once while retaining the same file and position navigation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, typescript
Domain
devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.