[cfe-dev] [Clang-tidy] Detecting if a catch was done by const ref
Richard via cfe-dev
cfe-dev at lists.llvm.org
Mon Mar 12 12:34:35 PDT 2018
[Please reply *only* to the list and do not include my email directly
in the To: or Cc: of your reply; otherwise I will not see your reply.
Thanks.]
In article <CAAt6xTvjSPEg7OVPWVbtqWdsDp5zja9_TfLTkdzoNoksmEr=KQ at mail.gmail.com>,
Aaron Ballman via cfe-dev <cfe-dev at lists.llvm.org> writes:
> I believe the matcher you're looking for is:
> varDecl(hasType(references(qualType(isConstQualified()))))
>
> For example, given:
>
> void f1() {
> try {
> } catch (int &e) {
> }
> }
>
> void f2() {
> try {
> } catch (const int &e) {
> }
> }
>
> produces:
>
> clang-query> match
> varDecl(hasType(references(qualType(isConstQualified()))))
>
> Match #1:
>
> C:\Users\Aaron\Desktop\test.cpp:9:12: note: "root" binds here
> } catch (const int &e) {
> ^~~~~~~~~~~~
> 1 match.
I think they want to match the catches that aren't const qualified, so
it might be (untested):
varDecl(hasType(references(qualType(not(isConstQualified())))))
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
More information about the cfe-dev
mailing list