Menu

library configuration: argument type / output parameter

2019-02-28
2019-02-28
  • Daniel Marjamäki

    It would help Cppcheck ValueFlow analysis if it knows if a function parameter is an "output" parameter.

    Example code:

        int x = 0;
        dostuff(x); // <- is x changed by dostuff?
        return y / x; // <- is this a division by zero?
    

    What do you think? Should we add "argument type" information or just some <input> or <output> element?

     
  • Daniel Marjamäki

    My spontanous feeling is that we can add <output> now for this purpose. And then full "argument type" information later to make it possible to configure overloaded functions.

    I would be interested to hear what you think..

     
  • orbitcowboy

    orbitcowboy - 2019-02-28

    Good idea: How about <arg nr="1" direction="in"/> for input. Output could be direction="out" and input and output arguments could be configured as direction="inout"?

     
  • Daniel Marjamäki

    Thanks for your feedback. Since you are very active, I want to know what your preference is.

     
  • orbitcowboy

    orbitcowboy - 2019-02-28

    I prefer my solution because it is more compact. But it is no showstopper if your suggestion is implemented :-)

     
  • versat

    versat - 2019-02-28

    +1 for first adding the possibility to specify if it is an input and / or output argument.

    I have no preference for a concrete syntax.
    If i can help for example with enhancing the relaxng file i am glad to hear what to do. I plan to work further on it anyway.

     
  • Daniel Marjamäki

    If i can help for example with enhancing the relaxng file i am glad to hear what to do. I plan to work further on it anyway.

    Feel free to implement the suggestion made by orbitcowboy. Is it ok if you:
    - fix the relaxng file
    - Add a variable (enum) in our Library
    - Fix the Library load function.

    ?

    After that we can look at using this info in the analysis. Feel free to adjust the isVariableChangedByFunctionCall().

     

    Last edit: Daniel Marjamäki 2019-02-28
  • Daniel Marjamäki

    I would be very happy to delegate all this to you :-)

     
  • versat

    versat - 2019-02-28

    Ok. If you can wait until tomorrow i will try to implement it. Not sure about the last part because i have not looked at this function but i will see 😀
    If someone wants to implement it now i have no problem with that also.

     
  • Daniel Marjamäki

    Great.. I can wait until tomorrow. Let me know if I can help you with the isVariableChangedByFunctionCall(). A hint: if there is library configuration then I do not think it's necessary to set the "inconclusive" flag.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.