https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/66495
Just ignore the attributes. >From c1c216058408cf54771bfdac71b0bcf28110f292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Fri, 15 Sep 2023 12:55:04 +0200 Subject: [PATCH] [clang][Interp] Handle AttributedStmts Just ignore the attributes. --- clang/lib/AST/Interp/ByteCodeStmtGen.cpp | 8 ++++++++ clang/lib/AST/Interp/ByteCodeStmtGen.h | 1 + clang/test/AST/Interp/if.cpp | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp index b7553d8963ff0ee..a0f50c3e69dd918 100644 --- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp @@ -246,6 +246,8 @@ bool ByteCodeStmtGen<Emitter>::visitStmt(const Stmt *S) { case Stmt::GCCAsmStmtClass: case Stmt::MSAsmStmtClass: return visitAsmStmt(cast<AsmStmt>(S)); + case Stmt::AttributedStmtClass: + return visitAttributedStmt(cast<AttributedStmt>(S)); case Stmt::NullStmtClass: return true; default: { @@ -628,6 +630,12 @@ bool ByteCodeStmtGen<Emitter>::visitAsmStmt(const AsmStmt *S) { return this->emitInvalid(S); } +template <class Emitter> +bool ByteCodeStmtGen<Emitter>::visitAttributedStmt(const AttributedStmt *S) { + // Ignore all attributes. + return this->visitStmt(S->getSubStmt()); +} + namespace clang { namespace interp { diff --git a/clang/lib/AST/Interp/ByteCodeStmtGen.h b/clang/lib/AST/Interp/ByteCodeStmtGen.h index 278e804a803c951..3bdcdd78f397e5b 100644 --- a/clang/lib/AST/Interp/ByteCodeStmtGen.h +++ b/clang/lib/AST/Interp/ByteCodeStmtGen.h @@ -68,6 +68,7 @@ class ByteCodeStmtGen final : public ByteCodeExprGen<Emitter> { bool visitCaseStmt(const CaseStmt *S); bool visitDefaultStmt(const DefaultStmt *S); bool visitAsmStmt(const AsmStmt *S); + bool visitAttributedStmt(const AttributedStmt *S); bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD); diff --git a/clang/test/AST/Interp/if.cpp b/clang/test/AST/Interp/if.cpp index 2449ace4dd6c6b5..86ae8de6f73ebb7 100644 --- a/clang/test/AST/Interp/if.cpp +++ b/clang/test/AST/Interp/if.cpp @@ -43,4 +43,11 @@ namespace InitDecl { return false; } static_assert(!f2(), ""); + + + constexpr int attrs() { + if (1) [[likely]] {} + return 1; + } + static_assert(attrs() == 1, ""); }; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits