[clang] [clang][bytecode] Handle UsingDirectiveDecls (PR #128888)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 07:04:39 PST 2025


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

By ignoring them.

>From 77ec128a7f6bfc92824d0b30e93916dd6a23949a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Wed, 26 Feb 2025 16:03:32 +0100
Subject: [PATCH] [clang][bytecode] Handle UsingDirectiveDecls

By ignoring them.
---
 clang/lib/AST/ByteCode/Compiler.cpp  |  2 +-
 clang/test/AST/ByteCode/literals.cpp | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 74f5d6ebd9ca6..ed7f9fe0dd8d7 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5096,7 +5096,7 @@ template <class Emitter>
 bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS) {
   for (const auto *D : DS->decls()) {
     if (isa<StaticAssertDecl, TagDecl, TypedefNameDecl, BaseUsingDecl,
-            FunctionDecl, NamespaceAliasDecl>(D))
+            FunctionDecl, NamespaceAliasDecl, UsingDirectiveDecl>(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 a80ee7ad84fc7..f206f020ecb47 100644
--- a/clang/test/AST/ByteCode/literals.cpp
+++ b/clang/test/AST/ByteCode/literals.cpp
@@ -1330,3 +1330,14 @@ void localConstexpr() {
   static_assert(a == 0, ""); // both-error {{not an integral constant expression}} \
                              // both-note {{initializer of 'a' is not a constant expression}}
 }
+
+namespace Foo {
+  namespace Bar {
+    constexpr int FB = 10;
+  }
+}
+constexpr int usingDirectiveDecl() {
+  using namespace Foo::Bar;
+  return FB;
+}
+static_assert(usingDirectiveDecl() == 10, "");



More information about the cfe-commits mailing list