[clang] ee71cbd - [clang][Interp] Ignore more non-VarDecl declarations
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 4 01:42:01 PDT 2023
Author: Timm Bäder
Date: 2023-04-04T10:41:46+02:00
New Revision: ee71cbddb77f8da9285657cac248b431928143b9
URL: https://github.com/llvm/llvm-project/commit/ee71cbddb77f8da9285657cac248b431928143b9
DIFF: https://github.com/llvm/llvm-project/commit/ee71cbddb77f8da9285657cac248b431928143b9.diff
LOG: [clang][Interp] Ignore more non-VarDecl declarations
They are harmless and handled by other means, but we used to return
false from visitDeclStmt.
Differential Revision: https://reviews.llvm.org/D145861
Added:
Modified:
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/test/AST/Interp/literals.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index 6faa3f9a47a9b..2c53900111d9b 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -224,7 +224,7 @@ bool ByteCodeStmtGen<Emitter>::visitCompoundStmt(
template <class Emitter>
bool ByteCodeStmtGen<Emitter>::visitDeclStmt(const DeclStmt *DS) {
for (auto *D : DS->decls()) {
- if (isa<StaticAssertDecl>(D))
+ if (isa<StaticAssertDecl, TagDecl, TypedefNameDecl>(D))
continue;
const auto *VD = dyn_cast<VarDecl>(D);
diff --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp
index 5883c1879b925..f31a49088dc6c 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -766,3 +766,16 @@ namespace TypeTraits {
static_assert(S3<U>{}.foo(), "");
static_assert(!S3<T>{}.foo(), "");
}
+
+#if __cplusplus >= 201402L
+constexpr int ignoredDecls() {
+ static_assert(true, "");
+ struct F { int a; };
+ enum E { b };
+ using A = int;
+ typedef int Z;
+
+ return F{12}.a;
+}
+static_assert(ignoredDecls() == 12, "");
+#endif
More information about the cfe-commits
mailing list