[clang-diff] Fix assertion error when dealing with wide strings
authorKaining Zhong <zhongkaining.paxos@bytedance.com>
Tue, 7 Jun 2022 17:39:46 +0000 (19:39 +0200)
committerJohannes Altmanninger <aclopte@gmail.com>
Tue, 7 Jun 2022 18:24:34 +0000 (20:24 +0200)
commite80748ff8840a10bd7c7336eb5e98664480ba1ba
tree0e814d1819703a52b5f6689d0601fbf61ba49b66
parent4561352f7bd972939f19d7ff8462386c97b584ad
[clang-diff] Fix assertion error when dealing with wide strings

Directly using StringLiteral::getString for wide string is not
currently supported; therefore in ASTDiff, getStmtValue will fail when
asserting that the StringLiteral has a width of 1. This patch also
covers cases for UTF16 and UTF32 encoding, along with corresponding
test cases.

Fixes https://github.com/llvm/llvm-project/issues/55771.

Reviewed By: johannes

Differential Revision: https://reviews.llvm.org/D126651
clang/lib/Tooling/ASTDiff/ASTDiff.cpp
clang/test/Tooling/clang-diff-ast.cpp