If the first parameter of the function is the ImplicitParamDecl codegen
automatically marks it as an implicit argument with this or self
pointer. To fix this problem Implicit ThisOrSelfAttr is added. This
attribute is used to mark real this or self pointers only.
Details
- Reviewers
rjmccall aaron.ballman - Commits
- rG56223237b083: [DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.
rC305075: [DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.
rL305075: [DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.
Diff Detail
- Repository
- rL LLVM
Event Timeline
Can you help me to understand what problem is being solved with this new attribute? Under what circumstances would the first argument be an ImplicitParamDecl but not an implicit this or self?
For captured regions an outlined function is created, where all parameters are ImplicitParamDecls. And the very first parameter is wrongly treated as 'this' argument of the member function.
Ah, thank you! That makes sense to me, but it begs the question: why an attribute rather than a bit on ImplicitParamDecl?
I agree: it would make more sense for ImplicitParamDecl to store a Kind that would always be provided at construction.
include/clang/AST/Decl.h | ||
---|---|---|
1388 ↗ | (On Diff #101199) | Is there a good reason not to have a little enum here and require the caller to pass it down? There's only 20 different call sites, it shouldn't be hard to quickly classify them. I think we should at least have: ObjCSelf ObjCCmd CXXThis CXXVTT and then if you want to categorize everything else as Other, that's fine. |
lib/CodeGen/CGDebugInfo.cpp | ||
3466 ↗ | (On Diff #101199) | I don't think you need the ArgNo conditions anymore. |
include/clang/AST/Decl.h | ||
---|---|---|
1387 ↗ | (On Diff #101402) | I would just call this "Other" and document it as being for kinds of implicit parameters that we haven't seen a purpose in categorizing yet. (Or you could just classify them all, I suppose.) We can use C++11 features in Clang now, so I would recommend hoisting this type out of ImplicitParamDecl and making it an enum class. You can then drop the "IPK_" prefixes. |
1394 ↗ | (On Diff #101402) | Comment is out-of-date. Also, please compress this into VarDecl's bit-field storage. |
1405 ↗ | (On Diff #101402) | I see the point in having a convenience constructor like this, but it should probably still take an IPK. |
1426 ↗ | (On Diff #101402) | Same idea. This should probably still take an IPK. |
1429 ↗ | (On Diff #101402) | This comment is out-of-date. |
lib/CodeGen/CGDebugInfo.cpp | ||
3475 ↗ | (On Diff #101402) | Looks like this whole block is still unnecessarily indented. |
lib/CodeGen/CGException.cpp | ||
1654 ↗ | (On Diff #101402) | These do not feel like good uses of your shorthand constructors. |
include/clang/AST/Decl.h | ||
---|---|---|
1387 ↗ | (On Diff #101402) | It's hard to classify them, in most cases they just represent some general parameters used for correct codegen of function types and that's it. |
include/clang/AST/Decl.h | ||
---|---|---|
901 ↗ | (On Diff #101571) | It's a bit strange to me that the non-parameter declaration bits now have a field for implicit parameter information. Why here instead of ParmVarDeclBits? |
1383 ↗ | (On Diff #101571) | Rather than use three access specifiers, can you reorder this? class ... { void anchor() override; public: ... }; |
lib/CodeGen/CGDebugInfo.cpp | ||
3471 ↗ | (On Diff #101571) | const auto * please. |
3586 ↗ | (On Diff #101571) | const auto * |
lib/CodeGen/CGOpenMPRuntime.cpp | ||
3467 ↗ | (On Diff #101571) | This no longer sets the SourceLocation -- is that intended? |
3479–3480 ↗ | (On Diff #101571) | This code would be cleaner if ImplicitParamDecl::Create() took a SourceLocation as it originally did. Perhaps the last param could be a default argument that defaults to SourceLocation{}? |
lib/CodeGen/CGStmtOpenMP.cpp | ||
284 ↗ | (On Diff #101571) | Why use a local variable here? |
lib/CodeGen/ItaniumCXXABI.cpp | ||
1411 ↗ | (On Diff #101571) | Can use auto * here. |
lib/CodeGen/MicrosoftCXXABI.cpp | ||
1416 ↗ | (On Diff #101571) | auto * |
1429 ↗ | (On Diff #101571) | auto * |
lib/Sema/SemaStmt.cpp | ||
3959 ↗ | (On Diff #101571) | auto * (and elsewhere, I'll stop posting about them.) |
lib/Serialization/ASTWriterDecl.cpp | ||
918 ↗ | (On Diff #101571) | const auto * |
include/clang/AST/Decl.h | ||
---|---|---|
901 ↗ | (On Diff #101571) | Actually, ImplicitParamDecl already uses some bits from the NonParmVarDeclBitfields, at least it may be marked as ARCPseudoStrong for ObjC. That's why I had to reuse NonParmVarDeclBitfields part. |
1383 ↗ | (On Diff #101571) | Ok |
lib/CodeGen/CGOpenMPRuntime.cpp | ||
3467 ↗ | (On Diff #101571) | Just missed this after some reworks, will return it back |
include/clang/AST/Decl.h | ||
---|---|---|
901 ↗ | (On Diff #101571) | Ew. That's nasty and we should probably fix that (not as part of this patch). Can you add a FIXME here? |
include/clang/AST/Decl.h | ||
---|---|---|
901 ↗ | (On Diff #101571) | Ok, I will add FIXME for ARCPseudoStrong and for the ImplicitParamKind bitfields |
Aside from one minor nit, LGTM!
include/clang/AST/Decl.h | ||
---|---|---|
901 ↗ | (On Diff #101571) |
Then the class name is poor, because I would not expect to find *anything* about parameter declarations (implicit or otherwise) in a class named NonParmVarDeclBitfields. However, I see the logic behind the split better now, so thank you for that. (Nothing needs to be done here for this patch.) |
lib/Serialization/ASTWriterDecl.cpp | ||
918 ↗ | (On Diff #101571) | This is still missing the const qualifier. |
include/clang/AST/Decl.h | ||
---|---|---|
901 ↗ | (On Diff #101571) | Yeah, I agree that it's unfortunate that we have two separate classes for parameter declarations. |