Consolidate the template instantiation logic.#128
Consolidate the template instantiation logic.#128vgvassilev merged 2 commits intocompiler-research:mainfrom
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
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.
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
| } | ||
|
|
||
| if (auto* VarTemplate = dyn_cast<VarTemplateDecl>(TemplateD)) { | ||
| DeclResult R = S.CheckVarTemplateId(VarTemplate, fakeLoc, fakeLoc, TLI); |
There was a problem hiding this comment.
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.
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.
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.
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.
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).