<div dir="ltr">I've posted this originally in the mailing list <a href="http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html">http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html</a> but so far, never came across a solution.</div><div class="gmail_extra"><br><div class="gmail_quote">2017-04-12 22:35 GMT+02:00 via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Did you ever find any data in clang that can be used to resolve the following? I've got a similar problem and the hack we're using is fragile and unappealing.<br>
<br>
<quote author='Brennan Vincent via cfe-dev'><br>
Hi,<br>
<br>
I am trying to transform all T a, b, c = ...; to single line declarations:<br>
<br>
T a;<br>
T b;<br>
T c = ...;<br>
<br>
This works well by matching for DeclStmt and iterating through the<br>
DeclGroup. Unfortunately, a global declared T a, b, c = ...;  does not<br>
result in such a DeclStmt:<br>
<br>
<cpp><br>
int alone;<br>
int alone2 = 3;<br>
<br>
int notalone1, notalone2 = 4;<br>
<br>
int main(void)<br>
{<br>
int lalone;<br>
int lalone2 = 3;<br>
<br>
int lnotalone1, lnotalone2 = 4;<br>
<br>
}<br>
</cpp><br>
<br>
>> clang-check -ast-dump test.c --<br>
TranslationUnitDecl 0x1742960 <<invalid sloc>> <invalid sloc><br>
|-TypedefDecl 0x1742e58 <<invalid sloc>> <invalid sloc> implicit __int128_t<br>
'__int128'<br>
|-TypedefDecl 0x1742eb8 <<invalid sloc>> <invalid sloc> implicit<br>
__uint128_t 'unsigned __int128'<br>
|-TypedefDecl 0x1743228 <<invalid sloc>> <invalid sloc> implicit<br>
__builtin_va_list '__va_list_tag [1]'<br>
|-VarDecl 0x1743288 </tmp/test.c:1:1, col:5> col:5 alone 'int'<br>
|-VarDecl 0x1743338 <line:2:1, col:14> col:5 alone2 'int' cinit<br>
| `-IntegerLiteral 0x1743398 <col:14> 'int' 3<br>
|-VarDecl 0x17433c8 <line:4:1, col:5> col:5 notalone1 'int'<br>
|-VarDecl 0x1743438 <col:1, col:28> col:16 notalone2 'int' cinit<br>
| `-IntegerLiteral 0x1743498 <col:28> 'int' 4<br>
`-FunctionDecl 0x1743590 <line:6:1, line:13:1> line:6:5 main 'int (void)'<br>
  `-CompoundStmt 0x1789d80 <line:7:1, line:13:1><br>
    |-DeclStmt 0x1789b90 <line:8:2, col:12><br>
    | `-VarDecl 0x1789b30 <col:2, col:6> col:6 lalone 'int'<br>
    |-DeclStmt 0x1789c38 <line:9:2, col:17><br>
    | `-VarDecl 0x1789bb8 <col:2, col:16> col:6 lalone2 'int' cinit<br>
    |   `-IntegerLiteral 0x1789c18 <col:16> 'int' 3<br>
    `-DeclStmt 0x1789d68 <line:11:2, col:32><br>
      |-VarDecl 0x1789c60 <col:2, col:6> col:6 lnotalone1 'int'<br>
      `-VarDecl 0x1789cd0 <col:2, col:31> col:18 lnotalone2 'int' cinit<br>
        `-IntegerLiteral 0x1789d30 <col:31> 'int' 4<br>
<br>
>> clang-check -version<br>
LLVM (<a href="http://llvm.org/" rel="noreferrer" target="_blank">http://llvm.org/</a>):<br>
  LLVM version 3.7.0<br>
  Optimized build.<br>
  Built Oct 31 2015 (11:07:58).<br>
  Default target: x86_64-unknown-linux-gnu<br>
  Host CPU: ivybridge<br>
<br>
As you can see, each notalone is a VarDecl whereas VarDecl for lnotaloneX<br>
is grouped in a DeclStmt. Is there any other way to find all the<br>
init-declarator lists?<br>
<br>
Thanks!<br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br>
</quote><br>
Quoted from:<br>
<a href="http://clang-developers.42468.n3.nabble.com/global-init-declarator-list-not-parsed-as-DeclStmt-tp4048843.html" rel="noreferrer" target="_blank">http://clang-developers.42468.<wbr>n3.nabble.com/global-init-<wbr>declarator-list-not-parsed-as-<wbr>DeclStmt-tp4048843.html</a><br>
<br>
<br>
______________________________<wbr>_______<br>
Sent from <a href="http://clang-developers.42468.n3.nabble.com" rel="noreferrer" target="_blank">http://clang-developers.42468.<wbr>n3.nabble.com</a><br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>