<div dir="ltr">Hi Nathan, thanks a lot, I think your answer teaches me a way of how to figure problems out by myself, I rarely print a class to AST for investigation before.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 20, 2020 at 6:05 PM Nathan James <<a href="mailto:nayjames123@gmail.com">nayjames123@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Yafei,<br>
<br>
Static members aren't FieldDecls, they are VarDecls.<br>
<br>
Take this example<br>
---<br>
class Foo {<br>
    static int Bar;<br>
};<br>
---<br>
<br>
AST output is (with some boilerplate removed)<br>
---<br>
`-CXXRecordDecl class Foo definition<br>
  |-CXXRecordDecl implicit class Foo<br>
  `-VarDecl col:16 Bar 'int' static<br>
---<br>
<br>
Once you have a VarDecl you should be able to use<br>
VarDecl::isStaticDataMember() to determine if its a static member of a<br>
class.<br>
<br>
~Nathan<br>
<br>
On Tue, 2020-10-20 at 17:55 +0800, Yafei Liu via cfe-dev wrote:<br>
> Hi, I checked all the API in FieldDecl and didn't find how to check<br>
> if it is a static member, and I tried this also:<br>
> <br>
> auto FieldType = TheField->getType();<br>
> <br>
> and I cannot find any static checking in QualType either.<br>
> <br>
> So how can I check if the field is static or not?<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote></div>