Skip to content
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

VSCode cannot see <ranges> namespaces in Clang 15 #9888

Closed
Zingam opened this issue Sep 18, 2022 · 16 comments
Closed

VSCode cannot see <ranges> namespaces in Clang 15 #9888

Zingam opened this issue Sep 18, 2022 · 16 comments
Assignees
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service parser quick fix
Milestone

Comments

@Zingam
Copy link

Zingam commented Sep 18, 2022

Type: Bug

I have been playing around with Clang 15 on Linux. I installed it via:
https://apt.llvm.org/
I created the "update-alternatives" manually, etc.

I copy & pasted this piece of code in a test CMake project:

  std::cout << "Ranges\n";
  auto const ints = { 0, 1, 2, 3, 4, 5 };
  auto even = [](int i) { return 0 == i % 2; };
  auto square = [](int i) { return i * i; };

  // "pipe" syntax of composing the views:
  for (int i :
       ints | std::views::filter(even) | std::views::transform(square)) {
    std::format("where am i? {}", "\n");
    std::cout << i << ' ';
  }

  std::cout << '\n';

  // a traditional "functional" composing syntax:
  for (int i : std::views::transform(std::views::filter(ints, even), square))
  {
    std::cout << i << ' ';
  }
  std::cout << "\n";

With GCC 12 config:

image

With Clang 15 config:

image

Extension version: 1.12.4
VS Code version: Code 1.71.2 (74b1f979648cc44d385a2286793c226e611f59e7, 2022-09-14T21:12:14.256Z)
OS version: Linux x64 5.15.0-47-generic snap
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)
GPU Status 2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off
Load (avg) 1, 1, 1
Memory (System) 7.42GB (3.47GB free)
Process Argv --no-sandbox --force-user-env --unity-launch --crash-reporter-id 20280fc3-3c6d-43d3-9eb5-55c536b003d8
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu-wayland
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu-wayland
XDG_SESSION_TYPE wayland
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30557514
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vscaat:30438848
vsclangdf:30486550
c4g48928:30535728
hb751961:30553087
dsvsc012cf:30540253
azure-dev_surveyone:30548225
2144e591:30553903
vsccc:30566497
fc301958:30567733

@Zingam
Copy link
Author

Zingam commented Sep 18, 2022

image
Test.zip

@sean-mcmanus sean-mcmanus self-assigned this Sep 20, 2022
@sean-mcmanus sean-mcmanus added this to the 1.13 milestone Sep 20, 2022
@sean-mcmanus sean-mcmanus added investigate: repro This issue's repro steps needs to be investigated/confirmed Language Service parser bug labels Sep 20, 2022
@sean-mcmanus
Copy link
Contributor

I'm not reproing the issue. Can you run C/C++: Log Diagnostics and provide the output and/or verify the clang 15 compiler is being used with C++23?

@sean-mcmanus
Copy link
Contributor

Also, you could run a command line /usr/bin/clang++-15 -std=c++2b -E ./test.cpp > ./test.out.cpp to generate a preprocessed file and look for an IntelliSense error that may be the root cause of the failure and what header is causing it.

@sean-mcmanus sean-mcmanus removed this from the 1.13 milestone Sep 20, 2022
@sean-mcmanus sean-mcmanus added more info needed The issue report is not actionable in its current state and removed investigate: repro This issue's repro steps needs to be investigated/confirmed labels Sep 20, 2022
@Zingam
Copy link
Author

Zingam commented Sep 22, 2022

This is 100% reproducible on my machine with the described setup with the attached Test.zip.
Some details:

  1. x64 Ubuntu 22.04
  2. LLVM installed from here: https://apt.llvm.org/
  3. Ubuntu's GCC 12 package

Steps to reproduce:

Test2.zip

  1. Start VSCode
  2. The project is opened by default, VSCode GCC Debug preset is selected by default.
  3. Switch to VSCode Clang Debug, rebuild

Observed the red squiggly lines. The squiggles appeared after the rebuild.

image

Please note the ranges include location:

image

I'm not reproing the issue. Can you run C/C++: Log Diagnostics and provide the output and/or verify the clang 15 compiler is being used with C++23?

This is the output:

