[clang] [llvm] Add RunTimeLang to Class and Enumeration DIBuilder functions (PR #72011)

2023-11-10 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/72011

RunTimeLang is already supported by DICompositeType, and already used by 
structs and unions. Add a new parameter in the class and enumeration create 
methods, so they can use the RunTimeLang attribute as well.

>From 82e6fefc0df010539519fefcae22c49d6c2a1459 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Fri, 10 Nov 2023 17:42:47 -0800
Subject: [PATCH] Add RunTimeLang to Class and Enumeration DIBuilder functions

RunTimeLang is already supported by DICompositeType, and already used by
structs and unions. Add a new parameter in the class and enumeration
create methods, so they can use the RunTimeLang attribute as well.
---
 clang/lib/CodeGen/CGDebugInfo.cpp |  6 +++---
 llvm/include/llvm/IR/DIBuilder.h  | 10 ++
 llvm/lib/IR/DIBuilder.cpp | 19 +++
 llvm/lib/IR/DebugInfo.cpp | 13 ++---
 4 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 84a166d3ac3659c..fc8088da998ddbd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3385,9 +3385,9 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const 
EnumType *Ty) {
   unsigned Line = getLineNumber(ED->getLocation());
   llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
   llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
-  return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
-Line, Size, Align, EltArray, ClassTy,
-Identifier, ED->isScoped());
+  return DBuilder.createEnumerationType(
+  EnumContext, ED->getName(), DefUnit, Line, Size, Align, EltArray, 
ClassTy,
+  /*RunTimeLang=*/0, Identifier, ED->isScoped());
 }
 
 llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent,
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index ecd6dd7b0a4f822..9c8646c8a544b74 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -424,6 +424,7 @@ namespace llvm {
 /// \param OffsetInBits Member offset.
 /// \param FlagsFlags to encode member attribute, e.g. private
 /// \param Elements class members.
+/// \param RunTimeLang  Optional parameter, Objective-C runtime version.
 /// \param VTableHolder Debug info of the base class that contains vtable
 /// for this type. This is used in
 /// DW_AT_containing_type. See DWARF documentation
@@ -434,8 +435,8 @@ namespace llvm {
 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
-DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
-StringRef UniqueIdentifier = "");
+unsigned RunTimeLang = 0, DIType *VTableHolder = nullptr,
+MDNode *TemplateParms = nullptr, StringRef UniqueIdentifier = "");
 
 /// Create debugging information entry for a struct.
 /// \param ScopeScope in which this struct is defined.
