[cfe-dev] [patch] Knowing if "static" was written or not

Paolo Bolzoni paolo.bolzoni1 at studenti.unipr.it
Sun Feb 7 12:59:56 PST 2010


The enclosed patch allows to differentiate between those functions and
variables explicitly marked with the keyword static and those functions
or variables that are marked static for semantic reason.

As an example for the C language, the definition of function f below is
static even though the static keyword does not appear:

static void f(void);
void f(void) {} /* this one */


As for C++, here we have an example of a static variable where the static
keyword does not appear:

struct A {
  static int a;
};
int A::a = -1; /* this one */


Currently there seems to be no way to distinguish between a function
that is static because the keyword static is there or because a previous
declaration was marked as static. My patch added few member functions to
FunctionDecl in order to allow making such a distinction.

It is already possible to detect the difference in the variables, but for
sake of clearness I also put a similar member function in VarDecl.

Paolo Bolzoni
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch_clang.tar.gz
Type: application/x-gzip
Size: 3091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100207/341bbbd3/attachment.bin>


More information about the cfe-dev mailing list