[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
This revision was automatically updated to reflect the committed changes. Closed by commit rL305075: [DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer. (authored by ABataev). Changed prior to commit: https://reviews.llvm.org/D33735?vs=101908&id=102024#toc Repository: rL LLVM https://reviews.llvm.org/D33735 Files: cfe/trunk/include/clang/AST/Decl.h cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/AST/Decl.cpp cfe/trunk/lib/AST/DeclObjC.cpp cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGCXXABI.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CGException.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriterDecl.cpp cfe/trunk/test/CodeGen/captured-statements.c cfe/trunk/test/CodeGenCXX/captured-statements.cpp Index: cfe/trunk/include/clang/AST/Decl.h === --- cfe/trunk/include/clang/AST/Decl.h +++ cfe/trunk/include/clang/AST/Decl.h @@ -851,6 +851,7 @@ class NonParmVarDeclBitfields { friend class VarDecl; +friend class ImplicitParamDecl; friend class ASTDeclReader; unsigned : NumVarDeclBits; @@ -894,6 +895,10 @@ /// declared in the same block scope. This controls whether we should merge /// the type of this declaration with its previous declaration. unsigned PreviousDeclInSameBlockScope : 1; + +/// Defines kind of the ImplicitParamDecl: 'this', 'self', 'vtt', '_cmd' or +/// something else. +unsigned ImplicitParamKind : 3; }; union { @@ -1376,20 +1381,50 @@ class ImplicitParamDecl : public VarDecl { void anchor() override; + public: + /// Defines the kind of the implicit parameter: is this an implicit parameter + /// with pointer to 'this', 'self', '_cmd', virtual table pointers, captured + /// context or something else. + enum ImplicitParamKind : unsigned { +ObjCSelf,/// Parameter for Objective-C 'self' argument +ObjCCmd, /// Parameter for Objective-C '_cmd' argument +CXXThis, /// Parameter for C++ 'this' argument +CXXVTT, /// Parameter for C++ virtual table pointers +CapturedContext, /// Parameter for captured context +Other, /// Other implicit parameter + }; + + /// Create implicit parameter. static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, - QualType T); + QualType T, ImplicitParamKind ParamKind); + static ImplicitParamDecl *Create(ASTContext &C, QualType T, + ImplicitParamKind ParamKind); static ImplicitParamDecl *CreateDeserialized(ASTContext &C, unsigned ID); ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, -IdentifierInfo *Id, QualType Type) -: VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type, - /*tinfo*/ nullptr, SC_None) { +IdentifierInfo *Id, QualType Type, +ImplicitParamKind ParamKind) + : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type, +/*TInfo=*/nullptr, SC_None) { +NonParmVarDeclBits.ImplicitParamKind = ParamKind; setImplicit(); } + ImplicitParamDecl(ASTContext &C, QualType Type, ImplicitParamKind ParamKind) + : VarDecl(ImplicitParam, C, /*DC=*/nullptr, SourceLocation(), +SourceLocation(), /*Id=*/nullptr, Type, +/*TInfo=*/nullptr, SC_None) { +NonParmVarDeclBits.ImplicitParamKind = ParamKind; +setImplicit(); + } + + /// Returns the implicit parameter kind. + ImplicitParamKind getParameterKind() const { +return static_cast(NonParmVarDeclBits.ImplicitParamKind); + } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == ImplicitParam; } Index: cfe/trunk/test/CodeGen/captured-statements.c === --- cfe/trunk/test/CodeGen/captured-statements.c +++ cfe/trunk/test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-fil
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
rjmccall accepted this revision. rjmccall added inline comments. Comment at: include/clang/AST/Decl.h:901 +/// member functions. +unsigned ImplicitParamKind : 3; }; aaron.ballman wrote: > rjmccall wrote: > > ABataev wrote: > > > aaron.ballman wrote: > > > > ABataev wrote: > > > > > aaron.ballman wrote: > > > > > > 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`? > > > > > 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. > > > > Ew. That's nasty and we should probably fix that (not as part of this > > > > patch). Can you add a FIXME here? > > > Ok, I will add FIXME for `ARCPseudoStrong` and for the > > > `ImplicitParamKind` bitfields > > The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of > > ParamVarDecl. > > > > The comment here needs to be updated. > > The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of > > ParamVarDecl. > > 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.) Yeah, I agree that it's unfortunate that we have two separate classes for parameter declarations. https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. Aside from one minor nit, LGTM! Comment at: include/clang/AST/Decl.h:901 +/// member functions. +unsigned ImplicitParamKind : 3; }; rjmccall wrote: > ABataev wrote: > > aaron.ballman wrote: > > > ABataev wrote: > > > > aaron.ballman wrote: > > > > > 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`? > > > > 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. > > > Ew. That's nasty and we should probably fix that (not as part of this > > > patch). Can you add a FIXME here? > > Ok, I will add FIXME for `ARCPseudoStrong` and for the `ImplicitParamKind` > > bitfields > The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of > ParamVarDecl. > > The comment here needs to be updated. > The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of > ParamVarDecl. 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.) Comment at: lib/Serialization/ASTWriterDecl.cpp:918 Record.push_back(D->isPreviousDeclInSameBlockScope()); +if (auto *IPD = dyn_cast(D)) + Record.push_back(static_cast(IPD->getParameterKind())); aaron.ballman wrote: > `const auto *` This is still missing the `const` qualifier. https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev updated this revision to Diff 101908. ABataev added a comment. Removed FIXMEs and corrected comment https://reviews.llvm.org/D33735 Files: include/clang/AST/Decl.h lib/AST/ASTImporter.cpp lib/AST/Decl.cpp lib/AST/DeclObjC.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGCXXABI.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/CGException.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGObjC.cpp lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/CodeGen/MicrosoftCXXABI.cpp lib/Sema/SemaStmt.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/CodeGen/captured-statements.c test/CodeGenCXX/captured-statements.cpp Index: test/CodeGenCXX/captured-statements.cpp === --- test/CodeGenCXX/captured-statements.cpp +++ test/CodeGenCXX/captured-statements.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 @@ -194,3 +194,18 @@ void call_test_captured_linkage() { test_captured_linkage(); } + +// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) Index: test/CodeGen/captured-statements.c === --- test/CodeGen/captured-statements.c +++ test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 @@ -98,3 +98,8 @@ // CHECK-GLOBALS: load i32, i32* @global // CHECK-GLOBALS: load i32, i32* @ // CHECK-GLOBALS: load i32, i32* @e + +// CHECK-GLOBALS-NOT: DIFlagObjectPointer +// CHECK-1-NOT: DIFlagObjectPointer +// CHECK-2-NOT: DIFlagObjectPointer +// CHECK-3-NOT: DIFlagObjectPointer Index: lib/Serialization/ASTWriterDecl.cpp === --- lib/Serialization/ASTWriterDecl.cpp +++ lib/Serialization/ASTWriterDecl.cpp @@ -915,6 +915,10 @@ Record.push_back(D->isConstexpr()); Record.push_back(D->isInitCapture()); Record.push_back(D->isPreviousDeclInSameBlockScope()); +if (auto *IPD = dyn_cast(D)) + Record.push_back(static_cast(IPD->getParameterKind())); +else + Record.push_back(0); } Record.push_back(D->getLinkageInternal()); @@ -1989,6 +1993,7 @@ Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope + Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local) Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum) Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1229,6 +1229,7 @@ VD->NonParmVarDeclBits.I
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
rjmccall added inline comments. Comment at: include/clang/AST/Decl.h:1387 +IPK_CapturedContext, /// Parameter for captured context +IPK_GeneralParam,/// General implicit parameter + }; ABataev wrote: > rjmccall wrote: > > 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. > 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. That's fair. Comment at: include/clang/AST/Decl.h:901 +/// member functions. +unsigned ImplicitParamKind : 3; }; ABataev wrote: > aaron.ballman wrote: > > ABataev wrote: > > > aaron.ballman wrote: > > > > 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`? > > > 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. > > Ew. That's nasty and we should probably fix that (not as part of this > > patch). Can you add a FIXME here? > Ok, I will add FIXME for `ARCPseudoStrong` and for the `ImplicitParamKind` > bitfields The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of ParamVarDecl. The comment here needs to be updated. https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev updated this revision to Diff 101751. ABataev added a comment. Update after review https://reviews.llvm.org/D33735 Files: include/clang/AST/Decl.h lib/AST/ASTImporter.cpp lib/AST/Decl.cpp lib/AST/DeclObjC.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGCXXABI.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/CGException.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGObjC.cpp lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/CodeGen/MicrosoftCXXABI.cpp lib/Sema/SemaStmt.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/CodeGen/captured-statements.c test/CodeGenCXX/captured-statements.cpp Index: test/CodeGenCXX/captured-statements.cpp === --- test/CodeGenCXX/captured-statements.cpp +++ test/CodeGenCXX/captured-statements.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 @@ -194,3 +194,18 @@ void call_test_captured_linkage() { test_captured_linkage(); } + +// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) Index: test/CodeGen/captured-statements.c === --- test/CodeGen/captured-statements.c +++ test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 @@ -98,3 +98,8 @@ // CHECK-GLOBALS: load i32, i32* @global // CHECK-GLOBALS: load i32, i32* @ // CHECK-GLOBALS: load i32, i32* @e + +// CHECK-GLOBALS-NOT: DIFlagObjectPointer +// CHECK-1-NOT: DIFlagObjectPointer +// CHECK-2-NOT: DIFlagObjectPointer +// CHECK-3-NOT: DIFlagObjectPointer Index: lib/Serialization/ASTWriterDecl.cpp === --- lib/Serialization/ASTWriterDecl.cpp +++ lib/Serialization/ASTWriterDecl.cpp @@ -915,6 +915,10 @@ Record.push_back(D->isConstexpr()); Record.push_back(D->isInitCapture()); Record.push_back(D->isPreviousDeclInSameBlockScope()); +if (auto *IPD = dyn_cast(D)) + Record.push_back(static_cast(IPD->getParameterKind())); +else + Record.push_back(0); } Record.push_back(D->getLinkageInternal()); @@ -1989,6 +1993,7 @@ Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope + Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local) Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum) Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1229,6 +1229,7 @@ VD->NonParmVarDeclBits.IsConstexpr = Reco
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev added inline comments. Comment at: include/clang/AST/Decl.h:901 +/// member functions. +unsigned ImplicitParamKind : 3; }; aaron.ballman wrote: > ABataev wrote: > > aaron.ballman wrote: > > > 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`? > > 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. > Ew. That's nasty and we should probably fix that (not as part of this patch). > Can you add a FIXME here? Ok, I will add FIXME for `ARCPseudoStrong` and for the `ImplicitParamKind` bitfields https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
aaron.ballman added inline comments. Comment at: include/clang/AST/Decl.h:901 +/// member functions. +unsigned ImplicitParamKind : 3; }; ABataev wrote: > aaron.ballman wrote: > > 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`? > 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. Ew. That's nasty and we should probably fix that (not as part of this patch). Can you add a FIXME here? https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev added inline comments. Comment at: include/clang/AST/Decl.h:901 +/// member functions. +unsigned ImplicitParamKind : 3; }; aaron.ballman wrote: > 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`? 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. Comment at: include/clang/AST/Decl.h:1383 class ImplicitParamDecl : public VarDecl { +public: + /// Defines the kind of the implicit parameter: is this an implicit parameter aaron.ballman wrote: > Rather than use three access specifiers, can you reorder this? > ``` > class ... { > void anchor() override; > > public: > ... > }; > ``` Ok Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3467 ImplicitParamDecl TaskPrivatesArg( - C, /*DC=*/nullptr, Loc, /*Id=*/nullptr, - C.getPointerType(PrivatesQTy).withConst().withRestrict()); + C, C.getPointerType(PrivatesQTy).withConst().withRestrict(), + ImplicitParamDecl::Other); aaron.ballman wrote: > This no longer sets the SourceLocation -- is that intended? Just missed this after some reworks, will return it back https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
aaron.ballman added inline comments. Comment at: include/clang/AST/Decl.h:901 +/// member functions. +unsigned ImplicitParamKind : 3; }; 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`? Comment at: include/clang/AST/Decl.h:1383 class ImplicitParamDecl : public VarDecl { +public: + /// Defines the kind of the implicit parameter: is this an implicit parameter Rather than use three access specifiers, can you reorder this? ``` class ... { void anchor() override; public: ... }; ``` Comment at: lib/CodeGen/CGDebugInfo.cpp:3471 + // then give it an object pointer flag. + if (auto *IPD = dyn_cast(VD)) { +if (IPD->getParameterKind() == ImplicitParamDecl::CXXThis || `const auto *` please. Comment at: lib/CodeGen/CGDebugInfo.cpp:3586 // block. Mark it as the object pointer. - if (isa(VD) && VD->getName() == "self") -Ty = CreateSelfType(VD->getType(), Ty); + if (auto *IPD = dyn_cast(VD)) +if (IPD->getParameterKind() == ImplicitParamDecl::ObjCSelf) `const auto *` Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3467 ImplicitParamDecl TaskPrivatesArg( - C, /*DC=*/nullptr, Loc, /*Id=*/nullptr, - C.getPointerType(PrivatesQTy).withConst().withRestrict()); + C, C.getPointerType(PrivatesQTy).withConst().withRestrict(), + ImplicitParamDecl::Other); This no longer sets the SourceLocation -- is that intended? Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3479-3480 +ImplicitParamDecl::Other); +IPD->setLocation(Loc); +Args.push_back(IPD); auto *VD = cast(cast(E)->getDecl()); 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{}`? Comment at: lib/CodeGen/CGStmtOpenMP.cpp:284 } -Args.push_back(ImplicitParamDecl::Create(getContext(), nullptr, - FD->getLocation(), II, ArgType)); +auto *IPD = ImplicitParamDecl::Create(getContext(), /*DC=*/nullptr, + FD->getLocation(), II, ArgType, Why use a local variable here? Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1411 QualType T = Context.getPointerType(Context.VoidPtrTy); -ImplicitParamDecl *VTTDecl - = ImplicitParamDecl::Create(Context, nullptr, MD->getLocation(), - &Context.Idents.get("vtt"), T); +ImplicitParamDecl *VTTDecl = ImplicitParamDecl::Create( +Context, nullptr, MD->getLocation(), &Context.Idents.get("vtt"), T, Can use `auto *` here. Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1416 if (isa(MD) && MD->getParent()->getNumVBases()) { -ImplicitParamDecl *IsMostDerived - = ImplicitParamDecl::Create(Context, nullptr, - CGF.CurGD.getDecl()->getLocation(), - &Context.Idents.get("is_most_derived"), - Context.IntTy); +ImplicitParamDecl *IsMostDerived = ImplicitParamDecl::Create( +Context, /*DC=*/nullptr, CGF.CurGD.getDecl()->getLocation(), `auto *` Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1429 } else if (isDeletingDtor(CGF.CurGD)) { -ImplicitParamDecl *ShouldDelete - = ImplicitParamDecl::Create(Context, nullptr, - CGF.CurGD.getDecl()->getLocation(), - &Context.Idents.get("should_call_delete"), - Context.IntTy); +ImplicitParamDecl *ShouldDelete = ImplicitParamDecl::Create( +Context, /*DC=*/nullptr, CGF.CurGD.getDecl()->getLocation(), `auto *` Comment at: lib/Sema/SemaStmt.cpp:3959 QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD)); - ImplicitParamDecl *Param -= ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType); + ImplicitParamDecl *Param = + ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType, `auto *` (and elsewhere, I'll stop posting about them.) Comment at: lib/Serialization/ASTWriterDecl.cpp:918 Record.push_back(D->isPreviousDeclInSameBlockScope()); +if (auto *IPD = dyn_cast(D)) + Record.push_back(static_cast(IPD->getParameterKind())); `const auto *` https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev updated this revision to Diff 101571. ABataev marked an inline comment as done. ABataev added a comment. Address John comments. https://reviews.llvm.org/D33735 Files: include/clang/AST/Decl.h lib/AST/ASTImporter.cpp lib/AST/Decl.cpp lib/AST/DeclObjC.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGCXXABI.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/CGException.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGObjC.cpp lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/CodeGen/MicrosoftCXXABI.cpp lib/Sema/SemaStmt.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/CodeGen/captured-statements.c test/CodeGenCXX/captured-statements.cpp Index: test/CodeGenCXX/captured-statements.cpp === --- test/CodeGenCXX/captured-statements.cpp +++ test/CodeGenCXX/captured-statements.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 @@ -194,3 +194,18 @@ void call_test_captured_linkage() { test_captured_linkage(); } + +// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) Index: test/CodeGen/captured-statements.c === --- test/CodeGen/captured-statements.c +++ test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 @@ -98,3 +98,8 @@ // CHECK-GLOBALS: load i32, i32* @global // CHECK-GLOBALS: load i32, i32* @ // CHECK-GLOBALS: load i32, i32* @e + +// CHECK-GLOBALS-NOT: DIFlagObjectPointer +// CHECK-1-NOT: DIFlagObjectPointer +// CHECK-2-NOT: DIFlagObjectPointer +// CHECK-3-NOT: DIFlagObjectPointer Index: lib/Serialization/ASTWriterDecl.cpp === --- lib/Serialization/ASTWriterDecl.cpp +++ lib/Serialization/ASTWriterDecl.cpp @@ -915,6 +915,10 @@ Record.push_back(D->isConstexpr()); Record.push_back(D->isInitCapture()); Record.push_back(D->isPreviousDeclInSameBlockScope()); +if (auto *IPD = dyn_cast(D)) + Record.push_back(static_cast(IPD->getParameterKind())); +else + Record.push_back(0); } Record.push_back(D->getLinkageInternal()); @@ -1989,6 +1993,7 @@ Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope + Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local) Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum) Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1229,6 +1229,7 @@
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev marked 7 inline comments as done. ABataev added inline comments. Comment at: include/clang/AST/Decl.h:1387 +IPK_CapturedContext, /// Parameter for captured context +IPK_GeneralParam,/// General implicit parameter + }; rjmccall wrote: > 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. 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. https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
rjmccall added inline comments. Comment at: include/clang/AST/Decl.h:1387 +IPK_CapturedContext, /// Parameter for captured context +IPK_GeneralParam,/// General implicit parameter + }; 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. Comment at: include/clang/AST/Decl.h:1394 + /// Whether this parameter represents implicit 'this'|'self' argument in + /// member functions. + ImplicitParamKind ParamKind; Comment is out-of-date. Also, please compress this into VarDecl's bit-field storage. Comment at: include/clang/AST/Decl.h:1405 + static ImplicitParamDecl *Create(ASTContext &C, QualType T, + DeclContext *DC = nullptr); I see the point in having a convenience constructor like this, but it should probably still take an IPK. Comment at: include/clang/AST/Decl.h:1426 setImplicit(); } Same idea. This should probably still take an IPK. Comment at: include/clang/AST/Decl.h:1429 + /// Returns true if the parameter represents implicit 'this' or 'self' + /// argument in member functions. + ImplicitParamKind getParameterKind() const { return ParamKind; } This comment is out-of-date. Comment at: lib/CodeGen/CGDebugInfo.cpp:3475 +Flags |= llvm::DINode::FlagObjectPointer; +} Looks like this whole block is still unnecessarily indented. Comment at: lib/CodeGen/CGException.cpp:1654 + IPD->setLocation(StartLoc); + IPD->setDeclName(&getContext().Idents.get("exception_pointers")); + Args.push_back(IPD); These do not feel like good uses of your shorthand constructors. https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev updated this revision to Diff 101402. ABataev added a comment. Added DeclContext parameter to constructors of ImplicitParamDecl class. https://reviews.llvm.org/D33735 Files: include/clang/AST/Decl.h lib/AST/ASTImporter.cpp lib/AST/Decl.cpp lib/AST/DeclObjC.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGCXXABI.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/CGException.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGObjC.cpp lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/CodeGen/MicrosoftCXXABI.cpp lib/Sema/SemaStmt.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/CodeGen/captured-statements.c test/CodeGenCXX/captured-statements.cpp Index: test/CodeGenCXX/captured-statements.cpp === --- test/CodeGenCXX/captured-statements.cpp +++ test/CodeGenCXX/captured-statements.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 @@ -194,3 +194,18 @@ void call_test_captured_linkage() { test_captured_linkage(); } + +// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) Index: test/CodeGen/captured-statements.c === --- test/CodeGen/captured-statements.c +++ test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 @@ -98,3 +98,8 @@ // CHECK-GLOBALS: load i32, i32* @global // CHECK-GLOBALS: load i32, i32* @ // CHECK-GLOBALS: load i32, i32* @e + +// CHECK-GLOBALS-NOT: DIFlagObjectPointer +// CHECK-1-NOT: DIFlagObjectPointer +// CHECK-2-NOT: DIFlagObjectPointer +// CHECK-3-NOT: DIFlagObjectPointer Index: lib/Serialization/ASTWriterDecl.cpp === --- lib/Serialization/ASTWriterDecl.cpp +++ lib/Serialization/ASTWriterDecl.cpp @@ -967,6 +967,7 @@ void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) { VisitVarDecl(D); + Record.push_back(D->getParameterKind()); Code = serialization::DECL_IMPLICIT_PARAM; } Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1278,6 +1278,8 @@ void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { VisitVarDecl(PD); + PD->ParamKind = + static_cast(Record.readInt()); } void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { Index: lib/Sema/SemaStmt.cpp === --- lib/Sema/SemaStmt.cpp +++ lib/Sema/SemaStmt.cpp @@ -3956,8 +3956,9 @@ DeclContext *DC = CapturedDecl::castToDeclContext(CD); IdentifierInfo *ParamName = &Context.Idents.get("__context"); QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD)); - ImplicitParamDecl *Param -= ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType); + ImplicitPar
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev updated this revision to Diff 101262. ABataev added a comment. Herald added a subscriber: jholewinski. Added different kinds of ImplicitParamDecl. https://reviews.llvm.org/D33735 Files: include/clang/AST/Decl.h lib/AST/ASTImporter.cpp lib/AST/Decl.cpp lib/AST/DeclObjC.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGCXXABI.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/CGException.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGObjC.cpp lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/CodeGen/MicrosoftCXXABI.cpp lib/Sema/SemaStmt.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/CodeGen/captured-statements.c test/CodeGenCXX/captured-statements.cpp Index: test/CodeGenCXX/captured-statements.cpp === --- test/CodeGenCXX/captured-statements.cpp +++ test/CodeGenCXX/captured-statements.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 @@ -194,3 +194,18 @@ void call_test_captured_linkage() { test_captured_linkage(); } + +// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) Index: test/CodeGen/captured-statements.c === --- test/CodeGen/captured-statements.c +++ test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 @@ -98,3 +98,8 @@ // CHECK-GLOBALS: load i32, i32* @global // CHECK-GLOBALS: load i32, i32* @ // CHECK-GLOBALS: load i32, i32* @e + +// CHECK-GLOBALS-NOT: DIFlagObjectPointer +// CHECK-1-NOT: DIFlagObjectPointer +// CHECK-2-NOT: DIFlagObjectPointer +// CHECK-3-NOT: DIFlagObjectPointer Index: lib/Serialization/ASTWriterDecl.cpp === --- lib/Serialization/ASTWriterDecl.cpp +++ lib/Serialization/ASTWriterDecl.cpp @@ -967,6 +967,7 @@ void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) { VisitVarDecl(D); + Record.push_back(D->getParameterKind()); Code = serialization::DECL_IMPLICIT_PARAM; } Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1278,6 +1278,8 @@ void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { VisitVarDecl(PD); + PD->ParamKind = + static_cast(Record.readInt()); } void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { Index: lib/Sema/SemaStmt.cpp === --- lib/Sema/SemaStmt.cpp +++ lib/Sema/SemaStmt.cpp @@ -3956,8 +3956,9 @@ DeclContext *DC = CapturedDecl::castToDeclContext(CD); IdentifierInfo *ParamName = &Context.Idents.get("__context"); QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD)); - ImplicitParamDecl *Param -= ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType); +
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
rjmccall added inline comments. Comment at: include/clang/AST/Decl.h:1388 SourceLocation IdLoc, IdentifierInfo *Id, - QualType T); + QualType T, bool IsThisOrSelf = false); 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. Comment at: lib/CodeGen/CGDebugInfo.cpp:3466 + // If this is the first argument, it is implicit and has ThisOrSelf attribute + // then give it an object pointer flag. + if (ArgNo && *ArgNo == 1) I don't think you need the ArgNo conditions anymore. https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev updated this revision to Diff 101199. ABataev added a comment. Updates after review https://reviews.llvm.org/D33735 Files: include/clang/AST/Decl.h lib/AST/Decl.cpp lib/AST/DeclObjC.cpp lib/CodeGen/CGCXXABI.cpp lib/CodeGen/CGDebugInfo.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/CodeGen/captured-statements.c test/CodeGenCXX/captured-statements.cpp Index: test/CodeGenCXX/captured-statements.cpp === --- test/CodeGenCXX/captured-statements.cpp +++ test/CodeGenCXX/captured-statements.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 @@ -194,3 +194,18 @@ void call_test_captured_linkage() { test_captured_linkage(); } + +// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) Index: test/CodeGen/captured-statements.c === --- test/CodeGen/captured-statements.c +++ test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 @@ -98,3 +98,8 @@ // CHECK-GLOBALS: load i32, i32* @global // CHECK-GLOBALS: load i32, i32* @ // CHECK-GLOBALS: load i32, i32* @e + +// CHECK-GLOBALS-NOT: DIFlagObjectPointer +// CHECK-1-NOT: DIFlagObjectPointer +// CHECK-2-NOT: DIFlagObjectPointer +// CHECK-3-NOT: DIFlagObjectPointer Index: lib/Serialization/ASTWriterDecl.cpp === --- lib/Serialization/ASTWriterDecl.cpp +++ lib/Serialization/ASTWriterDecl.cpp @@ -967,6 +967,7 @@ void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) { VisitVarDecl(D); + Record.push_back(D->isThisOrSelfParam()); Code = serialization::DECL_IMPLICIT_PARAM; } Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1278,6 +1278,7 @@ void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { VisitVarDecl(PD); + PD->IsThisOrSelf = Record.readInt(); } void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -3462,13 +3462,12 @@ unsigned AddressSpace = CGM.getContext().getTargetAddressSpace(VD->getType()); AppendAddressSpaceXDeref(AddressSpace, Expr); - // If this is the first argument and it is implicit then - // give it an object pointer flag. - // FIXME: There has to be a better way to do this, but for static - // functions there won't be an implicit param at arg1 and - // otherwise it is 'self' or 'this'. - if (isa(VD) && ArgNo && *ArgNo == 1) - Flags |= llvm::DINode::FlagObjectPointer; + // If this is the first argument, it is implicit and has ThisOrSelf attribute + // then give it an object pointer flag. + if (ArgNo && *ArgNo == 1) +if (auto *IPD = dyn_cast(VD)) + if (IPD->isThisOrSelfParam()) +Flags |= llvm::DINode::FlagObje
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev added a comment. In https://reviews.llvm.org/D33735#770333, @rjmccall wrote: > In https://reviews.llvm.org/D33735#770318, @aaron.ballman wrote: > > > In https://reviews.llvm.org/D33735#770296, @ABataev wrote: > > > > > In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote: > > > > > > > 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. Ok, will add a field to ImplicitParamDecl, thanks https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
rjmccall added a comment. In https://reviews.llvm.org/D33735#770318, @aaron.ballman wrote: > In https://reviews.llvm.org/D33735#770296, @ABataev wrote: > > > In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote: > > > > > 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. https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
aaron.ballman added a comment. In https://reviews.llvm.org/D33735#770296, @ABataev wrote: > In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote: > > > 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? https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev added a comment. In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote: > 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. https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
aaron.ballman added a comment. 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? https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev created this revision. 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. https://reviews.llvm.org/D33735 Files: include/clang/Basic/Attr.td lib/AST/DeclObjC.cpp lib/CodeGen/CGCXXABI.cpp lib/CodeGen/CGDebugInfo.cpp test/CodeGen/captured-statements.c test/CodeGenCXX/captured-statements.cpp test/Misc/ast-dump-decl.m test/Misc/pragma-attribute-objc-subject-match-rules.m test/Misc/pragma-attribute-objc.m Index: test/Misc/pragma-attribute-objc.m === --- test/Misc/pragma-attribute-objc.m +++ test/Misc/pragma-attribute-objc.m @@ -63,6 +63,7 @@ - (void)testIm:(int) x { // CHECK-LABEL: ObjCMethodDecl{{.*}}testIm // CHECK-NEXT: ImplicitParamDecl +// CHECK-NEXT: ThisOrSelfAttr // CHECK-NEXT: ImplicitParamDecl // CHECK-NEXT: ParmVarDecl{{.*}} x // CHECK-NEXT: AnnotateAttr{{.*}} "test" Index: test/Misc/pragma-attribute-objc-subject-match-rules.m === --- test/Misc/pragma-attribute-objc-subject-match-rules.m +++ test/Misc/pragma-attribute-objc-subject-match-rules.m @@ -60,16 +60,19 @@ @end // CHECK-OBJC_METHOD: ObjCMethodDecl{{.*}} testInstanceMethod // CHECK-OBJC_METHOD-NEXT: ImplicitParamDecl +// CHECK-OBJC_METHOD-NEXT: ThisOrSelfAttr // CHECK-OBJC_METHOD-NEXT: ImplicitParamDecl // CHECK-OBJC_METHOD-NEXT: CompoundStmt // CHECK-OBJC_METHOD-NEXT: AnnotateAttr{{.*}} "test" // CHECK-OBJC_METHOD: ObjCMethodDecl{{.*}} testClassMethod // CHECK-OBJC_METHOD-NEXT: ImplicitParamDecl +// CHECK-OBJC_METHOD-NEXT: ThisOrSelfAttr // CHECK-OBJC_METHOD-NEXT: ImplicitParamDecl // CHECK-OBJC_METHOD-NEXT: CompoundStmt // CHECK-OBJC_METHOD-NEXT: AnnotateAttr{{.*}} "test" // CHECK-OBJC_METHOD_IS_INSTANCE-LABEL: ObjCMethodDecl{{.*}} testInstanceMethod // CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: ImplicitParamDecl +// CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: ThisOrSelfAttr // CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: ImplicitParamDecl // CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: CompoundStmt // CHECK-OBJC_METHOD_IS_INSTANCE-NEXT: AnnotateAttr{{.*}} "test" Index: test/Misc/ast-dump-decl.m === --- test/Misc/ast-dump-decl.m +++ test/Misc/ast-dump-decl.m @@ -39,6 +39,7 @@ } // CHECK: ObjCMethodDecl{{.*}} - TestObjCMethodDecl: 'int' // CHECK-NEXT: ImplicitParamDecl{{.*}} self +// CHECK-NEXT: ThisOrSelfAttr // CHECK-NEXT: ImplicitParamDecl{{.*}} _cmd // CHECK-NEXT: ParmVarDecl{{.*}} i 'int' // CHECK-NEXT: ... Index: test/CodeGenCXX/captured-statements.cpp === --- test/CodeGenCXX/captured-statements.cpp +++ test/CodeGenCXX/captured-statements.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 @@ -194,3 +194,18 @@ void call_test_captured_linkage() { test_captured_linkage(); } + +// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) Index: test/CodeGen/captured-statements.c === --- test/CodeGen/captured-statements.c +++ test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %it