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

    <tr>
        <th>Summary</th>
        <td>
            CIndexer cannot resolve stdlib include path
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    When trying to use the CIndexer API and enabling logging I can see that it tries to use the incomplete include path `lib/clang/15.0.0/include`.

CIndexer passes the correct ResourceDir to the CompilerInstance, but not to the Clang Driver.

And the Clang Driver cannot find its installation path because of the hardcoded `clang` as first argument that it attempts to use to resolve its InstallDir.
https://github.com/llvm/llvm-project/blob/3031fa88f01e59dcacb0a3020fb9a27ccf2b7615/clang/tools/libclang/CIndex.cpp#L3762

I removed this line, and now I can use my unmodified command lines from the compile_commands.json (which contains absolute paths to the compiler binary) to make it resolve the correct ResourceDir.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVU8GOmzAQ_Rq4WEXGhLA5cEg3qhSph6qXHivbDOCtsZE9ZJu_75iQ7G6lHiohbDPPM_PeG5Tvru2PERzDcDVuYOjZEoHhCOz57Dr4DYEdv52ZdB0DJ5VNIOuHIa1npqVjERJeIjNIWQzE90mM036aLeC6tUsHbJY4smzPrVGZ-KKtdAOtZV3wgtNmgxGgyPgp48fb-9HNLGNMNSi59iGARvYdol-ChpMJqfbaPFU1FsLZRZROQyaemVqQOY8PSKrMTsFcIHwodSSufwMS03S3NxQ0GIkNJbZWovHuRkmBlom279fbowyd9h10ieuN5Z4zGSlFiMhkGJYJHD6kk4gwzfimnmeBeNkLrPXOt3pEcet1RJxjVh1JMnoGg-OiChKbDtZe7sunOfgX0oiOyvokeMWrspdPTz0voT50WmrFZcUF79VBikbrXqhmX9bvvEHvbUwJjbp_utlR6HnORPW1avbivYJnan3yF0g6mshoaFYD0hA5_7rNTSI5XdniJt-Z3hCYup8SJuFJp-CnzebVy59bOBYvkTTPxNPraPRIYYeS7GBSkVwL3iYs3m3ebgemjJPhmolDikzyV9L1IfE_xmnTOu_aqjtUB5mjQQvtYxi3qbhnidiRRh8mPV-Cbf_bKxPjAknyetccynxsu1rrBiq-56ovn0DvxK7SB9BCiL3kVZNbqcDGNqs_Z_UpN63gQvAdb0rOay6KptZ1ySU5S57XTZ_tOEzS2CIVLnwY8tCuPahliBS0JmJ8C9I_ZwYHcM8vFxx9aJ3poJevNl_7bddm_wCBuXVK">