Skip to content

Conversation

andykaylor
Copy link
Contributor

This fixes a build failure that occurs with some versions of clang. There was a problem in clang, which has been fixed in more recent versions, where mixing GNU-style attributes with C++-style attributes caused a failure. A recent code change updated a few uses of LLVM_ATTRIBUTE_UNUSED to [[maybe_unused]], triggering this problem.

This change reorders the attributes in a way that avoids the issue.

This fixes a build failure that occurs with some versions of clang. There
was a problem in clang, which has been fixed in more recent versions, where
mixing GNU-style attributes with C++-style attributes caused a failure.
A recent code change updated a few uses of `LLVM_ATTRIBUTE_UNUSED` to
`[[maybe_unused]]`, triggering this problem.

This change reorders the attributes in a way that avoids the issue.
@andykaylor andykaylor requested a review from erichkeane October 17, 2025 17:35
@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels Oct 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 17, 2025

@llvm/pr-subscribers-clang

Author: Andy Kaylor (andykaylor)

Changes

This fixes a build failure that occurs with some versions of clang. There was a problem in clang, which has been fixed in more recent versions, where mixing GNU-style attributes with C++-style attributes caused a failure. A recent code change updated a few uses of LLVM_ATTRIBUTE_UNUSED to [[maybe_unused]], triggering this problem.

This change reorders the attributes in a way that avoids the issue.


Full diff: https://github.com/llvm/llvm-project/pull/163997.diff

1 Files Affected:

  • (modified) clang/lib/CIR/CodeGen/CIRGenValue.h (+6-3)
diff --git a/clang/lib/CIR/CodeGen/CIRGenValue.h b/clang/lib/CIR/CodeGen/CIRGenValue.h
index 08d9913c09c38..d8fac76a0bd03 100644
--- a/clang/lib/CIR/CodeGen/CIRGenValue.h
+++ b/clang/lib/CIR/CodeGen/CIRGenValue.h
@@ -307,8 +307,9 @@ class AggValueSlot {
   /// This is set to true if some external code is responsible for setting up a
   /// destructor for the slot.  Otherwise the code which constructs it should
   /// push the appropriate cleanup.
+  [[maybe_unused]] 
   LLVM_PREFERRED_TYPE(bool)
-  [[maybe_unused]] unsigned destructedFlag : 1;
+  unsigned destructedFlag : 1;
 
   /// This is set to true if the memory in the slot is known to be zero before
   /// the assignment into it.  This means that zero fields don't need to be set.
@@ -326,16 +327,18 @@ class AggValueSlot {
   /// over.  Since it's invalid in general to memcpy a non-POD C++
   /// object, it's important that this flag never be set when
   /// evaluating an expression which constructs such an object.
+  [[maybe_unused]] 
   LLVM_PREFERRED_TYPE(bool)
-  [[maybe_unused]] unsigned aliasedFlag : 1;
+  unsigned aliasedFlag : 1;
 
   /// This is set to true if the tail padding of this slot might overlap
   /// another object that may have already been initialized (and whose
   /// value must be preserved by this initialization). If so, we may only
   /// store up to the dsize of the type. Otherwise we can widen stores to
   /// the size of the type.
+  [[maybe_unused]] 
   LLVM_PREFERRED_TYPE(bool)
-  [[maybe_unused]] unsigned overlapFlag : 1;
+  unsigned overlapFlag : 1;
 
 public:
   enum IsDestructed_t { IsNotDestructed, IsDestructed };

@llvmbot
Copy link
Member

llvmbot commented Oct 17, 2025

@llvm/pr-subscribers-clangir

Author: Andy Kaylor (andykaylor)

Changes

This fixes a build failure that occurs with some versions of clang. There was a problem in clang, which has been fixed in more recent versions, where mixing GNU-style attributes with C++-style attributes caused a failure. A recent code change updated a few uses of LLVM_ATTRIBUTE_UNUSED to [[maybe_unused]], triggering this problem.

This change reorders the attributes in a way that avoids the issue.


Full diff: https://github.com/llvm/llvm-project/pull/163997.diff

1 Files Affected:

  • (modified) clang/lib/CIR/CodeGen/CIRGenValue.h (+6-3)
diff --git a/clang/lib/CIR/CodeGen/CIRGenValue.h b/clang/lib/CIR/CodeGen/CIRGenValue.h
index 08d9913c09c38..d8fac76a0bd03 100644
--- a/clang/lib/CIR/CodeGen/CIRGenValue.h
+++ b/clang/lib/CIR/CodeGen/CIRGenValue.h
@@ -307,8 +307,9 @@ class AggValueSlot {
   /// This is set to true if some external code is responsible for setting up a
   /// destructor for the slot.  Otherwise the code which constructs it should
   /// push the appropriate cleanup.
+  [[maybe_unused]] 
   LLVM_PREFERRED_TYPE(bool)
-  [[maybe_unused]] unsigned destructedFlag : 1;
+  unsigned destructedFlag : 1;
 
   /// This is set to true if the memory in the slot is known to be zero before
   /// the assignment into it.  This means that zero fields don't need to be set.
@@ -326,16 +327,18 @@ class AggValueSlot {
   /// over.  Since it's invalid in general to memcpy a non-POD C++
   /// object, it's important that this flag never be set when
   /// evaluating an expression which constructs such an object.
+  [[maybe_unused]] 
   LLVM_PREFERRED_TYPE(bool)
-  [[maybe_unused]] unsigned aliasedFlag : 1;
+  unsigned aliasedFlag : 1;
 
   /// This is set to true if the tail padding of this slot might overlap
   /// another object that may have already been initialized (and whose
   /// value must be preserved by this initialization). If so, we may only
   /// store up to the dsize of the type. Otherwise we can widen stores to
   /// the size of the type.
+  [[maybe_unused]] 
   LLVM_PREFERRED_TYPE(bool)
-  [[maybe_unused]] unsigned overlapFlag : 1;
+  unsigned overlapFlag : 1;
 
 public:
   enum IsDestructed_t { IsNotDestructed, IsDestructed };

Copy link

github-actions bot commented Oct 17, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@xlauko xlauko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@andykaylor andykaylor merged commit e101afc into llvm:main Oct 17, 2025
8 of 9 checks passed
@andykaylor andykaylor deleted the maybe-unused-fix branch October 17, 2025 20:34
@kazutakahirata
Copy link
Contributor

@andykaylor Thank you for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants