[clang] [clang] Add missing canonicalization in int literal profile (PR #67822)

Henrik G. Olsson via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 29 08:53:58 PDT 2023


https://github.com/hnrklssn created https://github.com/llvm/llvm-project/pull/67822

The addition of the type kind to the profile ID of IntegerLiterals results in e.g. size_t and unsigned long literals mismatch even on platforms where they are canonically the same type. This patch checks the Canonical field to determine whether to canonicalize the type first.

rdar://116063468

>From 8ebdc7b829a3c2f59ef2773332511c81a40a8e73 Mon Sep 17 00:00:00 2001
From: "Henrik G. Olsson" <hnrklssn at gmail.com>
Date: Fri, 29 Sep 2023 17:33:57 +0200
Subject: [PATCH] [clang] Add missing canonicalization in int literal profile

The addition of the type kind to the profile ID of IntegerLiterals
results in e.g. size_t and unsigned long literals mismatch even on
platforms where they are canonically the same type. This patch checks
the Canonical field to determine whether to canonicalize the type first.

rdar://116063468
---
 clang/lib/AST/StmtProfile.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 2e4f15f83ac26ef..763d3d612698095 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -1335,6 +1335,8 @@ void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
   S->getValue().Profile(ID);
 
   QualType T = S->getType();
+  if (Canonical)
+    T = T.getCanonicalType();
   ID.AddInteger(T->getTypeClass());
   if (auto BitIntT = T->getAs<BitIntType>())
     BitIntT->Profile(ID);



More information about the cfe-commits mailing list