vsapsai updated this revision to Diff 467564.
vsapsai added a comment.

- Small fixes to address review comments.
- Try to make diagnostics more understandable.
- Check attributes on typedefs.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135472/new/

https://reviews.llvm.org/D135472

Files:
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/AST/ODRHash.cpp
  clang/test/Modules/odr_hash.cpp


Index: clang/test/Modules/odr_hash.cpp
===================================================================
--- clang/test/Modules/odr_hash.cpp
+++ clang/test/Modules/odr_hash.cpp
@@ -3788,6 +3788,32 @@
 // expected-note@second.h:* {{attribute specified here}}
 #endif
 
+#if defined(FIRST)
+struct TypedefAttributePresence {
+  typedef double *AlignedDoublePtr __attribute__((align_value(64)));
+};
+struct TypedefDifferentAttributeValue {
+  typedef double *AlignedDoublePtr __attribute__((align_value(64)));
+};
+#elif defined(SECOND)
+struct TypedefAttributePresence {
+  typedef double *AlignedDoublePtr;
+};
+struct TypedefDifferentAttributeValue {
+  typedef double *AlignedDoublePtr __attribute__((align_value(32)));
+};
+#else
+TypedefAttributePresence testTypedefAttrPresence;
+// expected-error@first.h:* {{'Types::Attributes::TypedefAttributePresence' 
has different definitions in different modules; first difference is definition 
in module 'FirstModule' found 'AlignedDoublePtr' with attribute 'align_value'}}
+// expected-note@first.h:* {{attribute specified here}}
+// expected-note@second.h:* {{but in 'SecondModule' found 'AlignedDoublePtr' 
with no attribute}}
+TypedefDifferentAttributeValue testDifferentArgumentsInTypedefAttribute;
+// expected-error@first.h:* 
{{'Types::Attributes::TypedefDifferentAttributeValue' has different definitions 
in different modules; first difference is definition in module 'FirstModule' 
found 'AlignedDoublePtr' with attribute ' __attribute__((align_value(64)))'}}
+// expected-note@first.h:* {{attribute specified here}}
+// expected-note@second.h:* {{but in 'SecondModule' found 'AlignedDoublePtr' 
with different attribute argument ' __attribute__((align_value(32)))'}}
+// expected-note@second.h:* {{attribute specified here}}
+#endif
+
 #if defined(FIRST)
 #define PACKED __attribute__((packed))
 struct PACKED AttributeInMacro {
Index: clang/lib/AST/ODRHash.cpp
===================================================================
--- clang/lib/AST/ODRHash.cpp
+++ clang/lib/AST/ODRHash.cpp
@@ -506,6 +506,14 @@
     }
     break;
   }
+  case attr::AlignValue: {
+    auto *M = cast<AlignValueAttr>(A);
+    Expr *AlignmentExpr = M->getAlignment();
+    ID.AddBoolean(AlignmentExpr);
+    if (AlignmentExpr)
+      AddStmt(AlignmentExpr);
+    break;
+  }
   case attr::EnumExtensibility: {
     auto *M = cast<EnumExtensibilityAttr>(A);
     ID.AddInteger(M->getExtensibility());
Index: clang/lib/AST/ODRDiagsEmitter.cpp
===================================================================
--- clang/lib/AST/ODRDiagsEmitter.cpp
+++ clang/lib/AST/ODRDiagsEmitter.cpp
@@ -193,6 +193,10 @@
     DiagNote(TypedefType) << IsTypeAlias << SecondName << SecondType;
     return true;
   }
+
+  if (diagnoseSubMismatchAttr(FirstRecord, FirstModule, SecondModule, FirstTD,
+                              SecondTD))
+    return true;
   return false;
 }
 


Index: clang/test/Modules/odr_hash.cpp
===================================================================
--- clang/test/Modules/odr_hash.cpp
+++ clang/test/Modules/odr_hash.cpp
@@ -3788,6 +3788,32 @@
 // expected-note@second.h:* {{attribute specified here}}
 #endif
 
+#if defined(FIRST)
+struct TypedefAttributePresence {
+  typedef double *AlignedDoublePtr __attribute__((align_value(64)));
+};
+struct TypedefDifferentAttributeValue {
+  typedef double *AlignedDoublePtr __attribute__((align_value(64)));
+};
+#elif defined(SECOND)
+struct TypedefAttributePresence {
+  typedef double *AlignedDoublePtr;
+};
+struct TypedefDifferentAttributeValue {
+  typedef double *AlignedDoublePtr __attribute__((align_value(32)));
+};
+#else
+TypedefAttributePresence testTypedefAttrPresence;
+// expected-error@first.h:* {{'Types::Attributes::TypedefAttributePresence' has different definitions in different modules; first difference is definition in module 'FirstModule' found 'AlignedDoublePtr' with attribute 'align_value'}}
+// expected-note@first.h:* {{attribute specified here}}
+// expected-note@second.h:* {{but in 'SecondModule' found 'AlignedDoublePtr' with no attribute}}
+TypedefDifferentAttributeValue testDifferentArgumentsInTypedefAttribute;
+// expected-error@first.h:* {{'Types::Attributes::TypedefDifferentAttributeValue' has different definitions in different modules; first difference is definition in module 'FirstModule' found 'AlignedDoublePtr' with attribute ' __attribute__((align_value(64)))'}}
+// expected-note@first.h:* {{attribute specified here}}
+// expected-note@second.h:* {{but in 'SecondModule' found 'AlignedDoublePtr' with different attribute argument ' __attribute__((align_value(32)))'}}
+// expected-note@second.h:* {{attribute specified here}}
+#endif
+
 #if defined(FIRST)
 #define PACKED __attribute__((packed))
 struct PACKED AttributeInMacro {
Index: clang/lib/AST/ODRHash.cpp
===================================================================
--- clang/lib/AST/ODRHash.cpp
+++ clang/lib/AST/ODRHash.cpp
@@ -506,6 +506,14 @@
     }
     break;
   }
+  case attr::AlignValue: {
+    auto *M = cast<AlignValueAttr>(A);
+    Expr *AlignmentExpr = M->getAlignment();
+    ID.AddBoolean(AlignmentExpr);
+    if (AlignmentExpr)
+      AddStmt(AlignmentExpr);
+    break;
+  }
   case attr::EnumExtensibility: {
     auto *M = cast<EnumExtensibilityAttr>(A);
     ID.AddInteger(M->getExtensibility());
Index: clang/lib/AST/ODRDiagsEmitter.cpp
===================================================================
--- clang/lib/AST/ODRDiagsEmitter.cpp
+++ clang/lib/AST/ODRDiagsEmitter.cpp
@@ -193,6 +193,10 @@
     DiagNote(TypedefType) << IsTypeAlias << SecondName << SecondType;
     return true;
   }
+
+  if (diagnoseSubMismatchAttr(FirstRecord, FirstModule, SecondModule, FirstTD,
+                              SecondTD))
+    return true;
   return false;
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to