This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Ignore more non-VarDecl declarations
ClosedPublic

Authored by tbaeder on Mar 11 2023, 11:33 PM.

Details

Summary
They are harmless and handled by other means, but we used to return
false from visitDeclStmt.

Diff Detail

Event Timeline

tbaeder created this revision.Mar 11 2023, 11:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2023, 11:33 PM
tbaeder requested review of this revision.Mar 11 2023, 11:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2023, 11:33 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman added inline comments.Mar 13 2023, 5:47 AM
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
227

What about other kinds of declarations, such as typedefs or functions?

typedef int foo, bar;
extern int a(), b();

(and so on)

tbaeder added inline comments.Mar 13 2023, 8:43 AM
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
227

That's a good question, I added these now because I ran into them, but my follow-up question would've indeed been "what others are there?" :)

aaron.ballman added inline comments.Mar 14 2023, 6:21 AM
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
227

I was going to say: basically anything reachable from this grammar production: http://eel.is/c++draft/dcl.pre#nt:simple-declaration but then I was surprised to see StaticAssertDecl here. It turns out that any declaration at block scope gets wrapped in a DeclStmt. Well, almost any: https://godbolt.org/z/nMYdYTPEq

tbaeder updated this revision to Diff 505092.Mar 14 2023, 7:40 AM
This revision is now accepted and ready to land.Mar 14 2023, 8:18 AM
This revision was landed with ongoing or failed builds.Apr 4 2023, 1:42 AM
This revision was automatically updated to reflect the committed changes.