[clang] [clang] Fix elaborated keyword canonicalization (PR #135916)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 16 09:17:11 PDT 2025


================
@@ -2838,6 +2838,18 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   /// immediately following this class.
   template <typename T> const T *getAs() const;
 
+  /// Look through sugar for an instance of TemplateSpecializationType which
+  /// is not a type alias.
+  const TemplateSpecializationType *
+  getAsNonAliasTemplateSpecializationType() const;
+
+  const TemplateSpecializationType *
+  castAsNonAliasTemplateSpecializationType() const {
+    auto TST = getAsNonAliasTemplateSpecializationType();
----------------
mizvekov wrote:

Yeah this automates a part of analysis with sugar which is very easy to get wrong.
If you are looking for a class template specialization and you want to get its as-written arguments, then you have to deal with the fact that you might encounter along the way a TST from an alias template (or builtin template) that might be pointing to anything, even an `int`, so it's very easy to get mixed up here.

https://github.com/llvm/llvm-project/pull/135916


More information about the cfe-commits mailing list