[clang] Avoid printing overly large integer. (PR #75902)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 19 00:05:07 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Nhat Nguyen (changkhothuychung)
<details>
<summary>Changes</summary>
Created a PR to fix issue #<!-- -->71675
---
Full diff: https://github.com/llvm/llvm-project/pull/75902.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+3)
``````````diff
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a3f68d4ffc0f6e..18631ec7dac152 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,6 +17132,9 @@ static bool ConvertAPValueToString(const APValue &V, QualType T,
case BuiltinType::WChar_U: {
unsigned TyWidth = Context.getIntWidth(T);
assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
+ if (V.getInt() >= (1 << 64)) {
+ return false;
+ }
uint32_t CodeUnit = static_cast<uint32_t>(V.getInt().getZExtValue());
WriteCharTypePrefix(BTy->getKind(), OS);
OS << '\'';
``````````
</details>
https://github.com/llvm/llvm-project/pull/75902
More information about the cfe-commits
mailing list