-------- Diagnostics - 9/22/2022, 9:02:57 AM
Version: 1.12.4
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++14",
    "intelliSenseMode": "linux-clang-x64",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": [
        "/home/hristo/Projects/ClangTest/src"
    ],
    "compilerPath": "/usr/bin/clang++",
    "compilerArgs": [],
    "compilerFragments": [
        "-g",
        "-stdlib=libc++",
        "-fexperimental-library",
        "-W",
        "-Wall",
        "-Werror",
        "-Wpedantic",
        "-std=gnu++2b"
    ]
}
Custom configurations:
[ /home/hristo/Projects/ClangTest/src/main.cpp ]
{
    "includePath": [],
    "defines": [],
    "compilerPath": "/usr/bin/clang++",
    "compilerArgs": [],
    "compilerFragments": [
        "-g",
        "-stdlib=libc++",
        "-fexperimental-library",
        "-W",
        "-Wall",
        "-Werror",
        "-Wpedantic",
        "-std=gnu++2b"
    ]
}
Translation Unit Mappings:
[ /home/hristo/Projects/ClangTest/src/main.cpp ]:
    /home/hristo/Projects/ClangTest/src/main.cpp
Translation Unit Configurations:
[ /home/hristo/Projects/ClangTest/src/main.cpp ]:
    Process ID: 6330
    Memory Usage: 124 MB
    Compiler Path: /usr/bin/clang++
    Includes:
        /usr/lib/llvm-15/include/c++/v1
        /usr/lib/llvm-15/lib/clang/15.0.1/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c++23
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=150001
Total Memory Usage: 124 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 22051

@Zingam
Copy link
Author

Zingam commented Sep 22, 2022

/usr/bin/clang++-15 -std=c++2b -E ./test.cpp > ./test.out.cpp

I run this command: /usr/bin/clang++-15 -std=c++2b -E ./main.cpp > ./main.out.cpp but I don't think that it is correct. Here is the output anyway:

main.zip

@Zingam
Copy link
Author

Zingam commented Sep 22, 2022

Also, you could run a command line /usr/bin/clang++-15 -std=c++2b -E ./test.cpp > ./test.out.cpp to generate a preprocessed file and look for an IntelliSense error that may be the root cause of the failure and what header is causing it.

Should the command be: /usr/bin/clang++-15 -std=c++2b -stdlib=libc++ -fexperimental-library -E ./main.cpp > ./main.out.cpp

main2.zip

@Zingam
Copy link
Author

Zingam commented Sep 22, 2022

$ update-alternatives --config gcc
There is only one alternative in link group gcc (providing /usr/bin/gcc): /usr/bin/gcc-12
Nothing to configure.
$ update-alternatives --config g++
There is only one alternative in link group g++ (providing /usr/bin/g++): /usr/bin/g++-12
Nothing to configure.
$ update-alternatives --config clang
There is only one alternative in link group clang (providing /usr/bin/clang): /usr/bin/clang-15
Nothing to configure.
$ update-alternatives --config clang++
There is only one alternative in link group clang++ (providing /usr/bin/clang++): /usr/bin/clang++-15
Nothing to configure.

@Zingam
Copy link
Author

Zingam commented Sep 22, 2022

Clean reconfigure for *VSCode Clang Debug" CMake preset:

[main] Configuring folder: ClangTest
[driver] Removing /home/hristo/Projects/ClangTest/.build/vscode-clang-debug/CMakeCache.txt
[driver] Removing /home/hristo/Projects/ClangTest/.build/vscode-clang-debug/CMakeFiles
[proc] Executing command: /snap/cmake/current/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/hristo/Projects/ClangTest/.build-out/vscode-clang-debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -S/home/hristo/Projects/ClangTest -B/home/hristo/Projects/ClangTest/.build/vscode-clang-debug -G Ninja
[cmake] -- The CXX compiler identification is Clang 15.0.1
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /usr/bin/clang++ - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- CPACK_GENERATOR: DEB;RPM
[cmake] -- CPACK_DEBIAN_PACKAGE_NAME ClangTest
[cmake] -- CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA /home/hristo/Projects/ClangTest/assets/linux/package/deb/scripts/preinst
[cmake] -- CPACK_PROJECT_NAME ClangTest
[cmake] -- --- AFTER CPack ---
[cmake] -- CPACK_GENERATOR: TBZ2;TGZ;TXZ;TZ
[cmake] -- CPACK_DEBIAN_PACKAGE_NAME ClangTest
[cmake] -- CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA /home/hristo/Projects/ClangTest/assets/linux/package/deb/scripts/preinst
[cmake] -- CPACK_PROJECT_NAME ClangTest
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] CMake Warning:
[cmake] Manually-specified variables were not used by the project:
[cmake]
[cmake] CMAKE_C_COMPILER
[cmake]
[cmake]
[cmake] -- Build files have been written to: /home/hristo/Projects/ClangTest/.build/vscode-clang-debug

