[PATCH] D54048: [AST] Get aliased type info from an aliased TemplateSpecialization.

Matt Davis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 3 14:03:34 PDT 2018


mattd updated this revision to Diff 172503.
mattd added a comment.

Thanks for the review @rjmccall.  I have moved the type-alias check into TemplateSpecializationType's desugar method.  I like this solution better.


https://reviews.llvm.org/D54048

Files:
  include/clang/AST/Type.h
  test/SemaCXX/alignof.cpp


Index: test/SemaCXX/alignof.cpp
===================================================================
--- test/SemaCXX/alignof.cpp
+++ test/SemaCXX/alignof.cpp
@@ -97,3 +97,8 @@
   typedef __attribute__((aligned(N))) int Field[sizeof(N)]; // expected-error {{requested alignment is dependent but declaration is not dependent}}
 };
 }
+
+typedef int __attribute__((aligned(16))) aligned_int;
+template <typename>
+using template_alias = aligned_int;
+static_assert(alignof(template_alias<void>) == 16, "Expected alignment of 16" );
Index: include/clang/AST/Type.h
===================================================================
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -4901,7 +4901,9 @@
     return !isDependentType() || isCurrentInstantiation() || isTypeAlias();
   }
 
-  QualType desugar() const { return getCanonicalTypeInternal(); }
+  QualType desugar() const {
+    return isTypeAlias() ? getAliasedType() : getCanonicalTypeInternal();
+  }
 
   void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx) {
     Profile(ID, Template, template_arguments(), Ctx);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54048.172503.patch
Type: text/x-patch
Size: 1096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181103/010a9e50/attachment.bin>


More information about the cfe-commits mailing list