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

    <tr>
        <th>Summary</th>
        <td>
            [clang] MemProfContextDisambiguation.cpp(2019,29): function cannot access 'AllocTypeCloningPriority' - Visual Studio 17 2022
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          jonathan-haubrich
      </td>
    </tr>
</table>

<pre>
    Compiling clang on Windows using `cmake -G "Visual Studio 17 2022"` results in the following error:
```
llvm-project\llvm\lib\Transforms\IPO\MemProfContextDisambiguation.cpp(2019,29): error C23
26: 'bool CallsiteContextGraph<ModuleCallsiteContextGraph,llvm::Function,llvm::Instruction *>::identifyClones::<lambda_
1>::operator ()(const std::shared_ptr<CallsiteContextGraph<ModuleCallsiteContextGraph,llvm::Function,llvm::Instruction
*>::ContextEdge> &,const std::shared_ptr<CallsiteContextGraph<ModuleCallsiteContextGraph,llvm::Function,llvm::Instructi
on *>::ContextEdge> &) const': function cannot access 'AllocTypeCloningPriority' [C:\Users\dweller\source\repos\llvm-pr
oject\build\lib\Transforms\IPO\LLVMipo.vcxproj]
```

It appears this might be caused by a bug related to lambdas, captures, and c-style arrays in more recent versions of MSVC / cl. See here: https://developercommunity.visualstudio.com/t/c2326-compiler-error-when-explicitly-capturing-a-c/1085499

A simple fix / workaround is to explicitly capture AllocTypeCloningPriority in the lambda rather than using the implicit capture default.

On line `2010` of `MemProfContextDisambiguation.cpp` changing `[&](` to `[&AllocTypeCloningPriority](` resulted in clang compiling successfully.

Version info:
```
Microsoft Visual Studio Community 2022
Version 17.3.5
VisualStudio.17.Release/17.3.5+32922.545
Microsoft .NET Framework
Version 4.8.04161

Installed Version: Community

Visual C++ 2022   00482-90000-00000-AA977
Microsoft Visual C++ 2022

Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVk1v2zgT_jX0ZSBBGlmydPDBUeKiQPO2aPtmjwVFjS22FCmQVBLvr19QUpw4SHaBAosFDMkaDufzmYfkzsmjJtqy_Irl1ys--s7Y7U-jue-4jjo-NlaKbtWY9rStTT9IJfURhOL6CEbDH1K35sHB6IKYFYno-S-C6AMwxDvpRq7gmx9baSDdACaIDJEVCVhyo_IOpAbfERyMUuYh2CBrjWXZjiXXLNmxIll-06dS9300WPOThGd5HT7DSzYsr79brt3B2N6xvP745TPL61vqv1hzqI329OivpeN9I48j99LoWAwDwxKTtGJYY8WwYtludg81ZrNDLIKQ4aYxRkHNlXLS02Lwg-VDx7L61rSjojcXcY4x27Fstx-1CJ4vhB-183ac5MBwx7KbWS5b0l4eTrUymtwsY1mteN-0_MccXHrWNgNZ7o0FhmVIBEthtPPgfDsruI5ban8M3rKs_nfTWBr3IpfF1E17JJbdAMOCYf1fBTiH96rab0VYwRQiw02AwGExCoJrbTxwIci5gIydUkZ8Pw0UWiX18YuVxkp_YrgBll_VwUNe_9-RDcBsH0gpsiyvnRmtIJbXlgbjFjRHg10CXCDejFK1f4fxT5_ubuVg4nvxGAaD5ddvTs78_OiBDwNx68B30kEvj52HhkDw0VELzQk4NOMRLCnuqQVvYIacY1iD4IMfLU3_uW5BRM6fFAG3lp-mWe6NJbAkSHu4J-uk0Q7MAW6_3dXAcA9CxfCNCDqyFOraeT9M8MY9w31L96QCmIXp-1FLf4rvJxJxE4fEwvQM957hXmCGRSQmRiIbTWMbPXSkI3oclBTSq1M0xyv1MeKRYLhPkzJfV9XLiuzAyX5QBAf5OAX4YOwvbs2oW5Au5P9s7yl_eK_lT2w2lwws9x1ZCEy6EGRYDO6CvbO1lg58VD5-GdZnDUpqCoyKSRraGKrIiuQfKa1IQHRcHxc-DsSORUAFlmHNm2fpu8g9a88sTW1IbOZ8cT4D3DiNwGFU6nQR-93cd5D6YN4j8l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