Skip to content

Commit 96d1571

Browse files
authored
[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).
1 parent 2f33b01 commit 96d1571

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

clang/include/clang/CIR/CIRGenerator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ class CIRGenerator : public clang::ASTConsumer {
7979
void HandleTranslationUnit(clang::ASTContext &astContext) override;
8080
void HandleInlineFunctionDefinition(clang::FunctionDecl *d) override;
8181
void HandleTagDeclDefinition(clang::TagDecl *d) override;
82+
void HandleTagDeclRequiredDefinition(const clang::TagDecl *D) override;
83+
void HandleCXXStaticMemberVarInstantiation(clang::VarDecl *D) override;
8284
void CompleteTentativeDefinition(clang::VarDecl *d) override;
85+
void HandleVTable(clang::CXXRecordDecl *rd) override;
8386

8487
mlir::ModuleOp getModule() const;
8588
mlir::MLIRContext &getMLIRContext() { return *mlirContext; };

clang/lib/CIR/CodeGen/CIRGenerator.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,30 @@ void CIRGenerator::HandleTagDeclDefinition(TagDecl *d) {
152152
cgm->errorNYI(d->getSourceRange(), "HandleTagDeclDefinition: OpenMP");
153153
}
154154

155+
void CIRGenerator::HandleTagDeclRequiredDefinition(const TagDecl *D) {
156+
if (diags.hasErrorOccurred())
157+
return;
158+
159+
assert(!cir::MissingFeatures::generateDebugInfo());
160+
}
161+
162+
void CIRGenerator::HandleCXXStaticMemberVarInstantiation(VarDecl *D) {
163+
if (diags.hasErrorOccurred())
164+
return;
165+
166+
cgm->errorNYI(D->getSourceRange(), "HandleCXXStaticMemberVarInstantiation");
167+
}
168+
155169
void CIRGenerator::CompleteTentativeDefinition(VarDecl *d) {
156170
if (diags.hasErrorOccurred())
157171
return;
158172

159173
cgm->emitTentativeDefinition(d);
160174
}
175+
176+
void CIRGenerator::HandleVTable(CXXRecordDecl *rd) {
177+
if (diags.hasErrorOccurred())
178+
return;
179+
180+
cgm->errorNYI(rd->getSourceRange(), "HandleVTable");
181+
}

clang/lib/CIR/FrontendAction/CIRGenAction.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class CIRGenConsumer : public clang::ASTConsumer {
8484
return true;
8585
}
8686

87+
void HandleCXXStaticMemberVarInstantiation(clang::VarDecl *VD) override {
88+
Gen->HandleCXXStaticMemberVarInstantiation(VD);
89+
}
90+
8791
void HandleInlineFunctionDefinition(FunctionDecl *D) override {
8892
Gen->HandleInlineFunctionDefinition(D);
8993
}
@@ -147,9 +151,15 @@ class CIRGenConsumer : public clang::ASTConsumer {
147151
Gen->HandleTagDeclDefinition(D);
148152
}
149153

154+
void HandleTagDeclRequiredDefinition(const TagDecl *D) override {
155+
Gen->HandleTagDeclRequiredDefinition(D);
156+
}
157+
150158
void CompleteTentativeDefinition(VarDecl *D) override {
151159
Gen->CompleteTentativeDefinition(D);
152160
}
161+
162+
void HandleVTable(CXXRecordDecl *RD) override { Gen->HandleVTable(RD); }
153163
};
154164
} // namespace cir
155165

0 commit comments

Comments
 (0)