Add new ASTMatcher that matches dynamic exception specifications.
Details
Diff Detail
Event Timeline
Please add tests, re-generate documentation and add the matcher to the dynamic matchers registry. See http://reviews.llvm.org/D19871 for an example.
- Added test, re-generated documentation, and add new matcher to the dynamic matchers registry.
include/clang/ASTMatchers/ASTMatchers.h | ||
---|---|---|
3229 | It's a bit odd to expose this on the declaration instead of the type since the AST carries this information on the type, not the declaration. I definitely see the utility in not having to go from the decl to the type in an AST matcher, though. Can you expose it on both FunctionDecl and FunctionProtoType instead? |
include/clang/ASTMatchers/ASTMatchers.h | ||
---|---|---|
3229 | It's modeled on the isNoThrow matcher directly below which used FunctionDecl, so I used it for this one too. Did you want me change this one to use FunctionProtoType or add 2 matchers, one using FunctionDecl and another one using FunctionProtoType? |
LGTM!
include/clang/ASTMatchers/ASTMatchers.h | ||
---|---|---|
3229 | Ah, good point about isNoThrow. I would say leave it as FunctionDecl for now and maybe a follow-on patch (not requesting you do this work, btw) can convert it to be a polymorphic matcher that accepts FunctionDecl and FunctionProtoType. |
- Added new isThrow matcher to complement isNoThrow, and changed hadDynamicExceptionSpec to take a parameter, e.g., isThrow() or isNoThrow().
I'm not keen on the new direction this patch has taken. hasDynamicExceptionSpec(isThrow()) is quite novel. What is the problem you are trying to solve with this?
include/clang/ASTMatchers/ASTMatchers.h | ||
---|---|---|
3251 | I'm not comfortable with this matcher; users can use unless(isNoThrow()) to get this behavior already. |
Great, unless() was what I was missing. I'll refactor along those lines.
As for what I'm trying to achieve, I want a set containing "throw()" and another set containing "throw(something)". If there's a cleaner way to achieve that with an existing matcher, please let me know.
allOf(hasDynamicExceptionSpecification(), isNoThrow()) gets you "throw()" and allOf(hasDynamicExceptionSpecification(), unless(isNoThrow()) gets you "throw(something)", doesn't it?
Okay, back to looking good. :-) I will commit on your behalf, since I'm back to somewhere with source access again.
It's a bit odd to expose this on the declaration instead of the type since the AST carries this information on the type, not the declaration. I definitely see the utility in not having to go from the decl to the type in an AST matcher, though. Can you expose it on both FunctionDecl and FunctionProtoType instead?