clion-cppcheck icon indicating copy to clipboard operation
clion-cppcheck copied to clipboard

apply the provided column information to the highlighting

Open firewave opened this issue 2 years ago • 2 comments

This applies the provided information from Cppcheck and improves the highlighting.

Example:

        <error id="returnDanglingLifetime" severity="error" msg="Returning pointer that will be invalid when returning." verbose="Returning pointer that will be invalid when returning." cwe="562" file0="C:/Users/Username/AppData/Local/Temp/FGuuaiWE_test.cpp">
            <location file="C:\Users\Username\AppData\Local\Temp\FGuuaiWE_test.cpp" line="5" column="9"/>
            <location file="C:\Users\Username\AppData\Local\Temp\FGuuaiWE_test.cpp" line="4" column="37" info="Pointer to container is created here."/>
        </error>

Before:

image

After:

image

firewave avatar Apr 26 '23 13:04 firewave

This might look a bit strange. Here's how Cppcheck displays it:

/mnt/s/clion/example_lite_3/test.cpp:5:9: error: Returning pointer that will be invalid when returning. [returnDanglingLifetime]
 return c;
        ^
/mnt/s/clion/example_lite_3/test.cpp:4:37: note: Pointer to container is created here.
 const char* c = std::string().c_str();
                                    ^
/mnt/s/clion/example_lite_3/test.cpp:5:9: note: Returning pointer that will be invalid when returning.
 return c;
        ^

Just highlighting the column in question might be too subtle. It might make more sense to limit it to the token and it looks like the Document offers that but I wonder how consistent that would be. The end of the affected code could also be provided by Cppcheck but that would require upstream changes.

firewave avatar Apr 27 '23 08:04 firewave

We should only highlight the token in question. We could try to determine this information ourselves (I think the Document even offers a function for that).

Or Cppcheck could offer the information in the output. I filed a ticket about offering this information: https://trac.cppcheck.net/ticket/12250.

firewave avatar Dec 07 '23 16:12 firewave