<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 --- - SBModule::FindFirstType does not find a second namespaced typedef with the same name"
   href="https://llvm.org/bugs/show_bug.cgi?id=31704">31704</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SBModule::FindFirstType does not find a second namespaced typedef with the same name
          </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=17871" name="attach_17871" title="Example code which shows the issue regarding FindFirstType">attachment 17871</a> <a href="attachment.cgi?id=17871&action=edit" title="Example code which shows the issue regarding FindFirstType">[details]</a></span>
Example code which shows the issue regarding FindFirstType

SBModule::FindFirstType has an issue with finding namespaced typedefs.
Consider the code:

class Foo {
public:
    typedef bool MyType;
};

class Bar {
public:
    typedef int MyType;
};

int main(int argc, char* argv[]) {
    Foo::MyType foo;
    Bar::MyType bar;
    (void) foo;
    (void) bar;
    return 0;
}

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

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


<span class="quote">>>> print lldb.target.FindFirstType("MyType")</span >
typedef Foo::MyType

<span class="quote">>>> print lldb.target.FindFirstType("Foo::MyType")</span >
typedef Foo::MyType

<span class="quote">>>> print lldb.target.FindFirstType("Bar::MyType")</span >

As you can see, trying to find Bar::MyType fails, but if I iterate over
FindTypes result, I can find both.

(lldb) version
lldb-360.99.0
  clang revision a41b64721d4be78870711cbb7b5af156a9e1f4ad
  llvm revision 3c45ea423a9e3d27eaf77af0639a73e0c56d9a35

The issue seems to be inside lldb::TypeSP Module::FindFirstType(const
SymbolContext &sc, const ConstString &name, bool exact_match)
which passes "1" as the max_matches argument, and this gets propagated in a
wrong way inside the implementation, where essentially a list of the two types
is found, and the second type is not checked because the first type didn't
match.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>