2929#include  " clang/Sema/ParsedTemplate.h" 
3030#include  " clang/Sema/Scope.h" 
3131#include  " clang/Sema/SemaCodeCompletion.h" 
32+ #include  " clang/Sema/SemaHLSL.h" 
3233#include  " llvm/Support/TimeProfiler.h" 
3334#include  < optional> 
3435
@@ -4903,7 +4904,7 @@ void Parser::ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs) {
49034904  }
49044905}
49054906
4906- void  Parser::ParseMicrosoftRootSignatureAttributeArgs  (ParsedAttributes &Attrs) {
4907+ void  Parser::ParseHLSLRootSignatureAttributeArgs  (ParsedAttributes &Attrs) {
49074908  assert (Tok.is (tok::identifier) &&
49084909         " Expected an identifier to denote which MS attribute to consider"  );
49094910  IdentifierInfo *RootSignatureIdent = Tok.getIdentifierInfo ();
@@ -4945,18 +4946,14 @@ void Parser::ParseMicrosoftRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
49454946
49464947  //  Construct our identifier
49474948  StringRef Signature = StrLiteral.value ()->getString ();
4948-   auto  Hash = llvm::hash_value (Signature);
4949-   std::string IdStr = " __hlsl_rootsig_decl_"   + std::to_string (Hash);
4950-   IdentifierInfo *DeclIdent = &(Actions.getASTContext ().Idents .get (IdStr));
4951- 
4952-   LookupResult R (Actions, DeclIdent, SourceLocation (),
4953-                  Sema::LookupOrdinaryName);
4954-   //  Check if we have already found a decl of the same name, if we haven't
4955-   //  then parse the root signature string and construct the in-memory elements
4956-   if  (!Actions.LookupQualifiedName (R, Actions.CurContext )) {
4949+   auto  [DeclIdent, Found] =
4950+       Actions.HLSL ().ActOnStartRootSignatureDecl (Signature);
4951+   //  If we haven't found an already defined DeclIdent then parse the root
4952+   //  signature string and construct the in-memory elements
4953+   if  (!Found) {
4954+     //  Offset location 1 to account for '"'
49574955    SourceLocation SignatureLoc =
4958-         StrLiteral.value ()->getExprLoc ().getLocWithOffset (
4959-             1 ); //  offset 1 for '"'
4956+         StrLiteral.value ()->getExprLoc ().getLocWithOffset (1 );
49604957    //  Invoke the root signature parser to construct the in-memory constructs
49614958    hlsl::RootSignatureLexer Lexer (Signature, SignatureLoc);
49624959    SmallVector<llvm::hlsl::rootsig::RootElement> RootElements;
@@ -4966,12 +4963,9 @@ void Parser::ParseMicrosoftRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
49664963      return ;
49674964    }
49684965
4969-     //  Create the Root Signature
4970-     auto  *SignatureDecl = HLSLRootSignatureDecl::Create (
4971-         Actions.getASTContext (), /* DeclContext=*/  Actions.CurContext ,
4972-         RootSignatureLoc, DeclIdent, RootElements);
4973-     SignatureDecl->setImplicit ();
4974-     Actions.PushOnScopeChains (SignatureDecl, getCurScope ());
4966+     //  Construct the declaration.
4967+     Actions.HLSL ().ActOnFinishRootSignatureDecl (RootSignatureLoc, DeclIdent,
4968+                                                 RootElements);
49754969  }
49764970
49774971  //  Create the arg for the ParsedAttr
@@ -5014,7 +5008,7 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes &Attrs) {
50145008      if  (Tok.getIdentifierInfo ()->getName () == " uuid"  )
50155009        ParseMicrosoftUuidAttributeArgs (Attrs);
50165010      else  if  (Tok.getIdentifierInfo ()->getName () == " RootSignature"  )
5017-         ParseMicrosoftRootSignatureAttributeArgs (Attrs);
5011+         ParseHLSLRootSignatureAttributeArgs (Attrs);
50185012      else  {
50195013        IdentifierInfo *II = Tok.getIdentifierInfo ();
50205014        SourceLocation NameLoc = Tok.getLocation ();
0 commit comments