This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CODECOMPOSER: Go to declaration/definition doesnt work properly for expressions inside constructor initializers

Part Number: CODECOMPOSER
Other Parts Discussed in Thread: TMS320F280041

Hi,

Found this in CCS 20.4.0.13__1.10.0 

When I "Ctrl+Click", or "RightClick>Go To Definition" on an expression inside a constructor initializer, the IDE brings me to the Constructor definition (red arrow), rather than the expression definition.

image.png

// Example Code, try going to the definition of TEMP via the TEMP expression in the constructor, it will not work.

const uint16_t TEMP = 6;

struct A
{
    A() : a(TEMP) {}

    volatile uint16_t a;
};
  • Hi David,

    Could you try to run Clean Projects and then build it again to see if that works? Also could you confirm that this is a C++ file you are editing?

    Udit

  • Confirmed this is a valid C++ enabled project that builds successfully. This file is main.cpp, so it has the right extension. Can confirm the IDE picks up C++ language mode for this file. I have done a clean, and a build after that, and the issue persists.

    This is a project for a c28 processor, TMS320F280041. This happens with all of my classes/structs in this project.

  • Could you restart your clangd server and then attach the logs? Do this when the file you're having issues with is open in the editor. To restart clangd server, open the command palette by pressing ctrl+shift+P, then click 'clangd: Restart language server'.
    To view logs, open Output view from View -> Output. Then select 'clangd' in the dropdown on the top right. You can right click and select Copy All.

  • Done. I had the file in question open and in focus, I then cleared the clangd history, clicked once in the editor, then used the command palette to execute 'clangd: Restart language server'. Once it restarted, I tried once to Ctrl+Click the TEMP expression inside the constructor initializer. I then right-clicked and copied all of the clangd logs.

    The path to the file in question is c:\Users\MYUSER\github\base\yyy\xxx\src\app\main.cpp. I have obfuscated some folder names, but everything else is as-is.


    I[11:02:12.714] <-- textDocument/codeAction(12)
    I[11:02:12.714] --> reply:textDocument/codeAction(12) 0 ms
    I[11:02:12.714] --> textDocument/clangd.fileStatus
    I[11:02:18.202] <-- shutdown(13)
    I[11:02:18.202] --> reply:shutdown(13) 0 ms
    I[11:02:18.203] <-- exit
    I[11:02:18.203] LSP finished, exiting with status 0
    I[11:02:18.270] clangd version 19.1.2 (github.com/.../llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
    I[11:02:18.271] Features: windows+grpc
    I[11:02:18.271] PID: 2948
    I[11:02:18.271] Working directory: c:\Users\MYUSER\github\base\yyy\xxx
    I[11:02:18.271] argv[0]: C:\ti\ccs2040\ccs\theia\resources\clangd\clangd.exe
    I[11:02:18.271] argv[1]: -header-insertion=never
    I[11:02:18.271] argv[2]: -limit-results=200
    I[11:02:18.283] Starting LSP over stdin/stdout
    I[11:02:18.283] <-- initialize(0)
    I[11:02:18.294] --> reply:initialize(0) 10 ms
    I[11:02:18.295] <-- initialized
    I[11:02:18.297] <-- textDocument/didOpen
    I[11:02:18.299] --> textDocument/publishDiagnostics
    I[11:02:18.299] --> textDocument/publishDiagnostics
    I[11:02:18.300] Loaded compilation database from c:\Users\MYUSER\github\base\yyy\xxx\Debug\.clangd\compile_commands.json
    I[11:02:18.300] ASTWorker building file c:\Users\MYUSER\github\base\yyy\xxx\src\app\main.cpp version 6 with command
    [C:/Users/MYUSER/github/base/yyy/xxx/Debug]
    "C:\\ti\\ccs2040\\ccs\\theia\\resources\\clangd\\clang++" --driver-mode=g++ -D -IC:/ti/compilers/ti-cgt-c2000_22.6.1.LTS/include -IC:/ti/controlSUITE/libs/app_libs/motor_control/math_blocks/v4.3 -IC:/ti/c2000/C2000Ware_5_04_00_00/libraries/math/IQmath/c28/include -IC:/ti/c2000/C2000Ware_5_04_00_00/libraries/math/FPUfastRTS/c28/include -IC:/ti/c2000/C2000Ware_5_04_00_00/device_support/f28004x/common/include -IC:/ti/c2000/C2000Ware_5_04_00_00/device_support/f28004x/headers/include -IC:/ti/c2000/C2000Ware_5_04_00_00/libraries/flash_api/f28004x/include/FlashAPI -IC:/ti/c2000/C2000Ware_5_04_00_00/driverlib/f28004x/driverlib -IC:/ti/c2000/C2000Ware_5_04_00_00/driverlib/f28004x -IC:/ti/c2000/C2000Ware_5_04_00_00/libraries/dsp/FPU/c28/include -IC:/Users/MYUSER/github/base/yyy/xxx/src/app -IC:/Users/MYUSER/github/base/yyy/xxx/src/boot -IC:/Users/MYUSER/github/base/yyy/xxx/base_firmware_common -IC:/Users/MYUSER/github/base/yyy/xxx/src/config -DMATH_TYPE=FLOAT_MATH -xc++ "-resource-dir=C:\\ti\\ccs2040\\ccs\\theia\\resources\\lib\\clang\\19" -- "c:\\Users\\MYUSER\\github\\base\\yyy\\xxx\\src\\app\\main.cpp"
    I[11:02:18.302] --> textDocument/publishDiagnostics
    I[11:02:18.308] --> window/workDoneProgress/create(0)
    I[11:02:18.308] Enqueueing 15 commands for indexing
    I[11:02:18.309] <-- reply(0)
    I[11:02:18.309] --> $/progress
    I[11:02:18.309] --> $/progress
    I[11:02:18.310] <-- textDocument/codeAction(1)
    I[11:02:18.320] --> textDocument/clangd.fileStatus
    I[11:02:18.329] <-- textDocument/documentLink(2)
    I[11:02:18.329] <-- textDocument/inlayHint(3)
    I[11:02:18.413] --> textDocument/publishDiagnostics
    I[11:02:18.414] Loaded compilation database from C:\Users\MYUSER\github\base\zzz\aaa\bbb\Debug\.clangd\compile_commands.json
    I[11:02:18.510] Built preamble of size 3389744 for file c:\Users\MYUSER\github\base\yyy\xxx\src\app\main.cpp version 6 in 0.19 seconds
    I[11:02:18.511] --> workspace/semanticTokens/refresh(1)
    I[11:02:18.511] --> textDocument/clangd.fileStatus
    I[11:02:18.511] <-- reply(1)
    I[11:02:18.542] --> textDocument/publishDiagnostics
    I[11:02:18.542] --> textDocument/inactiveRegions
    I[11:02:18.542] --> reply:textDocument/codeAction(1) 232 ms
    I[11:02:18.543] --> reply:textDocument/documentLink(2) 213 ms
    I[11:02:18.543] --> reply:textDocument/inlayHint(3) 213 ms
    I[11:02:18.543] --> textDocument/clangd.fileStatus
    I[11:02:18.548] --> $/progress
    I[11:02:18.548] --> $/progress
    I[11:02:18.548] --> $/progress
    E[11:02:18.555] Indexing C:\Users\MYUSER\github\base\yyy\xxx\src\boot\_F28004x_CodeStartBranch.asm failed: Couldn't build compiler invocation
    I[11:02:18.555] --> $/progress
    I[11:02:18.601] <-- textDocument/documentSymbol(4)
    I[11:02:18.602] --> reply:textDocument/documentSymbol(4) 1 ms
    I[11:02:18.602] --> textDocument/clangd.fileStatus
    I[11:02:18.604] <-- textDocument/foldingRange(5)
    I[11:02:18.605] --> reply:textDocument/foldingRange(5) 1 ms
    I[11:02:24.961] <-- textDocument/definition(6)
    I[11:02:24.962] --> reply:textDocument/definition(6) 1 ms
    I[11:02:24.962] --> textDocument/clangd.fileStatus
    I[11:02:25.250] <-- textDocument/hover(7)
    I[11:02:25.252] --> reply:textDocument/hover(7) 2 ms
    I[11:02:25.252] --> textDocument/clangd.fileStatus
    I[11:02:25.504] <-- textDocument/documentHighlight(8)
    I[11:02:25.505] --> reply:textDocument/documentHighlight(8) 0 ms
    I[11:02:25.505] --> textDocument/clangd.fileStatus
    I[11:02:25.561] <-- textDocument/definition(9)
    I[11:02:25.561] --> reply:textDocument/definition(9) 0 ms
    I[11:02:25.561] --> textDocument/clangd.fileStatus
    I[11:02:25.856] <-- textDocument/codeAction(10)
    I[11:02:25.856] --> reply:textDocument/codeAction(10) 0 ms
    I[11:02:25.856] --> textDocument/clangd.fileStatus
    

  • I don't see any obvious errors in the logs. Could you try to switch to the latest version of clangd? To do this, you can:

    * Download clangd from https://github.com/clangd/clangd/releases/tag/21.1.0 and unzip the folder.
    * In CCS, click the gear icon on the bottom left > General Settings > Clangd: Path. Update the path to the new executable. This would be something like <path>/clangd_21.1.0/bin/clangd.exe.
    * Delete the .clangd folder to delete cache from your ...zzz\aaa\bbb\ folder.
    * Rebuild the project and then restart the clangd server.

  • Thank you, those steps worked!

    Not sure if it was the updated clangd server, deleting the cache, or both, but now go-to-definition works as expected.