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

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 29 08:55:02 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/67822.diff


1 Files Affected:

- (modified) clang/lib/AST/StmtProfile.cpp (+2) 


``````````diff
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);

``````````

</details>


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


More information about the cfe-commits mailing list