Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply the provided column information to the highlighting #88

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

firewave
Copy link
Collaborator

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

firewave commented Dec 7, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant