Skip to content

False warning of constness #37

Closed
Closed

Description

@Stehsaer

Version

server 0.0.8

Editor

Visual Studio Code 1.138.0, AI feature turned off

Operating system

Debian Testing (x64) (Linux x64 7.1.12+deb14-amd64)

Build system

xmake

What happened

float rank_device_by_memory(const vk::raii::PhysicalDevice& phy_device) noexcept
{
	const auto memory_properties = phy_device.getMemoryProperties();

	auto device_local_heaps =
		memory_properties.memoryHeaps | std::views::filter([](const vk::MemoryHeap& heap) -> bool {
			return (heap.flags & vk::MemoryHeapFlagBits::eDeviceLocal)
				== vk::MemoryHeapFlagBits::eDeviceLocal;
		});

	const auto total_heap_memory_bytes = std::ranges::fold_left(
		device_local_heaps | std::views::transform(&vk::MemoryHeap::size),
		0,
		std::plus()
	);

	return static_cast<float>(total_heap_memory_bytes) / (1024.0f * 1024.0f);
}

Install vulkan-hpp and include <vulkan/vulkan.hpp> and <vulkan/vulkan_raii.hpp>

device_local_heaps cannot be declared as const, while mcppls hints that it can. Original clangd doesn't signal the same warning.

mcppls clangd

Additional Information

.clang-tidy:

Checks: " modernize-*, bugprone-*, readability-*, performance-*, misc-*,

  modernize-use-nodiscard,

  cppcoreguidelines-slicing,
  cppcoreguidelines-pro-bounds-array-to-pointer-decay,
  cppcoreguidelines-pro-bounds-pointer-arithmetic,
  cppcoreguidelines-pro-type-const-cast, cppcoreguidelines-pro-type-cstyle-cast,
  cppcoreguidelines-rvalue-reference-param-not-moved,
  cppcoreguidelines-virtual-class-destructor,
  cppcoreguidelines-avoid-capturing-lambda-coroutines,
  cppcoreguidelines-no-malloc, cppcoreguidelines-no-suspend-with-lock,
  cppcoreguidelines-prefer-member-initializer,

  -modernize-use-trailing-return-type, -modernize-loop-convert,
  -modernize-replace-auto-ptr, -modernize-use-default-member-init,
  -modernize-use-override, -modernize-avoid-c-arrays, -modernize-avoid-bind,
  -modernize-type-traits, -modernize-use-using,

  -bugprone-narrowing-conversions, -bugprone-std-namespace-modification,
  -bugprone-easily-swappable-parameters,
  -bugprone-implicit-widening-of-multiplication-result,
  -bugprone-reserved-identifier, -bugprone-exception-escape,
  -bugprone-unchecked-optional-access,

  -readability-braces-around-statements, -readability-else-after-return,
  -readability-magic-numbers, -readability-identifier-length,
  -readability-isolate-declaration, -readability-suspicious-call-argument,
  -readability-uppercase-literal-suffix,
  -readability-convert-member-functions-to-static, -readability-named-parameter,
  -readability-qualified-auto, -readability-math-missing-parentheses,

  -performance-no-int-to-ptr,-performance-enum-size,

  -misc-non-private-member-variables-in-classes, -misc-no-recursion,
  -misc-unused-parameters, -misc-use-anonymous-namespace, -misc-include-cleaner"

CheckOptions:
  readability-identifier-naming.ClassCase: CamelCase
  readability-identifier-naming.ClassIgnoredRegexp: (promise_type|iterator_concept|value_type|difference_type|reference|pointer)

  readability-identifier-naming.AbstractClassCase: CamelCase
  readability-identifier-naming.AbstractClassIgnoredRegexp: (promise_type|iterator_concept|value_type|difference_type|reference|pointer)

  readability-identifier-naming.TypeAliasCase: CamelCase
  readability-identifier-naming.TypeAliasIgnoredRegexp: (promise_type|iterator_concept|value_type|difference_type|reference|pointer)

  readability-identifier-naming.StructCase: CamelCase
  readability-identifier-naming.StructIgnoredRegexp: (promise_type|iterator_concept|value_type|difference_type|reference|pointer)

  readability-identifier-naming.UnionCase: CamelCase
  readability-identifier-naming.TypeTemplateParameterCase: CamelCase
  readability-identifier-naming.EnumCase: CamelCase
  readability-identifier-naming.EnumConstantCase: CamelCase
  readability-identifier-naming.ConceptCase: CamelCase

  readability-identifier-naming.ConstexprVariableCase: aNy_CasE
  readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
  readability-identifier-naming.ClassConstexprCase: aNy_CasE

  readability-identifier-naming.FunctionCase: lower_case
  readability-identifier-naming.FunctionIgnoredRegexp: ^_+.*

  readability-identifier-naming.VariableCase: lower_case
  readability-identifier-naming.VariableIgnoredRegexp: ^_+.*

  readability-identifier-naming.NamespaceCase: lower_case
  readability-identifier-naming.MemberCase: lower_case
  readability-identifier-naming.MethodCase: lower_case

.clangd:

Diagnostics:
  UnusedIncludes: Strict
  MissingIncludes: Strict

