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

    <tr>
        <th>Summary</th>
        <td>
            Debug info generated by clang-cl not correct when multiple variables with same name in one function
        </td>
    </tr>

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

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

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

<pre>
    When compiling C++ code h clang-cl, if the code is having multiple variables with same name in one function, the generated binary file and PDB file is not fully functional.  When debugging with Visual Studio, not all the variables can be seen in the debugger.

### Example program to replicate this issue
```C++
#include <iostream>
#include <vector>
#include <string>
#include <time.h>

void press_any_key()
{
        std::cout << "press enter to continue";
        std::string line;
        std::getline(std::cin, line);
}

int main()
{
        press_any_key();

        srand(time(nullptr));
        int x = rand() % 10000;
        {
                std::vector<int> z(2, x);
                if (z[1] > 9999)
                        throw std::runtime_error("branch 1");
        }
        {
                std::vector<int> z(10, x);
                if (z[1] > 9999)
                        throw std::runtime_error("branch 2");
        }

        return 0;
}
```

### Compilation flags
```
clang-cl /EHsc /Od -fuse-ld=lld /Zi /MDd clang_debug_test.cpp
```

### Steps to reproduce
* Compile the source code into executable using above command line
* Run the executable
* Open Visual Studio (2019), attach to the executable
* Add a breakpoint at both "if (z[1] > 9999)" statements
* Press enter in the command line to continue the execuation of the program which was blocked by press_any_key function
* In Visual Studio it should hit the first breakpoint.  This time the z and z[1] are shown in the "Auto" debug window
* F5 to continue the execution
* In Visual Studio it should hit the second breakpoint.  This time the z and z[1] are no longer shown in the "Auto" debug window
* If the program is built by MSVC both two breakpoint will show the variables correctly

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9Vktv4zgM_jXOhWhgy_WkOeTQJi12DoMZbBczwF4K2aZtbWUp0CNp-uuXkp04LdLB9rKBYMemSH586KNLXR9WvzpUUOl-K6RQ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