diff options
author | Andy Kaylor <akaylor@nvidia.com> | 2025-04-24 16:42:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-24 16:42:36 -0700 |
commit | b6746b06574686a587587acafb38881ca848089c (patch) | |
tree | d7686bcf30db5d1dd997ec600525abc97c3e2ce5 /clang/lib/CIR/CodeGen/CIRGenModule.cpp | |
parent | fdbf073a86573c9ac4d595fac8e06d252ce1469f (diff) | |
download | llvm-b6746b06574686a587587acafb38881ca848089c.zip llvm-b6746b06574686a587587acafb38881ca848089c.tar.gz llvm-b6746b06574686a587587acafb38881ca848089c.tar.bz2 |
[CIR] Upstream namepsace handling (#137253)
This adds the handlers for Decl::Namespace and Decl::UsingDirective
(which is needed for anonymous namespaces).
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenModule.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
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<ObjCImplDecl>(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<OpenACCDeclareDecl>(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<NamespaceDecl>(decl)); + break; } } |