-
Notifications
You must be signed in to change notification settings - Fork 31
[MRE] successive Declare fails if InstantiateFunctionDefinition fails in MakeFunctionCallable #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MRE] successive Declare fails if InstantiateFunctionDefinition fails in MakeFunctionCallable #616
Conversation
clang-tidy review says "All clean, LGTM! 👍" |
Summary of conversion had over discord: |
c2130c8
to
58d155a
Compare
clang-tidy review says "All clean, LGTM! 👍" |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #616 +/- ##
==========================================
+ Coverage 78.00% 78.18% +0.17%
==========================================
Files 9 9
Lines 3769 3781 +12
==========================================
+ Hits 2940 2956 +16
+ Misses 829 825 -4
🚀 New features to boost your workflow:
|
clang-tidy review says "All clean, LGTM! 👍" |
lib/CppInterOp/CppInterOp.cpp
Outdated
GeneratedPTU.takeError(), llvm::errs(), | ||
"[MakeFunctionCallable -> InstantiateFunctionDefinition] Failed to " | ||
"generate PTU:"); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to move this somewhere in InstantiateTemplate
and replace S.InstantiateFunctionDefinition
with it?
58d155a
to
65f2092
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
Cpp::GetClassTemplatedMethods("is_equal", Cpp::GetGlobalScope(), fns); | ||
EXPECT_EQ(fns.size(), 1); | ||
|
||
Cpp::TemplateArgInfo args[2] = {{o1}, {o2}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays]
Cpp::TemplateArgInfo args[2] = {{o1}, {o2}};
^
EXPECT_EQ(fns.size(), 1); | ||
|
||
Cpp::TemplateArgInfo args[2] = {{o1}, {o2}}; | ||
Cpp::TCppScope_t fn = Cpp::InstantiateTemplate(fns[0], args, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
Cpp::TCppScope_t fn = Cpp::InstantiateTemplate(fns[0], args, 2);
^
04cdcd5
to
35b6780
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
lib/CppInterOp/Compatibility.h
Outdated
@@ -376,6 +380,20 @@ namespace Cpp_utils = Cpp::utils; | |||
|
|||
namespace compat { | |||
using Interpreter = Cpp::Interpreter; | |||
|
|||
class PushTransactionRAII { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: class 'PushTransactionRAII' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class PushTransactionRAII {
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should be something like SynthesizingCodeRAII
or similar that tells the reader that we are producing ast nodes and require the codegen and the jit to know about it...
lib/CppInterOp/CppInterOp.cpp
Outdated
getSema().InstantiateFunctionDefinition(SourceLocation(), FD, | ||
/*Recursive=*/true, | ||
/*DefinitionRequired=*/true); | ||
(void)Cpp::Interpreter::CompilationResult(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "Cpp::Interpreter" is directly included [misc-include-cleaner]
lib/CppInterOp/CppInterOp.cpp:12:
+ #include "CppInterOpInterpreter.h"
16ae2e9
to
9f0c48a
Compare
9f0c48a
to
688fb53
Compare
add `InstantiateFunctionDefinition` function
688fb53
to
07e91ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
@@ -376,6 +381,20 @@ namespace Cpp_utils = Cpp::utils; | |||
|
|||
namespace compat { | |||
using Interpreter = Cpp::Interpreter; | |||
|
|||
class SynthesizingCodeRAII { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: class 'SynthesizingCodeRAII' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class SynthesizingCodeRAII {
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we replace more occurrences of PushTransactionRAII? LGTM!
I have not replaced it in other places because clang does the necessary cleanup, and we need not explicitly compile code for the cleanup to take place. If I replace it in all the occurrences, it would hit performance. |
This is a bug report.
If the instantiation of a templated function fails while CodeGen (
MakeFunctionCallable
), then successive call toCpp::Declare
fails.But a second call to
Cpp::Declare
will pass.I suspect something similar to
is required?