4646using namespace clang ;
4747using RegisterType = HLSLResourceBindingAttr::RegisterType;
4848
49+ static CXXRecordDecl *createHostLayoutStruct (Sema &S, CXXRecordDecl *StructDecl,
50+ HLSLBufferDecl *BufDecl);
51+
4952static RegisterType getRegisterType (ResourceClass RC) {
5053 switch (RC) {
5154 case ResourceClass::SRV:
@@ -296,7 +299,7 @@ static CXXRecordDecl *findRecordDecl(Sema &S, IdentifierInfo *II,
296299 DeclContext *DC) {
297300 DeclarationNameInfo NameInfo =
298301 DeclarationNameInfo (DeclarationName (II), SourceLocation ());
299- LookupResult R (S, NameInfo, Sema::LookupOrdinaryName );
302+ LookupResult R (S, NameInfo, Sema::LookupTagName );
300303 S.LookupName (R, S.getScopeForContext (DC));
301304 if (R.isSingleResult ())
302305 return R.getAsSingle <CXXRecordDecl>();
@@ -311,24 +314,24 @@ static IdentifierInfo *getHostLayoutStructName(Sema &S,
311314 bool MustBeUnique,
312315 DeclContext *DC) {
313316 ASTContext &AST = S.getASTContext ();
314- std::string NameBase;
317+ StringRef NameBase;
315318 if (NameBaseII) {
316- NameBase = NameBaseII->getName (). str () ;
319+ NameBase = NameBaseII->getName ();
317320 } else {
318321 // anonymous struct
319322 NameBase = " anon" ;
320323 MustBeUnique = true ;
321324 }
322325
323- std::string Name = " __layout_" + NameBase;
326+ std::string Name = ( " __layout_" + NameBase). str () ;
324327 IdentifierInfo *II = &AST.Idents .get (Name, tok::TokenKind::identifier);
325328 if (!MustBeUnique)
326329 return II;
327330
328331 unsigned suffix = 0 ;
329332 while (true ) {
330333 if (suffix != 0 )
331- II = &AST.Idents .get ((llvm::Twine ( Name) + " _" + Twine (suffix)).str (),
334+ II = &AST.Idents .get ((Name + " _" + Twine (suffix)).str (),
332335 tok::TokenKind::identifier);
333336 if (!findRecordDecl (S, II, DC))
334337 return II;
@@ -343,9 +346,6 @@ static bool isResourceRecordType(const Type *Ty) {
343346 return HLSLAttributedResourceType::findHandleTypeOnResource (Ty) != nullptr ;
344347}
345348
346- static CXXRecordDecl *createHostLayoutStruct (Sema &S, CXXRecordDecl *StructDecl,
347- HLSLBufferDecl *BufDecl);
348-
349349// Creates a field declaration of given name and type for HLSL buffer layout
350350// struct. Returns nullptr if the type cannot be use in HLSL Buffer layout.
351351static FieldDecl *createFieldForHostLayoutStruct (Sema &S, const Type *Ty,
@@ -362,10 +362,11 @@ static FieldDecl *createFieldForHostLayoutStruct(Sema &S, const Type *Ty,
362362 return nullptr ;
363363 Ty = RD->getTypeForDecl ();
364364 }
365- } else if (Ty->isConstantArrayType ()) {
366- if (isZeroSizedArray (cast<ConstantArrayType>(Ty)))
367- return nullptr ;
368365 }
366+ if (Ty->isConstantArrayType () &&
367+ isZeroSizedArray (cast<ConstantArrayType>(Ty)))
368+ return nullptr ;
369+
369370 QualType QT = QualType (Ty, 0 );
370371 ASTContext &AST = S.getASTContext ();
371372 TypeSourceInfo *TSI = AST.getTrivialTypeSourceInfo (QT, SourceLocation ());
0 commit comments