[clang] [clang] Fix elaborated keyword canonicalization (PR #135916)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 16 06:42:22 PDT 2025
================
@@ -1938,6 +1938,17 @@ TagDecl *Type::getAsTagDecl() const {
return nullptr;
}
+const TemplateSpecializationType *
+Type::getAsNonAliasTemplateSpecializationType() const {
+ for (const auto *T = this; /**/; /**/) {
+ const TemplateSpecializationType *TST =
+ T->getAs<TemplateSpecializationType>();
+ if (!TST || !TST->isTypeAlias())
+ return TST;
+ T = TST->desugar().getTypePtr();
+ }
+}
----------------
erichkeane wrote:
Oof... this is a bit of an abuse of `for` loops/pretending to be a `while`/etc. What about:
```
const auto *TST = this->getAs<TemplateSpecializationType>();
while (TST && TST->isTypeAlias()) {
TST = TST->desugar().getTypePTr();
}
return TST;
```
This would probably ALSO prevent any analysis based warnings of 'not all code paths return'. A little bit of repetition which is not perfect, but perhaps LESS odd?
https://github.com/llvm/llvm-project/pull/135916
More information about the cfe-commits
mailing list