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

    <tr>
        <th>Summary</th>
        <td>
            [HLSL] Move `Sema` work out of `Parser::ParseMicrosoftRootSignatureAttributeArgs`
        </td>
    </tr>

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

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

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

<pre>
    It was brought up [here](https://github.com/llvm/llvm-project/pull/137690#discussion_r2109967008), that the initial implementation was over-zealous in doing some `Sema` work in the `Parser` library. The `Sema` work is described below.

For context, when we parse and create `RootSignatureDecl`, we want to allow ourselves to only parse identical root signatures once. To do so, when we create a new `RootSignatureDecl`, we will place this implicit decl on the current scope. Then before we invoke the parser we will check to see if a corresponding decl was already created and instead just point to that decl.

So then, the `Sema` work being done is:
- the storing of the `Decl` onto the current scope
- the subsequent look-ups from the scope
- creation of the actual declaration

This issue tracks to move the above `Sema` work to be in `Sema`.

Proposed Solution:

Create two new functions `ActOnStartRootSignatureDecl` and `ActOnFinishRootSignatureDecl`.

The former will contain the creation of the unique `DeclIdent` from the root signature string and then try to lookup if the `Decl` has been previously parsed. It will return the `DeclIdent` and a `bool` if it was found.

The latter will contain the logic to take the parsed root elements (if parsed) and construct a `RootSignatureDecl` and then put this onto the scope with `PushOnScopeChains`.

The updated flow would look something like:

```
auto [DeclIdent, Found] = Actions.ActOnStartRootSignatureDecl(Signature);
if (!Found) {
  // Invoke RootSignatureParser
  ...
 Actions.ActOnFinishRootSignatureDecl(RootElements);
}
// Create ParsedArg
...
```

AC:
- Any `Sema` logic currently contained in `Parser::ParseMicrosoftRootSignatureAttributeArgs` should be moved out and encapsulated with `Sema`
- From the perspective of test-cases, this is expected to be a nfc
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVttuGzkS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