Redecl chains of function templates are not handled well currently. We
want to handle them similarly to functions, i.e. try to keep the
structure of the original AST as much as possible. The aim is to not
squash a prototype with a definition, rather we create both and put them
in a redecl chain.
Details
Diff Detail
- Repository
- rC Clang
- Build Status
Buildable 28555 Build 28554: arc lint + arc unit
Event Timeline
Hi Gabor,
The patch looks OK overall but I have some comments inline.
lib/AST/ASTImporter.cpp | ||
---|---|---|
4966–4967 | We should point that this function is for TemplateDecls only somehow. But we can't just pass TemplateDecl as the parameter due to loss of the actual return type. Maybewe should rename this function into "getTemplateDefinition()"? | |
5568 | We don't usually put such comments after control flow statements. If they are really needed, it is a good sign that a function must be split, and it's better to leave a FIXME for this (or do the split). |
@shafik, Could you please take a look?
I have run the LLDB tests on our macOS and I could not discover any regression.
LGTM outside of the question I had.
lib/AST/ASTImporter.cpp | ||
---|---|---|
4967 | Can we guarantee that D->getTemplatedDecl() will always return a valid pointer? | |
4967 | What other types besides CXXRecordDecl do we expect here? | |
5544 | Would it make sense to do the split into a separate function in the PR? | |
5595 | Can we guarantee that FoundByLookup->getTemplatedDecl() will always return a valid pointer? |
lib/AST/ASTImporter.cpp | ||
---|---|---|
4967 |
Actually, we always call this function on a ClassTemplateDecl or on a FunctionTemplateDecl which should return with a valid pointer. Still it is a good idea to put an assert at the beginning of the function, so I just did that. assert(D->getTemplatedDecl() && "Should be called on templates only");
FunctionDecl can be there too when we call this on a FunctiomTemplateDecl param. | |
5544 | I'd rather do that in another patch where we could address the similar issues in other visit functions too. Actually, most of the visit functions start with a lookup and then continue with a loop over the lookup results; this part could be split into a separate function everywhere. | |
5595 | This is a good catch, thanks. |
We should point that this function is for TemplateDecls only somehow. But we can't just pass TemplateDecl as the parameter due to loss of the actual return type. Maybewe should rename this function into "getTemplateDefinition()"?