From b6746b06574686a587587acafb38881ca848089c Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Thu, 24 Apr 2025 16:42:36 -0700 Subject: [CIR] Upstream namepsace handling (#137253) This adds the handlers for Decl::Namespace and Decl::UsingDirective (which is needed for anonymous namespaces). --- clang/lib/CIR/CodeGen/CIRGenModule.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp') diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index 0b266df..0f4193b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -621,6 +621,20 @@ CIRGenModule::getCIRLinkageVarDefinition(const VarDecl *vd, bool isConstant) { return getCIRLinkageForDeclarator(vd, linkage, isConstant); } +void CIRGenModule::emitDeclContext(const DeclContext *dc) { + for (Decl *decl : dc->decls()) { + // Unlike other DeclContexts, the contents of an ObjCImplDecl at TU scope + // are themselves considered "top-level", so EmitTopLevelDecl on an + // ObjCImplDecl does not recursively visit them. We need to do that in + // case they're nested inside another construct (LinkageSpecDecl / + // ExportDecl) that does stop them from being considered "top-level". + if (auto *oid = dyn_cast(decl)) + errorNYI(oid->getSourceRange(), "emitDeclConext: ObjCImplDecl"); + + emitTopLevelDecl(decl); + } +} + // Emit code for a single top level declaration. void CIRGenModule::emitTopLevelDecl(Decl *decl) { @@ -654,12 +668,18 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) { emitGlobalOpenACCDecl(cast(decl)); break; + case Decl::UsingDirective: // using namespace X; [C++] case Decl::Typedef: case Decl::TypeAlias: // using foo = bar; [C++11] case Decl::Record: case Decl::CXXRecord: assert(!cir::MissingFeatures::generateDebugInfo()); break; + + // C++ Decls + case Decl::Namespace: + emitDeclContext(cast(decl)); + break; } } -- cgit v1.1