Parameters of function declarations not included in decls_begin/decls_end #7814
Labels
bugzilla
Issues migrated from bugzilla
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
Extended Description
For the following code:
int foo(int bar);
int foo(int bar) {
return bar;
}
The first declaration of foo does not include 'int bar' in its decls_begin/decls_end, while the second does. Here the analysis, from a test program I wrote using RecursiveASTVisitor:
[ FunctionDecl ] sample.cc:17:5: int foo(int bar)
[ FunctionProtoType ] (sample.cc:17:5): int (identifier)(int)
Visiting result type
[ BuiltinType ] (sample.cc:17:5): int identifier
Visiting parameters
[@@@ HERE IS THE BUG -- there's nothing here @@@]
Done
[ FunctionDecl ] sample.cc:19:5: int foo(int bar) {
return bar;
}
[ FunctionProtoType ] (sample.cc:19:5): int (identifier)(int)
Visiting result type
[ BuiltinType ] (sample.cc:19:5): int identifier
Visiting parameters
[ ParmVarDecl ] sample.cc:19:13: int bar
[ BuiltinType ] (sample.cc:19:13): int identifier
Visiting function body
[ CompoundStmt ] (CompoundStmt 0x12f1f80 <sample.cc:19:18, line:21:1>
(ReturnStmt 0x12f1f58 <line:20:3, col:10>
(DeclRefExpr 0x12f1f28 col:10 'int' ParmVar='bar' 0x12f1e30)))
[ ReturnStmt ] (ReturnStmt 0x12f1f58 <sample.cc:20:3, col:10>
(DeclRefExpr 0x12f1f28 col:10 'int' ParmVar='bar' 0x12f1e30))
[ DeclRefExpr ] (DeclRefExpr 0x12f1f28 sample.cc:20:10 'int' ParmVar='bar' 0x
12f1e30)
The "visiting parameters" code just iterates over decls_begin/end.
dgregor analyzed the solution as follows:
it makes sense to have ParmVarDecls show up in the lexical scope of function declarations. we'd probably have to do that in Sema::ActOnFunctionDeclarator rather than Sema::ActOnStartOfFunctionDef
craig
The text was updated successfully, but these errors were encountered: