[PATCH] D43120: [clang-tidy] New checker for exceptions that are created but not thrown
Umann Kristóf via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 12 07:53:49 PST 2018
Szelethus marked 7 inline comments as done.
Szelethus added inline comments.
================
Comment at: clang-tidy/misc/ThrowKeywordMissingCheck.cpp:45
+ diag(TemporaryExpr->getLocStart(),
+ "exception instantiated but not bound (did you intend to 'throw'?)");
+}
----------------
aaron.ballman wrote:
> I'm not keen on the wording here ("bound" isn't a common phrase for exceptions). How about `"suspicious exception object created but not thrown; did you mean 'throw %0'"` and then pass in the text for the object construction?
I tried using the `Lexer::getSourceText` function, but it doesn't print the right parantheses (ex. `RegularException(` instead of `RegularException()`).
Also, are you sure it'd be a good idea to pass the entire statement there? In cases where it would be long, it could draw the programmer's attention away from the actual problem, the missing `throw` keyword.
https://reviews.llvm.org/D43120
More information about the cfe-commits
mailing list