This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Handle SourceLocExprs
ClosedPublic

Authored by tbaeder on Jul 18 2023, 10:30 AM.

Details

Summary

This is a bit awkward, since we get an APValue from the expression, which we then need to re-integrate into our bytecode/primtype based interpreter.

Diff Detail

Event Timeline

tbaeder created this revision.Jul 18 2023, 10:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 10:30 AM
tbaeder requested review of this revision.Jul 18 2023, 10:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 10:30 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Note that you are probably need something like SourceLocExprScopeGuard to make source_location actually work, , it might be worth doing in this patch.
The idea is to remember the location of a call when evaluating default arguments / default member initializers

clang/test/AST/Interp/builtin-functions.cpp
245

what is missing to enable the existing source location tests with the new intterpreter?

Note that you are probably need something like SourceLocExprScopeGuard to make source_location actually work, , it might be worth doing in this patch.
The idea is to remember the location of a call when evaluating default arguments / default member initializers

Yeah I saw, that's what the FIXME comment is about.

clang/test/AST/Interp/builtin-functions.cpp
245

There is a crash that I need to investigate first, but SemaCXX/source_location.cpp also uses stuff like static_assert(noexcept(...)); that I don't handle yet.

tbaeder added inline comments.Jul 19 2023, 7:24 AM
clang/test/AST/Interp/builtin-functions.cpp
245

Okay, after my last two patches I uploaded, the only problem missing is the broken source locations for initializers.

cor3ntin added inline comments.Jul 19 2023, 7:53 AM
clang/test/AST/Interp/builtin-functions.cpp
245

I think it might be worth doing in this patch (unless it requires a lot of work)

tbaeder added inline comments.Jul 20 2023, 4:11 AM
clang/test/AST/Interp/builtin-functions.cpp
245

I was wrong and there's some other work needed. Namely, I need to redo how we do initializers. I will definitely tackel that this quarter and dial down the work on new features.

tbaeder updated this revision to Diff 542420.Jul 20 2023, 4:11 AM
tbaeder updated this revision to Diff 543212.Jul 22 2023, 11:17 AM
tbaeder updated this revision to Diff 543249.Jul 22 2023, 10:43 PM

@cor3ntin Ok, I need...

to enable the existing tests with at least one of the RUN lines.

FYI i think this is fine but I'm waiting for progress on the PRs that would allow us to enable more tests.

@tbaeder Maybe you could land the dependencies of this patch so that we can progress it. Thanks!

Having https://reviews.llvm.org/D144457 and https://reviews.llvm.org/D144457 approved would make rebasing easier :)

I can look into https://reviews.llvm.org/D144457, but then having to do https://reviews.llvm.org/D144457 right after is going to be tough. (I suspect there may be a copy pasta here.) ;-)

Having https://reviews.llvm.org/D144457 and https://reviews.llvm.org/D144457 approved would make rebasing easier :)

I can look into https://reviews.llvm.org/D144457, but then having to do https://reviews.llvm.org/D144457 right after is going to be tough. (I suspect there may be a copy pasta here.) ;-)

But once you've reviewed https://reviews.llvm.org/D144457, reviewing https://reviews.llvm.org/D144457 shouldn't be that hard? :)

I'm pretty sure the second link should've been https://reviews.llvm.org/D152132.

Having https://reviews.llvm.org/D144457 and https://reviews.llvm.org/D144457 approved would make rebasing easier :)

I can look into https://reviews.llvm.org/D144457, but then having to do https://reviews.llvm.org/D144457 right after is going to be tough. (I suspect there may be a copy pasta here.) ;-)

But once you've reviewed https://reviews.llvm.org/D144457, reviewing https://reviews.llvm.org/D144457 shouldn't be that hard? :)

I dunno, I'm skeptical.

I'm pretty sure the second link should've been https://reviews.llvm.org/D152132.

Oh, so now we're moving the goalposts too? ;-) I'll check that one out next, thanks for clarifying!

All the dependencies have been pushed.

tbaeder updated this revision to Diff 551854.Aug 20 2023, 10:27 AM

So you can enable some of the sema source location tests?

I do in https://reviews.llvm.org/D156045, but that depends on other commits (not sure which exactly right now though).

cor3ntin accepted this revision.Sep 5 2023, 5:45 AM
This revision is now accepted and ready to land.Sep 5 2023, 5:45 AM
This revision was landed with ongoing or failed builds.Sep 6 2023, 5:46 AM
This revision was automatically updated to reflect the committed changes.