@@ -578,13 +579,14 @@ namespace llvm {
 /// \param AlignInBitsMember alignment.
 /// \param Elements   Enumeration elements.
 /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
+/// \param RunTimeLang  Optional parameter, Objective-C runtime version.
 /// \param UniqueIdentifier A unique identifier for the enum.
 /// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum 
class'.
 DICompositeType *createEnumerationType(
 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
-DIType *UnderlyingType, StringRef UniqueIdentifier = "", bool IsScoped 
= false);
-
+DIType *UnderlyingType, unsigned RunTimeLang = 0,
+StringRef UniqueIdentifier = "", bool IsScoped = false);
 /// Create debugging information entry for a set.
 /// \param Scope  Scope in which this set is defined.
 /// \param Name   Set name.
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 1ce8c17f8a880f6..b466018e9a7d998 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -477,14 +477,15 @@ DICompositeType *DIBuilder::createClassType(
 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
-DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
+unsigned RunTimeLang, DIType *VTableHolder, MDNode *TemplateParams,
+StringRef UniqueIdentifier) {
   assert((!Co

[clang] [llvm] Add RunTimeLang to Class and Enumeration DIBuilder functions (PR #72011)

2023-11-13 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 updated 
https://github.com/llvm/llvm-project/pull/72011

>From 051bd74b2af581fc52896538f0ce571770e57b3e Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Mon, 13 Nov 2023 09:48:00 -0800
Subject: [PATCH] Add RunTimeLang to Class and Enumeration DIBuilder functions

RunTimeLang is already supported by DICompositeType, and
already used by structs and unions. Add a new parameter in
the class and enumeration create methods, so they can use
the RunTimeLang attribute as well.
---
 clang/lib/CodeGen/CGDebugInfo.cpp |  6 +++---
 llvm/include/llvm/IR/DIBuilder.h  | 13 -
 llvm/lib/IR/DIBuilder.cpp | 19 +++
 llvm/lib/IR/DebugInfo.cpp | 13 ++---
 4 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 84a166d3ac3659c..fc8088da998ddbd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3385,9 +3385,9 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const 
EnumType *Ty) {
   unsigned Line = getLineNumber(ED->getLocation());
   llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
   llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
-  return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
-Line, Size, Align, EltArray, ClassTy,
-Identifier, ED->isScoped());
+  return DBuilder.createEnumerationType(
+  EnumContext, ED->getName(), DefUnit, Line, Size, Align, EltArray, 
ClassTy,
+  /*RunTimeLang=*/0, Identifier, ED->isScoped());
 }
 
 llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent,
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index ecd6dd7b0a4f822..884e99300d2ffc4 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -424,6 +424,7 @@ namespace llvm {
 /// \param OffsetInBits Member offset.
 /// \param FlagsFlags to encode member attribute, e.g. private
 /// \param Elements class members.
+/// \param RunTimeLang  Optional parameter, Objective-C runtime version.
 /// \param VTableHolder Debug info of the base class that contains vtable
 /// for this type. This is used in
 /// DW_AT_containing_type. See DWARF documentation
@@ -434,8 +435,8 @@ namespace llvm {
 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
-DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
-StringRef UniqueIdentifier = "");
+unsigned RunTimeLang = 0, DIType *VTableHolder = nullptr,
+MDNode *TemplateParms = nullptr, StringRef UniqueIdentifier = "");
 
 /// Create debugging information entry for a struct.
 /// \param ScopeScope in which this struct is defined.
@@ -578,13 +579,15 @@ namespace llvm {
 /// \param AlignInBitsMember alignment.
 /// \param Elements   Enumeration elements.
 /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
+/// \param RunTimeLang  Optional parameter, Objective-C runtime version.
 /// \param UniqueIdentifier A unique identifier for the enum.
-/// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum 
class'.
+/// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum
+/// class'.
 DICompositeType *createEnumerationType(
 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
-DIType *UnderlyingType, StringRef UniqueIdentifier = "", bool IsScoped 
= false);
-
+DIType *UnderlyingType, unsigned RunTimeLang = 0,
+StringRef UniqueIdentifier = "", bool IsScoped = false);
 /// Create debugging information entry for a set.
 /// \param Scope  Scope in which this set is defined.
 /// \param Name   Set name.
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 1ce8c17f8a880f6..b466018e9a7d998 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -477,14 +477,15 @@ DICompositeType *DIBuilder::createClassType(
 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
-DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
+unsigned RunTimeLang, DIType *VTableHolder, MDNode *TemplateParams,
+StringRef UniqueIdentifier) {
   assert((!Context || isa(Context)) &&
  "createClassType should be called with a valid Context");
 
   auto *R = DICompos

[clang] [llvm] Add RunTimeLang to Class and Enumeration DIBuilder functions (PR #72011)

2023-11-14 Thread Augusto Noronha via cfe-commits

augusto2112 wrote:

ping :) 

https://github.com/llvm/llvm-project/pull/72011
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Add RunTimeLang to Class and Enumeration DIBuilder functions (PR #72011)

2023-11-14 Thread Augusto Noronha via cfe-commits


@@ -424,6 +424,7 @@ namespace llvm {
 /// \param OffsetInBits Member offset.
 /// \param FlagsFlags to encode member attribute, e.g. private
 /// \param Elements class members.
+/// \param RunTimeLang  Optional parameter, Objective-C runtime version.

augusto2112 wrote:

> I think your entire patch would be a lot simpler if this were the last 
> parameter of the function, as you wouldn't need to change as many callsites 
> and have inline comments explaining the parameter. Did you have a motivation 
> in mind for placing the argument here?

I'm following the pattern on the ordering from the existing functions, for 
example:
```
DICompositeType *createStructType(
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");

DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
 DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits,
 DINode::DIFlags Flags,
 DINodeArray Elements,
 unsigned RunTimeLang = 0,
 StringRef UniqueIdentifier = "");
```


https://github.com/llvm/llvm-project/pull/72011
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] Add RunTimeLang to Class and Enumeration DIBuilder functions (PR #72011)

2023-11-14 Thread Augusto Noronha via cfe-commits

augusto2112 wrote:

@felipepiovezan I don't this patch as it is has any changes that are testable. 
I haven't added any code that will emit a RuntimeLang, only added the option to 
do that so I can add those callers downstream. In retrospect I should've marked 
it as NFC.

https://github.com/llvm/llvm-project/pull/72011
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Add RunTimeLang to Class and Enumeration DIBuilder functions (PR #72011)

2023-11-15 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 updated 
https://github.com/llvm/llvm-project/pull/72011

>From 8cebb68070de258e6f581e83c3b0541087f53570 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Mon, 13 Nov 2023 09:48:00 -0800
Subject: [PATCH] [DebugInfo][CGDebugInfo] Add RunTimeLang to more DIBuilder
 functions

RunTimeLang is already supported by DICompositeType, and already used by
structs and unions. Add a new parameter in the class and enumeration
create methods, so they can use the RunTimeLang attribute as well.
---
 clang/lib/CodeGen/CGDebugInfo.cpp |  6 +++---
 llvm/include/llvm/IR/DIBuilder.h  | 13 -
 llvm/lib/IR/DIBuilder.cpp | 19 +++
 llvm/lib/IR/DebugInfo.cpp | 13 ++---
 4 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 84a166d3ac3659c..fc8088da998ddbd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3385,9 +3385,9 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const 
EnumType *Ty) {
   unsigned Line = getLineNumber(ED->getLocation());
   llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
   llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
-  return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
-Line, Size, Align, EltArray, ClassTy,
-Identifier, ED->isScoped());
+  return DBuilder.createEnumerationType(
+  EnumContext, ED->getName(), DefUnit, Line, Size, Align, EltArray, 
ClassTy,
+  /*RunTimeLang=*/0, Identifier, ED->isScoped());
 }
 
 llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent,
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index ecd6dd7b0a4f822..884e99300d2ffc4 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -424,6 +424,7 @@ namespace llvm {
 /// \param OffsetInBits Member offset.
 /// \param FlagsFlags to encode member attribute, e.g. private
 /// \param Elements class members.
+/// \param RunTimeLang  Optional parameter, Objective-C runtime version.
 /// \param VTableHolder Debug info of the base class that contains vtable
 /// for this type. This is used in
 /// DW_AT_containing_type. See DWARF documentation
@@ -434,8 +435,8 @@ namespace llvm {
 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
-DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
-StringRef UniqueIdentifier = "");
+unsigned RunTimeLang = 0, DIType *VTableHolder = nullptr,
+MDNode *TemplateParms = nullptr, StringRef UniqueIdentifier = "");
 
 /// Create debugging information entry for a struct.
 /// \param ScopeScope in which this struct is defined.
@@ -578,13 +579,15 @@ namespace llvm {
 /// \param AlignInBitsMember alignment.
 /// \param Elements   Enumeration elements.
 /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
+/// \param RunTimeLang  Optional parameter, Objective-C runtime version.
 /// \param UniqueIdentifier A unique identifier for the enum.
-/// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum 
class'.
+/// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum
+/// class'.
 DICompositeType *createEnumerationType(
 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
-DIType *UnderlyingType, StringRef UniqueIdentifier = "", bool IsScoped 
= false);
-
+DIType *UnderlyingType, unsigned RunTimeLang = 0,
+StringRef UniqueIdentifier = "", bool IsScoped = false);
 /// Create debugging information entry for a set.
 /// \param Scope  Scope in which this set is defined.
 /// \param Name   Set name.
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 1ce8c17f8a880f6..b466018e9a7d998 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -477,14 +477,15 @@ DICompositeType *DIBuilder::createClassType(
 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
-DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
+unsigned RunTimeLang, DIType *VTableHolder, MDNode *TemplateParams,
+StringRef UniqueIdentifier) {
   assert((!Context || isa(Context)) &&
  "createClassType should be called with a valid Context");
 
   auto *R =

[clang] [llvm] Add RunTimeLang to Class and Enumeration DIBuilder functions (PR #72011)

2023-11-15 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 closed 
https://github.com/llvm/llvm-project/pull/72011
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 87bd71e - Revert "[NFC] Fix the warning Wcovered-switch-default"

2023-12-15 Thread Augusto Noronha via cfe-commits

Author: Augusto Noronha
Date: 2023-12-15T14:43:25-08:00
New Revision: 87bd71efd0af21b6663a7729317952535446f36d

URL: 
https://github.com/llvm/llvm-project/commit/87bd71efd0af21b6663a7729317952535446f36d
DIFF: 
https://github.com/llvm/llvm-project/commit/87bd71efd0af21b6663a7729317952535446f36d.diff

LOG: Revert "[NFC] Fix the warning Wcovered-switch-default"

This reverts commit e55bda06dc2bb1ef11ff4fcc43f90d8bf843f967.

Added: 


Modified: 
clang/include/clang/Serialization/ASTWriter.h

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index de69f99003d827..16ab9583f8ed8e 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -763,8 +763,9 @@ class ASTWriter : public ASTDeserializationListener,
   return DeclDependentNonTemplateCXXMethodAbbrev;
 case FunctionDecl::TK_DependentFunctionTemplateSpecialization:
   return DeclDependentSpecializationCXXMethodAbbrev;
+default:
+  llvm_unreachable("Unknwon Template Kind!");
 }
-llvm_unreachable("Unknwon Template Kind!");
   }
   unsigned getDeclTemplateTypeParmAbbrev() const {
 return DeclTemplateTypeParmAbbrev;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] eccc1cc - Revert "[NFC] [Serialization] Packing more bits and refactor AbbrevToUse"

2023-12-15 Thread Augusto Noronha via cfe-commits

Author: Augusto Noronha
Date: 2023-12-15T14:43:25-08:00
New Revision: eccc1cca71bb704e4dcaabccc993d08fd15b46a2

URL: 
https://github.com/llvm/llvm-project/commit/eccc1cca71bb704e4dcaabccc993d08fd15b46a2
DIFF: 
https://github.com/llvm/llvm-project/commit/eccc1cca71bb704e4dcaabccc993d08fd15b46a2.diff

LOG: Revert "[NFC] [Serialization] Packing more bits and refactor AbbrevToUse"

This reverts commit 9cdb825a4f1bf9e75829d03879620c6144d0b7bc.

Added: 


Modified: 
clang/include/clang/Serialization/ASTReader.h
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index a6dd779386dc16..9bb89ec9410911 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -2422,8 +2422,6 @@ class BitsUnpacker {
 CurrentBitsIndex = 0;
   }
 
-  void advance(uint32_t BitsWidth) { CurrentBitsIndex += BitsWidth; }
-
   bool getNextBit() {
 assert(isValid());
 return Value & (1 << CurrentBitsIndex++);

diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 16ab9583f8ed8e..a56929ef0245ee 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -564,25 +564,11 @@ class ASTWriter : public ASTDeserializationListener,
   unsigned DeclEnumAbbrev = 0;
   unsigned DeclObjCIvarAbbrev = 0;
   unsigned DeclCXXMethodAbbrev = 0;
-  unsigned DeclDependentNonTemplateCXXMethodAbbrev = 0;
-  unsigned DeclTemplateCXXMethodAbbrev = 0;
-  unsigned DeclMemberSpecializedCXXMethodAbbrev = 0;
-  unsigned DeclTemplateSpecializedCXXMethodAbbrev = 0;
-  unsigned DeclDependentSpecializationCXXMethodAbbrev = 0;
-  unsigned DeclTemplateTypeParmAbbrev = 0;
-  unsigned DeclUsingShadowAbbrev = 0;
 
   unsigned DeclRefExprAbbrev = 0;
   unsigned CharacterLiteralAbbrev = 0;
   unsigned IntegerLiteralAbbrev = 0;
   unsigned ExprImplicitCastAbbrev = 0;
-  unsigned BinaryOperatorAbbrev = 0;
-  unsigned CompoundAssignOperatorAbbrev = 0;
-  unsigned CallExprAbbrev = 0;
-  unsigned CXXOperatorCallExprAbbrev = 0;
-  unsigned CXXMemberCallExprAbbrev = 0;
-
-  unsigned CompoundStmtAbbrev = 0;
 
   void WriteDeclAbbrevs();
   void WriteDecl(ASTContext &Context, Decl *D);
@@ -749,42 +735,12 @@ class ASTWriter : public ASTDeserializationListener,
   unsigned getDeclFieldAbbrev() const { return DeclFieldAbbrev; }
   unsigned getDeclEnumAbbrev() const { return DeclEnumAbbrev; }
   unsigned getDeclObjCIvarAbbrev() const { return DeclObjCIvarAbbrev; }
-  unsigned getDeclCXXMethodAbbrev(FunctionDecl::TemplatedKind Kind) const {
-switch (Kind) {
-case FunctionDecl::TK_NonTemplate:
-  return DeclCXXMethodAbbrev;
-case FunctionDecl::TK_FunctionTemplate:
-  return DeclTemplateCXXMethodAbbrev;
-case FunctionDecl::TK_MemberSpecialization:
-  return DeclMemberSpecializedCXXMethodAbbrev;
-case FunctionDecl::TK_FunctionTemplateSpecialization:
-  return DeclTemplateSpecializedCXXMethodAbbrev;
-case FunctionDecl::TK_DependentNonTemplate:
-  return DeclDependentNonTemplateCXXMethodAbbrev;
-case FunctionDecl::TK_DependentFunctionTemplateSpecialization:
-  return DeclDependentSpecializationCXXMethodAbbrev;
-default:
-  llvm_unreachable("Unknwon Template Kind!");
-}
-  }
-  unsigned getDeclTemplateTypeParmAbbrev() const {
-return DeclTemplateTypeParmAbbrev;
-  }
-  unsigned getDeclUsingShadowAbbrev() const { return DeclUsingShadowAbbrev; }
+  unsigned getDeclCXXMethodAbbrev() const { return DeclCXXMethodAbbrev; }
 
   unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; }
   unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; }
   unsigned getIntegerLiteralAbbrev() const { return IntegerLiteralAbbrev; }
   unsigned getExprImplicitCastAbbrev() const { return ExprImplicitCastAbbrev; }
-  unsigned getBinaryOperatorAbbrev() const { return BinaryOperatorAbbrev; }
-  unsigned getCompoundAssignOperatorAbbrev() const {
-return CompoundAssignOperatorAbbrev;
-  }
-  unsigned getCallExprAbbrev() const { return CallExprAbbrev; }
-  unsigned getCXXOperatorCallExprAbbrev() { return CXXOperatorCallExprAbbrev; }
-  unsigned getCXXMemberCallExprAbbrev() { return CXXMemberCallExprAbbrev; }
-
-  unsigned getCompoundStmtAbbrev() const { return CompoundStmtAbbrev; }
 
   bool hasChain() const { return Chain; }
   ASTReader *getChain() const { return Chain; }
@@ -885,33 +841,46 @@ class BitsPacker {
   BitsPacker(BitsPacker &&) = delete;
   BitsPacker operator=(const BitsPacker &) = delete;
   BitsPa

[clang] Fix #pragma (packed, n) not emitting the alignment in debug info (PR #94673)

2024-06-06 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/94673

Debug info generation won't emit the alignment of types that have a standard 
alignment. It was not taking into account the that case.

rdar://127785973

>From 8fd0e9dcfd915367db1b66001daab47415406302 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Thu, 6 Jun 2024 12:29:05 -0700
Subject: [PATCH] Fix #pragma (packed, n) not emitting the alignment in debug
 info

Debug info generation won't emit the alignment of types that have a
standard alignment. It was not taking into account the
that case.

rdar://127785973
---
 clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++-
 clang/test/CodeGen/debug-info-packed-struct.c |  4 ++--
 clang/test/CodeGenCXX/debug-info-struct-align.cpp |  8 
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5f6f911c7a6d6..591e42b1969b4 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -58,7 +58,16 @@ using namespace clang::CodeGen;
 
 static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext &Ctx) {
   auto TI = Ctx.getTypeInfo(Ty);
-  return TI.isAlignRequired() ? TI.Align : 0;
+  if (TI.isAlignRequired())
+return TI.Align;
+
+  // MaxFieldAlignmentAttr is the attribute added to types 
+  // declared after #pragma pack(n).
+  if (auto *Decl = Ty->getAsRecordDecl())
+if (Decl->hasAttr())
+  return TI.Align;
+
+  return 0;
 }
 
 static uint32_t getTypeAlignIfRequired(QualType Ty, const ASTContext &Ctx) {
diff --git a/clang/test/CodeGen/debug-info-packed-struct.c 
b/clang/test/CodeGen/debug-info-packed-struct.c
index 6441a740e3799..676cdb38b396f 100644
--- a/clang/test/CodeGen/debug-info-packed-struct.c
+++ b/clang/test/CodeGen/debug-info-packed-struct.c
@@ -59,7 +59,7 @@ struct layout2 {
 #pragma pack()
 // CHECK: l2_ofs0
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs1",
-// CHECK-SAME: {{.*}}size: 64, offset: 8)
+// CHECK-SAME: {{.*}}size: 64, align: 8, offset: 8)
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs9",
 // CHECK-SAME: {{.*}}size: 1, offset: 72, flags: DIFlagBitField, 
extraData: i64 72)
 
@@ -81,7 +81,7 @@ struct layout3 {
 #pragma pack()
 // CHECK: l3_ofs0
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs4",
-// CHECK-SAME: {{.*}}size: 64, offset: 32)
+// CHECK-SAME: {{.*}}size: 64, align: 32, offset: 32)
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs12",
 // CHECK-SAME: {{.*}}size: 1, offset: 96, flags: DIFlagBitField, 
extraData: i64 96)
 
diff --git a/clang/test/CodeGenCXX/debug-info-struct-align.cpp 
b/clang/test/CodeGenCXX/debug-info-struct-align.cpp
index 1269cbce83ef0..cd91f4c302ddc 100644
--- a/clang/test/CodeGenCXX/debug-info-struct-align.cpp
+++ b/clang/test/CodeGenCXX/debug-info-struct-align.cpp
@@ -25,3 +25,11 @@ struct MyType2 {
 MyType2 mt2;
 
 static_assert(alignof(MyType2) == 1, "alignof MyType2 is wrong");
+
+#pragma pack(1)
+struct MyType3 {
+  int m;
+};
+MyType3 mt3;
+
+static_assert(alignof(MyType3) == 1, "alignof MyType3 is wrong");

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix #pragma (packed, n) not emitting the alignment in debug info (PR #94673)

2024-06-06 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 updated 
https://github.com/llvm/llvm-project/pull/94673

>From 3bf273f06fc82a5ca699d64b57dbc734f05fd896 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Thu, 6 Jun 2024 12:29:05 -0700
Subject: [PATCH] Fix #pragma (packed, n) not emitting the alignment in debug
 info

Debug info generation won't emit the alignment of types that have a
standard alignment. It was not taking into account the
that case.

rdar://127785973
---
 clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++-
 clang/test/CodeGen/debug-info-packed-struct.c |  4 ++--
 clang/test/CodeGenCXX/debug-info-struct-align.cpp |  8 
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5f6f911c7a6d6..681a475f9e4be 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -58,7 +58,16 @@ using namespace clang::CodeGen;
 
 static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext &Ctx) {
   auto TI = Ctx.getTypeInfo(Ty);
-  return TI.isAlignRequired() ? TI.Align : 0;
+  if (TI.isAlignRequired())
+return TI.Align;
+
+  // MaxFieldAlignmentAttr is the attribute added to types
+  // declared after #pragma pack(n).
+  if (auto *Decl = Ty->getAsRecordDecl())
+if (Decl->hasAttr())
+  return TI.Align;
+
+  return 0;
 }
 
 static uint32_t getTypeAlignIfRequired(QualType Ty, const ASTContext &Ctx) {
diff --git a/clang/test/CodeGen/debug-info-packed-struct.c 
b/clang/test/CodeGen/debug-info-packed-struct.c
index 6441a740e3799..676cdb38b396f 100644
--- a/clang/test/CodeGen/debug-info-packed-struct.c
+++ b/clang/test/CodeGen/debug-info-packed-struct.c
@@ -59,7 +59,7 @@ struct layout2 {
 #pragma pack()
 // CHECK: l2_ofs0
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs1",
-// CHECK-SAME: {{.*}}size: 64, offset: 8)
+// CHECK-SAME: {{.*}}size: 64, align: 8, offset: 8)
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs9",
 // CHECK-SAME: {{.*}}size: 1, offset: 72, flags: DIFlagBitField, 
extraData: i64 72)
 
@@ -81,7 +81,7 @@ struct layout3 {
 #pragma pack()
 // CHECK: l3_ofs0
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs4",
-// CHECK-SAME: {{.*}}size: 64, offset: 32)
+// CHECK-SAME: {{.*}}size: 64, align: 32, offset: 32)
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs12",
 // CHECK-SAME: {{.*}}size: 1, offset: 96, flags: DIFlagBitField, 
extraData: i64 96)
 
diff --git a/clang/test/CodeGenCXX/debug-info-struct-align.cpp 
b/clang/test/CodeGenCXX/debug-info-struct-align.cpp
index 1269cbce83ef0..cd91f4c302ddc 100644
--- a/clang/test/CodeGenCXX/debug-info-struct-align.cpp
+++ b/clang/test/CodeGenCXX/debug-info-struct-align.cpp
@@ -25,3 +25,11 @@ struct MyType2 {
 MyType2 mt2;
 
 static_assert(alignof(MyType2) == 1, "alignof MyType2 is wrong");
+
+#pragma pack(1)
+struct MyType3 {
+  int m;
+};
+MyType3 mt3;
+
+static_assert(alignof(MyType3) == 1, "alignof MyType3 is wrong");

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix #pragma (packed, n) not emitting the alignment in debug info (PR #94673)

2024-06-07 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 closed 
https://github.com/llvm/llvm-project/pull/94673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-25 Thread Augusto Noronha via cfe-commits


@@ -109,6 +110,21 @@ static bool IsArtificial(VarDecl const *VD) {
   cast(VD->getDeclContext())->isImplicit());
 }
 
+static bool usesDebugTransparent(const Decl *D, const CodeGenModule &CGM) {
+  if (!D)
+return false;
+
+  if (auto *attr = D->getAttr()) {

augusto2112 wrote:

I need the `attr` variable to access its location when reporting that it's 
missing.

https://github.com/llvm/llvm-project/pull/109490
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-25 Thread Augusto Noronha via cfe-commits


@@ -4160,6 +4178,8 @@ llvm::DISubprogram 
*CGDebugInfo::getFunctionFwdDeclOrStub(GlobalDecl GD,
   if (Stub) {
 Flags |= getCallSiteRelatedAttrs();
 SPFlags |= llvm::DISubprogram::SPFlagDefinition;
+if (usesDebugTransparent(FD, CGM))

augusto2112 wrote:

Turns out adding this flag only in `emitFunction` is enough to cover all cases.

https://github.com/llvm/llvm-project/pull/109490
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-25 Thread Augusto Noronha via cfe-commits


@@ -109,6 +110,21 @@ static bool IsArtificial(VarDecl const *VD) {
   cast(VD->getDeclContext())->isImplicit());
 }
 
+static bool usesDebugTransparent(const Decl *D, const CodeGenModule &CGM) {
+  if (!D)
+return false;
+
+  if (auto *attr = D->getAttr()) {
+auto opts = CGM.getCodeGenOpts();
+if (opts.DwarfVersion == 0) {

augusto2112 wrote:

It's not emitted (I'm adding a test to assert that)

https://github.com/llvm/llvm-project/pull/109490
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #110188)

2024-09-26 Thread Augusto Noronha via cfe-commits

augusto2112 wrote:

I opened this PR since I messed up 
https://github.com/llvm/llvm-project/pull/109490

https://github.com/llvm/llvm-project/pull/110188
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #110188)

2024-09-26 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/110188

The `debug_transparent` attribute is intended as a hint for debuggers that this 
function itself is not interesting, but it calls a function that might be.  So, 
when stepping in arrives at a function with this attribute, debuggers should 
transparently step-in through it into the functions called by the annotated 
function (but not by subsequent calls made by those functions), stopping at the 
first one its normal rules for whether to stop says to stop at - or stepping 
out again if none qualify. Also, when stepping out arrives at a function with 
this attribute, the debugger should continue stepping out to its caller.

>From 09940c37f0b9075b4a2c06e39932f1f772a2a13f Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Thu, 30 Mar 2023 14:01:36 -0700
Subject: [PATCH] [clang] Add "debug_transparent" attribute

The `debug_transparent` attribute is intended as a hint for
debuggers that this function itself is not interesting, but it calls a
function that might be.  So, when stepping in arrives at a function
with this attribute, debuggers should transparently step-in through it
into the functions called by the annotated function (but not by
subsequent calls made by those functions), stopping at the first one its
normal rules for whether to stop says to stop at - or stepping out again
if none qualify. Also, when stepping out arrives at a function with this
attribute, the debugger should continue stepping out to its caller.
---
 clang/docs/ReleaseNotes.rst   |  4 ++
 clang/include/clang/Basic/Attr.td |  7 +++
 clang/include/clang/Basic/AttrDocs.td | 60 +++
 .../clang/Basic/DiagnosticCommonKinds.td  |  2 +
 clang/lib/CodeGen/CGDebugInfo.cpp | 18 ++
 .../attr-debug-transparent-method-warning.cpp | 14 +
 .../CodeGen/attr-debug-transparent-method.cpp | 16 +
 .../attr-debug-transparent-no-warning.c   | 10 
 .../attr-debug-transparent-objc-warning.m | 12 
 .../CodeGen/attr-debug-transparent-objc.m | 13 
 .../CodeGen/attr-debug-transparent-warning.c  |  9 +++
 clang/test/CodeGen/attr-debug-transparent.c   | 10 
 ...a-attribute-supported-attributes-list.test |  1 +
 clang/test/Sema/attr-debug-transparent.c  |  7 +++
 .../SemaCXX/attr-debug-transparent-method.cpp | 11 
 .../SemaObjC/attr-debug-transparent-objc.m|  9 +++
 llvm/include/llvm/IR/DebugInfoFlags.def   |  3 +-
 llvm/include/llvm/IR/DebugInfoMetadata.h  |  3 +
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |  5 ++
 .../disubprogram-debug-transparent.ll | 39 
 .../AArch64/disubprogram-debug-transparent.ll | 42 +
 llvm/unittests/IR/MetadataTest.cpp|  7 +++
 22 files changed, 301 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-method-warning.cpp
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-method.cpp
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-no-warning.c
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-objc-warning.m
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-objc.m
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-warning.c
 create mode 100644 clang/test/CodeGen/attr-debug-transparent.c
 create mode 100644 clang/test/Sema/attr-debug-transparent.c
 create mode 100644 clang/test/SemaCXX/attr-debug-transparent-method.cpp
 create mode 100644 clang/test/SemaObjC/attr-debug-transparent-objc.m
 create mode 100644 llvm/test/Assembler/disubprogram-debug-transparent.ll
 create mode 100644 
llvm/test/DebugInfo/AArch64/disubprogram-debug-transparent.ll

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 14907e7db18de3..37f8e646140482 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -275,6 +275,10 @@ Attribute Changes in Clang
 
 - Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
   ``[[gsl::Pointer]]`` to STL explicit template specialization decls. 
(#GH109442)
+- Introduced a new function attribute ``__attribute__((debug_transparent))``
+  which is intended as a hint to debuggers that they should not stop at the 
annotated
+  function, but instead step through it when stepping in, and continuing 
directly to 
+  its caller when stepping out.
 
 Improvements to Clang's diagnostics
 ---
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index fbcbf0ed416416..3b6c8cb409e8a0 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -876,6 +876,13 @@ def Artificial : InheritableAttr {
   let SimpleHandler = 1;
 }
 
+def DebugTransparent: InheritableAttr {
+  let Spellings = [Clang<"debug_transparent">];
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
+  let Documentation = [DebugTransparentDocs];
+  let SimpleHandler

[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-26 Thread Augusto Noronha via cfe-commits

augusto2112 wrote:

I accidentally rebased on top of the wrong branch which tagged a lot of people 
as reviewers, I'm going to close this PR and open a new one as to not spam a 
ton of people.

https://github.com/llvm/llvm-project/pull/109490
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-26 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 updated 
https://github.com/llvm/llvm-project/pull/109490

>From b7271f2f4a638a5c03cb28b05bb836ca245acb41 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Thu, 30 Mar 2023 14:01:36 -0700
Subject: [PATCH] [clang] Add "debug_transparent" attribute

The `debug_transparent` attribute is intended as a hint for
debuggers that this function itself is not interesting, but it calls a
function that might be.  So, when stepping in arrives at a function
with this attribute, debuggers should transparently step-in through it
into the functions called by the annotated function (but not by
subsequent calls made by those functions), stopping at the first one its
normal rules for whether to stop says to stop at - or stepping out again
if none qualify. Also, when stepping out arrives at a function with this
attribute, the debugger should continue stepping out to its caller.
---
 clang/docs/ReleaseNotes.rst  |  4 
 .../include/clang/Basic/DiagnosticCommonKinds.td |  2 ++
 .../attr-debug-transparent-method-warning.cpp| 14 ++
 .../CodeGen/attr-debug-transparent-method.cpp| 16 
 .../CodeGen/attr-debug-transparent-no-warning.c  | 10 ++
 .../attr-debug-transparent-objc-warning.m| 12 
 clang/test/CodeGen/attr-debug-transparent-objc.m | 13 +
 .../CodeGen/attr-debug-transparent-warning.c |  9 +
 clang/test/CodeGen/attr-debug-transparent.c  | 10 ++
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp|  5 +
 10 files changed, 95 insertions(+)
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-method-warning.cpp
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-method.cpp
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-no-warning.c
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-objc-warning.m
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-objc.m
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-warning.c
 create mode 100644 clang/test/CodeGen/attr-debug-transparent.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1fbcac807d0b30..52c6fd27415688 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -293,6 +293,10 @@ Attribute Changes in Clang
 
 - Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
   ``[[gsl::Pointer]]`` to STL explicit template specialization decls. 
(#GH109442)
+- Introduced a new function attribute ``__attribute__((debug_transparent))``
+  which is intended as a hint to debuggers that they should not stop at the 
annotated
+  function, but instead step through it when stepping in, and continuing 
directly to 
+  its caller when stepping out.
 
 Improvements to Clang's diagnostics
 ---
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index ae709e45a700a1..e9cb8a9aaadfe2 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -467,4 +467,6 @@ def warn_try_not_valid_on_target : Warning<
   "target '%0' does not support exception handling;"
   " 'catch' block is ignored">,
   InGroup;
+def warn_debug_transparent_ignored : Warning<
+  "'debug_transparent' attribute is ignored since it is only supported by 
DWARF">;
 }
diff --git a/clang/test/CodeGen/attr-debug-transparent-method-warning.cpp 
b/clang/test/CodeGen/attr-debug-transparent-method-warning.cpp
new file mode 100644
index 00..71b8617d46bd2c
--- /dev/null
+++ b/clang/test/CodeGen/attr-debug-transparent-method-warning.cpp
@@ -0,0 +1,14 @@
+// Pipe stderr to FileCheck since we're checking for a warning
+// RUN: %clang -gcodeview -g -emit-llvm -S %s -o - 2>&1 | FileCheck %s
+
+
+struct S {
+[[clang::debug_transparent]] 
+void foo(void) {}
+};
+
+int main() {
+  S s;
+  s.foo();
+}
+// CHECK: warning: 'debug_transparent' attribute is ignored since it is only 
supported by DWARF
diff --git a/clang/test/CodeGen/attr-debug-transparent-method.cpp 
b/clang/test/CodeGen/attr-debug-transparent-method.cpp
new file mode 100644
index 00..300e46535576de
--- /dev/null
+++ b/clang/test/CodeGen/attr-debug-transparent-method.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang -gdwarf -emit-llvm -S %s -o - | FileCheck %s
+
+void bar(void) {}
+
+struct A {
+[[clang::debug_transparent()]]
+void foo(void) {
+  bar();
+}
+};
+
+int main() {
+  A().foo();
+}
+
+// CHECK: DISubprogram(name: "foo"{{.*}} DISPFlagIsDebugTransparent
diff --git a/clang/test/CodeGen/attr-debug-transparent-no-warning.c 
b/clang/test/CodeGen/attr-debug-transparent-no-warning.c
new file mode 100644
index 00..d49f1ce0bb4a82
--- /dev/null
+++ b/clang/test/CodeGen/attr-debug-transparent-no-warning.c
@@ -0,0 +1,10 @@
+// Pipe stderr to FileCheck since we're checking for a warning
+// RUN: %clang -gcodeview -emit-llvm -S

[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-26 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 closed 
https://github.com/llvm/llvm-project/pull/109490
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-20 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/109490

The `debug_transparent` attribute is intended as a hint for debuggers that this 
function itself is not interesting, but it calls a function that might be.  So, 
when stepping in arrives at a function with this attribute, debuggers should 
transparently step-in through it into the functions called by the annotated 
function (but not by subsequent calls made by those functions), stopping at the 
first one its normal rules for whether to stop says to stop at - or stepping 
out again if none qualify. Also, when stepping out arrives at a function with 
this attribute, the debugger should continue stepping out to its caller.

>From 413c07e92dce422a9a69fe6c872229843d3e99f5 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Thu, 30 Mar 2023 14:01:36 -0700
Subject: [PATCH] [clang] Add "debug_transparent" attribute

The `debug_transparent` attribute is intended as a hint for
debuggers that this function itself is not interesting, but it calls a
function that might be.  So, when stepping in arrives at a function
with this attribute, debuggers should transparently step-in through it
into the functions called by the annotated function (but not by
subsequent calls made by those functions), stopping at the first one its
normal rules for whether to stop says to stop at - or stepping out again
if none qualify. Also, when stepping out arrives at a function with this
attribute, the debugger should continue stepping out to its caller.
---
 clang/docs/ReleaseNotes.rst   |  5 ++
 clang/include/clang/Basic/Attr.td |  7 +++
 clang/include/clang/Basic/AttrDocs.td | 60 +++
 .../clang/Basic/DiagnosticCommonKinds.td  |  3 +
 clang/lib/CodeGen/CGDebugInfo.cpp | 27 +
 .../CodeGen/attr-debug-transparent-method.cpp | 16 +
 .../CodeGen/attr-debug-transparent-objc.m | 13 
 clang/test/CodeGen/attr-debug-transparent.c   | 10 
 ...a-attribute-supported-attributes-list.test |  1 +
 clang/test/Sema/attr-debug-transparent.c  |  7 +++
 .../SemaCXX/attr-debug-transparent-method.cpp | 11 
 .../SemaObjC/attr-debug-transparent-objc.m|  9 +++
 llvm/include/llvm/IR/DebugInfoFlags.def   |  3 +-
 llvm/include/llvm/IR/DebugInfoMetadata.h  |  3 +
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |  3 +
 .../disubprogram-debug-transparent.ll | 39 
 .../AArch64/disubprogram-debug-transparent.ll | 42 +
 llvm/unittests/IR/MetadataTest.cpp|  7 +++
 18 files changed, 265 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-method.cpp
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-objc.m
 create mode 100644 clang/test/CodeGen/attr-debug-transparent.c
 create mode 100644 clang/test/Sema/attr-debug-transparent.c
 create mode 100644 clang/test/SemaCXX/attr-debug-transparent-method.cpp
 create mode 100644 clang/test/SemaObjC/attr-debug-transparent-objc.m
 create mode 100644 llvm/test/Assembler/disubprogram-debug-transparent.ll
 create mode 100644 
llvm/test/DebugInfo/AArch64/disubprogram-debug-transparent.ll

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f4535db7356194..8a154a6563fe71 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -260,6 +260,11 @@ Attribute Changes in Clang
 - Introduced a new attribute ``[[clang::coro_await_elidable_argument]]`` on 
function parameters
   to propagate safe elide context to arguments if such function is also under 
a safe elide context.
 
+- Introduced a new function attribute ``__attribute__((debug_transparent))``
+  which is intended as a hint to debuggers that they should not stop at the 
annotated
+  function, but instead step through it when stepping in, and continuing 
directly to 
+  its caller when stepping out.
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ce86116680d7a3..d0b885afa55afe 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -876,6 +876,13 @@ def Artificial : InheritableAttr {
   let SimpleHandler = 1;
 }
 
+def DebugTransparent: InheritableAttr {
+  let Spellings = [Clang<"debug_transparent">];
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
+  let Documentation = [DebugTransparentDocs];
+  let SimpleHandler = 1;
+}
+
 def XRayInstrument : InheritableAttr {
   let Spellings = [Clang<"xray_always_instrument">,
Clang<"xray_never_instrument">];
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 8ef151b3f2fddb..2074f16d83643b 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7846,6 +7846,66 @@ As such, this function attribute is currently only 
supported on X86 targets.
   }];
 }

[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #109490)

2024-09-20 Thread Augusto Noronha via cfe-commits

augusto2112 wrote:

@dwblaikie @AaronBallman this is the "debug_transparent" patch that I opened 
last year but didn't get around to finish implementing 
(https://reviews.llvm.org/D146595).

The current version addresses the comments left in the phabricator review:
- Changed the name from debug_trampoline to debug_transparent
- Emits a warning if the attribute is used when emitting debug info that is not 
DWARF.

https://github.com/llvm/llvm-project/pull/109490
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #110188)

2024-10-01 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 updated 
https://github.com/llvm/llvm-project/pull/110188

>From a28f8e716a7efe356e0088c00257edfc15132cb7 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Thu, 30 Mar 2023 14:01:36 -0700
Subject: [PATCH] [clang] Add "debug_transparent" attribute

The `debug_transparent` attribute is intended as a hint for
debuggers that this function itself is not interesting, but it calls a
function that might be.  So, when stepping in arrives at a function
with this attribute, debuggers should transparently step-in through it
into the functions called by the annotated function (but not by
subsequent calls made by those functions), stopping at the first one its
normal rules for whether to stop says to stop at - or stepping out again
if none qualify. Also, when stepping out arrives at a function with this
attribute, the debugger should continue stepping out to its caller.
---
 clang/docs/ReleaseNotes.rst   |  4 ++
 clang/include/clang/Basic/Attr.td |  7 +++
 clang/include/clang/Basic/AttrDocs.td | 60 +++
 .../clang/Basic/DiagnosticCommonKinds.td  |  2 +
 clang/lib/CodeGen/CGDebugInfo.cpp | 16 +
 .../CodeGen/attr-debug-transparent-cxx.cpp| 37 
 .../attr-debug-transparent-method-warning.cpp | 14 +
 .../attr-debug-transparent-no-warning.c   | 10 
 .../attr-debug-transparent-objc-warning.m | 12 
 .../CodeGen/attr-debug-transparent-objc.m | 13 
 .../CodeGen/attr-debug-transparent-warning.c  |  9 +++
 clang/test/CodeGen/attr-debug-transparent.c   | 10 
 ...a-attribute-supported-attributes-list.test |  1 +
 clang/test/Sema/attr-debug-transparent.c  |  7 +++
 .../SemaCXX/attr-debug-transparent-method.cpp | 11 
 .../SemaObjC/attr-debug-transparent-objc.m|  9 +++
 llvm/include/llvm/IR/DebugInfoFlags.def   |  3 +-
 llvm/include/llvm/IR/DebugInfoMetadata.h  |  3 +
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |  5 ++
 .../disubprogram-debug-transparent.ll | 39 
 .../AArch64/disubprogram-debug-transparent.ll | 42 +
 llvm/unittests/IR/MetadataTest.cpp|  7 +++
 22 files changed, 320 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-cxx.cpp
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-method-warning.cpp
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-no-warning.c
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-objc-warning.m
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-objc.m
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-warning.c
 create mode 100644 clang/test/CodeGen/attr-debug-transparent.c
 create mode 100644 clang/test/Sema/attr-debug-transparent.c
 create mode 100644 clang/test/SemaCXX/attr-debug-transparent-method.cpp
 create mode 100644 clang/test/SemaObjC/attr-debug-transparent-objc.m
 create mode 100644 llvm/test/Assembler/disubprogram-debug-transparent.ll
 create mode 100644 
llvm/test/DebugInfo/AArch64/disubprogram-debug-transparent.ll

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 34d2b584274a5f..63a65bec74b1aa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -299,6 +299,10 @@ Attribute Changes in Clang
 
 - Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
   ``[[gsl::Pointer]]`` to STL explicit template specialization decls. 
(#GH109442)
+- Introduced a new function attribute ``__attribute__((debug_transparent))``
+  which is intended as a hint to debuggers that they should not stop at the 
annotated
+  function, but instead step through it when stepping in, and continuing 
directly to 
+  its caller when stepping out.
 
 Improvements to Clang's diagnostics
 ---
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index fbcbf0ed416416..3b6c8cb409e8a0 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -876,6 +876,13 @@ def Artificial : InheritableAttr {
   let SimpleHandler = 1;
 }
 
+def DebugTransparent: InheritableAttr {
+  let Spellings = [Clang<"debug_transparent">];
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
+  let Documentation = [DebugTransparentDocs];
+  let SimpleHandler = 1;
+}
+
 def XRayInstrument : InheritableAttr {
   let Spellings = [Clang<"xray_always_instrument">,
Clang<"xray_never_instrument">];
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 53d88482698f00..81a062a5d72a56 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7866,6 +7866,66 @@ As such, this function attribute is currently only 
supported on X86 targets.
   }];
 }
 
+def DebugTransparentDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``debug_transparent`` attribu

[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #110188)

2024-10-01 Thread Augusto Noronha via cfe-commits

https://github.com/augusto2112 updated 
https://github.com/llvm/llvm-project/pull/110188

>From 807fc9a690555930ef0c047f0c4253c6204376a9 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Thu, 30 Mar 2023 14:01:36 -0700
Subject: [PATCH] [clang] Add "debug_transparent" attribute

The `debug_transparent` attribute is intended as a hint for
debuggers that this function itself is not interesting, but it calls a
function that might be.  So, when stepping in arrives at a function
with this attribute, debuggers should transparently step-in through it
into the functions called by the annotated function (but not by
subsequent calls made by those functions), stopping at the first one its
normal rules for whether to stop says to stop at - or stepping out again
if none qualify. Also, when stepping out arrives at a function with this
attribute, the debugger should continue stepping out to its caller.
---
 clang/docs/ReleaseNotes.rst   |  4 ++
 clang/include/clang/Basic/Attr.td |  7 +++
 clang/include/clang/Basic/AttrDocs.td | 60 +++
 .../clang/Basic/DiagnosticCommonKinds.td  |  2 +
 clang/lib/CodeGen/CGDebugInfo.cpp | 17 ++
 .../CodeGen/attr-debug-transparent-cxx.cpp| 37 
 .../attr-debug-transparent-method-warning.cpp | 14 +
 .../attr-debug-transparent-no-warning.c   | 10 
 .../attr-debug-transparent-objc-warning.m | 12 
 .../CodeGen/attr-debug-transparent-objc.m | 13 
 .../CodeGen/attr-debug-transparent-warning.c  |  9 +++
 clang/test/CodeGen/attr-debug-transparent.c   | 10 
 ...a-attribute-supported-attributes-list.test |  1 +
 clang/test/Sema/attr-debug-transparent.c  |  7 +++
 .../SemaCXX/attr-debug-transparent-method.cpp | 11 
 .../SemaObjC/attr-debug-transparent-objc.m|  9 +++
 llvm/include/llvm/IR/DebugInfoFlags.def   |  3 +-
 llvm/include/llvm/IR/DebugInfoMetadata.h  |  3 +
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |  5 ++
 .../disubprogram-debug-transparent.ll | 39 
 .../AArch64/disubprogram-debug-transparent.ll | 42 +
 llvm/unittests/IR/MetadataTest.cpp|  7 +++
 22 files changed, 321 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-cxx.cpp
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-method-warning.cpp
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-no-warning.c
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-objc-warning.m
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-objc.m
 create mode 100644 clang/test/CodeGen/attr-debug-transparent-warning.c
 create mode 100644 clang/test/CodeGen/attr-debug-transparent.c
 create mode 100644 clang/test/Sema/attr-debug-transparent.c
 create mode 100644 clang/test/SemaCXX/attr-debug-transparent-method.cpp
 create mode 100644 clang/test/SemaObjC/attr-debug-transparent-objc.m
 create mode 100644 llvm/test/Assembler/disubprogram-debug-transparent.ll
 create mode 100644 
llvm/test/DebugInfo/AArch64/disubprogram-debug-transparent.ll

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 34d2b584274a5f..63a65bec74b1aa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -299,6 +299,10 @@ Attribute Changes in Clang
 
 - Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
   ``[[gsl::Pointer]]`` to STL explicit template specialization decls. 
(#GH109442)
+- Introduced a new function attribute ``__attribute__((debug_transparent))``
+  which is intended as a hint to debuggers that they should not stop at the 
annotated
+  function, but instead step through it when stepping in, and continuing 
directly to 
+  its caller when stepping out.
 
 Improvements to Clang's diagnostics
 ---
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index fbcbf0ed416416..3b6c8cb409e8a0 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -876,6 +876,13 @@ def Artificial : InheritableAttr {
   let SimpleHandler = 1;
 }
 
+def DebugTransparent: InheritableAttr {
+  let Spellings = [Clang<"debug_transparent">];
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
+  let Documentation = [DebugTransparentDocs];
+  let SimpleHandler = 1;
+}
+
 def XRayInstrument : InheritableAttr {
   let Spellings = [Clang<"xray_always_instrument">,
Clang<"xray_never_instrument">];
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 53d88482698f00..81a062a5d72a56 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7866,6 +7866,66 @@ As such, this function attribute is currently only 
supported on X86 targets.
   }];
 }
 
+def DebugTransparentDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``debug_transparent`` attrib

[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #110188)

2024-10-02 Thread Augusto Noronha via cfe-commits

augusto2112 wrote:

> As a new feature, this needs a proposal on Discourse.

@efriedma-quic as an RFC under clang? I wasn't aware this was a rule, is this a 
recent change?

https://github.com/llvm/llvm-project/pull/110188
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Add "debug_transparent" attribute (PR #110188)

2024-10-02 Thread Augusto Noronha via cfe-commits

augusto2112 wrote:

And would that be an RFC under "clang"? Or is there a different section on 
Discourse for feature proposals?

https://github.com/llvm/llvm-project/pull/110188
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits