<div dir="ltr"><div>I want to insert the enum constants from the values that are in the code.  One driving reason behind this is that there isn't really any single group that owns the enum.  One group could write it, but then nobody else would be permitted to modify it.  A different group could write it, but then they would have to generate some matching tables by hand.  Neither option is really acceptable.</div><div><br></div><div>The ideal is to write the enum value and pull it out of the code and generate the enum and associated tables.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 23, 2015 at 11:13 AM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><span>On Thu, Apr 23, 2015 at 7:43 PM Daniel Dilts <<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr">Yeah, I suspected as much.  Is there any real option for finding this location?  Would I have to do it where it is building the AST?</div></blockquote><div><br></div></span><div>Nope. For parsing incorrect code you need to write your own "parser". Why do you want to parse incorrect code though?</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 23, 2015 at 10:25 AM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr">Ok, this only works on valid code. If you have errors, all bets are off.<br></div><div><div><br><div class="gmail_quote">On Thu, Apr 23, 2015 at 7:23 PM Daniel Dilts <<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><br><div class="gmail_extra"><br></div><div class="gmail_quote">On Fri, Apr 17, 2015 at 5:19 PM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><br><br><div class="gmail_quote"><span>On Thu, Apr 16, 2015 at 5:45 PM Daniel Dilts <<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div>I am attempting to write a tool that will generate a table from tokens pulled from source code.</div><div><br></div><div>I have a static template function in a template class.  I want to find the first argument for all calls to the template function.</div><div><br></div><div>The problem is that the token may or may not be defined, since they will be defined in a generated table.</div><div><br></div><div>If I use dump-ast it appears that the function call is omitted from the AST, so I don't think that I can use AST matchers to find it.</div></div></blockquote><div><br></div></span><div>I somehow can't believe that - all calls are in the AST.</div></div></div></blockquote><div><br></div><div> </div></div></div><div dir="ltr"><div class="gmail_extra">Here is my example, using "clang version 3.7.0 (trunk 235602)".  Note that the call to Func is not present in the AST.</div><div class="gmail_extra"><br></div><div class="gmail_extra">enum MyEnum<br>{<br>};<br>void Func(MyEnum v);<br>int main()<br>{<br> Func(SomeEnumValue);<br> return 0;<br>}</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">clang.exe -Xclang -ast-dump test.cpp<br>test.cpp:7:7: error: use of undeclared identifier 'SomeEnumValue'<br>        Func(SomeEnumValue);<br>             ^<br>TranslationUnitDecl 0x836140 <<invalid sloc>> <invalid sloc><br>|-CXXRecordDecl 0x836400 <<invalid sloc>> <invalid sloc> implicit class type_inf<br>o<br>| `-TypeVisibilityAttr 0x836470 <<invalid sloc>> Implicit Default<br>|-TypedefDecl 0x8364b0 <<invalid sloc>> <invalid sloc> implicit size_t 'unsigned<br> int'<br>|-TypedefDecl 0x836508 <<invalid sloc>> <invalid sloc> implicit __builtin_va_lis<br>t 'char *'<br>|-EnumDecl 0x836538 <test.cpp:1:1, line:3:1> line:1:6 referenced MyEnum 'int'<br>|-FunctionDecl 0x836630 <line:4:1, col:19> col:6 Func 'void (enum MyEnum)'<br>| `-ParmVarDecl 0x8365b8 <col:11, col:18> col:18 v 'enum MyEnum'<br>`-FunctionDecl 0x836718 <line:5:1, line:9:1> line:5:5 main 'int (void)'<br>  `-CompoundStmt 0x836880 <line:6:1, line:9:1><br>    `-ReturnStmt 0x836870 <line:8:2, col:9><br>      `-IntegerLiteral 0x836850 <col:9> 'int' 01 error generated.<br></div><div class="gmail_extra"><br></div></div>
</blockquote></div>
</div></div></blockquote></div><br></div>
</blockquote></div></div></div></div>
</blockquote></div><br></div>