This is an archive of the discontinued LLVM Phabricator instance.

Extraction of a matcher for an unused value from an expression from the bugprone-unused-return-value check
Needs ReviewPublic

Authored by barcisz on Sep 13 2022, 12:36 PM.

Details

Summary

This diff extracts the matcher for an unused expression result from bugprone-unused-return-value into a utility. This diff is a prerequisite to D133804 which introduces
the cuda-unsafe-api-call-check

Diff Detail

Event Timeline

barcisz created this revision.Sep 13 2022, 12:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 13 2022, 12:36 PM
barcisz requested review of this revision.Sep 13 2022, 12:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 13 2022, 12:36 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jbcoe resigned from this revision.Sep 14 2022, 7:44 AM
barcisz edited the summary of this revision. (Show Details)Sep 15 2022, 3:02 PM

I feel like this matcher could do with some unit testing. I'd say create a test file in clang-tools-extra/unittests/clang-tidy/MatchersTest.cpp

clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
143–144

Can all these be removed now?

barcisz updated this revision to Diff 461562.Sep 20 2022, 7:11 AM

Removed unused matcher definitions from bugprone-unused-return-value

This comment was removed by barcisz.
barcisz updated this revision to Diff 461721.Sep 20 2022, 2:50 PM

Tests for the check

njames93 added a subscriber: kwk.Sep 22 2022, 11:15 PM
njames93 added inline comments.
clang-tools-extra/unittests/clang-tidy/MatchersTest.cpp
2 ↗(On Diff #461721)

@kwk I seem to recall you saying in another patch that this include will break standalone builds, would stripping the leading ../../ work?

kwk added inline comments.Sep 23 2022, 2:17 AM
clang-tools-extra/unittests/clang-tidy/MatchersTest.cpp
2 ↗(On Diff #461721)

@kwk I seem to recall you saying in another patch that this include will break standalone builds,

@njames93 that's correct. But I don't recall the patch ID :/

would stripping the leading ../../ work?

I don't know if the file is found then but it would make standalone builds certainly easier.

I'm not sure if I calculate correctly but given:

clang-tools-extra/unittests/clang-tidy/MatchersTest.cpp

then ../../ means clang-tools-extra/, no? If so, that directory doesn't contain a clang directory here. It seems as if the ../../ is relative to some other directory but not this file. Or am I too tired to get it?

njames93 added inline comments.Sep 23 2022, 10:47 AM
clang-tools-extra/unittests/clang-tidy/MatchersTest.cpp
2 ↗(On Diff #461721)

I'll test when I get a few cycles. If not, may need to copy some of the testing logic for this.

barcisz added inline comments.Sep 23 2022, 8:33 PM
clang-tools-extra/unittests/clang-tidy/MatchersTest.cpp
2 ↗(On Diff #461721)

Yes, the tests do indeed work but it's probably because it's getting the include path from another directory. I was actually thinking of adding the directory for clang as an include path within cmake but thought this would be better. There is also an option of copying the testing setup from clang and pasting it here, or to just create testing checks and use the existing check testing utilities to run the matchers inside of those checks. What do you reckon is the best solution in that case to the problem of standalone builds?

LegalizeAdulthood resigned from this revision.Mar 29 2023, 8:20 AM
tra added a subscriber: tra.Mar 29 2023, 11:48 AM