clangd configuration:

Hover:
  ShowAKA: True

InlayHints:
  BlockEnd: False
  Designators: True
  Enabled: True
  ParameterNames: True
  DeducedTypes: True
  TypeNameLimit: 0
  DefaultArguments: True

Index:
  StandardLibrary: true

Diagnostics:
  # UnusedIncludes: Strict
  # MissingIncludes: Strict
  Includes:
    AnalyzeAngledIncludes: True
    IgnoreHeader: [impl/*\.hpp]
  ClangTidy:
    FastCheckFilter: None
  Suppress: [builtin_definition]

CompileFlags:
  Add:
    [
      -Wall,
      -Wextra,
      -Wno-c99-designator,
      -Wno-int-to-pointer-cast,
      -Wreorder-init-list,
      -Wunreachable-code,
      -Wdangling,
      -Warray-bounds,
      -Xclang,
      -fbuiltin-headers-in-system-modules,
    ]
  Remove: [
      -mabi=*,
      -march=*,
      -mcpu=*,
      -mtune=*,
      -mbranch-cost=*,
      -Ibuild/.gens/*/rules/utils/bin2c,
      -fmodule-mapper=*,
      -fconcepts,
      -fcoroutines,
      # Cuda
      -ccbin=*,
      -rdc=*,
      -gencode,
      arch=*,
    ]
  BuiltinHeaders: QueryDriver

Completion:
  AllScopes: true
  ArgumentLists: None
  HeaderInsertion: IWYU
  CodePatterns: None

Documentation:
  CommentFormat: Doxygen

Style:
  AngledHeaders:
    - ".*/vulkan/vulkan.*"

Diagnostic bundle:
mcppls-bundle-20261001T094207.379Z.zip

What you expected

Silent the false warning on mcppls.

Diagnostic bundle

  • I attached the diagnostic bundle

Diagnostic report (only if there is no bundle)

Steps to reproduce

No response

Activity

  1. added
    bug
    on Oct 1, 2026
  2. Sunrisepeak commented on Oct 1, 2026

    @Sunrisepeak
    Owner

    Thanks for the detailed report and the bundle. 0.0.9 addresses everything in it. It is on Open VSX now; the VS Code Marketplace follows shortly.

    The const warning on device_local_heaps. This is a clang-tidy regression. clang-tidy 23.1, which mcppls bundles, reports it; 22.1.8 does not.

    • It is a false positive. A filter_view caches its begin(), so declaring it const breaks | std::views::transform(...).
    • The check only runs because your clangd config sets FastCheckFilter: None.
    • 0.0.9 drops misc-const-correctness for a variable holding a filter, drop_while, chunk_by or split view, or a view built on one. The check's other findings stay.
    • The reduced case is tracked as UP-22 in Upstream defects register (clangd, mcpp) #24 for upstream.
    • To silence the check entirely, set Diagnostics.ClangTidy.CheckOptions: misc-const-correctness.AnalyzeValues: false in .clangd.

    Completion slower than plain clangd. I reproduced it on your project's code.

    • With clangd's --experimental-modules-support, every completion rescans the file's module dependencies. With vulkan-hpp included, the median went from 82 ms to 254 ms, and the worst case to 869 ms. Headers are affected the same way.
    • 0.0.9 starts clangd without that flag for a project that uses no modules. Measured through the released server, the median is 81 ms, the same as plain clangd.
    • If you later add an import, clangd restarts once with modules support.
    • This is tracked as UP-23 in Upstream defects register (clangd, mcpp) #24.

    workers: undefined / "Value must match regex". mcppls.engine was a plain setting and also the parent of mcppls.engine.workers. VS Code drops the child's default in that case. On top of that, the value was never sent to the server.

    • The parent settings are now mcppls.engine.name and mcppls.buildDiscovery.mode. The old names keep working, and VS Code offers once to move yours.
    • engine.workers now takes effect.

    xmake "needs libpthread-stubs, libtool downloaded". These are build tools and libraries xmake needs to build libsdl3 from source, because your xmake.lua sets system = false for it. That is why installing them with apt fixed it.

    • The message now says so, and mentions the system package manager.
    • A start no longer runs xmake f with the proxy/dotnet keys xmake itself writes to .xmake/.../xmake.conf. Those made every start fail once and show a misleading "run xmake f -c" notice.
    • A failed online install is reported as such, with xmake's error and the path of its install log.
    • "Always Download in This Workspace" lets mcppls fetch what is needed without asking. "C++ Modules: Ask Before Downloading in This Workspace" takes it back.
    • After a download you asked for, you are told whether it worked.

    The slow first seconds after a restart. Your bundle showed a second server instance starting cold beside one left over from an earlier window.

    • A second instance now plans from the owner's cached model.
    • A server whose editor process is gone exits.
    • A clangd restart no longer blocks requests while the old clangd exits.

    If anything still looks off with 0.0.9, a new bundle (C++ Modules: Export Diagnostic Bundle, right after reproducing) would help.

  3. Sunrisepeak commented on Oct 24, 2026

    @Sunrisepeak
    Owner

    最新0.0.17 已经修复, 可以更新验证, 如有问题可以继续reopen反馈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions