This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Check instance pointers before calling functions on them
ClosedPublic

Authored by tbaeder on Oct 8 2022, 5:47 AM.

Details

Summary

Remove the double Call() implementation to reduce code duplication.
Then fix Function::getSource() so we can diagnose instance pointers being null.

As discussed in https://reviews.llvm.org/D134699 - this fixes the test case added there.
The output in this case is not 100% the same as the current constant interpreter however.

Diff Detail

Event Timeline

tbaeder created this revision.Oct 8 2022, 5:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 8 2022, 5:47 AM
tbaeder requested review of this revision.Oct 8 2022, 5:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 8 2022, 5:47 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tbaeder updated this revision to Diff 466280.Oct 8 2022, 5:48 AM
tbaeder updated this revision to Diff 466281.Oct 8 2022, 5:50 AM
tbaeder updated this revision to Diff 466282.Oct 8 2022, 5:53 AM
tbaeder added inline comments.Oct 10 2022, 9:56 PM
clang/lib/AST/Interp/Interp.h
1119

I think this is okay to do for now, but in the long run we need to check *all* the parameters passed to function calls...

tbaeder added inline comments.Oct 11 2022, 7:05 AM
clang/lib/AST/Interp/Function.cpp
39

While I think the comment here is correct, the decrement itself certainly isn't.

tbaeder updated this revision to Diff 467997.Oct 15 2022, 12:26 AM
aaron.ballman added inline comments.Oct 18 2022, 10:25 AM
clang/lib/AST/Interp/Function.cpp
39

Which comment and which decrement? (Or is this a stale review comment?)

clang/lib/AST/Interp/Interp.h
1111

Use a unique_ptr for this?

tbaeder updated this revision to Diff 468905.Oct 19 2022, 7:11 AM
tbaeder marked an inline comment as done.
This revision is now accepted and ready to land.Oct 19 2022, 9:21 AM
This revision was landed with ongoing or failed builds.Oct 22 2022, 1:50 AM
This revision was automatically updated to reflect the committed changes.