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

Highlight function arguments that may get modified

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • Not Evaluated
    • None
    • None
    • C/C++/Obj-C++ Support
    • None

    Description

      On the developer mailinglist, a discussion arose over using out variables using references versus using pointers (and whether to use out arguments at all). That triggered an idea that it would be useful if creator would highlight function arguments that may get changed by the function call.

      Say you are calling a function with this signature:

      bool doSomething(int a, int b, int& c);
      if (doSomething(myA, myB, myC)) {
        //...
      }

      it would be very helpfull if the myC argument would get a different highlight than myA and myB, so signify that its value may get modified by the call.

      Of course, if it were a const-ref, it would not be higlighted. It it were a pointer, it would, but if it were a pointer-to-const, it would not.

      Smart pointers would of course be a problem for this feature. I don't know how advanced the code model is in creator; perhaps it could do a best-effort for such objects.

      The use case is of course that it is much easier to reason about code if you can easily spot what values my change where. The return value of a function is easy in that respect, but out-parameters are not. I guess that is why they are banned in some coding standards, but the fact of the matter is that they are used and there may be very good reason to use them. It would help if they are easy to spot.

      Attachments

        Issue Links

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

          Activity

            People

              kandeler Christian Kandeler
              andre André Somers
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes