|
|
(20 intermediate revisions by 3 users not shown) |
Line 8: |
Line 8: |
| Linux/Mac: | | Linux/Mac: |
| export QT_LOGGING_RULES=qtc.clang*=true | | export QT_LOGGING_RULES=qtc.clang*=true |
| export LIBCLANG_TIMING=1
| |
| ./qtcreator | | ./qtcreator |
|
| |
|
| Windows (start [https://technet.microsoft.com/en-us/sysinternals/debugview.aspx DebugView] in advance to see the output): | | 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 | | set QT_LOGGING_RULES=qtc.clang*=true |
| set LIBCLANG_TIMING=1
| |
| qtcreator.exe | | qtcreator.exe |
|
| |
|
| The debugging output contains among others:
| | 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. |
| * The IPC messages send/received
| |
| * Output of libclang while parsing
| |
|
| |
|
| === Internal command line === | | === Compiler command lines for the code model context === |
| The debugging output from above will contain all the command line options that are passed on to libclang, which is enough for most cases. | | The file <build dir>/.qtc_clangd/compile_commands.json contains the exact command lines that clangd uses to parse the files in the project. |
|
| |
|
| However, to see also the resulting internal command line of libclang run:
| |
| # Restart Qt Creator with QTC_CLANG_NO_DIAGNOSTIC_CHECK=1 (>= Qt Creator 4.5)
| |
| # Switch to projects mode and there to the "Clang Code Model"
| |
| # Copy some warning configuration by clicking on "Copy...", give it a name like "Debug"
| |
| # Replace all the options from the copied configuration with "-###"
| |
| # Close and re-open the editor document - the new debugging output will contain also the internal command line
| |
|
| |
| Note that libclang/clangbackend will crash afterwards, so do not forget to switch back to a sane warning configuration.
| |
| == Related Environment Variables == | | == Related Environment Variables == |
| === Build related ===
| |
| * QTC_NO_CLANG_LIBTOOLING - Do not build against Clang's C++ libs; the ClangRefactoring plugin won't be build.
| |
|
| |
| === Run time related === | | === Run time related === |
| * LIBCLANG_TIMING - Timings from libclang for parse / reparse / preamble generation / completion. | | * QTC_CLANG_USE_TOOLCHAIN_MACROS - Uses also the toolchain macros for code model |
| * QTC_CLANG_NO_DIAGNOSTIC_CHECK - Avoid validation of warning configuration (>= Qt Creator 4.5) | | * QTC_CLANG_CMD_OPTIONS_BLACKLIST - Semicolon sepparated list of compiler command line options not to be passed to code model |
| * QTC_CLANG_NO_SUPPORTIVE_TRANSLATIONUNIT - Use only one translation unit per document.
| |
| * QTC_CLANG_NO_ALIVE_TIMER - Simplifies debugging in certain cases.
| |
| * QTC_CLANG_FORCE_VERBOSE_ALIVE - Simplifies debugging in certain cases.
| |
|
| |
|
| == Libclang == | | == clangd == |
| libclang is used inside clangbackend to provide code model features
| | clangd is used via the language server protocol to provide code model features |
|
| |
|
| === Builds === | | === Builds === |
Line 53: |
Line 35: |
|
| |
|
| Currently libclang is built with optimized MinGW compiler for all Qt Creator versions. More information about Windows builds: [[Build libclang on Windows]] | | Currently libclang is built with optimized MinGW compiler for all Qt Creator versions. More information about Windows builds: [[Build libclang on Windows]] |
|
| |
| === Minimal libclang installation that Qt Creator can use ===
| |
| The following targets are sufficient for this:
| |
| install-libclang install-libclang-headers install-clang-headers install-llvm-config
| |
|
| |
| == Clang Plugins ==
| |
| Clang plugins support is already in QtCreator master branch and will soon appear in the snapshots.
| |
|
| |
| Plugins usage significantly reduces libclang performance so set up your settings (Tools->Options->C++->Code Model->Clang Plugins) wisely:
| |
|
| |
| === Clazy ===
| |
| level1 adds '''50%''' to the parse/re-parse time, level0 adds only '''25%'''
| |
|
| |
| === Clang Tidy ===
| |
| clang-diagnostic-*,llvm-*,misc-* add '''200%''' to the original libclang parse/re-parse times
| |
|
| |
| == Backport candidates for Qt Creator 4.6 ==
| |
| Qt Creator 4.6 will ship with LLVM/Clang 5.
| |
|
| |
| The following changes from LLVMt/Clang trunk might be worthwhile to backport.
| |
|
| |
| '''Crash / Parsing'''
| |
|
| |
| [Sema] Fix crash in unused-lambda-capture warning for VLAs
| |
|
| |
| https://reviews.llvm.org/D41016
| |
|
| |
| '''Crash / Completion'''
| |
|
| |
| Fixed a crash in code completion.
| |
|
| |
| https://reviews.llvm.org/D37382
| |
|
| |
| Fixes crash when requesting completion at e.g. int (*foo(int a))(flo<CURSOR>
| |
|
| |
| '''Crash / Static Analyzer'''
| |
|
| |
| [analyzer] Fix a crash on C++17 AST for non-trivial construction into a trivial brace initializer.
| |
|
| |
| https://reviews.llvm.org/D40841
| |
|
| |
| '''Minor / AST Access'''
| |
|
| |
| [libclang] Fix cursors for in-class initializer of field declarations
| |
|
| |
| https://reviews.llvm.org/D40027
| |
|
| |
| https://bugs.llvm.org/show_bug.cgi?id=33745
| |
|
| |
| Fixes AST access to initializers of class members. Affects mostly semantic highlighting and highlighting of local uses.
| |
|
| |
| '''Minor / AST Access'''
| |
|
| |
| [libclang] Fix cursors for functions with trailing return type
| |
|
| |
| https://reviews.llvm.org/D40561
| |
|
| |
| '''Minor / AST properties'''
| |
|
| |
| [libclang] Add support for checking abstractness of records
| |
|
| |
| https://reviews.llvm.org/D40072
| |
|
| |
| Would need https://codereview.qt-project.org/#/c/211497/ on Qt Creator side.
| |
|
| |
| '''Improves Tooltips'''
| |
|
| |
| [DeclPrinter] Honor TerseOutput for constructors
| |
|
| |
| https://reviews.llvm.org/D39957
| |
|
| |
| Avoids printing member initialization list and body for constructor.
| |
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