[cfe-dev] how to check if a FieldDecl is static or not?
Nathan James via cfe-dev
cfe-dev at lists.llvm.org
Tue Oct 20 03:05:47 PDT 2020
Hi Yafei,
Static members aren't FieldDecls, they are VarDecls.
Take this example
---
class Foo {
static int Bar;
};
---
AST output is (with some boilerplate removed)
---
`-CXXRecordDecl class Foo definition
|-CXXRecordDecl implicit class Foo
`-VarDecl col:16 Bar 'int' static
---
Once you have a VarDecl you should be able to use
VarDecl::isStaticDataMember() to determine if its a static member of a
class.
~Nathan
On Tue, 2020-10-20 at 17:55 +0800, Yafei Liu via cfe-dev wrote:
> Hi, I checked all the API in FieldDecl and didn't find how to check
> if it is a static member, and I tried this also:
>
> auto FieldType = TheField->getType();
>
> and I cannot find any static checking in QualType either.
>
> So how can I check if the field is static or not?
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list