[clang] 38832a8 - [clang] fix obtaining EnumDecl for UsingEnumDecl (#156127)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 29 18:06:52 PDT 2025
Author: Matheus Izvekov
Date: 2025-08-30T01:06:48Z
New Revision: 38832a8443d76ce96b7e893a80538b9c3515a22a
URL: https://github.com/llvm/llvm-project/commit/38832a8443d76ce96b7e893a80538b9c3515a22a
DIFF: https://github.com/llvm/llvm-project/commit/38832a8443d76ce96b7e893a80538b9c3515a22a.diff
LOG: [clang] fix obtaining EnumDecl for UsingEnumDecl (#156127)
Use the castAs acessor for the type for a UsingEnumDecl, as it can be
sugar for an EnumType.
Fixes a regression reported here:
https://github.com/llvm/llvm-project/pull/155313#issuecomment-3238482327
Since this regression was never released, there are no release notes.
Added:
Modified:
clang/include/clang/AST/DeclCXX.h
clang/test/SemaTemplate/using-decl.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index 00d8f724671f1..8802664031d37 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3826,7 +3826,7 @@ class UsingEnumDecl : public BaseUsingDecl, public Mergeable<UsingEnumDecl> {
public:
EnumDecl *getEnumDecl() const {
- return cast<clang::EnumType>(EnumType->getType())->getOriginalDecl();
+ return EnumType->getType()->castAs<clang::EnumType>()->getOriginalDecl();
}
static UsingEnumDecl *Create(ASTContext &C, DeclContext *DC,
diff --git a/clang/test/SemaTemplate/using-decl.cpp b/clang/test/SemaTemplate/using-decl.cpp
index 1ef2a2dfaa019..d54d3a3f3ea9e 100644
--- a/clang/test/SemaTemplate/using-decl.cpp
+++ b/clang/test/SemaTemplate/using-decl.cpp
@@ -14,3 +14,15 @@ namespace UsingInGenericLambda {
}
void e() { c<int>(); }
}
+
+namespace UsingUsingEnum {
+ namespace foo {
+ enum class EnumOne {};
+ }
+ using foo::EnumOne;
+
+ template <class> void t() {
+ using enum EnumOne;
+ }
+ template void t<void>();
+} // namespace UsingUsingEnum
More information about the cfe-commits
mailing list