microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.45k stars 1.53k forks source link

Clang Tidy Code analysis not working with a Workspace file. #9978

Closed Zingam closed 1 year ago

Zingam commented 1 year ago

Type: Bug

I created a simple project with the following layout:

MyProject 
    .vs/settings.json
    MyProject
         Sample
               Sources
                    main.cpp
               CMakeLists.txt
          CMakeLists.txt
    .clang-tidy
    MyProject.code-workspace

I tried moving .clang-tidy around. I tried setting:

  "C_Cpp.codeAnalysis.clangTidy.enabled": true,

in .vscode/settings.json and also in MyProject.code-workspace but I couldn't get the clang-tidy code analisys to work.

In a most basic project without a workspace file it works.

Also is this presets setting supported for Clang-Tidy:

      "vendor": {
        "microsoft.com/VisualStudioSettings/CMake/1.0": {
          "enableMicrosoftCodeAnalysis": true,
        }
      }

Extension version: 1.13.2 VS Code version: Code 1.72.0 (64bbfbf67ada9953918d72e1df2f4d8e537d340e, 2022-10-04T23:20:47.539Z) OS version: Linux x64 5.15.0-48-generic snap Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 1298)| |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)|2, 2, 2| |Memory (System)|7.42GB (1.38GB 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:30581797 vsaa593:30376534 pythonvs932:30410667 cppdebug:30492333 vscaat:30438848 vsclangdf:30486550 c4g48928:30535728 dsvsc012cf:30540253 azure-dev_surveyone:30548225 2144e591:30553903 vsccc:30566497 pyindex848cf:30577861 nodejswelcome1:30583747 40g7c324:30573242 ```
michelleangela commented 1 year ago

@Zingam Could you try setting C_Cpp.codeAnalysis.clangTidy.config with the path of .clang-tidy? Also make sure this setting is configured in <workspaceFolder>\.vscode\settings.json so that VS code will find the settings.json file for your workspace folder.

image

Zingam commented 1 year ago

I tried your suggestion on this test project and I couldn't get it to work.

Example.zip

I tried:

  1. Setting C_Cpp.codeAnalysis.clangTidy.config in .vs/settings.json in the root folder
  2. Setting C_Cpp.codeAnalysis.clangTidy.config in .code-workspace
sean-mcmanus commented 1 year ago

C_Cpp.codeAnalysis.clangTidy.config doesn't support being passed a file, you need to add --config-file=<path> to C_Cpp.codeAnalysis.clangTidy.args, see https://github.com/microsoft/vscode-cpptools/issues/9981 .

If you don't set a config or args, then it'll look for a .clang-tidy file in the current workspace folder for the processed file or in a parent folder of that file -- that behavior is the default for clang-tidy itself -- if you have certain settings set that can cause a --config to be added then it would cause .clang-tidy to be skipped.

Also, what behavior are you seeing that makes you think it's not working? C/C++ logging output from C_Cpp.loggingLevel set to "Debug" could help, i.e. the clang-tidy command line gets output.

Zingam commented 1 year ago

The contents of the file I am testing is:

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
#include <FirstEngine/Base/Definitions.hpp>

#include <FirstEngine/Windows/Window.hpp>
////////////////////////////////////////////////////////////////////////////////
#include <expected>
#include <filesystem>
#include <iostream>
#include <optional>
#include <utility>
#include <vector>
////////////////////////////////////////////////////////////////////////////////
#include <cstdint>
////////////////////////////////////////////////////////////////////////////////

int
add(int a, int b)
{
  return a * 2;
}

int
main(int argc, const char** argv)
{
  FirstEngine::Window window;
  std::cout << window.Title() << std::endl;

  auto result = add(argc, 2);

  return std::to_underlying(ExitCode::Success);
}

This is my .clang-tidy file, which is placed next to the workspace file:

---
Checks: >
  -*,
  bugprone-*,
  cert-*,
  clang-analyzer-*,
  clang-diagnostic-*,
  concurrency-*,
  cppcoreguidelines-*,
  google-*,
  hicpp-*,
  misc-*,
  modernize-*,
  performance-*,
  portability-*,
  readability-*
CheckOptions:
  - key:             llvm-else-after-return.WarnOnConditionVariables
    value:           'false'
  - key:             modernize-loop-convert.MinConfidence
    value:           reasonable
  - key:             modernize-replace-auto-ptr.IncludeStyle
    value:           llvm
  - key:             cert-str34-c.DiagnoseSignedUnsignedCharComparisons
    value:           'false'
  - key:             google-readability-namespace-comments.ShortNamespaceLines
    value:           '10'
  - key:             cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
    value:           'false'
  - key:             cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
    value:           'true'
  - key:             cert-dcl16-c.NewSuffixes
    value:           'L;LL;LU;LLU'
  - key:             google-readability-braces-around-statements.ShortStatementLines
    value:           '1'
  - key:             modernize-pass-by-value.IncludeStyle
    value:           llvm
  - key:             google-readability-namespace-comments.SpacesBeforeComments
    value:           '2'
  - key:             modernize-loop-convert.MaxCopySize
    value:           '16'
  - key:             cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
    value:           'true'
  - key:             modernize-use-nullptr.NullMacros
    value:           'NULL'
  - key:             llvm-qualified-auto.AddConstToQualified
    value:           'false'
  - key:             modernize-loop-convert.NamingStyle
    value:           CamelCase
  - key:             llvm-else-after-return.WarnOnUnfixable
    value:           'false'
  - key:             google-readability-function-size.StatementThreshold
    value:           '800'
AnalyzeTemporaryDtors: false
WarningsAsErrors:      ''
...

This command produces some results, but VSCode shows none:

clang-tidy -config-file=.clang-tidy FirstEngine/Samples/HelloWorld/Source/main.cpp

This is the log:

Example.zip

Zingam commented 1 year ago

C_Cpp.codeAnalysis.clangTidy.config doesn't support being passed a file, you need to add --config-file=<path> to C_Cpp.codeAnalysis.clangTidy.args, see #9981 .

If you don't set a config or args, then it'll look for a .clang-tidy file in the current workspace folder for the processed file or in a parent folder of that file -- that behavior is the default for clang-tidy itself -- if you have certain settings set that can cause a --config to be added then it would cause .clang-tidy to be skipped.

Also, what behavior are you seeing that makes you think it's not working? C/C++ logging output from C_Cpp.loggingLevel set to "Debug" could help, i.e. the clang-tidy command line gets output.

I saw this fix and I was about to try the workaround.

Zingam commented 1 year ago

@sean-mcmanus From the log:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump:

  1. Program arguments: /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy --export-fixes=/tmp/loose/cpptools/11772483893519446356/fixes140025446520384.yaml --quiet /home/hrrr/Projects/Example/FirstEngine/Samples/HelloWorld/Source/main.cpp -- -std=gnu++2b -xc++ -Wno-pragma-pack -DSSP_STRONG=3 -DDBL_MIN_EXP=(-1021) -Dcpp_attributes=200809L -Dcpp_nontype_template_parameter_auto=201606L -DUINT_LEAST16_MAX=0xffff -DFLT16_HAS_QUIET_NAN=1 -DATOMIC_ACQUIRE=2 -DFLT128_MAX_10_EXP=4932 -DFLT_MIN=1.17549435082228750796873653722224568e-38F -DGCC_IEC_559_COMPLEX=2 -Dcpp_aggregate_nsdmi=201304L "-DUINT_LEAST8_TYPE=unsigned char" -Dcpp_impl_three_way_comparison=201907L "-DINTMAX_C(c)=c ## L" -D__CHAR_BIT=8 -Dcpp_designated_initializers=201707L -DUINT8_MAX=0xff -DSCHAR_WIDTH=8 -DWINT_MAX=0xffffffffU -DFLT32_MIN_EXP=(-125) -Dcpp_static_assert=201411L -DORDER_LITTLE_ENDIAN=1234 -DSIZE_MAX=0xffffffffffffffffUL -DWCHAR_MAX=0x7fffffff -DGCC_HAVE_SYNC_COMPARE_AND_SWAP_2=1 -DGCC_HAVE_SYNC_COMPARE_AND_SWAP_4=1 -DGCC_HAVE_SYNC_COMPARE_AND_SWAP_8=1 -DGCC_ATOMIC_CHAR_LOCK_FREE=2 -DGCC_IEC_559=2 -DFLT32X_DECIMAL_DIG=17 -DFLT_EVAL_METHOD=0 -Dcpp_binary_literals=201304L -DFLT64_DECIMAL_DIG=17 -DCET=3 -Dcpp_noexcept_function_type=201510L -D__GCC_ATOMIC_CHAR32_T_LOCK_FREE=2 -Dcpp_variadic_templates=200704L -DUINT_FAST64_MAX=0xffffffffffffffffUL -DSIG_ATOMIC_TYPE=int -DDBL_MIN_10_EXP=(-307) -DFINITE_MATH_ONLY=0 -Dcpp_variable_templates=201304L -DFLT32X_MAX_EXP=1024 -DGCC_HAVE_SYNC_COMPARE_AND_SWAP_1=1 -DFLT32_HAS_DENORM=1 -DUINT_FAST8_MAX=0xff -Dcpp_rvalue_reference=200610L -D__cpp_nested_namespace_definitions=201411L -DDEC64_MAX_EXP=385 -DINT8_C(c)=c -DINT_LEAST8_WIDTH=8 -Dcpp_variadic_using=201611L -DUINT_LEAST64_MAX=0xffffffffffffffffUL -DINT_LEAST8_MAX=0x7f -Dcpp_capture_star_this=201603L -DSHRT_MAX=0x7fff -DLDBL_MAX=1.18973149535723176502126385303097021e+4932L -Dcpp_impl_coroutine=201902L -DFLT64X_MAX_10_EXP=4932 -Dcpp_if_constexpr=201606L -DLDBL_IS_IEC_60559=2 -DFLT64X_HAS_QUIET_NAN=1 -DUINT_LEAST8_MAX=0xff -DGCC_ATOMIC_BOOL_LOCK_FREE=2 -DFLT128_DENORM_MIN=6.47517511943802511092443895822764655e-4966F128 "-DUINTMAX_TYPE=long unsigned int" -Dlinux=1 -DDEC32_EPSILON=1E-6DF -DFLT_EVAL_METHOD_TS_18661_3=0 -Dunix=1 -DUINT32_MAX=0xffffffffU -DGXX_EXPERIMENTAL_CXX0X=1 -DDBL_DENORM_MIN=double(4.94065645841246544176568792868221372e-324L) -DFLT128_MIN_EXP=(-16381) -DWINT_MIN=0U -DFLT128_MIN_10_EXP=(-4931) -DFLT32X_IS_IEC_60559=2 -DINT_LEAST16_WIDTH=16 -DSCHAR_MAX=0x7f -DFLT128_MANT_DIG=113 "-DWCHAR_MIN=(-WCHAR_MAX - 1)" "-DINT64_C(c)=c ## L" -Dcpp_impl_destroying_delete=201806L -DGCC_ATOMIC_POINTER_LOCK_FREE=2 -DFLT32X_MANT_DIG=53 -DGCC_ATOMIC_CHAR16_T_LOCK_FREE=2 -Dcpp_aligned_new=201606L -DFLT32_MAX_10_EXP=38 -DFLT64X_EPSILON=1.08420217248550443400745280086994171e-19F64x -DSTDC_HOSTED=1 -DDEC64_MIN_EXP=(-382) -Dcpp_decltype_auto=201304L -D__DBL_DIG=15 -DFLT32_DIG=6 -DFLT_EPSILON=1.19209289550781250000000000000000000e-7F -Dcpp_char8_t=201811L -DGXX_WEAK=1 -DSHRT_WIDTH=16 -DFLT32_IS_IEC_60559=2 -Dcpp_size_t_suffix=202011L -DLDBL_MIN=3.36210314311209350626267781732175260e-4932L -DDBL_IS_IEC_60559=2 -DDEC32_MAX=9.999999E96DF "-DCHAR8_TYPE=unsigned char" -Dcpp_threadsafe_static_init=200806L -Dcpp_enumerator_attributes=201411L -DFLT64X_DENORM_MIN=3.64519953188247460252840593361941982e-4951F64x -DFLT32X_HAS_INFINITY=1 -DINT32_MAX=0x7fffffff -DFLT16_DIG=3 -Dunix=1 -DINT_WIDTH=32 -DSIZEOF_LONG=8 -DSTDC_IEC_559=1 -DSTDC_ISO_10646=201706L -DUINT16_C(c)=c -DDECIMAL_DIG=21 -DSTDC_IEC_559_COMPLEX=1 -DFLT64_EPSILON=2.22044604925031308084726333618164062e-16F64 -Dgnu_linux=1 -DINT16_MAX=0x7fff -DFLT64_MIN_EXP=(-1021) -Dcpp_using_enum=201907L -DFLT64X_MIN_10_EXP=(-4931) -DLDBL_HAS_QUIET_NAN=1 -DFLT16_MIN_EXP=(-13) -DFLT64_MANT_DIG=53 -Dcpp_consteval=201811L -DFLT64X_MANT_DIG=64 -D__GXX_RTTI=1 -Dpie=2 -DMMX=1 -DFLT_HAS_DENORM=1 -DSIZEOF_LONG_DOUBLE=16 -DBIGGEST_ALIGNMENT=16 -DSTDC_UTF_16=1 -DFLT64_MAX_10_EXP=308 -DFLT16_MAX_10_EXP=4 -Dcpp_delegating_constructors=200604L -DFLT32_HAS_INFINITY=1 -DDBL_MAX=double(1.79769313486231570814527423731704357e+308L) -Dcpp_raw_strings=200710L -DINT_FAST32_MAX=0x7fffffffffffffffL -DDBL_HAS_INFINITY=1 -D__SIZEOF_FLOAT=4 -DHAVE_SPECULATION_SAFE_VALUE=1 -Dcpp_fold_expressions=201603L -DDEC32_MIN_EXP=(-94) -DINTPTR_WIDTH=64 -DFLT64X_HAS_INFINITY=1 -DUINT_LEAST32_MAX=0xffffffffU -DFLT32X_HAS_DENORM=1 "-DINT_FAST16_TYPE=long int" -DMMX_WITH_SSE=1 -DLDBL_HAS_DENORM=1 -DSEG_GS=1 -Dcplusplus=202100L -Dcpp_ref_qualifiers=200710L -D__DEC32_MIN=1E-95DF -DDEPRECATED=1 -Dcpp_rvalue_references=200610L -DDBL_MAX_EXP=1024 -DWCHAR_WIDTH=32 -DFLT32_MAX=3.40282346638528859811704183484516925e+38F32 -DDEC128_EPSILON=1E-33DL -DFLT16_DECIMAL_DIG=5 -DATOMIC_HLE_RELEASE=131072 -D__PTRDIFF_MAX=0x7fffffffffffffffL -Damd64=1 -DATOMIC_HLE_ACQUIRE=65536 -DGNUG=12 -DLONG_LONG_MAX=0x7fffffffffffffffLL -DSIZEOF_SIZE_T=8 -Dcpp_nsdmi=200809L -DFLT64X_MIN_EXP=(-16381) -DSIZEOF_WINT_T=4 -DLONG_LONG_WIDTH=64 -Dcpp_initializer_lists=200806L -DFLT32_MAX_EXP=128 -Dcpp_hex_float=201603L -DGXX_ABI_VERSION=1017 -DFLT128_HAS_INFINITY=1 -DFLT_MIN_EXP=(-125) -DGCC_HAVE_DWARF2_CFI_ASM=1 -D__x86_64=1 -Dcpp_lambdas=200907L "-DINT_FAST64_TYPE=long int" -DFLT64_DENORM_MIN=4.94065645841246544176568792868221372e-324F64 -Dcpp_template_auto=201606L -DDBL_MIN=double(2.22507385850720138309023271733240406e-308L) -DFLT16_DENORM_MIN=5.96046447753906250000000000000000000e-8F16 -DFLT128_EPSILON=1.92592994438723585305597794258492732e-34F128 -DFLT64X_NORM_MAX=1.18973149535723176502126385303097021e+4932F64x -DSIZEOF_POINTER=8 -DLP64=1 -DDBL_HAS_QUIET_NAN=1 -DFLT32X_EPSILON=2.22044604925031308084726333618164062e-16F32x -DDECIMAL_BID_FORMAT=1 -DFLT64_MIN_10_EXP=(-307) -DFLT16_MIN_10_EXP=(-4) -DFLT64X_DECIMAL_DIG=21 -DDEC128_MIN=1E-6143DL -DREGISTER_PREFIX= -DUINT16_MAX=0xffff -DLDBL_HAS_INFINITY=1 -DFLT32_MIN=1.17549435082228750796873653722224568e-38F32 "-DUINT8_TYPE=unsigned char" -DFLT_DIG=6 -DNO_INLINE=1 -DDEC_EVAL_METHOD=2 -DDEC128_MAX=9.999999999999999999999999999999999E6144DL -DFLT_MANT_DIG=24 -DLDBL_DECIMAL_DIG=21 -Dcpp_multidimensional_subscript=202110L "-DUINT64_C(c)=c ## UL" -D__cpp_unicode_characters=201411L -D_STDC_PREDEF_H=1 -Dcpp_if_consteval=202106L -DINT_LEAST32_MAX=0x7fffffff -DGCC_ATOMIC_INT_LOCK_FREE=2 -DFLT128_MAX_EXP=16384 -Dcpp_conditional_explicit=201806L -DFLT32_MANT_DIG=24 -DFLOAT_WORD_ORDER=ORDER_LITTLE_ENDIAN -DFLT32X_MIN_EXP=(-1021) -Dcpp_aggregate_paren_init=201902L -D__STDC_IEC_60559_COMPLEX=201404L -Dcpp_aggregate_bases=201603L -DFLT128_HAS_DENORM=1 -DFLT32_DECIMAL_DIG=9 -DFLT128_DIG=33 -DINT32_C(c)=c -DDEC64_EPSILON=1E-15DD -DORDER_PDP_ENDIAN=3412 -DDEC128_MIN_EXP=(-6142) -Dcpp_constinit=201907L "-DINT_FAST32_TYPE=long int" "-DUINT_LEAST16_TYPE=short unsigned int" -Dunix=1 -DDBL_HAS_DENORM=1 -Dcpp_rtti=199711L "-DSIZE_TYPE=long unsigned int" -DUINT64_MAX=0xffffffffffffffffUL -DFLT_IS_IEC_60559=2 -DGNUC_WIDE_EXECUTION_CHARSET_NAME=\"UTF-32LE\" -D__FLT64X_DIG=18 "-DINT8_TYPE=signed char" -Dcpp_digit_separators=201309L -DELF=1 -D__GCC_ASM_FLAG_OUTPUTS=1 "-DUINT32_TYPE=unsigned int" -DFLT_RADIX=2 "-DINT_LEAST16_TYPE=short int" -DLDBL_EPSILON=1.08420217248550443400745280086994171e-19L "-DUINTMAX_C(c)=c ## UL" -DGLIBCXX_BITSIZE_INT_N_0=128 -Dk8=1 -DFLT32X_MIN=2.22507385850720138309023271733240406e-308F32x -DSIG_ATOMIC_MAX=0x7fffffff -DGCC_ATOMIC_WCHAR_T_LOCK_FREE=2 -DUSER_LABEL_PREFIX= -DSTDC_IEC_60559_BFP=201404L -DSIZEOF_PTRDIFF_T=8 -DLDBL_DIG=18 -DFLT64_IS_IEC_60559=2 -Dx86_64=1 -DFLT16_IS_IEC_60559=2 -DFLT16_MAX_EXP=16 -DDEC32_SUBNORMAL_MIN=0.000001E-95DF -DINT_FAST16_MAX=0x7fffffffffffffffL -DGCC_CONSTRUCTIVE_SIZE=64 -D__FLT64_DIG=15 -DUINT_FAST32_MAX=0xffffffffffffffffUL "-DUINT_LEAST64_TYPE=long unsigned int" -DFLT16_EPSILON=9.76562500000000000000000000000000000e-4F16 -DFLT_HAS_QUIET_NAN=1 -DFLT_MAX_10_EXP=38 -DLONG_MAX=0x7fffffffffffffffL -DFLT64X_HAS_DENORM=1 -DDEC128_SUBNORMAL_MIN=0.000000000000000000000000000000001E-6143DL -DFLT_HAS_INFINITY=1 -DGNUC_EXECUTION_CHARSET_NAME=\"UTF-8\" -Dcpp_unicode_literals=200710L "-DUINT_FAST16_TYPE=long unsigned int" -DDEC64_MAX=9.999999999999999E384DD -DINT_FAST32_WIDTH=64 "-DCHAR16_TYPE=short unsigned int" -DPRAGMA_REDEFINE_EXTNAME=1 -D__SIZE_WIDTH=64 -DSEG_FS=1 -DINT_LEAST16_MAX=0x7fff -DFLT16_NORM_MAX=6.55040000000000000000000000000000000e+4F16 -DDEC64_MANT_DIG=16 -D__INT64_MAX=0x7fffffffffffffffL -DFLT32_DENORM_MIN=1.40129846432481707092372958328991613e-45F32 -DSIG_ATOMIC_WIDTH=32 "-DINT_LEAST64_TYPE=long int" "-DINT16_TYPE=short int" "-DINT_LEAST8_TYPE=signed char" -DFLT16_MAX=6.55040000000000000000000000000000000e+4F16 -Dcpp_structured_bindings=201606L -DSIZEOF_INT=4 -DDEC32_MAX_EXP=97 -DINT_FAST8_MAX=0x7f -DFLT128_MAX=1.18973149535723176508575932662800702e+4932F128 -DINTPTR_MAX=0x7fffffffffffffffL -Dcpp_guaranteed_copy_elision=201606L -Dlinux=1 -DFLT64_HAS_QUIET_NAN=1 -DFLT32_MIN_10_EXP=(-37) -DEXCEPTIONS=1 -DPTRDIFF_WIDTH=64 -DLDBL_MANT_DIG=64 -Dcpp_range_based_for=201603L -DFLT64_HAS_INFINITY=1 -DFLT64X_MAX=1.18973149535723176502126385303097021e+4932F64x -DFLT16_HAS_INFINITY=1 -DSTDCPP_DEFAULT_NEW_ALIGNMENT=16 "-DSIG_ATOMIC_MIN=(-SIG_ATOMIC_MAX - 1)" -Dcode_model_small=1 -DGCC_ATOMIC_LONG_LOCK_FREE=2 -Dcpp_nontype_template_args=201911L -DDEC32_MANT_DIG=7 -Dcpp_return_type_deduction=201304L -Dk8=1 "-D__INTPTR_TYPE=long int" "-DUINT16_TYPE=short unsigned int" -DWCHAR_TYPE=int -Dpic=2 -DUINTPTR_MAX=0xffffffffffffffffUL -DINT_FAST64_WIDTH=64 -Dcpp_nontype_template_parameter_class=201806L -D__cpp_concepts=202002L -Dcpp_decltype=200707L -DINT_FAST64_MAX=0x7fffffffffffffffL -DGCC_ATOMIC_TEST_AND_SET_TRUEVAL=1 -DFLT_NORM_MAX=3.40282346638528859811704183484516925e+38F -DFLT64X_MAX_EXP=16384 "-DUINT_FAST64_TYPE=long unsigned int" -D__cpp_constexpr_in_decltype=201711L -Dcpp_inline_variables=201606L -DINT_MAX=0x7fffffff -Dlinux=1 "-DINT64_TYPE=long int" -DFLT_MAX_EXP=128 -DORDER_BIG_ENDIAN=4321 -DDBL_MANT_DIG=53 -Dcpp_inheriting_constructors=201511L -DSIZEOF_FLOAT128=16 -DINT_LEAST64_MAX=0x7fffffffffffffffL -DDEC64_MIN=1E-383DD "-DWINT_TYPE=unsigned int" "-DUINT_LEAST32_TYPE=unsigned int" -DSIZEOF_SHORT=2 -DFLT32_NORM_MAX=3.40282346638528859811704183484516925e+38F32 -DLDBL_MIN_EXP=(-16381) -DFLT64_MAX=1.79769313486231570814527423731704357e+308F64 -Damd64=1 -DWINT_WIDTH=32 -DINT_LEAST64_WIDTH=64 -DLDBL_MAX_EXP=16384 -DFLT32X_MAX_10_EXP=308 -DSIZEOF_INT128=16 -DFLT16_MIN=6.10351562500000000000000000000000000e-5F16 -DFLT64X_IS_IEC_60559=2 -DLDBL_MAX_10_EXP=4932 -DATOMIC_RELAXED=0 -DDBL_EPSILON=double(2.22044604925031308084726333618164062e-16L) -DFLT128_MIN=3.36210314311209350626267781732175260e-4932F128 -D_LP64=1 -DUINT8_C(c)=c -DFLT64_MAX_EXP=1024 -DINT_LEAST32_TYPE=int -DSIZEOF_WCHAR_T=4 -DFLT128_NORM_MAX=1.18973149535723176508575932662800702e+4932F128 -DFLT64_NORM_MAX=1.79769313486231570814527423731704357e+308F64 -D__FLT128_HAS_QUIET_NAN=1 -DINTMAX_MAX=0x7fffffffffffffffL "-DINT_FAST8_TYPE=signed char" -Dcpp_namespace_attributes=201411L -D__FLT64X_MIN=3.36210314311209350626267781732175260e-4932F64x -DSTDCPP_THREADS=1 -DGNUC_STDC_INLINE=1 -DFLT64_HAS_DENORM=1 -DFLT32_EPSILON=1.19209289550781250000000000000000000e-7F32 -DFLT16_HAS_DENORM=1 -DDBL_DECIMAL_DIG=17 -DSTDC_UTF_32=1 -DINT_FAST8_WIDTH=8 -DFXSR=1 -DFLT32X_MAX=1.79769313486231570814527423731704357e+308F32x -DDBL_NORM_MAX=double(1.79769313486231570814527423731704357e+308L) -DBYTE_ORDER=ORDER_LITTLE_ENDIAN -DGCC_DESTRUCTIVE_SIZE=64 -DINTMAX_WIDTH=64 -Dcpp_runtime_arrays=198712L "-DUINT64_TYPE=long unsigned int" "-DUINT32_C(c)=c ## U" -Dcpp_alias_templates=200704L -Dcpp_constexpr_dynamic_alloc=201907L -DFLT_DENORM_MIN=1.40129846432481707092372958328991613e-45F -D__FLT128_IS_IEC_60559=2 -DINT8_MAX=0x7f -DLONG_WIDTH=64 -DPIC=2 "-DUINT_FAST32_TYPE=long unsigned int" -DFLT16_MANT_DIG=11 -DFLT32X_NORM_MAX=1.79769313486231570814527423731704357e+308F32x "-DCHAR32_TYPE=unsigned int" -DFLT_MAX=3.40282346638528859811704183484516925e+38F -Dcpp_constexpr=202110L -Dcpp_deduction_guides=201907L -DINT32_TYPE=int -DSIZEOF_DOUBLE=8 -Dcpp_exceptions=199711L -DFLT_MIN_10_EXP=(-37) -DFLT64_MIN=2.22507385850720138309023271733240406e-308F64 -DINT_LEAST32_WIDTH=32 "-DINTMAX_TYPE=long int" -DDEC128_MAX_EXP=6145 -DFLT32X_HAS_QUIET_NAN=1 -DATOMIC_CONSUME=1 -DGLIBCXX_TYPE_INT_N_0=int128 -DINT_FAST16_WIDTH=64 -DUINTMAX_MAX=0xffffffffffffffffUL -DPIE=2 -DFLT32X_DENORM_MIN=4.94065645841246544176568792868221372e-324F32x -Dcpp_template_template_args=201611L -DDBL_MAX_10_EXP=308 -DLDBL_DENORM_MIN=3.64519953188247460252840593361941982e-4951L -DGCC_ATOMIC_CHAR8_T_LOCK_FREE=2 -DINT16_C(c)=c -DSTDC=1 -D__FLT32X_DIG=15 "-DPTRDIFF_TYPE=long int" -DATOMIC_SEQ_CST=5 -D__FLT32X_MIN_10_EXP=(-307) "-DUINTPTR_TYPE=long unsigned int" -DDEC64_SUBNORMAL_MIN=0.000000000000001E-383DD -DDEC128_MANT_DIG=34 -DLDBL_MIN_10_EXP=(-4931) -Dcpp_generic_lambdas=201707L -DSIZEOF_LONG_LONG=8 -Dcpp_user_defined_literals=200809L -DFLT128_DECIMAL_DIG=36 -DGCC_ATOMIC_LLONG_LOCK_FREE=2 -DFLT32_HAS_QUIET_NAN=1 -DFLT_DECIMAL_DIG=9 -DUINT_FAST16_MAX=0xffffffffffffffffUL -DLDBL_NORM_MAX=1.18973149535723176502126385303097021e+4932L -DGCC_ATOMIC_SHORT_LOCK_FREE=2 "-DUINT_FAST8_TYPE=unsigned char" -D_GNU_SOURCE=1 -Dcpp_init_captures=201803L -DATOMIC_ACQ_REL=4 -D__ATOMIC_RELEASE=3 -I/home/hrrr/Projects/Example/FirstEngine/Engine/Libraries/Base/Include -I/home/hrrr/Projects/Example/FirstEngine/Engine/Libraries/Windows/Include -isystem/usr/include/c++/12 -isystem/usr/include/x86_64-linux-gnu/c++/12 -isystem/usr/include/c++/12/backward -isystem/usr/lib/gcc/x86_64-linux-gnu/12/include -isystem/usr/local/include -isystem/usr/include/x86_64-linux-gnu -isystem/usr/include
  2. parser at end of file Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x23)[0x34f3ae3] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x34f190e] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x34f3f96] /lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7ff80827d520] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZNK5clang4Stmt9getEndLocEv+0x8)[0x2aade48] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang4tidy11readability27BracesAroundStatementsCheck13findRParenLocINS_6IfStmtEEENS_14SourceLocationEPKT_RKNS_13SourceManagerEPKNS_10ASTContextE+0x40)[0xd606f0] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang4tidy11readability27BracesAroundStatementsCheck5checkERKNS_12ast_matchers11MatchFinder11MatchResultE+0x4f2)[0xd5fe32] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x2725a92] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang12ast_matchers8internal21BoundNodesTreeBuilder12visitMatchesEPNS2_7VisitorE+0x9c)[0x274e4ac] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x272537a] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x27328f9] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x272f70b] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x274dff3] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x272b7f4] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x2727fa2] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x2728ebd] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x2727fa2] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x272e17c] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x2727fa2] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang12ast_matchers11MatchFinder8matchASTERNS_10ASTContextE+0x300)[0x2704fb0] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang17MultiplexConsumer21HandleTranslationUnitERNS_10ASTContextE+0x2c)[0x1ac3ddc] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang8ParseASTERNS_4SemaEbb+0x273)[0x1cc5043] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang14FrontendAction7ExecuteEv+0xfb)[0x1a87bfb] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x356)[0x19fe776] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang7tooling21FrontendActionFactory13runInvocationESt10shared_ptrINS_18CompilerInvocationEEPNS_11FileManagerES2_INS_22PCHContainerOperationsEEPNS_18DiagnosticConsumerE+0x19c)[0x1544c2c] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy[0x1510df6] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang7tooling14ToolInvocation13runInvocationEPKcPNS_6driver11CompilationESt10shared_ptrINS_18CompilerInvocationEES7_INS_22PCHContainerOperationsEE+0x106)[0x1544996] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang7tooling14ToolInvocation3runEv+0x4fb)[0x1543a9b] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang7tooling9ClangTool3runEPNS0_10ToolActionE+0xd71)[0x1546191] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang4tidy12runClangTidyERNS0_16ClangTidyContextERKNS_7tooling19CompilationDatabaseEN4llvm8ArrayRefINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEENS7_18IntrusiveRefCntPtrINS7_3vfs17OverlayFileSystemEEEbbNS7_9StringRefE+0x457)[0x150d077] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_ZN5clang4tidy13clangTidyMainEiPPKc+0x202e)[0x97b4de] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7ff808264d90] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7ff808264e40] /home/hrrr/.vscode/extensions/ms-vscode.cpptools-1.13.2-linux-x64/bin/../LLVM/bin/clang-tidy(_start+0x2a)[0x97748a] cpptools/textEditorSelectionChange cpptools/textEditorSelectionChange cpptools/getCodeActions: /home/hrrr/Projects/Example/FirstEngine/Samples/HelloWorld/Source/main.cpp (id: 20)
Zingam commented 1 year ago

Let's hope this is the fix: https://github.com/microsoft/vscode-cpptools/pull/9979 but then cpptools seems to do something to annoy clang-tidy.

sean-mcmanus commented 1 year ago

Okay, thanks for the info. I'll see if I can repro that. We've noticed that sometimes clang-tidy will crash if there's some configuration issue that leads to some invalid parsing (not sure if that's the case here or not yet).

FYI, you may be able to get a call stack by ensure you have llvm-symbolizer in your PATH or set the environment var LLVM_SYMBOLIZER_PATH to point to it, but I haven't tried that yet.

Zingam commented 1 year ago

I removed the following checks and the crash stopped. There is a crash with the builtin clang-tidy and also with an external clang-tidy 15 from apt.llvm.org

-readability-braces-around-statements,
-readability-simplify-boolean-expr,
-google-readability-braces-around-statements,
-hicpp-braces-around-statements,

More info here: https://github.com/llvm/llvm-project/issues/58365#issuecomment-1279711274

There is no crash if I just call:

clang-tidy -config-file=.clang-tidy FirstEngine/Samples/HelloWorld/Source/main.cpp

This is a working configuration:

---
Checks: >
  -*,
  bugprone-*,
  cert-*,
  clang-analyzer-*,
  clang-diagnostic-*,
  concurrency-*,
  cppcoreguidelines-*,
  google-*,
  hicpp-*,
  misc-*,
  modernize-*,
  performance-*,
  portability-*,
  readability-*,
  -readability-braces-around-statements,
  -readability-simplify-boolean-expr,
  -google-readability-braces-around-statements,
  -hicpp-braces-around-statements,
CheckOptions:
  - key:             llvm-else-after-return.WarnOnConditionVariables
    value:           'false'
  - key:             modernize-loop-convert.MinConfidence
    value:           reasonable
  - key:             modernize-replace-auto-ptr.IncludeStyle
    value:           llvm
  - key:             cert-str34-c.DiagnoseSignedUnsignedCharComparisons
    value:           'false'
  - key:             google-readability-namespace-comments.ShortNamespaceLines
    value:           '10'
  - key:             cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
    value:           'false'
  - key:             cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
    value:           'true'
  - key:             cert-dcl16-c.NewSuffixes
    value:           'L;LL;LU;LLU'
  - key:             google-readability-braces-around-statements.ShortStatementLines
    value:           '1'
  - key:             modernize-pass-by-value.IncludeStyle
    value:           llvm
  - key:             google-readability-namespace-comments.SpacesBeforeComments
    value:           '2'
  - key:             modernize-loop-convert.MaxCopySize
    value:           '16'
  - key:             cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
    value:           'true'
  - key:             modernize-use-nullptr.NullMacros
    value:           'NULL'
  - key:             llvm-qualified-auto.AddConstToQualified
    value:           'false'
  - key:             modernize-loop-convert.NamingStyle
    value:           CamelCase
  - key:             llvm-else-after-return.WarnOnUnfixable
    value:           'false'
  - key:             google-readability-function-size.StatementThreshold
    value:           '800'
AnalyzeTemporaryDtors: false
WarningsAsErrors:      ''
...
Zingam commented 1 year ago

Now I see a different issue: there are no warning squiggles in the code editor but there are some in the log:

image

clang-tidy.log

Automatic clang-tidy analysis doesn't work: "C_Cpp.codeAnalysis.runAutomatically": true. I only get results by calling "Run Code Analysis on Active File".

sean-mcmanus commented 1 year ago

@Zingam Okay, thanks for the info. I've been busy this past week, but I'll try to investigate next week or so.

browntarik commented 1 year ago

After further investigation, we have deduced that it is highly unlikely that our extension is causing the issue. Our extension is simply responsible for passing arguments to execute clangtidy. For example, if a user adds a .clangtidy file, our extension adds a --config-file argument with the path to the .clangtidy file. Our extension is in no way modifying the file. It is more likely that this is an LLVM bug with opening .clangtidy files with certain checks enabled. As a result, we are closing this issue.