Example source code:
---<
int a,b,c;
void f() {
int a,b,c;
}
--->
in this simple code clang sees two top level declarations.
The first is a variable declaration (clang::VarDecl) and you can read all
declarations using getNextDeclarator() of the base class clang::ScopedDecl.
Instead the second is a function declaration. Its definition is a compound
statement, the first statement is a declaration statement (clang::DeclStmt),
here to see all the variables actually declared you need to use the
decl_iterators, where each returns a _single_ clang::VarDecl.
Since single variable declarations can express chains of declarations I see
strange this difference. Where is the reason?
Wasn't easier connect the DeclStmt with a single Decl, just like global type
or variable declarations?
pb
Example source code:
---<
int a,b,c;
void f() {
int a,b,c;
}
--->
in this simple code clang sees two top level declarations.
The first is a variable declaration (clang::VarDecl) and you can read all
declarations using getNextDeclarator() of the base class clang::ScopedDecl.
Instead the second is a function declaration. Its definition is a compound
statement, the first statement is a declaration statement (clang::DeclStmt),
here to see all the variables actually declared you need to use the
decl_iterators, where each returns a _single_ clang::VarDecl.
Since single variable declarations can express chains of declarations I see
strange this difference. Where is the reason?
Wasn't easier connect the DeclStmt with a single Decl, just like global type
or variable declarations?
DeclStmt's are implemented in terms of DeclGroup's. The motivation for DeclGroup's was discussed back in August.
See http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-August/002589.html for the thread.
Since DeclStmt's don't appear at file scope, there is an inconsistency. I don't recall if this work was completed (which might explain the inconsistency). I noticed a comment in VarDecl which says "Move to DeclGroup when it is implemented". Ted/Daniel, is this still a work in progress?
snaroff