Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-27111

More code coloring issues with clangd

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Fixed
    • Affects Version/s: Qt Creator 7.0.0-beta2
    • Fix Version/s: Qt Creator 7.0.0-rc1
    • Component/s: C/C++/Obj-C++ Support
    • Labels:
      None
    • Environment:
      Kubuntu 21.10
    • Platform/s:
      Linux/X11

      Description

      __func__ built-in macro is colored as a literal rather than a macro in QtCreator 7.0.0-beta2 with clangd enabled.

      This is also the case for __FUNCTION__ and __PRETTY_FUNCTION__.

      defined preprocessor keyword (e.g. #if defined(FOO) is colored black, as general text.

      Base type of an enum is colored black, if it's a typedef. For example:

      enum : std::uint32_t
      {
          zero
      };
      
      enum foo : std::uint32_t
      {
          bar
      };
      

      Stream name in output expression is italic, but only the variable name without the namespace name. For example:

      std::cout << "Hello" << std::endl;
      

      Here, only cout is italic, not std::. I should note that without clangd, std::cout is not italic (in full).

      Function parameters that are taken by const reference and passed by const reference to another function, are rendered italic, as if they are output parameters. For example:

      template< typename T >
      int test_ptr(std::unique_ptr< T > const& p);
      
      int test(std::unique_ptr< int > const& p)
      {
      	std::cout << test_ptr(p);
      	return 0;
      }
      

      Here p in test_ptr call is italic.

      For convenience, here is the complete testcase with the above issues:

      #include <cstdint>
      #include <memory>
      #include <type_traits>
      #include <string>
      #include <iostream>
      
      #if defined(FOO)
      #error Error
      #endif
      
      enum : std::uint32_t
      {
      	zero
      };
      
      enum foo : std::uint32_t
      {
      	bar
      };
      
      template< typename T >
      int test_ptr(std::unique_ptr< T > const& p);
      
      int test(std::unique_ptr< int > const& p)
      {
      	std::cout << __func__ << __FUNCTION__ << __PRETTY_FUNCTION__ << std::endl;
      	std::cout << test_ptr(p);
      
      	return 0;
      }
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            kandeler Christian Kandeler
            Reporter:
            lastique Andrey Semashev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes