[PATCH] D131466: [clang] add APValue type check in `TryPrintAsStringLiteral`
YingChi Long via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 8 22:22:42 PDT 2022
inclyc created this revision.
Herald added a project: All.
inclyc added reviewers: rsmith, aaron.ballman, shafik.
inclyc updated this revision to Diff 451047.
inclyc added a comment.
inclyc edited the summary of this revision.
inclyc published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
.
Fixes https://github.com/llvm/llvm-project/issues/57013
https://reviews.llvm.org/D115031 improved printing of non-type template
parameter args. But checking if the end of Inits is 0 without checking
if APValue is an integer, causes clang to segfault. This patch adds
the code to check the type. (May not be a proper bugfix.)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131466
Files:
clang/lib/AST/APValue.cpp
Index: clang/lib/AST/APValue.cpp
===================================================================
--- clang/lib/AST/APValue.cpp
+++ clang/lib/AST/APValue.cpp
@@ -637,10 +637,10 @@
return false;
// Nothing we can do about a sequence that is not null-terminated
- if (!Inits.back().getInt().isZero())
+ if (!Inits.back().isInt() || !Inits.back().getInt().isZero())
return false;
- else
- Inits = Inits.drop_back();
+
+ Inits = Inits.drop_back();
llvm::SmallString<40> Buf;
Buf.push_back('"');
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131466.451047.patch
Type: text/x-patch
Size: 524 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220809/d73f80ef/attachment.bin>
More information about the cfe-commits
mailing list