This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Lazily visit unknown global declarations
ClosedPublic

Authored by tbaeder on Aug 1 2023, 7:00 AM.

Details

Summary
In C, we don't get a evaluateAsInitializer() call for all global
declarations, yet we have to handle DeclRefExpr pointing to them.

Diff Detail

Event Timeline

tbaeder created this revision.Aug 1 2023, 7:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2023, 7:00 AM
tbaeder requested review of this revision.Aug 1 2023, 7:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2023, 7:00 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tbaeder updated this revision to Diff 546090.Aug 1 2023, 9:14 AM
aaron.ballman added inline comments.Aug 2 2023, 6:20 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
2462–2463

Do we want to assert/limit this functionality to C instead of doing it in both C and C++?

clang/test/AST/Interp/c.c
18–19

Pedantically, this is also not a constant expression. Probably worth adding -pedantic to the RUN lines to ensure we properly warn with both constexpr engines.

tbaeder added inline comments.Aug 3 2023, 5:29 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
2462–2463

I never know how to do something for just C. I know there's stuff in LangOpts for C++, but no LangOpts::C?

cor3ntin added inline comments.Aug 3 2023, 5:54 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
2462–2463

!LangOpts.CPlusPlus afaik

tbaeder updated this revision to Diff 546882.Aug 3 2023, 8:12 AM
tbaeder marked 3 inline comments as done.
This revision is now accepted and ready to land.Sep 14 2023, 6:50 AM
This revision was automatically updated to reflect the committed changes.