[clang] 96d1571 - [CIR] Add diagnostic for NYI AST visitor handlers (#151561)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 1 09:29:03 PDT 2025


Author: Andy Kaylor
Date: 2025-08-01T09:29:00-07:00
New Revision: 96d1571a2fc68061b3e007d0502c49923363ba49

URL: https://github.com/llvm/llvm-project/commit/96d1571a2fc68061b3e007d0502c49923363ba49
DIFF: https://github.com/llvm/llvm-project/commit/96d1571a2fc68061b3e007d0502c49923363ba49.diff

LOG: [CIR] Add diagnostic for NYI AST visitor handlers (#151561)

A couple of handlers that were missing from the CIRGenerator AST visitor
allowed important features to be silently ignored during CIR generation.
This change adds these handlers with diagnostics to report that they are
not yet handled (except in the case where only debug information is
missed).

Added: 
    

Modified: 
    clang/include/clang/CIR/CIRGenerator.h
    clang/lib/CIR/CodeGen/CIRGenerator.cpp
    clang/lib/CIR/FrontendAction/CIRGenAction.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h
index dd48eec238fca..5ea11463ffa9f 100644
--- a/clang/include/clang/CIR/CIRGenerator.h
+++ b/clang/include/clang/CIR/CIRGenerator.h
@@ -79,7 +79,10 @@ class CIRGenerator : public clang::ASTConsumer {
   void HandleTranslationUnit(clang::ASTContext &astContext) override;
   void HandleInlineFunctionDefinition(clang::FunctionDecl *d) override;
   void HandleTagDeclDefinition(clang::TagDecl *d) override;
+  void HandleTagDeclRequiredDefinition(const clang::TagDecl *D) override;
+  void HandleCXXStaticMemberVarInstantiation(clang::VarDecl *D) override;
   void CompleteTentativeDefinition(clang::VarDecl *d) override;
+  void HandleVTable(clang::CXXRecordDecl *rd) override;
 
   mlir::ModuleOp getModule() const;
   mlir::MLIRContext &getMLIRContext() { return *mlirContext; };

diff  --git a/clang/lib/CIR/CodeGen/CIRGenerator.cpp b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
index 99d652841be27..b0357d9d3b7fa 100644
--- a/clang/lib/CIR/CodeGen/CIRGenerator.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
@@ -152,9 +152,30 @@ void CIRGenerator::HandleTagDeclDefinition(TagDecl *d) {
     cgm->errorNYI(d->getSourceRange(), "HandleTagDeclDefinition: OpenMP");
 }
 
+void CIRGenerator::HandleTagDeclRequiredDefinition(const TagDecl *D) {
+  if (diags.hasErrorOccurred())
+    return;
+
+  assert(!cir::MissingFeatures::generateDebugInfo());
+}
+
+void CIRGenerator::HandleCXXStaticMemberVarInstantiation(VarDecl *D) {
+  if (diags.hasErrorOccurred())
+    return;
+
+  cgm->errorNYI(D->getSourceRange(), "HandleCXXStaticMemberVarInstantiation");
+}
+
 void CIRGenerator::CompleteTentativeDefinition(VarDecl *d) {
   if (diags.hasErrorOccurred())
     return;
 
   cgm->emitTentativeDefinition(d);
 }
+
+void CIRGenerator::HandleVTable(CXXRecordDecl *rd) {
+  if (diags.hasErrorOccurred())
+    return;
+
+  cgm->errorNYI(rd->getSourceRange(), "HandleVTable");
+}

diff  --git a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
index 9264aa6b18b58..67bb5657d4001 100644
--- a/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
+++ b/clang/lib/CIR/FrontendAction/CIRGenAction.cpp
@@ -84,6 +84,10 @@ class CIRGenConsumer : public clang::ASTConsumer {
     return true;
   }
 
+  void HandleCXXStaticMemberVarInstantiation(clang::VarDecl *VD) override {
+    Gen->HandleCXXStaticMemberVarInstantiation(VD);
+  }
+
   void HandleInlineFunctionDefinition(FunctionDecl *D) override {
     Gen->HandleInlineFunctionDefinition(D);
   }
@@ -147,9 +151,15 @@ class CIRGenConsumer : public clang::ASTConsumer {
     Gen->HandleTagDeclDefinition(D);
   }
 
+  void HandleTagDeclRequiredDefinition(const TagDecl *D) override {
+    Gen->HandleTagDeclRequiredDefinition(D);
+  }
+
   void CompleteTentativeDefinition(VarDecl *D) override {
     Gen->CompleteTentativeDefinition(D);
   }
+
+  void HandleVTable(CXXRecordDecl *RD) override { Gen->HandleVTable(RD); }
 };
 } // namespace cir
 


        


More information about the cfe-commits mailing list