vsapsai created this revision.
vsapsai added reviewers: rsmith, riccibruno.
Herald added a subscriber: ributzka.
vsapsai requested review of this revision.
Herald added a project: clang.

FastTypeQuals are used only by FunctionProtoType and put in
FunctionTypeBitfields in FunctionType to pack with the other bitfields.
So in ODR-hashing they should be used only for FunctionProtoType but not
for FunctionNoProtoType or for common FunctionType.

rdar://65305646


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104963

Files:
  clang/lib/AST/ODRHash.cpp
  clang/test/Modules/odr_hash-record.c


Index: clang/test/Modules/odr_hash-record.c
===================================================================
--- clang/test/Modules/odr_hash-record.c
+++ clang/test/Modules/odr_hash-record.c
@@ -381,6 +381,21 @@
 struct TSS1 *tss1;
 #endif
 
+// Function pointer in a struct.
+#if defined(FIRST)
+typedef void (*HandlerProcPtr)();
+struct Handler {
+    HandlerProcPtr procPtr;
+};
+#elif defined(SECOND)
+typedef void (*HandlerProcPtr)();
+struct Handler {
+    HandlerProcPtr procPtr;
+};
+#else
+struct Handler h;
+#endif
+
 // Keep macros contained to one file.
 #ifdef FIRST
 #undef FIRST
Index: clang/lib/AST/ODRHash.cpp
===================================================================
--- clang/lib/AST/ODRHash.cpp
+++ clang/lib/AST/ODRHash.cpp
@@ -910,9 +910,6 @@
   void VisitFunctionType(const FunctionType *T) {
     AddQualType(T->getReturnType());
     T->getExtInfo().Profile(ID);
-    Hash.AddBoolean(T->isConst());
-    Hash.AddBoolean(T->isVolatile());
-    Hash.AddBoolean(T->isRestrict());
     VisitType(T);
   }
 
@@ -921,6 +918,9 @@
   }
 
   void VisitFunctionProtoType(const FunctionProtoType *T) {
+    Hash.AddBoolean(T->isConst());
+    Hash.AddBoolean(T->isVolatile());
+    Hash.AddBoolean(T->isRestrict());
     ID.AddInteger(T->getNumParams());
     for (auto ParamType : T->getParamTypes())
       AddQualType(ParamType);


Index: clang/test/Modules/odr_hash-record.c
===================================================================
--- clang/test/Modules/odr_hash-record.c
+++ clang/test/Modules/odr_hash-record.c
@@ -381,6 +381,21 @@
 struct TSS1 *tss1;
 #endif
 
+// Function pointer in a struct.
+#if defined(FIRST)
+typedef void (*HandlerProcPtr)();
+struct Handler {
+    HandlerProcPtr procPtr;
+};
+#elif defined(SECOND)
+typedef void (*HandlerProcPtr)();
+struct Handler {
+    HandlerProcPtr procPtr;
+};
+#else
+struct Handler h;
+#endif
+
 // Keep macros contained to one file.
 #ifdef FIRST
 #undef FIRST
Index: clang/lib/AST/ODRHash.cpp
===================================================================
--- clang/lib/AST/ODRHash.cpp
+++ clang/lib/AST/ODRHash.cpp
@@ -910,9 +910,6 @@
   void VisitFunctionType(const FunctionType *T) {
     AddQualType(T->getReturnType());
     T->getExtInfo().Profile(ID);
-    Hash.AddBoolean(T->isConst());
-    Hash.AddBoolean(T->isVolatile());
-    Hash.AddBoolean(T->isRestrict());
     VisitType(T);
   }
 
@@ -921,6 +918,9 @@
   }
 
   void VisitFunctionProtoType(const FunctionProtoType *T) {
+    Hash.AddBoolean(T->isConst());
+    Hash.AddBoolean(T->isVolatile());
+    Hash.AddBoolean(T->isRestrict());
     ID.AddInteger(T->getNumParams());
     for (auto ParamType : T->getParamTypes())
       AddQualType(ParamType);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D104963: [ODR] Fi... Volodymyr Sapsai via Phabricator via cfe-commits

Reply via email to