[clang] [clang][AST] Hash `AttributedType`'s `Attr` by Arguments (PR #200961)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 8 09:18:52 PDT 2026


================
@@ -376,4 +376,88 @@ bool areAlignedAttrsEqual(const AlignedAttr &A1, const AlignedAttr &A2,
 }
 } // namespace
 
+namespace {
+// Machinery to unique attributes based on the arguments.
+// The construction mirrors the equivalent testing code above.
+// The content of the arguments are added to the FoldingSetNodeID instance,
+// which allows the AttributedTypes to unique the attributes based on
+// the value of the arguments.
+
+#define USE_DEFAULT_PROFILE                                                    \
+  (std::is_same_v<T, StringRef> || std::is_same_v<T, VersionTuple> ||          \
+   std::is_same_v<T, IdentifierInfo *> ||                                      \
+   std::is_same_v<T, const IdentifierInfo *> || std::is_enum_v<T> ||           \
+   std::is_integral_v<T>)
+
+template <class T>
+typename std::enable_if_t<!USE_DEFAULT_PROFILE>
+profileAttrArg(llvm::FoldingSetNodeID &, const ASTContext &, T) {}
----------------
Xazax-hun wrote:

Is it OK to silently not do anything for some types? Or should this be a declaration only to trigger a linker error in that case?

https://github.com/llvm/llvm-project/pull/200961


More information about the cfe-commits mailing list