<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - SBTarget::FindTypes does not find resolved function pointer types"
   href="https://llvm.org/bugs/show_bug.cgi?id=31706">31706</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SBTarget::FindTypes does not find resolved function pointer types
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alexandru.croitor@qt.io
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=17872" name="attach_17872" title="Example code which shows the issue regarding FindTypes">attachment 17872</a> <a href="attachment.cgi?id=17872&action=edit" title="Example code which shows the issue regarding FindTypes">[details]</a></span>
Example code which shows the issue regarding FindTypes

SBTarget::FindTypes does not find resolved function pointer types, which were
declared as function pointer typedefs.

Consider the code:

typedef struct _type {
  int value;
} MyType;
typedef void (*FunctionPointer)(MyType*);

void function(MyType* t) {
    (void) t;
}

int main(int argc, char* argv[]) {
    MyType t;
    FunctionPointer fp = &function;
    fp(&t);
    return 0;
}

Compile with clang++ -O0 -g ./main.cpp
Run lldb ./a.out and go into python script mode, then:

<span class="quote">>>> lldb.target.FindTypes("FunctionPointer").GetSize()</span >
1

<span class="quote">>>> lldb.target.FindTypes("void (*)(MyType*)").GetSize()</span >
0


<span class="quote">>>> lldb.target.FindTypes("void (*)(MyType *)").GetSize()</span >
0

But if I do:
<span class="quote">>>> for t in lldb.target.GetModuleAtIndex(0).GetTypes():</span >
...   print t.GetName()

I get:

FunctionPointer
void (*)(MyType *)
MyType *
MyType
_type
void (MyType *)
main
char **
char *
char
int

which obviously contains "void (*)(MyType *)" which I have searched for
previously.

dwardump-ing the executable dSYM I can see DWARF data for the typedef, but not
for the underlying type of the typedef.

Is this a bug? Should FindTypes find resolved typedefs? Or is this intended
behavior?

(lldb) version
lldb-360.99.0
  clang revision a41b64721d4be78870711cbb7b5af156a9e1f4ad
  llvm revision 3c45ea423a9e3d27eaf77af0639a73e0c56d9a35</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>