Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[CIR][NFC] Upstream bulk handling for Decl kinds #138319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025

Conversation

andykaylor
Copy link
Contributor

This adds explicit case statements for Decl types that weren't explicitly present in the emitDecl function. Those that need no handling are just accepted. Those that will need handling still go to errorNYI, but the default statement is removed.

This adds explicit case statements for Decl types that weren't
explicitly present in the emitDecl function. Those that need no
handling are just accepted. Those that will need handling still
go to errorNYI, but the default statement is removed.
@andykaylor andykaylor requested a review from erichkeane May 2, 2025 18:08
@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels May 2, 2025
@llvmbot
Copy link
Member

llvmbot commented May 2, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clangir

Author: Andy Kaylor (andykaylor)

Changes

This adds explicit case statements for Decl types that weren't explicitly present in the emitDecl function. Those that need no handling are just accepted. Those that will need handling still go to errorNYI, but the default statement is removed.


Full diff: https://github.com/llvm/llvm-project/pull/138319.diff

1 Files Affected:

  • (modified) clang/lib/CIR/CodeGen/CIRGenDecl.cpp (+84-2)
diff --git a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
index 90498cd18f46b..498d7533c2204 100644
--- a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
@@ -268,11 +268,87 @@ void CIRGenFunction::emitExprAsInit(const Expr *init, const ValueDecl *d,
 
 void CIRGenFunction::emitDecl(const Decl &d) {
   switch (d.getKind()) {
-  case Decl::LinkageSpec:
+  case Decl::BuiltinTemplate:
+  case Decl::TranslationUnit:
+  case Decl::ExternCContext:
   case Decl::Namespace:
+  case Decl::UnresolvedUsingTypename:
+  case Decl::ClassTemplateSpecialization:
+  case Decl::ClassTemplatePartialSpecialization:
+  case Decl::VarTemplateSpecialization:
+  case Decl::VarTemplatePartialSpecialization:
+  case Decl::TemplateTypeParm:
+  case Decl::UnresolvedUsingValue:
+  case Decl::NonTypeTemplateParm:
+  case Decl::CXXDeductionGuide:
+  case Decl::CXXMethod:
+  case Decl::CXXConstructor:
+  case Decl::CXXDestructor:
+  case Decl::CXXConversion:
+  case Decl::Field:
+  case Decl::MSProperty:
+  case Decl::IndirectField:
+  case Decl::ObjCIvar:
+  case Decl::ObjCAtDefsField:
+  case Decl::ParmVar:
+  case Decl::ImplicitParam:
+  case Decl::ClassTemplate:
+  case Decl::VarTemplate:
+  case Decl::FunctionTemplate:
+  case Decl::TypeAliasTemplate:
+  case Decl::TemplateTemplateParm:
+  case Decl::ObjCMethod:
+  case Decl::ObjCCategory:
+  case Decl::ObjCProtocol:
+  case Decl::ObjCInterface:
+  case Decl::ObjCCategoryImpl:
+  case Decl::ObjCImplementation:
+  case Decl::ObjCProperty:
+  case Decl::ObjCCompatibleAlias:
+  case Decl::PragmaComment:
+  case Decl::PragmaDetectMismatch:
+  case Decl::AccessSpec:
+  case Decl::LinkageSpec:
+  case Decl::Export:
+  case Decl::ObjCPropertyImpl:
+  case Decl::FileScopeAsm:
+  case Decl::Friend:
+  case Decl::FriendTemplate:
+  case Decl::Block:
+  case Decl::OutlinedFunction:
+  case Decl::Captured:
+  case Decl::UsingShadow:
+  case Decl::ConstructorUsingShadow:
+  case Decl::ObjCTypeParam:
+  case Decl::Binding:
+  case Decl::UnresolvedUsingIfExists:
     llvm_unreachable("Declaration should not be in declstmts!");
 
+  case Decl::Function:     // void X();
+  case Decl::EnumConstant: // enum ? { X = ? }
+  case Decl::StaticAssert: // static_assert(X, ""); [C++0x]
+  case Decl::Label:        // __label__ x;
+  case Decl::Import:
+  case Decl::MSGuid: // __declspec(uuid("..."))
+  case Decl::TemplateParamObject:
+  case Decl::OMPThreadPrivate:
+  case Decl::OMPAllocate:
+  case Decl::OMPCapturedExpr:
+  case Decl::OMPRequires:
+  case Decl::Empty:
+  case Decl::Concept:
+  case Decl::LifetimeExtendedTemporary:
+  case Decl::RequiresExprBody:
+  case Decl::UnnamedGlobalConstant:
+    // None of these decls require codegen support.
+    return;
+
+  case Decl::Enum:   // enum X;
   case Decl::Record: // struct/union/class X;
+  case Decl::CXXRecord: // struct/union/class X; [C++]
+  case Decl::NamespaceAlias:
+  case Decl::Using:          // using X; [C++]
+  case Decl::UsingEnum:      // using enum X; [C++]
   case Decl::UsingDirective: // using namespace X; [C++]
     assert(!cir::MissingFeatures::generateDebugInfo());
     return;
@@ -297,7 +373,13 @@ void CIRGenFunction::emitDecl(const Decl &d) {
       cgm.errorNYI(d.getSourceRange(), "emitDecl: variably modified type");
     return;
   }
-  default:
+  case Decl::ImplicitConceptSpecialization:
+  case Decl::HLSLBuffer:
+  case Decl::TopLevelStmt:
+  case Decl::UsingPack:
+  case Decl::Decomposition: // This could be moved to join Decl::Var
+  case Decl::OMPDeclareReduction:
+  case Decl::OMPDeclareMapper:
     cgm.errorNYI(d.getSourceRange(),
                  std::string("emitDecl: unhandled decl type: ") +
                      d.getDeclKindName());

@andykaylor andykaylor merged commit 17fdcda into llvm:main May 2, 2025
14 checks passed
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This adds explicit case statements for Decl types that weren't
explicitly present in the emitDecl function. Those that need no handling
are just accepted. Those that will need handling still go to errorNYI,
but the default statement is removed.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This adds explicit case statements for Decl types that weren't
explicitly present in the emitDecl function. Those that need no handling
are just accepted. Those that will need handling still go to errorNYI,
but the default statement is removed.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This adds explicit case statements for Decl types that weren't
explicitly present in the emitDecl function. Those that need no handling
are just accepted. Those that will need handling still go to errorNYI,
but the default statement is removed.
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
This adds explicit case statements for Decl types that weren't
explicitly present in the emitDecl function. Those that need no handling
are just accepted. Those that will need handling still go to errorNYI,
but the default statement is removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants