<html>
    <head>
      <base href="http://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 --- - ParseAssemblyString does not resolve types already present in module"
   href="http://llvm.org/bugs/show_bug.cgi?id=21058">21058</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ParseAssemblyString does not resolve types already present in module
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>LLVM assembly language parser
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jan+llvm-bugzilla@sheijk.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13085" name="attach_13085" title="Repro case">attachment 13085</a> <a href="attachment.cgi?id=13085&action=edit" title="Repro case">[details]</a></span>
Repro case

Reproduction steps:

- create a new LLVM module
- define a new named struct type foo_t (either using 
- call ParseAssemblyString passing it the existing module and a source string
that uses one of the types added before

Or compile the attached file and run it w/o arguments to use
ParseAssemblyString to define the type or with --api-type to create foo_t using
the C++ API.

Expected:

Functions in the textural LLVM IR passed to ParseAssemblyString will use the
type struct.foo_t which is already defined in the module.

What happens:

Whenever this new code references struct.foo_t the parser creates a new opaque
struct type struct.foo_t.0 and uses that instead of struct.foo_t. This looks
like the same behaviour as when creating a new struct type with a name that is
already used.

The parser in lib/AsmParser/LLParser.cpp seems to look up named structs in it's
member NamedTypes in function ParseType. NamedTypes gets polulated when new
types get defined in ParseNamedType but I don't see it getting filled with the
existing types of the module. So ParseType will create a new opaque type that
gets renamed due to the naming conflict. I think this could easily be solved by
looking up the named type in the module (LLParser::M) inside ParseType using
Module::getTypeByName.</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>