diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2025-07-29 14:09:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-29 14:09:02 -0400 |
commit | 30a5d569b2102bba1cfb5d253bd73ec2ebce7ee0 (patch) | |
tree | 80ed2fd6c5937d016d610fa616e77139de89d77c /clang/lib/AST/ASTStructuralEquivalence.cpp | |
parent | 5ae79baab3ed30161654999adfd4a01d5b977726 (diff) | |
download | llvm-30a5d569b2102bba1cfb5d253bd73ec2ebce7ee0.zip llvm-30a5d569b2102bba1cfb5d253bd73ec2ebce7ee0.tar.gz llvm-30a5d569b2102bba1cfb5d253bd73ec2ebce7ee0.tar.bz2 |
[C23] AST equivalence of attributes (#151196)
Implicitly declared types (like __NSConstantString_tag, etc) will be
declared with visibility attributes. This causes problems when merging
ASTs because we currently reject declaration merging for declarations
with attributes.
This relaxes that restriction somewhat; implicit declarations can now
have attributes when merging; we assume that if the compiler generated
it, it's fine.
Diffstat (limited to 'clang/lib/AST/ASTStructuralEquivalence.cpp')
-rw-r--r-- | clang/lib/AST/ASTStructuralEquivalence.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp index 1a7001a..22bb4cb 100644 --- a/clang/lib/AST/ASTStructuralEquivalence.cpp +++ b/clang/lib/AST/ASTStructuralEquivalence.cpp @@ -456,7 +456,9 @@ CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context, const Decl *D1, const Decl *D2, const Decl *PrimaryDecl = nullptr) { // If either declaration has an attribute on it, we treat the declarations - // as not being structurally equivalent. + // as not being structurally equivalent unless both declarations are implicit + // (ones generated by the compiler like __NSConstantString_tag). + // // FIXME: this should be handled on a case-by-case basis via tablegen in // Attr.td. There are multiple cases to consider: one declaration with the // attribute, another without it; different attribute syntax|spellings for @@ -468,7 +470,7 @@ CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context, D1Attr = *D1->getAttrs().begin(); if (D2->hasAttrs()) D2Attr = *D2->getAttrs().begin(); - if (D1Attr || D2Attr) { + if ((D1Attr || D2Attr) && !D1->isImplicit() && !D2->isImplicit()) { const auto *DiagnoseDecl = cast<TypeDecl>(PrimaryDecl ? PrimaryDecl : D2); Context.Diag2(DiagnoseDecl->getLocation(), diag::warn_odr_tag_type_with_attributes) |