[clang-tools-extra] [clang-tidy] offer option to check sugared types in avoid-c-arrays check (PR #131468)
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 15 15:13:08 PDT 2025
================
@@ -96,6 +97,26 @@ void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) {
diag(ArrayType->getBeginLoc(),
"do not declare %select{C-style|C VLA}0 arrays, use %1 instead")
<< IsVLA << llvm::join(RecommendTypes, " or ");
+
+ if (CheckSugaredTypes) {
+ PrintingPolicy PrintPolicy{getLangOpts()};
+ PrintPolicy.SuppressTagKeyword = true;
+
+ const auto TypeName = ArrayType->getType().getAsString(PrintPolicy);
+ const auto DesugaredTypeName = ArrayType->getType()
+ ->getUnqualifiedDesugaredType()
+ ->getCanonicalTypeInternal()
----------------
PiotrZSL wrote:
thats internal function, do not use it
use methods from [QualType](https://clang.llvm.org/doxygen/classclang_1_1QualType.html)
https://github.com/llvm/llvm-project/pull/131468
More information about the cfe-commits
mailing list