[clang] [clang][bytecode] Ignore Namespace{Using, Alias}Decls (PR #125387)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 2 01:08:54 PST 2025


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/125387

These were missing here and are used in a few libc++ tests.

>From 7d77e6cdb6bf651b1b19c48e41c7e182e990e5d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sun, 2 Feb 2025 10:07:13 +0100
Subject: [PATCH] [clang][bytecode] Ignore Namespace{Using,Alias}Decls

These were missing here and are used in a few libc++ tests.
---
 clang/lib/AST/ByteCode/Compiler.cpp  | 4 ++--
 clang/test/AST/ByteCode/literals.cpp | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index f7f4f713c787f25..b9e22ebb7a41a90 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4991,8 +4991,8 @@ bool Compiler<Emitter>::visitCompoundStmt(const CompoundStmt *S) {
 template <class Emitter>
 bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS) {
   for (const auto *D : DS->decls()) {
-    if (isa<StaticAssertDecl, TagDecl, TypedefNameDecl, UsingEnumDecl,
-            FunctionDecl>(D))
+    if (isa<StaticAssertDecl, TagDecl, TypedefNameDecl, BaseUsingDecl,
+            FunctionDecl, NamespaceAliasDecl>(D))
       continue;
 
     const auto *VD = dyn_cast<VarDecl>(D);
diff --git a/clang/test/AST/ByteCode/literals.cpp b/clang/test/AST/ByteCode/literals.cpp
index b75ca2b19a969a9..a80ee7ad84fc748 100644
--- a/clang/test/AST/ByteCode/literals.cpp
+++ b/clang/test/AST/ByteCode/literals.cpp
@@ -914,12 +914,18 @@ namespace TypeTraits {
 }
 
 #if __cplusplus >= 201402L
+namespace SomeNS {
+  using MyInt = int;
+}
+
 constexpr int ignoredDecls() {
   static_assert(true, "");
   struct F { int a; };
   enum E { b };
   using A = int;
   typedef int Z;
+  namespace NewNS = SomeNS;
+  using NewNS::MyInt;
 
   return F{12}.a;
 }



More information about the cfe-commits mailing list