<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64161>64161</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Assertion in lexer for Unicode bidirectional text support
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          r0ller
      </td>
    </tr>
</table>

<pre>
    When llvm and clang are built with debug build type, the front end crashes on trying to compile this one liner with clang:

int A\N{LEFT-TO-RIGHT OVERRIDE};

I attached the stack dump (crash.txt) but for whatever reasons the preprocessed sources don't get generated.

I debugged the issue as well and checked the source file LiteralSupport.cpp as the function expandUCNs() where the assertion fails resides there. There's a function called ProcessNamedUCNEscape() which seems to be handling such named escapes like the one that triggers the crash. That function calls after some checks nameToCodepointStrict() whereas before the failing assert nameToCodepointLooseMatching() is called but it returns nullopt. That gave me the idea to call nameToCodepointStrict() before nameToCodepointLooseMatching() is called and only call the latter if the former doesn't return anything. The order may be the other way around as well but judging by their names calling the stricter seemed logical. Actually, that seems to solve the problem at least the codepoint returned (202D) matches what is listed in the [UCN list](https://www.unicode.org/Public/15.0.0/ucd/NamesList.txt).

Does this solution seem to make sense? Shall I go on and submit a patch?
[crash.txt](https://github.com/llvm/llvm-project/files/12185078/crash.txt)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU1v2zgT_jX0ZVBDouPIOfiQxPH7BsimRevunkfiSGJDkQI5iuN_vxhKbdrFYoEeEgO2Zub5mHmEKdnOE-3V9k5tDyucuA9xHwvnKK7qYC77v3ry4NzrAOgNNA59BxgJ6sk6hrPlHgzVU5e_MMCXkZS-B-4J2hg8A0lZxNRTguCB48X6DjhAE4bROgLurfxC4KynOLfMc9TmVhUHVSz_rWe4Vdv7Z1XdPT0cTx9OHz98fvzf_0_w8c-Hz58fDw-qOqjN3c81j4DM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