[PATCH] D133586: [clang] do not hash undefined qualifiers for FunctionNoProtoType

Richard Howell via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 9 10:01:54 PDT 2022


rmaz created this revision.
Herald added a project: All.
rmaz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When calculating the ODR hash of a `FunctionNoProtoType` do not
include qualifiers derived from `FastTypeQuals`. These are only
defined in the constructor for `FunctionProtoType`.

This change ensures the ODR hash and PCM output is stable for
and modules containing `FunctionNoProtoType`s.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133586

Files:
  clang/lib/AST/ODRHash.cpp


Index: clang/lib/AST/ODRHash.cpp
===================================================================
--- clang/lib/AST/ODRHash.cpp
+++ clang/lib/AST/ODRHash.cpp
@@ -889,9 +889,12 @@
   void VisitFunctionType(const FunctionType *T) {
     AddQualType(T->getReturnType());
     T->getExtInfo().Profile(ID);
-    Hash.AddBoolean(T->isConst());
-    Hash.AddBoolean(T->isVolatile());
-    Hash.AddBoolean(T->isRestrict());
+    if (T->isFunctionProtoType()) {
+      // These values are undefined for FunctionNoProtoType
+      Hash.AddBoolean(T->isConst());
+      Hash.AddBoolean(T->isVolatile());
+      Hash.AddBoolean(T->isRestrict());
+    }
     VisitType(T);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133586.459101.patch
Type: text/x-patch
Size: 670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220909/00599e31/attachment-0001.bin>


More information about the cfe-commits mailing list