[clang] [clang][bytecode] Handle UsingDirectiveDecls (PR #128888)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 26 07:05:36 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
By ignoring them.
---
Full diff: https://github.com/llvm/llvm-project/pull/128888.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+1-1)
- (modified) clang/test/AST/ByteCode/literals.cpp (+11)
``````````diff
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, "");
``````````
</details>
https://github.com/llvm/llvm-project/pull/128888
More information about the cfe-commits
mailing list