[HLSL] Support cbuffer/tbuffer for hlsl.
authorXiang Li <python3kgae@outlook.com>
Fri, 15 Jul 2022 17:45:57 +0000 (10:45 -0700)
committerXiang Li <python3kgae@outlook.com>
Wed, 21 Sep 2022 17:07:43 +0000 (10:07 -0700)
commit782ac2182c2b02de775c0f5a3d935613f2b748f5
tree55127bbcb01ad97421cdcfeff44665606e075319
parent1f4d3c681c9552f9b0327a9c6d9db6c2153fc459
[HLSL] Support cbuffer/tbuffer for hlsl.

This is first part for support cbuffer/tbuffer.

The format for cbuffer/tbuffer is
BufferType [Name] [: register(b#)] { VariableDeclaration [: packoffset(c#.xyzw)]; ... };

More details at https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-constants

New keyword 'cbuffer' and 'tbuffer' are added.
New AST node HLSLBufferDecl is added.
Build AST for simple cbuffer/tbuffer without attribute support.

The special thing is variables declared inside cbuffer is exposed into global scope.
So isTransparentContext should return true for HLSLBuffer.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D129883
36 files changed:
clang/include/clang/AST/Decl.h
clang/include/clang/AST/JSONNodeDumper.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Basic/DeclNodes.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseHLSL.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/CMakeLists.txt
clang/lib/Sema/IdentifierResolver.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaHLSL.cpp [new file with mode: 0644]
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/AST/HLSL/Inputs/empty.hlsl [new file with mode: 0644]
clang/test/AST/HLSL/ast-dump-comment-cbuffe-tbufferr.hlsl [new file with mode: 0644]
clang/test/AST/HLSL/cbuffer_tbuffer.hlsl [new file with mode: 0644]
clang/test/AST/HLSL/pch_hlsl_buffer.hlsl [new file with mode: 0644]
clang/test/ParserHLSL/cb_error.hlsl [new file with mode: 0644]
clang/test/ParserHLSL/invalid_inside_cb.hlsl [new file with mode: 0644]
clang/test/SemaHLSL/cb_error.hlsl [new file with mode: 0644]