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:转至声明/定义对构造函数初始化程序内的表达式不起作用

Guru**** 2670045 points

Other Parts Discussed in Thread: TMS320F280041

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/1594339/codecomposer-go-to-declaration-definition-doesnt-work-properly-for-expressions-inside-constructor-initializers

部件号: CODECOMPOSER
主题: TMS320F280041 中讨论的其他器件

您好、

在 CCS 20.4.0.13__1.10.0 中发现了这一点  

当我在构造函数初始化程序内的表达式上“Ctrl+click"或“或“rightclick>Go to Definition“时、IDE 将我带到构造函数定义(红色箭头)、而不是表达式定义。

image.png

//示例代码、尝试通过构造函数中的 TEMP 表达式转到 TEMP 的定义、它将不起作用。

const uint16_t TEMP = 6;

结构 A
  A():A(TEMP){}

  易失性 uint16_t A;
};
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、David:

    您能否尝试 运行清理工程、然后再次编译以查看它是否起作用? 您还能确认这是您正在编辑的 C++文件吗?

    Udit

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    已确认这是一个已成功编译且启用 C++的有效工程。 该文件是 main.cpp、因此具有正确的扩展名。 可以确认 IDE 为该文件选取 C++语言模式。 我做了一个清洁和一个构建之后,这个问题仍然存在。

    这是一个 c28 处理器 TMS320F280041 的工程。 这个项目中的所有类/结构都会发生这种情况。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    是否可以重新启动 clangd 服务器、然后附加日志? 当您遇到问题的文件在编辑器中打开时执行此操作。 要重新启动 clangd 服务器、请按 Ctrl+Shift+P 打开命令面板、然后单击“clangd: restart language server“。
    要查看日志、请从“视图“->"输出“输出“中打开“输出视图“。 然后在右上角的下拉列表中选择“clangd"。“。 您可以右键单击并选择“全部复制“。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    已完成。 我打开了有问题的文件并在焦点中,然后清除 clangd 历史记录,在编辑器中单击一次,然后使用命令面板执行'clangd:重新启动语言服务器'。 重新启动后、我尝试了一次按住 Ctrl 键并单击构造函数初始化程序内的 TEMP 表达式。 然后右键单击并复制所有 clangd 日志。

    相关文件的路径为  c:\Users\MYUSER\GitHub \base\yyy\xxx\app\main.cpp src。 我混淆了一些文件夹名称,但其他一切都是一样的。


    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
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我在日志中看不到任何明显的错误。 是否可以尝试切换到最新版本的 clangd? 为此、您可以:

    *从 https://github.com/clangd/clangd/releases/tag/21.1.0 下载 clangd 并解压缩文件夹。
    *在 CCS 中,点击左下角的齿轮图标>常规设置> Clangd: PATH。 更新新可执行文件的路径。 这是类似的 /clangd_21.1.0/bin/clangd.exe。
    *删除.clangd 文件夹以从您的.zzz\aaa\bbb\文件夹中删除缓存。
    *重建项目,然后重新启动 clangd 服务器。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢你,这些步骤有效!

    不确定它是更新的 clangd 服务器、删除缓存还是两者都删除、但现在转至定义按预期工作。