Qt Creator Clang Code Model: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(40 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Tools::QtCreator]]
Documentation: http://doc.qt.io/qtcreator/creator-clang-codemodel.html
Documentation: http://doc.qt.io/qtcreator/creator-clang-codemodel.html


== Debugging ==
== Debugging ==


[http://doc.qt.io/qt-5/qloggingcategory.html QLoggingCategory] is used for debugging output. Thus, a file qtlogging.ini with the contents
With the following invocation debugging output will be generated:


[Rules]
Linux/Mac:
  qtc.clangcodemodel.ipc=true
  export QT_LOGGING_RULES=qtc.clang*=true
qtc.clangbackend.verboselib=true
  ./qtcreator
  qtc.clangbackend.parse=true
qtc.clangbackend.timers=true


and the Qt Creator invocation
Windows (start [https://technet.microsoft.com/en-us/sysinternals/debugview.aspx DebugView] in advance to see the output):
set QT_LOGGING_RULES=qtc.clang*=true
qtcreator.exe


Linux/Mac:
This will create way too much output. But since the lines are prefixed with the rule that generated them, you can easily adapt your settings to what you are actually interested in.
$ QT_LOGGING_CONF=/path/to/qtlogging.ini ./qtcreator


Windows (start [https://technet.microsoft.com/en-us/sysinternals/debugview.aspx DebugView] in advance to see the output):
=== Compiler command lines for the code model context ===
$ set QT_LOGGING_CONF=\path\to\qtlogging.ini
The file <build dir>/.qtc_clangd/compile_commands.json contains the exact command lines that clangd uses to parse the files in the project.
$ qtcreator.exe


will generate debugging output.
== Related Environment Variables ==
=== Run time related ===
* QTC_CLANG_USE_TOOLCHAIN_MACROS - Uses also the toolchain macros for code model
* QTC_CLANG_CMD_OPTIONS_BLACKLIST - Semicolon sepparated list of compiler command line options not to be passed to code model
 
== clangd ==
clangd is used via the language server protocol to provide code model features
 
=== Builds ===
Linux and Mac:
 
libclang is built with the same compilers as Qt Creator ("Clang 7.0 (Apple)" for macOS, and GCC 5.3 from RHEL (which turns on old ABI compatibility with _GLIBCXX_USE_CXX11_ABI=0 by default) on Linux)
 
Windows:
 
Currently libclang is built with optimized MinGW compiler for all Qt Creator versions. More information about Windows builds: [[Build libclang on Windows]]

Latest revision as of 14:27, 20 May 2022

Documentation: http://doc.qt.io/qtcreator/creator-clang-codemodel.html

Debugging

With the following invocation debugging output will be generated:

Linux/Mac:

export QT_LOGGING_RULES=qtc.clang*=true
./qtcreator

Windows (start DebugView in advance to see the output):

set QT_LOGGING_RULES=qtc.clang*=true
qtcreator.exe

This will create way too much output. But since the lines are prefixed with the rule that generated them, you can easily adapt your settings to what you are actually interested in.

Compiler command lines for the code model context

The file <build dir>/.qtc_clangd/compile_commands.json contains the exact command lines that clangd uses to parse the files in the project.

Related Environment Variables

Run time related

  • QTC_CLANG_USE_TOOLCHAIN_MACROS - Uses also the toolchain macros for code model
  • QTC_CLANG_CMD_OPTIONS_BLACKLIST - Semicolon sepparated list of compiler command line options not to be passed to code model

clangd

clangd is used via the language server protocol to provide code model features

Builds

Linux and Mac:

libclang is built with the same compilers as Qt Creator ("Clang 7.0 (Apple)" for macOS, and GCC 5.3 from RHEL (which turns on old ABI compatibility with _GLIBCXX_USE_CXX11_ABI=0 by default) on Linux)

Windows:

Currently libclang is built with optimized MinGW compiler for all Qt Creator versions. More information about Windows builds: Build libclang on Windows