Skip to content

Commit 9d5aaa0

Browse files
tbaederrzahiraam
authored andcommitted
[clang][Interp] Handle AttributedStmts (llvm#66495)
Just ignore the attributes.
1 parent b481fcf commit 9d5aaa0

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

clang/lib/AST/Interp/ByteCodeStmtGen.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ bool ByteCodeStmtGen<Emitter>::visitStmt(const Stmt *S) {
243243
case Stmt::GCCAsmStmtClass:
244244
case Stmt::MSAsmStmtClass:
245245
return visitAsmStmt(cast<AsmStmt>(S));
246+
case Stmt::AttributedStmtClass:
247+
return visitAttributedStmt(cast<AttributedStmt>(S));
246248
case Stmt::NullStmtClass:
247249
return true;
248250
default: {
@@ -625,6 +627,12 @@ bool ByteCodeStmtGen<Emitter>::visitAsmStmt(const AsmStmt *S) {
625627
return this->emitInvalid(S);
626628
}
627629

630+
template <class Emitter>
631+
bool ByteCodeStmtGen<Emitter>::visitAttributedStmt(const AttributedStmt *S) {
632+
// Ignore all attributes.
633+
return this->visitStmt(S->getSubStmt());
634+
}
635+
628636
namespace clang {
629637
namespace interp {
630638

clang/lib/AST/Interp/ByteCodeStmtGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class ByteCodeStmtGen final : public ByteCodeExprGen<Emitter> {
6464
bool visitCaseStmt(const CaseStmt *S);
6565
bool visitDefaultStmt(const DefaultStmt *S);
6666
bool visitAsmStmt(const AsmStmt *S);
67+
bool visitAttributedStmt(const AttributedStmt *S);
6768

6869
bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
6970

clang/test/AST/Interp/if.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@ namespace InitDecl {
4343
return false;
4444
}
4545
static_assert(!f2(), "");
46+
47+
48+
constexpr int attrs() {
49+
if (1) [[likely]] {}
50+
return 1;
51+
}
52+
static_assert(attrs() == 1, "");
4653
};

0 commit comments

Comments
 (0)