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

Improve error recovery in Clang Model in function arguments (incomplete AST due errors)

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • P2: Important
    • None
    • Qt Creator 4.7.0, Qt Creator 4.8.0-beta1
    • C/C++/Obj-C++ Support
    • Linux/X11

    Description

      I started trying out Clang Core Model, since I heard the old one is going to be eventually be removed (note apart: it is a bit of a resource hog, but a quick google shows it's a very common complaint).

      There is an issue that is happening all the time for me, and it is becoming too annoying to the point I had to disable the plugin.

      When I have simple functions, such as this one:

      void test( int width, int height, int depth, int numMipmaps );
      
      void foo()
      {
          int width = 0, height = 0, depth = 0, numMipmaps = 0;
          test( width, height, depth, numMipmaps );
      }
      

      It will show up like this:

      If I enter a mistake, the old code model would stop highlighting "depth_wrong" because it is invalid:

      But with the Clang model, the following happens:

      depth_wrong is underlined (nice) but the whole arguments stopped being highlighted!!!

      It is very hard to code like this when QtCreator keeps shifting between highlighted and all-black variables as I type. It is very distracting.

      The same problem arises when I'm modifying a pre-existing function (specially complex ones): the whole thing flashes to black and now it is very hard what is wrong and what is right; despite the underline.

      I understand that Clang has worse error recovery but it sounds like QtCreator still has enough information to show the proper colour, given that autocompletion still works, and so do snippets that come afterwards.

      QtCreator could overcome this limitation by:

      1. Using old information. The correct information was working 10 seconds ago, just fetch old data
      2. Internally fix those silly errors. depth_wrong is not valid? Replace it int(0), clang will now work

      This is a real case:

      What's wrong is that baseMipLevel & mapType are not defined.
      mTextureArrays is declared as:

      enum TextureMapType
      {
          TEXTURE_TYPE_DIFFUSE,
          NUM_TEXTURE_TYPES
      };
      typedef vector<TextureArray>::type TextureArrayVec;
      TextureArrayVec     mTextureArrays[NUM_TEXTURE_TYPES];
      

      If I replace baseMipLevel with uint8() and mapType with TextureMapType() highlighting works again:

      Also considering that even when highlighting is broken "Follow Symbol Under Cursor" still works for black text, it seems like QtCreator still has enough information to keep highlighting working correctly.

      Whether it's a QtCreator bug, or an issue on how Clang works, QtCreator should be capable of recovering from such simple errors and greatly enhance as a tool.

      Because frankly as it is right now, with such poor error recovery the overall coding productivity decreases, outweighing the benefits.

      Cheers

      Attachments

        1. 01.png
          01.png
          25 kB
        2. 02.png
          02.png
          26 kB
        3. 03.png
          03.png
          26 kB
        4. 04.png
          04.png
          84 kB
        5. 05.png
          05.png
          94 kB

        Issue Links

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

          Activity

            People

              kandeler Christian Kandeler
              dark_sylinc Matias N. Goldberg
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes