-
Notifications
You must be signed in to change notification settings - Fork 26
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
Consolidate the template instantiation logic. #128
Consolidate the template instantiation logic. #128
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #128 +/- ##
===========================================
- Coverage 78.74% 63.24% -15.51%
===========================================
Files 8 15 +7
Lines 3091 4097 +1006
===========================================
+ Hits 2434 2591 +157
- Misses 657 1506 +849
... and 15 files with indirect coverage changes
|
cbacdb4
to
0d69570
Compare
This looks good to go for the incoming template fix patch in |
3280562
to
81bde3d
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/Interpreter/CppInterOp.cpp
Outdated
} else if (auto* VarTemplate = dyn_cast<VarTemplateDecl>(TemplateD)) { | ||
DeclResult R = S.CheckVarTemplateId(VarTemplate, fakeLoc, fakeLoc, TLI); | ||
if (R.isInvalid()) { | ||
// FIXME: Diagnose | ||
} | ||
return R.get(); | ||
} |
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 use 'else' after 'return' [llvm-else-after-return]
} else if (auto* VarTemplate = dyn_cast<VarTemplateDecl>(TemplateD)) { | |
DeclResult R = S.CheckVarTemplateId(VarTemplate, fakeLoc, fakeLoc, TLI); | |
if (R.isInvalid()) { | |
// FIXME: Diagnose | |
} | |
return R.get(); | |
} | |
} if (auto* VarTemplate = dyn_cast<VarTemplateDecl>(TemplateD)) { | |
DeclResult R = S.CheckVarTemplateId(VarTemplate, fakeLoc, fakeLoc, TLI); | |
if (R.isInvalid()) { | |
// FIXME: Diagnose | |
} | |
return R.get(); | |
} |
81bde3d
to
a3750e9
Compare
This patch offers a single interface for instantiation of class, function and variable templates. That would simplify user code where we do not need to care what is the underlying template pattern (most of the time).
8a31adc
to
2aa6cec
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
} | ||
|
||
if (auto* VarTemplate = dyn_cast<VarTemplateDecl>(TemplateD)) { | ||
DeclResult R = S.CheckVarTemplateId(VarTemplate, fakeLoc, fakeLoc, TLI); |
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: variable 'R' is not initialized [cppcoreguidelines-init-variables]
DeclResult R = S.CheckVarTemplateId(VarTemplate, fakeLoc, fakeLoc, TLI); | |
DeclResult R = 0 = S.CheckVarTemplateId(VarTemplate, fakeLoc, fakeLoc, TLI); |
} | ||
|
||
TEST(ScopeReflectionTest, InstantiateVarTemplate) { | ||
std::vector<Decl*> Decls; |
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: variable 'Decls' is not initialized [cppcoreguidelines-init-variables]
std::vector<Decl*> Decls; | |
std::vector<Decl*> Decls = 0; |
GetAllTopLevelDecls(code, Decls); | ||
ASTContext& C = Interp->getCI()->getASTContext(); | ||
|
||
std::vector<Cpp::TemplateArgInfo> args1 = {C.IntTy.getAsOpaquePtr()}; |
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: variable 'args1' is not initialized [cppcoreguidelines-init-variables]
std::vector<Cpp::TemplateArgInfo> args1 = {C.IntTy.getAsOpaquePtr()}; | |
std::vector<Cpp::TemplateArgInfo> args1 = 0 = {C.IntTy.getAsOpaquePtr()}; |
} | ||
|
||
TEST(ScopeReflectionTest, InstantiateFunctionTemplate) { | ||
std::vector<Decl*> Decls; |
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: variable 'Decls' is not initialized [cppcoreguidelines-init-variables]
std::vector<Decl*> Decls; | |
std::vector<Decl*> Decls = 0; |
GetAllTopLevelDecls(code, Decls); | ||
ASTContext& C = Interp->getCI()->getASTContext(); | ||
|
||
std::vector<Cpp::TemplateArgInfo> args1 = {C.IntTy.getAsOpaquePtr()}; |
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: variable 'args1' is not initialized [cppcoreguidelines-init-variables]
std::vector<Cpp::TemplateArgInfo> args1 = {C.IntTy.getAsOpaquePtr()}; | |
std::vector<Cpp::TemplateArgInfo> args1 = 0 = {C.IntTy.getAsOpaquePtr()}; |
@vgvassilev looks like all the bots are failing only on the cppyy and xeus builds due to the pending update in cppyy-backend compiler-research/cppyy-backend#94 I believe this PR can be merged now |
This patch offers a single interface for instantiation of class, function and variable templates. That would simplify user code where we do not need to care what is the underlying template pattern (most of the time).