29
29
#include " clang/Sema/ParsedTemplate.h"
30
30
#include " clang/Sema/Scope.h"
31
31
#include " clang/Sema/SemaCodeCompletion.h"
32
+ #include " clang/Sema/SemaHLSL.h"
32
33
#include " llvm/Support/TimeProfiler.h"
33
34
#include < optional>
34
35
@@ -4903,7 +4904,7 @@ void Parser::ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs) {
4903
4904
}
4904
4905
}
4905
4906
4906
- void Parser::ParseMicrosoftRootSignatureAttributeArgs (ParsedAttributes &Attrs) {
4907
+ void Parser::ParseHLSLRootSignatureAttributeArgs (ParsedAttributes &Attrs) {
4907
4908
assert (Tok.is (tok::identifier) &&
4908
4909
" Expected an identifier to denote which MS attribute to consider" );
4909
4910
IdentifierInfo *RootSignatureIdent = Tok.getIdentifierInfo ();
@@ -4945,18 +4946,14 @@ void Parser::ParseMicrosoftRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
4945
4946
4946
4947
// Construct our identifier
4947
4948
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 '"'
4957
4955
SourceLocation SignatureLoc =
4958
- StrLiteral.value ()->getExprLoc ().getLocWithOffset (
4959
- 1 ); // offset 1 for '"'
4956
+ StrLiteral.value ()->getExprLoc ().getLocWithOffset (1 );
4960
4957
// Invoke the root signature parser to construct the in-memory constructs
4961
4958
hlsl::RootSignatureLexer Lexer (Signature, SignatureLoc);
4962
4959
SmallVector<llvm::hlsl::rootsig::RootElement> RootElements;
@@ -4966,12 +4963,9 @@ void Parser::ParseMicrosoftRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
4966
4963
return ;
4967
4964
}
4968
4965
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);
4975
4969
}
4976
4970
4977
4971
// Create the arg for the ParsedAttr
@@ -5014,7 +5008,7 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes &Attrs) {
5014
5008
if (Tok.getIdentifierInfo ()->getName () == " uuid" )
5015
5009
ParseMicrosoftUuidAttributeArgs (Attrs);
5016
5010
else if (Tok.getIdentifierInfo ()->getName () == " RootSignature" )
5017
- ParseMicrosoftRootSignatureAttributeArgs (Attrs);
5011
+ ParseHLSLRootSignatureAttributeArgs (Attrs);
5018
5012
else {
5019
5013
IdentifierInfo *II = Tok.getIdentifierInfo ();
5020
5014
SourceLocation NameLoc = Tok.getLocation ();
0 commit comments