How to check if a Decl is static

Hi all,

I need to check if a given Decl, and more specifically a FunctionDecl, is declared static.
Currently I’m manually looking for the static token using SourceManager::getCharcterData.
Is there more elegant way?

Thanks in advance,

Only members can be static, right?
I believe what you are looking for is clang::CXXMethodDecl::isStatic(), defined in clang/AST/DeclCXX.h (There was a thread recently: “Online Doxygen docs are incomplete”)


Thank you, but I’m working on C files, not C++.
Is there similar isStatic method in C context?

Thanks in advance,

VarDecl has getStorageClass() and getStorageClassAsWritten(). The latter is what the user actually used on the decl, the former is computed by merging decls.