CODECOMPOSER: Clang-Tidy not showing issues

Part Number: CODECOMPOSER

Hi,

we are having trouble seeing clang-tidy problems in one of our projects. Using the identical .clang-tidy file in a fresh example project from Simplelink SDK, output is shown as expected. In our project no messages appear. I am assuming that some internal problem blocks the output or stops processing. Is there any way to debug this? Do you have some loggin of the clang-tidy status?

BR, Matthias

  • Hello,

    I assume you are using CCS 20. If you are not on 20.4.0 already, I do suggest moving to it. It has some fixes/enhancements for clang-tidy.

    Do you have some loggin of the clang-tidy status?

    There are some parameters that can be passed to clang-tidy from the command-line that can provide more verbose diagnostics However I assume you are asking if this can be done from the IDE. I do not think there is though I would need to confirm.

    Thanks

    ki 

  • Hi Ki,

    we are using CCS 20.4 already. I can run clang-tidy from the command line without problems since it is a third party tool. But my problem is that there is no highlighting or listing of the output in the CCS interface. Something is obviously going wrong, but I don't have any way to see what it could be. Verbose diagnostics of clang-tidy do not help because that already runs. The problem must be inside the CCS implementation. As far as I understand, it is not using the clangd functionality directly for this output?

  • As far as I understand, it is not using the clangd functionality directly for this output?

    It should be. Can you attach your .clang-tidy file?

  • Sure, here it is:

    ---
    # Based on WebKit coding guidelines

    Checks: >
    -*,
    clang-diagnostic-unused-function,

    cppcoreguidelines-use-enum-class,

    bugprone-*,
    -bugprone-easily-swappable-parameters,

    google-*,
    -google-readability-todo,

    misc-*,
    -misc-include-cleaner,
    -misc-non-private-member-variables-in-classes,

    performance-*,
    -performance-enum-size,

    portability-*,
    -portability-avoid-pragma-once,

    readability-*,

    modernize-redundant-void-arg,
    modernize-use-nullptr,
    modernize-raw-string-literal,
    modernize-return-braced-init-list,
    modernize-use-bool-literals,
    modernize-use-default-member-init,
    modernize-use-equals-default,
    modernize-use-override

    # Turn all the warnings from the checks above into errors.
    WarningsAsErrors: "*"

    CheckOptions:
    - { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
    - { key: readability-identifier-naming.NamespaceCase, value: CamelCase }
    - { key: readability-identifier-naming.ClassCase, value: CamelCase }
    - { key: readability-identifier-naming.StructCase, value: CamelCase }
    - { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
    - { key: readability-identifier-naming.EnumCase, value: CamelCase }
    - { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
    - { key: readability-identifier-naming.FunctionCase, value: camelBack }
    - { key: readability-identifier-naming.ParameterCase, value: camelBack }
    - { key: readability-identifier-naming.VariableCase, value: camelBack }
    - { key: readability-identifier-naming.MemberCase, value: camelBack }
    - { key: readability-identifier-naming.GlobalConstantCase, value: camelBack }
    - { key: readability-identifier-naming.GlobalVariablePrefix, value: g_ }
    - { key: readability-identifier-naming.ClassMemberPrefix, value: m_ }
    - { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ }
    - { key: readability-identifier-naming.ProtectedMemberPrefix, value: m_ }

    #ExcludeHeaderFilterRegex: 'scif'
    HeaderFilterRegex: ^(?!.*scif)(?!.*(?:^|/|\\)ti(?:/|\\)|.*ti_drivers_config\.h).*

    # use our own clang-format files
    # FormatStyle: 'file'

  • Thank you, we will take a look.

  • Hi Ki,

    in the meantime i stumbled upon a possible reason: We are using TIarmclang 3.2.3, since it we ran into some incompability with Simplelink 8.30 with the version 4.x. Changing the compiler for the project to 4.0.4, I can see clang-tidy reports again, but am now struggling with an errno.h include issue.

    Is there any update on Simplelink -> clang 4.0 compatibility or any way to get clang-tidy working with 3.2.3?

    Another problem that now comes up:

    "DeviceFamily_XYZ undefined. You must define a DeviceFamily_XYZ!" [clang-diagnostic-error]

    This is defined in Debug\syscfg\ti_utils_build_compiler.opt, which is included in the compilation. The project compiles successfully, but the clang-tidy seems to ignore any file-based compiler commands. Can we change any config to make this work?

  • We are using TIarmclang 3.2.3, since it we ran into some incompability with Simplelink 8.30 with the version 4.x. Changing the compiler for the project to 4.0.4

    oh this is a very interesting datapoint, thank you!

    Is there any update on Simplelink -> clang 4.0 compatibility

    I don't have any answers for that one. I suggest starting a new thread for the SDK experts.

    or any way to get clang-tidy working with 3.2.3?

    we are looking into this

  • Hi Ki, we have now been able to move to TIARmclang 4.0.4, so the workflow is mostly working as expected.

    The remaining issue is this:

    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(driverlib/vims.h) -> "DeviceFamily_XYZ undefined. You must define a DeviceFamily_XYZ!" [clang-diagnostic-error]
    The familiy shoudl be defined in Debug\syscfg\ti_utils_build_compiler.opt (-DDeviceFamily_CC13X2), which is included in the compilation. Syntax highlighting is aware of the definition, but the clang-diagnostic-error still shows via clang-tidy.
    It seems that clang-tidy is not aware of any file-based compiler commands, although it is expanded correctly in the compile_commands.json. Do you have any idea how to fix it?
  • It seems that clang-tidy is not aware of any file-based compiler commands, although it is expanded correctly in the compile_commands.json.

    The first part of your statement does not surprise me. However the second part does. I would image if the define is properly expanded then it would get properly picked up by clang-tidy.

    I tried this with one of the basic examples from the SDK and see the same issue. I tried defining in the .clang-tidy file but it does not seem to be getting picked up. It seems to only get picked up when added to the project properties or when I define it a source/header file.

  • I will need to discuss with engineering again. This and also the 3.2.3 compatibility issue. I can reproduce both issues.