Clean reconfigure for VSCode GCC Debug CMake preset:

[main] Configuring folder: ClangTest
[driver] Removing /home/hristo/Projects/ClangTest/.build/vscode-gcc-debug/CMakeCache.txt
[driver] Removing /home/hristo/Projects/ClangTest/.build/vscode-gcc-debug/CMakeFiles
[proc] Executing command: /snap/cmake/current/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/hristo/Projects/ClangTest/.build-out/vscode-gcc-debug -DCMAKE_C_COMPILER=/usr/bin/gcc-12 -DCMAKE_CXX_COMPILER=/usr/bin/g++-12 -S/home/hristo/Projects/ClangTest -B/home/hristo/Projects/ClangTest/.build/vscode-gcc-debug -G Ninja
[cmake] -- The CXX compiler identification is GNU 12.1.0
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /usr/bin/g++-12 - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- CPACK_GENERATOR: DEB;RPM
[cmake] -- CPACK_DEBIAN_PACKAGE_NAME ClangTest
[cmake] -- CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA /home/hristo/Projects/ClangTest/assets/linux/package/deb/scripts/preinst
[cmake] -- CPACK_PROJECT_NAME ClangTest
[cmake] -- --- AFTER CPack ---
[cmake] -- CPACK_GENERATOR: TBZ2;TGZ;TXZ;TZ
[cmake] -- CPACK_DEBIAN_PACKAGE_NAME ClangTest
[cmake] -- CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA /home/hristo/Projects/ClangTest/assets/linux/package/deb/scripts/preinst
[cmake] -- CPACK_PROJECT_NAME ClangTest
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] CMake Warning:
[cmake] Manually-specified variables were not used by the project:
[cmake]
[cmake] CMAKE_C_COMPILER
[cmake]
[cmake]
[cmake] -- Build files have been written to: /home/hristo/Projects/ClangTest/.build/vscode-gcc-debug

@sean-mcmanus sean-mcmanus added investigate: repro This issue's repro steps needs to be investigated/confirmed and removed more info needed The issue report is not actionable in its current state labels Sep 23, 2022
@sean-mcmanus sean-mcmanus added this to the 1.13 milestone Sep 23, 2022
@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Sep 23, 2022

With the main2.zip file I hit https://developercommunity.visualstudio.com/t/C-IntelliSense-doesnt-recognize-clang/10156062 , which might be the root cause of this bug, but I'm not sure yet. I don't get the error when I remove the __attribute__((using_if_exists)).

@sean-mcmanus
Copy link
Contributor

Also, with the main.zip, I'm getting some "not implemented" error internally -- our C++23 support is still in development so it looks like the system header code is using features we don't support yet. Are you able to repro the issue with C++20? I can try myself later too...

@Zingam
Copy link
Author

Zingam commented Sep 24, 2022

It's the same in C++20 mode. The squiggles appear/disappear only after a rebuild (after switching a cmake configure preset):
image

Test3.zip

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Sep 24, 2022

Ah, okay -- I got the repro now -- I didn't have libc++ installed. I'm investigating...

UPDATE: Looks like we aren't handling "-fexperimental-library" sufficiently -- clang itself gives the same error without that flag. Still investigating...

@sean-mcmanus
Copy link
Contributor

@Zingam You should be able to work around the issue via using "defines": [ "__has_feature(experimental_library)=1"], I'm not sure yet if the fix will make it into 1.13.1 or not.

@sean-mcmanus sean-mcmanus removed the investigate: repro This issue's repro steps needs to be investigated/confirmed label Sep 26, 2022
@sean-mcmanus sean-mcmanus modified the milestones: 1.13, 1.13.1 Sep 26, 2022
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Sep 26, 2022
@sean-mcmanus
Copy link
Contributor

@Zingam
Copy link
Author

Zingam commented Sep 29, 2022

I switched to 1.13.1. I can confirm that the reported issue is fix.

Now I'm experiencing two more issues with the same "test".

  1. Performance when CTRL+Click on std::view is very poor on my machine. It takes very long to load the IntelliSense data, and then the line that should appears under std::range::view feels to no appear: appears disappears. This feature behaves erratically. This sluggish behavior is present in the Clang configuration. In the GCC configuration the performance is much smoother. IMO
  2. In the GCC configuration now I am seeing this (I haven't noticed this error before):
    image

@sean-mcmanus
Copy link
Contributor

@Zingam Okay, I've filed #9937 to track those issues.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service parser quick fix
Projects
None yet
Development

No branches or pull requests

2 participants