This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix potential assert in use-noexcept check
ClosedPublic

Authored by njames93 on May 21 2020, 3:11 AM.

Details

Summary

Fix a potential assert in use-noexcept check if there is an issue getting the TypeSourceInfo as well as a small clean up.

Diff Detail

Event Timeline

njames93 created this revision.May 21 2020, 3:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 21 2020, 3:11 AM

Figured out the actual cause of this bug, getExceptionSpecRange() returns a null range if the function has an unknown return type

undefined_type throws() throw();

This is the tidy output (where assertions are disabled)

warning: dynamic exception specification '' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
/home/ce/example.cpp:1:1: error: unknown type name 'undefined_type' [clang-diagnostic-error]
undefined_type throws() throw();
^
1 warning and 1 error generated.
Error while processing /home/ce/example.cpp.
Found compiler error(s).
aaron.ballman accepted this revision.May 23 2020, 6:48 AM

LGTM, but please add a test case for the changes.

This revision is now accepted and ready to land.May 23 2020, 6:48 AM
njames93 updated this revision to Diff 265899.May 23 2020, 4:35 PM
  • Isolated exact cause of the assert.

LGTM, but please add a test case for the changes.

As this fix is preventing a crash in error causing code I can't include a specific test case as the clang-tidy tests will fail if there is any error emitted from clang.

LGTM, but please add a test case for the changes.

As this fix is preventing a crash in error causing code I can't include a specific test case as the clang-tidy tests will fail if there is any error emitted from clang.

We support that case as well. See test/clang-tidy/checkers/misc-unused-using-decls-errors.cpp as an example.

njames93 updated this revision to Diff 265923.May 24 2020, 6:39 AM
  • Added test case
This revision was automatically updated to reflect the committed changes.