|
@@ -312,21 +312,7 @@ void SPIRVEmitter::HandleTranslationUnit(ASTContext &context) {
|
|
|
} else if (auto *varDecl = dyn_cast<VarDecl>(decl)) {
|
|
|
doVarDecl(varDecl);
|
|
|
} else if (auto *recordDecl = dyn_cast<RecordDecl>(decl)) {
|
|
|
- // Ignore implict records
|
|
|
- // Somehow we'll have implicit records with:
|
|
|
- // static const int Length = count;
|
|
|
- // that can mess up with the normal CodeGen.
|
|
|
- if (recordDecl->isImplicit())
|
|
|
- continue;
|
|
|
-
|
|
|
- // Handle each static member with inline initializer.
|
|
|
- // Each static member has a corresponding VarDecl inside the
|
|
|
- // RecordDecl. For those defined in the translation unit,
|
|
|
- // their VarDecls do not have initializer.
|
|
|
- for (auto *subDecl : recordDecl->decls())
|
|
|
- if (auto *varDecl = dyn_cast<VarDecl>(subDecl))
|
|
|
- if (varDecl->isStaticDataMember() && varDecl->hasInit())
|
|
|
- doVarDecl(varDecl);
|
|
|
+ doRecordDecl(recordDecl);
|
|
|
} else if (auto *bufferDecl = dyn_cast<HLSLBufferDecl>(decl)) {
|
|
|
// This is a cbuffer/tbuffer decl.
|
|
|
|
|
@@ -410,6 +396,8 @@ void SPIRVEmitter::doDecl(const Decl *decl) {
|
|
|
doFunctionDecl(funcDecl);
|
|
|
} else if (dyn_cast<HLSLBufferDecl>(decl)) {
|
|
|
llvm_unreachable("HLSLBufferDecl should not be handled here");
|
|
|
+ } else if (const auto *recordDecl = dyn_cast<RecordDecl>(decl)) {
|
|
|
+ doRecordDecl(recordDecl);
|
|
|
} else {
|
|
|
emitError("decl type %0 unimplemented", decl->getLocation())
|
|
|
<< decl->getDeclKindName();
|
|
@@ -736,6 +724,24 @@ void SPIRVEmitter::validateVKAttributes(const NamedDecl *decl) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void SPIRVEmitter::doRecordDecl(const RecordDecl *recordDecl) {
|
|
|
+ // Ignore implict records
|
|
|
+ // Somehow we'll have implicit records with:
|
|
|
+ // static const int Length = count;
|
|
|
+ // that can mess up with the normal CodeGen.
|
|
|
+ if (recordDecl->isImplicit())
|
|
|
+ return;
|
|
|
+
|
|
|
+ // Handle each static member with inline initializer.
|
|
|
+ // Each static member has a corresponding VarDecl inside the
|
|
|
+ // RecordDecl. For those defined in the translation unit,
|
|
|
+ // their VarDecls do not have initializer.
|
|
|
+ for (auto *subDecl : recordDecl->decls())
|
|
|
+ if (auto *varDecl = dyn_cast<VarDecl>(subDecl))
|
|
|
+ if (varDecl->isStaticDataMember() && varDecl->hasInit())
|
|
|
+ doVarDecl(varDecl);
|
|
|
+}
|
|
|
+
|
|
|
void SPIRVEmitter::doVarDecl(const VarDecl *decl) {
|
|
|
validateVKAttributes(decl);
|
|
|
|