[clang] a955426 - [clang][bytecode] Handle UsingDirectiveDecls (#128888)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 26 07:55:18 PST 2025
Author: Timm Baeder
Date: 2025-02-26T16:55:15+01:00
New Revision: a955426a16bcbb9bf05eb0e3894663dff4983b00
URL: https://github.com/llvm/llvm-project/commit/a955426a16bcbb9bf05eb0e3894663dff4983b00
DIFF: https://github.com/llvm/llvm-project/commit/a955426a16bcbb9bf05eb0e3894663dff4983b00.diff
LOG: [clang][bytecode] Handle UsingDirectiveDecls (#128888)
By ignoring them.
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/literals.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index de0ce8b2644d3..4cf6a48edd5e0 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5107,7 +5107,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