Qt Creator Clang Code Model: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Add section "Minimal libclang installation that Qt Creator can use")
(Update with regard to QTC_CLANG_NO_DIAGNOSTIC_CHECK)
Line 24: Line 24:


However, to see also the resulting internal command line of libclang run:
However, to see also the resulting internal command line of libclang run:
# Restart Qt Creator with QTC_CLANG_NO_DIAGNOSTIC_CHECK=1
# Switch to projects mode and there to the "Clang Code Model"
# 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"
# Copy some warning configuration by clicking on "Copy...", give it a name like "Debug"
Line 36: Line 37:
=== Run time related ===
=== Run time related ===
* LIBCLANG_TIMING - Timings from libclang for parse / reparse / preamble generation / completion.
* LIBCLANG_TIMING - Timings from libclang for parse / reparse / preamble generation / completion.
* QTC_CLANG_NO_DIAGNOSTIC_CHECK - avoid validation of warning configuration
* QTC_CLANG_NO_SUPPORTIVE_TRANSLATIONUNIT - Use only one translation unit per document.
* QTC_CLANG_NO_SUPPORTIVE_TRANSLATIONUNIT - Use only one translation unit per document.
* QTC_CLANG_NO_ALIVE_TIMER - Simplifies debugging in certain cases.
* QTC_CLANG_NO_ALIVE_TIMER - Simplifies debugging in certain cases.

Revision as of 12:32, 26 September 2017

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
export LIBCLANG_TIMING=1
./qtcreator

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

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

The debugging output contains among others:

  • The IPC messages send/received
  • Output of libclang while parsing

Internal command line

The debugging output from above will contain all the command line options that are passed on to libclang, which is enough for most cases.

However, to see also the resulting internal command line of libclang run:

  1. Restart Qt Creator with QTC_CLANG_NO_DIAGNOSTIC_CHECK=1
  2. Switch to projects mode and there to the "Clang Code Model"
  3. Copy some warning configuration by clicking on "Copy...", give it a name like "Debug"
  4. Replace all the options from the copied configuration with "-###"
  5. 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

Build related

  • QTC_NO_CLANG_LIBTOOLING - Do not build against Clang's C++ libs; the ClangRefactoring plugin won't be build.

Run time related

  • LIBCLANG_TIMING - Timings from libclang for parse / reparse / preamble generation / completion.
  • QTC_CLANG_NO_DIAGNOSTIC_CHECK - avoid validation of warning configuration
  • 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

libclang is used inside clangbackend 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

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